@@ -1,291 +1,281 | |||
|
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 <Catalogue/CatalogueController.h> |
|
26 | 26 | #include <Catalogue2/browser.h> |
|
27 | 27 | #include <DataSource/DataSourceController.h> |
|
28 | 28 | #include <DataSource/DataSourceWidget.h> |
|
29 | 29 | #include <Settings/SqpSettingsDialog.h> |
|
30 | 30 | #include <Settings/SqpSettingsGeneralWidget.h> |
|
31 | 31 | #include <SidePane/SqpSidePane.h> |
|
32 | 32 | #include <SqpApplication.h> |
|
33 | 33 | #include <Time/TimeController.h> |
|
34 | 34 | #include <TimeWidget/TimeWidget.h> |
|
35 | #include <Visualization/VisualizationController.h> | |
|
36 | 35 | |
|
37 | 36 | #include "toolbar.h" |
|
38 | 37 | |
|
39 | 38 | #include <QAction> |
|
40 | 39 | #include <QCloseEvent> |
|
41 | 40 | #include <QDate> |
|
42 | 41 | #include <QDir> |
|
43 | 42 | #include <QFileDialog> |
|
44 | 43 | #include <QMessageBox> |
|
45 | 44 | #include <QToolBar> |
|
46 | 45 | #include <QToolButton> |
|
47 | 46 | #include <memory.h> |
|
48 | 47 | |
|
49 | 48 | |
|
50 | 49 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") |
|
51 | 50 | |
|
52 | 51 | namespace |
|
53 | 52 | { |
|
54 | 53 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; |
|
55 | 54 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; |
|
56 | 55 | const auto VIEWPLITTERINDEX = 2; |
|
57 | 56 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; |
|
58 | 57 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; |
|
59 | 58 | } |
|
60 | 59 | |
|
61 | 60 | class MainWindow::MainWindowPrivate |
|
62 | 61 | { |
|
63 | 62 | public: |
|
64 | 63 | explicit MainWindowPrivate(MainWindow* mainWindow) |
|
65 | 64 | : m_LastOpenLeftInspectorSize {} |
|
66 | 65 | , m_LastOpenRightInspectorSize {} |
|
67 | 66 | , m_GeneralSettingsWidget { new SqpSettingsGeneralWidget { mainWindow } } |
|
68 | 67 | , m_SettingsDialog { new SqpSettingsDialog { mainWindow } } |
|
69 | 68 | , m_CatalogExplorer { new CataloguesBrowser { mainWindow } } |
|
70 | 69 | { |
|
71 | 70 | } |
|
72 | 71 | |
|
73 | 72 | QSize m_LastOpenLeftInspectorSize; |
|
74 | 73 | QSize m_LastOpenRightInspectorSize; |
|
75 | 74 | /// General settings widget. MainWindow has the ownership |
|
76 | 75 | SqpSettingsGeneralWidget* m_GeneralSettingsWidget; |
|
77 | 76 | /// Settings dialog. MainWindow has the ownership |
|
78 | 77 | SqpSettingsDialog* m_SettingsDialog; |
|
79 | 78 | /// Catalogue dialog. MainWindow has the ownership |
|
80 | 79 | CataloguesBrowser* m_CatalogExplorer; |
|
81 | 80 | |
|
82 | 81 | bool checkDataToSave(QWidget* parentWidget); |
|
83 | 82 | }; |
|
84 | 83 | |
|
85 | 84 | MainWindow::MainWindow(QWidget* parent) |
|
86 | 85 | : QMainWindow { parent } |
|
87 | 86 | , m_Ui { new Ui::MainWindow } |
|
88 | 87 | , impl { spimpl::make_unique_impl<MainWindowPrivate>(this) } |
|
89 | 88 | { |
|
90 | 89 | m_Ui->setupUi(this); |
|
91 | 90 | setWindowTitle(QString("SciQLop v%1").arg(SCIQLOP_VERSION)); |
|
92 | 91 | |
|
93 | 92 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
94 | 93 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
95 | 94 | |
|
96 | 95 | // impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view); |
|
97 | 96 | |
|
98 | 97 | |
|
99 | 98 | auto spacerLeftTop = new QWidget {}; |
|
100 | 99 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
101 | 100 | |
|
102 | 101 | auto spacerLeftBottom = new QWidget {}; |
|
103 | 102 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
104 | 103 | |
|
105 | 104 | |
|
106 | 105 | auto spacerRightTop = new QWidget {}; |
|
107 | 106 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
108 | 107 | |
|
109 | 108 | auto spacerRightBottom = new QWidget {}; |
|
110 | 109 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
111 | 110 | |
|
112 | 111 | |
|
113 | 112 | auto openInspector = [this](bool checked, bool right, auto action) { |
|
114 | 113 | action->setIcon( |
|
115 | 114 | QIcon { (checked ^ right) ? ":/icones/next.png" : ":/icones/previous.png" }); |
|
116 | 115 | |
|
117 | 116 | auto& lastInspectorSize |
|
118 | 117 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; |
|
119 | 118 | |
|
120 | 119 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() |
|
121 | 120 | : m_Ui->leftMainInspectorWidget->size(); |
|
122 | 121 | |
|
123 | 122 | // Update of the last opened geometry |
|
124 | 123 | if (checked) |
|
125 | 124 | { |
|
126 | 125 | lastInspectorSize = nextInspectorSize; |
|
127 | 126 | } |
|
128 | 127 | |
|
129 | 128 | auto startSize = lastInspectorSize; |
|
130 | 129 | auto endSize = startSize; |
|
131 | 130 | endSize.setWidth(0); |
|
132 | 131 | |
|
133 | 132 | auto splitterInspectorIndex |
|
134 | 133 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; |
|
135 | 134 | |
|
136 | 135 | auto currentSizes = m_Ui->splitter->sizes(); |
|
137 | 136 | if (checked) |
|
138 | 137 | { |
|
139 | 138 | // adjust sizes individually here, e.g. |
|
140 | 139 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); |
|
141 | 140 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); |
|
142 | 141 | m_Ui->splitter->setSizes(currentSizes); |
|
143 | 142 | } |
|
144 | 143 | else |
|
145 | 144 | { |
|
146 | 145 | // adjust sizes individually here, e.g. |
|
147 | 146 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); |
|
148 | 147 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); |
|
149 | 148 | m_Ui->splitter->setSizes(currentSizes); |
|
150 | 149 | } |
|
151 | 150 | }; |
|
152 | 151 | |
|
153 | 152 | |
|
154 | 153 | // //////////////// // |
|
155 | 154 | // Menu and Toolbar // |
|
156 | 155 | // //////////////// // |
|
157 | 156 | this->menuBar()->addAction(tr("File")); |
|
158 | 157 | auto toolsMenu = this->menuBar()->addMenu(tr("Tools")); |
|
159 | 158 | toolsMenu->addAction(tr("Settings..."), [this]() { |
|
160 | 159 | // Loads settings |
|
161 | 160 | impl->m_SettingsDialog->loadSettings(); |
|
162 | 161 | |
|
163 | 162 | // Open settings dialog and save settings if the dialog is accepted |
|
164 | 163 | if (impl->m_SettingsDialog->exec() == QDialog::Accepted) |
|
165 | 164 | { |
|
166 | 165 | impl->m_SettingsDialog->saveSettings(); |
|
167 | 166 | } |
|
168 | 167 | }); |
|
169 | 168 | auto mainToolBar = new ToolBar(this); |
|
170 | 169 | this->addToolBar(mainToolBar); |
|
171 | 170 | connect(mainToolBar, &ToolBar::setPlotsInteractionMode, sqpApp, |
|
172 | 171 | &SqpApplication::setPlotsInteractionMode); |
|
173 | 172 | connect(mainToolBar, &ToolBar::setPlotsCursorMode, sqpApp, &SqpApplication::setPlotsCursorMode); |
|
174 | 173 | connect(mainToolBar, &ToolBar::showCataloguesBrowser, |
|
175 | 174 | [this]() { impl->m_CatalogExplorer->show(); }); |
|
176 | 175 | |
|
177 | 176 | // //////// // |
|
178 | 177 | // Settings // |
|
179 | 178 | // //////// // |
|
180 | 179 | |
|
181 | 180 | // Registers "general settings" widget to the settings dialog |
|
182 | 181 | impl->m_SettingsDialog->registerWidget( |
|
183 | 182 | QStringLiteral("General"), impl->m_GeneralSettingsWidget); |
|
184 | 183 | |
|
185 | 184 | // /////////// // |
|
186 | 185 | // Connections // |
|
187 | 186 | // /////////// // |
|
188 | 187 | |
|
189 | 188 | // Widgets / controllers connections |
|
190 | 189 | |
|
191 | 190 | // DataSource |
|
192 | 191 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem*)), |
|
193 | 192 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem*))); |
|
194 | 193 | |
|
195 | 194 | // Time |
|
196 | 195 | // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), |
|
197 | 196 | // SLOT(onTimeToUpdate(DateTimeRange))); |
|
198 | 197 | connect(mainToolBar, &ToolBar::timeUpdated, &sqpApp->timeController(), |
|
199 | 198 | &TimeController::setDateTimeRange); |
|
200 | 199 | |
|
201 | // Visualization | |
|
202 | connect(&sqpApp->visualizationController(), | |
|
203 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable2>)), m_Ui->view, | |
|
204 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable2>))); | |
|
205 | ||
|
206 | connect(&sqpApp->visualizationController(), | |
|
207 | SIGNAL(rangeChanged(std::shared_ptr<Variable2>, const DateTimeRange&)), m_Ui->view, | |
|
208 | SLOT(onRangeChanged(std::shared_ptr<Variable2>, const DateTimeRange&))); | |
|
209 | ||
|
210 | 200 | // Widgets / widgets connections |
|
211 | 201 | |
|
212 | 202 | // For the following connections, we use DirectConnection to allow each widget that can |
|
213 | 203 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. |
|
214 | 204 | // The order of connections is also important, since it determines the order in which each |
|
215 | 205 | // widget will attach its menu |
|
216 | 206 | connect(m_Ui->variableInspectorWidget, |
|
217 | 207 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu*, const QVector<std::shared_ptr<Variable>>&)), |
|
218 | 208 | m_Ui->view, SLOT(attachVariableMenu(QMenu*, const QVector<std::shared_ptr<Variable>>&)), |
|
219 | 209 | Qt::DirectConnection); |
|
220 | 210 | } |
|
221 | 211 | |
|
222 | 212 | MainWindow::~MainWindow() {} |
|
223 | 213 | |
|
224 | 214 | void MainWindow::changeEvent(QEvent* e) |
|
225 | 215 | { |
|
226 | 216 | QMainWindow::changeEvent(e); |
|
227 | 217 | switch (e->type()) |
|
228 | 218 | { |
|
229 | 219 | case QEvent::LanguageChange: |
|
230 | 220 | m_Ui->retranslateUi(this); |
|
231 | 221 | break; |
|
232 | 222 | default: |
|
233 | 223 | break; |
|
234 | 224 | } |
|
235 | 225 | } |
|
236 | 226 | |
|
237 | 227 | void MainWindow::closeEvent(QCloseEvent* event) |
|
238 | 228 | { |
|
239 | 229 | if (!impl->checkDataToSave(this)) |
|
240 | 230 | { |
|
241 | 231 | event->ignore(); |
|
242 | 232 | } |
|
243 | 233 | else |
|
244 | 234 | { |
|
245 | 235 | event->accept(); |
|
246 | 236 | } |
|
247 | 237 | } |
|
248 | 238 | |
|
249 | 239 | void MainWindow::keyPressEvent(QKeyEvent* event) |
|
250 | 240 | { |
|
251 | 241 | switch (event->key()) |
|
252 | 242 | { |
|
253 | 243 | case Qt::Key_F11: |
|
254 | 244 | if (this->isFullScreen()) |
|
255 | 245 | { |
|
256 | 246 | this->showNormal(); |
|
257 | 247 | } |
|
258 | 248 | else |
|
259 | 249 | { |
|
260 | 250 | this->showFullScreen(); |
|
261 | 251 | } |
|
262 | 252 | break; |
|
263 | 253 | default: |
|
264 | 254 | break; |
|
265 | 255 | } |
|
266 | 256 | } |
|
267 | 257 | |
|
268 | 258 | bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget* parentWidget) |
|
269 | 259 | { |
|
270 | 260 | // auto hasChanges = sqpApp->catalogueController().hasChanges(); |
|
271 | 261 | // if (hasChanges) |
|
272 | 262 | // { |
|
273 | 263 | // // There are some unsaved changes |
|
274 | 264 | // switch (QMessageBox::question(parentWidget, tr("Save changes"), |
|
275 | 265 | // tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"), |
|
276 | 266 | // QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel, |
|
277 | 267 | // QMessageBox::SaveAll)) |
|
278 | 268 | // { |
|
279 | 269 | // case QMessageBox::SaveAll: |
|
280 | 270 | // sqpApp->catalogueController().saveAll(); |
|
281 | 271 | // break; |
|
282 | 272 | // case QMessageBox::Discard: |
|
283 | 273 | // break; |
|
284 | 274 | // case QMessageBox::Cancel: |
|
285 | 275 | // default: |
|
286 | 276 | // return false; |
|
287 | 277 | // } |
|
288 | 278 | // } |
|
289 | 279 | |
|
290 | 280 | return true; |
|
291 | 281 | } |
@@ -1,1 +1,1 | |||
|
1 | Subproject commit 521f9540ac01f61c92600a4aa6c8d3c148abc74a | |
|
1 | Subproject commit 64a22e9756a85346e7aef52d26bc5c50c4778d86 |
@@ -1,117 +1,113 | |||
|
1 | 1 | #ifndef SCIQLOP_SQPAPPLICATION_H |
|
2 | 2 | #define SCIQLOP_SQPAPPLICATION_H |
|
3 | 3 | |
|
4 | 4 | #include "SqpApplication.h" |
|
5 | 5 | |
|
6 | 6 | #include <QAction> |
|
7 | 7 | #include <QApplication> |
|
8 | 8 | #include <QLoggingCategory> |
|
9 | 9 | #include <QMenuBar> |
|
10 | 10 | #include <QProxyStyle> |
|
11 | 11 | #include <QStyleOption> |
|
12 | 12 | #include <QWidget> |
|
13 | 13 | #include <QWidgetAction> |
|
14 | 14 | |
|
15 | 15 | #include <Common/spimpl.h> |
|
16 | 16 | |
|
17 | 17 | Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) |
|
18 | 18 | |
|
19 | 19 | #if defined(sqpApp) |
|
20 | 20 | #undef sqpApp |
|
21 | 21 | #endif |
|
22 | 22 | #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance())) |
|
23 | 23 | |
|
24 | 24 | class DataSourceController; |
|
25 | 25 | class NetworkController; |
|
26 | 26 | class TimeController; |
|
27 | 27 | class VariableController; |
|
28 | 28 | class VariableController2; |
|
29 | 29 | class VariableModel2; |
|
30 | class VisualizationController; | |
|
31 | 30 | class DragDropGuiController; |
|
32 | 31 | class ActionsGuiController; |
|
33 | 32 | class CatalogueController; |
|
34 | 33 | |
|
35 | 34 | /* stolen from here https://forum.qt.io/topic/90403/show-tooltip-immediatly/6 */ |
|
36 | 35 | class MyProxyStyle : public QProxyStyle |
|
37 | 36 | { |
|
38 | 37 | public: |
|
39 | 38 | using QProxyStyle::QProxyStyle; |
|
40 | 39 | |
|
41 | 40 | int styleHint(StyleHint hint, const QStyleOption* option = nullptr, |
|
42 | 41 | const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) const override |
|
43 | 42 | { |
|
44 | 43 | if (widget) |
|
45 | 44 | auto cname = widget->metaObject()->className(); |
|
46 | 45 | if (hint == QStyle::SH_ToolButton_PopupDelay && widget |
|
47 | 46 | /*&& widget->inherits(QWidgetAction::staticMetaObject.className())*/) |
|
48 | 47 | { |
|
49 | 48 | return 0; |
|
50 | 49 | } |
|
51 | 50 | |
|
52 | 51 | return QProxyStyle::styleHint(hint, option, widget, returnData); |
|
53 | 52 | } |
|
54 | 53 | }; |
|
55 | 54 | |
|
56 | 55 | /** |
|
57 | 56 | * @brief The SqpApplication class aims to make the link between SciQlop |
|
58 | 57 | * and its plugins. This is the intermediate class that SciQlop has to use |
|
59 | 58 | * in the way to connect a data source. Please first use load method to initialize |
|
60 | 59 | * a plugin specified by its metadata name (JSON plugin source) then others specifics |
|
61 | 60 | * method will be able to access it. |
|
62 | 61 | * You can load a data source driver plugin then create a data source. |
|
63 | 62 | */ |
|
64 | 63 | |
|
65 | 64 | class SqpApplication : public QApplication |
|
66 | 65 | { |
|
67 | 66 | Q_OBJECT |
|
68 | 67 | public: |
|
69 | 68 | explicit SqpApplication(int& argc, char** argv); |
|
70 | 69 | ~SqpApplication() override; |
|
71 | 70 | void initialize(); |
|
72 | 71 | |
|
73 | 72 | /// Accessors for the differents sciqlop controllers |
|
74 | 73 | DataSourceController& dataSourceController() noexcept; |
|
75 | 74 | NetworkController& networkController() noexcept; |
|
76 | 75 | TimeController& timeController() noexcept; |
|
77 | 76 | VariableController2& variableController() noexcept; |
|
78 | 77 | std::shared_ptr<VariableController2> variableControllerOwner() noexcept; |
|
79 | //@TODO there should not be any global model it's just GUI impl detail | |
|
80 | // VariableModel2 &variableModel() noexcept; | |
|
81 | VisualizationController& visualizationController() noexcept; | |
|
82 | 78 | CatalogueController& catalogueController() noexcept; |
|
83 | 79 | |
|
84 | 80 | /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but |
|
85 | 81 | /// doesn't live in a thread and access gui |
|
86 | 82 | DragDropGuiController& dragDropGuiController() noexcept; |
|
87 | 83 | ActionsGuiController& actionsGuiController() noexcept; |
|
88 | 84 | |
|
89 | 85 | enum class PlotsInteractionMode |
|
90 | 86 | { |
|
91 | 87 | None, |
|
92 | 88 | ZoomBox, |
|
93 | 89 | DragAndDrop, |
|
94 | 90 | SelectionZones |
|
95 | 91 | }; |
|
96 | 92 | |
|
97 | 93 | enum class PlotsCursorMode |
|
98 | 94 | { |
|
99 | 95 | NoCursor, |
|
100 | 96 | Vertical, |
|
101 | 97 | Temporal, |
|
102 | 98 | Horizontal, |
|
103 | 99 | Cross |
|
104 | 100 | }; |
|
105 | 101 | |
|
106 | 102 | PlotsInteractionMode plotsInteractionMode() const; |
|
107 | 103 | void setPlotsInteractionMode(PlotsInteractionMode mode); |
|
108 | 104 | |
|
109 | 105 | PlotsCursorMode plotsCursorMode() const; |
|
110 | 106 | void setPlotsCursorMode(PlotsCursorMode mode); |
|
111 | 107 | |
|
112 | 108 | private: |
|
113 | 109 | class SqpApplicationPrivate; |
|
114 | 110 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; |
|
115 | 111 | }; |
|
116 | 112 | |
|
117 | 113 | #endif // SCIQLOP_SQPAPPLICATION_H |
@@ -1,193 +1,156 | |||
|
1 | 1 | #include "SqpApplication.h" |
|
2 | 2 | |
|
3 | 3 | #include <Actions/ActionsGuiController.h> |
|
4 | 4 | #include <Catalogue/CatalogueController.h> |
|
5 | 5 | #include <Data/IDataProvider.h> |
|
6 | 6 | #include <DataSource/DataSourceController.h> |
|
7 | 7 | #include <DragAndDrop/DragDropGuiController.h> |
|
8 | 8 | #include <Network/NetworkController.h> |
|
9 | 9 | #include <QThread> |
|
10 | 10 | #include <Time/TimeController.h> |
|
11 | 11 | #include <Variable/VariableController2.h> |
|
12 | 12 | #include <Variable/VariableModel2.h> |
|
13 | #include <Visualization/VisualizationController.h> | |
|
14 | 13 | |
|
15 | 14 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
16 | 15 | |
|
17 | 16 | class SqpApplication::SqpApplicationPrivate |
|
18 | 17 | { |
|
19 | 18 | public: |
|
20 | 19 | SqpApplicationPrivate() |
|
21 | 20 | : m_VariableController { std::make_shared<VariableController2>() } |
|
22 | 21 | , m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None) |
|
23 | 22 | , m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) |
|
24 | 23 | { |
|
25 | 24 | // /////////////////////////////// // |
|
26 | 25 | // Connections between controllers // |
|
27 | 26 | // /////////////////////////////// // |
|
28 | 27 | |
|
29 | 28 | // VariableController <-> DataSourceController |
|
30 | 29 | connect(&m_DataSourceController, &DataSourceController::createVariable, |
|
31 | 30 | [](const QString& variableName, const QVariantHash& variableMetadata, |
|
32 | 31 | std::shared_ptr<IDataProvider> variableProvider) { |
|
33 | 32 | sqpApp->variableController().createVariable(variableName, variableMetadata, |
|
34 | 33 | variableProvider, sqpApp->timeController().dateTime()); |
|
35 | 34 | }); |
|
36 | 35 | |
|
37 | // VariableController <-> VisualizationController | |
|
38 | // connect(m_VariableController.get(), | |
|
39 | // SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | |
|
40 | // m_VisualizationController.get(), | |
|
41 | // SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | |
|
42 | // Qt::DirectConnection); | |
|
43 | ||
|
44 | // connect(m_VariableController.get(), | |
|
45 | // SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), | |
|
46 | // m_VisualizationController.get(), | |
|
47 | // SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &))); | |
|
48 | ||
|
49 | 36 | |
|
50 | 37 | m_DataSourceController.moveToThread(&m_DataSourceControllerThread); |
|
51 | 38 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); |
|
52 | 39 | m_NetworkController.moveToThread(&m_NetworkControllerThread); |
|
53 | 40 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); |
|
54 | m_VisualizationController.moveToThread(&m_VisualizationControllerThread); | |
|
55 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); | |
|
56 | 41 | |
|
57 | 42 | // Additionnal init |
|
58 | 43 | // m_VariableController->setTimeController(m_TimeController.get()); |
|
59 | 44 | } |
|
60 | 45 | |
|
61 | 46 | virtual ~SqpApplicationPrivate() |
|
62 | 47 | { |
|
63 | 48 | m_DataSourceControllerThread.quit(); |
|
64 | 49 | m_DataSourceControllerThread.wait(); |
|
65 | 50 | |
|
66 | 51 | m_NetworkControllerThread.quit(); |
|
67 | 52 | m_NetworkControllerThread.wait(); |
|
68 | ||
|
69 | m_VisualizationControllerThread.quit(); | |
|
70 | m_VisualizationControllerThread.wait(); | |
|
71 | 53 | } |
|
72 | 54 | |
|
73 | 55 | DataSourceController m_DataSourceController; |
|
74 | 56 | std::shared_ptr<VariableController2> m_VariableController; |
|
75 | 57 | TimeController m_TimeController; |
|
76 | 58 | NetworkController m_NetworkController; |
|
77 | VisualizationController m_VisualizationController; | |
|
78 | 59 | CatalogueController m_CatalogueController; |
|
79 | 60 | |
|
80 | 61 | QThread m_DataSourceControllerThread; |
|
81 | 62 | QThread m_NetworkControllerThread; |
|
82 | QThread m_VisualizationControllerThread; | |
|
83 | 63 | |
|
84 | 64 | DragDropGuiController m_DragDropGuiController; |
|
85 | 65 | ActionsGuiController m_ActionsGuiController; |
|
86 | 66 | |
|
87 | 67 | SqpApplication::PlotsInteractionMode m_PlotInterractionMode; |
|
88 | 68 | SqpApplication::PlotsCursorMode m_PlotCursorMode; |
|
89 | 69 | }; |
|
90 | 70 | |
|
91 | 71 | |
|
92 | 72 | SqpApplication::SqpApplication(int& argc, char** argv) |
|
93 | 73 | : QApplication { argc, argv }, impl { spimpl::make_unique_impl<SqpApplicationPrivate>() } |
|
94 | 74 | { |
|
95 | 75 | this->setStyle(new MyProxyStyle(this->style())); |
|
96 | 76 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); |
|
97 | 77 | |
|
98 | 78 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
|
99 | 79 | |
|
100 | 80 | connect(&impl->m_DataSourceControllerThread, &QThread::started, &impl->m_DataSourceController, |
|
101 | 81 | &DataSourceController::initialize); |
|
102 | 82 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, &impl->m_DataSourceController, |
|
103 | 83 | &DataSourceController::finalize); |
|
104 | 84 | |
|
105 | 85 | connect(&impl->m_NetworkControllerThread, &QThread::started, &impl->m_NetworkController, |
|
106 | 86 | &NetworkController::initialize); |
|
107 | 87 | connect(&impl->m_NetworkControllerThread, &QThread::finished, &impl->m_NetworkController, |
|
108 | 88 | &NetworkController::finalize); |
|
109 | 89 | |
|
110 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |
|
111 | &impl->m_VisualizationController, &VisualizationController::initialize); | |
|
112 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |
|
113 | &impl->m_VisualizationController, &VisualizationController::finalize); | |
|
114 | ||
|
115 | 90 | impl->m_DataSourceControllerThread.start(); |
|
116 | 91 | impl->m_NetworkControllerThread.start(); |
|
117 | impl->m_VisualizationControllerThread.start(); | |
|
118 | // impl->m_CatalogueController.initialize(); | |
|
119 | 92 | } |
|
120 | 93 | |
|
121 | 94 | SqpApplication::~SqpApplication() {} |
|
122 | 95 | |
|
123 | 96 | void SqpApplication::initialize() {} |
|
124 | 97 | |
|
125 | 98 | DataSourceController& SqpApplication::dataSourceController() noexcept |
|
126 | 99 | { |
|
127 | 100 | return impl->m_DataSourceController; |
|
128 | 101 | } |
|
129 | 102 | |
|
130 | 103 | NetworkController& SqpApplication::networkController() noexcept |
|
131 | 104 | { |
|
132 | 105 | return impl->m_NetworkController; |
|
133 | 106 | } |
|
134 | 107 | |
|
135 | 108 | TimeController& SqpApplication::timeController() noexcept |
|
136 | 109 | { |
|
137 | 110 | return impl->m_TimeController; |
|
138 | 111 | } |
|
139 | 112 | |
|
140 | 113 | VariableController2& SqpApplication::variableController() noexcept |
|
141 | 114 | { |
|
142 | 115 | return *impl->m_VariableController; |
|
143 | 116 | } |
|
144 | 117 | |
|
145 | 118 | std::shared_ptr<VariableController2> SqpApplication::variableControllerOwner() noexcept |
|
146 | 119 | { |
|
147 | 120 | return impl->m_VariableController; |
|
148 | 121 | } |
|
149 | 122 | |
|
150 | // VariableModel2 &SqpApplication::variableModel() noexcept | |
|
151 | //{ | |
|
152 | // return impl->m_VariableModel; | |
|
153 | //} | |
|
154 | ||
|
155 | VisualizationController& SqpApplication::visualizationController() noexcept | |
|
156 | { | |
|
157 | return impl->m_VisualizationController; | |
|
158 | } | |
|
159 | ||
|
160 | 123 | CatalogueController& SqpApplication::catalogueController() noexcept |
|
161 | 124 | { |
|
162 | 125 | return impl->m_CatalogueController; |
|
163 | 126 | } |
|
164 | 127 | |
|
165 | 128 | DragDropGuiController& SqpApplication::dragDropGuiController() noexcept |
|
166 | 129 | { |
|
167 | 130 | return impl->m_DragDropGuiController; |
|
168 | 131 | } |
|
169 | 132 | |
|
170 | 133 | ActionsGuiController& SqpApplication::actionsGuiController() noexcept |
|
171 | 134 | { |
|
172 | 135 | return impl->m_ActionsGuiController; |
|
173 | 136 | } |
|
174 | 137 | |
|
175 | 138 | SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const |
|
176 | 139 | { |
|
177 | 140 | return impl->m_PlotInterractionMode; |
|
178 | 141 | } |
|
179 | 142 | |
|
180 | 143 | void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode) |
|
181 | 144 | { |
|
182 | 145 | impl->m_PlotInterractionMode = mode; |
|
183 | 146 | } |
|
184 | 147 | |
|
185 | 148 | SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const |
|
186 | 149 | { |
|
187 | 150 | return impl->m_PlotCursorMode; |
|
188 | 151 | } |
|
189 | 152 | |
|
190 | 153 | void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode) |
|
191 | 154 | { |
|
192 | 155 | impl->m_PlotCursorMode = mode; |
|
193 | 156 | } |
General Comments 0
You need to be logged in to leave comments.
Login now