diff --git a/src/Cassini/cassinidatafile.cpp b/src/Cassini/cassinidatafile.cpp --- a/src/Cassini/cassinidatafile.cpp +++ b/src/Cassini/cassinidatafile.cpp @@ -161,14 +161,18 @@ double __decodeTimeFromEpochDayOnly(int { struct tm t; time_t t_of_day; - t.tm_year=(1000*(data[ofset] & 0x0F)) + (100*(data[ofset+1] & 0x0F)) + (10*(data[ofset+2] & 0x0F)) + ((data[ofset+3] & 0x0F)) -1900; +// t.tm_year=(1000*(data[ofset] & 0x0F)) + (100*(data[ofset+1] & 0x0F)) + (10*(data[ofset+2] & 0x0F)) + ((data[ofset+3] & 0x0F)) -1900; + t.tm_year=(1000*(data[ofset] & 0x0F)) + (100*(data[ofset+1] & 0x0F)) + (10*(data[ofset+2] & 0x0F)) + ((data[ofset+3] & 0x0F)); t.tm_mon=(10*(data[ofset+5] & 0x0F)) + ((data[ofset+6] & 0x0F)); t.tm_mday=(10*(data[ofset+8] & 0x0F)) + ((data[ofset+9] & 0x0F)); t.tm_hour=0; t.tm_min=0; t.tm_sec=0; - t_of_day = mktime(&t); - return (double)t_of_day; +// t_of_day = mktime(&t); +// return (double)t_of_day; + QDateTime date(QDate(t.tm_year,t.tm_mon,1),QTime(0,0)); +// date.setDate(); + return (double)((date.toMSecsSinceEpoch()/1000.0)-(24*3600)); } void CassiniDataFile::run() diff --git a/src/Cassini/cassinitools.cpp b/src/Cassini/cassinitools.cpp --- a/src/Cassini/cassinitools.cpp +++ b/src/Cassini/cassinitools.cpp @@ -10,6 +10,7 @@ CassiniToolsGUI* CassiniTools::m_Cassini CassiniDataFile* CassiniTools::m_dataFile=NULL; int CassiniTools::m_defaultPlot=-1; int CassiniTools::m_fftPlot=-1; +SocExplorerPlotActions* CassiniTools::ExportAction=NULL; Qt::GlobalColor QLopColours[]= {Qt::black, Qt::red, @@ -61,6 +62,9 @@ void CassiniTools::makePlot() SocExplorerPlotActions* action=new SocExplorerPlotActions("export view",plot->PID(),_self); plot->addAction(action); QObject::connect(action,SIGNAL(triggered(int)),_self,SLOT(export_view(int))); + ExportAction=new SocExplorerPlotActions("export view to "+QString(plot->title()).replace(".TAB","-part.TAB"),plot->PID(),_self); + plot->addAction(ExportAction); + QObject::connect(ExportAction,SIGNAL(triggered(int)),_self,SLOT(export_view_Predefined_FileName(int))); action=new SocExplorerPlotActions("FFT of the current view",plot->PID(),_self); plot->addAction(action); QObject::connect(action,SIGNAL(triggered(int)),_self,SLOT(compute_fft_on_view(int))); @@ -100,7 +104,10 @@ void CassiniTools::plotFile(const QStrin plot = QLopPlots::getPlot(m_defaultPlot); } if(plot) + { plot->setTitle(File); + ExportAction->setText("export view to "+QString(File).replace(".TAB","-part.TAB")); + } } } @@ -116,7 +123,29 @@ void CassiniTools::export_view(int PID) if(plot==NULL) return; { - QString fileName = QFileDialog::getSaveFileName(); + QString fileName = plot->title(); + fileName = QFileDialog::getSaveFileName(0,tr("Set filename"),fileName.replace(".TAB","-part.TAB")); + if(fileName!="") + { + QLopDataList vectors; + for(int i=0;igraphCount();i++) + { + QLopData* vect = new QLopData(); + vect->data = plot->getVisibleData(i); + vectors.append(vect); + } + m_dataFile->saveFile(fileName,vectors); + } + } +} + +void CassiniTools::export_view_Predefined_FileName(int PID) +{ + SocExplorerPlot* plot = QLopPlots::getPlot(PID); + if(plot==NULL) + return; + { + QString fileName = QString(plot->title()).replace(".TAB","-part.TAB"); if(fileName!="") { QLopDataList vectors; diff --git a/src/Cassini/cassinitools.h b/src/Cassini/cassinitools.h --- a/src/Cassini/cassinitools.h +++ b/src/Cassini/cassinitools.h @@ -18,6 +18,7 @@ private: static CassiniToolsGUI* m_CassiniToolsGUI; static CassiniDataFile* m_dataFile; static int m_defaultPlot,m_fftPlot; + static SocExplorerPlotActions* ExportAction; CassiniTools(bool noGUI=false, QObject *parent=0); ~CassiniTools(); static void makePlot(); @@ -32,6 +33,7 @@ public: public slots: void plot_TAB_File(const QString& fileName); void export_view(int PID); + void export_view_Predefined_FileName(int PID); void compute_fft_on_view(int PID); private slots: void dataReady(QLopDataList data); diff --git a/src/SocExplorerPlot.cpp b/src/SocExplorerPlot.cpp --- a/src/SocExplorerPlot.cpp +++ b/src/SocExplorerPlot.cpp @@ -104,10 +104,16 @@ void SocExplorerPlot::setTitle(QString t /*! @todo Function borcken fixe this! */ + this->m_Title = title; emit titleChanged(title); this->repaint(); } +const QString &SocExplorerPlot::title() +{ + return m_Title; +} + void SocExplorerPlot::setXaxisLabel(QString label) { this->m_plot->xAxis->setLabel(label); @@ -201,7 +207,16 @@ void SocExplorerPlot::setGraphName(int g if(graphIndexm_plot->graphCount()) { this->m_plot->graph(graphIndex)->setName(name); + } +} + +const QString &SocExplorerPlot::graphName(int graphIndex) +{ + if(graphIndexm_plot->graphCount()) + { + return this->m_plot->graph(graphIndex)->name(); } + return ""; } diff --git a/src/SocExplorerPlot.h b/src/SocExplorerPlot.h --- a/src/SocExplorerPlot.h +++ b/src/SocExplorerPlot.h @@ -63,6 +63,7 @@ public: explicit SocExplorerPlot(QWidget *parent = 0); ~SocExplorerPlot(); void setTitle(QString title); + const QString& title(); void setXaxisLabel(QString label); void setXaxisLog(); void setXaxisRange(double lower, double upper); @@ -79,6 +80,7 @@ public: int graphCount(); void removeAllGraphs(); void setGraphName(int graphIndex,QString name); + const QString& graphName(int graphIndex); void setGraphData(int graphIndex, QList x, QList y); void setGraphData(int graphIndex, QCPDataMap* data,bool copy = true,bool replot=true); void setGraphData(int graphIndex, QVector *data, bool replot); @@ -125,6 +127,7 @@ private: QRubberBand * mRubberBand; QPoint mOrigin; QList m_actions; + QString m_Title; int m_PID; };