##// END OF EJS Templates
Connects variable widget to visualization widget...
Alexandre Leroux -
r249:3d1d1572319d
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 }
General Comments 0
You need to be logged in to leave comments. Login now