00001
00002
00003
00004
00005
00006
00007 #include "MimePointsImport.h"
00008 #include <QApplication>
00009 #include <QClipboard>
00010 #include "Transformation.h"
00011
00012 MimePointsImport::MimePointsImport ()
00013 {
00014 }
00015
00016 MimePointsImport::~MimePointsImport ()
00017 {
00018 }
00019
00020 void MimePointsImport::retrievePoints (const Transformation &transformation,
00021 QList<QPoint> &points,
00022 QList<double> &ordinals) const
00023 {
00024
00025
00026 const QString TAB_DELIMITER ("\t");
00027
00028 const QClipboard *clipboard = QApplication::clipboard();
00029 QString text = clipboard->text ();
00030 QStringList lines = text.split ("\n");
00031
00032
00033 int ordinal = 0;
00034 for (int i = 0; i < lines.count(); i++) {
00035
00036 QString line = lines.at (i);
00037
00038
00039 QStringList fields = line.split (TAB_DELIMITER);
00040 if (!line.trimmed ().isEmpty () &&
00041 fields.count () == 2) {
00042
00043 QString field0 = fields [0];
00044 QString field1 = fields [1];
00045 bool ok0, ok1;
00046 double value0 = field0.toDouble (&ok0);
00047 double value1 = field1.toDouble (&ok1);
00048 if (ok0 && ok1) {
00049
00050 QPointF pointScreen;
00051 transformation.transformRawGraphToScreen (QPointF (value0, value1),
00052 pointScreen);
00053
00054 points.push_back (pointScreen.toPoint ());
00055 ordinals.push_back (ordinal++);
00056 }
00057 }
00058 }
00059 }