@@ -1,364 +1,366 | |||||
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/CatalogueExplorer.h> |
|
25 | #include <Catalogue/CatalogueExplorer.h> | |
26 | #include <DataSource/DataSourceController.h> |
|
26 | #include <DataSource/DataSourceController.h> | |
27 | #include <DataSource/DataSourceWidget.h> |
|
27 | #include <DataSource/DataSourceWidget.h> | |
28 | #include <Settings/SqpSettingsDialog.h> |
|
28 | #include <Settings/SqpSettingsDialog.h> | |
29 | #include <Settings/SqpSettingsGeneralWidget.h> |
|
29 | #include <Settings/SqpSettingsGeneralWidget.h> | |
30 | #include <SidePane/SqpSidePane.h> |
|
30 | #include <SidePane/SqpSidePane.h> | |
31 | #include <SqpApplication.h> |
|
31 | #include <SqpApplication.h> | |
32 | #include <Time/TimeController.h> |
|
32 | #include <Time/TimeController.h> | |
33 | #include <TimeWidget/TimeWidget.h> |
|
33 | #include <TimeWidget/TimeWidget.h> | |
34 | #include <Variable/Variable.h> |
|
34 | #include <Variable/Variable.h> | |
35 | #include <Variable/VariableController.h> |
|
35 | #include <Variable/VariableController.h> | |
36 | #include <Visualization/VisualizationController.h> |
|
36 | #include <Visualization/VisualizationController.h> | |
37 |
|
37 | |||
38 | #include <QAction> |
|
38 | #include <QAction> | |
39 | #include <QDate> |
|
39 | #include <QDate> | |
40 | #include <QDir> |
|
40 | #include <QDir> | |
41 | #include <QFileDialog> |
|
41 | #include <QFileDialog> | |
42 | #include <QToolBar> |
|
42 | #include <QToolBar> | |
43 | #include <QToolButton> |
|
43 | #include <QToolButton> | |
44 | #include <memory.h> |
|
44 | #include <memory.h> | |
45 |
|
45 | |||
46 | #include "iostream" |
|
46 | #include "iostream" | |
47 |
|
47 | |||
48 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") |
|
48 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") | |
49 |
|
49 | |||
50 | namespace { |
|
50 | namespace { | |
51 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; |
|
51 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; | |
52 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; |
|
52 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; | |
53 | const auto VIEWPLITTERINDEX = 2; |
|
53 | const auto VIEWPLITTERINDEX = 2; | |
54 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; |
|
54 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; | |
55 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; |
|
55 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | class MainWindow::MainWindowPrivate { |
|
58 | class MainWindow::MainWindowPrivate { | |
59 | public: |
|
59 | public: | |
60 | explicit MainWindowPrivate(MainWindow *mainWindow) |
|
60 | explicit MainWindowPrivate(MainWindow *mainWindow) | |
61 | : m_LastOpenLeftInspectorSize{}, |
|
61 | : m_LastOpenLeftInspectorSize{}, | |
62 | m_LastOpenRightInspectorSize{}, |
|
62 | m_LastOpenRightInspectorSize{}, | |
63 | m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}}, |
|
63 | m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}}, | |
64 | m_SettingsDialog{new SqpSettingsDialog{mainWindow}}, |
|
64 | m_SettingsDialog{new SqpSettingsDialog{mainWindow}}, | |
65 | m_CatalogExplorer{new CatalogueExplorer{mainWindow}} |
|
65 | m_CatalogExplorer{new CatalogueExplorer{mainWindow}} | |
66 | { |
|
66 | { | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | QSize m_LastOpenLeftInspectorSize; |
|
69 | QSize m_LastOpenLeftInspectorSize; | |
70 | QSize m_LastOpenRightInspectorSize; |
|
70 | QSize m_LastOpenRightInspectorSize; | |
71 | /// General settings widget. MainWindow has the ownership |
|
71 | /// General settings widget. MainWindow has the ownership | |
72 | SqpSettingsGeneralWidget *m_GeneralSettingsWidget; |
|
72 | SqpSettingsGeneralWidget *m_GeneralSettingsWidget; | |
73 | /// Settings dialog. MainWindow has the ownership |
|
73 | /// Settings dialog. MainWindow has the ownership | |
74 | SqpSettingsDialog *m_SettingsDialog; |
|
74 | SqpSettingsDialog *m_SettingsDialog; | |
75 | /// Catalogue dialog. MainWindow has the ownership |
|
75 | /// Catalogue dialog. MainWindow has the ownership | |
76 | CatalogueExplorer *m_CatalogExplorer; |
|
76 | CatalogueExplorer *m_CatalogExplorer; | |
77 | }; |
|
77 | }; | |
78 |
|
78 | |||
79 | MainWindow::MainWindow(QWidget *parent) |
|
79 | MainWindow::MainWindow(QWidget *parent) | |
80 | : QMainWindow{parent}, |
|
80 | : QMainWindow{parent}, | |
81 | m_Ui{new Ui::MainWindow}, |
|
81 | m_Ui{new Ui::MainWindow}, | |
82 | impl{spimpl::make_unique_impl<MainWindowPrivate>(this)} |
|
82 | impl{spimpl::make_unique_impl<MainWindowPrivate>(this)} | |
83 | { |
|
83 | { | |
84 | m_Ui->setupUi(this); |
|
84 | m_Ui->setupUi(this); | |
85 |
|
85 | |||
86 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
86 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); | |
87 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
87 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); | |
88 |
|
88 | |||
|
89 | impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view); | |||
|
90 | ||||
89 |
|
91 | |||
90 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); |
|
92 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); | |
91 | auto openLeftInspectorAction = new QAction{QIcon{ |
|
93 | auto openLeftInspectorAction = new QAction{QIcon{ | |
92 | ":/icones/previous.png", |
|
94 | ":/icones/previous.png", | |
93 | }, |
|
95 | }, | |
94 | tr("Show/hide the left inspector"), this}; |
|
96 | tr("Show/hide the left inspector"), this}; | |
95 |
|
97 | |||
96 |
|
98 | |||
97 | auto spacerLeftTop = new QWidget{}; |
|
99 | auto spacerLeftTop = new QWidget{}; | |
98 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
100 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
99 |
|
101 | |||
100 | auto spacerLeftBottom = new QWidget{}; |
|
102 | auto spacerLeftBottom = new QWidget{}; | |
101 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
103 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
102 |
|
104 | |||
103 | leftSidePane->addWidget(spacerLeftTop); |
|
105 | leftSidePane->addWidget(spacerLeftTop); | |
104 | leftSidePane->addAction(openLeftInspectorAction); |
|
106 | leftSidePane->addAction(openLeftInspectorAction); | |
105 | leftSidePane->addWidget(spacerLeftBottom); |
|
107 | leftSidePane->addWidget(spacerLeftBottom); | |
106 |
|
108 | |||
107 |
|
109 | |||
108 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); |
|
110 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); | |
109 | auto openRightInspectorAction = new QAction{QIcon{ |
|
111 | auto openRightInspectorAction = new QAction{QIcon{ | |
110 | ":/icones/next.png", |
|
112 | ":/icones/next.png", | |
111 | }, |
|
113 | }, | |
112 | tr("Show/hide the right inspector"), this}; |
|
114 | tr("Show/hide the right inspector"), this}; | |
113 |
|
115 | |||
114 | auto spacerRightTop = new QWidget{}; |
|
116 | auto spacerRightTop = new QWidget{}; | |
115 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
117 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
116 |
|
118 | |||
117 | auto spacerRightBottom = new QWidget{}; |
|
119 | auto spacerRightBottom = new QWidget{}; | |
118 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
120 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
119 |
|
121 | |||
120 | rightSidePane->addWidget(spacerRightTop); |
|
122 | rightSidePane->addWidget(spacerRightTop); | |
121 | rightSidePane->addAction(openRightInspectorAction); |
|
123 | rightSidePane->addAction(openRightInspectorAction); | |
122 | rightSidePane->addWidget(spacerRightBottom); |
|
124 | rightSidePane->addWidget(spacerRightBottom); | |
123 |
|
125 | |||
124 | openLeftInspectorAction->setCheckable(true); |
|
126 | openLeftInspectorAction->setCheckable(true); | |
125 | openRightInspectorAction->setCheckable(true); |
|
127 | openRightInspectorAction->setCheckable(true); | |
126 |
|
128 | |||
127 | auto openInspector = [this](bool checked, bool right, auto action) { |
|
129 | auto openInspector = [this](bool checked, bool right, auto action) { | |
128 |
|
130 | |||
129 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); |
|
131 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); | |
130 |
|
132 | |||
131 | auto &lastInspectorSize |
|
133 | auto &lastInspectorSize | |
132 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; |
|
134 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; | |
133 |
|
135 | |||
134 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() |
|
136 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() | |
135 | : m_Ui->leftMainInspectorWidget->size(); |
|
137 | : m_Ui->leftMainInspectorWidget->size(); | |
136 |
|
138 | |||
137 | // Update of the last opened geometry |
|
139 | // Update of the last opened geometry | |
138 | if (checked) { |
|
140 | if (checked) { | |
139 | lastInspectorSize = nextInspectorSize; |
|
141 | lastInspectorSize = nextInspectorSize; | |
140 | } |
|
142 | } | |
141 |
|
143 | |||
142 | auto startSize = lastInspectorSize; |
|
144 | auto startSize = lastInspectorSize; | |
143 | auto endSize = startSize; |
|
145 | auto endSize = startSize; | |
144 | endSize.setWidth(0); |
|
146 | endSize.setWidth(0); | |
145 |
|
147 | |||
146 | auto splitterInspectorIndex |
|
148 | auto splitterInspectorIndex | |
147 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; |
|
149 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; | |
148 |
|
150 | |||
149 | auto currentSizes = m_Ui->splitter->sizes(); |
|
151 | auto currentSizes = m_Ui->splitter->sizes(); | |
150 | if (checked) { |
|
152 | if (checked) { | |
151 | // adjust sizes individually here, e.g. |
|
153 | // adjust sizes individually here, e.g. | |
152 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); |
|
154 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); | |
153 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); |
|
155 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); | |
154 | m_Ui->splitter->setSizes(currentSizes); |
|
156 | m_Ui->splitter->setSizes(currentSizes); | |
155 | } |
|
157 | } | |
156 | else { |
|
158 | else { | |
157 | // adjust sizes individually here, e.g. |
|
159 | // adjust sizes individually here, e.g. | |
158 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); |
|
160 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); | |
159 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); |
|
161 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); | |
160 | m_Ui->splitter->setSizes(currentSizes); |
|
162 | m_Ui->splitter->setSizes(currentSizes); | |
161 | } |
|
163 | } | |
162 |
|
164 | |||
163 | }; |
|
165 | }; | |
164 |
|
166 | |||
165 |
|
167 | |||
166 | connect(openLeftInspectorAction, &QAction::triggered, |
|
168 | connect(openLeftInspectorAction, &QAction::triggered, | |
167 | [openInspector, openLeftInspectorAction](bool checked) { |
|
169 | [openInspector, openLeftInspectorAction](bool checked) { | |
168 | openInspector(checked, false, openLeftInspectorAction); |
|
170 | openInspector(checked, false, openLeftInspectorAction); | |
169 | }); |
|
171 | }); | |
170 | connect(openRightInspectorAction, &QAction::triggered, |
|
172 | connect(openRightInspectorAction, &QAction::triggered, | |
171 | [openInspector, openRightInspectorAction](bool checked) { |
|
173 | [openInspector, openRightInspectorAction](bool checked) { | |
172 | openInspector(checked, true, openRightInspectorAction); |
|
174 | openInspector(checked, true, openRightInspectorAction); | |
173 | }); |
|
175 | }); | |
174 |
|
176 | |||
175 | // //////////////// // |
|
177 | // //////////////// // | |
176 | // Menu and Toolbar // |
|
178 | // Menu and Toolbar // | |
177 | // //////////////// // |
|
179 | // //////////////// // | |
178 | this->menuBar()->addAction(tr("File")); |
|
180 | this->menuBar()->addAction(tr("File")); | |
179 | auto toolsMenu = this->menuBar()->addMenu(tr("Tools")); |
|
181 | auto toolsMenu = this->menuBar()->addMenu(tr("Tools")); | |
180 | toolsMenu->addAction(tr("Settings..."), [this]() { |
|
182 | toolsMenu->addAction(tr("Settings..."), [this]() { | |
181 | // Loads settings |
|
183 | // Loads settings | |
182 | impl->m_SettingsDialog->loadSettings(); |
|
184 | impl->m_SettingsDialog->loadSettings(); | |
183 |
|
185 | |||
184 | // Open settings dialog and save settings if the dialog is accepted |
|
186 | // Open settings dialog and save settings if the dialog is accepted | |
185 | if (impl->m_SettingsDialog->exec() == QDialog::Accepted) { |
|
187 | if (impl->m_SettingsDialog->exec() == QDialog::Accepted) { | |
186 | impl->m_SettingsDialog->saveSettings(); |
|
188 | impl->m_SettingsDialog->saveSettings(); | |
187 | } |
|
189 | } | |
188 |
|
190 | |||
189 | }); |
|
191 | }); | |
190 |
|
192 | |||
191 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); |
|
193 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); | |
192 |
|
194 | |||
193 | auto timeWidget = new TimeWidget{}; |
|
195 | auto timeWidget = new TimeWidget{}; | |
194 | mainToolBar->addWidget(timeWidget); |
|
196 | mainToolBar->addWidget(timeWidget); | |
195 |
|
197 | |||
196 | // Interaction modes |
|
198 | // Interaction modes | |
197 | auto actionPointerMode = new QAction{QIcon(":/icones/pointer.png"), "Move", this}; |
|
199 | auto actionPointerMode = new QAction{QIcon(":/icones/pointer.png"), "Move", this}; | |
198 | actionPointerMode->setCheckable(true); |
|
200 | actionPointerMode->setCheckable(true); | |
199 | actionPointerMode->setChecked(sqpApp->plotsInteractionMode() |
|
201 | actionPointerMode->setChecked(sqpApp->plotsInteractionMode() | |
200 | == SqpApplication::PlotsInteractionMode::None); |
|
202 | == SqpApplication::PlotsInteractionMode::None); | |
201 | connect(actionPointerMode, &QAction::triggered, |
|
203 | connect(actionPointerMode, &QAction::triggered, | |
202 | []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); }); |
|
204 | []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); }); | |
203 |
|
205 | |||
204 | auto actionZoomMode = new QAction{QIcon(":/icones/zoom.png"), "Zoom", this}; |
|
206 | auto actionZoomMode = new QAction{QIcon(":/icones/zoom.png"), "Zoom", this}; | |
205 | actionZoomMode->setCheckable(true); |
|
207 | actionZoomMode->setCheckable(true); | |
206 | actionZoomMode->setChecked(sqpApp->plotsInteractionMode() |
|
208 | actionZoomMode->setChecked(sqpApp->plotsInteractionMode() | |
207 | == SqpApplication::PlotsInteractionMode::ZoomBox); |
|
209 | == SqpApplication::PlotsInteractionMode::ZoomBox); | |
208 | connect(actionZoomMode, &QAction::triggered, []() { |
|
210 | connect(actionZoomMode, &QAction::triggered, []() { | |
209 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox); |
|
211 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox); | |
210 | }); |
|
212 | }); | |
211 |
|
213 | |||
212 | auto actionOrganisationMode = new QAction{QIcon(":/icones/drag.png"), "Organize", this}; |
|
214 | auto actionOrganisationMode = new QAction{QIcon(":/icones/drag.png"), "Organize", this}; | |
213 | actionOrganisationMode->setCheckable(true); |
|
215 | actionOrganisationMode->setCheckable(true); | |
214 | actionOrganisationMode->setChecked(sqpApp->plotsInteractionMode() |
|
216 | actionOrganisationMode->setChecked(sqpApp->plotsInteractionMode() | |
215 | == SqpApplication::PlotsInteractionMode::DragAndDrop); |
|
217 | == SqpApplication::PlotsInteractionMode::DragAndDrop); | |
216 | connect(actionOrganisationMode, &QAction::triggered, []() { |
|
218 | connect(actionOrganisationMode, &QAction::triggered, []() { | |
217 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop); |
|
219 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop); | |
218 | }); |
|
220 | }); | |
219 |
|
221 | |||
220 | auto actionZonesMode = new QAction{QIcon(":/icones/rectangle.png"), "Zones", this}; |
|
222 | auto actionZonesMode = new QAction{QIcon(":/icones/rectangle.png"), "Zones", this}; | |
221 | actionZonesMode->setCheckable(true); |
|
223 | actionZonesMode->setCheckable(true); | |
222 | actionZonesMode->setChecked(sqpApp->plotsInteractionMode() |
|
224 | actionZonesMode->setChecked(sqpApp->plotsInteractionMode() | |
223 | == SqpApplication::PlotsInteractionMode::SelectionZones); |
|
225 | == SqpApplication::PlotsInteractionMode::SelectionZones); | |
224 | connect(actionZonesMode, &QAction::triggered, []() { |
|
226 | connect(actionZonesMode, &QAction::triggered, []() { | |
225 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones); |
|
227 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones); | |
226 | }); |
|
228 | }); | |
227 |
|
229 | |||
228 | auto modeActionGroup = new QActionGroup{this}; |
|
230 | auto modeActionGroup = new QActionGroup{this}; | |
229 | modeActionGroup->addAction(actionZoomMode); |
|
231 | modeActionGroup->addAction(actionZoomMode); | |
230 | modeActionGroup->addAction(actionZonesMode); |
|
232 | modeActionGroup->addAction(actionZonesMode); | |
231 | modeActionGroup->addAction(actionOrganisationMode); |
|
233 | modeActionGroup->addAction(actionOrganisationMode); | |
232 | modeActionGroup->addAction(actionPointerMode); |
|
234 | modeActionGroup->addAction(actionPointerMode); | |
233 | modeActionGroup->setExclusive(true); |
|
235 | modeActionGroup->setExclusive(true); | |
234 |
|
236 | |||
235 | mainToolBar->addSeparator(); |
|
237 | mainToolBar->addSeparator(); | |
236 | mainToolBar->addAction(actionPointerMode); |
|
238 | mainToolBar->addAction(actionPointerMode); | |
237 | mainToolBar->addAction(actionZoomMode); |
|
239 | mainToolBar->addAction(actionZoomMode); | |
238 | mainToolBar->addAction(actionOrganisationMode); |
|
240 | mainToolBar->addAction(actionOrganisationMode); | |
239 | mainToolBar->addAction(actionZonesMode); |
|
241 | mainToolBar->addAction(actionZonesMode); | |
240 | mainToolBar->addSeparator(); |
|
242 | mainToolBar->addSeparator(); | |
241 |
|
243 | |||
242 | // Cursors |
|
244 | // Cursors | |
243 | auto btnCursor = new QToolButton{this}; |
|
245 | auto btnCursor = new QToolButton{this}; | |
244 | btnCursor->setIcon(QIcon(":/icones/cursor.png")); |
|
246 | btnCursor->setIcon(QIcon(":/icones/cursor.png")); | |
245 | btnCursor->setText("Cursor"); |
|
247 | btnCursor->setText("Cursor"); | |
246 | btnCursor->setToolTip("Cursor"); |
|
248 | btnCursor->setToolTip("Cursor"); | |
247 | btnCursor->setPopupMode(QToolButton::InstantPopup); |
|
249 | btnCursor->setPopupMode(QToolButton::InstantPopup); | |
248 | auto cursorMenu = new QMenu("CursorMenu", this); |
|
250 | auto cursorMenu = new QMenu("CursorMenu", this); | |
249 | btnCursor->setMenu(cursorMenu); |
|
251 | btnCursor->setMenu(cursorMenu); | |
250 |
|
252 | |||
251 | auto noCursorAction = cursorMenu->addAction("No Cursor"); |
|
253 | auto noCursorAction = cursorMenu->addAction("No Cursor"); | |
252 | noCursorAction->setCheckable(true); |
|
254 | noCursorAction->setCheckable(true); | |
253 | noCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
255 | noCursorAction->setChecked(sqpApp->plotsCursorMode() | |
254 | == SqpApplication::PlotsCursorMode::NoCursor); |
|
256 | == SqpApplication::PlotsCursorMode::NoCursor); | |
255 | connect(noCursorAction, &QAction::triggered, |
|
257 | connect(noCursorAction, &QAction::triggered, | |
256 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); }); |
|
258 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); }); | |
257 |
|
259 | |||
258 | cursorMenu->addSeparator(); |
|
260 | cursorMenu->addSeparator(); | |
259 | auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor"); |
|
261 | auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor"); | |
260 | verticalCursorAction->setCheckable(true); |
|
262 | verticalCursorAction->setCheckable(true); | |
261 | verticalCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
263 | verticalCursorAction->setChecked(sqpApp->plotsCursorMode() | |
262 | == SqpApplication::PlotsCursorMode::Vertical); |
|
264 | == SqpApplication::PlotsCursorMode::Vertical); | |
263 | connect(verticalCursorAction, &QAction::triggered, |
|
265 | connect(verticalCursorAction, &QAction::triggered, | |
264 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); }); |
|
266 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); }); | |
265 |
|
267 | |||
266 | auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor"); |
|
268 | auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor"); | |
267 | temporalCursorAction->setCheckable(true); |
|
269 | temporalCursorAction->setCheckable(true); | |
268 | temporalCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
270 | temporalCursorAction->setChecked(sqpApp->plotsCursorMode() | |
269 | == SqpApplication::PlotsCursorMode::Temporal); |
|
271 | == SqpApplication::PlotsCursorMode::Temporal); | |
270 | connect(temporalCursorAction, &QAction::triggered, |
|
272 | connect(temporalCursorAction, &QAction::triggered, | |
271 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); }); |
|
273 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); }); | |
272 |
|
274 | |||
273 | auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor"); |
|
275 | auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor"); | |
274 | horizontalCursorAction->setCheckable(true); |
|
276 | horizontalCursorAction->setCheckable(true); | |
275 | horizontalCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
277 | horizontalCursorAction->setChecked(sqpApp->plotsCursorMode() | |
276 | == SqpApplication::PlotsCursorMode::Horizontal); |
|
278 | == SqpApplication::PlotsCursorMode::Horizontal); | |
277 | connect(horizontalCursorAction, &QAction::triggered, |
|
279 | connect(horizontalCursorAction, &QAction::triggered, | |
278 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); }); |
|
280 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); }); | |
279 |
|
281 | |||
280 | auto crossCursorAction = cursorMenu->addAction("Cross Cursor"); |
|
282 | auto crossCursorAction = cursorMenu->addAction("Cross Cursor"); | |
281 | crossCursorAction->setCheckable(true); |
|
283 | crossCursorAction->setCheckable(true); | |
282 | crossCursorAction->setChecked(sqpApp->plotsCursorMode() |
|
284 | crossCursorAction->setChecked(sqpApp->plotsCursorMode() | |
283 | == SqpApplication::PlotsCursorMode::Cross); |
|
285 | == SqpApplication::PlotsCursorMode::Cross); | |
284 | connect(crossCursorAction, &QAction::triggered, |
|
286 | connect(crossCursorAction, &QAction::triggered, | |
285 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); }); |
|
287 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); }); | |
286 |
|
288 | |||
287 | mainToolBar->addWidget(btnCursor); |
|
289 | mainToolBar->addWidget(btnCursor); | |
288 |
|
290 | |||
289 | auto cursorModeActionGroup = new QActionGroup{this}; |
|
291 | auto cursorModeActionGroup = new QActionGroup{this}; | |
290 | cursorModeActionGroup->setExclusive(true); |
|
292 | cursorModeActionGroup->setExclusive(true); | |
291 | cursorModeActionGroup->addAction(noCursorAction); |
|
293 | cursorModeActionGroup->addAction(noCursorAction); | |
292 | cursorModeActionGroup->addAction(verticalCursorAction); |
|
294 | cursorModeActionGroup->addAction(verticalCursorAction); | |
293 | cursorModeActionGroup->addAction(temporalCursorAction); |
|
295 | cursorModeActionGroup->addAction(temporalCursorAction); | |
294 | cursorModeActionGroup->addAction(horizontalCursorAction); |
|
296 | cursorModeActionGroup->addAction(horizontalCursorAction); | |
295 | cursorModeActionGroup->addAction(crossCursorAction); |
|
297 | cursorModeActionGroup->addAction(crossCursorAction); | |
296 |
|
298 | |||
297 | // Catalog |
|
299 | // Catalog | |
298 | mainToolBar->addSeparator(); |
|
300 | mainToolBar->addSeparator(); | |
299 | mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues", |
|
301 | mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues", | |
300 | [this]() { impl->m_CatalogExplorer->show(); }); |
|
302 | [this]() { impl->m_CatalogExplorer->show(); }); | |
301 |
|
303 | |||
302 | // //////// // |
|
304 | // //////// // | |
303 | // Settings // |
|
305 | // Settings // | |
304 | // //////// // |
|
306 | // //////// // | |
305 |
|
307 | |||
306 | // Registers "general settings" widget to the settings dialog |
|
308 | // Registers "general settings" widget to the settings dialog | |
307 | impl->m_SettingsDialog->registerWidget(QStringLiteral("General"), |
|
309 | impl->m_SettingsDialog->registerWidget(QStringLiteral("General"), | |
308 | impl->m_GeneralSettingsWidget); |
|
310 | impl->m_GeneralSettingsWidget); | |
309 |
|
311 | |||
310 | // /////////// // |
|
312 | // /////////// // | |
311 | // Connections // |
|
313 | // Connections // | |
312 | // /////////// // |
|
314 | // /////////// // | |
313 |
|
315 | |||
314 | // Controllers / controllers connections |
|
316 | // Controllers / controllers connections | |
315 | connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpRange)), &sqpApp->variableController(), |
|
317 | connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpRange)), &sqpApp->variableController(), | |
316 | SLOT(onDateTimeOnSelection(SqpRange))); |
|
318 | SLOT(onDateTimeOnSelection(SqpRange))); | |
317 |
|
319 | |||
318 | // Widgets / controllers connections |
|
320 | // Widgets / controllers connections | |
319 |
|
321 | |||
320 | // DataSource |
|
322 | // DataSource | |
321 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), |
|
323 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), | |
322 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); |
|
324 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); | |
323 |
|
325 | |||
324 | // Time |
|
326 | // Time | |
325 | connect(timeWidget, SIGNAL(timeUpdated(SqpRange)), &sqpApp->timeController(), |
|
327 | connect(timeWidget, SIGNAL(timeUpdated(SqpRange)), &sqpApp->timeController(), | |
326 | SLOT(onTimeToUpdate(SqpRange))); |
|
328 | SLOT(onTimeToUpdate(SqpRange))); | |
327 |
|
329 | |||
328 | // Visualization |
|
330 | // Visualization | |
329 | connect(&sqpApp->visualizationController(), |
|
331 | connect(&sqpApp->visualizationController(), | |
330 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view, |
|
332 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view, | |
331 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>))); |
|
333 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>))); | |
332 |
|
334 | |||
333 | connect(&sqpApp->visualizationController(), |
|
335 | connect(&sqpApp->visualizationController(), | |
334 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), m_Ui->view, |
|
336 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), m_Ui->view, | |
335 | SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpRange &))); |
|
337 | SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpRange &))); | |
336 |
|
338 | |||
337 | // Widgets / widgets connections |
|
339 | // Widgets / widgets connections | |
338 |
|
340 | |||
339 | // For the following connections, we use DirectConnection to allow each widget that can |
|
341 | // For the following connections, we use DirectConnection to allow each widget that can | |
340 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. |
|
342 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. | |
341 | // The order of connections is also important, since it determines the order in which each |
|
343 | // The order of connections is also important, since it determines the order in which each | |
342 | // widget will attach its menu |
|
344 | // widget will attach its menu | |
343 | connect( |
|
345 | connect( | |
344 | m_Ui->variableInspectorWidget, |
|
346 | m_Ui->variableInspectorWidget, | |
345 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)), |
|
347 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
346 | m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)), |
|
348 | m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)), | |
347 | Qt::DirectConnection); |
|
349 | Qt::DirectConnection); | |
348 | } |
|
350 | } | |
349 |
|
351 | |||
350 | MainWindow::~MainWindow() |
|
352 | MainWindow::~MainWindow() | |
351 | { |
|
353 | { | |
352 | } |
|
354 | } | |
353 |
|
355 | |||
354 | void MainWindow::changeEvent(QEvent *e) |
|
356 | void MainWindow::changeEvent(QEvent *e) | |
355 | { |
|
357 | { | |
356 | QMainWindow::changeEvent(e); |
|
358 | QMainWindow::changeEvent(e); | |
357 | switch (e->type()) { |
|
359 | switch (e->type()) { | |
358 | case QEvent::LanguageChange: |
|
360 | case QEvent::LanguageChange: | |
359 | m_Ui->retranslateUi(this); |
|
361 | m_Ui->retranslateUi(this); | |
360 | break; |
|
362 | break; | |
361 | default: |
|
363 | default: | |
362 | break; |
|
364 | break; | |
363 | } |
|
365 | } | |
364 | } |
|
366 | } |
@@ -1,34 +1,37 | |||||
1 | #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
1 | #ifndef SCIQLOP_CATALOGUEEVENTSWIDGET_H | |
2 | #define SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
2 | #define SCIQLOP_CATALOGUEEVENTSWIDGET_H | |
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 | #include <QWidget> |
|
5 | #include <QWidget> | |
6 |
|
6 | |||
7 | class DBCatalogue; |
|
7 | class DBCatalogue; | |
8 | class DBEvent; |
|
8 | class DBEvent; | |
|
9 | class VisualizationWidget; | |||
9 |
|
10 | |||
10 | namespace Ui { |
|
11 | namespace Ui { | |
11 | class CatalogueEventsWidget; |
|
12 | class CatalogueEventsWidget; | |
12 | } |
|
13 | } | |
13 |
|
14 | |||
14 | class CatalogueEventsWidget : public QWidget { |
|
15 | class CatalogueEventsWidget : public QWidget { | |
15 | Q_OBJECT |
|
16 | Q_OBJECT | |
16 |
|
17 | |||
17 | signals: |
|
18 | signals: | |
18 | void eventsSelected(const QVector<DBEvent> &event); |
|
19 | void eventsSelected(const QVector<DBEvent> &event); | |
19 |
|
20 | |||
20 | public: |
|
21 | public: | |
21 | explicit CatalogueEventsWidget(QWidget *parent = 0); |
|
22 | explicit CatalogueEventsWidget(QWidget *parent = 0); | |
22 | virtual ~CatalogueEventsWidget(); |
|
23 | virtual ~CatalogueEventsWidget(); | |
23 |
|
24 | |||
|
25 | void setVisualizationWidget(VisualizationWidget *visualization); | |||
|
26 | ||||
24 | public slots: |
|
27 | public slots: | |
25 | void populateWithCatalogues(const QVector<DBCatalogue> &catalogues); |
|
28 | void populateWithCatalogues(const QVector<DBCatalogue> &catalogues); | |
26 |
|
29 | |||
27 | private: |
|
30 | private: | |
28 | Ui::CatalogueEventsWidget *ui; |
|
31 | Ui::CatalogueEventsWidget *ui; | |
29 |
|
32 | |||
30 | class CatalogueEventsWidgetPrivate; |
|
33 | class CatalogueEventsWidgetPrivate; | |
31 | spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl; |
|
34 | spimpl::unique_impl_ptr<CatalogueEventsWidgetPrivate> impl; | |
32 | }; |
|
35 | }; | |
33 |
|
36 | |||
34 | #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H |
|
37 | #endif // SCIQLOP_CATALOGUEEVENTSWIDGET_H |
@@ -1,21 +1,29 | |||||
1 | #ifndef SCIQLOP_CATALOGUEEXPLORER_H |
|
1 | #ifndef SCIQLOP_CATALOGUEEXPLORER_H | |
2 | #define SCIQLOP_CATALOGUEEXPLORER_H |
|
2 | #define SCIQLOP_CATALOGUEEXPLORER_H | |
3 |
|
3 | |||
|
4 | #include <Common/spimpl.h> | |||
4 | #include <QDialog> |
|
5 | #include <QDialog> | |
5 |
|
6 | |||
6 | namespace Ui { |
|
7 | namespace Ui { | |
7 | class CatalogueExplorer; |
|
8 | class CatalogueExplorer; | |
8 | } |
|
9 | } | |
9 |
|
10 | |||
|
11 | class VisualizationWidget; | |||
|
12 | ||||
10 | class CatalogueExplorer : public QDialog { |
|
13 | class CatalogueExplorer : public QDialog { | |
11 | Q_OBJECT |
|
14 | Q_OBJECT | |
12 |
|
15 | |||
13 | public: |
|
16 | public: | |
14 | explicit CatalogueExplorer(QWidget *parent = 0); |
|
17 | explicit CatalogueExplorer(QWidget *parent = 0); | |
15 | virtual ~CatalogueExplorer(); |
|
18 | virtual ~CatalogueExplorer(); | |
16 |
|
19 | |||
|
20 | void setVisualizationWidget(VisualizationWidget *visualization); | |||
|
21 | ||||
17 | private: |
|
22 | private: | |
18 | Ui::CatalogueExplorer *ui; |
|
23 | Ui::CatalogueExplorer *ui; | |
|
24 | ||||
|
25 | class CatalogueExplorerPrivate; | |||
|
26 | spimpl::unique_impl_ptr<CatalogueExplorerPrivate> impl; | |||
19 | }; |
|
27 | }; | |
20 |
|
28 | |||
21 | #endif // SCIQLOP_CATALOGUEEXPLORER_H |
|
29 | #endif // SCIQLOP_CATALOGUEEXPLORER_H |
@@ -1,80 +1,84 | |||||
1 | #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H |
|
1 | #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H | |
2 | #define SCIQLOP_VISUALIZATIONTABWIDGET_H |
|
2 | #define SCIQLOP_VISUALIZATIONTABWIDGET_H | |
3 |
|
3 | |||
4 | #include "Visualization/IVisualizationWidget.h" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 |
|
5 | |||
6 | #include <Common/spimpl.h> |
|
6 | #include <Common/spimpl.h> | |
7 |
|
7 | |||
8 | #include <QLoggingCategory> |
|
8 | #include <QLoggingCategory> | |
9 | #include <QMimeData> |
|
9 | #include <QMimeData> | |
10 | #include <QWidget> |
|
10 | #include <QWidget> | |
11 |
|
11 | |||
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationTabWidget) |
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationTabWidget) | |
13 |
|
13 | |||
14 | class Variable; |
|
14 | class Variable; | |
15 | class VisualizationZoneWidget; |
|
15 | class VisualizationZoneWidget; | |
16 |
|
16 | |||
17 | namespace Ui { |
|
17 | namespace Ui { | |
18 | class VisualizationTabWidget; |
|
18 | class VisualizationTabWidget; | |
19 | } // namespace Ui |
|
19 | } // namespace Ui | |
20 |
|
20 | |||
21 | class VisualizationTabWidget : public QWidget, public IVisualizationWidget { |
|
21 | class VisualizationTabWidget : public QWidget, public IVisualizationWidget { | |
22 | Q_OBJECT |
|
22 | Q_OBJECT | |
23 |
|
23 | |||
24 | public: |
|
24 | public: | |
25 | explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0); |
|
25 | explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0); | |
26 | virtual ~VisualizationTabWidget(); |
|
26 | virtual ~VisualizationTabWidget(); | |
27 |
|
27 | |||
28 | /// Add a zone widget |
|
28 | /// Adds a zone widget | |
29 | void addZone(VisualizationZoneWidget *zoneWidget); |
|
29 | void addZone(VisualizationZoneWidget *zoneWidget); | |
30 |
|
30 | |||
|
31 | /// Inserts a zone widget at the specified position | |||
31 | void insertZone(int index, VisualizationZoneWidget *zoneWidget); |
|
32 | void insertZone(int index, VisualizationZoneWidget *zoneWidget); | |
32 |
|
33 | |||
|
34 | /// Returns the list of zone widget names in the order they are displayed | |||
|
35 | QStringList availableZoneWidgets() const; | |||
|
36 | ||||
33 | /** |
|
37 | /** | |
34 | * Creates a zone using a variable. The variable will be displayed in a new graph of the new |
|
38 | * Creates a zone using a variable. The variable will be displayed in a new graph of the new | |
35 | * zone. The zone is added at the end. |
|
39 | * zone. The zone is added at the end. | |
36 | * @param variable the variable for which to create the zone |
|
40 | * @param variable the variable for which to create the zone | |
37 | * @return the pointer to the created zone |
|
41 | * @return the pointer to the created zone | |
38 | */ |
|
42 | */ | |
39 | VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable); |
|
43 | VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable); | |
40 |
|
44 | |||
41 | /** |
|
45 | /** | |
42 | * Creates a zone using a list of variables. The variables will be displayed in a new graph of |
|
46 | * Creates a zone using a list of variables. The variables will be displayed in a new graph of | |
43 | * the new zone. The zone is inserted at the specified index. |
|
47 | * the new zone. The zone is inserted at the specified index. | |
44 | * @param variables the variables for which to create the zone |
|
48 | * @param variables the variables for which to create the zone | |
45 | * @param index The index where the zone should be inserted in the layout |
|
49 | * @param index The index where the zone should be inserted in the layout | |
46 | * @return the pointer to the created zone |
|
50 | * @return the pointer to the created zone | |
47 | */ |
|
51 | */ | |
48 | VisualizationZoneWidget *createZone(const QList<std::shared_ptr<Variable> > &variables, |
|
52 | VisualizationZoneWidget *createZone(const QList<std::shared_ptr<Variable> > &variables, | |
49 | int index); |
|
53 | int index); | |
50 |
|
54 | |||
51 | /** |
|
55 | /** | |
52 | * Creates a zone which is empty (no variables). The zone is inserted at the specified index. |
|
56 | * Creates a zone which is empty (no variables). The zone is inserted at the specified index. | |
53 | * @param index The index where the zone should be inserted in the layout |
|
57 | * @param index The index where the zone should be inserted in the layout | |
54 | * @return the pointer to the created zone |
|
58 | * @return the pointer to the created zone | |
55 | */ |
|
59 | */ | |
56 | VisualizationZoneWidget *createEmptyZone(int index); |
|
60 | VisualizationZoneWidget *createEmptyZone(int index); | |
57 |
|
61 | |||
58 | // IVisualizationWidget interface |
|
62 | // IVisualizationWidget interface | |
59 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
63 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
60 | bool canDrop(const Variable &variable) const override; |
|
64 | bool canDrop(const Variable &variable) const override; | |
61 | bool contains(const Variable &variable) const override; |
|
65 | bool contains(const Variable &variable) const override; | |
62 | QString name() const override; |
|
66 | QString name() const override; | |
63 |
|
67 | |||
64 | protected: |
|
68 | protected: | |
65 | void closeEvent(QCloseEvent *event) override; |
|
69 | void closeEvent(QCloseEvent *event) override; | |
66 |
|
70 | |||
67 | private: |
|
71 | private: | |
68 | /// @return the layout of tab in which zones are added |
|
72 | /// @return the layout of tab in which zones are added | |
69 | QLayout &tabLayout() const noexcept; |
|
73 | QLayout &tabLayout() const noexcept; | |
70 |
|
74 | |||
71 | Ui::VisualizationTabWidget *ui; |
|
75 | Ui::VisualizationTabWidget *ui; | |
72 |
|
76 | |||
73 | class VisualizationTabWidgetPrivate; |
|
77 | class VisualizationTabWidgetPrivate; | |
74 | spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl; |
|
78 | spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl; | |
75 |
|
79 | |||
76 | private slots: |
|
80 | private slots: | |
77 | void dropMimeData(int index, const QMimeData *mimeData); |
|
81 | void dropMimeData(int index, const QMimeData *mimeData); | |
78 | }; |
|
82 | }; | |
79 |
|
83 | |||
80 | #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H |
|
84 | #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H |
@@ -1,63 +1,65 | |||||
1 | #ifndef SCIQLOP_VISUALIZATIONWIDGET_H |
|
1 | #ifndef SCIQLOP_VISUALIZATIONWIDGET_H | |
2 | #define SCIQLOP_VISUALIZATIONWIDGET_H |
|
2 | #define SCIQLOP_VISUALIZATIONWIDGET_H | |
3 |
|
3 | |||
4 | #include "Visualization/IVisualizationWidget.h" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 | #include <Data/SqpRange.h> |
|
5 | #include <Data/SqpRange.h> | |
6 |
|
6 | |||
7 | #include <QLoggingCategory> |
|
7 | #include <QLoggingCategory> | |
8 | #include <QWidget> |
|
8 | #include <QWidget> | |
9 |
|
9 | |||
10 | #include <Common/spimpl.h> |
|
10 | #include <Common/spimpl.h> | |
11 |
|
11 | |||
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) |
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) | |
13 |
|
13 | |||
14 | class QMenu; |
|
14 | class QMenu; | |
15 | class Variable; |
|
15 | class Variable; | |
16 | class VisualizationTabWidget; |
|
16 | class VisualizationTabWidget; | |
17 | class VisualizationSelectionZoneManager; |
|
17 | class VisualizationSelectionZoneManager; | |
18 |
|
18 | |||
19 | namespace Ui { |
|
19 | namespace Ui { | |
20 | class VisualizationWidget; |
|
20 | class VisualizationWidget; | |
21 | } // namespace Ui |
|
21 | } // namespace Ui | |
22 |
|
22 | |||
23 | class VisualizationWidget : public QWidget, public IVisualizationWidget { |
|
23 | class VisualizationWidget : public QWidget, public IVisualizationWidget { | |
24 | Q_OBJECT |
|
24 | Q_OBJECT | |
25 |
|
25 | |||
26 | public: |
|
26 | public: | |
27 | explicit VisualizationWidget(QWidget *parent = 0); |
|
27 | explicit VisualizationWidget(QWidget *parent = 0); | |
28 | virtual ~VisualizationWidget(); |
|
28 | virtual ~VisualizationWidget(); | |
29 |
|
29 | |||
30 | /// Returns the class which manage the selection of selection zone across the visualization |
|
30 | /// Returns the class which manage the selection of selection zone across the visualization | |
31 | VisualizationSelectionZoneManager &selectionZoneManager() const; |
|
31 | VisualizationSelectionZoneManager &selectionZoneManager() const; | |
32 |
|
32 | |||
|
33 | VisualizationTabWidget *currentTabWidget() const; | |||
|
34 | ||||
33 | // IVisualizationWidget interface |
|
35 | // IVisualizationWidget interface | |
34 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
36 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
35 | bool canDrop(const Variable &variable) const override; |
|
37 | bool canDrop(const Variable &variable) const override; | |
36 | bool contains(const Variable &variable) const override; |
|
38 | bool contains(const Variable &variable) const override; | |
37 | QString name() const override; |
|
39 | QString name() const override; | |
38 |
|
40 | |||
39 | public slots: |
|
41 | public slots: | |
40 | /** |
|
42 | /** | |
41 | * Attaches to a menu the menu relative to the visualization of variables |
|
43 | * Attaches to a menu the menu relative to the visualization of variables | |
42 | * @param menu the parent menu of the generated menu |
|
44 | * @param menu the parent menu of the generated menu | |
43 | * @param variables the variables for which to generate the menu |
|
45 | * @param variables the variables for which to generate the menu | |
44 | */ |
|
46 | */ | |
45 | void attachVariableMenu(QMenu *menu, |
|
47 | void attachVariableMenu(QMenu *menu, | |
46 | const QVector<std::shared_ptr<Variable> > &variables) noexcept; |
|
48 | const QVector<std::shared_ptr<Variable> > &variables) noexcept; | |
47 |
|
49 | |||
48 | /// Slot called when a variable is about to be deleted from SciQlop |
|
50 | /// Slot called when a variable is about to be deleted from SciQlop | |
49 | void onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept; |
|
51 | void onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept; | |
50 |
|
52 | |||
51 | void onRangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range) noexcept; |
|
53 | void onRangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range) noexcept; | |
52 |
|
54 | |||
53 | protected: |
|
55 | protected: | |
54 | void closeEvent(QCloseEvent *event) override; |
|
56 | void closeEvent(QCloseEvent *event) override; | |
55 |
|
57 | |||
56 | private: |
|
58 | private: | |
57 | Ui::VisualizationWidget *ui; |
|
59 | Ui::VisualizationWidget *ui; | |
58 |
|
60 | |||
59 | class VisualizationWidgetPrivate; |
|
61 | class VisualizationWidgetPrivate; | |
60 | spimpl::unique_impl_ptr<VisualizationWidgetPrivate> impl; |
|
62 | spimpl::unique_impl_ptr<VisualizationWidgetPrivate> impl; | |
61 | }; |
|
63 | }; | |
62 |
|
64 | |||
63 | #endif // VISUALIZATIONWIDGET_H |
|
65 | #endif // VISUALIZATIONWIDGET_H |
@@ -1,193 +1,218 | |||||
1 | #include "Catalogue/CatalogueEventsWidget.h" |
|
1 | #include "Catalogue/CatalogueEventsWidget.h" | |
2 | #include "ui_CatalogueEventsWidget.h" |
|
2 | #include "ui_CatalogueEventsWidget.h" | |
3 |
|
3 | |||
4 | #include <Catalogue/CatalogueController.h> |
|
4 | #include <Catalogue/CatalogueController.h> | |
5 | #include <Catalogue/CatalogueEventsTableModel.h> |
|
5 | #include <Catalogue/CatalogueEventsTableModel.h> | |
6 | #include <CatalogueDao.h> |
|
6 | #include <CatalogueDao.h> | |
7 | #include <DBCatalogue.h> |
|
7 | #include <DBCatalogue.h> | |
8 | #include <SqpApplication.h> |
|
8 | #include <SqpApplication.h> | |
|
9 | #include <Visualization/VisualizationTabWidget.h> | |||
|
10 | #include <Visualization/VisualizationWidget.h> | |||
9 |
|
11 | |||
10 | #include <QDialog> |
|
12 | #include <QDialog> | |
11 | #include <QDialogButtonBox> |
|
13 | #include <QDialogButtonBox> | |
12 | #include <QListWidget> |
|
14 | #include <QListWidget> | |
13 |
|
15 | |||
14 |
|
16 | |||
15 | /// Format of the dates appearing in the label of a cursor |
|
17 | /// Format of the dates appearing in the label of a cursor | |
16 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss"); |
|
18 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss"); | |
17 |
|
19 | |||
18 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
20 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { | |
19 |
|
21 | |||
20 | CatalogueEventsTableModel *m_Model = nullptr; |
|
22 | CatalogueEventsTableModel *m_Model = nullptr; | |
21 | QString m_ZoneForTimeMode; |
|
23 | QString m_ZoneForTimeMode; | |
22 | QString m_ZoneForGraphMode; |
|
24 | QString m_ZoneForGraphMode; | |
23 |
|
25 | |||
|
26 | VisualizationWidget *m_VisualizationWidget = nullptr; | |||
|
27 | ||||
24 | void setEvents(const QVector<DBEvent> &events, QTableView *tableView) |
|
28 | void setEvents(const QVector<DBEvent> &events, QTableView *tableView) | |
25 | { |
|
29 | { | |
26 | tableView->setSortingEnabled(false); |
|
30 | tableView->setSortingEnabled(false); | |
27 | m_Model->setEvents(events); |
|
31 | m_Model->setEvents(events); | |
28 | tableView->setSortingEnabled(true); |
|
32 | tableView->setSortingEnabled(true); | |
29 | } |
|
33 | } | |
30 |
|
34 | |||
31 | void addEvent(const DBEvent &event, QTableView *tableView) |
|
35 | void addEvent(const DBEvent &event, QTableView *tableView) | |
32 | { |
|
36 | { | |
33 | tableView->setSortingEnabled(false); |
|
37 | tableView->setSortingEnabled(false); | |
34 | m_Model->addEvent(event); |
|
38 | m_Model->addEvent(event); | |
35 | tableView->setSortingEnabled(true); |
|
39 | tableView->setSortingEnabled(true); | |
36 | } |
|
40 | } | |
37 |
|
41 | |||
38 | void removeEvent(const DBEvent &event, QTableView *tableView) |
|
42 | void removeEvent(const DBEvent &event, QTableView *tableView) | |
39 | { |
|
43 | { | |
40 | tableView->setSortingEnabled(false); |
|
44 | tableView->setSortingEnabled(false); | |
41 | m_Model->removeEvent(event); |
|
45 | m_Model->removeEvent(event); | |
42 | tableView->setSortingEnabled(true); |
|
46 | tableView->setSortingEnabled(true); | |
43 | } |
|
47 | } | |
44 |
|
48 | |||
45 | QStringList selectZone(QWidget *parent, const QStringList &availableZones, |
|
49 | QStringList getAvailableVisualizationZoneList() const | |
46 | const QStringList &selectedZones, bool allowMultiSelection, |
|
50 | { | |
47 | const QPoint &location) |
|
51 | if (m_VisualizationWidget) { | |
|
52 | if (auto tab = m_VisualizationWidget->currentTabWidget()) { | |||
|
53 | return tab->availableZoneWidgets(); | |||
|
54 | } | |||
|
55 | } | |||
|
56 | ||||
|
57 | return QStringList{}; | |||
|
58 | } | |||
|
59 | ||||
|
60 | QStringList selectZone(QWidget *parent, const QStringList &selectedZones, | |||
|
61 | bool allowMultiSelection, const QPoint &location) | |||
48 | { |
|
62 | { | |
|
63 | auto availableZones = getAvailableVisualizationZoneList(); | |||
|
64 | if (availableZones.isEmpty()) { | |||
|
65 | return QStringList{}; | |||
|
66 | } | |||
|
67 | ||||
49 | QDialog d(parent, Qt::Tool); |
|
68 | QDialog d(parent, Qt::Tool); | |
50 | d.setWindowTitle("Choose a zone"); |
|
69 | d.setWindowTitle("Choose a zone"); | |
51 | auto layout = new QVBoxLayout{&d}; |
|
70 | auto layout = new QVBoxLayout{&d}; | |
52 | layout->setContentsMargins(0, 0, 0, 0); |
|
71 | layout->setContentsMargins(0, 0, 0, 0); | |
53 | auto listWidget = new QListWidget{&d}; |
|
72 | auto listWidget = new QListWidget{&d}; | |
54 | layout->addWidget(listWidget); |
|
73 | layout->addWidget(listWidget); | |
55 |
|
74 | |||
56 | QSet<QListWidgetItem *> checkedItems; |
|
75 | QSet<QListWidgetItem *> checkedItems; | |
57 | for (auto zone : availableZones) { |
|
76 | for (auto zone : availableZones) { | |
58 | auto item = new QListWidgetItem{zone}; |
|
77 | auto item = new QListWidgetItem{zone}; | |
59 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); |
|
78 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); | |
60 | if (selectedZones.contains(zone)) { |
|
79 | if (selectedZones.contains(zone)) { | |
61 | item->setCheckState(Qt::Checked); |
|
80 | item->setCheckState(Qt::Checked); | |
62 | checkedItems << item; |
|
81 | checkedItems << item; | |
63 | } |
|
82 | } | |
64 | else { |
|
83 | else { | |
65 | item->setCheckState(Qt::Unchecked); |
|
84 | item->setCheckState(Qt::Unchecked); | |
66 | } |
|
85 | } | |
67 |
|
86 | |||
68 | listWidget->addItem(item); |
|
87 | listWidget->addItem(item); | |
69 | } |
|
88 | } | |
70 |
|
89 | |||
71 | auto buttonBox = new QDialogButtonBox{QDialogButtonBox::Ok, &d}; |
|
90 | auto buttonBox = new QDialogButtonBox{QDialogButtonBox::Ok, &d}; | |
72 | layout->addWidget(buttonBox); |
|
91 | layout->addWidget(buttonBox); | |
73 |
|
92 | |||
74 | QObject::connect(buttonBox, &QDialogButtonBox::accepted, &d, &QDialog::accept); |
|
93 | QObject::connect(buttonBox, &QDialogButtonBox::accepted, &d, &QDialog::accept); | |
75 | QObject::connect(buttonBox, &QDialogButtonBox::rejected, &d, &QDialog::reject); |
|
94 | QObject::connect(buttonBox, &QDialogButtonBox::rejected, &d, &QDialog::reject); | |
76 |
|
95 | |||
77 | QObject::connect(listWidget, &QListWidget::itemChanged, |
|
96 | QObject::connect(listWidget, &QListWidget::itemChanged, | |
78 | [&checkedItems, allowMultiSelection, listWidget](auto item) { |
|
97 | [&checkedItems, allowMultiSelection, listWidget](auto item) { | |
79 | if (item->checkState() == Qt::Checked) { |
|
98 | if (item->checkState() == Qt::Checked) { | |
80 | if (!allowMultiSelection) { |
|
99 | if (!allowMultiSelection) { | |
81 | for (auto checkedItem : checkedItems) { |
|
100 | for (auto checkedItem : checkedItems) { | |
82 | listWidget->blockSignals(true); |
|
101 | listWidget->blockSignals(true); | |
83 | checkedItem->setCheckState(Qt::Unchecked); |
|
102 | checkedItem->setCheckState(Qt::Unchecked); | |
84 | listWidget->blockSignals(false); |
|
103 | listWidget->blockSignals(false); | |
85 | } |
|
104 | } | |
86 |
|
105 | |||
87 | checkedItems.clear(); |
|
106 | checkedItems.clear(); | |
88 | } |
|
107 | } | |
89 | checkedItems << item; |
|
108 | checkedItems << item; | |
90 | } |
|
109 | } | |
91 | else { |
|
110 | else { | |
92 | checkedItems.remove(item); |
|
111 | checkedItems.remove(item); | |
93 | } |
|
112 | } | |
94 | }); |
|
113 | }); | |
95 |
|
114 | |||
96 | QStringList result; |
|
115 | QStringList result; | |
97 |
|
116 | |||
98 | d.setMinimumWidth(120); |
|
117 | d.setMinimumWidth(120); | |
99 | d.resize(d.minimumSizeHint()); |
|
118 | d.resize(d.minimumSizeHint()); | |
100 | d.move(location); |
|
119 | d.move(location); | |
101 | if (d.exec() == QDialog::Accepted) { |
|
120 | if (d.exec() == QDialog::Accepted) { | |
102 | for (auto item : checkedItems) { |
|
121 | for (auto item : checkedItems) { | |
103 | result += item->text(); |
|
122 | result += item->text(); | |
104 | } |
|
123 | } | |
105 | } |
|
124 | } | |
|
125 | else { | |||
|
126 | result = selectedZones; | |||
|
127 | } | |||
106 |
|
128 | |||
107 | return result; |
|
129 | return result; | |
108 | } |
|
130 | } | |
109 | }; |
|
131 | }; | |
110 |
|
132 | |||
111 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) |
|
133 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) | |
112 | : QWidget(parent), |
|
134 | : QWidget(parent), | |
113 | ui(new Ui::CatalogueEventsWidget), |
|
135 | ui(new Ui::CatalogueEventsWidget), | |
114 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} |
|
136 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} | |
115 | { |
|
137 | { | |
116 | ui->setupUi(this); |
|
138 | ui->setupUi(this); | |
117 |
|
139 | |||
118 | impl->m_Model = new CatalogueEventsTableModel{this}; |
|
140 | impl->m_Model = new CatalogueEventsTableModel{this}; | |
119 | ui->tableView->setModel(impl->m_Model); |
|
141 | ui->tableView->setModel(impl->m_Model); | |
120 |
|
142 | |||
121 | ui->tableView->setSortingEnabled(true); |
|
143 | ui->tableView->setSortingEnabled(true); | |
122 | ui->tableView->setDragDropMode(QAbstractItemView::DragDrop); |
|
144 | ui->tableView->setDragDropMode(QAbstractItemView::DragDrop); | |
123 | ui->tableView->setDragEnabled(true); |
|
145 | ui->tableView->setDragEnabled(true); | |
124 |
|
146 | |||
125 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { |
|
147 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { | |
126 | if (checked) { |
|
148 | if (checked) { | |
127 | ui->btnChart->setChecked(false); |
|
149 | ui->btnChart->setChecked(false); | |
128 | impl->m_ZoneForTimeMode |
|
150 | impl->m_ZoneForTimeMode | |
129 |
= impl->selectZone(this, { |
|
151 | = impl->selectZone(this, {impl->m_ZoneForTimeMode}, false, | |
130 | {impl->m_ZoneForTimeMode}, false, |
|
|||
131 | this->mapToGlobal(ui->btnTime->frameGeometry().center())) |
|
152 | this->mapToGlobal(ui->btnTime->frameGeometry().center())) | |
132 | .value(0); |
|
153 | .value(0); | |
133 | } |
|
154 | } | |
134 | }); |
|
155 | }); | |
135 |
|
156 | |||
136 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { |
|
157 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { | |
137 | if (checked) { |
|
158 | if (checked) { | |
138 | ui->btnTime->setChecked(false); |
|
159 | ui->btnTime->setChecked(false); | |
139 | impl->m_ZoneForGraphMode |
|
160 | impl->m_ZoneForGraphMode | |
140 |
= impl->selectZone(this, { |
|
161 | = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false, | |
141 | {impl->m_ZoneForGraphMode}, false, |
|
|||
142 | this->mapToGlobal(ui->btnChart->frameGeometry().center())) |
|
162 | this->mapToGlobal(ui->btnChart->frameGeometry().center())) | |
143 | .value(0); |
|
163 | .value(0); | |
144 | } |
|
164 | } | |
145 | }); |
|
165 | }); | |
146 |
|
166 | |||
147 | auto emitSelection = [this]() { |
|
167 | auto emitSelection = [this]() { | |
148 | QVector<DBEvent> events; |
|
168 | QVector<DBEvent> events; | |
149 | for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { |
|
169 | for (auto rowIndex : ui->tableView->selectionModel()->selectedRows()) { | |
150 | events << impl->m_Model->getEvent(rowIndex.row()); |
|
170 | events << impl->m_Model->getEvent(rowIndex.row()); | |
151 | } |
|
171 | } | |
152 |
|
172 | |||
153 | emit this->eventsSelected(events); |
|
173 | emit this->eventsSelected(events); | |
154 | }; |
|
174 | }; | |
155 |
|
175 | |||
156 | connect(ui->tableView, &QTableView::clicked, emitSelection); |
|
176 | connect(ui->tableView, &QTableView::clicked, emitSelection); | |
157 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection); |
|
177 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection); | |
158 |
|
178 | |||
159 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { |
|
179 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { | |
160 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; |
|
180 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; | |
161 | ui->btnChart->setEnabled(isNotMultiSelection); |
|
181 | ui->btnChart->setEnabled(isNotMultiSelection); | |
162 | ui->btnTime->setEnabled(isNotMultiSelection); |
|
182 | ui->btnTime->setEnabled(isNotMultiSelection); | |
163 | }); |
|
183 | }); | |
164 |
|
184 | |||
165 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
|
185 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
166 | ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); |
|
186 | ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); | |
167 | ui->tableView->horizontalHeader()->setSortIndicatorShown(true); |
|
187 | ui->tableView->horizontalHeader()->setSortIndicatorShown(true); | |
168 | } |
|
188 | } | |
169 |
|
189 | |||
170 | CatalogueEventsWidget::~CatalogueEventsWidget() |
|
190 | CatalogueEventsWidget::~CatalogueEventsWidget() | |
171 | { |
|
191 | { | |
172 | delete ui; |
|
192 | delete ui; | |
173 | } |
|
193 | } | |
174 |
|
194 | |||
|
195 | void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualization) | |||
|
196 | { | |||
|
197 | impl->m_VisualizationWidget = visualization; | |||
|
198 | } | |||
|
199 | ||||
175 | void CatalogueEventsWidget::populateWithCatalogues(const QVector<DBCatalogue> &catalogues) |
|
200 | void CatalogueEventsWidget::populateWithCatalogues(const QVector<DBCatalogue> &catalogues) | |
176 | { |
|
201 | { | |
177 | auto &dao = sqpApp->catalogueController().getDao(); |
|
202 | auto &dao = sqpApp->catalogueController().getDao(); | |
178 |
|
203 | |||
179 | QSet<QUuid> eventIds; |
|
204 | QSet<QUuid> eventIds; | |
180 | QVector<DBEvent> events; |
|
205 | QVector<DBEvent> events; | |
181 |
|
206 | |||
182 | for (auto catalogue : catalogues) { |
|
207 | for (auto catalogue : catalogues) { | |
183 | auto catalogueEvents = dao.getCatalogueEvents(catalogue); |
|
208 | auto catalogueEvents = dao.getCatalogueEvents(catalogue); | |
184 | for (auto event : catalogueEvents) { |
|
209 | for (auto event : catalogueEvents) { | |
185 | if (!eventIds.contains(event.getUniqId())) { |
|
210 | if (!eventIds.contains(event.getUniqId())) { | |
186 | events << event; |
|
211 | events << event; | |
187 | eventIds.insert(event.getUniqId()); |
|
212 | eventIds.insert(event.getUniqId()); | |
188 | } |
|
213 | } | |
189 | } |
|
214 | } | |
190 | } |
|
215 | } | |
191 |
|
216 | |||
192 | impl->setEvents(events, ui->tableView); |
|
217 | impl->setEvents(events, ui->tableView); | |
193 | } |
|
218 | } |
@@ -1,50 +1,61 | |||||
1 | #include "Catalogue/CatalogueExplorer.h" |
|
1 | #include "Catalogue/CatalogueExplorer.h" | |
2 | #include "ui_CatalogueExplorer.h" |
|
2 | #include "ui_CatalogueExplorer.h" | |
3 |
|
3 | |||
|
4 | #include <Visualization/VisualizationWidget.h> | |||
|
5 | ||||
4 | #include <DBCatalogue.h> |
|
6 | #include <DBCatalogue.h> | |
5 | #include <DBEvent.h> |
|
7 | #include <DBEvent.h> | |
6 |
|
8 | |||
|
9 | struct CatalogueExplorer::CatalogueExplorerPrivate { | |||
|
10 | }; | |||
|
11 | ||||
7 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) |
|
12 | CatalogueExplorer::CatalogueExplorer(QWidget *parent) | |
8 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), |
|
13 | : QDialog(parent, Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), | |
9 | ui(new Ui::CatalogueExplorer) |
|
14 | ui(new Ui::CatalogueExplorer), | |
|
15 | impl{spimpl::make_unique_impl<CatalogueExplorerPrivate>()} | |||
10 | { |
|
16 | { | |
11 | ui->setupUi(this); |
|
17 | ui->setupUi(this); | |
12 |
|
18 | |||
13 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) { |
|
19 | connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSelected, [this](auto catalogues) { | |
14 | if (catalogues.count() == 1) { |
|
20 | if (catalogues.count() == 1) { | |
15 | ui->inspector->setCatalogue(catalogues.first()); |
|
21 | ui->inspector->setCatalogue(catalogues.first()); | |
16 | } |
|
22 | } | |
17 | else { |
|
23 | else { | |
18 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); |
|
24 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |
19 | } |
|
25 | } | |
20 |
|
26 | |||
21 | ui->events->populateWithCatalogues(catalogues); |
|
27 | ui->events->populateWithCatalogues(catalogues); | |
22 | }); |
|
28 | }); | |
23 |
|
29 | |||
24 | connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) { |
|
30 | connect(ui->catalogues, &CatalogueSideBarWidget::databaseSelected, [this](auto databases) { | |
25 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); |
|
31 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |
26 | }); |
|
32 | }); | |
27 |
|
33 | |||
28 | connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected, |
|
34 | connect(ui->catalogues, &CatalogueSideBarWidget::trashSelected, | |
29 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); |
|
35 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |
30 |
|
36 | |||
31 | connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected, |
|
37 | connect(ui->catalogues, &CatalogueSideBarWidget::allEventsSelected, | |
32 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); |
|
38 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |
33 |
|
39 | |||
34 | connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared, |
|
40 | connect(ui->catalogues, &CatalogueSideBarWidget::selectionCleared, | |
35 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); |
|
41 | [this]() { ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); }); | |
36 |
|
42 | |||
37 | connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) { |
|
43 | connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) { | |
38 | if (events.count() == 1) { |
|
44 | if (events.count() == 1) { | |
39 | ui->inspector->setEvent(events.first()); |
|
45 | ui->inspector->setEvent(events.first()); | |
40 | } |
|
46 | } | |
41 | else { |
|
47 | else { | |
42 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); |
|
48 | ui->inspector->showPage(CatalogueInspectorWidget::Page::Empty); | |
43 | } |
|
49 | } | |
44 | }); |
|
50 | }); | |
45 | } |
|
51 | } | |
46 |
|
52 | |||
47 | CatalogueExplorer::~CatalogueExplorer() |
|
53 | CatalogueExplorer::~CatalogueExplorer() | |
48 | { |
|
54 | { | |
49 | delete ui; |
|
55 | delete ui; | |
50 | } |
|
56 | } | |
|
57 | ||||
|
58 | void CatalogueExplorer::setVisualizationWidget(VisualizationWidget *visualization) | |||
|
59 | { | |||
|
60 | ui->events->setVisualizationWidget(visualization); | |||
|
61 | } |
@@ -1,329 +1,338 | |||||
1 | #include "Visualization/VisualizationTabWidget.h" |
|
1 | #include "Visualization/VisualizationTabWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "ui_VisualizationTabWidget.h" |
|
3 | #include "ui_VisualizationTabWidget.h" | |
4 |
|
4 | |||
5 | #include "Visualization/VisualizationGraphWidget.h" |
|
5 | #include "Visualization/VisualizationGraphWidget.h" | |
6 | #include "Visualization/VisualizationZoneWidget.h" |
|
6 | #include "Visualization/VisualizationZoneWidget.h" | |
7 |
|
7 | |||
8 | #include "Visualization/MacScrollBarStyle.h" |
|
8 | #include "Visualization/MacScrollBarStyle.h" | |
9 |
|
9 | |||
10 | #include "Variable/VariableController.h" |
|
10 | #include "Variable/VariableController.h" | |
11 |
|
11 | |||
12 | #include "Common/MimeTypesDef.h" |
|
12 | #include "Common/MimeTypesDef.h" | |
13 |
|
13 | |||
14 | #include "DragAndDrop/DragDropGuiController.h" |
|
14 | #include "DragAndDrop/DragDropGuiController.h" | |
15 | #include "SqpApplication.h" |
|
15 | #include "SqpApplication.h" | |
16 |
|
16 | |||
17 | Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget") |
|
17 | Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget") | |
18 |
|
18 | |||
19 | namespace { |
|
19 | namespace { | |
20 |
|
20 | |||
21 | /// Generates a default name for a new zone, according to the number of zones already displayed in |
|
21 | /// Generates a default name for a new zone, according to the number of zones already displayed in | |
22 | /// the tab |
|
22 | /// the tab | |
23 | QString defaultZoneName(const QLayout &layout) |
|
23 | QString defaultZoneName(const QLayout &layout) | |
24 | { |
|
24 | { | |
25 | auto count = 0; |
|
25 | auto count = 0; | |
26 | for (auto i = 0; i < layout.count(); ++i) { |
|
26 | for (auto i = 0; i < layout.count(); ++i) { | |
27 | if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) { |
|
27 | if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) { | |
28 | count++; |
|
28 | count++; | |
29 | } |
|
29 | } | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | return QObject::tr("Zone %1").arg(count + 1); |
|
32 | return QObject::tr("Zone %1").arg(count + 1); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | /** |
|
35 | /** | |
36 | * Applies a function to all zones of the tab represented by its layout |
|
36 | * Applies a function to all zones of the tab represented by its layout | |
37 | * @param layout the layout that contains zones |
|
37 | * @param layout the layout that contains zones | |
38 | * @param fun the function to apply to each zone |
|
38 | * @param fun the function to apply to each zone | |
39 | */ |
|
39 | */ | |
40 | template <typename Fun> |
|
40 | template <typename Fun> | |
41 | void processZones(QLayout &layout, Fun fun) |
|
41 | void processZones(QLayout &layout, Fun fun) | |
42 | { |
|
42 | { | |
43 | for (auto i = 0; i < layout.count(); ++i) { |
|
43 | for (auto i = 0; i < layout.count(); ++i) { | |
44 | if (auto item = layout.itemAt(i)) { |
|
44 | if (auto item = layout.itemAt(i)) { | |
45 | if (auto visualizationZoneWidget |
|
45 | if (auto visualizationZoneWidget | |
46 | = dynamic_cast<VisualizationZoneWidget *>(item->widget())) { |
|
46 | = dynamic_cast<VisualizationZoneWidget *>(item->widget())) { | |
47 | fun(*visualizationZoneWidget); |
|
47 | fun(*visualizationZoneWidget); | |
48 | } |
|
48 | } | |
49 | } |
|
49 | } | |
50 | } |
|
50 | } | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | } // namespace |
|
53 | } // namespace | |
54 |
|
54 | |||
55 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { |
|
55 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { | |
56 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} |
|
56 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} | |
57 |
|
57 | |||
58 | QString m_Name; |
|
58 | QString m_Name; | |
59 |
|
59 | |||
60 | #ifdef Q_OS_MAC |
|
60 | #ifdef Q_OS_MAC | |
61 | std::unique_ptr<MacScrollBarStyle> m_MacScrollBarStyle = std::make_unique<MacScrollBarStyle>(); |
|
61 | std::unique_ptr<MacScrollBarStyle> m_MacScrollBarStyle = std::make_unique<MacScrollBarStyle>(); | |
62 | #endif |
|
62 | #endif | |
63 |
|
63 | |||
64 | void dropGraph(int index, VisualizationTabWidget *tabWidget); |
|
64 | void dropGraph(int index, VisualizationTabWidget *tabWidget); | |
65 | void dropZone(int index, VisualizationTabWidget *tabWidget); |
|
65 | void dropZone(int index, VisualizationTabWidget *tabWidget); | |
66 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, |
|
66 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, | |
67 | VisualizationTabWidget *tabWidget); |
|
67 | VisualizationTabWidget *tabWidget); | |
68 | }; |
|
68 | }; | |
69 |
|
69 | |||
70 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) |
|
70 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) | |
71 | : QWidget{parent}, |
|
71 | : QWidget{parent}, | |
72 | ui{new Ui::VisualizationTabWidget}, |
|
72 | ui{new Ui::VisualizationTabWidget}, | |
73 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} |
|
73 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} | |
74 | { |
|
74 | { | |
75 | ui->setupUi(this); |
|
75 | ui->setupUi(this); | |
76 |
|
76 | |||
77 | #ifdef Q_OS_MAC |
|
77 | #ifdef Q_OS_MAC | |
78 | impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true); |
|
78 | impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true); | |
79 | #endif |
|
79 | #endif | |
80 |
|
80 | |||
81 | ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Zone, "Zone"); |
|
81 | ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Zone, "Zone"); | |
82 | ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12); |
|
82 | ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12); | |
83 | ui->dragDropContainer->layout()->setSpacing(0); |
|
83 | ui->dragDropContainer->layout()->setSpacing(0); | |
84 | ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH, |
|
84 | ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH, | |
85 | VisualizationDragDropContainer::DropBehavior::Inserted); |
|
85 | VisualizationDragDropContainer::DropBehavior::Inserted); | |
86 | ui->dragDropContainer->setMimeType(MIME_TYPE_ZONE, |
|
86 | ui->dragDropContainer->setMimeType(MIME_TYPE_ZONE, | |
87 | VisualizationDragDropContainer::DropBehavior::Inserted); |
|
87 | VisualizationDragDropContainer::DropBehavior::Inserted); | |
88 | ui->dragDropContainer->setMimeType(MIME_TYPE_VARIABLE_LIST, |
|
88 | ui->dragDropContainer->setMimeType(MIME_TYPE_VARIABLE_LIST, | |
89 | VisualizationDragDropContainer::DropBehavior::Inserted); |
|
89 | VisualizationDragDropContainer::DropBehavior::Inserted); | |
90 |
|
90 | |||
91 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { |
|
91 | ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) { | |
92 | return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData, |
|
92 | return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData, | |
93 | ui->dragDropContainer); |
|
93 | ui->dragDropContainer); | |
94 | }); |
|
94 | }); | |
95 |
|
95 | |||
96 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, |
|
96 | connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this, | |
97 | &VisualizationTabWidget::dropMimeData); |
|
97 | &VisualizationTabWidget::dropMimeData); | |
98 |
|
98 | |||
99 | sqpApp->dragDropGuiController().addDragDropScrollArea(ui->scrollArea); |
|
99 | sqpApp->dragDropGuiController().addDragDropScrollArea(ui->scrollArea); | |
100 |
|
100 | |||
101 | // Widget is deleted when closed |
|
101 | // Widget is deleted when closed | |
102 | setAttribute(Qt::WA_DeleteOnClose); |
|
102 | setAttribute(Qt::WA_DeleteOnClose); | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | VisualizationTabWidget::~VisualizationTabWidget() |
|
105 | VisualizationTabWidget::~VisualizationTabWidget() | |
106 | { |
|
106 | { | |
107 | sqpApp->dragDropGuiController().removeDragDropScrollArea(ui->scrollArea); |
|
107 | sqpApp->dragDropGuiController().removeDragDropScrollArea(ui->scrollArea); | |
108 | delete ui; |
|
108 | delete ui; | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) |
|
111 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) | |
112 | { |
|
112 | { | |
113 | ui->dragDropContainer->addDragWidget(zoneWidget); |
|
113 | ui->dragDropContainer->addDragWidget(zoneWidget); | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | void VisualizationTabWidget::insertZone(int index, VisualizationZoneWidget *zoneWidget) |
|
116 | void VisualizationTabWidget::insertZone(int index, VisualizationZoneWidget *zoneWidget) | |
117 | { |
|
117 | { | |
118 | ui->dragDropContainer->insertDragWidget(index, zoneWidget); |
|
118 | ui->dragDropContainer->insertDragWidget(index, zoneWidget); | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
|
121 | QStringList VisualizationTabWidget::availableZoneWidgets() const | |||
|
122 | { | |||
|
123 | QStringList zones; | |||
|
124 | processZones(tabLayout(), | |||
|
125 | [&zones](VisualizationZoneWidget &zoneWidget) { zones << zoneWidget.name(); }); | |||
|
126 | ||||
|
127 | return zones; | |||
|
128 | } | |||
|
129 | ||||
121 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) |
|
130 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) | |
122 | { |
|
131 | { | |
123 | return createZone({variable}, -1); |
|
132 | return createZone({variable}, -1); | |
124 | } |
|
133 | } | |
125 |
|
134 | |||
126 | VisualizationZoneWidget * |
|
135 | VisualizationZoneWidget * | |
127 | VisualizationTabWidget::createZone(const QList<std::shared_ptr<Variable> > &variables, int index) |
|
136 | VisualizationTabWidget::createZone(const QList<std::shared_ptr<Variable> > &variables, int index) | |
128 | { |
|
137 | { | |
129 | auto zoneWidget = createEmptyZone(index); |
|
138 | auto zoneWidget = createEmptyZone(index); | |
130 |
|
139 | |||
131 | // Creates a new graph into the zone |
|
140 | // Creates a new graph into the zone | |
132 | zoneWidget->createGraph(variables, index); |
|
141 | zoneWidget->createGraph(variables, index); | |
133 |
|
142 | |||
134 | return zoneWidget; |
|
143 | return zoneWidget; | |
135 | } |
|
144 | } | |
136 |
|
145 | |||
137 | VisualizationZoneWidget *VisualizationTabWidget::createEmptyZone(int index) |
|
146 | VisualizationZoneWidget *VisualizationTabWidget::createEmptyZone(int index) | |
138 | { |
|
147 | { | |
139 | auto zoneWidget |
|
148 | auto zoneWidget | |
140 | = new VisualizationZoneWidget{defaultZoneName(*ui->dragDropContainer->layout()), this}; |
|
149 | = new VisualizationZoneWidget{defaultZoneName(*ui->dragDropContainer->layout()), this}; | |
141 | this->insertZone(index, zoneWidget); |
|
150 | this->insertZone(index, zoneWidget); | |
142 |
|
151 | |||
143 | return zoneWidget; |
|
152 | return zoneWidget; | |
144 | } |
|
153 | } | |
145 |
|
154 | |||
146 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
155 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) | |
147 | { |
|
156 | { | |
148 | if (visitor) { |
|
157 | if (visitor) { | |
149 | visitor->visitEnter(this); |
|
158 | visitor->visitEnter(this); | |
150 |
|
159 | |||
151 | // Apply visitor to zone children: widgets different from zones are not visited (no action) |
|
160 | // Apply visitor to zone children: widgets different from zones are not visited (no action) | |
152 | processZones(tabLayout(), [visitor](VisualizationZoneWidget &zoneWidget) { |
|
161 | processZones(tabLayout(), [visitor](VisualizationZoneWidget &zoneWidget) { | |
153 | zoneWidget.accept(visitor); |
|
162 | zoneWidget.accept(visitor); | |
154 | }); |
|
163 | }); | |
155 |
|
164 | |||
156 | visitor->visitLeave(this); |
|
165 | visitor->visitLeave(this); | |
157 | } |
|
166 | } | |
158 | else { |
|
167 | else { | |
159 | qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null"); |
|
168 | qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null"); | |
160 | } |
|
169 | } | |
161 | } |
|
170 | } | |
162 |
|
171 | |||
163 | bool VisualizationTabWidget::canDrop(const Variable &variable) const |
|
172 | bool VisualizationTabWidget::canDrop(const Variable &variable) const | |
164 | { |
|
173 | { | |
165 | // A tab can always accomodate a variable |
|
174 | // A tab can always accomodate a variable | |
166 | Q_UNUSED(variable); |
|
175 | Q_UNUSED(variable); | |
167 | return true; |
|
176 | return true; | |
168 | } |
|
177 | } | |
169 |
|
178 | |||
170 | bool VisualizationTabWidget::contains(const Variable &variable) const |
|
179 | bool VisualizationTabWidget::contains(const Variable &variable) const | |
171 | { |
|
180 | { | |
172 | Q_UNUSED(variable); |
|
181 | Q_UNUSED(variable); | |
173 | return false; |
|
182 | return false; | |
174 | } |
|
183 | } | |
175 |
|
184 | |||
176 | QString VisualizationTabWidget::name() const |
|
185 | QString VisualizationTabWidget::name() const | |
177 | { |
|
186 | { | |
178 | return impl->m_Name; |
|
187 | return impl->m_Name; | |
179 | } |
|
188 | } | |
180 |
|
189 | |||
181 | void VisualizationTabWidget::closeEvent(QCloseEvent *event) |
|
190 | void VisualizationTabWidget::closeEvent(QCloseEvent *event) | |
182 | { |
|
191 | { | |
183 | // Closes zones in the tab |
|
192 | // Closes zones in the tab | |
184 | processZones(tabLayout(), [](VisualizationZoneWidget &zoneWidget) { zoneWidget.close(); }); |
|
193 | processZones(tabLayout(), [](VisualizationZoneWidget &zoneWidget) { zoneWidget.close(); }); | |
185 |
|
194 | |||
186 | QWidget::closeEvent(event); |
|
195 | QWidget::closeEvent(event); | |
187 | } |
|
196 | } | |
188 |
|
197 | |||
189 | QLayout &VisualizationTabWidget::tabLayout() const noexcept |
|
198 | QLayout &VisualizationTabWidget::tabLayout() const noexcept | |
190 | { |
|
199 | { | |
191 | return *ui->dragDropContainer->layout(); |
|
200 | return *ui->dragDropContainer->layout(); | |
192 | } |
|
201 | } | |
193 |
|
202 | |||
194 | void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData) |
|
203 | void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData) | |
195 | { |
|
204 | { | |
196 | if (mimeData->hasFormat(MIME_TYPE_GRAPH)) { |
|
205 | if (mimeData->hasFormat(MIME_TYPE_GRAPH)) { | |
197 | impl->dropGraph(index, this); |
|
206 | impl->dropGraph(index, this); | |
198 | } |
|
207 | } | |
199 | else if (mimeData->hasFormat(MIME_TYPE_ZONE)) { |
|
208 | else if (mimeData->hasFormat(MIME_TYPE_ZONE)) { | |
200 | impl->dropZone(index, this); |
|
209 | impl->dropZone(index, this); | |
201 | } |
|
210 | } | |
202 | else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { |
|
211 | else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { | |
203 | auto variables = sqpApp->variableController().variablesForMimeData( |
|
212 | auto variables = sqpApp->variableController().variablesForMimeData( | |
204 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); |
|
213 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); | |
205 | impl->dropVariables(variables, index, this); |
|
214 | impl->dropVariables(variables, index, this); | |
206 | } |
|
215 | } | |
207 | else { |
|
216 | else { | |
208 | qCWarning(LOG_VisualizationZoneWidget()) |
|
217 | qCWarning(LOG_VisualizationZoneWidget()) | |
209 | << tr("VisualizationTabWidget::dropMimeData, unknown MIME data received."); |
|
218 | << tr("VisualizationTabWidget::dropMimeData, unknown MIME data received."); | |
210 | } |
|
219 | } | |
211 | } |
|
220 | } | |
212 |
|
221 | |||
213 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph( |
|
222 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph( | |
214 | int index, VisualizationTabWidget *tabWidget) |
|
223 | int index, VisualizationTabWidget *tabWidget) | |
215 | { |
|
224 | { | |
216 | auto &helper = sqpApp->dragDropGuiController(); |
|
225 | auto &helper = sqpApp->dragDropGuiController(); | |
217 |
|
226 | |||
218 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget()); |
|
227 | auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget()); | |
219 | if (!graphWidget) { |
|
228 | if (!graphWidget) { | |
220 | qCWarning(LOG_VisualizationZoneWidget()) |
|
229 | qCWarning(LOG_VisualizationZoneWidget()) | |
221 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the dropped graph is not " |
|
230 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the dropped graph is not " | |
222 | "found or invalid."); |
|
231 | "found or invalid."); | |
223 | Q_ASSERT(false); |
|
232 | Q_ASSERT(false); | |
224 | return; |
|
233 | return; | |
225 | } |
|
234 | } | |
226 |
|
235 | |||
227 | auto parentDragDropContainer |
|
236 | auto parentDragDropContainer | |
228 | = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget()); |
|
237 | = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget()); | |
229 | if (!parentDragDropContainer) { |
|
238 | if (!parentDragDropContainer) { | |
230 | qCWarning(LOG_VisualizationZoneWidget()) |
|
239 | qCWarning(LOG_VisualizationZoneWidget()) | |
231 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the parent container of " |
|
240 | << tr("VisualizationTabWidget::dropGraph, drop aborted, the parent container of " | |
232 | "the dropped graph is not found."); |
|
241 | "the dropped graph is not found."); | |
233 | Q_ASSERT(false); |
|
242 | Q_ASSERT(false); | |
234 | return; |
|
243 | return; | |
235 | } |
|
244 | } | |
236 |
|
245 | |||
237 | auto nbGraph = parentDragDropContainer->countDragWidget(); |
|
246 | auto nbGraph = parentDragDropContainer->countDragWidget(); | |
238 |
|
247 | |||
239 | const auto &variables = graphWidget->variables(); |
|
248 | const auto &variables = graphWidget->variables(); | |
240 |
|
249 | |||
241 | if (!variables.isEmpty()) { |
|
250 | if (!variables.isEmpty()) { | |
242 | // Abort the requests for the variables (if any) |
|
251 | // Abort the requests for the variables (if any) | |
243 | // Commented, because it's not sure if it's needed or not |
|
252 | // Commented, because it's not sure if it's needed or not | |
244 | // for (const auto& var : variables) |
|
253 | // for (const auto& var : variables) | |
245 | //{ |
|
254 | //{ | |
246 | // sqpApp->variableController().onAbortProgressRequested(var); |
|
255 | // sqpApp->variableController().onAbortProgressRequested(var); | |
247 | //} |
|
256 | //} | |
248 |
|
257 | |||
249 | if (nbGraph == 1) { |
|
258 | if (nbGraph == 1) { | |
250 | // This is the only graph in the previous zone, close the zone |
|
259 | // This is the only graph in the previous zone, close the zone | |
251 | helper.delayedCloseWidget(graphWidget->parentZoneWidget()); |
|
260 | helper.delayedCloseWidget(graphWidget->parentZoneWidget()); | |
252 | } |
|
261 | } | |
253 | else { |
|
262 | else { | |
254 | // Close the graph |
|
263 | // Close the graph | |
255 | helper.delayedCloseWidget(graphWidget); |
|
264 | helper.delayedCloseWidget(graphWidget); | |
256 | } |
|
265 | } | |
257 |
|
266 | |||
258 | auto zoneWidget = tabWidget->createZone(variables, index); |
|
267 | auto zoneWidget = tabWidget->createZone(variables, index); | |
259 | auto firstGraph = zoneWidget->firstGraph(); |
|
268 | auto firstGraph = zoneWidget->firstGraph(); | |
260 | if (firstGraph) { |
|
269 | if (firstGraph) { | |
261 | firstGraph->addSelectionZones(graphWidget->selectionZoneRanges()); |
|
270 | firstGraph->addSelectionZones(graphWidget->selectionZoneRanges()); | |
262 | } |
|
271 | } | |
263 | else { |
|
272 | else { | |
264 | qCWarning(LOG_VisualizationZoneWidget()) |
|
273 | qCWarning(LOG_VisualizationZoneWidget()) | |
265 | << tr("VisualizationTabWidget::dropGraph, no graph added in the widget."); |
|
274 | << tr("VisualizationTabWidget::dropGraph, no graph added in the widget."); | |
266 | Q_ASSERT(false); |
|
275 | Q_ASSERT(false); | |
267 | } |
|
276 | } | |
268 | } |
|
277 | } | |
269 | else { |
|
278 | else { | |
270 | // The graph is empty, create an empty zone and move the graph inside |
|
279 | // The graph is empty, create an empty zone and move the graph inside | |
271 |
|
280 | |||
272 | auto parentZoneWidget = graphWidget->parentZoneWidget(); |
|
281 | auto parentZoneWidget = graphWidget->parentZoneWidget(); | |
273 |
|
282 | |||
274 | parentDragDropContainer->layout()->removeWidget(graphWidget); |
|
283 | parentDragDropContainer->layout()->removeWidget(graphWidget); | |
275 |
|
284 | |||
276 | auto zoneWidget = tabWidget->createEmptyZone(index); |
|
285 | auto zoneWidget = tabWidget->createEmptyZone(index); | |
277 | zoneWidget->addGraph(graphWidget); |
|
286 | zoneWidget->addGraph(graphWidget); | |
278 |
|
287 | |||
279 | // Close the old zone if it was the only graph inside |
|
288 | // Close the old zone if it was the only graph inside | |
280 | if (nbGraph == 1) { |
|
289 | if (nbGraph == 1) { | |
281 | helper.delayedCloseWidget(parentZoneWidget); |
|
290 | helper.delayedCloseWidget(parentZoneWidget); | |
282 | } |
|
291 | } | |
283 | } |
|
292 | } | |
284 | } |
|
293 | } | |
285 |
|
294 | |||
286 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropZone( |
|
295 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropZone( | |
287 | int index, VisualizationTabWidget *tabWidget) |
|
296 | int index, VisualizationTabWidget *tabWidget) | |
288 | { |
|
297 | { | |
289 | auto &helper = sqpApp->dragDropGuiController(); |
|
298 | auto &helper = sqpApp->dragDropGuiController(); | |
290 |
|
299 | |||
291 | auto zoneWidget = qobject_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget()); |
|
300 | auto zoneWidget = qobject_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget()); | |
292 | if (!zoneWidget) { |
|
301 | if (!zoneWidget) { | |
293 | qCWarning(LOG_VisualizationZoneWidget()) |
|
302 | qCWarning(LOG_VisualizationZoneWidget()) | |
294 | << tr("VisualizationTabWidget::dropZone, drop aborted, the dropped zone is not " |
|
303 | << tr("VisualizationTabWidget::dropZone, drop aborted, the dropped zone is not " | |
295 | "found or invalid."); |
|
304 | "found or invalid."); | |
296 | Q_ASSERT(false); |
|
305 | Q_ASSERT(false); | |
297 | return; |
|
306 | return; | |
298 | } |
|
307 | } | |
299 |
|
308 | |||
300 | auto parentDragDropContainer |
|
309 | auto parentDragDropContainer | |
301 | = qobject_cast<VisualizationDragDropContainer *>(zoneWidget->parentWidget()); |
|
310 | = qobject_cast<VisualizationDragDropContainer *>(zoneWidget->parentWidget()); | |
302 | if (!parentDragDropContainer) { |
|
311 | if (!parentDragDropContainer) { | |
303 | qCWarning(LOG_VisualizationZoneWidget()) |
|
312 | qCWarning(LOG_VisualizationZoneWidget()) | |
304 | << tr("VisualizationTabWidget::dropZone, drop aborted, the parent container of " |
|
313 | << tr("VisualizationTabWidget::dropZone, drop aborted, the parent container of " | |
305 | "the dropped zone is not found."); |
|
314 | "the dropped zone is not found."); | |
306 | Q_ASSERT(false); |
|
315 | Q_ASSERT(false); | |
307 | return; |
|
316 | return; | |
308 | } |
|
317 | } | |
309 |
|
318 | |||
310 | // Simple move of the zone, no variable operation associated |
|
319 | // Simple move of the zone, no variable operation associated | |
311 | parentDragDropContainer->layout()->removeWidget(zoneWidget); |
|
320 | parentDragDropContainer->layout()->removeWidget(zoneWidget); | |
312 | tabWidget->ui->dragDropContainer->insertDragWidget(index, zoneWidget); |
|
321 | tabWidget->ui->dragDropContainer->insertDragWidget(index, zoneWidget); | |
313 | } |
|
322 | } | |
314 |
|
323 | |||
315 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropVariables( |
|
324 | void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropVariables( | |
316 | const QList<std::shared_ptr<Variable> > &variables, int index, |
|
325 | const QList<std::shared_ptr<Variable> > &variables, int index, | |
317 | VisualizationTabWidget *tabWidget) |
|
326 | VisualizationTabWidget *tabWidget) | |
318 | { |
|
327 | { | |
319 | // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and |
|
328 | // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and | |
320 | // compatible variable here |
|
329 | // compatible variable here | |
321 | if (variables.count() > 1) { |
|
330 | if (variables.count() > 1) { | |
322 | qCWarning(LOG_VisualizationZoneWidget()) |
|
331 | qCWarning(LOG_VisualizationZoneWidget()) | |
323 | << tr("VisualizationTabWidget::dropVariables, dropping multiple variables, operation " |
|
332 | << tr("VisualizationTabWidget::dropVariables, dropping multiple variables, operation " | |
324 | "aborted."); |
|
333 | "aborted."); | |
325 | return; |
|
334 | return; | |
326 | } |
|
335 | } | |
327 |
|
336 | |||
328 | tabWidget->createZone(variables, index); |
|
337 | tabWidget->createZone(variables, index); | |
329 | } |
|
338 | } |
@@ -1,215 +1,224 | |||||
1 | #include "Visualization/VisualizationWidget.h" |
|
1 | #include "Visualization/VisualizationWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "Visualization/VisualizationActionManager.h" |
|
3 | #include "Visualization/VisualizationActionManager.h" | |
4 | #include "Visualization/VisualizationGraphWidget.h" |
|
4 | #include "Visualization/VisualizationGraphWidget.h" | |
5 | #include "Visualization/VisualizationSelectionZoneItem.h" |
|
5 | #include "Visualization/VisualizationSelectionZoneItem.h" | |
6 | #include "Visualization/VisualizationSelectionZoneManager.h" |
|
6 | #include "Visualization/VisualizationSelectionZoneManager.h" | |
7 | #include "Visualization/VisualizationTabWidget.h" |
|
7 | #include "Visualization/VisualizationTabWidget.h" | |
8 | #include "Visualization/VisualizationZoneWidget.h" |
|
8 | #include "Visualization/VisualizationZoneWidget.h" | |
9 | #include "Visualization/operations/FindVariableOperation.h" |
|
9 | #include "Visualization/operations/FindVariableOperation.h" | |
10 | #include "Visualization/operations/GenerateVariableMenuOperation.h" |
|
10 | #include "Visualization/operations/GenerateVariableMenuOperation.h" | |
11 | #include "Visualization/operations/RemoveVariableOperation.h" |
|
11 | #include "Visualization/operations/RemoveVariableOperation.h" | |
12 | #include "Visualization/operations/RescaleAxeOperation.h" |
|
12 | #include "Visualization/operations/RescaleAxeOperation.h" | |
13 | #include "Visualization/qcustomplot.h" |
|
13 | #include "Visualization/qcustomplot.h" | |
14 |
|
14 | |||
15 | #include "ui_VisualizationWidget.h" |
|
15 | #include "ui_VisualizationWidget.h" | |
16 |
|
16 | |||
17 | #include "DragAndDrop/DragDropGuiController.h" |
|
17 | #include "DragAndDrop/DragDropGuiController.h" | |
18 | #include "SqpApplication.h" |
|
18 | #include "SqpApplication.h" | |
19 |
|
19 | |||
20 | #include <QToolButton> |
|
20 | #include <QToolButton> | |
21 |
|
21 | |||
22 | #include <memory> |
|
22 | #include <memory> | |
23 |
|
23 | |||
24 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") |
|
24 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") | |
25 |
|
25 | |||
26 | struct VisualizationWidget::VisualizationWidgetPrivate { |
|
26 | struct VisualizationWidget::VisualizationWidgetPrivate { | |
27 | std::unique_ptr<VisualizationSelectionZoneManager> m_ZoneSelectionManager = nullptr; |
|
27 | std::unique_ptr<VisualizationSelectionZoneManager> m_ZoneSelectionManager = nullptr; | |
28 | VisualizationActionManager m_ActionManager; |
|
28 | VisualizationActionManager m_ActionManager; | |
29 |
|
29 | |||
30 | VisualizationWidgetPrivate() |
|
30 | VisualizationWidgetPrivate() | |
31 | : m_ZoneSelectionManager(std::make_unique<VisualizationSelectionZoneManager>()) |
|
31 | : m_ZoneSelectionManager(std::make_unique<VisualizationSelectionZoneManager>()) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 | }; |
|
34 | }; | |
35 |
|
35 | |||
36 | VisualizationWidget::VisualizationWidget(QWidget *parent) |
|
36 | VisualizationWidget::VisualizationWidget(QWidget *parent) | |
37 | : QWidget{parent}, |
|
37 | : QWidget{parent}, | |
38 | ui{new Ui::VisualizationWidget}, |
|
38 | ui{new Ui::VisualizationWidget}, | |
39 | impl{spimpl::make_unique_impl<VisualizationWidgetPrivate>()} |
|
39 | impl{spimpl::make_unique_impl<VisualizationWidgetPrivate>()} | |
40 | { |
|
40 | { | |
41 | ui->setupUi(this); |
|
41 | ui->setupUi(this); | |
42 |
|
42 | |||
43 | auto addTabViewButton = new QToolButton{ui->tabWidget}; |
|
43 | auto addTabViewButton = new QToolButton{ui->tabWidget}; | |
44 | addTabViewButton->setText(tr("Add View")); |
|
44 | addTabViewButton->setText(tr("Add View")); | |
45 | addTabViewButton->setCursor(Qt::ArrowCursor); |
|
45 | addTabViewButton->setCursor(Qt::ArrowCursor); | |
46 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); |
|
46 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); | |
47 |
|
47 | |||
48 | auto enableMinimumCornerWidgetSize = [this](bool enable) { |
|
48 | auto enableMinimumCornerWidgetSize = [this](bool enable) { | |
49 |
|
49 | |||
50 | auto tabViewCornerWidget = ui->tabWidget->cornerWidget(); |
|
50 | auto tabViewCornerWidget = ui->tabWidget->cornerWidget(); | |
51 | auto width = enable ? tabViewCornerWidget->width() : 0; |
|
51 | auto width = enable ? tabViewCornerWidget->width() : 0; | |
52 | auto height = enable ? tabViewCornerWidget->height() : 0; |
|
52 | auto height = enable ? tabViewCornerWidget->height() : 0; | |
53 | tabViewCornerWidget->setMinimumHeight(height); |
|
53 | tabViewCornerWidget->setMinimumHeight(height); | |
54 | tabViewCornerWidget->setMinimumWidth(width); |
|
54 | tabViewCornerWidget->setMinimumWidth(width); | |
55 | ui->tabWidget->setMinimumHeight(height); |
|
55 | ui->tabWidget->setMinimumHeight(height); | |
56 | ui->tabWidget->setMinimumWidth(width); |
|
56 | ui->tabWidget->setMinimumWidth(width); | |
57 | }; |
|
57 | }; | |
58 |
|
58 | |||
59 | auto addTabView = [this, enableMinimumCornerWidgetSize]() { |
|
59 | auto addTabView = [this, enableMinimumCornerWidgetSize]() { | |
60 | auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1), |
|
60 | auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1), | |
61 | ui->tabWidget}; |
|
61 | ui->tabWidget}; | |
62 | auto index = ui->tabWidget->addTab(widget, widget->name()); |
|
62 | auto index = ui->tabWidget->addTab(widget, widget->name()); | |
63 | if (ui->tabWidget->count() > 0) { |
|
63 | if (ui->tabWidget->count() > 0) { | |
64 | enableMinimumCornerWidgetSize(false); |
|
64 | enableMinimumCornerWidgetSize(false); | |
65 | } |
|
65 | } | |
66 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); |
|
66 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) { |
|
69 | auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) { | |
70 | if (ui->tabWidget->count() == 1) { |
|
70 | if (ui->tabWidget->count() == 1) { | |
71 | enableMinimumCornerWidgetSize(true); |
|
71 | enableMinimumCornerWidgetSize(true); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | // Removes widget from tab and closes it |
|
74 | // Removes widget from tab and closes it | |
75 | auto widget = ui->tabWidget->widget(index); |
|
75 | auto widget = ui->tabWidget->widget(index); | |
76 | ui->tabWidget->removeTab(index); |
|
76 | ui->tabWidget->removeTab(index); | |
77 | if (widget) { |
|
77 | if (widget) { | |
78 | widget->close(); |
|
78 | widget->close(); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); |
|
81 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); | |
82 |
|
82 | |||
83 | }; |
|
83 | }; | |
84 |
|
84 | |||
85 | ui->tabWidget->setTabsClosable(true); |
|
85 | ui->tabWidget->setTabsClosable(true); | |
86 |
|
86 | |||
87 | connect(addTabViewButton, &QToolButton::clicked, addTabView); |
|
87 | connect(addTabViewButton, &QToolButton::clicked, addTabView); | |
88 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); |
|
88 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); | |
89 |
|
89 | |||
90 | sqpApp->dragDropGuiController().addDragDropTabBar(ui->tabWidget->tabBar()); |
|
90 | sqpApp->dragDropGuiController().addDragDropTabBar(ui->tabWidget->tabBar()); | |
91 |
|
91 | |||
92 | // Actions |
|
92 | // Actions | |
93 | impl->m_ActionManager.installSelectionZoneActions(); |
|
93 | impl->m_ActionManager.installSelectionZoneActions(); | |
94 |
|
94 | |||
95 | auto removeZoneAction = new QAction("Remove selected zone(s)"); |
|
95 | auto removeZoneAction = new QAction("Remove selected zone(s)"); | |
96 | removeZoneAction->setShortcut(QKeySequence::Delete); |
|
96 | removeZoneAction->setShortcut(QKeySequence::Delete); | |
97 | connect(removeZoneAction, &QAction::triggered, [this]() { |
|
97 | connect(removeZoneAction, &QAction::triggered, [this]() { | |
98 | auto selection = impl->m_ZoneSelectionManager->selectedItems(); |
|
98 | auto selection = impl->m_ZoneSelectionManager->selectedItems(); | |
99 | for (auto selectionZone : selection) { |
|
99 | for (auto selectionZone : selection) { | |
100 | if (auto graph = selectionZone->parentGraphWidget()) { |
|
100 | if (auto graph = selectionZone->parentGraphWidget()) { | |
101 | graph->removeSelectionZone(selectionZone); |
|
101 | graph->removeSelectionZone(selectionZone); | |
102 | } |
|
102 | } | |
103 | } |
|
103 | } | |
104 | }); |
|
104 | }); | |
105 | addAction(removeZoneAction); |
|
105 | addAction(removeZoneAction); | |
106 |
|
106 | |||
107 | // Adds default tab |
|
107 | // Adds default tab | |
108 | addTabView(); |
|
108 | addTabView(); | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | VisualizationWidget::~VisualizationWidget() |
|
111 | VisualizationWidget::~VisualizationWidget() | |
112 | { |
|
112 | { | |
113 | sqpApp->dragDropGuiController().removeDragDropTabBar(ui->tabWidget->tabBar()); |
|
113 | sqpApp->dragDropGuiController().removeDragDropTabBar(ui->tabWidget->tabBar()); | |
114 | delete ui; |
|
114 | delete ui; | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | VisualizationSelectionZoneManager &VisualizationWidget::selectionZoneManager() const |
|
117 | VisualizationSelectionZoneManager &VisualizationWidget::selectionZoneManager() const | |
118 | { |
|
118 | { | |
119 | return *impl->m_ZoneSelectionManager.get(); |
|
119 | return *impl->m_ZoneSelectionManager.get(); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
|
122 | VisualizationTabWidget *VisualizationWidget::currentTabWidget() const | |||
|
123 | { | |||
|
124 | if (auto tab = qobject_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) { | |||
|
125 | return tab; | |||
|
126 | } | |||
|
127 | ||||
|
128 | return nullptr; | |||
|
129 | } | |||
|
130 | ||||
122 | void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
131 | void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor) | |
123 | { |
|
132 | { | |
124 | if (visitor) { |
|
133 | if (visitor) { | |
125 | visitor->visitEnter(this); |
|
134 | visitor->visitEnter(this); | |
126 |
|
135 | |||
127 | // Apply visitor for tab children |
|
136 | // Apply visitor for tab children | |
128 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { |
|
137 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { | |
129 | // Widgets different from tabs are not visited (no action) |
|
138 | // Widgets different from tabs are not visited (no action) | |
130 | if (auto visualizationTabWidget |
|
139 | if (auto visualizationTabWidget | |
131 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { |
|
140 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { | |
132 | visualizationTabWidget->accept(visitor); |
|
141 | visualizationTabWidget->accept(visitor); | |
133 | } |
|
142 | } | |
134 | } |
|
143 | } | |
135 |
|
144 | |||
136 | visitor->visitLeave(this); |
|
145 | visitor->visitLeave(this); | |
137 | } |
|
146 | } | |
138 | else { |
|
147 | else { | |
139 | qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null"); |
|
148 | qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null"); | |
140 | } |
|
149 | } | |
141 | } |
|
150 | } | |
142 |
|
151 | |||
143 | bool VisualizationWidget::canDrop(const Variable &variable) const |
|
152 | bool VisualizationWidget::canDrop(const Variable &variable) const | |
144 | { |
|
153 | { | |
145 | // The main widget can never accomodate a variable |
|
154 | // The main widget can never accomodate a variable | |
146 | Q_UNUSED(variable); |
|
155 | Q_UNUSED(variable); | |
147 | return false; |
|
156 | return false; | |
148 | } |
|
157 | } | |
149 |
|
158 | |||
150 | bool VisualizationWidget::contains(const Variable &variable) const |
|
159 | bool VisualizationWidget::contains(const Variable &variable) const | |
151 | { |
|
160 | { | |
152 | Q_UNUSED(variable); |
|
161 | Q_UNUSED(variable); | |
153 | return false; |
|
162 | return false; | |
154 | } |
|
163 | } | |
155 |
|
164 | |||
156 | QString VisualizationWidget::name() const |
|
165 | QString VisualizationWidget::name() const | |
157 | { |
|
166 | { | |
158 | return QStringLiteral("MainView"); |
|
167 | return QStringLiteral("MainView"); | |
159 | } |
|
168 | } | |
160 |
|
169 | |||
161 | void VisualizationWidget::attachVariableMenu( |
|
170 | void VisualizationWidget::attachVariableMenu( | |
162 | QMenu *menu, const QVector<std::shared_ptr<Variable> > &variables) noexcept |
|
171 | QMenu *menu, const QVector<std::shared_ptr<Variable> > &variables) noexcept | |
163 | { |
|
172 | { | |
164 | // Menu is generated only if there is a single variable |
|
173 | // Menu is generated only if there is a single variable | |
165 | if (variables.size() == 1) { |
|
174 | if (variables.size() == 1) { | |
166 | if (auto variable = variables.first()) { |
|
175 | if (auto variable = variables.first()) { | |
167 | // Gets the containers of the variable |
|
176 | // Gets the containers of the variable | |
168 | FindVariableOperation findVariableOperation{variable}; |
|
177 | FindVariableOperation findVariableOperation{variable}; | |
169 | accept(&findVariableOperation); |
|
178 | accept(&findVariableOperation); | |
170 | auto variableContainers = findVariableOperation.result(); |
|
179 | auto variableContainers = findVariableOperation.result(); | |
171 |
|
180 | |||
172 | // Generates the actions that make it possible to visualize the variable |
|
181 | // Generates the actions that make it possible to visualize the variable | |
173 | GenerateVariableMenuOperation generateVariableMenuOperation{ |
|
182 | GenerateVariableMenuOperation generateVariableMenuOperation{ | |
174 | menu, variable, std::move(variableContainers)}; |
|
183 | menu, variable, std::move(variableContainers)}; | |
175 | accept(&generateVariableMenuOperation); |
|
184 | accept(&generateVariableMenuOperation); | |
176 | } |
|
185 | } | |
177 | else { |
|
186 | else { | |
178 | qCCritical(LOG_VisualizationWidget()) << tr( |
|
187 | qCCritical(LOG_VisualizationWidget()) << tr( | |
179 | "Can't generate the menu relative to the visualization: the variable is null"); |
|
188 | "Can't generate the menu relative to the visualization: the variable is null"); | |
180 | } |
|
189 | } | |
181 | } |
|
190 | } | |
182 | else { |
|
191 | else { | |
183 | qCDebug(LOG_VisualizationWidget()) |
|
192 | qCDebug(LOG_VisualizationWidget()) | |
184 | << tr("No generation of the menu related to the visualization: several variables are " |
|
193 | << tr("No generation of the menu related to the visualization: several variables are " | |
185 | "selected"); |
|
194 | "selected"); | |
186 | } |
|
195 | } | |
187 | } |
|
196 | } | |
188 |
|
197 | |||
189 | void VisualizationWidget::onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept |
|
198 | void VisualizationWidget::onVariableAboutToBeDeleted(std::shared_ptr<Variable> variable) noexcept | |
190 | { |
|
199 | { | |
191 | // Calls the operation of removing all references to the variable in the visualization |
|
200 | // Calls the operation of removing all references to the variable in the visualization | |
192 | auto removeVariableOperation = RemoveVariableOperation{variable}; |
|
201 | auto removeVariableOperation = RemoveVariableOperation{variable}; | |
193 | accept(&removeVariableOperation); |
|
202 | accept(&removeVariableOperation); | |
194 | } |
|
203 | } | |
195 |
|
204 | |||
196 | void VisualizationWidget::onRangeChanged(std::shared_ptr<Variable> variable, |
|
205 | void VisualizationWidget::onRangeChanged(std::shared_ptr<Variable> variable, | |
197 | const SqpRange &range) noexcept |
|
206 | const SqpRange &range) noexcept | |
198 | { |
|
207 | { | |
199 | // Calls the operation of rescaling all graph that contrains variable in the visualization |
|
208 | // Calls the operation of rescaling all graph that contrains variable in the visualization | |
200 | auto rescaleVariableOperation = RescaleAxeOperation{variable, range}; |
|
209 | auto rescaleVariableOperation = RescaleAxeOperation{variable, range}; | |
201 | accept(&rescaleVariableOperation); |
|
210 | accept(&rescaleVariableOperation); | |
202 | } |
|
211 | } | |
203 |
|
212 | |||
204 | void VisualizationWidget::closeEvent(QCloseEvent *event) |
|
213 | void VisualizationWidget::closeEvent(QCloseEvent *event) | |
205 | { |
|
214 | { | |
206 | // Closes tabs in the widget |
|
215 | // Closes tabs in the widget | |
207 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { |
|
216 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { | |
208 | if (auto visualizationTabWidget |
|
217 | if (auto visualizationTabWidget | |
209 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { |
|
218 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { | |
210 | visualizationTabWidget->close(); |
|
219 | visualizationTabWidget->close(); | |
211 | } |
|
220 | } | |
212 | } |
|
221 | } | |
213 |
|
222 | |||
214 | QWidget::closeEvent(event); |
|
223 | QWidget::closeEvent(event); | |
215 | } |
|
224 | } |
General Comments 0
You need to be logged in to leave comments.
Login now