@@ -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 | 28 | QMAKE_CXXFLAGS += -O5 -fopenmp |
|
29 | 29 | QMAKE_LFLAGS += -O5 -fopenmp |
|
30 | #QMAKE_CXXFLAGS += -O0 -fopenmp | |
|
31 | #QMAKE_LFLAGS += -O0 -fopenmp | |
|
30 | 32 | |
|
31 | 33 | SOURCES += src/main.cpp\ |
|
32 | 34 | src/mainwindow.cpp \ |
@@ -56,7 +58,8 SOURCES += src/main.cpp\ | |||
|
56 | 58 | src/Core/Widgets/qcustomplotvect.cpp \ |
|
57 | 59 | src/Core/qlopdatabase.cpp \ |
|
58 | 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 | 64 | HEADERS += src/mainwindow.h \ |
|
62 | 65 | src/SocExplorerPlot.h \ |
@@ -87,7 +90,8 HEADERS += src/mainwindow.h \ | |||
|
87 | 90 | src/Core/Widgets/qcustomplotvect.h \ |
|
88 | 91 | src/Core/qlopdatabase.h \ |
|
89 | 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 | 96 | FORMS += src/mainwindow.ui \ |
|
93 | 97 | src/Core/Widgets/downloadhistory.ui \ |
@@ -1,7 +1,7 | |||
|
1 |
%global upstream_name qlop-0. |
|
|
1 | %global upstream_name qlop-0.2-1 | |
|
2 | 2 | |
|
3 | 3 | Name: qlop |
|
4 |
Version: 0. |
|
|
4 | Version: 0.2 | |
|
5 | 5 | Release: 1%{?dist} |
|
6 | 6 | Summary: QLop is an interactive plotting software, this is an early development preview of what this software will be. |
|
7 | 7 | Group: Development/Tools |
@@ -30,7 +30,7 Requires(post): qt5-qtxmlpatterns | |||
|
30 | 30 | Requires(post): qt5-pythonqt |
|
31 | 31 | Requires(post): fftw |
|
32 | 32 | |
|
33 |
Provides: qlop = 0. |
|
|
33 | Provides: qlop = 0.2-1 | |
|
34 | 34 | |
|
35 | 35 | %description |
|
36 | 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 | 281 | %changelog |
|
282 | * Wed Apr 29 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.2 | |
|
283 | - Update source to r14 | |
|
284 | ||
|
282 | 285 | * Wed Apr 8 2015 Alexis Jeandet <alexis.jeandet@member.fsf.org> - 0.1 |
|
283 | 286 | - Initial Fedora packaging |
|
284 | 287 |
@@ -33,8 +33,10 CassiniDataDownloader::CassiniDataDownlo | |||
|
33 | 33 | { |
|
34 | 34 | ui->setupUi(this); |
|
35 | 35 | m_xmlLoader = new ExpXmlDownLoader(); |
|
36 | m_TTDownLoader = new ExpTimeTableDownLoader(); | |
|
36 | 37 | connect(this->ui->calendar,SIGNAL(activated(QDate)),this,SLOT(downloadData(QDate))); |
|
37 | 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 | 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 | 26 | #include <QWidget> |
|
27 | 27 | #include <QDate> |
|
28 | 28 | #include <expxmldownloader.h> |
|
29 | #include "exptimetabledownloader.h" | |
|
29 | 30 | |
|
30 | 31 | namespace Ui { |
|
31 | 32 | class CassiniDataDownloader; |
@@ -39,14 +40,17 public: | |||
|
39 | 40 | explicit CassiniDataDownloader(QWidget *parent = 0); |
|
40 | 41 | ~CassiniDataDownloader(); |
|
41 | 42 | |
|
43 | public slots: | |
|
42 | 44 | protected: |
|
43 | 45 | void changeEvent(QEvent *e); |
|
44 | 46 | private slots: |
|
45 | 47 | void downloadData(const QDate & date ); |
|
48 | void loadTimeTableFile(); | |
|
46 | 49 | void loadXmlFile(); |
|
47 | 50 | private: |
|
48 | 51 | Ui::CassiniDataDownloader *ui; |
|
49 | 52 | ExpXmlDownLoader* m_xmlLoader; |
|
53 | ExpTimeTableDownLoader* m_TTDownLoader; | |
|
50 | 54 | }; |
|
51 | 55 | |
|
52 | 56 | #endif // CASSINIDATADOWNLOADER_H |
@@ -54,7 +54,7 | |||
|
54 | 54 | </property> |
|
55 | 55 | </widget> |
|
56 | 56 | </item> |
|
57 |
<item row=" |
|
|
57 | <item row="2" column="0"> | |
|
58 | 58 | <widget class="QGroupBox" name="groupBox"> |
|
59 | 59 | <property name="styleSheet"> |
|
60 | 60 | <string notr="true">QGroupBox { |
@@ -75,13 +75,20 QGroupBox::title { | |||
|
75 | 75 | <layout class="QVBoxLayout" name="verticalLayout"/> |
|
76 | 76 | </widget> |
|
77 | 77 | </item> |
|
78 |
<item row=" |
|
|
78 | <item row="3" column="0"> | |
|
79 | 79 | <widget class="QPushButton" name="startDownloadQpb"> |
|
80 | 80 | <property name="text"> |
|
81 | 81 | <string>Start Download</string> |
|
82 | 82 | </property> |
|
83 | 83 | </widget> |
|
84 | 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 | 92 | </layout> |
|
86 | 93 | </widget> |
|
87 | 94 | </widget> |
@@ -215,6 +215,9 void CassiniDataFile::readFile() | |||
|
215 | 215 | ch1V->unit="nT"; |
|
216 | 216 | ch2V->unit="nT"; |
|
217 | 217 | ch3V->unit="nT"; |
|
218 | ch1V->source=fileName; | |
|
219 | ch2V->source=fileName; | |
|
220 | ch3V->source=fileName; | |
|
218 | 221 | data.append(ch1V); |
|
219 | 222 | data.append(ch2V); |
|
220 | 223 | data.append(ch3V); |
@@ -290,7 +293,7 void CassiniDataFile::writeFile() | |||
|
290 | 293 | { |
|
291 | 294 | double key = ch1V->data->at(i).key; |
|
292 | 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 | 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 | 298 | out << "\r\n"; |
|
296 | 299 | } |
@@ -300,6 +303,7 void CassiniDataFile::writeFile() | |||
|
300 | 303 | delete ch1V; |
|
301 | 304 | delete ch2V; |
|
302 | 305 | delete ch3V; |
|
306 | emit fileWritten(); | |
|
303 | 307 | } |
|
304 | 308 | } |
|
305 | 309 | } |
@@ -36,6 +36,7 public: | |||
|
36 | 36 | void saveFile(const QString& fileName,QLopDataList data); |
|
37 | 37 | void run(); |
|
38 | 38 | signals: |
|
39 | void fileWritten(); | |
|
39 | 40 | public slots: |
|
40 | 41 | |
|
41 | 42 | private : |
@@ -26,6 +26,7 | |||
|
26 | 26 | #include <QAction> |
|
27 | 27 | #include <fftw3.h> |
|
28 | 28 | #include <omp.h> |
|
29 | #include <qlopdatabase.h> | |
|
29 | 30 | |
|
30 | 31 | CassiniTools* CassiniTools::_self=NULL; |
|
31 | 32 | QDockWidget* CassiniTools::m_gui=NULL; |
@@ -35,6 +36,7 int CassiniTools::m_defaultPlot=-1; | |||
|
35 | 36 | int CassiniTools::m_fftPlot=-1; |
|
36 | 37 | SocExplorerPlotActions* CassiniTools::ExportAction=NULL; |
|
37 | 38 | |
|
39 | ||
|
38 | 40 | Qt::GlobalColor QLopColours[]= {Qt::black, |
|
39 | 41 | Qt::red, |
|
40 | 42 | Qt::blue, |
@@ -60,6 +62,7 CassiniTools::CassiniTools(bool noGUI,QO | |||
|
60 | 62 | { |
|
61 | 63 | m_dataFile = new CassiniDataFile(); |
|
62 | 64 | connect(m_dataFile,SIGNAL(dataReady(QLopDataList)),this,SLOT(dataReady(QLopDataList))); |
|
65 | connect(m_dataFile,SIGNAL(fileWritten()),this,SLOT(fileWritten())); | |
|
63 | 66 | m_serviceName="CassiniTools"; |
|
64 | 67 | m_noGui=noGUI; |
|
65 | 68 | fftw_init_threads(); |
@@ -295,6 +298,7 const QString &CassiniTools::serviceName | |||
|
295 | 298 | |
|
296 | 299 | void CassiniTools::dataReady(QLopDataList data) |
|
297 | 300 | { |
|
301 | static QLopDataList prevData=QLopDataList(); | |
|
298 | 302 | SocExplorerPlot* plot = QLopPlots::getPlot(m_defaultPlot); |
|
299 | 303 | if(plot==NULL) |
|
300 | 304 | { |
@@ -303,7 +307,9 void CassiniTools::dataReady(QLopDataLis | |||
|
303 | 307 | } |
|
304 | 308 | if(plot) |
|
305 | 309 | { |
|
310 | QLopDataBase::removeData(prevData); | |
|
306 | 311 | plot->removeAllGraphs(); |
|
312 | // QLopDataBase::re | |
|
307 | 313 | for(int i=0;i<data.count();i++) |
|
308 | 314 | { |
|
309 | 315 | plot->addGraph(); |
@@ -317,6 +323,24 void CassiniTools::dataReady(QLopDataLis | |||
|
317 | 323 | } |
|
318 | 324 | plot->rescaleAxis(); |
|
319 | 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 | 59 | private slots: |
|
60 | 60 | static QString generateFileName(const QString& baseName,const QString& extension); |
|
61 | 61 | void dataReady(QLopDataList data); |
|
62 | void fileWritten(); | |
|
62 | 63 | }; |
|
63 | 64 | |
|
64 | 65 | #endif // CASSINITOOLS_H |
@@ -8,6 +8,7 QLopDataBaseViewer::QLopDataBaseViewer(Q | |||
|
8 | 8 | ui->setupUi(this); |
|
9 | 9 | this->model = new QLopDataBaseViewerModel(); |
|
10 | 10 | this->ui->dataBaseTbleView->setModel(model); |
|
11 | connect(QLopDataBase::self(),SIGNAL(DBChanged()),this->model,SLOT(DBChanged())); | |
|
11 | 12 | } |
|
12 | 13 | |
|
13 | 14 | QLopDataBaseViewer::~QLopDataBaseViewer() |
@@ -27,3 +28,4 void QLopDataBaseViewer::changeEvent(QEv | |||
|
27 | 28 | break; |
|
28 | 29 | } |
|
29 | 30 | } |
|
31 |
@@ -16,7 +16,11 | |||
|
16 | 16 | <widget class="QWidget" name="dockWidgetContents"> |
|
17 | 17 | <layout class="QGridLayout" name="gridLayout"> |
|
18 | 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 | 24 | </item> |
|
21 | 25 | </layout> |
|
22 | 26 | </widget> |
@@ -19,7 +19,7 int QLopDataBaseViewerModel::rowCount(co | |||
|
19 | 19 | |
|
20 | 20 | int QLopDataBaseViewerModel::columnCount(const QModelIndex &parent) const |
|
21 | 21 | { |
|
22 |
return |
|
|
22 | return 5; | |
|
23 | 23 | } |
|
24 | 24 | |
|
25 | 25 | QVariant QLopDataBaseViewerModel::data(const QModelIndex &index, int role) const |
@@ -28,14 +28,63 QVariant QLopDataBaseViewerModel::data(c | |||
|
28 | 28 | return QVariant(); |
|
29 | 29 | QLopData* data=QLopDataBase::self()->getDataFromIdex(index.row()); |
|
30 | 30 | if(data) |
|
31 | { | |
|
32 | switch (index.column()) { | |
|
33 | case 0: | |
|
31 | 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 | 53 | else QVariant(); |
|
33 | 54 | } |
|
34 | 55 | |
|
35 | 56 | QVariant QLopDataBaseViewerModel::headerData(int section, Qt::Orientation orientation, int role) const |
|
36 | 57 | { |
|
37 | if (role == Qt::SizeHintRole) | |
|
38 | return QSize(1, 1); | |
|
58 | //if (role == Qt::SizeHintRole) | |
|
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 | 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 | 8 | class QLopDataBaseViewerModel : public QAbstractTableModel |
|
9 | 9 | { |
|
10 | Q_OBJECT | |
|
10 | 11 | public: |
|
11 | 12 | QLopDataBaseViewerModel(QObject *parent=0); |
|
12 | 13 | ~QLopDataBaseViewerModel(); |
@@ -17,6 +18,8 public: | |||
|
17 | 18 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; |
|
18 | 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 | 23 | private: |
|
21 | 24 | |
|
22 | 25 | }; |
@@ -21,6 +21,14 | |||
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | |
|
23 | 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 | 33 | QLopData::QLopData(QObject *parent) : QObject(parent) |
|
26 | 34 | { |
@@ -36,11 +36,11 typedef struct dataVector | |||
|
36 | 36 | typedef QList<dataVector> QListOfDataVector; |
|
37 | 37 | |
|
38 | 38 | |
|
39 | ||
|
40 | 39 | class QLopData : public QObject |
|
41 | 40 | { |
|
42 | 41 | Q_OBJECT |
|
43 | 42 | public: |
|
43 | #define QLopDataTypeCnt 5 | |
|
44 | 44 | typedef enum QLopDataType |
|
45 | 45 | { |
|
46 | 46 | Scalar=0, |
@@ -48,15 +48,32 public: | |||
|
48 | 48 | Matrix=2, |
|
49 | 49 | QCPDataVector=3, |
|
50 | 50 | None=-1, |
|
51 | } | |
|
52 | QLopDataType; | |
|
51 | }QLopDataType; | |
|
52 | ||
|
53 | struct QLopDataTypeList_t | |
|
54 | { | |
|
55 | QLopDataType type; | |
|
56 | const char* typeStr; | |
|
57 | }; | |
|
58 | ||
|
59 | static struct QLopDataTypeList_t QLopDataTypeList[]; | |
|
53 | 60 | explicit QLopData(QObject *parent = 0); |
|
54 | 61 | ~QLopData(); |
|
55 | 62 | QString name; |
|
56 | 63 | QString source; |
|
57 | 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 | 74 | QLopDataType type; |
|
59 | 75 | int ID; |
|
76 | virtual int size(){return 0;} | |
|
60 | 77 | signals: |
|
61 | 78 | void dataChanged(); |
|
62 | 79 | public slots: |
@@ -70,6 +87,7 public: | |||
|
70 | 87 | explicit QLopQCPDataVector(QObject *parent = 0); |
|
71 | 88 | ~QLopQCPDataVector(); |
|
72 | 89 | QVector<QCPData>* data; |
|
90 | int size(){return data->length();} | |
|
73 | 91 | signals: |
|
74 | 92 | public slots: |
|
75 | 93 | private: |
@@ -82,10 +100,12 public: | |||
|
82 | 100 | explicit QLopQVector(QObject *parent = 0); |
|
83 | 101 | ~QLopQVector(); |
|
84 | 102 | QVector<double>* data; |
|
103 | int size(){return data->length();} | |
|
85 | 104 | signals: |
|
86 | 105 | public slots: |
|
87 | 106 | private: |
|
88 | 107 | }; |
|
89 | 108 | typedef QList<QLopData*> QLopDataList; |
|
90 | 109 | |
|
110 | ||
|
91 | 111 | #endif // QLOPDATA_H |
@@ -1,7 +1,9 | |||
|
1 | 1 | #include "qlopdatabase.h" |
|
2 | #include <qlopdatabaseviewer.h> | |
|
2 | 3 | |
|
3 | 4 | QList<QLopData*>* QLopDataBase::m_dataBase=NULL; |
|
4 | 5 | QLopDataBase* QLopDataBase::_self=NULL; |
|
6 | QDockWidget* QLopDataBase::m_gui=NULL; | |
|
5 | 7 | |
|
6 | 8 | #define INIT() \ |
|
7 | 9 | if(Q_UNLIKELY(_self==NULL))\ |
@@ -9,9 +11,11 QLopDataBase* QLopDataBase::_self=NULL; | |||
|
9 | 11 | init();\ |
|
10 | 12 | } |
|
11 | 13 | |
|
12 |
QLopDataBase::QLopDataBase(QObject *parent) : Q |
|
|
14 | QLopDataBase::QLopDataBase(bool noGUI,QObject *parent) : QLopService(parent) | |
|
13 | 15 | { |
|
14 | 16 | this->m_dataBase = new QList<QLopData*>(); |
|
17 | m_serviceName="QLopDataBase"; | |
|
18 | m_noGui=noGUI; | |
|
15 | 19 | } |
|
16 | 20 | |
|
17 | 21 | QLopDataBase::~QLopDataBase() |
@@ -19,17 +23,34 QLopDataBase::~QLopDataBase() | |||
|
19 | 23 | |
|
20 | 24 | } |
|
21 | 25 | |
|
22 |
|
|
|
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 | 38 | _self=new QLopDataBase(); |
|
25 | 39 | } |
|
26 | 40 | |
|
41 | const QString &QLopDataBase::serviceName() | |
|
42 | { | |
|
43 | INIT(); | |
|
44 | return m_serviceName; | |
|
45 | } | |
|
46 | ||
|
27 | 47 | int QLopDataBase::addData(QLopData *data) |
|
28 | 48 | { |
|
29 | 49 | INIT(); |
|
30 | 50 | if(!m_dataBase->contains(data)) |
|
31 | 51 | { |
|
32 | 52 | m_dataBase->append(data); |
|
53 | emit QLopDataBase::self()->DBChanged(); | |
|
33 | 54 | return 1; |
|
34 | 55 | } |
|
35 | 56 | return 0; |
@@ -43,9 +64,34 int QLopDataBase::addData(const QLopData | |||
|
43 | 64 | { |
|
44 | 65 | addedData += addData(data.at(i)); |
|
45 | 66 | } |
|
67 | emit QLopDataBase::self()->DBChanged(); | |
|
46 | 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 | 95 | QLopDataBase *QLopDataBase::self() |
|
50 | 96 | { |
|
51 | 97 | INIT(); |
@@ -54,11 +100,13 QLopDataBase *QLopDataBase::self() | |||
|
54 | 100 | |
|
55 | 101 | int QLopDataBase::count() |
|
56 | 102 | { |
|
103 | INIT(); | |
|
57 | 104 | return m_dataBase->count(); |
|
58 | 105 | } |
|
59 | 106 | |
|
60 | 107 | QLopData *QLopDataBase::getData(const QString &name) |
|
61 | 108 | { |
|
109 | INIT(); | |
|
62 | 110 | for (int i = 0; i < m_dataBase->count(); i++) |
|
63 | 111 | { |
|
64 | 112 | if(Q_UNLIKELY(m_dataBase->at(i)->name==name)) |
@@ -71,6 +119,7 QLopData *QLopDataBase::getData(const QS | |||
|
71 | 119 | |
|
72 | 120 | QLopData *QLopDataBase::getData(int ID) |
|
73 | 121 | { |
|
122 | INIT(); | |
|
74 | 123 | for (int i = 0; i < m_dataBase->count(); i++) |
|
75 | 124 | { |
|
76 | 125 | if(Q_UNLIKELY(m_dataBase->at(i)->ID==ID)) |
@@ -4,24 +4,32 | |||
|
4 | 4 | #include <QObject> |
|
5 | 5 | #include <qlopdata.h> |
|
6 | 6 | #include <QList> |
|
7 | #include <qlopservice.h> | |
|
7 | 8 | |
|
8 |
class QLopDataBase |
|
|
9 | class QLopDataBaseViewer; | |
|
10 | ||
|
11 | class QLopDataBase : public QLopService | |
|
9 | 12 | { |
|
10 | 13 | Q_OBJECT |
|
11 | explicit QLopDataBase(QObject *parent = 0); | |
|
14 | static QDockWidget* m_gui; | |
|
15 | QLopDataBase(bool noGUI=false,QObject *parent = 0); | |
|
12 | 16 | ~QLopDataBase(); |
|
13 | 17 | static QLopDataBase* _self; |
|
14 | 18 | public: |
|
15 | static void init(); | |
|
19 | QDockWidget* getGUI(); | |
|
20 | static void init(bool noGUI=false,QObject *parent = 0); | |
|
21 | const QString& serviceName(); | |
|
16 | 22 | static int addData(QLopData* data); |
|
17 | 23 | static int addData(const QLopDataList &data); |
|
24 | static int removeData(QLopData* data); | |
|
25 | static int removeData(const QLopDataList &data); | |
|
18 | 26 | static QLopDataBase* self(); |
|
19 | 27 | static int count(); |
|
20 | 28 | static QLopData* getData(const QString& name); |
|
21 | 29 | static QLopData* getData(int ID); |
|
22 | 30 | QLopData* getDataFromIdex(int index); |
|
23 | 31 | signals: |
|
24 | ||
|
32 | void DBChanged(); | |
|
25 | 33 | public slots: |
|
26 | 34 | private: |
|
27 | 35 | static QList<QLopData*>* m_dataBase; |
@@ -32,8 +32,10 | |||
|
32 | 32 | #include <filedownloader.h> |
|
33 | 33 | #include <cassinitools.h> |
|
34 | 34 | #include <qlopplots.h> |
|
35 | #include <qlopdatabase.h> | |
|
35 | 36 | |
|
36 | 37 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() |
|
38 | <<QLopDataBase::self() | |
|
37 | 39 | <<FileDownloader::self() |
|
38 | 40 | <<CassiniTools::self() |
|
39 | 41 | << QLopPlots::self(); |
General Comments 0
You need to be logged in to leave comments.
Login now