##// END OF EJS Templates
Fix wrong merge
Thibaud Rabillard -
r1122:6c9818605a3c
parent child
Show More
@@ -1,198 +1,212
1 1 #include "SqpApplication.h"
2 2
3 3 #include <Actions/ActionsGuiController.h>
4 #include <Catalogue/CatalogueController.h>
4 5 #include <Data/IDataProvider.h>
5 6 #include <DataSource/DataSourceController.h>
6 7 #include <DragAndDrop/DragDropGuiController.h>
7 8 #include <Network/NetworkController.h>
8 9 #include <QThread>
9 10 #include <Time/TimeController.h>
10 11 #include <Variable/Variable.h>
11 12 #include <Variable/VariableController.h>
12 13 #include <Variable/VariableModel.h>
13 14 #include <Visualization/VisualizationController.h>
14 15
15 16 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
16 17
17 18 class SqpApplication::SqpApplicationPrivate {
18 19 public:
19 20 SqpApplicationPrivate()
20 21 : m_DataSourceController{std::make_unique<DataSourceController>()},
21 22 m_VariableController{std::make_unique<VariableController>()},
22 23 m_TimeController{std::make_unique<TimeController>()},
23 24 m_NetworkController{std::make_unique<NetworkController>()},
24 25 m_VisualizationController{std::make_unique<VisualizationController>()},
25 26 m_DragDropGuiController{std::make_unique<DragDropGuiController>()},
26 27 m_CatalogueController{std::make_unique<CatalogueController>()},
27 28 m_ActionsGuiController{std::make_unique<ActionsGuiController>()},
28 29 m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None),
29 30 m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor)
30 31 {
31 32 // /////////////////////////////// //
32 33 // Connections between controllers //
33 34 // /////////////////////////////// //
34 35
35 36 // VariableController <-> DataSourceController
36 37 connect(m_DataSourceController.get(),
37 38 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
38 39 std::shared_ptr<IDataProvider>)),
39 40 m_VariableController.get(),
40 41 SLOT(createVariable(const QString &, const QVariantHash &,
41 42 std::shared_ptr<IDataProvider>)));
42 43
43 44 connect(m_VariableController->variableModel(), &VariableModel::requestVariable,
44 45 m_DataSourceController.get(), &DataSourceController::requestVariable);
45 46
46 47 // VariableController <-> VisualizationController
47 48 connect(m_VariableController.get(),
48 49 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
49 50 m_VisualizationController.get(),
50 51 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
51 52
52 53 connect(m_VariableController.get(),
53 54 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)),
54 55 m_VisualizationController.get(),
55 56 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
56 57
57 58
58 59 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
59 60 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
60 61 m_NetworkController->moveToThread(&m_NetworkControllerThread);
61 62 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
62 63 m_VariableController->moveToThread(&m_VariableControllerThread);
63 64 m_VariableControllerThread.setObjectName("VariableControllerThread");
64 65 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
65 66 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
67 m_CatalogueController->moveToThread(&m_CatalogueControllerThread);
68 m_CatalogueControllerThread.setObjectName("CatalogueControllerThread");
66 69
67 70
68 71 // Additionnal init
69 72 m_VariableController->setTimeController(m_TimeController.get());
70 73 }
71 74
72 75 virtual ~SqpApplicationPrivate()
73 76 {
74 77 m_DataSourceControllerThread.quit();
75 78 m_DataSourceControllerThread.wait();
76 79
77 80 m_NetworkControllerThread.quit();
78 81 m_NetworkControllerThread.wait();
79 82
80 83 m_VariableControllerThread.quit();
81 84 m_VariableControllerThread.wait();
82 85
83 86 m_VisualizationControllerThread.quit();
84 87 m_VisualizationControllerThread.wait();
88
89 m_CatalogueControllerThread.quit();
90 m_CatalogueControllerThread.wait();
85 91 }
86 92
87 93 std::unique_ptr<DataSourceController> m_DataSourceController;
88 94 std::unique_ptr<VariableController> m_VariableController;
89 95 std::unique_ptr<TimeController> m_TimeController;
90 96 std::unique_ptr<NetworkController> m_NetworkController;
91 97 std::unique_ptr<VisualizationController> m_VisualizationController;
98 std::unique_ptr<CatalogueController> m_CatalogueController;
92 99
93 100 QThread m_DataSourceControllerThread;
94 101 QThread m_NetworkControllerThread;
95 102 QThread m_VariableControllerThread;
96 103 QThread m_VisualizationControllerThread;
104 QThread m_CatalogueControllerThread;
97 105
98 106 std::unique_ptr<DragDropGuiController> m_DragDropGuiController;
99 107 std::unique_ptr<ActionsGuiController> m_ActionsGuiController;
100 108
101 109 SqpApplication::PlotsInteractionMode m_PlotInterractionMode;
102 110 SqpApplication::PlotsCursorMode m_PlotCursorMode;
103 111 };
104 112
105 113
106 114 SqpApplication::SqpApplication(int &argc, char **argv)
107 115 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
108 116 {
109 117 qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread();
110 118
111 119 connect(&impl->m_DataSourceControllerThread, &QThread::started,
112 120 impl->m_DataSourceController.get(), &DataSourceController::initialize);
113 121 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
114 122 impl->m_DataSourceController.get(), &DataSourceController::finalize);
115 123
116 124 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
117 125 &NetworkController::initialize);
118 126 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
119 127 &NetworkController::finalize);
120 128
121 129 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
122 130 &VariableController::initialize);
123 131 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
124 132 &VariableController::finalize);
125 133
126 134 connect(&impl->m_VisualizationControllerThread, &QThread::started,
127 135 impl->m_VisualizationController.get(), &VisualizationController::initialize);
128 136 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
129 137 impl->m_VisualizationController.get(), &VisualizationController::finalize);
130 138
139 connect(&impl->m_CatalogueControllerThread, &QThread::started,
140 impl->m_CatalogueController.get(), &CatalogueController::initialize);
141 connect(&impl->m_CatalogueControllerThread, &QThread::finished,
142 impl->m_CatalogueController.get(), &CatalogueController::finalize);
143
131 144 impl->m_DataSourceControllerThread.start();
132 145 impl->m_NetworkControllerThread.start();
133 146 impl->m_VariableControllerThread.start();
134 147 impl->m_VisualizationControllerThread.start();
148 impl->m_CatalogueControllerThread.start();
135 149 }
136 150
137 151 SqpApplication::~SqpApplication()
138 152 {
139 153 }
140 154
141 155 void SqpApplication::initialize()
142 156 {
143 157 }
144 158
145 159 DataSourceController &SqpApplication::dataSourceController() noexcept
146 160 {
147 161 return *impl->m_DataSourceController;
148 162 }
149 163
150 164 NetworkController &SqpApplication::networkController() noexcept
151 165 {
152 166 return *impl->m_NetworkController;
153 167 }
154 168
155 169 TimeController &SqpApplication::timeController() noexcept
156 170 {
157 171 return *impl->m_TimeController;
158 172 }
159 173
160 174 VariableController &SqpApplication::variableController() noexcept
161 175 {
162 176 return *impl->m_VariableController;
163 177 }
164 178
165 179 VisualizationController &SqpApplication::visualizationController() noexcept
166 180 {
167 181 return *impl->m_VisualizationController;
168 182 }
169 183
170 184 DragDropGuiController &SqpApplication::dragDropGuiController() noexcept
171 185 {
172 186 return *impl->m_DragDropGuiController;
173 187 }
174 188
175 189 ActionsGuiController &SqpApplication::actionsGuiController() noexcept
176 190 {
177 191 return *impl->m_ActionsGuiController;
178 192 }
179 193
180 194 SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const
181 195 {
182 196 return impl->m_PlotInterractionMode;
183 197 }
184 198
185 199 void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode)
186 200 {
187 201 impl->m_PlotInterractionMode = mode;
188 202 }
189 203
190 204 SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const
191 205 {
192 206 return impl->m_PlotCursorMode;
193 207 }
194 208
195 209 void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode)
196 210 {
197 211 impl->m_PlotCursorMode = mode;
198 212 }
General Comments 4
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

Approved

Status change > Approved

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