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

Pull request updated. Auto status change to "Under Review"

Changed commits:
  * 1 added
  * 0 removed

Changed files:
  * M gui/include/Visualization/VisualizationGraphWidget.h
  * M gui/src/Visualization/VisualizationGraphWidget.cpp
Approved
author

Status change > Approved

You need to be logged in to leave comments. Login now