##// END OF EJS Templates
Creates the slot to display the created variable in the Visualization widget...
Alexandre Leroux -
r175:81ea5016bbcd
parent child
Show More
@@ -1,233 +1,239
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 <TimeWidget/TimeWidget.h>
29 #include <TimeWidget/TimeWidget.h>
30 #include <Variable/Variable.h>
31 #include <Visualization/VisualizationController.h>
30
32
31 #include <QAction>
33 #include <QAction>
32 #include <QDate>
34 #include <QDate>
33 #include <QDateTime>
35 #include <QDateTime>
34 #include <QDir>
36 #include <QDir>
35 #include <QFileDialog>
37 #include <QFileDialog>
36 #include <QToolBar>
38 #include <QToolBar>
37 #include <QToolButton>
39 #include <QToolButton>
38 #include <memory.h>
40 #include <memory.h>
39
41
40 //#include <omp.h>
42 //#include <omp.h>
41 //#include <network/filedownloader.h>
43 //#include <network/filedownloader.h>
42 //#include <qlopdatabase.h>
44 //#include <qlopdatabase.h>
43 //#include <qlopsettings.h>
45 //#include <qlopsettings.h>
44 //#include <qlopgui.h>
46 //#include <qlopgui.h>
45 //#include <spacedata.h>
47 //#include <spacedata.h>
46 //#include "qlopcore.h"
48 //#include "qlopcore.h"
47 //#include "qlopcodecmanager.h"
49 //#include "qlopcodecmanager.h"
48 //#include "cdfcodec.h"
50 //#include "cdfcodec.h"
49 //#include "amdatxtcodec.h"
51 //#include "amdatxtcodec.h"
50 //#include <qlopplotmanager.h>
52 //#include <qlopplotmanager.h>
51
53
52 #include "iostream"
54 #include "iostream"
53
55
54 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
56 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
55
57
56 namespace {
58 namespace {
57 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
59 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
58 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
60 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
59 const auto VIEWPLITTERINDEX = 2;
61 const auto VIEWPLITTERINDEX = 2;
60 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
62 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
61 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
63 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
62 }
64 }
63
65
64 class MainWindow::MainWindowPrivate {
66 class MainWindow::MainWindowPrivate {
65 public:
67 public:
66 QSize m_LastOpenLeftInspectorSize;
68 QSize m_LastOpenLeftInspectorSize;
67 QSize m_LastOpenRightInspectorSize;
69 QSize m_LastOpenRightInspectorSize;
68 };
70 };
69
71
70 MainWindow::MainWindow(QWidget *parent)
72 MainWindow::MainWindow(QWidget *parent)
71 : QMainWindow{parent},
73 : QMainWindow{parent},
72 m_Ui{new Ui::MainWindow},
74 m_Ui{new Ui::MainWindow},
73 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
75 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
74 {
76 {
75 m_Ui->setupUi(this);
77 m_Ui->setupUi(this);
76
78
77 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
79 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
78 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
80 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
79
81
80
82
81 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
83 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
82 auto openLeftInspectorAction = new QAction{QIcon{
84 auto openLeftInspectorAction = new QAction{QIcon{
83 ":/icones/previous.png",
85 ":/icones/previous.png",
84 },
86 },
85 tr("Show/hide the left inspector"), this};
87 tr("Show/hide the left inspector"), this};
86
88
87
89
88 auto spacerLeftTop = new QWidget{};
90 auto spacerLeftTop = new QWidget{};
89 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
91 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
90
92
91 auto spacerLeftBottom = new QWidget{};
93 auto spacerLeftBottom = new QWidget{};
92 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
94 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93
95
94 leftSidePane->addWidget(spacerLeftTop);
96 leftSidePane->addWidget(spacerLeftTop);
95 leftSidePane->addAction(openLeftInspectorAction);
97 leftSidePane->addAction(openLeftInspectorAction);
96 leftSidePane->addWidget(spacerLeftBottom);
98 leftSidePane->addWidget(spacerLeftBottom);
97
99
98
100
99 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
101 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
100 auto openRightInspectorAction = new QAction{QIcon{
102 auto openRightInspectorAction = new QAction{QIcon{
101 ":/icones/next.png",
103 ":/icones/next.png",
102 },
104 },
103 tr("Show/hide the right inspector"), this};
105 tr("Show/hide the right inspector"), this};
104
106
105 auto spacerRightTop = new QWidget{};
107 auto spacerRightTop = new QWidget{};
106 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
108 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
107
109
108 auto spacerRightBottom = new QWidget{};
110 auto spacerRightBottom = new QWidget{};
109 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
111 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110
112
111 rightSidePane->addWidget(spacerRightTop);
113 rightSidePane->addWidget(spacerRightTop);
112 rightSidePane->addAction(openRightInspectorAction);
114 rightSidePane->addAction(openRightInspectorAction);
113 rightSidePane->addWidget(spacerRightBottom);
115 rightSidePane->addWidget(spacerRightBottom);
114
116
115 openLeftInspectorAction->setCheckable(true);
117 openLeftInspectorAction->setCheckable(true);
116 openRightInspectorAction->setCheckable(true);
118 openRightInspectorAction->setCheckable(true);
117
119
118 auto openInspector = [this](bool checked, bool right, auto action) {
120 auto openInspector = [this](bool checked, bool right, auto action) {
119
121
120 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
122 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
121
123
122 auto &lastInspectorSize
124 auto &lastInspectorSize
123 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
125 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
124
126
125 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
127 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
126 : m_Ui->leftMainInspectorWidget->size();
128 : m_Ui->leftMainInspectorWidget->size();
127
129
128 // Update of the last opened geometry
130 // Update of the last opened geometry
129 if (checked) {
131 if (checked) {
130 lastInspectorSize = nextInspectorSize;
132 lastInspectorSize = nextInspectorSize;
131 }
133 }
132
134
133 auto startSize = lastInspectorSize;
135 auto startSize = lastInspectorSize;
134 auto endSize = startSize;
136 auto endSize = startSize;
135 endSize.setWidth(0);
137 endSize.setWidth(0);
136
138
137 auto splitterInspectorIndex
139 auto splitterInspectorIndex
138 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
140 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
139
141
140 auto currentSizes = m_Ui->splitter->sizes();
142 auto currentSizes = m_Ui->splitter->sizes();
141 if (checked) {
143 if (checked) {
142 // adjust sizes individually here, e.g.
144 // adjust sizes individually here, e.g.
143 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
145 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
144 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
146 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
145 m_Ui->splitter->setSizes(currentSizes);
147 m_Ui->splitter->setSizes(currentSizes);
146 }
148 }
147 else {
149 else {
148 // adjust sizes individually here, e.g.
150 // adjust sizes individually here, e.g.
149 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
151 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
150 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
152 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
151 m_Ui->splitter->setSizes(currentSizes);
153 m_Ui->splitter->setSizes(currentSizes);
152 }
154 }
153
155
154 };
156 };
155
157
156
158
157 connect(openLeftInspectorAction, &QAction::triggered,
159 connect(openLeftInspectorAction, &QAction::triggered,
158 [openInspector, openLeftInspectorAction](bool checked) {
160 [openInspector, openLeftInspectorAction](bool checked) {
159 openInspector(checked, false, openLeftInspectorAction);
161 openInspector(checked, false, openLeftInspectorAction);
160 });
162 });
161 connect(openRightInspectorAction, &QAction::triggered,
163 connect(openRightInspectorAction, &QAction::triggered,
162 [openInspector, openRightInspectorAction](bool checked) {
164 [openInspector, openRightInspectorAction](bool checked) {
163 openInspector(checked, true, openRightInspectorAction);
165 openInspector(checked, true, openRightInspectorAction);
164 });
166 });
165
167
166 this->menuBar()->addAction(tr("File"));
168 this->menuBar()->addAction(tr("File"));
167 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
169 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
168
170
169 mainToolBar->addWidget(new TimeWidget{});
171 mainToolBar->addWidget(new TimeWidget{});
170
172
171 // Widgets / controllers connections
173 // Widgets / controllers connections
172 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
174 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
173 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
175 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
174
176
177 qRegisterMetaType<std::shared_ptr<Variable> >();
178 connect(&sqpApp->visualizationController(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
179 m_Ui->view, SLOT(displayVariable(std::shared_ptr<Variable>)));
180
175 /* QLopGUI::registerMenuBar(menuBar());
181 /* QLopGUI::registerMenuBar(menuBar());
176 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
182 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
177 this->m_progressWidget = new QWidget();
183 this->m_progressWidget = new QWidget();
178 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
184 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
179 this->m_progressWidget->setLayout(this->m_progressLayout);
185 this->m_progressWidget->setLayout(this->m_progressLayout);
180 this->m_progressWidget->setWindowModality(Qt::WindowModal);
186 this->m_progressWidget->setWindowModality(Qt::WindowModal);
181 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
187 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
182 for(int i=0;i<OMP_THREADS;i++)
188 for(int i=0;i<OMP_THREADS;i++)
183 {
189 {
184 this->m_progress.append(new QProgressBar(this->m_progressWidget));
190 this->m_progress.append(new QProgressBar(this->m_progressWidget));
185 this->m_progress.last()->setMinimum(0);
191 this->m_progress.last()->setMinimum(0);
186 this->m_progress.last()->setMaximum(100);
192 this->m_progress.last()->setMaximum(100);
187 this->m_progressLayout->addWidget(this->m_progress.last());
193 this->m_progressLayout->addWidget(this->m_progress.last());
188 this->m_progressWidget->hide();
194 this->m_progressWidget->hide();
189 this->m_progressThreadIds[i] = -1;
195 this->m_progressThreadIds[i] = -1;
190 }
196 }
191 this->m_progressWidget->setWindowTitle("Loading File");
197 this->m_progressWidget->setWindowTitle("Loading File");
192 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
198 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
193 << QLopCore::self()
199 << QLopCore::self()
194 << QLopPlotManager::self()
200 << QLopPlotManager::self()
195 << QLopCodecManager::self()
201 << QLopCodecManager::self()
196 << FileDownloader::self()
202 << FileDownloader::self()
197 << QLopDataBase::self()
203 << QLopDataBase::self()
198 << SpaceData::self();
204 << SpaceData::self();
199
205
200 CDFCodec::registerToManager();
206 CDFCodec::registerToManager();
201 AMDATXTCodec::registerToManager();
207 AMDATXTCodec::registerToManager();
202
208
203
209
204 for(int i=0;i<ServicesToLoad.count();i++)
210 for(int i=0;i<ServicesToLoad.count();i++)
205 {
211 {
206 qDebug()<<ServicesToLoad.at(i)->serviceName();
212 qDebug()<<ServicesToLoad.at(i)->serviceName();
207 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
213 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
208 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
214 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
209 if(wdgt)
215 if(wdgt)
210 {
216 {
211 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
217 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
212 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
218 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
213 }
219 }
214 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
220 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
215 }*/
221 }*/
216 }
222 }
217
223
218 MainWindow::~MainWindow()
224 MainWindow::~MainWindow()
219 {
225 {
220 }
226 }
221
227
222
228
223 void MainWindow::changeEvent(QEvent *e)
229 void MainWindow::changeEvent(QEvent *e)
224 {
230 {
225 QMainWindow::changeEvent(e);
231 QMainWindow::changeEvent(e);
226 switch (e->type()) {
232 switch (e->type()) {
227 case QEvent::LanguageChange:
233 case QEvent::LanguageChange:
228 m_Ui->retranslateUi(this);
234 m_Ui->retranslateUi(this);
229 break;
235 break;
230 default:
236 default:
231 break;
237 break;
232 }
238 }
233 }
239 }
@@ -1,42 +1,52
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 class Variable;
9 class VisualizationTabWidget;
10 class VisualizationTabWidget;
10
11
11 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
12
13
13 namespace Ui {
14 namespace Ui {
14 class VisualizationWidget;
15 class VisualizationWidget;
15 } // namespace Ui
16 } // namespace Ui
16
17
17 class VisualizationWidget : public QWidget, public IVisualizationWidget {
18 class VisualizationWidget : public QWidget, public IVisualizationWidget {
18 Q_OBJECT
19 Q_OBJECT
19
20
20 public:
21 public:
21 explicit VisualizationWidget(QWidget *parent = 0);
22 explicit VisualizationWidget(QWidget *parent = 0);
22 virtual ~VisualizationWidget();
23 virtual ~VisualizationWidget();
23
24
24 /// Add a zone widget
25 /// Add a zone widget
25 virtual void addTab(VisualizationTabWidget *tabWidget);
26 virtual void addTab(VisualizationTabWidget *tabWidget);
26
27
27 /// Create a tab using a Variable
28 /// Create a tab using a Variable
28 VisualizationTabWidget *createTab();
29 VisualizationTabWidget *createTab();
29
30
30 /// Remove a tab
31 /// Remove a tab
31 void removeTab(VisualizationTabWidget *tab);
32 void removeTab(VisualizationTabWidget *tab);
32
33
33 // IVisualizationWidget interface
34 // IVisualizationWidget interface
34 void accept(IVisualizationWidget *visitor) override;
35 void accept(IVisualizationWidget *visitor) override;
35 void close() override;
36 void close() override;
36 QString name() const;
37 QString name() const;
37
38
39 public slots:
40 /**
41 * Displays a variable in a new graph of a new zone of the current tab
42 * @param variable the variable to display
43 * @todo this is a temporary method that will be replaced by own actions for each type of
44 * visualization widget
45 */
46 void displayVariable(std::shared_ptr<Variable> variable) noexcept;
47
38 private:
48 private:
39 Ui::VisualizationWidget *ui;
49 Ui::VisualizationWidget *ui;
40 };
50 };
41
51
42 #endif // VISUALIZATIONWIDGET_H
52 #endif // VISUALIZATIONWIDGET_H
@@ -1,80 +1,85
1 #include "Visualization/VisualizationWidget.h"
1 #include "Visualization/VisualizationWidget.h"
2 #include "Visualization/VisualizationTabWidget.h"
2 #include "Visualization/VisualizationTabWidget.h"
3 #include "Visualization/qcustomplot.h"
3 #include "Visualization/qcustomplot.h"
4
4
5 #include "ui_VisualizationWidget.h"
5 #include "ui_VisualizationWidget.h"
6
6
7 #include <QToolButton>
7 #include <QToolButton>
8
8
9 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
9 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
10
10
11 VisualizationWidget::VisualizationWidget(QWidget *parent)
11 VisualizationWidget::VisualizationWidget(QWidget *parent)
12 : QWidget{parent}, ui{new Ui::VisualizationWidget}
12 : QWidget{parent}, ui{new Ui::VisualizationWidget}
13 {
13 {
14 ui->setupUi(this);
14 ui->setupUi(this);
15
15
16 auto addTabViewButton = new QToolButton{ui->tabWidget};
16 auto addTabViewButton = new QToolButton{ui->tabWidget};
17 addTabViewButton->setText(tr("Add View"));
17 addTabViewButton->setText(tr("Add View"));
18 addTabViewButton->setCursor(Qt::ArrowCursor);
18 addTabViewButton->setCursor(Qt::ArrowCursor);
19 addTabViewButton->setAutoRaise(true);
19 addTabViewButton->setAutoRaise(true);
20 ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
20 ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
21 auto width = ui->tabWidget->cornerWidget()->width();
21 auto width = ui->tabWidget->cornerWidget()->width();
22 auto height = ui->tabWidget->cornerWidget()->height();
22 auto height = ui->tabWidget->cornerWidget()->height();
23 addTabViewButton->setMinimumHeight(height);
23 addTabViewButton->setMinimumHeight(height);
24 addTabViewButton->setMinimumWidth(width);
24 addTabViewButton->setMinimumWidth(width);
25 ui->tabWidget->setMinimumHeight(height);
25 ui->tabWidget->setMinimumHeight(height);
26 ui->tabWidget->setMinimumWidth(width);
26 ui->tabWidget->setMinimumWidth(width);
27
27
28 auto addTabView = [&]() {
28 auto addTabView = [&]() {
29 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
29 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
30 QString("View %1").arg(ui->tabWidget->count() + 1));
30 QString("View %1").arg(ui->tabWidget->count() + 1));
31 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
31 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
32 };
32 };
33
33
34 auto removeTabView = [&](int index) {
34 auto removeTabView = [&](int index) {
35 ui->tabWidget->removeTab(index);
35 ui->tabWidget->removeTab(index);
36 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
36 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
37 };
37 };
38
38
39 ui->tabWidget->setTabsClosable(true);
39 ui->tabWidget->setTabsClosable(true);
40
40
41 connect(addTabViewButton, &QToolButton::clicked, addTabView);
41 connect(addTabViewButton, &QToolButton::clicked, addTabView);
42 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
42 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
43 }
43 }
44
44
45 VisualizationWidget::~VisualizationWidget()
45 VisualizationWidget::~VisualizationWidget()
46 {
46 {
47 delete ui;
47 delete ui;
48 }
48 }
49
49
50 void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget)
50 void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget)
51 {
51 {
52 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
52 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
53 // lambda function (in the constructor)
53 // lambda function (in the constructor)
54 }
54 }
55
55
56 VisualizationTabWidget *VisualizationWidget::createTab()
56 VisualizationTabWidget *VisualizationWidget::createTab()
57 {
57 {
58 }
58 }
59
59
60 void VisualizationWidget::removeTab(VisualizationTabWidget *tab)
60 void VisualizationWidget::removeTab(VisualizationTabWidget *tab)
61 {
61 {
62 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
62 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
63 // lambda function (in the constructor)
63 // lambda function (in the constructor)
64 }
64 }
65
65
66 void VisualizationWidget::accept(IVisualizationWidget *visitor)
66 void VisualizationWidget::accept(IVisualizationWidget *visitor)
67 {
67 {
68 // TODO: manage the visitor
68 // TODO: manage the visitor
69 }
69 }
70
70
71 void VisualizationWidget::close()
71 void VisualizationWidget::close()
72 {
72 {
73 // The main view cannot be directly closed.
73 // The main view cannot be directly closed.
74 return;
74 return;
75 }
75 }
76
76
77 QString VisualizationWidget::name() const
77 QString VisualizationWidget::name() const
78 {
78 {
79 return QStringLiteral("MainView");
79 return QStringLiteral("MainView");
80 }
80 }
81
82 void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
83 {
84 /// @todo ALX : add variable in a new graph
85 }
General Comments 0
You need to be logged in to leave comments. Login now