##// END OF EJS Templates
Add catalogue controller to SqpApplication
trabillard -
r1177:cca0e9bff7aa
parent child
Show More
@@ -1,69 +1,71
1 #ifndef SCIQLOP_SQPAPPLICATION_H
1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
3
3
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5
5
6 #include <QApplication>
6 #include <QApplication>
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8
8
9 #include <Common/spimpl.h>
9 #include <Common/spimpl.h>
10
10
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12
12
13 #if defined(sqpApp)
13 #if defined(sqpApp)
14 #undef sqpApp
14 #undef sqpApp
15 #endif
15 #endif
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
17
17
18 class DataSourceController;
18 class DataSourceController;
19 class NetworkController;
19 class NetworkController;
20 class TimeController;
20 class TimeController;
21 class VariableController;
21 class VariableController;
22 class VisualizationController;
22 class VisualizationController;
23 class DragDropGuiController;
23 class DragDropGuiController;
24 class ActionsGuiController;
24 class ActionsGuiController;
25 class CatalogueController;
25
26
26 /**
27 /**
27 * @brief The SqpApplication class aims to make the link between SciQlop
28 * @brief The SqpApplication class aims to make the link between SciQlop
28 * and its plugins. This is the intermediate class that SciQlop has to use
29 * and its plugins. This is the intermediate class that SciQlop has to use
29 * in the way to connect a data source. Please first use load method to initialize
30 * in the way to connect a data source. Please first use load method to initialize
30 * a plugin specified by its metadata name (JSON plugin source) then others specifics
31 * a plugin specified by its metadata name (JSON plugin source) then others specifics
31 * method will be able to access it.
32 * method will be able to access it.
32 * You can load a data source driver plugin then create a data source.
33 * You can load a data source driver plugin then create a data source.
33 */
34 */
34
35
35 class SqpApplication : public QApplication {
36 class SqpApplication : public QApplication {
36 Q_OBJECT
37 Q_OBJECT
37 public:
38 public:
38 explicit SqpApplication(int &argc, char **argv);
39 explicit SqpApplication(int &argc, char **argv);
39 virtual ~SqpApplication();
40 virtual ~SqpApplication();
40 void initialize();
41 void initialize();
41
42
42 /// Accessors for the differents sciqlop controllers
43 /// Accessors for the differents sciqlop controllers
43 DataSourceController &dataSourceController() noexcept;
44 DataSourceController &dataSourceController() noexcept;
44 NetworkController &networkController() noexcept;
45 NetworkController &networkController() noexcept;
45 TimeController &timeController() noexcept;
46 TimeController &timeController() noexcept;
46 VariableController &variableController() noexcept;
47 VariableController &variableController() noexcept;
47 VisualizationController &visualizationController() noexcept;
48 VisualizationController &visualizationController() noexcept;
49 CatalogueController &catalogueController() noexcept;
48
50
49 /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but
51 /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but
50 /// doesn't live in a thread and access gui
52 /// doesn't live in a thread and access gui
51 DragDropGuiController &dragDropGuiController() noexcept;
53 DragDropGuiController &dragDropGuiController() noexcept;
52 ActionsGuiController &actionsGuiController() noexcept;
54 ActionsGuiController &actionsGuiController() noexcept;
53
55
54 enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones };
56 enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones };
55
57
56 enum class PlotsCursorMode { NoCursor, Vertical, Temporal, Horizontal, Cross };
58 enum class PlotsCursorMode { NoCursor, Vertical, Temporal, Horizontal, Cross };
57
59
58 PlotsInteractionMode plotsInteractionMode() const;
60 PlotsInteractionMode plotsInteractionMode() const;
59 void setPlotsInteractionMode(PlotsInteractionMode mode);
61 void setPlotsInteractionMode(PlotsInteractionMode mode);
60
62
61 PlotsCursorMode plotsCursorMode() const;
63 PlotsCursorMode plotsCursorMode() const;
62 void setPlotsCursorMode(PlotsCursorMode mode);
64 void setPlotsCursorMode(PlotsCursorMode mode);
63
65
64 private:
66 private:
65 class SqpApplicationPrivate;
67 class SqpApplicationPrivate;
66 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
68 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
67 };
69 };
68
70
69 #endif // SCIQLOP_SQPAPPLICATION_H
71 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,212 +1,217
1 #include "SqpApplication.h"
1 #include "SqpApplication.h"
2
2
3 #include <Actions/ActionsGuiController.h>
3 #include <Actions/ActionsGuiController.h>
4 #include <Catalogue/CatalogueController.h>
4 #include <Catalogue/CatalogueController.h>
5 #include <Data/IDataProvider.h>
5 #include <Data/IDataProvider.h>
6 #include <DataSource/DataSourceController.h>
6 #include <DataSource/DataSourceController.h>
7 #include <DragAndDrop/DragDropGuiController.h>
7 #include <DragAndDrop/DragDropGuiController.h>
8 #include <Network/NetworkController.h>
8 #include <Network/NetworkController.h>
9 #include <QThread>
9 #include <QThread>
10 #include <Time/TimeController.h>
10 #include <Time/TimeController.h>
11 #include <Variable/Variable.h>
11 #include <Variable/Variable.h>
12 #include <Variable/VariableController.h>
12 #include <Variable/VariableController.h>
13 #include <Variable/VariableModel.h>
13 #include <Variable/VariableModel.h>
14 #include <Visualization/VisualizationController.h>
14 #include <Visualization/VisualizationController.h>
15
15
16 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
16 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
17
17
18 class SqpApplication::SqpApplicationPrivate {
18 class SqpApplication::SqpApplicationPrivate {
19 public:
19 public:
20 SqpApplicationPrivate()
20 SqpApplicationPrivate()
21 : m_DataSourceController{std::make_unique<DataSourceController>()},
21 : m_DataSourceController{std::make_unique<DataSourceController>()},
22 m_VariableController{std::make_unique<VariableController>()},
22 m_VariableController{std::make_unique<VariableController>()},
23 m_TimeController{std::make_unique<TimeController>()},
23 m_TimeController{std::make_unique<TimeController>()},
24 m_NetworkController{std::make_unique<NetworkController>()},
24 m_NetworkController{std::make_unique<NetworkController>()},
25 m_VisualizationController{std::make_unique<VisualizationController>()},
25 m_VisualizationController{std::make_unique<VisualizationController>()},
26 m_DragDropGuiController{std::make_unique<DragDropGuiController>()},
26 m_DragDropGuiController{std::make_unique<DragDropGuiController>()},
27 m_CatalogueController{std::make_unique<CatalogueController>()},
27 m_CatalogueController{std::make_unique<CatalogueController>()},
28 m_ActionsGuiController{std::make_unique<ActionsGuiController>()},
28 m_ActionsGuiController{std::make_unique<ActionsGuiController>()},
29 m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None),
29 m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None),
30 m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor)
30 m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor)
31 {
31 {
32 // /////////////////////////////// //
32 // /////////////////////////////// //
33 // Connections between controllers //
33 // Connections between controllers //
34 // /////////////////////////////// //
34 // /////////////////////////////// //
35
35
36 // VariableController <-> DataSourceController
36 // VariableController <-> DataSourceController
37 connect(m_DataSourceController.get(),
37 connect(m_DataSourceController.get(),
38 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
38 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
39 std::shared_ptr<IDataProvider>)),
39 std::shared_ptr<IDataProvider>)),
40 m_VariableController.get(),
40 m_VariableController.get(),
41 SLOT(createVariable(const QString &, const QVariantHash &,
41 SLOT(createVariable(const QString &, const QVariantHash &,
42 std::shared_ptr<IDataProvider>)));
42 std::shared_ptr<IDataProvider>)));
43
43
44 connect(m_VariableController->variableModel(), &VariableModel::requestVariable,
44 connect(m_VariableController->variableModel(), &VariableModel::requestVariable,
45 m_DataSourceController.get(), &DataSourceController::requestVariable);
45 m_DataSourceController.get(), &DataSourceController::requestVariable);
46
46
47 // VariableController <-> VisualizationController
47 // VariableController <-> VisualizationController
48 connect(m_VariableController.get(),
48 connect(m_VariableController.get(),
49 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
49 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
50 m_VisualizationController.get(),
50 m_VisualizationController.get(),
51 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
51 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
52
52
53 connect(m_VariableController.get(),
53 connect(m_VariableController.get(),
54 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)),
54 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)),
55 m_VisualizationController.get(),
55 m_VisualizationController.get(),
56 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
56 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
57
57
58
58
59 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
59 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
60 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
60 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
61 m_NetworkController->moveToThread(&m_NetworkControllerThread);
61 m_NetworkController->moveToThread(&m_NetworkControllerThread);
62 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
62 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
63 m_VariableController->moveToThread(&m_VariableControllerThread);
63 m_VariableController->moveToThread(&m_VariableControllerThread);
64 m_VariableControllerThread.setObjectName("VariableControllerThread");
64 m_VariableControllerThread.setObjectName("VariableControllerThread");
65 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
65 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
66 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
66 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
67 m_CatalogueController->moveToThread(&m_CatalogueControllerThread);
67 m_CatalogueController->moveToThread(&m_CatalogueControllerThread);
68 m_CatalogueControllerThread.setObjectName("CatalogueControllerThread");
68 m_CatalogueControllerThread.setObjectName("CatalogueControllerThread");
69
69
70
70
71 // Additionnal init
71 // Additionnal init
72 m_VariableController->setTimeController(m_TimeController.get());
72 m_VariableController->setTimeController(m_TimeController.get());
73 }
73 }
74
74
75 virtual ~SqpApplicationPrivate()
75 virtual ~SqpApplicationPrivate()
76 {
76 {
77 m_DataSourceControllerThread.quit();
77 m_DataSourceControllerThread.quit();
78 m_DataSourceControllerThread.wait();
78 m_DataSourceControllerThread.wait();
79
79
80 m_NetworkControllerThread.quit();
80 m_NetworkControllerThread.quit();
81 m_NetworkControllerThread.wait();
81 m_NetworkControllerThread.wait();
82
82
83 m_VariableControllerThread.quit();
83 m_VariableControllerThread.quit();
84 m_VariableControllerThread.wait();
84 m_VariableControllerThread.wait();
85
85
86 m_VisualizationControllerThread.quit();
86 m_VisualizationControllerThread.quit();
87 m_VisualizationControllerThread.wait();
87 m_VisualizationControllerThread.wait();
88
88
89 m_CatalogueControllerThread.quit();
89 m_CatalogueControllerThread.quit();
90 m_CatalogueControllerThread.wait();
90 m_CatalogueControllerThread.wait();
91 }
91 }
92
92
93 std::unique_ptr<DataSourceController> m_DataSourceController;
93 std::unique_ptr<DataSourceController> m_DataSourceController;
94 std::unique_ptr<VariableController> m_VariableController;
94 std::unique_ptr<VariableController> m_VariableController;
95 std::unique_ptr<TimeController> m_TimeController;
95 std::unique_ptr<TimeController> m_TimeController;
96 std::unique_ptr<NetworkController> m_NetworkController;
96 std::unique_ptr<NetworkController> m_NetworkController;
97 std::unique_ptr<VisualizationController> m_VisualizationController;
97 std::unique_ptr<VisualizationController> m_VisualizationController;
98 std::unique_ptr<CatalogueController> m_CatalogueController;
98 std::unique_ptr<CatalogueController> m_CatalogueController;
99
99
100 QThread m_DataSourceControllerThread;
100 QThread m_DataSourceControllerThread;
101 QThread m_NetworkControllerThread;
101 QThread m_NetworkControllerThread;
102 QThread m_VariableControllerThread;
102 QThread m_VariableControllerThread;
103 QThread m_VisualizationControllerThread;
103 QThread m_VisualizationControllerThread;
104 QThread m_CatalogueControllerThread;
104 QThread m_CatalogueControllerThread;
105
105
106 std::unique_ptr<DragDropGuiController> m_DragDropGuiController;
106 std::unique_ptr<DragDropGuiController> m_DragDropGuiController;
107 std::unique_ptr<ActionsGuiController> m_ActionsGuiController;
107 std::unique_ptr<ActionsGuiController> m_ActionsGuiController;
108
108
109 SqpApplication::PlotsInteractionMode m_PlotInterractionMode;
109 SqpApplication::PlotsInteractionMode m_PlotInterractionMode;
110 SqpApplication::PlotsCursorMode m_PlotCursorMode;
110 SqpApplication::PlotsCursorMode m_PlotCursorMode;
111 };
111 };
112
112
113
113
114 SqpApplication::SqpApplication(int &argc, char **argv)
114 SqpApplication::SqpApplication(int &argc, char **argv)
115 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
115 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
116 {
116 {
117 qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread();
117 qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread();
118
118
119 connect(&impl->m_DataSourceControllerThread, &QThread::started,
119 connect(&impl->m_DataSourceControllerThread, &QThread::started,
120 impl->m_DataSourceController.get(), &DataSourceController::initialize);
120 impl->m_DataSourceController.get(), &DataSourceController::initialize);
121 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
121 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
122 impl->m_DataSourceController.get(), &DataSourceController::finalize);
122 impl->m_DataSourceController.get(), &DataSourceController::finalize);
123
123
124 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
124 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
125 &NetworkController::initialize);
125 &NetworkController::initialize);
126 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
126 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
127 &NetworkController::finalize);
127 &NetworkController::finalize);
128
128
129 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
129 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
130 &VariableController::initialize);
130 &VariableController::initialize);
131 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
131 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
132 &VariableController::finalize);
132 &VariableController::finalize);
133
133
134 connect(&impl->m_VisualizationControllerThread, &QThread::started,
134 connect(&impl->m_VisualizationControllerThread, &QThread::started,
135 impl->m_VisualizationController.get(), &VisualizationController::initialize);
135 impl->m_VisualizationController.get(), &VisualizationController::initialize);
136 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
136 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
137 impl->m_VisualizationController.get(), &VisualizationController::finalize);
137 impl->m_VisualizationController.get(), &VisualizationController::finalize);
138
138
139 connect(&impl->m_CatalogueControllerThread, &QThread::started,
139 connect(&impl->m_CatalogueControllerThread, &QThread::started,
140 impl->m_CatalogueController.get(), &CatalogueController::initialize);
140 impl->m_CatalogueController.get(), &CatalogueController::initialize);
141 connect(&impl->m_CatalogueControllerThread, &QThread::finished,
141 connect(&impl->m_CatalogueControllerThread, &QThread::finished,
142 impl->m_CatalogueController.get(), &CatalogueController::finalize);
142 impl->m_CatalogueController.get(), &CatalogueController::finalize);
143
143
144 impl->m_DataSourceControllerThread.start();
144 impl->m_DataSourceControllerThread.start();
145 impl->m_NetworkControllerThread.start();
145 impl->m_NetworkControllerThread.start();
146 impl->m_VariableControllerThread.start();
146 impl->m_VariableControllerThread.start();
147 impl->m_VisualizationControllerThread.start();
147 impl->m_VisualizationControllerThread.start();
148 impl->m_CatalogueControllerThread.start();
148 impl->m_CatalogueControllerThread.start();
149 }
149 }
150
150
151 SqpApplication::~SqpApplication()
151 SqpApplication::~SqpApplication()
152 {
152 {
153 }
153 }
154
154
155 void SqpApplication::initialize()
155 void SqpApplication::initialize()
156 {
156 {
157 }
157 }
158
158
159 DataSourceController &SqpApplication::dataSourceController() noexcept
159 DataSourceController &SqpApplication::dataSourceController() noexcept
160 {
160 {
161 return *impl->m_DataSourceController;
161 return *impl->m_DataSourceController;
162 }
162 }
163
163
164 NetworkController &SqpApplication::networkController() noexcept
164 NetworkController &SqpApplication::networkController() noexcept
165 {
165 {
166 return *impl->m_NetworkController;
166 return *impl->m_NetworkController;
167 }
167 }
168
168
169 TimeController &SqpApplication::timeController() noexcept
169 TimeController &SqpApplication::timeController() noexcept
170 {
170 {
171 return *impl->m_TimeController;
171 return *impl->m_TimeController;
172 }
172 }
173
173
174 VariableController &SqpApplication::variableController() noexcept
174 VariableController &SqpApplication::variableController() noexcept
175 {
175 {
176 return *impl->m_VariableController;
176 return *impl->m_VariableController;
177 }
177 }
178
178
179 VisualizationController &SqpApplication::visualizationController() noexcept
179 VisualizationController &SqpApplication::visualizationController() noexcept
180 {
180 {
181 return *impl->m_VisualizationController;
181 return *impl->m_VisualizationController;
182 }
182 }
183
183
184 CatalogueController &SqpApplication::catalogueController() noexcept
185 {
186 return *impl->m_CatalogueController;
187 }
188
184 DragDropGuiController &SqpApplication::dragDropGuiController() noexcept
189 DragDropGuiController &SqpApplication::dragDropGuiController() noexcept
185 {
190 {
186 return *impl->m_DragDropGuiController;
191 return *impl->m_DragDropGuiController;
187 }
192 }
188
193
189 ActionsGuiController &SqpApplication::actionsGuiController() noexcept
194 ActionsGuiController &SqpApplication::actionsGuiController() noexcept
190 {
195 {
191 return *impl->m_ActionsGuiController;
196 return *impl->m_ActionsGuiController;
192 }
197 }
193
198
194 SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const
199 SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const
195 {
200 {
196 return impl->m_PlotInterractionMode;
201 return impl->m_PlotInterractionMode;
197 }
202 }
198
203
199 void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode)
204 void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode)
200 {
205 {
201 impl->m_PlotInterractionMode = mode;
206 impl->m_PlotInterractionMode = mode;
202 }
207 }
203
208
204 SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const
209 SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const
205 {
210 {
206 return impl->m_PlotCursorMode;
211 return impl->m_PlotCursorMode;
207 }
212 }
208
213
209 void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode)
214 void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode)
210 {
215 {
211 impl->m_PlotCursorMode = mode;
216 impl->m_PlotCursorMode = mode;
212 }
217 }
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

You need to be logged in to leave comments. Login now