@@ -1,233 +1,239 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SciQLop Software |
|
3 | 3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "MainWindow.h" |
|
23 | 23 | #include "ui_MainWindow.h" |
|
24 | 24 | |
|
25 | 25 | #include <DataSource/DataSourceController.h> |
|
26 | 26 | #include <DataSource/DataSourceWidget.h> |
|
27 | 27 | #include <SidePane/SqpSidePane.h> |
|
28 | 28 | #include <SqpApplication.h> |
|
29 | 29 | #include <TimeWidget/TimeWidget.h> |
|
30 | #include <Variable/Variable.h> | |
|
31 | #include <Visualization/VisualizationController.h> | |
|
30 | 32 | |
|
31 | 33 | #include <QAction> |
|
32 | 34 | #include <QDate> |
|
33 | 35 | #include <QDateTime> |
|
34 | 36 | #include <QDir> |
|
35 | 37 | #include <QFileDialog> |
|
36 | 38 | #include <QToolBar> |
|
37 | 39 | #include <QToolButton> |
|
38 | 40 | #include <memory.h> |
|
39 | 41 | |
|
40 | 42 | //#include <omp.h> |
|
41 | 43 | //#include <network/filedownloader.h> |
|
42 | 44 | //#include <qlopdatabase.h> |
|
43 | 45 | //#include <qlopsettings.h> |
|
44 | 46 | //#include <qlopgui.h> |
|
45 | 47 | //#include <spacedata.h> |
|
46 | 48 | //#include "qlopcore.h" |
|
47 | 49 | //#include "qlopcodecmanager.h" |
|
48 | 50 | //#include "cdfcodec.h" |
|
49 | 51 | //#include "amdatxtcodec.h" |
|
50 | 52 | //#include <qlopplotmanager.h> |
|
51 | 53 | |
|
52 | 54 | #include "iostream" |
|
53 | 55 | |
|
54 | 56 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") |
|
55 | 57 | |
|
56 | 58 | namespace { |
|
57 | 59 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; |
|
58 | 60 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; |
|
59 | 61 | const auto VIEWPLITTERINDEX = 2; |
|
60 | 62 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; |
|
61 | 63 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; |
|
62 | 64 | } |
|
63 | 65 | |
|
64 | 66 | class MainWindow::MainWindowPrivate { |
|
65 | 67 | public: |
|
66 | 68 | QSize m_LastOpenLeftInspectorSize; |
|
67 | 69 | QSize m_LastOpenRightInspectorSize; |
|
68 | 70 | }; |
|
69 | 71 | |
|
70 | 72 | MainWindow::MainWindow(QWidget *parent) |
|
71 | 73 | : QMainWindow{parent}, |
|
72 | 74 | m_Ui{new Ui::MainWindow}, |
|
73 | 75 | impl{spimpl::make_unique_impl<MainWindowPrivate>()} |
|
74 | 76 | { |
|
75 | 77 | m_Ui->setupUi(this); |
|
76 | 78 | |
|
77 | 79 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
78 | 80 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
79 | 81 | |
|
80 | 82 | |
|
81 | 83 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); |
|
82 | 84 | auto openLeftInspectorAction = new QAction{QIcon{ |
|
83 | 85 | ":/icones/previous.png", |
|
84 | 86 | }, |
|
85 | 87 | tr("Show/hide the left inspector"), this}; |
|
86 | 88 | |
|
87 | 89 | |
|
88 | 90 | auto spacerLeftTop = new QWidget{}; |
|
89 | 91 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
90 | 92 | |
|
91 | 93 | auto spacerLeftBottom = new QWidget{}; |
|
92 | 94 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
93 | 95 | |
|
94 | 96 | leftSidePane->addWidget(spacerLeftTop); |
|
95 | 97 | leftSidePane->addAction(openLeftInspectorAction); |
|
96 | 98 | leftSidePane->addWidget(spacerLeftBottom); |
|
97 | 99 | |
|
98 | 100 | |
|
99 | 101 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); |
|
100 | 102 | auto openRightInspectorAction = new QAction{QIcon{ |
|
101 | 103 | ":/icones/next.png", |
|
102 | 104 | }, |
|
103 | 105 | tr("Show/hide the right inspector"), this}; |
|
104 | 106 | |
|
105 | 107 | auto spacerRightTop = new QWidget{}; |
|
106 | 108 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
107 | 109 | |
|
108 | 110 | auto spacerRightBottom = new QWidget{}; |
|
109 | 111 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
110 | 112 | |
|
111 | 113 | rightSidePane->addWidget(spacerRightTop); |
|
112 | 114 | rightSidePane->addAction(openRightInspectorAction); |
|
113 | 115 | rightSidePane->addWidget(spacerRightBottom); |
|
114 | 116 | |
|
115 | 117 | openLeftInspectorAction->setCheckable(true); |
|
116 | 118 | openRightInspectorAction->setCheckable(true); |
|
117 | 119 | |
|
118 | 120 | auto openInspector = [this](bool checked, bool right, auto action) { |
|
119 | 121 | |
|
120 | 122 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); |
|
121 | 123 | |
|
122 | 124 | auto &lastInspectorSize |
|
123 | 125 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; |
|
124 | 126 | |
|
125 | 127 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() |
|
126 | 128 | : m_Ui->leftMainInspectorWidget->size(); |
|
127 | 129 | |
|
128 | 130 | // Update of the last opened geometry |
|
129 | 131 | if (checked) { |
|
130 | 132 | lastInspectorSize = nextInspectorSize; |
|
131 | 133 | } |
|
132 | 134 | |
|
133 | 135 | auto startSize = lastInspectorSize; |
|
134 | 136 | auto endSize = startSize; |
|
135 | 137 | endSize.setWidth(0); |
|
136 | 138 | |
|
137 | 139 | auto splitterInspectorIndex |
|
138 | 140 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; |
|
139 | 141 | |
|
140 | 142 | auto currentSizes = m_Ui->splitter->sizes(); |
|
141 | 143 | if (checked) { |
|
142 | 144 | // adjust sizes individually here, e.g. |
|
143 | 145 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); |
|
144 | 146 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); |
|
145 | 147 | m_Ui->splitter->setSizes(currentSizes); |
|
146 | 148 | } |
|
147 | 149 | else { |
|
148 | 150 | // adjust sizes individually here, e.g. |
|
149 | 151 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); |
|
150 | 152 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); |
|
151 | 153 | m_Ui->splitter->setSizes(currentSizes); |
|
152 | 154 | } |
|
153 | 155 | |
|
154 | 156 | }; |
|
155 | 157 | |
|
156 | 158 | |
|
157 | 159 | connect(openLeftInspectorAction, &QAction::triggered, |
|
158 | 160 | [openInspector, openLeftInspectorAction](bool checked) { |
|
159 | 161 | openInspector(checked, false, openLeftInspectorAction); |
|
160 | 162 | }); |
|
161 | 163 | connect(openRightInspectorAction, &QAction::triggered, |
|
162 | 164 | [openInspector, openRightInspectorAction](bool checked) { |
|
163 | 165 | openInspector(checked, true, openRightInspectorAction); |
|
164 | 166 | }); |
|
165 | 167 | |
|
166 | 168 | this->menuBar()->addAction(tr("File")); |
|
167 | 169 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); |
|
168 | 170 | |
|
169 | 171 | mainToolBar->addWidget(new TimeWidget{}); |
|
170 | 172 | |
|
171 | 173 | // Widgets / controllers connections |
|
172 | 174 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), |
|
173 | 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 | 181 | /* QLopGUI::registerMenuBar(menuBar()); |
|
176 | 182 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
|
177 | 183 | this->m_progressWidget = new QWidget(); |
|
178 | 184 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); |
|
179 | 185 | this->m_progressWidget->setLayout(this->m_progressLayout); |
|
180 | 186 | this->m_progressWidget->setWindowModality(Qt::WindowModal); |
|
181 | 187 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); |
|
182 | 188 | for(int i=0;i<OMP_THREADS;i++) |
|
183 | 189 | { |
|
184 | 190 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); |
|
185 | 191 | this->m_progress.last()->setMinimum(0); |
|
186 | 192 | this->m_progress.last()->setMaximum(100); |
|
187 | 193 | this->m_progressLayout->addWidget(this->m_progress.last()); |
|
188 | 194 | this->m_progressWidget->hide(); |
|
189 | 195 | this->m_progressThreadIds[i] = -1; |
|
190 | 196 | } |
|
191 | 197 | this->m_progressWidget->setWindowTitle("Loading File"); |
|
192 | 198 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() |
|
193 | 199 | << QLopCore::self() |
|
194 | 200 | << QLopPlotManager::self() |
|
195 | 201 | << QLopCodecManager::self() |
|
196 | 202 | << FileDownloader::self() |
|
197 | 203 | << QLopDataBase::self() |
|
198 | 204 | << SpaceData::self(); |
|
199 | 205 | |
|
200 | 206 | CDFCodec::registerToManager(); |
|
201 | 207 | AMDATXTCodec::registerToManager(); |
|
202 | 208 | |
|
203 | 209 | |
|
204 | 210 | for(int i=0;i<ServicesToLoad.count();i++) |
|
205 | 211 | { |
|
206 | 212 | qDebug()<<ServicesToLoad.at(i)->serviceName(); |
|
207 | 213 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI |
|
208 | 214 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); |
|
209 | 215 | if(wdgt) |
|
210 | 216 | { |
|
211 | 217 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
212 | 218 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); |
|
213 | 219 | } |
|
214 | 220 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); |
|
215 | 221 | }*/ |
|
216 | 222 | } |
|
217 | 223 | |
|
218 | 224 | MainWindow::~MainWindow() |
|
219 | 225 | { |
|
220 | 226 | } |
|
221 | 227 | |
|
222 | 228 | |
|
223 | 229 | void MainWindow::changeEvent(QEvent *e) |
|
224 | 230 | { |
|
225 | 231 | QMainWindow::changeEvent(e); |
|
226 | 232 | switch (e->type()) { |
|
227 | 233 | case QEvent::LanguageChange: |
|
228 | 234 | m_Ui->retranslateUi(this); |
|
229 | 235 | break; |
|
230 | 236 | default: |
|
231 | 237 | break; |
|
232 | 238 | } |
|
233 | 239 | } |
@@ -1,42 +1,52 | |||
|
1 | 1 | #ifndef SCIQLOP_VISUALIZATIONWIDGET_H |
|
2 | 2 | #define SCIQLOP_VISUALIZATIONWIDGET_H |
|
3 | 3 | |
|
4 | 4 | #include "Visualization/IVisualizationWidget.h" |
|
5 | 5 | |
|
6 | 6 | #include <QLoggingCategory> |
|
7 | 7 | #include <QWidget> |
|
8 | 8 | |
|
9 | class Variable; | |
|
9 | 10 | class VisualizationTabWidget; |
|
10 | 11 | |
|
11 | 12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) |
|
12 | 13 | |
|
13 | 14 | namespace Ui { |
|
14 | 15 | class VisualizationWidget; |
|
15 | 16 | } // namespace Ui |
|
16 | 17 | |
|
17 | 18 | class VisualizationWidget : public QWidget, public IVisualizationWidget { |
|
18 | 19 | Q_OBJECT |
|
19 | 20 | |
|
20 | 21 | public: |
|
21 | 22 | explicit VisualizationWidget(QWidget *parent = 0); |
|
22 | 23 | virtual ~VisualizationWidget(); |
|
23 | 24 | |
|
24 | 25 | /// Add a zone widget |
|
25 | 26 | virtual void addTab(VisualizationTabWidget *tabWidget); |
|
26 | 27 | |
|
27 | 28 | /// Create a tab using a Variable |
|
28 | 29 | VisualizationTabWidget *createTab(); |
|
29 | 30 | |
|
30 | 31 | /// Remove a tab |
|
31 | 32 | void removeTab(VisualizationTabWidget *tab); |
|
32 | 33 | |
|
33 | 34 | // IVisualizationWidget interface |
|
34 | 35 | void accept(IVisualizationWidget *visitor) override; |
|
35 | 36 | void close() override; |
|
36 | 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 | 48 | private: |
|
39 | 49 | Ui::VisualizationWidget *ui; |
|
40 | 50 | }; |
|
41 | 51 | |
|
42 | 52 | #endif // VISUALIZATIONWIDGET_H |
@@ -1,80 +1,85 | |||
|
1 | 1 | #include "Visualization/VisualizationWidget.h" |
|
2 | 2 | #include "Visualization/VisualizationTabWidget.h" |
|
3 | 3 | #include "Visualization/qcustomplot.h" |
|
4 | 4 | |
|
5 | 5 | #include "ui_VisualizationWidget.h" |
|
6 | 6 | |
|
7 | 7 | #include <QToolButton> |
|
8 | 8 | |
|
9 | 9 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") |
|
10 | 10 | |
|
11 | 11 | VisualizationWidget::VisualizationWidget(QWidget *parent) |
|
12 | 12 | : QWidget{parent}, ui{new Ui::VisualizationWidget} |
|
13 | 13 | { |
|
14 | 14 | ui->setupUi(this); |
|
15 | 15 | |
|
16 | 16 | auto addTabViewButton = new QToolButton{ui->tabWidget}; |
|
17 | 17 | addTabViewButton->setText(tr("Add View")); |
|
18 | 18 | addTabViewButton->setCursor(Qt::ArrowCursor); |
|
19 | 19 | addTabViewButton->setAutoRaise(true); |
|
20 | 20 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); |
|
21 | 21 | auto width = ui->tabWidget->cornerWidget()->width(); |
|
22 | 22 | auto height = ui->tabWidget->cornerWidget()->height(); |
|
23 | 23 | addTabViewButton->setMinimumHeight(height); |
|
24 | 24 | addTabViewButton->setMinimumWidth(width); |
|
25 | 25 | ui->tabWidget->setMinimumHeight(height); |
|
26 | 26 | ui->tabWidget->setMinimumWidth(width); |
|
27 | 27 | |
|
28 | 28 | auto addTabView = [&]() { |
|
29 | 29 | auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget), |
|
30 | 30 | QString("View %1").arg(ui->tabWidget->count() + 1)); |
|
31 | 31 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); |
|
32 | 32 | }; |
|
33 | 33 | |
|
34 | 34 | auto removeTabView = [&](int index) { |
|
35 | 35 | ui->tabWidget->removeTab(index); |
|
36 | 36 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); |
|
37 | 37 | }; |
|
38 | 38 | |
|
39 | 39 | ui->tabWidget->setTabsClosable(true); |
|
40 | 40 | |
|
41 | 41 | connect(addTabViewButton, &QToolButton::clicked, addTabView); |
|
42 | 42 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); |
|
43 | 43 | } |
|
44 | 44 | |
|
45 | 45 | VisualizationWidget::~VisualizationWidget() |
|
46 | 46 | { |
|
47 | 47 | delete ui; |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget) |
|
51 | 51 | { |
|
52 | 52 | // NOTE: check is this method has to be deleted because of its dupplicated version visible as |
|
53 | 53 | // lambda function (in the constructor) |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | VisualizationTabWidget *VisualizationWidget::createTab() |
|
57 | 57 | { |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | void VisualizationWidget::removeTab(VisualizationTabWidget *tab) |
|
61 | 61 | { |
|
62 | 62 | // NOTE: check is this method has to be deleted because of its dupplicated version visible as |
|
63 | 63 | // lambda function (in the constructor) |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | void VisualizationWidget::accept(IVisualizationWidget *visitor) |
|
67 | 67 | { |
|
68 | 68 | // TODO: manage the visitor |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | void VisualizationWidget::close() |
|
72 | 72 | { |
|
73 | 73 | // The main view cannot be directly closed. |
|
74 | 74 | return; |
|
75 | 75 | } |
|
76 | 76 | |
|
77 | 77 | QString VisualizationWidget::name() const |
|
78 | 78 | { |
|
79 | 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