# HG changeset patch # User Alexis Jeandet # Date 2015-04-29 09:59:14 # Node ID 0e9217f774985ea3ecc74c17a640bf25d5e37636 # Parent c0cb4ee23d2544023cee321b46cce6823d17546a Fixed bug #388 Added cassini FGM download from Time table files. Fixed smal issue on export function. Some Work on QLop database. diff --git a/QLop.pro b/QLop.pro --- a/QLop.pro +++ b/QLop.pro @@ -27,6 +27,8 @@ INCLUDEPATH += src/QCustomPlot \ QMAKE_CXXFLAGS += -O5 -fopenmp QMAKE_LFLAGS += -O5 -fopenmp +#QMAKE_CXXFLAGS += -O0 -fopenmp +#QMAKE_LFLAGS += -O0 -fopenmp SOURCES += src/main.cpp\ src/mainwindow.cpp \ @@ -56,7 +58,8 @@ SOURCES += src/main.cpp\ src/Core/Widgets/qcustomplotvect.cpp \ src/Core/qlopdatabase.cpp \ src/Core/Widgets/qlopdatabaseviewer.cpp \ - src/Core/Widgets/qlopdatabaseviewermodel.cpp + src/Core/Widgets/qlopdatabaseviewermodel.cpp \ + src/Cassini/exptimetabledownloader.cpp HEADERS += src/mainwindow.h \ src/SocExplorerPlot.h \ @@ -87,7 +90,8 @@ HEADERS += src/mainwindow.h \ src/Core/Widgets/qcustomplotvect.h \ src/Core/qlopdatabase.h \ src/Core/Widgets/qlopdatabaseviewer.h \ - src/Core/Widgets/qlopdatabaseviewermodel.h + src/Core/Widgets/qlopdatabaseviewermodel.h \ + src/Cassini/exptimetabledownloader.h FORMS += src/mainwindow.ui \ src/Core/Widgets/downloadhistory.ui \ diff --git a/linux/QLop.spec b/linux/QLop.spec --- a/linux/QLop.spec +++ b/linux/QLop.spec @@ -1,7 +1,7 @@ -%global upstream_name qlop-0.1-1 +%global upstream_name qlop-0.2-1 Name: qlop -Version: 0.1 +Version: 0.2 Release: 1%{?dist} Summary: QLop is an interactive plotting software, this is an early development preview of what this software will be. Group: Development/Tools @@ -30,7 +30,7 @@ Requires(post): qt5-qtxmlpatterns Requires(post): qt5-pythonqt Requires(post): fftw -Provides: qlop = 0.1-1 +Provides: qlop = 0.2-1 %description QLop is an interactive plotting software, this is an early development preview of what this software will be. @@ -279,6 +279,9 @@ make install INSTALL_ROOT=%{buildroot} %changelog +* Wed Apr 29 2015 Alexis Jeandet - 0.2 +- Update source to r14 + * Wed Apr 8 2015 Alexis Jeandet - 0.1 - Initial Fedora packaging diff --git a/src/Cassini/cassinidatadownloader.cpp b/src/Cassini/cassinidatadownloader.cpp --- a/src/Cassini/cassinidatadownloader.cpp +++ b/src/Cassini/cassinidatadownloader.cpp @@ -33,8 +33,10 @@ CassiniDataDownloader::CassiniDataDownlo { ui->setupUi(this); m_xmlLoader = new ExpXmlDownLoader(); + m_TTDownLoader = new ExpTimeTableDownLoader(); connect(this->ui->calendar,SIGNAL(activated(QDate)),this,SLOT(downloadData(QDate))); connect(this->ui->LoadXmlFileQpb,SIGNAL(clicked()),this,SLOT(loadXmlFile())); + connect(this->ui->LoadTimeTableQpb,SIGNAL(clicked()),this,SLOT(loadTimeTableFile())); } CassiniDataDownloader::~CassiniDataDownloader() @@ -89,3 +91,19 @@ void CassiniDataDownloader::loadXmlFile( } } } + +void CassiniDataDownloader::loadTimeTableFile() +{ + QString file=QFileDialog::getOpenFileName(); + if(QFile::exists(file)) + { + if(m_TTDownLoader->parseFile(file)) + { + QList daysToDl = m_TTDownLoader->daysToDownload(); + for(int i=0;i #include #include +#include "exptimetabledownloader.h" namespace Ui { class CassiniDataDownloader; @@ -39,14 +40,17 @@ public: explicit CassiniDataDownloader(QWidget *parent = 0); ~CassiniDataDownloader(); +public slots: protected: void changeEvent(QEvent *e); private slots: void downloadData(const QDate & date ); + void loadTimeTableFile(); void loadXmlFile(); private: Ui::CassiniDataDownloader *ui; ExpXmlDownLoader* m_xmlLoader; + ExpTimeTableDownLoader* m_TTDownLoader; }; #endif // CASSINIDATADOWNLOADER_H diff --git a/src/Cassini/cassinidatadownloader.ui b/src/Cassini/cassinidatadownloader.ui --- a/src/Cassini/cassinidatadownloader.ui +++ b/src/Cassini/cassinidatadownloader.ui @@ -54,7 +54,7 @@ - + QGroupBox { @@ -75,13 +75,20 @@ QGroupBox::title { - + Start Download + + + + Load a Time Table + + + diff --git a/src/Cassini/cassinidatafile.cpp b/src/Cassini/cassinidatafile.cpp --- a/src/Cassini/cassinidatafile.cpp +++ b/src/Cassini/cassinidatafile.cpp @@ -215,6 +215,9 @@ void CassiniDataFile::readFile() ch1V->unit="nT"; ch2V->unit="nT"; ch3V->unit="nT"; + ch1V->source=fileName; + ch2V->source=fileName; + ch3V->source=fileName; data.append(ch1V); data.append(ch2V); data.append(ch3V); @@ -290,7 +293,7 @@ void CassiniDataFile::writeFile() { double key = ch1V->data->at(i).key; QDateTime date = QDateTime::fromMSecsSinceEpoch(key*1000); - out << date.toString(Qt::ISODate)+QString(".%1").arg(date.time().msec(),3); + out << date.toString(Qt::ISODate)+(QString(".%1").arg(date.time().msec(),3)).replace(" ","0"); 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); out << "\r\n"; } @@ -300,6 +303,7 @@ void CassiniDataFile::writeFile() delete ch1V; delete ch2V; delete ch3V; + emit fileWritten(); } } } diff --git a/src/Cassini/cassinidatafile.h b/src/Cassini/cassinidatafile.h --- a/src/Cassini/cassinidatafile.h +++ b/src/Cassini/cassinidatafile.h @@ -36,6 +36,7 @@ public: void saveFile(const QString& fileName,QLopDataList data); void run(); signals: + void fileWritten(); public slots: private : diff --git a/src/Cassini/cassinitools.cpp b/src/Cassini/cassinitools.cpp --- a/src/Cassini/cassinitools.cpp +++ b/src/Cassini/cassinitools.cpp @@ -26,6 +26,7 @@ #include #include #include +#include CassiniTools* CassiniTools::_self=NULL; QDockWidget* CassiniTools::m_gui=NULL; @@ -35,6 +36,7 @@ int CassiniTools::m_defaultPlot=-1; int CassiniTools::m_fftPlot=-1; SocExplorerPlotActions* CassiniTools::ExportAction=NULL; + Qt::GlobalColor QLopColours[]= {Qt::black, Qt::red, Qt::blue, @@ -60,6 +62,7 @@ CassiniTools::CassiniTools(bool noGUI,QO { m_dataFile = new CassiniDataFile(); connect(m_dataFile,SIGNAL(dataReady(QLopDataList)),this,SLOT(dataReady(QLopDataList))); + connect(m_dataFile,SIGNAL(fileWritten()),this,SLOT(fileWritten())); m_serviceName="CassiniTools"; m_noGui=noGUI; fftw_init_threads(); @@ -238,7 +241,7 @@ void CassiniTools::compute_fft_on_view(i fftw_free(in); for(int i=0;idata->count()/2;i++) { -// (*FFTout->data)[i].value=sqrt((out[i][0] * out[i][0]) + (out[i][1] * out[i][1]))/ch1V->data->count(); + // (*FFTout->data)[i].value=sqrt((out[i][0] * out[i][0]) + (out[i][1] * out[i][1]))/ch1V->data->count(); (*FFTout->data)[i].value=((out[i][0] * out[i][0]) + (out[i][1] * out[i][1]))/(ch1V->data->count()); (*FFTout->data)[i].key = i; } @@ -295,6 +298,7 @@ const QString &CassiniTools::serviceName void CassiniTools::dataReady(QLopDataList data) { + static QLopDataList prevData=QLopDataList(); SocExplorerPlot* plot = QLopPlots::getPlot(m_defaultPlot); if(plot==NULL) { @@ -303,7 +307,9 @@ void CassiniTools::dataReady(QLopDataLis } if(plot) { + QLopDataBase::removeData(prevData); plot->removeAllGraphs(); + // QLopDataBase::re for(int i=0;iaddGraph(); @@ -317,6 +323,24 @@ void CassiniTools::dataReady(QLopDataLis } plot->rescaleAxis(); plot->replot(); + prevData = data; + QLopDataBase::addData(data); } } +void CassiniTools::fileWritten() +{ + SocExplorerPlot* plot = QLopPlots::getPlot(m_defaultPlot); + if(plot==NULL) + { + makePlot(); + plot = QLopPlots::getPlot(m_defaultPlot); + } + if(plot) + { + QString fileName = QString(plot->title()).replace(".TAB","-part"); + fileName = generateFileName(fileName,".TAB"); + ExportAction->setText("export view to "+fileName); + } +} + diff --git a/src/Cassini/cassinitools.h b/src/Cassini/cassinitools.h --- a/src/Cassini/cassinitools.h +++ b/src/Cassini/cassinitools.h @@ -59,6 +59,7 @@ public slots: private slots: static QString generateFileName(const QString& baseName,const QString& extension); void dataReady(QLopDataList data); + void fileWritten(); }; #endif // CASSINITOOLS_H diff --git a/src/Cassini/exptimetabledownloader.cpp b/src/Cassini/exptimetabledownloader.cpp new file mode 100644 --- /dev/null +++ b/src/Cassini/exptimetabledownloader.cpp @@ -0,0 +1,100 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the QLop Software +-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ + +#include "exptimetabledownloader.h" +#include +#include +#include +#include +#include +#include + +ExpTimeTableDownLoader::ExpTimeTableDownLoader(QObject *parent) : QObject(parent) +{ + +} + +ExpTimeTableDownLoader::~ExpTimeTableDownLoader() +{ + +} + +bool ExpTimeTableDownLoader::parseFile(const QString &fileName) +{ + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) + return false; + m_intervals.clear(); + while (!file.atEnd()) + { + QString line = file.readLine(); + ExpXmlDownLoaderIntervals interval; + line = line.trimmed(); + if(!line.contains("AMDA Search:") && (line[0]!='#') && (line.count()>0)) + { + QStringList lineST = line.split(" "); + interval.start = lineST.at(0); + interval.stop = lineST.at(1); + m_intervals.append(interval); + } + } + makeDownloadList(); + return true; +} + +void ExpTimeTableDownLoader::addDaysToDownload(QList days) +{ + for(int i=0;i &ExpTimeTableDownLoader::daysToDownload() +{ + return m_FilesToDownload; +} + +void ExpTimeTableDownLoader::makeDownloadList() +{ + for(int i=0;i daysToDl; + QDateTime start,stop; + start=start.fromString(m_intervals[i].start,Qt::ISODate); + stop=stop.fromString(m_intervals[i].stop,Qt::ISODate); + int days=start.daysTo(stop); + daysToDl.append(start.date()); + if(days) + { + for(int j=0;j +#include "expxmldownloader.h" + +class ExpTimeTableDownLoader : public QObject +{ + Q_OBJECT +public: + explicit ExpTimeTableDownLoader(QObject *parent = 0); + ~ExpTimeTableDownLoader(); + bool parseFile(const QString &fileName); + const QList& daysToDownload(); +signals: + +public slots: +private: + + QList m_intervals; + QList m_FilesToDownload; + void makeDownloadList(); + void addDaysToDownload(QList days); +}; + +#endif // EXPTIMETABLEDOWNLOADER_H diff --git a/src/Core/Widgets/qlopdatabaseviewer.cpp b/src/Core/Widgets/qlopdatabaseviewer.cpp --- a/src/Core/Widgets/qlopdatabaseviewer.cpp +++ b/src/Core/Widgets/qlopdatabaseviewer.cpp @@ -8,6 +8,7 @@ QLopDataBaseViewer::QLopDataBaseViewer(Q ui->setupUi(this); this->model = new QLopDataBaseViewerModel(); this->ui->dataBaseTbleView->setModel(model); + connect(QLopDataBase::self(),SIGNAL(DBChanged()),this->model,SLOT(DBChanged())); } QLopDataBaseViewer::~QLopDataBaseViewer() @@ -27,3 +28,4 @@ void QLopDataBaseViewer::changeEvent(QEv break; } } + diff --git a/src/Core/Widgets/qlopdatabaseviewer.ui b/src/Core/Widgets/qlopdatabaseviewer.ui --- a/src/Core/Widgets/qlopdatabaseviewer.ui +++ b/src/Core/Widgets/qlopdatabaseviewer.ui @@ -16,7 +16,11 @@ - + + + false + + diff --git a/src/Core/Widgets/qlopdatabaseviewermodel.cpp b/src/Core/Widgets/qlopdatabaseviewermodel.cpp --- a/src/Core/Widgets/qlopdatabaseviewermodel.cpp +++ b/src/Core/Widgets/qlopdatabaseviewermodel.cpp @@ -19,7 +19,7 @@ int QLopDataBaseViewerModel::rowCount(co int QLopDataBaseViewerModel::columnCount(const QModelIndex &parent) const { - return 3; + return 5; } QVariant QLopDataBaseViewerModel::data(const QModelIndex &index, int role) const @@ -28,14 +28,63 @@ QVariant QLopDataBaseViewerModel::data(c return QVariant(); QLopData* data=QLopDataBase::self()->getDataFromIdex(index.row()); if(data) - return data->name; + { + switch (index.column()) { + case 0: + return data->name; + break; + case 1: + return data->source; + break; + case 2: + return data->typeStr(); + break; + case 3: + return data->unit; + break; + case 4: + return data->size(); + break; + default: + return data->name; + break; + } + } else QVariant(); } QVariant QLopDataBaseViewerModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::SizeHintRole) - return QSize(1, 1); + //if (role == Qt::SizeHintRole) + // return QSize(1, 1); + if(orientation==Qt::Horizontal && role==Qt::DisplayRole) + { + switch (section) { + case 0: + return QVariant("Name"); + break; + case 1: + return QVariant("Source"); + break; + case 2: + return QVariant("Type"); + break; + case 3: + return QVariant("Unit"); + break; + case 4: + return QVariant("Size"); + break; + default: + break; + } + } return QVariant(); } +void QLopDataBaseViewerModel::DBChanged() +{ + beginResetModel(); + endResetModel(); +} + diff --git a/src/Core/Widgets/qlopdatabaseviewermodel.h b/src/Core/Widgets/qlopdatabaseviewermodel.h --- a/src/Core/Widgets/qlopdatabaseviewermodel.h +++ b/src/Core/Widgets/qlopdatabaseviewermodel.h @@ -7,6 +7,7 @@ class QLopDataBaseViewerModel : public QAbstractTableModel { + Q_OBJECT public: QLopDataBaseViewerModel(QObject *parent=0); ~QLopDataBaseViewerModel(); @@ -17,6 +18,8 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; +public slots: + void DBChanged(); private: }; diff --git a/src/Core/qlopdata.cpp b/src/Core/qlopdata.cpp --- a/src/Core/qlopdata.cpp +++ b/src/Core/qlopdata.cpp @@ -21,6 +21,14 @@ ----------------------------------------------------------------------------*/ #include "qlopdata.h" +QLopData::QLopDataTypeList_t QLopData::QLopDataTypeList[]= + { + {Scalar,"Scalar"}, + {Vector,"Vector"}, + {Matrix,"Matrix"}, + {QCPDataVector,"QCPDataVector"}, + {None,"None"} + }; QLopData::QLopData(QObject *parent) : QObject(parent) { diff --git a/src/Core/qlopdata.h b/src/Core/qlopdata.h --- a/src/Core/qlopdata.h +++ b/src/Core/qlopdata.h @@ -36,11 +36,11 @@ typedef struct dataVector typedef QList QListOfDataVector; - class QLopData : public QObject { Q_OBJECT public: +#define QLopDataTypeCnt 5 typedef enum QLopDataType { Scalar=0, @@ -48,15 +48,32 @@ public: Matrix=2, QCPDataVector=3, None=-1, - } - QLopDataType; + }QLopDataType; + + struct QLopDataTypeList_t + { + QLopDataType type; + const char* typeStr; + }; + + static struct QLopDataTypeList_t QLopDataTypeList[]; explicit QLopData(QObject *parent = 0); ~QLopData(); QString name; QString source; QString unit; + QString typeStr() + { + for(int i=0;itype) + return QLopDataTypeList[i].typeStr; + } + return "Unknow data type"; + } QLopDataType type; int ID; + virtual int size(){return 0;} signals: void dataChanged(); public slots: @@ -70,6 +87,7 @@ public: explicit QLopQCPDataVector(QObject *parent = 0); ~QLopQCPDataVector(); QVector* data; + int size(){return data->length();} signals: public slots: private: @@ -82,10 +100,12 @@ public: explicit QLopQVector(QObject *parent = 0); ~QLopQVector(); QVector* data; + int size(){return data->length();} signals: public slots: private: }; typedef QList QLopDataList; + #endif // QLOPDATA_H diff --git a/src/Core/qlopdatabase.cpp b/src/Core/qlopdatabase.cpp --- a/src/Core/qlopdatabase.cpp +++ b/src/Core/qlopdatabase.cpp @@ -1,7 +1,9 @@ #include "qlopdatabase.h" +#include QList* QLopDataBase::m_dataBase=NULL; QLopDataBase* QLopDataBase::_self=NULL; +QDockWidget* QLopDataBase::m_gui=NULL; #define INIT() \ if(Q_UNLIKELY(_self==NULL))\ @@ -9,9 +11,11 @@ QLopDataBase* QLopDataBase::_self=NULL; init();\ } -QLopDataBase::QLopDataBase(QObject *parent) : QObject(parent) +QLopDataBase::QLopDataBase(bool noGUI,QObject *parent) : QLopService(parent) { this->m_dataBase = new QList(); + m_serviceName="QLopDataBase"; + m_noGui=noGUI; } QLopDataBase::~QLopDataBase() @@ -19,17 +23,34 @@ QLopDataBase::~QLopDataBase() } -void QLopDataBase::init() +QDockWidget *QLopDataBase::getGUI() +{ + if(!m_noGui && (m_gui==NULL)) + { + m_gui=new QLopDataBaseViewer(); + m_gui->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); + } + return m_gui; +} + +void QLopDataBase::init(bool noGUI, QObject *parent) { _self=new QLopDataBase(); } +const QString &QLopDataBase::serviceName() +{ + INIT(); + return m_serviceName; +} + int QLopDataBase::addData(QLopData *data) { INIT(); if(!m_dataBase->contains(data)) { m_dataBase->append(data); + emit QLopDataBase::self()->DBChanged(); return 1; } return 0; @@ -43,9 +64,34 @@ int QLopDataBase::addData(const QLopData { addedData += addData(data.at(i)); } + emit QLopDataBase::self()->DBChanged(); return addedData; } +int QLopDataBase::removeData(QLopData *data) +{ + INIT(); + if(m_dataBase->contains(data)) + { + m_dataBase->removeAll(data); + emit QLopDataBase::self()->DBChanged(); + return 1; + } + return 0; +} + +int QLopDataBase::removeData(const QLopDataList &data) +{ + INIT(); + int removedData=0; + for (int i = 0; i < data.count(); i++) + { + removedData += removeData(data.at(i)); + } + emit QLopDataBase::self()->DBChanged(); + return removedData; +} + QLopDataBase *QLopDataBase::self() { INIT(); @@ -54,11 +100,13 @@ QLopDataBase *QLopDataBase::self() int QLopDataBase::count() { + INIT(); return m_dataBase->count(); } QLopData *QLopDataBase::getData(const QString &name) { + INIT(); for (int i = 0; i < m_dataBase->count(); i++) { if(Q_UNLIKELY(m_dataBase->at(i)->name==name)) @@ -71,6 +119,7 @@ QLopData *QLopDataBase::getData(const QS QLopData *QLopDataBase::getData(int ID) { + INIT(); for (int i = 0; i < m_dataBase->count(); i++) { if(Q_UNLIKELY(m_dataBase->at(i)->ID==ID)) diff --git a/src/Core/qlopdatabase.h b/src/Core/qlopdatabase.h --- a/src/Core/qlopdatabase.h +++ b/src/Core/qlopdatabase.h @@ -4,24 +4,32 @@ #include #include #include +#include -class QLopDataBase : public QObject +class QLopDataBaseViewer; + +class QLopDataBase : public QLopService { Q_OBJECT - explicit QLopDataBase(QObject *parent = 0); + static QDockWidget* m_gui; + QLopDataBase(bool noGUI=false,QObject *parent = 0); ~QLopDataBase(); static QLopDataBase* _self; public: - static void init(); + QDockWidget* getGUI(); + static void init(bool noGUI=false,QObject *parent = 0); + const QString& serviceName(); static int addData(QLopData* data); static int addData(const QLopDataList &data); + static int removeData(QLopData* data); + static int removeData(const QLopDataList &data); static QLopDataBase* self(); static int count(); static QLopData* getData(const QString& name); static QLopData* getData(int ID); QLopData* getDataFromIdex(int index); signals: - + void DBChanged(); public slots: private: static QList* m_dataBase; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -32,8 +32,10 @@ #include #include #include +#include const QListServicesToLoad=QList() + <