##// END OF EJS Templates
Merge branch 'feature/VariableMenu2' into develop
Alexandre Leroux -
r233:aa2508ab83a4 merge
parent child
Show More
@@ -1,248 +1,254
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 <DataSource/DataSourceController.h>
25 #include <DataSource/DataSourceController.h>
26 #include <DataSource/DataSourceWidget.h>
26 #include <DataSource/DataSourceWidget.h>
27 #include <SidePane/SqpSidePane.h>
27 #include <SidePane/SqpSidePane.h>
28 #include <SqpApplication.h>
28 #include <SqpApplication.h>
29 #include <Time/TimeController.h>
29 #include <Time/TimeController.h>
30 #include <TimeWidget/TimeWidget.h>
30 #include <TimeWidget/TimeWidget.h>
31 #include <Variable/Variable.h>
31 #include <Variable/Variable.h>
32 #include <Visualization/VisualizationController.h>
32 #include <Visualization/VisualizationController.h>
33
33
34 #include <QAction>
34 #include <QAction>
35 #include <QDate>
35 #include <QDate>
36 #include <QDateTime>
36 #include <QDateTime>
37 #include <QDir>
37 #include <QDir>
38 #include <QFileDialog>
38 #include <QFileDialog>
39 #include <QToolBar>
39 #include <QToolBar>
40 #include <QToolButton>
40 #include <QToolButton>
41 #include <memory.h>
41 #include <memory.h>
42
42
43 //#include <omp.h>
43 //#include <omp.h>
44 //#include <network/filedownloader.h>
44 //#include <network/filedownloader.h>
45 //#include <qlopdatabase.h>
45 //#include <qlopdatabase.h>
46 //#include <qlopsettings.h>
46 //#include <qlopsettings.h>
47 //#include <qlopgui.h>
47 //#include <qlopgui.h>
48 //#include <spacedata.h>
48 //#include <spacedata.h>
49 //#include "qlopcore.h"
49 //#include "qlopcore.h"
50 //#include "qlopcodecmanager.h"
50 //#include "qlopcodecmanager.h"
51 //#include "cdfcodec.h"
51 //#include "cdfcodec.h"
52 //#include "amdatxtcodec.h"
52 //#include "amdatxtcodec.h"
53 //#include <qlopplotmanager.h>
53 //#include <qlopplotmanager.h>
54
54
55 #include "iostream"
55 #include "iostream"
56
56
57 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
57 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
58
58
59 namespace {
59 namespace {
60 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
60 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
61 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
61 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
62 const auto VIEWPLITTERINDEX = 2;
62 const auto VIEWPLITTERINDEX = 2;
63 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
63 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
64 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
64 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
65 }
65 }
66
66
67 class MainWindow::MainWindowPrivate {
67 class MainWindow::MainWindowPrivate {
68 public:
68 public:
69 QSize m_LastOpenLeftInspectorSize;
69 QSize m_LastOpenLeftInspectorSize;
70 QSize m_LastOpenRightInspectorSize;
70 QSize m_LastOpenRightInspectorSize;
71 };
71 };
72
72
73 MainWindow::MainWindow(QWidget *parent)
73 MainWindow::MainWindow(QWidget *parent)
74 : QMainWindow{parent},
74 : QMainWindow{parent},
75 m_Ui{new Ui::MainWindow},
75 m_Ui{new Ui::MainWindow},
76 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
76 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
77 {
77 {
78 m_Ui->setupUi(this);
78 m_Ui->setupUi(this);
79
79
80 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
80 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
81 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
81 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
82
82
83
83
84 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
84 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
85 auto openLeftInspectorAction = new QAction{QIcon{
85 auto openLeftInspectorAction = new QAction{QIcon{
86 ":/icones/previous.png",
86 ":/icones/previous.png",
87 },
87 },
88 tr("Show/hide the left inspector"), this};
88 tr("Show/hide the left inspector"), this};
89
89
90
90
91 auto spacerLeftTop = new QWidget{};
91 auto spacerLeftTop = new QWidget{};
92 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
92 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93
93
94 auto spacerLeftBottom = new QWidget{};
94 auto spacerLeftBottom = new QWidget{};
95 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
95 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
96
96
97 leftSidePane->addWidget(spacerLeftTop);
97 leftSidePane->addWidget(spacerLeftTop);
98 leftSidePane->addAction(openLeftInspectorAction);
98 leftSidePane->addAction(openLeftInspectorAction);
99 leftSidePane->addWidget(spacerLeftBottom);
99 leftSidePane->addWidget(spacerLeftBottom);
100
100
101
101
102 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
102 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
103 auto openRightInspectorAction = new QAction{QIcon{
103 auto openRightInspectorAction = new QAction{QIcon{
104 ":/icones/next.png",
104 ":/icones/next.png",
105 },
105 },
106 tr("Show/hide the right inspector"), this};
106 tr("Show/hide the right inspector"), this};
107
107
108 auto spacerRightTop = new QWidget{};
108 auto spacerRightTop = new QWidget{};
109 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
109 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110
110
111 auto spacerRightBottom = new QWidget{};
111 auto spacerRightBottom = new QWidget{};
112 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
112 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
113
113
114 rightSidePane->addWidget(spacerRightTop);
114 rightSidePane->addWidget(spacerRightTop);
115 rightSidePane->addAction(openRightInspectorAction);
115 rightSidePane->addAction(openRightInspectorAction);
116 rightSidePane->addWidget(spacerRightBottom);
116 rightSidePane->addWidget(spacerRightBottom);
117
117
118 openLeftInspectorAction->setCheckable(true);
118 openLeftInspectorAction->setCheckable(true);
119 openRightInspectorAction->setCheckable(true);
119 openRightInspectorAction->setCheckable(true);
120
120
121 auto openInspector = [this](bool checked, bool right, auto action) {
121 auto openInspector = [this](bool checked, bool right, auto action) {
122
122
123 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
123 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
124
124
125 auto &lastInspectorSize
125 auto &lastInspectorSize
126 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
126 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
127
127
128 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
128 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
129 : m_Ui->leftMainInspectorWidget->size();
129 : m_Ui->leftMainInspectorWidget->size();
130
130
131 // Update of the last opened geometry
131 // Update of the last opened geometry
132 if (checked) {
132 if (checked) {
133 lastInspectorSize = nextInspectorSize;
133 lastInspectorSize = nextInspectorSize;
134 }
134 }
135
135
136 auto startSize = lastInspectorSize;
136 auto startSize = lastInspectorSize;
137 auto endSize = startSize;
137 auto endSize = startSize;
138 endSize.setWidth(0);
138 endSize.setWidth(0);
139
139
140 auto splitterInspectorIndex
140 auto splitterInspectorIndex
141 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
141 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
142
142
143 auto currentSizes = m_Ui->splitter->sizes();
143 auto currentSizes = m_Ui->splitter->sizes();
144 if (checked) {
144 if (checked) {
145 // adjust sizes individually here, e.g.
145 // adjust sizes individually here, e.g.
146 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
146 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
147 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
147 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
148 m_Ui->splitter->setSizes(currentSizes);
148 m_Ui->splitter->setSizes(currentSizes);
149 }
149 }
150 else {
150 else {
151 // adjust sizes individually here, e.g.
151 // adjust sizes individually here, e.g.
152 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
152 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
153 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
153 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
154 m_Ui->splitter->setSizes(currentSizes);
154 m_Ui->splitter->setSizes(currentSizes);
155 }
155 }
156
156
157 };
157 };
158
158
159
159
160 connect(openLeftInspectorAction, &QAction::triggered,
160 connect(openLeftInspectorAction, &QAction::triggered,
161 [openInspector, openLeftInspectorAction](bool checked) {
161 [openInspector, openLeftInspectorAction](bool checked) {
162 openInspector(checked, false, openLeftInspectorAction);
162 openInspector(checked, false, openLeftInspectorAction);
163 });
163 });
164 connect(openRightInspectorAction, &QAction::triggered,
164 connect(openRightInspectorAction, &QAction::triggered,
165 [openInspector, openRightInspectorAction](bool checked) {
165 [openInspector, openRightInspectorAction](bool checked) {
166 openInspector(checked, true, openRightInspectorAction);
166 openInspector(checked, true, openRightInspectorAction);
167 });
167 });
168
168
169 this->menuBar()->addAction(tr("File"));
169 this->menuBar()->addAction(tr("File"));
170 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
170 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
171
171
172 auto timeWidget = new TimeWidget{};
172 auto timeWidget = new TimeWidget{};
173 mainToolBar->addWidget(timeWidget);
173 mainToolBar->addWidget(timeWidget);
174
174
175 // Widgets / controllers connections
175 // Widgets / controllers connections
176
176
177 // DataSource
177 // DataSource
178 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
178 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
179 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
179 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
180
180
181 // Time
181 // Time
182 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
182 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 SLOT(onTimeToUpdate(SqpDateTime)));
183 SLOT(onTimeToUpdate(SqpDateTime)));
184
184
185 // Variable
185 // Widgets / widgets connections
186 qRegisterMetaType<std::shared_ptr<Variable> >();
186 qRegisterMetaType<std::shared_ptr<Variable> >();
187 connect(&sqpApp->visualizationController(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
187
188 m_Ui->view, SLOT(displayVariable(std::shared_ptr<Variable>)));
188 // For the following connections, we use DirectConnection to allow each widget that can
189 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
190 // The order of connections is also important, since it determines the order in which each
191 // widget will attach its menu
192 connect(m_Ui->variableInspectorWidget,
193 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, std::shared_ptr<Variable>)), m_Ui->view,
194 SLOT(attachVariableMenu(QMenu *, std::shared_ptr<Variable>)), Qt::DirectConnection);
189
195
190 /* QLopGUI::registerMenuBar(menuBar());
196 /* QLopGUI::registerMenuBar(menuBar());
191 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
197 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
192 this->m_progressWidget = new QWidget();
198 this->m_progressWidget = new QWidget();
193 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
199 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
194 this->m_progressWidget->setLayout(this->m_progressLayout);
200 this->m_progressWidget->setLayout(this->m_progressLayout);
195 this->m_progressWidget->setWindowModality(Qt::WindowModal);
201 this->m_progressWidget->setWindowModality(Qt::WindowModal);
196 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
202 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
197 for(int i=0;i<OMP_THREADS;i++)
203 for(int i=0;i<OMP_THREADS;i++)
198 {
204 {
199 this->m_progress.append(new QProgressBar(this->m_progressWidget));
205 this->m_progress.append(new QProgressBar(this->m_progressWidget));
200 this->m_progress.last()->setMinimum(0);
206 this->m_progress.last()->setMinimum(0);
201 this->m_progress.last()->setMaximum(100);
207 this->m_progress.last()->setMaximum(100);
202 this->m_progressLayout->addWidget(this->m_progress.last());
208 this->m_progressLayout->addWidget(this->m_progress.last());
203 this->m_progressWidget->hide();
209 this->m_progressWidget->hide();
204 this->m_progressThreadIds[i] = -1;
210 this->m_progressThreadIds[i] = -1;
205 }
211 }
206 this->m_progressWidget->setWindowTitle("Loading File");
212 this->m_progressWidget->setWindowTitle("Loading File");
207 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
213 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
208 << QLopCore::self()
214 << QLopCore::self()
209 << QLopPlotManager::self()
215 << QLopPlotManager::self()
210 << QLopCodecManager::self()
216 << QLopCodecManager::self()
211 << FileDownloader::self()
217 << FileDownloader::self()
212 << QLopDataBase::self()
218 << QLopDataBase::self()
213 << SpaceData::self();
219 << SpaceData::self();
214
220
215 CDFCodec::registerToManager();
221 CDFCodec::registerToManager();
216 AMDATXTCodec::registerToManager();
222 AMDATXTCodec::registerToManager();
217
223
218
224
219 for(int i=0;i<ServicesToLoad.count();i++)
225 for(int i=0;i<ServicesToLoad.count();i++)
220 {
226 {
221 qDebug()<<ServicesToLoad.at(i)->serviceName();
227 qDebug()<<ServicesToLoad.at(i)->serviceName();
222 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
228 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
223 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
229 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
224 if(wdgt)
230 if(wdgt)
225 {
231 {
226 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
232 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
227 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
233 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
228 }
234 }
229 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
235 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
230 }*/
236 }*/
231 }
237 }
232
238
233 MainWindow::~MainWindow()
239 MainWindow::~MainWindow()
234 {
240 {
235 }
241 }
236
242
237
243
238 void MainWindow::changeEvent(QEvent *e)
244 void MainWindow::changeEvent(QEvent *e)
239 {
245 {
240 QMainWindow::changeEvent(e);
246 QMainWindow::changeEvent(e);
241 switch (e->type()) {
247 switch (e->type()) {
242 case QEvent::LanguageChange:
248 case QEvent::LanguageChange:
243 m_Ui->retranslateUi(this);
249 m_Ui->retranslateUi(this);
244 break;
250 break;
245 default:
251 default:
246 break;
252 break;
247 }
253 }
248 }
254 }
@@ -1,49 +1,51
1 #ifndef SCIQLOP_VARIABLEMODEL_H
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
3
4
4
5 #include <Data/SqpDateTime.h>
5 #include <Data/SqpDateTime.h>
6
6
7 #include <QAbstractTableModel>
7 #include <QAbstractTableModel>
8 #include <QLoggingCategory>
8 #include <QLoggingCategory>
9
9
10 #include <Common/spimpl.h>
10 #include <Common/spimpl.h>
11
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
13
13
14 class IDataSeries;
14 class IDataSeries;
15 class Variable;
15 class Variable;
16
16
17 /**
17 /**
18 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
18 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
19 */
19 */
20 class VariableModel : public QAbstractTableModel {
20 class VariableModel : public QAbstractTableModel {
21 public:
21 public:
22 explicit VariableModel(QObject *parent = nullptr);
22 explicit VariableModel(QObject *parent = nullptr);
23
23
24 /**
24 /**
25 * Creates a new variable in the model
25 * Creates a new variable in the model
26 * @param name the name of the new variable
26 * @param name the name of the new variable
27 * @param dateTime the dateTime of the new variable
27 * @param dateTime the dateTime of the new variable
28 * @param defaultDataSeries the default data of the new variable
28 * @param defaultDataSeries the default data of the new variable
29 * @return the pointer to the new variable
29 * @return the pointer to the new variable
30 */
30 */
31 std::shared_ptr<Variable>
31 std::shared_ptr<Variable>
32 createVariable(const QString &name, const SqpDateTime &dateTime,
32 createVariable(const QString &name, const SqpDateTime &dateTime,
33 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
33 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
34
34
35 std::shared_ptr<Variable> variable(int index) const;
36
35 // /////////////////////////// //
37 // /////////////////////////// //
36 // QAbstractTableModel methods //
38 // QAbstractTableModel methods //
37 // /////////////////////////// //
39 // /////////////////////////// //
38 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
40 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
39 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
41 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
40 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
42 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
41 virtual QVariant headerData(int section, Qt::Orientation orientation,
43 virtual QVariant headerData(int section, Qt::Orientation orientation,
42 int role = Qt::DisplayRole) const override;
44 int role = Qt::DisplayRole) const override;
43
45
44 private:
46 private:
45 class VariableModelPrivate;
47 class VariableModelPrivate;
46 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
48 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
47 };
49 };
48
50
49 #endif // SCIQLOP_VARIABLEMODEL_H
51 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -1,120 +1,125
1 #include <Variable/Variable.h>
1 #include <Variable/Variable.h>
2 #include <Variable/VariableModel.h>
2 #include <Variable/VariableModel.h>
3
3
4 #include <Data/IDataSeries.h>
4 #include <Data/IDataSeries.h>
5
5
6 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
7
7
8 namespace {
8 namespace {
9
9
10 // Column indexes
10 // Column indexes
11 const auto NAME_COLUMN = 0;
11 const auto NAME_COLUMN = 0;
12 const auto UNIT_COLUMN = 1;
12 const auto UNIT_COLUMN = 1;
13 const auto MISSION_COLUMN = 2;
13 const auto MISSION_COLUMN = 2;
14 const auto NB_COLUMNS = 3;
14 const auto NB_COLUMNS = 3;
15
15
16 } // namespace
16 } // namespace
17
17
18 struct VariableModel::VariableModelPrivate {
18 struct VariableModel::VariableModelPrivate {
19 /// Variables created in SciQlop
19 /// Variables created in SciQlop
20 std::vector<std::shared_ptr<Variable> > m_Variables;
20 std::vector<std::shared_ptr<Variable> > m_Variables;
21 };
21 };
22
22
23 VariableModel::VariableModel(QObject *parent)
23 VariableModel::VariableModel(QObject *parent)
24 : QAbstractTableModel{parent}, impl{spimpl::make_unique_impl<VariableModelPrivate>()}
24 : QAbstractTableModel{parent}, impl{spimpl::make_unique_impl<VariableModelPrivate>()}
25 {
25 {
26 }
26 }
27
27
28 std::shared_ptr<Variable>
28 std::shared_ptr<Variable>
29 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
29 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
30 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept
31 {
31 {
32 auto insertIndex = rowCount();
32 auto insertIndex = rowCount();
33 beginInsertRows({}, insertIndex, insertIndex);
33 beginInsertRows({}, insertIndex, insertIndex);
34
34
35 /// @todo For the moment, the other data of the variable is initialized with default values
35 /// @todo For the moment, the other data of the variable is initialized with default values
36 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
36 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
37 QStringLiteral("mission"), dateTime);
37 QStringLiteral("mission"), dateTime);
38 variable->setDataSeries(std::move(defaultDataSeries));
38 variable->setDataSeries(std::move(defaultDataSeries));
39
39
40 impl->m_Variables.push_back(variable);
40 impl->m_Variables.push_back(variable);
41
41
42 endInsertRows();
42 endInsertRows();
43
43
44 return variable;
44 return variable;
45 }
45 }
46
46
47 std::shared_ptr<Variable> VariableModel::variable(int index) const
48 {
49 return (index >= 0 && index < impl->m_Variables.size()) ? impl->m_Variables.at(index) : nullptr;
50 }
51
47 int VariableModel::columnCount(const QModelIndex &parent) const
52 int VariableModel::columnCount(const QModelIndex &parent) const
48 {
53 {
49 Q_UNUSED(parent);
54 Q_UNUSED(parent);
50
55
51 return NB_COLUMNS;
56 return NB_COLUMNS;
52 }
57 }
53
58
54 int VariableModel::rowCount(const QModelIndex &parent) const
59 int VariableModel::rowCount(const QModelIndex &parent) const
55 {
60 {
56 Q_UNUSED(parent);
61 Q_UNUSED(parent);
57
62
58 return impl->m_Variables.size();
63 return impl->m_Variables.size();
59 }
64 }
60
65
61 QVariant VariableModel::data(const QModelIndex &index, int role) const
66 QVariant VariableModel::data(const QModelIndex &index, int role) const
62 {
67 {
63 if (!index.isValid()) {
68 if (!index.isValid()) {
64 return QVariant{};
69 return QVariant{};
65 }
70 }
66
71
67 if (index.row() < 0 || index.row() >= rowCount()) {
72 if (index.row() < 0 || index.row() >= rowCount()) {
68 return QVariant{};
73 return QVariant{};
69 }
74 }
70
75
71 if (role == Qt::DisplayRole) {
76 if (role == Qt::DisplayRole) {
72 if (auto variable = impl->m_Variables.at(index.row()).get()) {
77 if (auto variable = impl->m_Variables.at(index.row()).get()) {
73 switch (index.column()) {
78 switch (index.column()) {
74 case NAME_COLUMN:
79 case NAME_COLUMN:
75 return variable->name();
80 return variable->name();
76 case UNIT_COLUMN:
81 case UNIT_COLUMN:
77 return variable->unit();
82 return variable->unit();
78 case MISSION_COLUMN:
83 case MISSION_COLUMN:
79 return variable->mission();
84 return variable->mission();
80 default:
85 default:
81 // No action
86 // No action
82 break;
87 break;
83 }
88 }
84
89
85 qWarning(LOG_VariableModel())
90 qWarning(LOG_VariableModel())
86 << tr("Can't get data (unknown column %1)").arg(index.column());
91 << tr("Can't get data (unknown column %1)").arg(index.column());
87 }
92 }
88 else {
93 else {
89 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
94 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
90 }
95 }
91 }
96 }
92
97
93 return QVariant{};
98 return QVariant{};
94 }
99 }
95
100
96 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
101 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
97 {
102 {
98 if (role != Qt::DisplayRole) {
103 if (role != Qt::DisplayRole) {
99 return QVariant{};
104 return QVariant{};
100 }
105 }
101
106
102 if (orientation == Qt::Horizontal) {
107 if (orientation == Qt::Horizontal) {
103 switch (section) {
108 switch (section) {
104 case NAME_COLUMN:
109 case NAME_COLUMN:
105 return tr("Name");
110 return tr("Name");
106 case UNIT_COLUMN:
111 case UNIT_COLUMN:
107 return tr("Unit");
112 return tr("Unit");
108 case MISSION_COLUMN:
113 case MISSION_COLUMN:
109 return tr("Mission");
114 return tr("Mission");
110 default:
115 default:
111 // No action
116 // No action
112 break;
117 break;
113 }
118 }
114
119
115 qWarning(LOG_VariableModel())
120 qWarning(LOG_VariableModel())
116 << tr("Can't get header data (unknown column %1)").arg(section);
121 << tr("Can't get header data (unknown column %1)").arg(section);
117 }
122 }
118
123
119 return QVariant{};
124 return QVariant{};
120 }
125 }
@@ -1,26 +1,46
1 #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H
1 #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H
2 #define SCIQLOP_VARIABLEINSPECTORWIDGET_H
2 #define SCIQLOP_VARIABLEINSPECTORWIDGET_H
3
3
4 #include <QMenu>
4 #include <QWidget>
5 #include <QWidget>
5
6
7 #include <memory>
8
9 class Variable;
10
6 namespace Ui {
11 namespace Ui {
7 class VariableInspectorWidget;
12 class VariableInspectorWidget;
8 } // Ui
13 } // Ui
9
14
10 /**
15 /**
11 * @brief The VariableInspectorWidget class representes represents the variable inspector, from
16 * @brief The VariableInspectorWidget class representes represents the variable inspector, from
12 * which it is possible to view the loaded variables, handle them or trigger their display in
17 * which it is possible to view the loaded variables, handle them or trigger their display in
13 * visualization
18 * visualization
14 */
19 */
15 class VariableInspectorWidget : public QWidget {
20 class VariableInspectorWidget : public QWidget {
16 Q_OBJECT
21 Q_OBJECT
17
22
18 public:
23 public:
19 explicit VariableInspectorWidget(QWidget *parent = 0);
24 explicit VariableInspectorWidget(QWidget *parent = 0);
20 virtual ~VariableInspectorWidget();
25 virtual ~VariableInspectorWidget();
21
26
27 signals:
28 /**
29 * Signal emitted before a menu concerning a variable is displayed. It is used for other widgets
30 * to complete the menu.
31 * @param tableMenu the menu to be completed
32 * @param variable the variable concerned by the menu
33 * @remarks To make the dynamic addition of menus work, the connections to this signal must be
34 * in Qt :: DirectConnection
35 */
36 void tableMenuAboutToBeDisplayed(QMenu *tableMenu, std::shared_ptr<Variable> variable);
37
22 private:
38 private:
23 Ui::VariableInspectorWidget *ui;
39 Ui::VariableInspectorWidget *ui;
40
41 private slots:
42 /// Slot called when right clicking on an variable in the table (displays a menu)
43 void onTableMenuRequested(const QPoint &pos) noexcept;
24 };
44 };
25
45
26 #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H
46 #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H
@@ -1,53 +1,53
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
5
6 #include <QLoggingCategory>
6 #include <QLoggingCategory>
7 #include <QWidget>
7 #include <QWidget>
8
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
10
10
11 class QMenu;
11 class Variable;
12 class Variable;
12 class VisualizationTabWidget;
13 class VisualizationTabWidget;
13
14
14 namespace Ui {
15 namespace Ui {
15 class VisualizationWidget;
16 class VisualizationWidget;
16 } // namespace Ui
17 } // namespace Ui
17
18
18 class VisualizationWidget : public QWidget, public IVisualizationWidget {
19 class VisualizationWidget : public QWidget, public IVisualizationWidget {
19 Q_OBJECT
20 Q_OBJECT
20
21
21 public:
22 public:
22 explicit VisualizationWidget(QWidget *parent = 0);
23 explicit VisualizationWidget(QWidget *parent = 0);
23 virtual ~VisualizationWidget();
24 virtual ~VisualizationWidget();
24
25
25 /// Add a zone widget
26 /// Add a zone widget
26 virtual void addTab(VisualizationTabWidget *tabWidget);
27 virtual void addTab(VisualizationTabWidget *tabWidget);
27
28
28 /// Create a tab using a Variable
29 /// Create a tab using a Variable
29 VisualizationTabWidget *createTab();
30 VisualizationTabWidget *createTab();
30
31
31 /// Remove a tab
32 /// Remove a tab
32 void removeTab(VisualizationTabWidget *tab);
33 void removeTab(VisualizationTabWidget *tab);
33
34
34 // IVisualizationWidget interface
35 // IVisualizationWidget interface
35 void accept(IVisualizationWidgetVisitor *visitor) override;
36 void accept(IVisualizationWidgetVisitor *visitor) override;
36 bool canDrop(const Variable &variable) const override;
37 bool canDrop(const Variable &variable) const override;
37 void close() override;
38 void close() override;
38 QString name() const override;
39 QString name() const override;
39
40
40 public slots:
41 public slots:
41 /**
42 /**
42 * Displays a variable in a new graph of a new zone of the current tab
43 * Attaches to a menu the menu relating to the visualization of a variable
43 * @param variable the variable to display
44 * @param menu the parent menu of the generated menu
44 * @todo this is a temporary method that will be replaced by own actions for each type of
45 * @param variable the variable for which to generate the menu
45 * visualization widget
46 */
46 */
47 void displayVariable(std::shared_ptr<Variable> variable) noexcept;
47 void attachVariableMenu(QMenu *menu, std::shared_ptr<Variable> variable) noexcept;
48
48
49 private:
49 private:
50 Ui::VisualizationWidget *ui;
50 Ui::VisualizationWidget *ui;
51 };
51 };
52
52
53 #endif // VISUALIZATIONWIDGET_H
53 #endif // VISUALIZATIONWIDGET_H
@@ -1,26 +1,50
1 #include <Variable/VariableController.h>
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableInspectorWidget.h>
2 #include <Variable/VariableInspectorWidget.h>
3 #include <Variable/VariableModel.h>
3 #include <Variable/VariableModel.h>
4
4
5 #include <ui_VariableInspectorWidget.h>
5 #include <ui_VariableInspectorWidget.h>
6
6
7 #include <QSortFilterProxyModel>
7 #include <QSortFilterProxyModel>
8
8
9 #include <SqpApplication.h>
9 #include <SqpApplication.h>
10
10
11 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
11 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
12 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
12 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
13 {
13 {
14 ui->setupUi(this);
14 ui->setupUi(this);
15
15
16 // Sets model for table
16 // Sets model for table
17 auto sortFilterModel = new QSortFilterProxyModel{this};
17 auto sortFilterModel = new QSortFilterProxyModel{this};
18 sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
18 sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
19
19
20 ui->tableView->setModel(sortFilterModel);
20 ui->tableView->setModel(sortFilterModel);
21
22 // Connection to show a menu when right clicking on the tree
23 ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
24 connect(ui->tableView, &QTableView::customContextMenuRequested, this,
25 &VariableInspectorWidget::onTableMenuRequested);
21 }
26 }
22
27
23 VariableInspectorWidget::~VariableInspectorWidget()
28 VariableInspectorWidget::~VariableInspectorWidget()
24 {
29 {
25 delete ui;
30 delete ui;
26 }
31 }
32
33 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept
34 {
35 auto selectedIndex = ui->tableView->indexAt(pos);
36 if (selectedIndex.isValid()) {
37 // Gets the model to retrieve the underlying selected variable
38 auto model = sqpApp->variableController().variableModel();
39 if (auto selectedVariable = model->variable(selectedIndex.row())) {
40 QMenu tableMenu{};
41
42 // Emit a signal so that potential receivers can populate the menu before displaying it
43 emit tableMenuAboutToBeDisplayed(&tableMenu, selectedVariable);
44
45 if (!tableMenu.isEmpty()) {
46 tableMenu.exec(mapToGlobal(pos));
47 }
48 }
49 }
50 }
@@ -1,136 +1,131
1 #include "Visualization/VisualizationWidget.h"
1 #include "Visualization/VisualizationWidget.h"
2 #include "Visualization/IVisualizationWidgetVisitor.h"
2 #include "Visualization/IVisualizationWidgetVisitor.h"
3 #include "Visualization/VisualizationGraphWidget.h"
3 #include "Visualization/VisualizationGraphWidget.h"
4 #include "Visualization/VisualizationTabWidget.h"
4 #include "Visualization/VisualizationTabWidget.h"
5 #include "Visualization/VisualizationZoneWidget.h"
5 #include "Visualization/VisualizationZoneWidget.h"
6 #include "Visualization/operations/GenerateVariableMenuOperation.h"
6 #include "Visualization/qcustomplot.h"
7 #include "Visualization/qcustomplot.h"
7
8
8 #include "ui_VisualizationWidget.h"
9 #include "ui_VisualizationWidget.h"
9
10
10 #include <QToolButton>
11 #include <QToolButton>
11
12
12 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
13 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
13
14
14 VisualizationWidget::VisualizationWidget(QWidget *parent)
15 VisualizationWidget::VisualizationWidget(QWidget *parent)
15 : QWidget{parent}, ui{new Ui::VisualizationWidget}
16 : QWidget{parent}, ui{new Ui::VisualizationWidget}
16 {
17 {
17 ui->setupUi(this);
18 ui->setupUi(this);
18
19
19 auto addTabViewButton = new QToolButton{ui->tabWidget};
20 auto addTabViewButton = new QToolButton{ui->tabWidget};
20 addTabViewButton->setText(tr("Add View"));
21 addTabViewButton->setText(tr("Add View"));
21 addTabViewButton->setCursor(Qt::ArrowCursor);
22 addTabViewButton->setCursor(Qt::ArrowCursor);
22 ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
23 ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
23
24
24 auto enableMinimumCornerWidgetSize = [this](bool enable) {
25 auto enableMinimumCornerWidgetSize = [this](bool enable) {
25
26
26 auto tabViewCornerWidget = ui->tabWidget->cornerWidget();
27 auto tabViewCornerWidget = ui->tabWidget->cornerWidget();
27 auto width = enable ? tabViewCornerWidget->width() : 0;
28 auto width = enable ? tabViewCornerWidget->width() : 0;
28 auto height = enable ? tabViewCornerWidget->height() : 0;
29 auto height = enable ? tabViewCornerWidget->height() : 0;
29 tabViewCornerWidget->setMinimumHeight(height);
30 tabViewCornerWidget->setMinimumHeight(height);
30 tabViewCornerWidget->setMinimumWidth(width);
31 tabViewCornerWidget->setMinimumWidth(width);
31 ui->tabWidget->setMinimumHeight(height);
32 ui->tabWidget->setMinimumHeight(height);
32 ui->tabWidget->setMinimumWidth(width);
33 ui->tabWidget->setMinimumWidth(width);
33 };
34 };
34
35
35 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
36 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
36 auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1),
37 auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1),
37 ui->tabWidget};
38 ui->tabWidget};
38 auto index = ui->tabWidget->addTab(widget, widget->name());
39 auto index = ui->tabWidget->addTab(widget, widget->name());
39 if (ui->tabWidget->count() > 0) {
40 if (ui->tabWidget->count() > 0) {
40 enableMinimumCornerWidgetSize(false);
41 enableMinimumCornerWidgetSize(false);
41 }
42 }
42 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
43 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
43 };
44 };
44
45
45 auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) {
46 auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) {
46 if (ui->tabWidget->count() == 1) {
47 if (ui->tabWidget->count() == 1) {
47 enableMinimumCornerWidgetSize(true);
48 enableMinimumCornerWidgetSize(true);
48 }
49 }
49
50
50 ui->tabWidget->removeTab(index);
51 ui->tabWidget->removeTab(index);
51 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
52 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
52
53
53 };
54 };
54
55
55 ui->tabWidget->setTabsClosable(true);
56 ui->tabWidget->setTabsClosable(true);
56
57
57 connect(addTabViewButton, &QToolButton::clicked, addTabView);
58 connect(addTabViewButton, &QToolButton::clicked, addTabView);
58 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
59 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
59
60
60 // Adds default tab
61 // Adds default tab
61 addTabView();
62 addTabView();
62 }
63 }
63
64
64 VisualizationWidget::~VisualizationWidget()
65 VisualizationWidget::~VisualizationWidget()
65 {
66 {
66 delete ui;
67 delete ui;
67 }
68 }
68
69
69 void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget)
70 void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget)
70 {
71 {
71 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
72 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
72 // lambda function (in the constructor)
73 // lambda function (in the constructor)
73 }
74 }
74
75
75 VisualizationTabWidget *VisualizationWidget::createTab()
76 VisualizationTabWidget *VisualizationWidget::createTab()
76 {
77 {
77 }
78 }
78
79
79 void VisualizationWidget::removeTab(VisualizationTabWidget *tab)
80 void VisualizationWidget::removeTab(VisualizationTabWidget *tab)
80 {
81 {
81 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
82 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
82 // lambda function (in the constructor)
83 // lambda function (in the constructor)
83 }
84 }
84
85
85 void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor)
86 void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor)
86 {
87 {
87 if (visitor) {
88 if (visitor) {
88 visitor->visitEnter(this);
89 visitor->visitEnter(this);
89
90
90 // Apply visitor for tab children
91 // Apply visitor for tab children
91 for (auto i = 0; i < ui->tabWidget->count(); ++i) {
92 for (auto i = 0; i < ui->tabWidget->count(); ++i) {
92 // Widgets different from tabs are not visited (no action)
93 // Widgets different from tabs are not visited (no action)
93 if (auto visualizationTabWidget
94 if (auto visualizationTabWidget
94 = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) {
95 = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) {
95 visualizationTabWidget->accept(visitor);
96 visualizationTabWidget->accept(visitor);
96 }
97 }
97 }
98 }
98
99
99 visitor->visitLeave(this);
100 visitor->visitLeave(this);
100 }
101 }
101 else {
102 else {
102 qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null");
103 qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null");
103 }
104 }
104 }
105 }
105
106
106 bool VisualizationWidget::canDrop(const Variable &variable) const
107 bool VisualizationWidget::canDrop(const Variable &variable) const
107 {
108 {
108 // The main widget can never accomodate a variable
109 // The main widget can never accomodate a variable
109 Q_UNUSED(variable);
110 Q_UNUSED(variable);
110 return false;
111 return false;
111 }
112 }
112
113
113 void VisualizationWidget::close()
114 void VisualizationWidget::close()
114 {
115 {
115 // The main view cannot be directly closed.
116 // The main view cannot be directly closed.
116 return;
117 return;
117 }
118 }
118
119
119 QString VisualizationWidget::name() const
120 QString VisualizationWidget::name() const
120 {
121 {
121 return QStringLiteral("MainView");
122 return QStringLiteral("MainView");
122 }
123 }
123
124
124 void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
125 void VisualizationWidget::attachVariableMenu(QMenu *menu,
126 std::shared_ptr<Variable> variable) noexcept
125 {
127 {
126 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
128 // Generates the actions that make it possible to visualize the variable
127 if (!currentTab->createZone(variable)) {
129 auto generateVariableMenuOperation = GenerateVariableMenuOperation{menu, variable};
128 qCCritical(LOG_VisualizationWidget())
130 accept(&generateVariableMenuOperation);
129 << tr("Can't display the variable : can't create a new zone in the current tab");
130 }
131 }
132 else {
133 qCCritical(LOG_VisualizationWidget())
134 << tr("Can't display the variable : there is no current tab");
135 }
136 }
131 }
General Comments 0
You need to be logged in to leave comments. Login now