##// END OF EJS Templates
Correction MR
perrinel -
r139:94f8c05d7495
parent child
Show More
@@ -1,235 +1,233
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
30
31 #include <QAction>
31 #include <QAction>
32 #include <QDate>
32 #include <QDate>
33 #include <QDateTime>
33 #include <QDateTime>
34 #include <QDir>
34 #include <QDir>
35 #include <QFileDialog>
35 #include <QFileDialog>
36 #include <QToolBar>
36 #include <QToolBar>
37 #include <QToolButton>
37 #include <QToolButton>
38 #include <memory.h>
38 #include <memory.h>
39
39
40 //#include <omp.h>
40 //#include <omp.h>
41 //#include <network/filedownloader.h>
41 //#include <network/filedownloader.h>
42 //#include <qlopdatabase.h>
42 //#include <qlopdatabase.h>
43 //#include <qlopsettings.h>
43 //#include <qlopsettings.h>
44 //#include <qlopgui.h>
44 //#include <qlopgui.h>
45 //#include <spacedata.h>
45 //#include <spacedata.h>
46 //#include "qlopcore.h"
46 //#include "qlopcore.h"
47 //#include "qlopcodecmanager.h"
47 //#include "qlopcodecmanager.h"
48 //#include "cdfcodec.h"
48 //#include "cdfcodec.h"
49 //#include "amdatxtcodec.h"
49 //#include "amdatxtcodec.h"
50 //#include <qlopplotmanager.h>
50 //#include <qlopplotmanager.h>
51
51
52 #include "iostream"
52 #include "iostream"
53
53
54 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
54 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
55
55
56 namespace {
56 namespace {
57 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
57 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
58 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
58 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
59 const auto VIEWPLITTERINDEX = 2;
59 const auto VIEWPLITTERINDEX = 2;
60 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
60 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
61 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
61 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
62 }
62 }
63
63
64 class MainWindow::MainWindowPrivate {
64 class MainWindow::MainWindowPrivate {
65 public:
65 public:
66 QSize m_LastOpenLeftInspectorSize;
66 QSize m_LastOpenLeftInspectorSize;
67 QSize m_LastOpenRightInspectorSize;
67 QSize m_LastOpenRightInspectorSize;
68 };
68 };
69
69
70 MainWindow::MainWindow(QWidget *parent)
70 MainWindow::MainWindow(QWidget *parent)
71 : QMainWindow{parent},
71 : QMainWindow{parent},
72 m_Ui{new Ui::MainWindow},
72 m_Ui{new Ui::MainWindow},
73 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
73 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
74 {
74 {
75 m_Ui->setupUi(this);
75 m_Ui->setupUi(this);
76
76
77 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
77 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
78 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
78 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
79
79
80
80
81 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
81 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
82 auto openLeftInspectorAction = new QAction(
82 auto openLeftInspectorAction = new QAction{QIcon{
83 QIcon{
84 ":/icones/previous.png",
83 ":/icones/previous.png",
85 },
84 },
86 tr("Show/hide the left inspector"), this);
85 tr("Show/hide the left inspector"), this};
87
86
88
87
89 QWidget *spacerLeftTop = new QWidget();
88 auto spacerLeftTop = new QWidget{};
90 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
89 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
91
90
92 QWidget *spacerLeftBottom = new QWidget();
91 auto spacerLeftBottom = new QWidget{};
93 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
92 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
94
93
95 leftSidePane->addWidget(spacerLeftTop);
94 leftSidePane->addWidget(spacerLeftTop);
96 leftSidePane->addAction(openLeftInspectorAction);
95 leftSidePane->addAction(openLeftInspectorAction);
97 leftSidePane->addWidget(spacerLeftBottom);
96 leftSidePane->addWidget(spacerLeftBottom);
98
97
99
98
100 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
99 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
101 auto openRightInspectorAction = new QAction(
100 auto openRightInspectorAction = new QAction{QIcon{
102 QIcon{
103 ":/icones/next.png",
101 ":/icones/next.png",
104 },
102 },
105 tr("Show/hide the right inspector"), this);
103 tr("Show/hide the right inspector"), this};
106
104
107 QWidget *spacerRightTop = new QWidget();
105 auto spacerRightTop = new QWidget{};
108 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
106 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
109
107
110 QWidget *spacerRightBottom = new QWidget();
108 auto spacerRightBottom = new QWidget{};
111 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
109 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
112
110
113 rightSidePane->addWidget(spacerRightTop);
111 rightSidePane->addWidget(spacerRightTop);
114 rightSidePane->addAction(openRightInspectorAction);
112 rightSidePane->addAction(openRightInspectorAction);
115 rightSidePane->addWidget(spacerRightBottom);
113 rightSidePane->addWidget(spacerRightBottom);
116
114
117 openLeftInspectorAction->setCheckable(true);
115 openLeftInspectorAction->setCheckable(true);
118 openRightInspectorAction->setCheckable(true);
116 openRightInspectorAction->setCheckable(true);
119
117
120 auto openInspector = [this](bool checked, bool right, auto action) {
118 auto openInspector = [this](bool checked, bool right, auto action) {
121
119
122 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
120 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
123
121
124 auto &lastInspectorSize
122 auto &lastInspectorSize
125 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
123 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
126
124
127 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
125 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
128 : m_Ui->leftMainInspectorWidget->size();
126 : m_Ui->leftMainInspectorWidget->size();
129
127
130 // Update of the last opened geometry
128 // Update of the last opened geometry
131 if (checked) {
129 if (checked) {
132 lastInspectorSize = nextInspectorSize;
130 lastInspectorSize = nextInspectorSize;
133 }
131 }
134
132
135 auto startSize = lastInspectorSize;
133 auto startSize = lastInspectorSize;
136 auto endSize = startSize;
134 auto endSize = startSize;
137 endSize.setWidth(0);
135 endSize.setWidth(0);
138
136
139 auto splitterInspectorIndex
137 auto splitterInspectorIndex
140 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
138 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
141
139
142 auto currentSizes = m_Ui->splitter->sizes();
140 auto currentSizes = m_Ui->splitter->sizes();
143 if (checked) {
141 if (checked) {
144 // adjust sizes individually here, e.g.
142 // adjust sizes individually here, e.g.
145 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
143 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
146 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
144 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
147 m_Ui->splitter->setSizes(currentSizes);
145 m_Ui->splitter->setSizes(currentSizes);
148 }
146 }
149 else {
147 else {
150 // adjust sizes individually here, e.g.
148 // adjust sizes individually here, e.g.
151 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
149 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
152 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
150 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
153 m_Ui->splitter->setSizes(currentSizes);
151 m_Ui->splitter->setSizes(currentSizes);
154 }
152 }
155
153
156 };
154 };
157
155
158
156
159 connect(openLeftInspectorAction, &QAction::triggered,
157 connect(openLeftInspectorAction, &QAction::triggered,
160 [openInspector, openLeftInspectorAction](bool checked) {
158 [openInspector, openLeftInspectorAction](bool checked) {
161 openInspector(checked, false, openLeftInspectorAction);
159 openInspector(checked, false, openLeftInspectorAction);
162 });
160 });
163 connect(openRightInspectorAction, &QAction::triggered,
161 connect(openRightInspectorAction, &QAction::triggered,
164 [openInspector, openRightInspectorAction](bool checked) {
162 [openInspector, openRightInspectorAction](bool checked) {
165 openInspector(checked, true, openRightInspectorAction);
163 openInspector(checked, true, openRightInspectorAction);
166 });
164 });
167
165
168 this->menuBar()->addAction(tr("File"));
166 this->menuBar()->addAction(tr("File"));
169 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
167 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
170
168
171 mainToolBar->addWidget(new TimeWidget());
169 mainToolBar->addWidget(new TimeWidget{});
172
170
173 // Widgets / controllers connections
171 // Widgets / controllers connections
174 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
172 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
175 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
173 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
176
174
177 /* QLopGUI::registerMenuBar(menuBar());
175 /* QLopGUI::registerMenuBar(menuBar());
178 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
176 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
179 this->m_progressWidget = new QWidget();
177 this->m_progressWidget = new QWidget();
180 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
178 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
181 this->m_progressWidget->setLayout(this->m_progressLayout);
179 this->m_progressWidget->setLayout(this->m_progressLayout);
182 this->m_progressWidget->setWindowModality(Qt::WindowModal);
180 this->m_progressWidget->setWindowModality(Qt::WindowModal);
183 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
181 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
184 for(int i=0;i<OMP_THREADS;i++)
182 for(int i=0;i<OMP_THREADS;i++)
185 {
183 {
186 this->m_progress.append(new QProgressBar(this->m_progressWidget));
184 this->m_progress.append(new QProgressBar(this->m_progressWidget));
187 this->m_progress.last()->setMinimum(0);
185 this->m_progress.last()->setMinimum(0);
188 this->m_progress.last()->setMaximum(100);
186 this->m_progress.last()->setMaximum(100);
189 this->m_progressLayout->addWidget(this->m_progress.last());
187 this->m_progressLayout->addWidget(this->m_progress.last());
190 this->m_progressWidget->hide();
188 this->m_progressWidget->hide();
191 this->m_progressThreadIds[i] = -1;
189 this->m_progressThreadIds[i] = -1;
192 }
190 }
193 this->m_progressWidget->setWindowTitle("Loading File");
191 this->m_progressWidget->setWindowTitle("Loading File");
194 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
192 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
195 << QLopCore::self()
193 << QLopCore::self()
196 << QLopPlotManager::self()
194 << QLopPlotManager::self()
197 << QLopCodecManager::self()
195 << QLopCodecManager::self()
198 << FileDownloader::self()
196 << FileDownloader::self()
199 << QLopDataBase::self()
197 << QLopDataBase::self()
200 << SpaceData::self();
198 << SpaceData::self();
201
199
202 CDFCodec::registerToManager();
200 CDFCodec::registerToManager();
203 AMDATXTCodec::registerToManager();
201 AMDATXTCodec::registerToManager();
204
202
205
203
206 for(int i=0;i<ServicesToLoad.count();i++)
204 for(int i=0;i<ServicesToLoad.count();i++)
207 {
205 {
208 qDebug()<<ServicesToLoad.at(i)->serviceName();
206 qDebug()<<ServicesToLoad.at(i)->serviceName();
209 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
207 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
210 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
208 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
211 if(wdgt)
209 if(wdgt)
212 {
210 {
213 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
211 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
214 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
212 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
215 }
213 }
216 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
214 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
217 }*/
215 }*/
218 }
216 }
219
217
220 MainWindow::~MainWindow()
218 MainWindow::~MainWindow()
221 {
219 {
222 }
220 }
223
221
224
222
225 void MainWindow::changeEvent(QEvent *e)
223 void MainWindow::changeEvent(QEvent *e)
226 {
224 {
227 QMainWindow::changeEvent(e);
225 QMainWindow::changeEvent(e);
228 switch (e->type()) {
226 switch (e->type()) {
229 case QEvent::LanguageChange:
227 case QEvent::LanguageChange:
230 m_Ui->retranslateUi(this);
228 m_Ui->retranslateUi(this);
231 break;
229 break;
232 default:
230 default:
233 break;
231 break;
234 }
232 }
235 }
233 }
@@ -1,23 +1,21
1 #ifndef SCIQLOP_TIMEWIDGET_H
1 #ifndef SCIQLOP_TIMEWIDGET_H
2 #define SCIQLOP_TIMEWIDGET_H
2 #define SCIQLOP_TIMEWIDGET_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5
5
6 namespace Ui {
6 namespace Ui {
7 class TimeWidget;
7 class TimeWidget;
8 } // Ui
8 } // Ui
9
9
10 class TimeWidget;
11
12 class TimeWidget : public QWidget {
10 class TimeWidget : public QWidget {
13 Q_OBJECT
11 Q_OBJECT
14
12
15 public:
13 public:
16 explicit TimeWidget(QWidget *parent = 0);
14 explicit TimeWidget(QWidget *parent = 0);
17 virtual ~TimeWidget();
15 virtual ~TimeWidget();
18
16
19 private:
17 private:
20 Ui::TimeWidget *ui;
18 Ui::TimeWidget *ui;
21 };
19 };
22
20
23 #endif // SCIQLOP_ SQPSIDEPANE_H
21 #endif // SCIQLOP_ SQPSIDEPANE_H
General Comments 0
You need to be logged in to leave comments. Login now