##// END OF EJS Templates
plot view export works on cassini fgm data.
jeandet -
r8:c56bc5e5916b default
parent child
Show More
@@ -43,6 +43,15 CassiniDataFile::~CassiniDataFile()
43 void CassiniDataFile::parseFile(const QString &fileName)
43 void CassiniDataFile::parseFile(const QString &fileName)
44 {
44 {
45 this->fileName = fileName;
45 this->fileName = fileName;
46 m_Write = false;
47 this->start();
48 }
49
50 void CassiniDataFile::saveFile(const QString &fileName, QLopDataList data)
51 {
52 this->fileName = fileName;
53 m_Write = true;
54 m_data = data;
46 this->start();
55 this->start();
47 }
56 }
48
57
@@ -164,6 +173,18 double __decodeTimeFromEpochDayOnly(int
164
173
165 void CassiniDataFile::run()
174 void CassiniDataFile::run()
166 {
175 {
176 if(!m_Write)
177 {
178 readFile();
179 }
180 else
181 {
182 writeFile();
183 }
184 }
185
186 void CassiniDataFile::readFile()
187 {
167 FILE* dataFile;
188 FILE* dataFile;
168 dataFile = fopen(fileName.toStdString().c_str(),"r");
189 dataFile = fopen(fileName.toStdString().c_str(),"r");
169
190
@@ -247,3 +268,35 void CassiniDataFile::run()
247 }
268 }
248 }
269 }
249
270
271 void CassiniDataFile::writeFile()
272 {
273 QFile dataFile(fileName);
274 dataFile.open(QIODevice::WriteOnly);
275 QTextStream out(&dataFile);
276 if(dataFile.isOpen())
277 {
278 if(m_data.count()==3)
279 {
280 QLopData* ch1V=m_data.at(0);
281 QLopData* ch2V=m_data.at(1);
282 QLopData* ch3V=m_data.at(2);
283 if(ch1V->data->count()==ch2V->data->count() && ch1V->data->count()==ch3V->data->count())
284 {
285 for(int i=0;i<ch1V->data->count();i++)
286 {
287 double key = ch1V->data->at(i).key;
288 QDateTime date = QDateTime::fromMSecsSinceEpoch(key*1000);
289 out << date.toString(Qt::ISODate)+QString(".%1").arg(date.time().msec(),3);
290 out << QString("%1%2%3").arg(ch1V->data->at(i).value, 11, 'f', 3).arg(ch2V->data->at(i).value, 11, 'f', 3).arg(ch3V->data->at(i).value, 11, 'f', 3);
291 out << "\r\n";
292 }
293 }
294 dataFile.flush();
295 m_data.clear();
296 delete ch1V;
297 delete ch2V;
298 delete ch3V;
299 }
300 }
301 }
302
@@ -33,12 +33,17 public:
33 explicit CassiniDataFile(QObject *parent = 0);
33 explicit CassiniDataFile(QObject *parent = 0);
34 ~CassiniDataFile();
34 ~CassiniDataFile();
35 void parseFile(const QString& fileName);
35 void parseFile(const QString& fileName);
36 void saveFile(const QString& fileName,QLopDataList data);
36 void run();
37 void run();
37 signals:
38 signals:
38 public slots:
39 public slots:
39
40
40 private :
41 private :
42 void readFile();
43 void writeFile();
44 bool m_Write;
41 QString fileName;
45 QString fileName;
46 QLopDataList m_data;
42 };
47 };
43
48
44
49
@@ -57,7 +57,7 void CassiniTools::makePlot()
57 plot->setContextMenuPolicy(Qt::ActionsContextMenu);
57 plot->setContextMenuPolicy(Qt::ActionsContextMenu);
58 SocExplorerPlotActions* action=new SocExplorerPlotActions("export view",plot->PID(),_self);
58 SocExplorerPlotActions* action=new SocExplorerPlotActions("export view",plot->PID(),_self);
59 plot->addAction(action);
59 plot->addAction(action);
60 QObject::connect(action,SIGNAL(triggered()),_self,SLOT(export_view()));
60 QObject::connect(action,SIGNAL(triggered(int)),_self,SLOT(export_view(int)));
61 }
61 }
62 }
62 }
63
63
@@ -111,6 +111,17 void CassiniTools::export_view(int PID)
111 return;
111 return;
112 {
112 {
113 QString fileName = QFileDialog::getSaveFileName();
113 QString fileName = QFileDialog::getSaveFileName();
114 if(fileName!="")
115 {
116 QLopDataList vectors;
117 for(int i=0;i<plot->graphCount();i++)
118 {
119 QLopData* vect = new QLopData();
120 vect->data = plot->getVisibleData(i);
121 vectors.append(vect);
122 }
123 m_dataFile->saveFile(fileName,vectors);
124 }
114 }
125 }
115 }
126 }
116
127
@@ -60,6 +60,16 void QCPGraphVect::setData(QVector<QCPDa
60 }
60 }
61 }
61 }
62
62
63 QVector<QCPData> *QCPGraphVect::getVisibleData()
64 {
65 QVector<QCPData>* data = new QVector<QCPData>();
66 bool mAdaptiveSampling_save = mAdaptiveSampling;
67 mAdaptiveSampling = false;
68 getPreparedData(data,NULL);
69 mAdaptiveSampling = mAdaptiveSampling_save;
70 return data;
71 }
72
63 void QCPGraphVect::draw(QCPPainter *painter)
73 void QCPGraphVect::draw(QCPPainter *painter)
64 {
74 {
65 if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; }
75 if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; }
@@ -12,6 +12,7 public:
12 ~QCPGraphVect();
12 ~QCPGraphVect();
13 QVector<QCPData> *data() const { return mData; }
13 QVector<QCPData> *data() const { return mData; }
14 void setData(QVector<QCPData> *data);
14 void setData(QVector<QCPData> *data);
15 QVector<QCPData>* getVisibleData();
15 protected:
16 protected:
16 QVector<QCPData>* mData;
17 QVector<QCPData>* mData;
17 virtual void draw(QCPPainter *painter);
18 virtual void draw(QCPPainter *painter);
@@ -93,8 +93,8 void SocExplorerPlot::addAction(SocExplo
93
93
94 QVector<QCPData> *SocExplorerPlot::getVisibleData(int graphIndex)
94 QVector<QCPData> *SocExplorerPlot::getVisibleData(int graphIndex)
95 {
95 {
96 QVector<QCPData> *wholeData=((QCPGraphVect*)m_plot->graph(graphIndex))->data();
96 QVector<QCPData> *visibleData=((QCPGraphVect*)m_plot->graph(graphIndex))->getVisibleData();
97 // m_plot->xAxis->
97 return visibleData;
98 }
98 }
99
99
100 void SocExplorerPlot::setTitle(QString title)
100 void SocExplorerPlot::setTitle(QString title)
General Comments 0
You need to be logged in to leave comments. Login now