@@ -0,0 +1,46 | |||||
|
1 | #ifndef SCIQLOP_METATYPES_H | |||
|
2 | #define SCIQLOP_METATYPES_H | |||
|
3 | ||||
|
4 | #include <QMetaType> | |||
|
5 | ||||
|
6 | /** | |||
|
7 | * Struct used to create an instance that registers a type in Qt for signals / slots mechanism | |||
|
8 | * @tparam T the type to register | |||
|
9 | */ | |||
|
10 | template <typename T> | |||
|
11 | struct MetaTypeRegistry { | |||
|
12 | explicit MetaTypeRegistry() { qRegisterMetaType<T>(); } | |||
|
13 | }; | |||
|
14 | ||||
|
15 | /** | |||
|
16 | * This macro can be used to : | |||
|
17 | * - declare a type as a Qt meta type | |||
|
18 | * - and register it (through a static instance) at the launch of SciQlop, so it can be passed in | |||
|
19 | * Qt signals/slots | |||
|
20 | * | |||
|
21 | * It can be used both in .h or in .cpp files | |||
|
22 | * | |||
|
23 | * @param NAME name of the instance under which the type will be registered (in uppercase) | |||
|
24 | * @param TYPE type to register | |||
|
25 | * | |||
|
26 | * Example: | |||
|
27 | * ~~~cpp | |||
|
28 | * // The following macro : | |||
|
29 | * // - declares std::shared_ptr<Variable> as a Qt meta type | |||
|
30 | * // - registers it through an instance named VAR_SHARED_PTR | |||
|
31 | * SCIQLOP_REGISTER_META_TYPE(VAR_SHARED_PTR, std::shared_ptr<Variable>) | |||
|
32 | * | |||
|
33 | * // The following macro : | |||
|
34 | * // - declares a raw pointer of Variable as a Qt meta type | |||
|
35 | * // - registers it through an instance named VAR_RAW_PTR | |||
|
36 | * SCIQLOP_REGISTER_META_TYPE(VAR_RAW_PTR, Variable*) | |||
|
37 | * ~~~ | |||
|
38 | * | |||
|
39 | */ | |||
|
40 | // clang-format off | |||
|
41 | #define SCIQLOP_REGISTER_META_TYPE(NAME, TYPE) \ | |||
|
42 | Q_DECLARE_METATYPE(TYPE) \ | |||
|
43 | const auto NAME = MetaTypeRegistry<TYPE>{}; \ | |||
|
44 | // clang-format on | |||
|
45 | ||||
|
46 | #endif // SCIQLOP_METATYPES_H |
@@ -1,261 +1,259 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SciQLop Software |
|
2 | -- This file is a part of the SciQLop Software | |
3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
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 |
|
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 |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
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 |
|
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 |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "MainWindow.h" |
|
22 | #include "MainWindow.h" | |
23 | #include "ui_MainWindow.h" |
|
23 | #include "ui_MainWindow.h" | |
24 |
|
24 | |||
25 | #include <DataSource/DataSourceController.h> |
|
25 | #include <DataSource/DataSourceController.h> | |
26 | #include <DataSource/DataSourceWidget.h> |
|
26 | #include <DataSource/DataSourceWidget.h> | |
27 | #include <SidePane/SqpSidePane.h> |
|
27 | #include <SidePane/SqpSidePane.h> | |
28 | #include <SqpApplication.h> |
|
28 | #include <SqpApplication.h> | |
29 | #include <Time/TimeController.h> |
|
29 | #include <Time/TimeController.h> | |
30 | #include <TimeWidget/TimeWidget.h> |
|
30 | #include <TimeWidget/TimeWidget.h> | |
31 | #include <Variable/Variable.h> |
|
31 | #include <Variable/Variable.h> | |
32 | #include <Variable/VariableController.h> |
|
32 | #include <Variable/VariableController.h> | |
33 | #include <Visualization/VisualizationController.h> |
|
33 | #include <Visualization/VisualizationController.h> | |
34 |
|
34 | |||
35 | #include <QAction> |
|
35 | #include <QAction> | |
36 | #include <QDate> |
|
36 | #include <QDate> | |
37 | #include <QDateTime> |
|
37 | #include <QDateTime> | |
38 | #include <QDir> |
|
38 | #include <QDir> | |
39 | #include <QFileDialog> |
|
39 | #include <QFileDialog> | |
40 | #include <QToolBar> |
|
40 | #include <QToolBar> | |
41 | #include <QToolButton> |
|
41 | #include <QToolButton> | |
42 | #include <memory.h> |
|
42 | #include <memory.h> | |
43 |
|
43 | |||
44 | //#include <omp.h> |
|
44 | //#include <omp.h> | |
45 | //#include <network/filedownloader.h> |
|
45 | //#include <network/filedownloader.h> | |
46 | //#include <qlopdatabase.h> |
|
46 | //#include <qlopdatabase.h> | |
47 | //#include <qlopsettings.h> |
|
47 | //#include <qlopsettings.h> | |
48 | //#include <qlopgui.h> |
|
48 | //#include <qlopgui.h> | |
49 | //#include <spacedata.h> |
|
49 | //#include <spacedata.h> | |
50 | //#include "qlopcore.h" |
|
50 | //#include "qlopcore.h" | |
51 | //#include "qlopcodecmanager.h" |
|
51 | //#include "qlopcodecmanager.h" | |
52 | //#include "cdfcodec.h" |
|
52 | //#include "cdfcodec.h" | |
53 | //#include "amdatxtcodec.h" |
|
53 | //#include "amdatxtcodec.h" | |
54 | //#include <qlopplotmanager.h> |
|
54 | //#include <qlopplotmanager.h> | |
55 |
|
55 | |||
56 | #include "iostream" |
|
56 | #include "iostream" | |
57 |
|
57 | |||
58 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") |
|
58 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") | |
59 |
|
59 | |||
60 | namespace { |
|
60 | namespace { | |
61 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; |
|
61 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; | |
62 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; |
|
62 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; | |
63 | const auto VIEWPLITTERINDEX = 2; |
|
63 | const auto VIEWPLITTERINDEX = 2; | |
64 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; |
|
64 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; | |
65 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; |
|
65 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | class MainWindow::MainWindowPrivate { |
|
68 | class MainWindow::MainWindowPrivate { | |
69 | public: |
|
69 | public: | |
70 | QSize m_LastOpenLeftInspectorSize; |
|
70 | QSize m_LastOpenLeftInspectorSize; | |
71 | QSize m_LastOpenRightInspectorSize; |
|
71 | QSize m_LastOpenRightInspectorSize; | |
72 | }; |
|
72 | }; | |
73 |
|
73 | |||
74 | MainWindow::MainWindow(QWidget *parent) |
|
74 | MainWindow::MainWindow(QWidget *parent) | |
75 | : QMainWindow{parent}, |
|
75 | : QMainWindow{parent}, | |
76 | m_Ui{new Ui::MainWindow}, |
|
76 | m_Ui{new Ui::MainWindow}, | |
77 | impl{spimpl::make_unique_impl<MainWindowPrivate>()} |
|
77 | impl{spimpl::make_unique_impl<MainWindowPrivate>()} | |
78 | { |
|
78 | { | |
79 | m_Ui->setupUi(this); |
|
79 | m_Ui->setupUi(this); | |
80 |
|
80 | |||
81 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
81 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); | |
82 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
82 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); | |
83 |
|
83 | |||
84 |
|
84 | |||
85 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); |
|
85 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); | |
86 | auto openLeftInspectorAction = new QAction{QIcon{ |
|
86 | auto openLeftInspectorAction = new QAction{QIcon{ | |
87 | ":/icones/previous.png", |
|
87 | ":/icones/previous.png", | |
88 | }, |
|
88 | }, | |
89 | tr("Show/hide the left inspector"), this}; |
|
89 | tr("Show/hide the left inspector"), this}; | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | auto spacerLeftTop = new QWidget{}; |
|
92 | auto spacerLeftTop = new QWidget{}; | |
93 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
93 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
94 |
|
94 | |||
95 | auto spacerLeftBottom = new QWidget{}; |
|
95 | auto spacerLeftBottom = new QWidget{}; | |
96 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
96 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
97 |
|
97 | |||
98 | leftSidePane->addWidget(spacerLeftTop); |
|
98 | leftSidePane->addWidget(spacerLeftTop); | |
99 | leftSidePane->addAction(openLeftInspectorAction); |
|
99 | leftSidePane->addAction(openLeftInspectorAction); | |
100 | leftSidePane->addWidget(spacerLeftBottom); |
|
100 | leftSidePane->addWidget(spacerLeftBottom); | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); |
|
103 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); | |
104 | auto openRightInspectorAction = new QAction{QIcon{ |
|
104 | auto openRightInspectorAction = new QAction{QIcon{ | |
105 | ":/icones/next.png", |
|
105 | ":/icones/next.png", | |
106 | }, |
|
106 | }, | |
107 | tr("Show/hide the right inspector"), this}; |
|
107 | tr("Show/hide the right inspector"), this}; | |
108 |
|
108 | |||
109 | auto spacerRightTop = new QWidget{}; |
|
109 | auto spacerRightTop = new QWidget{}; | |
110 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
110 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
111 |
|
111 | |||
112 | auto spacerRightBottom = new QWidget{}; |
|
112 | auto spacerRightBottom = new QWidget{}; | |
113 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
113 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
114 |
|
114 | |||
115 | rightSidePane->addWidget(spacerRightTop); |
|
115 | rightSidePane->addWidget(spacerRightTop); | |
116 | rightSidePane->addAction(openRightInspectorAction); |
|
116 | rightSidePane->addAction(openRightInspectorAction); | |
117 | rightSidePane->addWidget(spacerRightBottom); |
|
117 | rightSidePane->addWidget(spacerRightBottom); | |
118 |
|
118 | |||
119 | openLeftInspectorAction->setCheckable(true); |
|
119 | openLeftInspectorAction->setCheckable(true); | |
120 | openRightInspectorAction->setCheckable(true); |
|
120 | openRightInspectorAction->setCheckable(true); | |
121 |
|
121 | |||
122 | auto openInspector = [this](bool checked, bool right, auto action) { |
|
122 | auto openInspector = [this](bool checked, bool right, auto action) { | |
123 |
|
123 | |||
124 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); |
|
124 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); | |
125 |
|
125 | |||
126 | auto &lastInspectorSize |
|
126 | auto &lastInspectorSize | |
127 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; |
|
127 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; | |
128 |
|
128 | |||
129 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() |
|
129 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() | |
130 | : m_Ui->leftMainInspectorWidget->size(); |
|
130 | : m_Ui->leftMainInspectorWidget->size(); | |
131 |
|
131 | |||
132 | // Update of the last opened geometry |
|
132 | // Update of the last opened geometry | |
133 | if (checked) { |
|
133 | if (checked) { | |
134 | lastInspectorSize = nextInspectorSize; |
|
134 | lastInspectorSize = nextInspectorSize; | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | auto startSize = lastInspectorSize; |
|
137 | auto startSize = lastInspectorSize; | |
138 | auto endSize = startSize; |
|
138 | auto endSize = startSize; | |
139 | endSize.setWidth(0); |
|
139 | endSize.setWidth(0); | |
140 |
|
140 | |||
141 | auto splitterInspectorIndex |
|
141 | auto splitterInspectorIndex | |
142 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; |
|
142 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; | |
143 |
|
143 | |||
144 | auto currentSizes = m_Ui->splitter->sizes(); |
|
144 | auto currentSizes = m_Ui->splitter->sizes(); | |
145 | if (checked) { |
|
145 | if (checked) { | |
146 | // adjust sizes individually here, e.g. |
|
146 | // adjust sizes individually here, e.g. | |
147 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); |
|
147 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); | |
148 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); |
|
148 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); | |
149 | m_Ui->splitter->setSizes(currentSizes); |
|
149 | m_Ui->splitter->setSizes(currentSizes); | |
150 | } |
|
150 | } | |
151 | else { |
|
151 | else { | |
152 | // adjust sizes individually here, e.g. |
|
152 | // adjust sizes individually here, e.g. | |
153 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); |
|
153 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); | |
154 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); |
|
154 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); | |
155 | m_Ui->splitter->setSizes(currentSizes); |
|
155 | m_Ui->splitter->setSizes(currentSizes); | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | }; |
|
158 | }; | |
159 |
|
159 | |||
160 |
|
160 | |||
161 | connect(openLeftInspectorAction, &QAction::triggered, |
|
161 | connect(openLeftInspectorAction, &QAction::triggered, | |
162 | [openInspector, openLeftInspectorAction](bool checked) { |
|
162 | [openInspector, openLeftInspectorAction](bool checked) { | |
163 | openInspector(checked, false, openLeftInspectorAction); |
|
163 | openInspector(checked, false, openLeftInspectorAction); | |
164 | }); |
|
164 | }); | |
165 | connect(openRightInspectorAction, &QAction::triggered, |
|
165 | connect(openRightInspectorAction, &QAction::triggered, | |
166 | [openInspector, openRightInspectorAction](bool checked) { |
|
166 | [openInspector, openRightInspectorAction](bool checked) { | |
167 | openInspector(checked, true, openRightInspectorAction); |
|
167 | openInspector(checked, true, openRightInspectorAction); | |
168 | }); |
|
168 | }); | |
169 |
|
169 | |||
170 | this->menuBar()->addAction(tr("File")); |
|
170 | this->menuBar()->addAction(tr("File")); | |
171 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); |
|
171 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); | |
172 |
|
172 | |||
173 | auto timeWidget = new TimeWidget{}; |
|
173 | auto timeWidget = new TimeWidget{}; | |
174 | mainToolBar->addWidget(timeWidget); |
|
174 | mainToolBar->addWidget(timeWidget); | |
175 |
|
175 | |||
176 | // Widgets / controllers connections |
|
176 | // Widgets / controllers connections | |
177 |
|
177 | |||
178 | // DataSource |
|
178 | // DataSource | |
179 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), |
|
179 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), | |
180 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); |
|
180 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); | |
181 |
|
181 | |||
182 | // Time |
|
182 | // Time | |
183 | connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(), |
|
183 | connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(), | |
184 | SLOT(onTimeToUpdate(SqpDateTime))); |
|
184 | SLOT(onTimeToUpdate(SqpDateTime))); | |
185 |
|
185 | |||
186 | qRegisterMetaType<SqpDateTime>(); |
|
|||
187 | connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)), |
|
186 | connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)), | |
188 | &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime))); |
|
187 | &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime))); | |
189 |
|
188 | |||
190 | // Widgets / widgets connections |
|
189 | // Widgets / widgets connections | |
191 | qRegisterMetaType<std::shared_ptr<Variable> >(); |
|
|||
192 |
|
190 | |||
193 | // For the following connections, we use DirectConnection to allow each widget that can |
|
191 | // For the following connections, we use DirectConnection to allow each widget that can | |
194 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. |
|
192 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. | |
195 | // The order of connections is also important, since it determines the order in which each |
|
193 | // The order of connections is also important, since it determines the order in which each | |
196 | // widget will attach its menu |
|
194 | // widget will attach its menu | |
197 | connect( |
|
195 | connect( | |
198 | m_Ui->variableInspectorWidget, |
|
196 | m_Ui->variableInspectorWidget, | |
199 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)), |
|
197 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
200 | m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)), |
|
198 | m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
201 | Qt::DirectConnection); |
|
199 | Qt::DirectConnection); | |
202 |
|
200 | |||
203 | /* QLopGUI::registerMenuBar(menuBar()); |
|
201 | /* QLopGUI::registerMenuBar(menuBar()); | |
204 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
|
202 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); | |
205 | this->m_progressWidget = new QWidget(); |
|
203 | this->m_progressWidget = new QWidget(); | |
206 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); |
|
204 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); | |
207 | this->m_progressWidget->setLayout(this->m_progressLayout); |
|
205 | this->m_progressWidget->setLayout(this->m_progressLayout); | |
208 | this->m_progressWidget->setWindowModality(Qt::WindowModal); |
|
206 | this->m_progressWidget->setWindowModality(Qt::WindowModal); | |
209 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); |
|
207 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); | |
210 | for(int i=0;i<OMP_THREADS;i++) |
|
208 | for(int i=0;i<OMP_THREADS;i++) | |
211 | { |
|
209 | { | |
212 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); |
|
210 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); | |
213 | this->m_progress.last()->setMinimum(0); |
|
211 | this->m_progress.last()->setMinimum(0); | |
214 | this->m_progress.last()->setMaximum(100); |
|
212 | this->m_progress.last()->setMaximum(100); | |
215 | this->m_progressLayout->addWidget(this->m_progress.last()); |
|
213 | this->m_progressLayout->addWidget(this->m_progress.last()); | |
216 | this->m_progressWidget->hide(); |
|
214 | this->m_progressWidget->hide(); | |
217 | this->m_progressThreadIds[i] = -1; |
|
215 | this->m_progressThreadIds[i] = -1; | |
218 | } |
|
216 | } | |
219 | this->m_progressWidget->setWindowTitle("Loading File"); |
|
217 | this->m_progressWidget->setWindowTitle("Loading File"); | |
220 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() |
|
218 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() | |
221 | << QLopCore::self() |
|
219 | << QLopCore::self() | |
222 | << QLopPlotManager::self() |
|
220 | << QLopPlotManager::self() | |
223 | << QLopCodecManager::self() |
|
221 | << QLopCodecManager::self() | |
224 | << FileDownloader::self() |
|
222 | << FileDownloader::self() | |
225 | << QLopDataBase::self() |
|
223 | << QLopDataBase::self() | |
226 | << SpaceData::self(); |
|
224 | << SpaceData::self(); | |
227 |
|
225 | |||
228 | CDFCodec::registerToManager(); |
|
226 | CDFCodec::registerToManager(); | |
229 | AMDATXTCodec::registerToManager(); |
|
227 | AMDATXTCodec::registerToManager(); | |
230 |
|
228 | |||
231 |
|
229 | |||
232 | for(int i=0;i<ServicesToLoad.count();i++) |
|
230 | for(int i=0;i<ServicesToLoad.count();i++) | |
233 | { |
|
231 | { | |
234 | qDebug()<<ServicesToLoad.at(i)->serviceName(); |
|
232 | qDebug()<<ServicesToLoad.at(i)->serviceName(); | |
235 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI |
|
233 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI | |
236 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); |
|
234 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); | |
237 | if(wdgt) |
|
235 | if(wdgt) | |
238 | { |
|
236 | { | |
239 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
237 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); | |
240 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); |
|
238 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); | |
241 | } |
|
239 | } | |
242 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); |
|
240 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); | |
243 | }*/ |
|
241 | }*/ | |
244 | } |
|
242 | } | |
245 |
|
243 | |||
246 | MainWindow::~MainWindow() |
|
244 | MainWindow::~MainWindow() | |
247 | { |
|
245 | { | |
248 | } |
|
246 | } | |
249 |
|
247 | |||
250 |
|
248 | |||
251 | void MainWindow::changeEvent(QEvent *e) |
|
249 | void MainWindow::changeEvent(QEvent *e) | |
252 | { |
|
250 | { | |
253 | QMainWindow::changeEvent(e); |
|
251 | QMainWindow::changeEvent(e); | |
254 | switch (e->type()) { |
|
252 | switch (e->type()) { | |
255 | case QEvent::LanguageChange: |
|
253 | case QEvent::LanguageChange: | |
256 | m_Ui->retranslateUi(this); |
|
254 | m_Ui->retranslateUi(this); | |
257 | break; |
|
255 | break; | |
258 | default: |
|
256 | default: | |
259 | break; |
|
257 | break; | |
260 | } |
|
258 | } | |
261 | } |
|
259 | } |
@@ -1,39 +1,42 | |||||
1 | #ifndef SCIQLOP_IDATAPROVIDER_H |
|
1 | #ifndef SCIQLOP_IDATAPROVIDER_H | |
2 | #define SCIQLOP_IDATAPROVIDER_H |
|
2 | #define SCIQLOP_IDATAPROVIDER_H | |
3 |
|
3 | |||
4 | #include <memory> |
|
4 | #include <memory> | |
5 |
|
5 | |||
6 | #include <QObject> |
|
6 | #include <QObject> | |
7 |
|
7 | |||
|
8 | #include <Common/MetaTypes.h> | |||
|
9 | ||||
8 | #include <Data/SqpDateTime.h> |
|
10 | #include <Data/SqpDateTime.h> | |
9 |
|
11 | |||
10 | class DataProviderParameters; |
|
12 | class DataProviderParameters; | |
11 | class IDataSeries; |
|
13 | class IDataSeries; | |
12 |
|
14 | |||
13 | /** |
|
15 | /** | |
14 | * @brief The IDataProvider interface aims to declare a data provider. |
|
16 | * @brief The IDataProvider interface aims to declare a data provider. | |
15 | * |
|
17 | * | |
16 | * A data provider is an entity that generates data and returns it according to various parameters |
|
18 | * A data provider is an entity that generates data and returns it according to various parameters | |
17 | * (time interval, product to retrieve the data, etc.) |
|
19 | * (time interval, product to retrieve the data, etc.) | |
18 | * |
|
20 | * | |
19 | * @sa IDataSeries |
|
21 | * @sa IDataSeries | |
20 | */ |
|
22 | */ | |
21 | class IDataProvider : public QObject { |
|
23 | class IDataProvider : public QObject { | |
22 |
|
24 | |||
23 | Q_OBJECT |
|
25 | Q_OBJECT | |
24 | public: |
|
26 | public: | |
25 | virtual ~IDataProvider() noexcept = default; |
|
27 | virtual ~IDataProvider() noexcept = default; | |
26 |
|
28 | |||
27 | virtual std::unique_ptr<IDataSeries> |
|
29 | virtual std::unique_ptr<IDataSeries> | |
28 | retrieveData(const DataProviderParameters ¶meters) const = 0; |
|
30 | retrieveData(const DataProviderParameters ¶meters) const = 0; | |
29 |
|
31 | |||
30 |
|
32 | |||
31 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; |
|
33 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; | |
32 |
|
34 | |||
33 | signals: |
|
35 | signals: | |
34 | void dataProvided(std::shared_ptr<IDataSeries> dateSerie, const SqpDateTime &dateTime); |
|
36 | void dataProvided(std::shared_ptr<IDataSeries> dateSerie, const SqpDateTime &dateTime); | |
35 | }; |
|
37 | }; | |
|
38 | ||||
36 | // Required for using shared_ptr in signals/slots |
|
39 | // Required for using shared_ptr in signals/slots | |
37 |
|
|
40 | SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_PTR_REGISTRY, std::shared_ptr<IDataProvider>) | |
38 |
|
41 | |||
39 | #endif // SCIQLOP_IDATAPROVIDER_H |
|
42 | #endif // SCIQLOP_IDATAPROVIDER_H |
@@ -1,54 +1,54 | |||||
1 | #ifndef SCIQLOP_IDATASERIES_H |
|
1 | #ifndef SCIQLOP_IDATASERIES_H | |
2 | #define SCIQLOP_IDATASERIES_H |
|
2 | #define SCIQLOP_IDATASERIES_H | |
3 |
|
3 | |||
|
4 | #include <Common/MetaTypes.h> | |||
4 |
|
5 | |||
5 | #include <memory> |
|
6 | #include <memory> | |
6 |
|
7 | |||
7 | #include <QObject> |
|
|||
8 | #include <QString> |
|
8 | #include <QString> | |
9 |
|
9 | |||
10 | template <int Dim> |
|
10 | template <int Dim> | |
11 | class ArrayData; |
|
11 | class ArrayData; | |
12 |
|
12 | |||
13 | struct Unit { |
|
13 | struct Unit { | |
14 | explicit Unit(const QString &name = {}, bool timeUnit = false) |
|
14 | explicit Unit(const QString &name = {}, bool timeUnit = false) | |
15 | : m_Name{name}, m_TimeUnit{timeUnit} |
|
15 | : m_Name{name}, m_TimeUnit{timeUnit} | |
16 | { |
|
16 | { | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | QString m_Name; ///< Unit name |
|
19 | QString m_Name; ///< Unit name | |
20 | bool m_TimeUnit; ///< The unit is a unit of time |
|
20 | bool m_TimeUnit; ///< The unit is a unit of time | |
21 | }; |
|
21 | }; | |
22 |
|
22 | |||
23 | /** |
|
23 | /** | |
24 | * @brief The IDataSeries aims to declare a data series. |
|
24 | * @brief The IDataSeries aims to declare a data series. | |
25 | * |
|
25 | * | |
26 | * A data series is an entity that contains at least : |
|
26 | * A data series is an entity that contains at least : | |
27 | * - one dataset representing the x-axis |
|
27 | * - one dataset representing the x-axis | |
28 | * - one dataset representing the values |
|
28 | * - one dataset representing the values | |
29 | * |
|
29 | * | |
30 | * Each dataset is represented by an ArrayData, and is associated with a unit. |
|
30 | * Each dataset is represented by an ArrayData, and is associated with a unit. | |
31 | * |
|
31 | * | |
32 | * An ArrayData can be unidimensional or two-dimensional, depending on the implementation of the |
|
32 | * An ArrayData can be unidimensional or two-dimensional, depending on the implementation of the | |
33 | * IDataSeries. The x-axis dataset is always unidimensional. |
|
33 | * IDataSeries. The x-axis dataset is always unidimensional. | |
34 | * |
|
34 | * | |
35 | * @sa ArrayData |
|
35 | * @sa ArrayData | |
36 | */ |
|
36 | */ | |
37 | class IDataSeries { |
|
37 | class IDataSeries { | |
38 | public: |
|
38 | public: | |
39 | virtual ~IDataSeries() noexcept = default; |
|
39 | virtual ~IDataSeries() noexcept = default; | |
40 |
|
40 | |||
41 | /// Returns the x-axis dataset |
|
41 | /// Returns the x-axis dataset | |
42 | virtual std::shared_ptr<ArrayData<1> > xAxisData() = 0; |
|
42 | virtual std::shared_ptr<ArrayData<1> > xAxisData() = 0; | |
43 |
|
43 | |||
44 | virtual Unit xAxisUnit() const = 0; |
|
44 | virtual Unit xAxisUnit() const = 0; | |
45 |
|
45 | |||
46 | virtual Unit valuesUnit() const = 0; |
|
46 | virtual Unit valuesUnit() const = 0; | |
47 |
|
47 | |||
48 | virtual void merge(IDataSeries *dataSeries) = 0; |
|
48 | virtual void merge(IDataSeries *dataSeries) = 0; | |
49 | }; |
|
49 | }; | |
50 |
|
50 | |||
51 | // Required for using shared_ptr in signals/slots |
|
51 | // Required for using shared_ptr in signals/slots | |
52 |
|
|
52 | SCIQLOP_REGISTER_META_TYPE(IDATASERIES_PTR_REGISTRY, std::shared_ptr<IDataSeries>) | |
53 |
|
53 | |||
54 | #endif // SCIQLOP_IDATASERIES_H |
|
54 | #endif // SCIQLOP_IDATASERIES_H |
@@ -1,42 +1,44 | |||||
1 | #ifndef SCIQLOP_SQPDATETIME_H |
|
1 | #ifndef SCIQLOP_SQPDATETIME_H | |
2 | #define SCIQLOP_SQPDATETIME_H |
|
2 | #define SCIQLOP_SQPDATETIME_H | |
3 |
|
3 | |||
4 | #include <QObject> |
|
4 | #include <QObject> | |
5 |
|
5 | |||
6 | #include <QDateTime> |
|
6 | #include <QDateTime> | |
7 | #include <QDebug> |
|
7 | #include <QDebug> | |
8 |
|
8 | |||
|
9 | #include <Common/MetaTypes.h> | |||
|
10 | ||||
9 | /** |
|
11 | /** | |
10 | * @brief The SqpDateTime struct holds the information of time parameters |
|
12 | * @brief The SqpDateTime struct holds the information of time parameters | |
11 | */ |
|
13 | */ | |
12 | struct SqpDateTime { |
|
14 | struct SqpDateTime { | |
13 | /// Start time |
|
15 | /// Start time | |
14 | double m_TStart; |
|
16 | double m_TStart; | |
15 | /// End time |
|
17 | /// End time | |
16 | double m_TEnd; |
|
18 | double m_TEnd; | |
17 |
|
19 | |||
18 | bool contains(const SqpDateTime &dateTime) |
|
20 | bool contains(const SqpDateTime &dateTime) | |
19 | { |
|
21 | { | |
20 | return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd); |
|
22 | return (m_TStart <= dateTime.m_TStart && m_TEnd >= dateTime.m_TEnd); | |
21 | } |
|
23 | } | |
22 |
|
24 | |||
23 | bool intersect(const SqpDateTime &dateTime) |
|
25 | bool intersect(const SqpDateTime &dateTime) | |
24 | { |
|
26 | { | |
25 | return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd); |
|
27 | return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd); | |
26 | } |
|
28 | } | |
27 | }; |
|
29 | }; | |
28 |
|
30 | |||
29 | inline QDebug operator<<(QDebug d, SqpDateTime obj) |
|
31 | inline QDebug operator<<(QDebug d, SqpDateTime obj) | |
30 | { |
|
32 | { | |
31 | auto tendDateTimeStart = QDateTime::fromMSecsSinceEpoch(obj.m_TStart * 1000); |
|
33 | auto tendDateTimeStart = QDateTime::fromMSecsSinceEpoch(obj.m_TStart * 1000); | |
32 | auto tendDateTimeEnd = QDateTime::fromMSecsSinceEpoch(obj.m_TEnd * 1000); |
|
34 | auto tendDateTimeEnd = QDateTime::fromMSecsSinceEpoch(obj.m_TEnd * 1000); | |
33 |
|
35 | |||
34 | // QDebug << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; |
|
36 | // QDebug << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; | |
35 | d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; |
|
37 | d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; | |
36 | return d; |
|
38 | return d; | |
37 | } |
|
39 | } | |
38 |
|
40 | |||
39 | // Required for using shared_ptr in signals/slots |
|
41 | // Required for using shared_ptr in signals/slots | |
40 | Q_DECLARE_METATYPE(SqpDateTime) |
|
42 | SCIQLOP_REGISTER_META_TYPE(SQPDATETIME_REGISTRY, SqpDateTime) | |
41 |
|
43 | |||
42 | #endif // SCIQLOP_SQPDATETIME_H |
|
44 | #endif // SCIQLOP_SQPDATETIME_H |
@@ -1,55 +1,55 | |||||
1 | #ifndef SCIQLOP_VARIABLE_H |
|
1 | #ifndef SCIQLOP_VARIABLE_H | |
2 | #define SCIQLOP_VARIABLE_H |
|
2 | #define SCIQLOP_VARIABLE_H | |
3 |
|
3 | |||
4 | #include <Data/SqpDateTime.h> |
|
4 | #include <Data/SqpDateTime.h> | |
5 |
|
5 | |||
6 |
|
||||
7 | #include <QLoggingCategory> |
|
6 | #include <QLoggingCategory> | |
8 | #include <QObject> |
|
7 | #include <QObject> | |
9 |
|
8 | |||
|
9 | #include <Common/MetaTypes.h> | |||
10 | #include <Common/spimpl.h> |
|
10 | #include <Common/spimpl.h> | |
11 |
|
11 | |||
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_Variable) |
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_Variable) | |
13 |
|
13 | |||
14 | class IDataSeries; |
|
14 | class IDataSeries; | |
15 | class QString; |
|
15 | class QString; | |
16 |
|
16 | |||
17 | /** |
|
17 | /** | |
18 | * @brief The Variable class represents a variable in SciQlop. |
|
18 | * @brief The Variable class represents a variable in SciQlop. | |
19 | */ |
|
19 | */ | |
20 | class Variable : public QObject { |
|
20 | class Variable : public QObject { | |
21 |
|
21 | |||
22 | Q_OBJECT |
|
22 | Q_OBJECT | |
23 |
|
23 | |||
24 | public: |
|
24 | public: | |
25 | explicit Variable(const QString &name, const QString &unit, const QString &mission, |
|
25 | explicit Variable(const QString &name, const QString &unit, const QString &mission, | |
26 | const SqpDateTime &dateTime); |
|
26 | const SqpDateTime &dateTime); | |
27 |
|
27 | |||
28 | QString name() const noexcept; |
|
28 | QString name() const noexcept; | |
29 | QString mission() const noexcept; |
|
29 | QString mission() const noexcept; | |
30 | QString unit() const noexcept; |
|
30 | QString unit() const noexcept; | |
31 | SqpDateTime dateTime() const noexcept; |
|
31 | SqpDateTime dateTime() const noexcept; | |
32 | void setDateTime(const SqpDateTime &dateTime) noexcept; |
|
32 | void setDateTime(const SqpDateTime &dateTime) noexcept; | |
33 |
|
33 | |||
34 | /// @return the data of the variable, nullptr if there is no data |
|
34 | /// @return the data of the variable, nullptr if there is no data | |
35 | IDataSeries *dataSeries() const noexcept; |
|
35 | IDataSeries *dataSeries() const noexcept; | |
36 |
|
36 | |||
37 | bool contains(const SqpDateTime &dateTime); |
|
37 | bool contains(const SqpDateTime &dateTime); | |
38 | bool intersect(const SqpDateTime &dateTime); |
|
38 | bool intersect(const SqpDateTime &dateTime); | |
39 | void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept; |
|
39 | void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept; | |
40 |
|
40 | |||
41 | public slots: |
|
41 | public slots: | |
42 | void onAddDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept; |
|
42 | void onAddDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept; | |
43 |
|
43 | |||
44 | signals: |
|
44 | signals: | |
45 | void updated(); |
|
45 | void updated(); | |
46 |
|
46 | |||
47 | private: |
|
47 | private: | |
48 | class VariablePrivate; |
|
48 | class VariablePrivate; | |
49 | spimpl::unique_impl_ptr<VariablePrivate> impl; |
|
49 | spimpl::unique_impl_ptr<VariablePrivate> impl; | |
50 | }; |
|
50 | }; | |
51 |
|
51 | |||
52 | // Required for using shared_ptr in signals/slots |
|
52 | // Required for using shared_ptr in signals/slots | |
53 |
|
|
53 | SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr<Variable>) | |
54 |
|
54 | |||
55 | #endif // SCIQLOP_VARIABLE_H |
|
55 | #endif // SCIQLOP_VARIABLE_H |
@@ -1,177 +1,175 | |||||
1 | #include <Variable/Variable.h> |
|
1 | #include <Variable/Variable.h> | |
2 | #include <Variable/VariableCacheController.h> |
|
2 | #include <Variable/VariableCacheController.h> | |
3 | #include <Variable/VariableController.h> |
|
3 | #include <Variable/VariableController.h> | |
4 | #include <Variable/VariableModel.h> |
|
4 | #include <Variable/VariableModel.h> | |
5 |
|
5 | |||
6 | #include <Data/DataProviderParameters.h> |
|
6 | #include <Data/DataProviderParameters.h> | |
7 | #include <Data/IDataProvider.h> |
|
7 | #include <Data/IDataProvider.h> | |
8 | #include <Data/IDataSeries.h> |
|
8 | #include <Data/IDataSeries.h> | |
9 | #include <Time/TimeController.h> |
|
9 | #include <Time/TimeController.h> | |
10 |
|
10 | |||
11 | #include <QDateTime> |
|
11 | #include <QDateTime> | |
12 | #include <QMutex> |
|
12 | #include <QMutex> | |
13 | #include <QThread> |
|
13 | #include <QThread> | |
14 | #include <QtCore/QItemSelectionModel> |
|
14 | #include <QtCore/QItemSelectionModel> | |
15 |
|
15 | |||
16 | #include <unordered_map> |
|
16 | #include <unordered_map> | |
17 |
|
17 | |||
18 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") |
|
18 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") | |
19 |
|
19 | |||
20 | namespace { |
|
20 | namespace { | |
21 |
|
21 | |||
22 | /// @todo Generates default dataseries, according to the provider passed in parameter. This method |
|
22 | /// @todo Generates default dataseries, according to the provider passed in parameter. This method | |
23 | /// will be deleted when the timerange is recovered from SciQlop |
|
23 | /// will be deleted when the timerange is recovered from SciQlop | |
24 | std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider, |
|
24 | std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider, | |
25 | const SqpDateTime &dateTime) noexcept |
|
25 | const SqpDateTime &dateTime) noexcept | |
26 | { |
|
26 | { | |
27 | auto parameters = DataProviderParameters{dateTime}; |
|
27 | auto parameters = DataProviderParameters{dateTime}; | |
28 |
|
28 | |||
29 | return provider.retrieveData(parameters); |
|
29 | return provider.retrieveData(parameters); | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | } // namespace |
|
32 | } // namespace | |
33 |
|
33 | |||
34 | struct VariableController::VariableControllerPrivate { |
|
34 | struct VariableController::VariableControllerPrivate { | |
35 | explicit VariableControllerPrivate(VariableController *parent) |
|
35 | explicit VariableControllerPrivate(VariableController *parent) | |
36 | : m_WorkingMutex{}, |
|
36 | : m_WorkingMutex{}, | |
37 | m_VariableModel{new VariableModel{parent}}, |
|
37 | m_VariableModel{new VariableModel{parent}}, | |
38 | m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, |
|
38 | m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, | |
39 | m_VariableCacheController{std::make_unique<VariableCacheController>()} |
|
39 | m_VariableCacheController{std::make_unique<VariableCacheController>()} | |
40 | { |
|
40 | { | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | QMutex m_WorkingMutex; |
|
43 | QMutex m_WorkingMutex; | |
44 | /// Variable model. The VariableController has the ownership |
|
44 | /// Variable model. The VariableController has the ownership | |
45 | VariableModel *m_VariableModel; |
|
45 | VariableModel *m_VariableModel; | |
46 | QItemSelectionModel *m_VariableSelectionModel; |
|
46 | QItemSelectionModel *m_VariableSelectionModel; | |
47 |
|
47 | |||
48 |
|
48 | |||
49 | TimeController *m_TimeController{nullptr}; |
|
49 | TimeController *m_TimeController{nullptr}; | |
50 | std::unique_ptr<VariableCacheController> m_VariableCacheController; |
|
50 | std::unique_ptr<VariableCacheController> m_VariableCacheController; | |
51 |
|
51 | |||
52 | std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> > |
|
52 | std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> > | |
53 | m_VariableToProviderMap; |
|
53 | m_VariableToProviderMap; | |
54 | }; |
|
54 | }; | |
55 |
|
55 | |||
56 | VariableController::VariableController(QObject *parent) |
|
56 | VariableController::VariableController(QObject *parent) | |
57 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)} |
|
57 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)} | |
58 | { |
|
58 | { | |
59 | qCDebug(LOG_VariableController()) << tr("VariableController construction") |
|
59 | qCDebug(LOG_VariableController()) << tr("VariableController construction") | |
60 | << QThread::currentThread(); |
|
60 | << QThread::currentThread(); | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | VariableController::~VariableController() |
|
63 | VariableController::~VariableController() | |
64 | { |
|
64 | { | |
65 | qCDebug(LOG_VariableController()) << tr("VariableController destruction") |
|
65 | qCDebug(LOG_VariableController()) << tr("VariableController destruction") | |
66 | << QThread::currentThread(); |
|
66 | << QThread::currentThread(); | |
67 | this->waitForFinish(); |
|
67 | this->waitForFinish(); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | VariableModel *VariableController::variableModel() noexcept |
|
70 | VariableModel *VariableController::variableModel() noexcept | |
71 | { |
|
71 | { | |
72 | return impl->m_VariableModel; |
|
72 | return impl->m_VariableModel; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | QItemSelectionModel *VariableController::variableSelectionModel() noexcept |
|
75 | QItemSelectionModel *VariableController::variableSelectionModel() noexcept | |
76 | { |
|
76 | { | |
77 | return impl->m_VariableSelectionModel; |
|
77 | return impl->m_VariableSelectionModel; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | void VariableController::setTimeController(TimeController *timeController) noexcept |
|
80 | void VariableController::setTimeController(TimeController *timeController) noexcept | |
81 | { |
|
81 | { | |
82 | impl->m_TimeController = timeController; |
|
82 | impl->m_TimeController = timeController; | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | void VariableController::createVariable(const QString &name, |
|
85 | void VariableController::createVariable(const QString &name, | |
86 | std::shared_ptr<IDataProvider> provider) noexcept |
|
86 | std::shared_ptr<IDataProvider> provider) noexcept | |
87 | { |
|
87 | { | |
88 |
|
88 | |||
89 | if (!impl->m_TimeController) { |
|
89 | if (!impl->m_TimeController) { | |
90 | qCCritical(LOG_VariableController()) |
|
90 | qCCritical(LOG_VariableController()) | |
91 | << tr("Impossible to create variable: The time controller is null"); |
|
91 | << tr("Impossible to create variable: The time controller is null"); | |
92 | return; |
|
92 | return; | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 |
|
95 | |||
96 | /// @todo : for the moment : |
|
96 | /// @todo : for the moment : | |
97 | /// - the provider is only used to retrieve data from the variable for its initialization, but |
|
97 | /// - the provider is only used to retrieve data from the variable for its initialization, but | |
98 | /// it will be retained later |
|
98 | /// it will be retained later | |
99 | /// - default data are generated for the variable, without taking into account the timerange set |
|
99 | /// - default data are generated for the variable, without taking into account the timerange set | |
100 | /// in sciqlop |
|
100 | /// in sciqlop | |
101 | auto dateTime = impl->m_TimeController->dateTime(); |
|
101 | auto dateTime = impl->m_TimeController->dateTime(); | |
102 | if (auto newVariable = impl->m_VariableModel->createVariable( |
|
102 | if (auto newVariable = impl->m_VariableModel->createVariable( | |
103 | name, dateTime, generateDefaultDataSeries(*provider, dateTime))) { |
|
103 | name, dateTime, generateDefaultDataSeries(*provider, dateTime))) { | |
104 |
|
104 | |||
105 | // store the provider |
|
105 | // store the provider | |
106 | impl->m_VariableToProviderMap[newVariable] = provider; |
|
106 | impl->m_VariableToProviderMap[newVariable] = provider; | |
107 | qRegisterMetaType<std::shared_ptr<IDataSeries> >(); |
|
|||
108 | qRegisterMetaType<SqpDateTime>(); |
|
|||
109 | connect(provider.get(), &IDataProvider::dataProvided, newVariable.get(), |
|
107 | connect(provider.get(), &IDataProvider::dataProvided, newVariable.get(), | |
110 | &Variable::onAddDataSeries); |
|
108 | &Variable::onAddDataSeries); | |
111 |
|
109 | |||
112 |
|
110 | |||
113 | // store in cache |
|
111 | // store in cache | |
114 | impl->m_VariableCacheController->addDateTime(newVariable, dateTime); |
|
112 | impl->m_VariableCacheController->addDateTime(newVariable, dateTime); | |
115 |
|
113 | |||
116 | // notify the creation |
|
114 | // notify the creation | |
117 | emit variableCreated(newVariable); |
|
115 | emit variableCreated(newVariable); | |
118 | } |
|
116 | } | |
119 | } |
|
117 | } | |
120 |
|
118 | |||
121 | void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime) |
|
119 | void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime) | |
122 | { |
|
120 | { | |
123 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); |
|
121 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); | |
124 |
|
122 | |||
125 | for (const auto &selectedRow : qAsConst(selectedRows)) { |
|
123 | for (const auto &selectedRow : qAsConst(selectedRows)) { | |
126 | if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) { |
|
124 | if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) { | |
127 | selectedVariable->setDateTime(dateTime); |
|
125 | selectedVariable->setDateTime(dateTime); | |
128 | this->onRequestDataLoading(selectedVariable, dateTime); |
|
126 | this->onRequestDataLoading(selectedVariable, dateTime); | |
129 | } |
|
127 | } | |
130 | } |
|
128 | } | |
131 | } |
|
129 | } | |
132 |
|
130 | |||
133 |
|
131 | |||
134 | void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable, |
|
132 | void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable, | |
135 | const SqpDateTime &dateTime) |
|
133 | const SqpDateTime &dateTime) | |
136 | { |
|
134 | { | |
137 | // we want to load data of the variable for the dateTime. |
|
135 | // we want to load data of the variable for the dateTime. | |
138 | // First we check if the cache contains some of them. |
|
136 | // First we check if the cache contains some of them. | |
139 | // For the other, we ask the provider to give them. |
|
137 | // For the other, we ask the provider to give them. | |
140 | if (variable) { |
|
138 | if (variable) { | |
141 |
|
139 | |||
142 | auto dateTimeListNotInCache |
|
140 | auto dateTimeListNotInCache | |
143 | = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime); |
|
141 | = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime); | |
144 |
|
142 | |||
145 | if (!dateTimeListNotInCache.empty()) { |
|
143 | if (!dateTimeListNotInCache.empty()) { | |
146 | // Ask the provider for each data on the dateTimeListNotInCache |
|
144 | // Ask the provider for each data on the dateTimeListNotInCache | |
147 | impl->m_VariableToProviderMap.at(variable)->requestDataLoading( |
|
145 | impl->m_VariableToProviderMap.at(variable)->requestDataLoading( | |
148 | std::move(dateTimeListNotInCache)); |
|
146 | std::move(dateTimeListNotInCache)); | |
149 | // store in cache |
|
147 | // store in cache | |
150 | impl->m_VariableCacheController->addDateTime(variable, dateTime); |
|
148 | impl->m_VariableCacheController->addDateTime(variable, dateTime); | |
151 | } |
|
149 | } | |
152 | else { |
|
150 | else { | |
153 | emit variable->updated(); |
|
151 | emit variable->updated(); | |
154 | } |
|
152 | } | |
155 | } |
|
153 | } | |
156 | else { |
|
154 | else { | |
157 | qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null"); |
|
155 | qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null"); | |
158 | } |
|
156 | } | |
159 | } |
|
157 | } | |
160 |
|
158 | |||
161 |
|
159 | |||
162 | void VariableController::initialize() |
|
160 | void VariableController::initialize() | |
163 | { |
|
161 | { | |
164 | qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread(); |
|
162 | qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread(); | |
165 | impl->m_WorkingMutex.lock(); |
|
163 | impl->m_WorkingMutex.lock(); | |
166 | qCDebug(LOG_VariableController()) << tr("VariableController init END"); |
|
164 | qCDebug(LOG_VariableController()) << tr("VariableController init END"); | |
167 | } |
|
165 | } | |
168 |
|
166 | |||
169 | void VariableController::finalize() |
|
167 | void VariableController::finalize() | |
170 | { |
|
168 | { | |
171 | impl->m_WorkingMutex.unlock(); |
|
169 | impl->m_WorkingMutex.unlock(); | |
172 | } |
|
170 | } | |
173 |
|
171 | |||
174 | void VariableController::waitForFinish() |
|
172 | void VariableController::waitForFinish() | |
175 | { |
|
173 | { | |
176 | QMutexLocker locker{&impl->m_WorkingMutex}; |
|
174 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
177 | } |
|
175 | } |
@@ -1,120 +1,118 | |||||
1 | #include "SqpApplication.h" |
|
1 | #include "SqpApplication.h" | |
2 |
|
2 | |||
3 | #include <Data/IDataProvider.h> |
|
3 | #include <Data/IDataProvider.h> | |
4 | #include <DataSource/DataSourceController.h> |
|
4 | #include <DataSource/DataSourceController.h> | |
5 | #include <QThread> |
|
5 | #include <QThread> | |
6 | #include <Time/TimeController.h> |
|
6 | #include <Time/TimeController.h> | |
7 | #include <Variable/Variable.h> |
|
7 | #include <Variable/Variable.h> | |
8 | #include <Variable/VariableController.h> |
|
8 | #include <Variable/VariableController.h> | |
9 | #include <Visualization/VisualizationController.h> |
|
9 | #include <Visualization/VisualizationController.h> | |
10 |
|
10 | |||
11 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
11 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | |
12 |
|
12 | |||
13 | class SqpApplication::SqpApplicationPrivate { |
|
13 | class SqpApplication::SqpApplicationPrivate { | |
14 | public: |
|
14 | public: | |
15 | SqpApplicationPrivate() |
|
15 | SqpApplicationPrivate() | |
16 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
16 | : m_DataSourceController{std::make_unique<DataSourceController>()}, | |
17 | m_TimeController{std::make_unique<TimeController>()}, |
|
17 | m_TimeController{std::make_unique<TimeController>()}, | |
18 | m_VariableController{std::make_unique<VariableController>()}, |
|
18 | m_VariableController{std::make_unique<VariableController>()}, | |
19 | m_VisualizationController{std::make_unique<VisualizationController>()} |
|
19 | m_VisualizationController{std::make_unique<VisualizationController>()} | |
20 | { |
|
20 | { | |
21 | // /////////////////////////////// // |
|
21 | // /////////////////////////////// // | |
22 | // Connections between controllers // |
|
22 | // Connections between controllers // | |
23 | // /////////////////////////////// // |
|
23 | // /////////////////////////////// // | |
24 |
|
24 | |||
25 | // VariableController <-> DataSourceController |
|
25 | // VariableController <-> DataSourceController | |
26 | qRegisterMetaType<std::shared_ptr<IDataProvider> >(); |
|
|||
27 | connect(m_DataSourceController.get(), |
|
26 | connect(m_DataSourceController.get(), | |
28 | SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)), |
|
27 | SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)), | |
29 | m_VariableController.get(), |
|
28 | m_VariableController.get(), | |
30 | SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>))); |
|
29 | SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>))); | |
31 |
|
30 | |||
32 | // VariableController <-> VisualizationController |
|
31 | // VariableController <-> VisualizationController | |
33 | qRegisterMetaType<std::shared_ptr<Variable> >(); |
|
|||
34 | connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)), |
|
32 | connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)), | |
35 | m_VisualizationController.get(), |
|
33 | m_VisualizationController.get(), | |
36 | SIGNAL(variableCreated(std::shared_ptr<Variable>))); |
|
34 | SIGNAL(variableCreated(std::shared_ptr<Variable>))); | |
37 |
|
35 | |||
38 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
36 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | |
39 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
37 | m_VariableController->moveToThread(&m_VariableControllerThread); | |
40 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
38 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |
41 |
|
39 | |||
42 | // Additionnal init |
|
40 | // Additionnal init | |
43 | m_VariableController->setTimeController(m_TimeController.get()); |
|
41 | m_VariableController->setTimeController(m_TimeController.get()); | |
44 | } |
|
42 | } | |
45 |
|
43 | |||
46 | virtual ~SqpApplicationPrivate() |
|
44 | virtual ~SqpApplicationPrivate() | |
47 | { |
|
45 | { | |
48 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); |
|
46 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); | |
49 | m_DataSourceControllerThread.quit(); |
|
47 | m_DataSourceControllerThread.quit(); | |
50 | m_DataSourceControllerThread.wait(); |
|
48 | m_DataSourceControllerThread.wait(); | |
51 |
|
49 | |||
52 | m_VariableControllerThread.quit(); |
|
50 | m_VariableControllerThread.quit(); | |
53 | m_VariableControllerThread.wait(); |
|
51 | m_VariableControllerThread.wait(); | |
54 |
|
52 | |||
55 | m_VisualizationControllerThread.quit(); |
|
53 | m_VisualizationControllerThread.quit(); | |
56 | m_VisualizationControllerThread.wait(); |
|
54 | m_VisualizationControllerThread.wait(); | |
57 | } |
|
55 | } | |
58 |
|
56 | |||
59 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
57 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
60 | std::unique_ptr<VariableController> m_VariableController; |
|
58 | std::unique_ptr<VariableController> m_VariableController; | |
61 | std::unique_ptr<TimeController> m_TimeController; |
|
59 | std::unique_ptr<TimeController> m_TimeController; | |
62 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
60 | std::unique_ptr<VisualizationController> m_VisualizationController; | |
63 | QThread m_DataSourceControllerThread; |
|
61 | QThread m_DataSourceControllerThread; | |
64 | QThread m_VariableControllerThread; |
|
62 | QThread m_VariableControllerThread; | |
65 | QThread m_VisualizationControllerThread; |
|
63 | QThread m_VisualizationControllerThread; | |
66 | }; |
|
64 | }; | |
67 |
|
65 | |||
68 |
|
66 | |||
69 | SqpApplication::SqpApplication(int &argc, char **argv) |
|
67 | SqpApplication::SqpApplication(int &argc, char **argv) | |
70 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} |
|
68 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | |
71 | { |
|
69 | { | |
72 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); |
|
70 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); | |
73 |
|
71 | |||
74 | connect(&impl->m_DataSourceControllerThread, &QThread::started, |
|
72 | connect(&impl->m_DataSourceControllerThread, &QThread::started, | |
75 | impl->m_DataSourceController.get(), &DataSourceController::initialize); |
|
73 | impl->m_DataSourceController.get(), &DataSourceController::initialize); | |
76 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
74 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, | |
77 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
75 | impl->m_DataSourceController.get(), &DataSourceController::finalize); | |
78 |
|
76 | |||
79 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), |
|
77 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | |
80 | &VariableController::initialize); |
|
78 | &VariableController::initialize); | |
81 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), |
|
79 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | |
82 | &VariableController::finalize); |
|
80 | &VariableController::finalize); | |
83 |
|
81 | |||
84 | connect(&impl->m_VisualizationControllerThread, &QThread::started, |
|
82 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |
85 | impl->m_VisualizationController.get(), &VisualizationController::initialize); |
|
83 | impl->m_VisualizationController.get(), &VisualizationController::initialize); | |
86 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, |
|
84 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |
87 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
85 | impl->m_VisualizationController.get(), &VisualizationController::finalize); | |
88 |
|
86 | |||
89 | impl->m_DataSourceControllerThread.start(); |
|
87 | impl->m_DataSourceControllerThread.start(); | |
90 | impl->m_VariableControllerThread.start(); |
|
88 | impl->m_VariableControllerThread.start(); | |
91 | impl->m_VisualizationControllerThread.start(); |
|
89 | impl->m_VisualizationControllerThread.start(); | |
92 | } |
|
90 | } | |
93 |
|
91 | |||
94 | SqpApplication::~SqpApplication() |
|
92 | SqpApplication::~SqpApplication() | |
95 | { |
|
93 | { | |
96 | } |
|
94 | } | |
97 |
|
95 | |||
98 | void SqpApplication::initialize() |
|
96 | void SqpApplication::initialize() | |
99 | { |
|
97 | { | |
100 | } |
|
98 | } | |
101 |
|
99 | |||
102 | DataSourceController &SqpApplication::dataSourceController() noexcept |
|
100 | DataSourceController &SqpApplication::dataSourceController() noexcept | |
103 | { |
|
101 | { | |
104 | return *impl->m_DataSourceController; |
|
102 | return *impl->m_DataSourceController; | |
105 | } |
|
103 | } | |
106 |
|
104 | |||
107 | TimeController &SqpApplication::timeController() noexcept |
|
105 | TimeController &SqpApplication::timeController() noexcept | |
108 | { |
|
106 | { | |
109 | return *impl->m_TimeController; |
|
107 | return *impl->m_TimeController; | |
110 | } |
|
108 | } | |
111 |
|
109 | |||
112 | VariableController &SqpApplication::variableController() noexcept |
|
110 | VariableController &SqpApplication::variableController() noexcept | |
113 | { |
|
111 | { | |
114 | return *impl->m_VariableController; |
|
112 | return *impl->m_VariableController; | |
115 | } |
|
113 | } | |
116 |
|
114 | |||
117 | VisualizationController &SqpApplication::visualizationController() noexcept |
|
115 | VisualizationController &SqpApplication::visualizationController() noexcept | |
118 | { |
|
116 | { | |
119 | return *impl->m_VisualizationController; |
|
117 | return *impl->m_VisualizationController; | |
120 | } |
|
118 | } |
General Comments 0
You need to be logged in to leave comments.
Login now