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