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