##// END OF EJS Templates
Fixed bug 388...
jeandet -
r14:0e9217f77498 default
parent child
Show More
@@ -0,0 +1,100
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the QLop Software
3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22
23 #include "exptimetabledownloader.h"
24 #include <QFile>
25 #include <QString>
26 #include <QStringList>
27 #include <QDate>
28 #include <QDateTime>
29 #include <QDebug>
30
31 ExpTimeTableDownLoader::ExpTimeTableDownLoader(QObject *parent) : QObject(parent)
32 {
33
34 }
35
36 ExpTimeTableDownLoader::~ExpTimeTableDownLoader()
37 {
38
39 }
40
41 bool ExpTimeTableDownLoader::parseFile(const QString &fileName)
42 {
43 QFile file(fileName);
44 if (!file.open(QIODevice::ReadOnly))
45 return false;
46 m_intervals.clear();
47 while (!file.atEnd())
48 {
49 QString line = file.readLine();
50 ExpXmlDownLoaderIntervals interval;
51 line = line.trimmed();
52 if(!line.contains("AMDA Search:") && (line[0]!='#') && (line.count()>0))
53 {
54 QStringList lineST = line.split(" ");
55 interval.start = lineST.at(0);
56 interval.stop = lineST.at(1);
57 m_intervals.append(interval);
58 }
59 }
60 makeDownloadList();
61 return true;
62 }
63
64 void ExpTimeTableDownLoader::addDaysToDownload(QList<QDate> days)
65 {
66 for(int i=0;i<days.count();i++)
67 {
68 if(!m_FilesToDownload.contains(days.at(i)))
69 {
70 m_FilesToDownload.append(days.at(i));
71 }
72 }
73 }
74
75 const QList<QDate> &ExpTimeTableDownLoader::daysToDownload()
76 {
77 return m_FilesToDownload;
78 }
79
80 void ExpTimeTableDownLoader::makeDownloadList()
81 {
82 for(int i=0;i<m_intervals.count();i++)
83 {
84 QList<QDate> daysToDl;
85 QDateTime start,stop;
86 start=start.fromString(m_intervals[i].start,Qt::ISODate);
87 stop=stop.fromString(m_intervals[i].stop,Qt::ISODate);
88 int days=start.daysTo(stop);
89 daysToDl.append(start.date());
90 if(days)
91 {
92 for(int j=0;j<days;j++)
93 {
94 daysToDl.append(start.addDays(j+1).date());
95 }
96 }
97 addDaysToDownload(daysToDl);
98 }
99 qDebug()<<m_FilesToDownload.count();
100 }
@@ -0,0 +1,47
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the QLop Software
3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #ifndef EXPTIMETABLEDOWNLOADER_H
23 #define EXPTIMETABLEDOWNLOADER_H
24
25 #include <QObject>
26 #include "expxmldownloader.h"
27
28 class ExpTimeTableDownLoader : public QObject
29 {
30 Q_OBJECT
31 public:
32 explicit ExpTimeTableDownLoader(QObject *parent = 0);
33 ~ExpTimeTableDownLoader();
34 bool parseFile(const QString &fileName);
35 const QList<QDate>& daysToDownload();
36 signals:
37
38 public slots:
39 private:
40
41 QList<ExpXmlDownLoaderIntervals> m_intervals;
42 QList<QDate> m_FilesToDownload;
43 void makeDownloadList();
44 void addDaysToDownload(QList<QDate> days);
45 };
46
47 #endif // EXPTIMETABLEDOWNLOADER_H
@@ -27,6 +27,8 INCLUDEPATH += src/QCustomPlot \
27
27
28 QMAKE_CXXFLAGS += -O5 -fopenmp
28 QMAKE_CXXFLAGS += -O5 -fopenmp
29 QMAKE_LFLAGS += -O5 -fopenmp
29 QMAKE_LFLAGS += -O5 -fopenmp
30 #QMAKE_CXXFLAGS += -O0 -fopenmp
31 #QMAKE_LFLAGS += -O0 -fopenmp
30
32
31 SOURCES += src/main.cpp\
33 SOURCES += src/main.cpp\
32 src/mainwindow.cpp \
34 src/mainwindow.cpp \
@@ -56,7 +58,8 SOURCES += src/main.cpp\
56 src/Core/Widgets/qcustomplotvect.cpp \
58 src/Core/Widgets/qcustomplotvect.cpp \
57 src/Core/qlopdatabase.cpp \
59 src/Core/qlopdatabase.cpp \
58 src/Core/Widgets/qlopdatabaseviewer.cpp \
60 src/Core/Widgets/qlopdatabaseviewer.cpp \
59 src/Core/Widgets/qlopdatabaseviewermodel.cpp
61 src/Core/Widgets/qlopdatabaseviewermodel.cpp \
62 src/Cassini/exptimetabledownloader.cpp
60
63
61 HEADERS += src/mainwindow.h \
64 HEADERS += src/mainwindow.h \
62 src/SocExplorerPlot.h \
65 src/SocExplorerPlot.h \
@@ -87,7 +90,8 HEADERS += src/mainwindow.h \
87 src/Core/Widgets/qcustomplotvect.h \
90 src/Core/Widgets/qcustomplotvect.h \
88 src/Core/qlopdatabase.h \
91 src/Core/qlopdatabase.h \
89 src/Core/Widgets/qlopdatabaseviewer.h \
92 src/Core/Widgets/qlopdatabaseviewer.h \
90 src/Core/Widgets/qlopdatabaseviewermodel.h
93 src/Core/Widgets/qlopdatabaseviewermodel.h \
94 src/Cassini/exptimetabledownloader.h
91
95
92 FORMS += src/mainwindow.ui \
96 FORMS += src/mainwindow.ui \
93 src/Core/Widgets/downloadhistory.ui \
97 src/Core/Widgets/downloadhistory.ui \
@@ -1,7 +1,7
1 %global upstream_name qlop-0.1-1
1 %global upstream_name qlop-0.2-1
2
2
3 Name: qlop
3 Name: qlop
4 Version: 0.1
4 Version: 0.2
5 Release: 1%{?dist}
5 Release: 1%{?dist}
6 Summary: QLop is an interactive plotting software, this is an early development preview of what this software will be.
6 Summary: QLop is an interactive plotting software, this is an early development preview of what this software will be.
7 Group: Development/Tools
7 Group: Development/Tools
@@ -30,7 +30,7 Requires(post): qt5-qtxmlpatterns
30 Requires(post): qt5-pythonqt
30 Requires(post): qt5-pythonqt
31 Requires(post): fftw
31 Requires(post): fftw
32
32
33 Provides: qlop = 0.1-1
33 Provides: qlop = 0.2-1
34
34
35 %description
35 %description
36 QLop is an interactive plotting software, this is an early development preview of what this software will be.
36 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}
279
279
280
280
281 %changelog
281 %changelog
282 * Wed Apr 29 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.2
283 - Update source to r14
284
282 * Wed Apr 8 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.1
285 * Wed Apr 8 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.1
283 - Initial Fedora packaging
286 - Initial Fedora packaging
284
287
@@ -33,8 +33,10 CassiniDataDownloader::CassiniDataDownlo
33 {
33 {
34 ui->setupUi(this);
34 ui->setupUi(this);
35 m_xmlLoader = new ExpXmlDownLoader();
35 m_xmlLoader = new ExpXmlDownLoader();
36 m_TTDownLoader = new ExpTimeTableDownLoader();
36 connect(this->ui->calendar,SIGNAL(activated(QDate)),this,SLOT(downloadData(QDate)));
37 connect(this->ui->calendar,SIGNAL(activated(QDate)),this,SLOT(downloadData(QDate)));
37 connect(this->ui->LoadXmlFileQpb,SIGNAL(clicked()),this,SLOT(loadXmlFile()));
38 connect(this->ui->LoadXmlFileQpb,SIGNAL(clicked()),this,SLOT(loadXmlFile()));
39 connect(this->ui->LoadTimeTableQpb,SIGNAL(clicked()),this,SLOT(loadTimeTableFile()));
38 }
40 }
39
41
40 CassiniDataDownloader::~CassiniDataDownloader()
42 CassiniDataDownloader::~CassiniDataDownloader()
@@ -89,3 +91,19 void CassiniDataDownloader::loadXmlFile(
89 }
91 }
90 }
92 }
91 }
93 }
94
95 void CassiniDataDownloader::loadTimeTableFile()
96 {
97 QString file=QFileDialog::getOpenFileName();
98 if(QFile::exists(file))
99 {
100 if(m_TTDownLoader->parseFile(file))
101 {
102 QList<QDate> daysToDl = m_TTDownLoader->daysToDownload();
103 for(int i=0;i<daysToDl.count();i++)
104 {
105 downloadData(daysToDl.at(i));
106 }
107 }
108 }
109 }
@@ -26,6 +26,7
26 #include <QWidget>
26 #include <QWidget>
27 #include <QDate>
27 #include <QDate>
28 #include <expxmldownloader.h>
28 #include <expxmldownloader.h>
29 #include "exptimetabledownloader.h"
29
30
30 namespace Ui {
31 namespace Ui {
31 class CassiniDataDownloader;
32 class CassiniDataDownloader;
@@ -39,14 +40,17 public:
39 explicit CassiniDataDownloader(QWidget *parent = 0);
40 explicit CassiniDataDownloader(QWidget *parent = 0);
40 ~CassiniDataDownloader();
41 ~CassiniDataDownloader();
41
42
43 public slots:
42 protected:
44 protected:
43 void changeEvent(QEvent *e);
45 void changeEvent(QEvent *e);
44 private slots:
46 private slots:
45 void downloadData(const QDate & date );
47 void downloadData(const QDate & date );
48 void loadTimeTableFile();
46 void loadXmlFile();
49 void loadXmlFile();
47 private:
50 private:
48 Ui::CassiniDataDownloader *ui;
51 Ui::CassiniDataDownloader *ui;
49 ExpXmlDownLoader* m_xmlLoader;
52 ExpXmlDownLoader* m_xmlLoader;
53 ExpTimeTableDownLoader* m_TTDownLoader;
50 };
54 };
51
55
52 #endif // CASSINIDATADOWNLOADER_H
56 #endif // CASSINIDATADOWNLOADER_H
@@ -54,7 +54,7
54 </property>
54 </property>
55 </widget>
55 </widget>
56 </item>
56 </item>
57 <item row="1" column="0">
57 <item row="2" column="0">
58 <widget class="QGroupBox" name="groupBox">
58 <widget class="QGroupBox" name="groupBox">
59 <property name="styleSheet">
59 <property name="styleSheet">
60 <string notr="true">QGroupBox {
60 <string notr="true">QGroupBox {
@@ -75,13 +75,20 QGroupBox::title {
75 <layout class="QVBoxLayout" name="verticalLayout"/>
75 <layout class="QVBoxLayout" name="verticalLayout"/>
76 </widget>
76 </widget>
77 </item>
77 </item>
78 <item row="2" column="0">
78 <item row="3" column="0">
79 <widget class="QPushButton" name="startDownloadQpb">
79 <widget class="QPushButton" name="startDownloadQpb">
80 <property name="text">
80 <property name="text">
81 <string>Start Download</string>
81 <string>Start Download</string>
82 </property>
82 </property>
83 </widget>
83 </widget>
84 </item>
84 </item>
85 <item row="1" column="0">
86 <widget class="QPushButton" name="LoadTimeTableQpb">
87 <property name="text">
88 <string>Load a Time Table</string>
89 </property>
90 </widget>
91 </item>
85 </layout>
92 </layout>
86 </widget>
93 </widget>
87 </widget>
94 </widget>
@@ -215,6 +215,9 void CassiniDataFile::readFile()
215 ch1V->unit="nT";
215 ch1V->unit="nT";
216 ch2V->unit="nT";
216 ch2V->unit="nT";
217 ch3V->unit="nT";
217 ch3V->unit="nT";
218 ch1V->source=fileName;
219 ch2V->source=fileName;
220 ch3V->source=fileName;
218 data.append(ch1V);
221 data.append(ch1V);
219 data.append(ch2V);
222 data.append(ch2V);
220 data.append(ch3V);
223 data.append(ch3V);
@@ -290,7 +293,7 void CassiniDataFile::writeFile()
290 {
293 {
291 double key = ch1V->data->at(i).key;
294 double key = ch1V->data->at(i).key;
292 QDateTime date = QDateTime::fromMSecsSinceEpoch(key*1000);
295 QDateTime date = QDateTime::fromMSecsSinceEpoch(key*1000);
293 out << date.toString(Qt::ISODate)+QString(".%1").arg(date.time().msec(),3);
296 out << date.toString(Qt::ISODate)+(QString(".%1").arg(date.time().msec(),3)).replace(" ","0");
294 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);
297 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);
295 out << "\r\n";
298 out << "\r\n";
296 }
299 }
@@ -300,6 +303,7 void CassiniDataFile::writeFile()
300 delete ch1V;
303 delete ch1V;
301 delete ch2V;
304 delete ch2V;
302 delete ch3V;
305 delete ch3V;
306 emit fileWritten();
303 }
307 }
304 }
308 }
305 }
309 }
@@ -36,6 +36,7 public:
36 void saveFile(const QString& fileName,QLopDataList data);
36 void saveFile(const QString& fileName,QLopDataList data);
37 void run();
37 void run();
38 signals:
38 signals:
39 void fileWritten();
39 public slots:
40 public slots:
40
41
41 private :
42 private :
@@ -26,6 +26,7
26 #include <QAction>
26 #include <QAction>
27 #include <fftw3.h>
27 #include <fftw3.h>
28 #include <omp.h>
28 #include <omp.h>
29 #include <qlopdatabase.h>
29
30
30 CassiniTools* CassiniTools::_self=NULL;
31 CassiniTools* CassiniTools::_self=NULL;
31 QDockWidget* CassiniTools::m_gui=NULL;
32 QDockWidget* CassiniTools::m_gui=NULL;
@@ -35,6 +36,7 int CassiniTools::m_defaultPlot=-1;
35 int CassiniTools::m_fftPlot=-1;
36 int CassiniTools::m_fftPlot=-1;
36 SocExplorerPlotActions* CassiniTools::ExportAction=NULL;
37 SocExplorerPlotActions* CassiniTools::ExportAction=NULL;
37
38
39
38 Qt::GlobalColor QLopColours[]= {Qt::black,
40 Qt::GlobalColor QLopColours[]= {Qt::black,
39 Qt::red,
41 Qt::red,
40 Qt::blue,
42 Qt::blue,
@@ -60,6 +62,7 CassiniTools::CassiniTools(bool noGUI,QO
60 {
62 {
61 m_dataFile = new CassiniDataFile();
63 m_dataFile = new CassiniDataFile();
62 connect(m_dataFile,SIGNAL(dataReady(QLopDataList)),this,SLOT(dataReady(QLopDataList)));
64 connect(m_dataFile,SIGNAL(dataReady(QLopDataList)),this,SLOT(dataReady(QLopDataList)));
65 connect(m_dataFile,SIGNAL(fileWritten()),this,SLOT(fileWritten()));
63 m_serviceName="CassiniTools";
66 m_serviceName="CassiniTools";
64 m_noGui=noGUI;
67 m_noGui=noGUI;
65 fftw_init_threads();
68 fftw_init_threads();
@@ -238,7 +241,7 void CassiniTools::compute_fft_on_view(i
238 fftw_free(in);
241 fftw_free(in);
239 for(int i=0;i<ch1V->data->count()/2;i++)
242 for(int i=0;i<ch1V->data->count()/2;i++)
240 {
243 {
241 // (*FFTout->data)[i].value=sqrt((out[i][0] * out[i][0]) + (out[i][1] * out[i][1]))/ch1V->data->count();
244 // (*FFTout->data)[i].value=sqrt((out[i][0] * out[i][0]) + (out[i][1] * out[i][1]))/ch1V->data->count();
242 (*FFTout->data)[i].value=((out[i][0] * out[i][0]) + (out[i][1] * out[i][1]))/(ch1V->data->count());
245 (*FFTout->data)[i].value=((out[i][0] * out[i][0]) + (out[i][1] * out[i][1]))/(ch1V->data->count());
243 (*FFTout->data)[i].key = i;
246 (*FFTout->data)[i].key = i;
244 }
247 }
@@ -295,6 +298,7 const QString &CassiniTools::serviceName
295
298
296 void CassiniTools::dataReady(QLopDataList data)
299 void CassiniTools::dataReady(QLopDataList data)
297 {
300 {
301 static QLopDataList prevData=QLopDataList();
298 SocExplorerPlot* plot = QLopPlots::getPlot(m_defaultPlot);
302 SocExplorerPlot* plot = QLopPlots::getPlot(m_defaultPlot);
299 if(plot==NULL)
303 if(plot==NULL)
300 {
304 {
@@ -303,7 +307,9 void CassiniTools::dataReady(QLopDataLis
303 }
307 }
304 if(plot)
308 if(plot)
305 {
309 {
310 QLopDataBase::removeData(prevData);
306 plot->removeAllGraphs();
311 plot->removeAllGraphs();
312 // QLopDataBase::re
307 for(int i=0;i<data.count();i++)
313 for(int i=0;i<data.count();i++)
308 {
314 {
309 plot->addGraph();
315 plot->addGraph();
@@ -317,6 +323,24 void CassiniTools::dataReady(QLopDataLis
317 }
323 }
318 plot->rescaleAxis();
324 plot->rescaleAxis();
319 plot->replot();
325 plot->replot();
326 prevData = data;
327 QLopDataBase::addData(data);
320 }
328 }
321 }
329 }
322
330
331 void CassiniTools::fileWritten()
332 {
333 SocExplorerPlot* plot = QLopPlots::getPlot(m_defaultPlot);
334 if(plot==NULL)
335 {
336 makePlot();
337 plot = QLopPlots::getPlot(m_defaultPlot);
338 }
339 if(plot)
340 {
341 QString fileName = QString(plot->title()).replace(".TAB","-part");
342 fileName = generateFileName(fileName,".TAB");
343 ExportAction->setText("export view to "+fileName);
344 }
345 }
346
@@ -59,6 +59,7 public slots:
59 private slots:
59 private slots:
60 static QString generateFileName(const QString& baseName,const QString& extension);
60 static QString generateFileName(const QString& baseName,const QString& extension);
61 void dataReady(QLopDataList data);
61 void dataReady(QLopDataList data);
62 void fileWritten();
62 };
63 };
63
64
64 #endif // CASSINITOOLS_H
65 #endif // CASSINITOOLS_H
@@ -8,6 +8,7 QLopDataBaseViewer::QLopDataBaseViewer(Q
8 ui->setupUi(this);
8 ui->setupUi(this);
9 this->model = new QLopDataBaseViewerModel();
9 this->model = new QLopDataBaseViewerModel();
10 this->ui->dataBaseTbleView->setModel(model);
10 this->ui->dataBaseTbleView->setModel(model);
11 connect(QLopDataBase::self(),SIGNAL(DBChanged()),this->model,SLOT(DBChanged()));
11 }
12 }
12
13
13 QLopDataBaseViewer::~QLopDataBaseViewer()
14 QLopDataBaseViewer::~QLopDataBaseViewer()
@@ -27,3 +28,4 void QLopDataBaseViewer::changeEvent(QEv
27 break;
28 break;
28 }
29 }
29 }
30 }
31
@@ -16,7 +16,11
16 <widget class="QWidget" name="dockWidgetContents">
16 <widget class="QWidget" name="dockWidgetContents">
17 <layout class="QGridLayout" name="gridLayout">
17 <layout class="QGridLayout" name="gridLayout">
18 <item row="0" column="0">
18 <item row="0" column="0">
19 <widget class="QTableView" name="dataBaseTbleView"/>
19 <widget class="QTableView" name="dataBaseTbleView">
20 <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
21 <bool>false</bool>
22 </attribute>
23 </widget>
20 </item>
24 </item>
21 </layout>
25 </layout>
22 </widget>
26 </widget>
@@ -19,7 +19,7 int QLopDataBaseViewerModel::rowCount(co
19
19
20 int QLopDataBaseViewerModel::columnCount(const QModelIndex &parent) const
20 int QLopDataBaseViewerModel::columnCount(const QModelIndex &parent) const
21 {
21 {
22 return 3;
22 return 5;
23 }
23 }
24
24
25 QVariant QLopDataBaseViewerModel::data(const QModelIndex &index, int role) const
25 QVariant QLopDataBaseViewerModel::data(const QModelIndex &index, int role) const
@@ -28,14 +28,63 QVariant QLopDataBaseViewerModel::data(c
28 return QVariant();
28 return QVariant();
29 QLopData* data=QLopDataBase::self()->getDataFromIdex(index.row());
29 QLopData* data=QLopDataBase::self()->getDataFromIdex(index.row());
30 if(data)
30 if(data)
31 return data->name;
31 {
32 switch (index.column()) {
33 case 0:
34 return data->name;
35 break;
36 case 1:
37 return data->source;
38 break;
39 case 2:
40 return data->typeStr();
41 break;
42 case 3:
43 return data->unit;
44 break;
45 case 4:
46 return data->size();
47 break;
48 default:
49 return data->name;
50 break;
51 }
52 }
32 else QVariant();
53 else QVariant();
33 }
54 }
34
55
35 QVariant QLopDataBaseViewerModel::headerData(int section, Qt::Orientation orientation, int role) const
56 QVariant QLopDataBaseViewerModel::headerData(int section, Qt::Orientation orientation, int role) const
36 {
57 {
37 if (role == Qt::SizeHintRole)
58 //if (role == Qt::SizeHintRole)
38 return QSize(1, 1);
59 // return QSize(1, 1);
60 if(orientation==Qt::Horizontal && role==Qt::DisplayRole)
61 {
62 switch (section) {
63 case 0:
64 return QVariant("Name");
65 break;
66 case 1:
67 return QVariant("Source");
68 break;
69 case 2:
70 return QVariant("Type");
71 break;
72 case 3:
73 return QVariant("Unit");
74 break;
75 case 4:
76 return QVariant("Size");
77 break;
78 default:
79 break;
80 }
81 }
39 return QVariant();
82 return QVariant();
40 }
83 }
41
84
85 void QLopDataBaseViewerModel::DBChanged()
86 {
87 beginResetModel();
88 endResetModel();
89 }
90
@@ -7,6 +7,7
7
7
8 class QLopDataBaseViewerModel : public QAbstractTableModel
8 class QLopDataBaseViewerModel : public QAbstractTableModel
9 {
9 {
10 Q_OBJECT
10 public:
11 public:
11 QLopDataBaseViewerModel(QObject *parent=0);
12 QLopDataBaseViewerModel(QObject *parent=0);
12 ~QLopDataBaseViewerModel();
13 ~QLopDataBaseViewerModel();
@@ -17,6 +18,8 public:
17 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
18 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
18 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
19 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
19
20
21 public slots:
22 void DBChanged();
20 private:
23 private:
21
24
22 };
25 };
@@ -21,6 +21,14
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22
22
23 #include "qlopdata.h"
23 #include "qlopdata.h"
24 QLopData::QLopDataTypeList_t QLopData::QLopDataTypeList[]=
25 {
26 {Scalar,"Scalar"},
27 {Vector,"Vector"},
28 {Matrix,"Matrix"},
29 {QCPDataVector,"QCPDataVector"},
30 {None,"None"}
31 };
24
32
25 QLopData::QLopData(QObject *parent) : QObject(parent)
33 QLopData::QLopData(QObject *parent) : QObject(parent)
26 {
34 {
@@ -36,11 +36,11 typedef struct dataVector
36 typedef QList<dataVector> QListOfDataVector;
36 typedef QList<dataVector> QListOfDataVector;
37
37
38
38
39
40 class QLopData : public QObject
39 class QLopData : public QObject
41 {
40 {
42 Q_OBJECT
41 Q_OBJECT
43 public:
42 public:
43 #define QLopDataTypeCnt 5
44 typedef enum QLopDataType
44 typedef enum QLopDataType
45 {
45 {
46 Scalar=0,
46 Scalar=0,
@@ -48,15 +48,32 public:
48 Matrix=2,
48 Matrix=2,
49 QCPDataVector=3,
49 QCPDataVector=3,
50 None=-1,
50 None=-1,
51 }
51 }QLopDataType;
52 QLopDataType;
52
53 struct QLopDataTypeList_t
54 {
55 QLopDataType type;
56 const char* typeStr;
57 };
58
59 static struct QLopDataTypeList_t QLopDataTypeList[];
53 explicit QLopData(QObject *parent = 0);
60 explicit QLopData(QObject *parent = 0);
54 ~QLopData();
61 ~QLopData();
55 QString name;
62 QString name;
56 QString source;
63 QString source;
57 QString unit;
64 QString unit;
65 QString typeStr()
66 {
67 for(int i=0;i<QLopDataTypeCnt;i++)
68 {
69 if(QLopDataTypeList[i].type==this->type)
70 return QLopDataTypeList[i].typeStr;
71 }
72 return "Unknow data type";
73 }
58 QLopDataType type;
74 QLopDataType type;
59 int ID;
75 int ID;
76 virtual int size(){return 0;}
60 signals:
77 signals:
61 void dataChanged();
78 void dataChanged();
62 public slots:
79 public slots:
@@ -70,6 +87,7 public:
70 explicit QLopQCPDataVector(QObject *parent = 0);
87 explicit QLopQCPDataVector(QObject *parent = 0);
71 ~QLopQCPDataVector();
88 ~QLopQCPDataVector();
72 QVector<QCPData>* data;
89 QVector<QCPData>* data;
90 int size(){return data->length();}
73 signals:
91 signals:
74 public slots:
92 public slots:
75 private:
93 private:
@@ -82,10 +100,12 public:
82 explicit QLopQVector(QObject *parent = 0);
100 explicit QLopQVector(QObject *parent = 0);
83 ~QLopQVector();
101 ~QLopQVector();
84 QVector<double>* data;
102 QVector<double>* data;
103 int size(){return data->length();}
85 signals:
104 signals:
86 public slots:
105 public slots:
87 private:
106 private:
88 };
107 };
89 typedef QList<QLopData*> QLopDataList;
108 typedef QList<QLopData*> QLopDataList;
90
109
110
91 #endif // QLOPDATA_H
111 #endif // QLOPDATA_H
@@ -1,7 +1,9
1 #include "qlopdatabase.h"
1 #include "qlopdatabase.h"
2 #include <qlopdatabaseviewer.h>
2
3
3 QList<QLopData*>* QLopDataBase::m_dataBase=NULL;
4 QList<QLopData*>* QLopDataBase::m_dataBase=NULL;
4 QLopDataBase* QLopDataBase::_self=NULL;
5 QLopDataBase* QLopDataBase::_self=NULL;
6 QDockWidget* QLopDataBase::m_gui=NULL;
5
7
6 #define INIT() \
8 #define INIT() \
7 if(Q_UNLIKELY(_self==NULL))\
9 if(Q_UNLIKELY(_self==NULL))\
@@ -9,9 +11,11 QLopDataBase* QLopDataBase::_self=NULL;
9 init();\
11 init();\
10 }
12 }
11
13
12 QLopDataBase::QLopDataBase(QObject *parent) : QObject(parent)
14 QLopDataBase::QLopDataBase(bool noGUI,QObject *parent) : QLopService(parent)
13 {
15 {
14 this->m_dataBase = new QList<QLopData*>();
16 this->m_dataBase = new QList<QLopData*>();
17 m_serviceName="QLopDataBase";
18 m_noGui=noGUI;
15 }
19 }
16
20
17 QLopDataBase::~QLopDataBase()
21 QLopDataBase::~QLopDataBase()
@@ -19,17 +23,34 QLopDataBase::~QLopDataBase()
19
23
20 }
24 }
21
25
22 void QLopDataBase::init()
26 QDockWidget *QLopDataBase::getGUI()
27 {
28 if(!m_noGui && (m_gui==NULL))
29 {
30 m_gui=new QLopDataBaseViewer();
31 m_gui->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
32 }
33 return m_gui;
34 }
35
36 void QLopDataBase::init(bool noGUI, QObject *parent)
23 {
37 {
24 _self=new QLopDataBase();
38 _self=new QLopDataBase();
25 }
39 }
26
40
41 const QString &QLopDataBase::serviceName()
42 {
43 INIT();
44 return m_serviceName;
45 }
46
27 int QLopDataBase::addData(QLopData *data)
47 int QLopDataBase::addData(QLopData *data)
28 {
48 {
29 INIT();
49 INIT();
30 if(!m_dataBase->contains(data))
50 if(!m_dataBase->contains(data))
31 {
51 {
32 m_dataBase->append(data);
52 m_dataBase->append(data);
53 emit QLopDataBase::self()->DBChanged();
33 return 1;
54 return 1;
34 }
55 }
35 return 0;
56 return 0;
@@ -43,9 +64,34 int QLopDataBase::addData(const QLopData
43 {
64 {
44 addedData += addData(data.at(i));
65 addedData += addData(data.at(i));
45 }
66 }
67 emit QLopDataBase::self()->DBChanged();
46 return addedData;
68 return addedData;
47 }
69 }
48
70
71 int QLopDataBase::removeData(QLopData *data)
72 {
73 INIT();
74 if(m_dataBase->contains(data))
75 {
76 m_dataBase->removeAll(data);
77 emit QLopDataBase::self()->DBChanged();
78 return 1;
79 }
80 return 0;
81 }
82
83 int QLopDataBase::removeData(const QLopDataList &data)
84 {
85 INIT();
86 int removedData=0;
87 for (int i = 0; i < data.count(); i++)
88 {
89 removedData += removeData(data.at(i));
90 }
91 emit QLopDataBase::self()->DBChanged();
92 return removedData;
93 }
94
49 QLopDataBase *QLopDataBase::self()
95 QLopDataBase *QLopDataBase::self()
50 {
96 {
51 INIT();
97 INIT();
@@ -54,11 +100,13 QLopDataBase *QLopDataBase::self()
54
100
55 int QLopDataBase::count()
101 int QLopDataBase::count()
56 {
102 {
103 INIT();
57 return m_dataBase->count();
104 return m_dataBase->count();
58 }
105 }
59
106
60 QLopData *QLopDataBase::getData(const QString &name)
107 QLopData *QLopDataBase::getData(const QString &name)
61 {
108 {
109 INIT();
62 for (int i = 0; i < m_dataBase->count(); i++)
110 for (int i = 0; i < m_dataBase->count(); i++)
63 {
111 {
64 if(Q_UNLIKELY(m_dataBase->at(i)->name==name))
112 if(Q_UNLIKELY(m_dataBase->at(i)->name==name))
@@ -71,6 +119,7 QLopData *QLopDataBase::getData(const QS
71
119
72 QLopData *QLopDataBase::getData(int ID)
120 QLopData *QLopDataBase::getData(int ID)
73 {
121 {
122 INIT();
74 for (int i = 0; i < m_dataBase->count(); i++)
123 for (int i = 0; i < m_dataBase->count(); i++)
75 {
124 {
76 if(Q_UNLIKELY(m_dataBase->at(i)->ID==ID))
125 if(Q_UNLIKELY(m_dataBase->at(i)->ID==ID))
@@ -4,24 +4,32
4 #include <QObject>
4 #include <QObject>
5 #include <qlopdata.h>
5 #include <qlopdata.h>
6 #include <QList>
6 #include <QList>
7 #include <qlopservice.h>
7
8
8 class QLopDataBase : public QObject
9 class QLopDataBaseViewer;
10
11 class QLopDataBase : public QLopService
9 {
12 {
10 Q_OBJECT
13 Q_OBJECT
11 explicit QLopDataBase(QObject *parent = 0);
14 static QDockWidget* m_gui;
15 QLopDataBase(bool noGUI=false,QObject *parent = 0);
12 ~QLopDataBase();
16 ~QLopDataBase();
13 static QLopDataBase* _self;
17 static QLopDataBase* _self;
14 public:
18 public:
15 static void init();
19 QDockWidget* getGUI();
20 static void init(bool noGUI=false,QObject *parent = 0);
21 const QString& serviceName();
16 static int addData(QLopData* data);
22 static int addData(QLopData* data);
17 static int addData(const QLopDataList &data);
23 static int addData(const QLopDataList &data);
24 static int removeData(QLopData* data);
25 static int removeData(const QLopDataList &data);
18 static QLopDataBase* self();
26 static QLopDataBase* self();
19 static int count();
27 static int count();
20 static QLopData* getData(const QString& name);
28 static QLopData* getData(const QString& name);
21 static QLopData* getData(int ID);
29 static QLopData* getData(int ID);
22 QLopData* getDataFromIdex(int index);
30 QLopData* getDataFromIdex(int index);
23 signals:
31 signals:
24
32 void DBChanged();
25 public slots:
33 public slots:
26 private:
34 private:
27 static QList<QLopData*>* m_dataBase;
35 static QList<QLopData*>* m_dataBase;
@@ -32,8 +32,10
32 #include <filedownloader.h>
32 #include <filedownloader.h>
33 #include <cassinitools.h>
33 #include <cassinitools.h>
34 #include <qlopplots.h>
34 #include <qlopplots.h>
35 #include <qlopdatabase.h>
35
36
36 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
37 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
38 <<QLopDataBase::self()
37 <<FileDownloader::self()
39 <<FileDownloader::self()
38 <<CassiniTools::self()
40 <<CassiniTools::self()
39 << QLopPlots::self();
41 << QLopPlots::self();
General Comments 0
You need to be logged in to leave comments. Login now