##// END OF EJS Templates
Merge branch 'feature/TimeWidgetInUse' into develop
perrinel -
r194:435054a2a67e merge
parent child
Show More
@@ -0,0 +1,15
1 #ifndef SCIQLOP_SQPDATETIME_H
2 #define SCIQLOP_SQPDATETIME_H
3
4 /**
5 * @brief The SqpDateTime struct holds the information of time parameters
6 * @sa SqpDateTime
7 */
8 struct SqpDateTime {
9 /// Start time
10 double m_TStart;
11 /// End time
12 double m_TEnd;
13 };
14
15 #endif // SCIQLOP_SQPDATETIME_H
@@ -0,0 +1,37
1 #ifndef SCIQLOP_TIMECONTROLLER_H
2 #define SCIQLOP_TIMECONTROLLER_H
3
4 #include <Data/SqpDateTime.h>
5
6 #include <QLoggingCategory>
7 #include <QObject>
8
9 #include <Common/spimpl.h>
10
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController)
13
14 /**
15 * @brief The TimeController class aims to handle the Time parameters notification in SciQlop.
16 */
17 class TimeController : public QObject {
18 Q_OBJECT
19 public:
20 explicit TimeController(QObject *parent = 0);
21
22 SqpDateTime dateTime() const noexcept;
23
24 signals:
25 /// Signal emitted to notify that time parameters has beed updated
26 void timeUpdated(SqpDateTime time);
27
28 public slots:
29 /// Slot called when a new dateTime has been defined. Call timeUpdated signal
30 void onTimeToUpdate(SqpDateTime dateTime);
31
32 private:
33 class TimeControllerPrivate;
34 spimpl::unique_impl_ptr<TimeControllerPrivate> impl;
35 };
36
37 #endif // SCIQLOP_TIMECONTROLLER_H
@@ -0,0 +1,26
1 #include "Time/TimeController.h"
2
3 Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController")
4
5 struct TimeController::TimeControllerPrivate {
6
7 SqpDateTime m_DateTime;
8 };
9
10 TimeController::TimeController(QObject *parent)
11 : QObject{parent}, impl{spimpl::make_unique_impl<TimeControllerPrivate>()}
12 {
13 qCDebug(LOG_TimeController()) << tr("TimeController construction");
14 }
15
16 SqpDateTime TimeController::dateTime() const noexcept
17 {
18 return impl->m_DateTime;
19 }
20
21 void TimeController::onTimeToUpdate(SqpDateTime dateTime)
22 {
23 impl->m_DateTime = dateTime;
24
25 emit timeUpdated(dateTime);
26 }
@@ -1,239 +1,248
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SciQLop Software
3 3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "MainWindow.h"
23 23 #include "ui_MainWindow.h"
24 24
25 25 #include <DataSource/DataSourceController.h>
26 26 #include <DataSource/DataSourceWidget.h>
27 27 #include <SidePane/SqpSidePane.h>
28 28 #include <SqpApplication.h>
29 #include <Time/TimeController.h>
29 30 #include <TimeWidget/TimeWidget.h>
30 31 #include <Variable/Variable.h>
31 32 #include <Visualization/VisualizationController.h>
32 33
33 34 #include <QAction>
34 35 #include <QDate>
35 36 #include <QDateTime>
36 37 #include <QDir>
37 38 #include <QFileDialog>
38 39 #include <QToolBar>
39 40 #include <QToolButton>
40 41 #include <memory.h>
41 42
42 43 //#include <omp.h>
43 44 //#include <network/filedownloader.h>
44 45 //#include <qlopdatabase.h>
45 46 //#include <qlopsettings.h>
46 47 //#include <qlopgui.h>
47 48 //#include <spacedata.h>
48 49 //#include "qlopcore.h"
49 50 //#include "qlopcodecmanager.h"
50 51 //#include "cdfcodec.h"
51 52 //#include "amdatxtcodec.h"
52 53 //#include <qlopplotmanager.h>
53 54
54 55 #include "iostream"
55 56
56 57 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
57 58
58 59 namespace {
59 60 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
60 61 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
61 62 const auto VIEWPLITTERINDEX = 2;
62 63 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
63 64 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
64 65 }
65 66
66 67 class MainWindow::MainWindowPrivate {
67 68 public:
68 69 QSize m_LastOpenLeftInspectorSize;
69 70 QSize m_LastOpenRightInspectorSize;
70 71 };
71 72
72 73 MainWindow::MainWindow(QWidget *parent)
73 74 : QMainWindow{parent},
74 75 m_Ui{new Ui::MainWindow},
75 76 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
76 77 {
77 78 m_Ui->setupUi(this);
78 79
79 80 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
80 81 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
81 82
82 83
83 84 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
84 85 auto openLeftInspectorAction = new QAction{QIcon{
85 86 ":/icones/previous.png",
86 87 },
87 88 tr("Show/hide the left inspector"), this};
88 89
89 90
90 91 auto spacerLeftTop = new QWidget{};
91 92 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
92 93
93 94 auto spacerLeftBottom = new QWidget{};
94 95 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
95 96
96 97 leftSidePane->addWidget(spacerLeftTop);
97 98 leftSidePane->addAction(openLeftInspectorAction);
98 99 leftSidePane->addWidget(spacerLeftBottom);
99 100
100 101
101 102 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
102 103 auto openRightInspectorAction = new QAction{QIcon{
103 104 ":/icones/next.png",
104 105 },
105 106 tr("Show/hide the right inspector"), this};
106 107
107 108 auto spacerRightTop = new QWidget{};
108 109 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
109 110
110 111 auto spacerRightBottom = new QWidget{};
111 112 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
112 113
113 114 rightSidePane->addWidget(spacerRightTop);
114 115 rightSidePane->addAction(openRightInspectorAction);
115 116 rightSidePane->addWidget(spacerRightBottom);
116 117
117 118 openLeftInspectorAction->setCheckable(true);
118 119 openRightInspectorAction->setCheckable(true);
119 120
120 121 auto openInspector = [this](bool checked, bool right, auto action) {
121 122
122 123 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
123 124
124 125 auto &lastInspectorSize
125 126 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
126 127
127 128 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
128 129 : m_Ui->leftMainInspectorWidget->size();
129 130
130 131 // Update of the last opened geometry
131 132 if (checked) {
132 133 lastInspectorSize = nextInspectorSize;
133 134 }
134 135
135 136 auto startSize = lastInspectorSize;
136 137 auto endSize = startSize;
137 138 endSize.setWidth(0);
138 139
139 140 auto splitterInspectorIndex
140 141 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
141 142
142 143 auto currentSizes = m_Ui->splitter->sizes();
143 144 if (checked) {
144 145 // adjust sizes individually here, e.g.
145 146 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
146 147 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
147 148 m_Ui->splitter->setSizes(currentSizes);
148 149 }
149 150 else {
150 151 // adjust sizes individually here, e.g.
151 152 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
152 153 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
153 154 m_Ui->splitter->setSizes(currentSizes);
154 155 }
155 156
156 157 };
157 158
158 159
159 160 connect(openLeftInspectorAction, &QAction::triggered,
160 161 [openInspector, openLeftInspectorAction](bool checked) {
161 162 openInspector(checked, false, openLeftInspectorAction);
162 163 });
163 164 connect(openRightInspectorAction, &QAction::triggered,
164 165 [openInspector, openRightInspectorAction](bool checked) {
165 166 openInspector(checked, true, openRightInspectorAction);
166 167 });
167 168
168 169 this->menuBar()->addAction(tr("File"));
169 170 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
170 171
171 mainToolBar->addWidget(new TimeWidget{});
172 auto timeWidget = new TimeWidget{};
173 mainToolBar->addWidget(timeWidget);
172 174
173 175 // Widgets / controllers connections
176
177 // DataSource
174 178 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
175 179 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
176 180
181 // Time
182 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 SLOT(onTimeToUpdate(SqpDateTime)));
184
185 // Variable
177 186 qRegisterMetaType<std::shared_ptr<Variable> >();
178 187 connect(&sqpApp->visualizationController(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
179 188 m_Ui->view, SLOT(displayVariable(std::shared_ptr<Variable>)));
180 189
181 190 /* QLopGUI::registerMenuBar(menuBar());
182 191 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
183 192 this->m_progressWidget = new QWidget();
184 193 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
185 194 this->m_progressWidget->setLayout(this->m_progressLayout);
186 195 this->m_progressWidget->setWindowModality(Qt::WindowModal);
187 196 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
188 197 for(int i=0;i<OMP_THREADS;i++)
189 198 {
190 199 this->m_progress.append(new QProgressBar(this->m_progressWidget));
191 200 this->m_progress.last()->setMinimum(0);
192 201 this->m_progress.last()->setMaximum(100);
193 202 this->m_progressLayout->addWidget(this->m_progress.last());
194 203 this->m_progressWidget->hide();
195 204 this->m_progressThreadIds[i] = -1;
196 205 }
197 206 this->m_progressWidget->setWindowTitle("Loading File");
198 207 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
199 208 << QLopCore::self()
200 209 << QLopPlotManager::self()
201 210 << QLopCodecManager::self()
202 211 << FileDownloader::self()
203 212 << QLopDataBase::self()
204 213 << SpaceData::self();
205 214
206 215 CDFCodec::registerToManager();
207 216 AMDATXTCodec::registerToManager();
208 217
209 218
210 219 for(int i=0;i<ServicesToLoad.count();i++)
211 220 {
212 221 qDebug()<<ServicesToLoad.at(i)->serviceName();
213 222 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
214 223 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
215 224 if(wdgt)
216 225 {
217 226 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
218 227 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
219 228 }
220 229 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
221 230 }*/
222 231 }
223 232
224 233 MainWindow::~MainWindow()
225 234 {
226 235 }
227 236
228 237
229 238 void MainWindow::changeEvent(QEvent *e)
230 239 {
231 240 QMainWindow::changeEvent(e);
232 241 switch (e->type()) {
233 242 case QEvent::LanguageChange:
234 243 m_Ui->retranslateUi(this);
235 244 break;
236 245 default:
237 246 break;
238 247 }
239 248 }
@@ -1,16 +1,15
1 1 #ifndef SCIQLOP_DATAPROVIDERPARAMETERS_H
2 2 #define SCIQLOP_DATAPROVIDERPARAMETERS_H
3 3
4 #include "SqpDateTime.h"
5
4 6 /**
5 7 * @brief The DataProviderParameters struct holds the information needed to retrieve data from a
6 8 * data provider
7 9 * @sa IDataProvider
8 10 */
9 11 struct DataProviderParameters {
10 /// Start time
11 double m_TStart;
12 /// End time
13 double m_TEnd;
12 SqpDateTime m_Time;
14 13 };
15 14
16 15 #endif // SCIQLOP_DATAPROVIDERPARAMETERS_H
@@ -1,48 +1,51
1 1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
2 2 #define SCIQLOP_VARIABLECONTROLLER_H
3 3
4 4 #include <QLoggingCategory>
5 5 #include <QObject>
6 6
7 7 #include <Common/spimpl.h>
8 8
9 9 class IDataProvider;
10 class TimeController;
10 11 class Variable;
11 12 class VariableModel;
12 13
13 14 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
14 15
15 16 /**
16 17 * @brief The VariableController class aims to handle the variables in SciQlop.
17 18 */
18 19 class VariableController : public QObject {
19 20 Q_OBJECT
20 21 public:
21 22 explicit VariableController(QObject *parent = 0);
22 23 virtual ~VariableController();
23 24
24 25 VariableModel *variableModel() noexcept;
25 26
27 void setTimeController(TimeController *timeController) noexcept;
28
26 29 signals:
27 30 /// Signal emitted when a variable has been created
28 31 void variableCreated(std::shared_ptr<Variable> variable);
29 32
30 33 public slots:
31 34 /**
32 35 * Creates a new variable and adds it to the model
33 36 * @param name the name of the new variable
34 37 * @param provider the data provider for the new variable
35 38 */
36 39 void createVariable(const QString &name, std::shared_ptr<IDataProvider> provider) noexcept;
37 40
38 41 void initialize();
39 42 void finalize();
40 43
41 44 private:
42 45 void waitForFinish();
43 46
44 47 class VariableControllerPrivate;
45 48 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
46 49 };
47 50
48 51 #endif // SCIQLOP_VARIABLECONTROLLER_H
@@ -1,91 +1,110
1 1 #include <Variable/VariableController.h>
2 2 #include <Variable/VariableModel.h>
3 3
4 4 #include <Data/DataProviderParameters.h>
5 5 #include <Data/IDataProvider.h>
6 6 #include <Data/IDataSeries.h>
7 #include <Time/TimeController.h>
7 8
8 9 #include <QDateTime>
9 10 #include <QMutex>
10 11 #include <QThread>
11 12
12 13 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
13 14
14 15 namespace {
15 16
16 17 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
17 18 /// will be deleted when the timerange is recovered from SciQlop
18 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider) noexcept
19 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
20 const SqpDateTime &dateTime) noexcept
19 21 {
20 auto parameters = DataProviderParameters{
21 // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
22 static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
23 / 1000.),
24 static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
25 / 1000.};
22 auto parameters = DataProviderParameters{dateTime};
26 23
27 24 return provider.retrieveData(parameters);
28 25 }
29 26
30 27 } // namespace
31 28
32 29 struct VariableController::VariableControllerPrivate {
33 30 explicit VariableControllerPrivate(VariableController *parent)
34 31 : m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}
35 32 {
36 33 }
37 34
38 35 QMutex m_WorkingMutex;
39 36 /// Variable model. The VariableController has the ownership
40 37 VariableModel *m_VariableModel;
38
39 TimeController *m_TimeController;
41 40 };
42 41
43 42 VariableController::VariableController(QObject *parent)
44 43 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
45 44 {
46 45 qCDebug(LOG_VariableController()) << tr("VariableController construction")
47 46 << QThread::currentThread();
48 47 }
49 48
50 49 VariableController::~VariableController()
51 50 {
52 51 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
53 52 << QThread::currentThread();
54 53 this->waitForFinish();
55 54 }
56 55
57 56 VariableModel *VariableController::variableModel() noexcept
58 57 {
59 58 return impl->m_VariableModel;
60 59 }
61 60
61 void VariableController::setTimeController(TimeController *timeController) noexcept
62 {
63 impl->m_TimeController = timeController;
64 }
65
62 66 void VariableController::createVariable(const QString &name,
63 67 std::shared_ptr<IDataProvider> provider) noexcept
64 68 {
69 // TORM
70 // auto dateTime = SqpDateTime{
71 // // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
72 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
73 // / 1000.),
74 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
75 // / 1000.};
76
77 if (!impl->m_TimeController) {
78 qCCritical(LOG_VariableController())
79 << tr("Impossible to create variable: The time controller is null");
80 return;
81 }
82
83
65 84 /// @todo : for the moment :
66 85 /// - the provider is only used to retrieve data from the variable for its initialization, but
67 86 /// it will be retained later
68 87 /// - default data are generated for the variable, without taking into account the timerange set
69 88 /// in sciqlop
70 if (auto newVariable
71 = impl->m_VariableModel->createVariable(name, generateDefaultDataSeries(*provider))) {
89 if (auto newVariable = impl->m_VariableModel->createVariable(
90 name, generateDefaultDataSeries(*provider, impl->m_TimeController->dateTime()))) {
72 91 emit variableCreated(newVariable);
73 92 }
74 93 }
75 94
76 95 void VariableController::initialize()
77 96 {
78 97 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
79 98 impl->m_WorkingMutex.lock();
80 99 qCDebug(LOG_VariableController()) << tr("VariableController init END");
81 100 }
82 101
83 102 void VariableController::finalize()
84 103 {
85 104 impl->m_WorkingMutex.unlock();
86 105 }
87 106
88 107 void VariableController::waitForFinish()
89 108 {
90 109 QMutexLocker locker{&impl->m_WorkingMutex};
91 110 }
@@ -1,48 +1,50
1 1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 2 #define SCIQLOP_SQPAPPLICATION_H
3 3
4 4 #include "SqpApplication.h"
5 5
6 6 #include <QApplication>
7 7 #include <QLoggingCategory>
8 8
9 9 #include <Common/spimpl.h>
10 10
11 11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12 12
13 13 #if defined(sqpApp)
14 14 #undef sqpApp
15 15 #endif
16 16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
17 17
18 18 class DataSourceController;
19 class TimeController;
19 20 class VariableController;
20 21 class VisualizationController;
21 22
22 23 /**
23 24 * @brief The SqpApplication class aims to make the link between SciQlop
24 25 * and its plugins. This is the intermediate class that SciQlop has to use
25 26 * in the way to connect a data source. Please first use load method to initialize
26 27 * a plugin specified by its metadata name (JSON plugin source) then others specifics
27 28 * method will be able to access it.
28 29 * You can load a data source driver plugin then create a data source.
29 30 */
30 31
31 32 class SqpApplication : public QApplication {
32 33 Q_OBJECT
33 34 public:
34 35 explicit SqpApplication(int &argc, char **argv);
35 36 virtual ~SqpApplication();
36 37 void initialize();
37 38
38 39 /// Accessors for the differents sciqlop controllers
39 40 DataSourceController &dataSourceController() noexcept;
41 TimeController &timeController() noexcept;
40 42 VariableController &variableController() noexcept;
41 43 VisualizationController &visualizationController() noexcept;
42 44
43 45 private:
44 46 class SqpApplicationPrivate;
45 47 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
46 48 };
47 49
48 50 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,21 +1,32
1 1 #ifndef SCIQLOP_TIMEWIDGET_H
2 2 #define SCIQLOP_TIMEWIDGET_H
3 3
4 4 #include <QWidget>
5 5
6 #include <Data/SqpDateTime.h>
7
6 8 namespace Ui {
7 9 class TimeWidget;
8 10 } // Ui
9 11
10 12 class TimeWidget : public QWidget {
11 13 Q_OBJECT
12 14
13 15 public:
14 16 explicit TimeWidget(QWidget *parent = 0);
15 17 virtual ~TimeWidget();
16 18
19 signals:
20 /// Signal emitted when the time parameters has beed updated
21 void timeUpdated(SqpDateTime time);
22
23 public slots:
24 /// slot called when time parameters update has ben requested
25 void onTimeUpdateRequested();
26
27
17 28 private:
18 29 Ui::TimeWidget *ui;
19 30 };
20 31
21 32 #endif // SCIQLOP_ SQPSIDEPANE_H
@@ -1,109 +1,120
1 1 #include "SqpApplication.h"
2 2
3 3 #include <Data/IDataProvider.h>
4 4 #include <DataSource/DataSourceController.h>
5 5 #include <QThread>
6 #include <Time/TimeController.h>
6 7 #include <Variable/Variable.h>
7 8 #include <Variable/VariableController.h>
8 9 #include <Visualization/VisualizationController.h>
9 10
10 11 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
11 12
12 13 class SqpApplication::SqpApplicationPrivate {
13 14 public:
14 15 SqpApplicationPrivate()
15 16 : m_DataSourceController{std::make_unique<DataSourceController>()},
17 m_TimeController{std::make_unique<TimeController>()},
16 18 m_VariableController{std::make_unique<VariableController>()},
17 19 m_VisualizationController{std::make_unique<VisualizationController>()}
18 20 {
19 21 // /////////////////////////////// //
20 22 // Connections between controllers //
21 23 // /////////////////////////////// //
22 24
23 25 // VariableController <-> DataSourceController
24 26 qRegisterMetaType<std::shared_ptr<IDataProvider> >();
25 27 connect(m_DataSourceController.get(),
26 28 SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)),
27 29 m_VariableController.get(),
28 30 SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>)));
29 31
30 32 // VariableController <-> VisualizationController
31 33 qRegisterMetaType<std::shared_ptr<Variable> >();
32 34 connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
33 35 m_VisualizationController.get(),
34 36 SIGNAL(variableCreated(std::shared_ptr<Variable>)));
35 37
36 38 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
37 39 m_VariableController->moveToThread(&m_VariableControllerThread);
38 40 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
41
42 // Additionnal init
43 m_VariableController->setTimeController(m_TimeController.get());
39 44 }
40 45
41 46 virtual ~SqpApplicationPrivate()
42 47 {
43 48 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
44 49 m_DataSourceControllerThread.quit();
45 50 m_DataSourceControllerThread.wait();
46 51
47 52 m_VariableControllerThread.quit();
48 53 m_VariableControllerThread.wait();
49 54
50 55 m_VisualizationControllerThread.quit();
51 56 m_VisualizationControllerThread.wait();
52 57 }
53 58
54 59 std::unique_ptr<DataSourceController> m_DataSourceController;
55 60 std::unique_ptr<VariableController> m_VariableController;
61 std::unique_ptr<TimeController> m_TimeController;
56 62 std::unique_ptr<VisualizationController> m_VisualizationController;
57 63 QThread m_DataSourceControllerThread;
58 64 QThread m_VariableControllerThread;
59 65 QThread m_VisualizationControllerThread;
60 66 };
61 67
62 68
63 69 SqpApplication::SqpApplication(int &argc, char **argv)
64 70 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
65 71 {
66 72 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
67 73
68 74 connect(&impl->m_DataSourceControllerThread, &QThread::started,
69 75 impl->m_DataSourceController.get(), &DataSourceController::initialize);
70 76 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
71 77 impl->m_DataSourceController.get(), &DataSourceController::finalize);
72 78
73 79 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
74 80 &VariableController::initialize);
75 81 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
76 82 &VariableController::finalize);
77 83
78 84 connect(&impl->m_VisualizationControllerThread, &QThread::started,
79 85 impl->m_VisualizationController.get(), &VisualizationController::initialize);
80 86 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
81 87 impl->m_VisualizationController.get(), &VisualizationController::finalize);
82 88
83 89 impl->m_DataSourceControllerThread.start();
84 90 impl->m_VariableControllerThread.start();
85 91 impl->m_VisualizationControllerThread.start();
86 92 }
87 93
88 94 SqpApplication::~SqpApplication()
89 95 {
90 96 }
91 97
92 98 void SqpApplication::initialize()
93 99 {
94 100 }
95 101
96 102 DataSourceController &SqpApplication::dataSourceController() noexcept
97 103 {
98 104 return *impl->m_DataSourceController;
99 105 }
100 106
107 TimeController &SqpApplication::timeController() noexcept
108 {
109 return *impl->m_TimeController;
110 }
111
101 112 VariableController &SqpApplication::variableController() noexcept
102 113 {
103 114 return *impl->m_VariableController;
104 115 }
105 116
106 117 VisualizationController &SqpApplication::visualizationController() noexcept
107 118 {
108 119 return *impl->m_VisualizationController;
109 120 }
@@ -1,12 +1,29
1 1 #include "TimeWidget/TimeWidget.h"
2 2 #include "ui_TimeWidget.h"
3 3
4
4 5 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
5 6 {
6 7 ui->setupUi(this);
8
9 // Connection
10 connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
11 &TimeWidget::onTimeUpdateRequested);
12
13 connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
14 &TimeWidget::onTimeUpdateRequested);
7 15 }
8 16
9 17 TimeWidget::~TimeWidget()
10 18 {
11 19 delete ui;
12 20 }
21
22 void TimeWidget::onTimeUpdateRequested()
23 {
24 auto dateTime = SqpDateTime{
25 static_cast<double>(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.),
26 static_cast<double>(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.};
27
28 emit timeUpdated(std::move(dateTime));
29 }
@@ -1,30 +1,32
1 1 #include "CosinusProvider.h"
2 2
3 3 #include <Data/DataProviderParameters.h>
4 4 #include <Data/ScalarSeries.h>
5 5
6 6 #include <cmath>
7 7
8 8 std::unique_ptr<IDataSeries>
9 9 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
10 10 {
11 auto dateTime = parameters.m_Time;
12
11 13 // Gets the timerange from the parameters
12 auto start = parameters.m_TStart;
13 auto end = parameters.m_TEnd;
14 auto start = dateTime.m_TStart;
15 auto end = dateTime.m_TEnd;
14 16
15 17 // We assure that timerange is valid
16 18 if (end < start) {
17 19 std::swap(start, end);
18 20 }
19 21
20 22 // Generates scalar series containing cosinus values (one value per second)
21 23 auto scalarSeries
22 24 = std::make_unique<ScalarSeries>(end - start, Unit{QStringLiteral("t"), true}, Unit{});
23 25
24 26 auto dataIndex = 0;
25 27 for (auto time = start; time < end; ++time, ++dataIndex) {
26 28 scalarSeries->setData(dataIndex, time, std::cos(time));
27 29 }
28 30
29 31 return scalarSeries;
30 32 }
General Comments 0
You need to be logged in to leave comments. Login now