##// END OF EJS Templates
Merge pull request 156 from SCIQLOP-Initialisation develop...
leroux -
r206:373baac343d6 merge
parent child
Show More
@@ -0,0 +1,14
1 #ifndef SCIQLOP_SQPDATETIME_H
2 #define SCIQLOP_SQPDATETIME_H
3
4 /**
5 * @brief The SqpDateTime struct holds the information of time parameters
6 */
7 struct SqpDateTime {
8 /// Start time
9 double m_TStart;
10 /// End time
11 double m_TEnd;
12 };
13
14 #endif // SCIQLOP_SQPDATETIME_H
@@ -0,0 +1,37
1 #ifndef SCIQLOP_TIMECONTROLLER_H
2 #define SCIQLOP_TIMECONTROLLER_H
3
4 #include <Data/SqpDateTime.h>
5
6 #include <QLoggingCategory>
7 #include <QObject>
8
9 #include <Common/spimpl.h>
10
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController)
13
14 /**
15 * @brief The TimeController class aims to handle the Time parameters notification in SciQlop.
16 */
17 class TimeController : public QObject {
18 Q_OBJECT
19 public:
20 explicit TimeController(QObject *parent = 0);
21
22 SqpDateTime dateTime() const noexcept;
23
24 signals:
25 /// Signal emitted to notify that time parameters has beed updated
26 void timeUpdated(SqpDateTime time);
27
28 public slots:
29 /// Slot called when a new dateTime has been defined. Call timeUpdated signal
30 void onTimeToUpdate(SqpDateTime dateTime);
31
32 private:
33 class TimeControllerPrivate;
34 spimpl::unique_impl_ptr<TimeControllerPrivate> impl;
35 };
36
37 #endif // SCIQLOP_TIMECONTROLLER_H
@@ -0,0 +1,26
1 #include "Time/TimeController.h"
2
3 Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController")
4
5 struct TimeController::TimeControllerPrivate {
6
7 SqpDateTime m_DateTime;
8 };
9
10 TimeController::TimeController(QObject *parent)
11 : QObject{parent}, impl{spimpl::make_unique_impl<TimeControllerPrivate>()}
12 {
13 qCDebug(LOG_TimeController()) << tr("TimeController construction");
14 }
15
16 SqpDateTime TimeController::dateTime() const noexcept
17 {
18 return impl->m_DateTime;
19 }
20
21 void TimeController::onTimeToUpdate(SqpDateTime dateTime)
22 {
23 impl->m_DateTime = dateTime;
24
25 emit timeUpdated(dateTime);
26 }
@@ -26,6 +26,7
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 <TimeWidget/TimeWidget.h>
30 #include <TimeWidget/TimeWidget.h>
30 #include <Variable/Variable.h>
31 #include <Variable/Variable.h>
31 #include <Visualization/VisualizationController.h>
32 #include <Visualization/VisualizationController.h>
@@ -168,12 +169,20 MainWindow::MainWindow(QWidget *parent)
168 this->menuBar()->addAction(tr("File"));
169 this->menuBar()->addAction(tr("File"));
169 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
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 // Widgets / controllers connections
175 // Widgets / controllers connections
176
177 // DataSource
174 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
178 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
175 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
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 qRegisterMetaType<std::shared_ptr<Variable> >();
186 qRegisterMetaType<std::shared_ptr<Variable> >();
178 connect(&sqpApp->visualizationController(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
187 connect(&sqpApp->visualizationController(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
179 m_Ui->view, SLOT(displayVariable(std::shared_ptr<Variable>)));
188 m_Ui->view, SLOT(displayVariable(std::shared_ptr<Variable>)));
@@ -1,16 +1,15
1 #ifndef SCIQLOP_DATAPROVIDERPARAMETERS_H
1 #ifndef SCIQLOP_DATAPROVIDERPARAMETERS_H
2 #define SCIQLOP_DATAPROVIDERPARAMETERS_H
2 #define SCIQLOP_DATAPROVIDERPARAMETERS_H
3
3
4 #include "SqpDateTime.h"
5
4 /**
6 /**
5 * @brief The DataProviderParameters struct holds the information needed to retrieve data from a
7 * @brief The DataProviderParameters struct holds the information needed to retrieve data from a
6 * data provider
8 * data provider
7 * @sa IDataProvider
9 * @sa IDataProvider
8 */
10 */
9 struct DataProviderParameters {
11 struct DataProviderParameters {
10 /// Start time
12 SqpDateTime m_Time;
11 double m_TStart;
12 /// End time
13 double m_TEnd;
14 };
13 };
15
14
16 #endif // SCIQLOP_DATAPROVIDERPARAMETERS_H
15 #endif // SCIQLOP_DATAPROVIDERPARAMETERS_H
@@ -7,6 +7,7
7 #include <Common/spimpl.h>
7 #include <Common/spimpl.h>
8
8
9 class IDataProvider;
9 class IDataProvider;
10 class TimeController;
10 class Variable;
11 class Variable;
11 class VariableModel;
12 class VariableModel;
12
13
@@ -23,6 +24,8 public:
23
24
24 VariableModel *variableModel() noexcept;
25 VariableModel *variableModel() noexcept;
25
26
27 void setTimeController(TimeController *timeController) noexcept;
28
26 signals:
29 signals:
27 /// Signal emitted when a variable has been created
30 /// Signal emitted when a variable has been created
28 void variableCreated(std::shared_ptr<Variable> variable);
31 void variableCreated(std::shared_ptr<Variable> variable);
@@ -4,6 +4,7
4 #include <Data/DataProviderParameters.h>
4 #include <Data/DataProviderParameters.h>
5 #include <Data/IDataProvider.h>
5 #include <Data/IDataProvider.h>
6 #include <Data/IDataSeries.h>
6 #include <Data/IDataSeries.h>
7 #include <Time/TimeController.h>
7
8
8 #include <QDateTime>
9 #include <QDateTime>
9 #include <QMutex>
10 #include <QMutex>
@@ -15,14 +16,10 namespace {
15
16
16 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
17 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
17 /// will be deleted when the timerange is recovered from SciQlop
18 /// will be deleted when the timerange is recovered from SciQlop
18 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider) noexcept
19 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
20 const SqpDateTime &dateTime) noexcept
19 {
21 {
20 auto parameters = DataProviderParameters{
22 auto parameters = DataProviderParameters{dateTime};
21 // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
22 static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
23 / 1000.),
24 static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
25 / 1000.};
26
23
27 return provider.retrieveData(parameters);
24 return provider.retrieveData(parameters);
28 }
25 }
@@ -38,6 +35,8 struct VariableController::VariableControllerPrivate {
38 QMutex m_WorkingMutex;
35 QMutex m_WorkingMutex;
39 /// Variable model. The VariableController has the ownership
36 /// Variable model. The VariableController has the ownership
40 VariableModel *m_VariableModel;
37 VariableModel *m_VariableModel;
38
39 TimeController *m_TimeController{nullptr};
41 };
40 };
42
41
43 VariableController::VariableController(QObject *parent)
42 VariableController::VariableController(QObject *parent)
@@ -59,16 +58,36 VariableModel *VariableController::variableModel() noexcept
59 return impl->m_VariableModel;
58 return impl->m_VariableModel;
60 }
59 }
61
60
61 void VariableController::setTimeController(TimeController *timeController) noexcept
62 {
63 impl->m_TimeController = timeController;
64 }
65
62 void VariableController::createVariable(const QString &name,
66 void VariableController::createVariable(const QString &name,
63 std::shared_ptr<IDataProvider> provider) noexcept
67 std::shared_ptr<IDataProvider> provider) noexcept
64 {
68 {
69 // TORM
70 // auto dateTime = SqpDateTime{
71 // // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
72 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
73 // / 1000.),
74 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
75 // / 1000.};
76
77 if (!impl->m_TimeController) {
78 qCCritical(LOG_VariableController())
79 << tr("Impossible to create variable: The time controller is null");
80 return;
81 }
82
83
65 /// @todo : for the moment :
84 /// @todo : for the moment :
66 /// - the provider is only used to retrieve data from the variable for its initialization, but
85 /// - the provider is only used to retrieve data from the variable for its initialization, but
67 /// it will be retained later
86 /// it will be retained later
68 /// - default data are generated for the variable, without taking into account the timerange set
87 /// - default data are generated for the variable, without taking into account the timerange set
69 /// in sciqlop
88 /// in sciqlop
70 if (auto newVariable
89 if (auto newVariable = impl->m_VariableModel->createVariable(
71 = impl->m_VariableModel->createVariable(name, generateDefaultDataSeries(*provider))) {
90 name, generateDefaultDataSeries(*provider, impl->m_TimeController->dateTime()))) {
72 emit variableCreated(newVariable);
91 emit variableCreated(newVariable);
73 }
92 }
74 }
93 }
@@ -16,6 +16,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
17
17
18 class DataSourceController;
18 class DataSourceController;
19 class TimeController;
19 class VariableController;
20 class VariableController;
20 class VisualizationController;
21 class VisualizationController;
21
22
@@ -37,6 +38,7 public:
37
38
38 /// Accessors for the differents sciqlop controllers
39 /// Accessors for the differents sciqlop controllers
39 DataSourceController &dataSourceController() noexcept;
40 DataSourceController &dataSourceController() noexcept;
41 TimeController &timeController() noexcept;
40 VariableController &variableController() noexcept;
42 VariableController &variableController() noexcept;
41 VisualizationController &visualizationController() noexcept;
43 VisualizationController &visualizationController() noexcept;
42
44
@@ -3,6 +3,8
3
3
4 #include <QWidget>
4 #include <QWidget>
5
5
6 #include <Data/SqpDateTime.h>
7
6 namespace Ui {
8 namespace Ui {
7 class TimeWidget;
9 class TimeWidget;
8 } // Ui
10 } // Ui
@@ -14,6 +16,15 public:
14 explicit TimeWidget(QWidget *parent = 0);
16 explicit TimeWidget(QWidget *parent = 0);
15 virtual ~TimeWidget();
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 private:
28 private:
18 Ui::TimeWidget *ui;
29 Ui::TimeWidget *ui;
19 };
30 };
@@ -19,7 +19,7 class VisualizationGraphWidget : public QWidget, public IVisualizationWidget {
19 Q_OBJECT
19 Q_OBJECT
20
20
21 public:
21 public:
22 explicit VisualizationGraphWidget(QWidget *parent = 0);
22 explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0);
23 virtual ~VisualizationGraphWidget();
23 virtual ~VisualizationGraphWidget();
24
24
25 void addVariable(std::shared_ptr<Variable> variable);
25 void addVariable(std::shared_ptr<Variable> variable);
@@ -3,8 +3,11
3
3
4 #include "Visualization/IVisualizationWidget.h"
4 #include "Visualization/IVisualizationWidget.h"
5
5
6 #include <Common/spimpl.h>
7
6 #include <QWidget>
8 #include <QWidget>
7
9
10 class Variable;
8 class VisualizationZoneWidget;
11 class VisualizationZoneWidget;
9
12
10 namespace Ui {
13 namespace Ui {
@@ -15,14 +18,19 class VisualizationTabWidget : public QWidget, public IVisualizationWidget {
15 Q_OBJECT
18 Q_OBJECT
16
19
17 public:
20 public:
18 explicit VisualizationTabWidget(QWidget *parent = 0);
21 explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0);
19 virtual ~VisualizationTabWidget();
22 virtual ~VisualizationTabWidget();
20
23
21 /// Add a zone widget
24 /// Add a zone widget
22 void addZone(VisualizationZoneWidget *zoneWidget);
25 void addZone(VisualizationZoneWidget *zoneWidget);
23
26
24 /// Create a zone using a Variable
27 /**
25 VisualizationZoneWidget *createZone();
28 * Creates a zone using a variable. The variable will be displayed in a new graph of the new
29 * zone.
30 * @param variable the variable for which to create the zone
31 * @return the pointer to the created zone
32 */
33 VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable);
26
34
27 /// Remove a zone
35 /// Remove a zone
28 void removeZone(VisualizationZoneWidget *zone);
36 void removeZone(VisualizationZoneWidget *zone);
@@ -34,6 +42,9 public:
34
42
35 private:
43 private:
36 Ui::VisualizationTabWidget *ui;
44 Ui::VisualizationTabWidget *ui;
45
46 class VisualizationTabWidgetPrivate;
47 spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl;
37 };
48 };
38
49
39 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
50 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
@@ -3,26 +3,31
3
3
4 #include "Visualization/IVisualizationWidget.h"
4 #include "Visualization/IVisualizationWidget.h"
5
5
6 class VisualizationGraphWidget;
7
8 #include <QWidget>
6 #include <QWidget>
9
7
10 namespace Ui {
8 namespace Ui {
11 class VisualizationZoneWidget;
9 class VisualizationZoneWidget;
12 } // Ui
10 } // Ui
13
11
12 class Variable;
13 class VisualizationGraphWidget;
14
14 class VisualizationZoneWidget : public QWidget, public IVisualizationWidget {
15 class VisualizationZoneWidget : public QWidget, public IVisualizationWidget {
15 Q_OBJECT
16 Q_OBJECT
16
17
17 public:
18 public:
18 explicit VisualizationZoneWidget(QWidget *parent = 0);
19 explicit VisualizationZoneWidget(const QString &name = {}, QWidget *parent = 0);
19 virtual ~VisualizationZoneWidget();
20 virtual ~VisualizationZoneWidget();
20
21
21 /// Add a graph widget
22 /// Add a graph widget
22 void addGraph(VisualizationGraphWidget *graphWidget);
23 void addGraph(VisualizationGraphWidget *graphWidget);
23
24
24 /// Create a graph using a Variable
25 /**
25 VisualizationGraphWidget *createGraph();
26 * Creates a graph using a variable. The variable will be displayed in the new graph.
27 * @param variable the variable for which to create the graph
28 * @return the pointer to the created graph
29 */
30 VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable);
26
31
27 /// Remove a graph
32 /// Remove a graph
28 void removeGraph(VisualizationGraphWidget *graph);
33 void removeGraph(VisualizationGraphWidget *graph);
@@ -3,6 +3,7
3 #include <Data/IDataProvider.h>
3 #include <Data/IDataProvider.h>
4 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceController.h>
5 #include <QThread>
5 #include <QThread>
6 #include <Time/TimeController.h>
6 #include <Variable/Variable.h>
7 #include <Variable/Variable.h>
7 #include <Variable/VariableController.h>
8 #include <Variable/VariableController.h>
8 #include <Visualization/VisualizationController.h>
9 #include <Visualization/VisualizationController.h>
@@ -13,6 +14,7 class SqpApplication::SqpApplicationPrivate {
13 public:
14 public:
14 SqpApplicationPrivate()
15 SqpApplicationPrivate()
15 : m_DataSourceController{std::make_unique<DataSourceController>()},
16 : m_DataSourceController{std::make_unique<DataSourceController>()},
17 m_TimeController{std::make_unique<TimeController>()},
16 m_VariableController{std::make_unique<VariableController>()},
18 m_VariableController{std::make_unique<VariableController>()},
17 m_VisualizationController{std::make_unique<VisualizationController>()}
19 m_VisualizationController{std::make_unique<VisualizationController>()}
18 {
20 {
@@ -36,6 +38,9 public:
36 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
38 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
37 m_VariableController->moveToThread(&m_VariableControllerThread);
39 m_VariableController->moveToThread(&m_VariableControllerThread);
38 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
40 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
41
42 // Additionnal init
43 m_VariableController->setTimeController(m_TimeController.get());
39 }
44 }
40
45
41 virtual ~SqpApplicationPrivate()
46 virtual ~SqpApplicationPrivate()
@@ -53,6 +58,7 public:
53
58
54 std::unique_ptr<DataSourceController> m_DataSourceController;
59 std::unique_ptr<DataSourceController> m_DataSourceController;
55 std::unique_ptr<VariableController> m_VariableController;
60 std::unique_ptr<VariableController> m_VariableController;
61 std::unique_ptr<TimeController> m_TimeController;
56 std::unique_ptr<VisualizationController> m_VisualizationController;
62 std::unique_ptr<VisualizationController> m_VisualizationController;
57 QThread m_DataSourceControllerThread;
63 QThread m_DataSourceControllerThread;
58 QThread m_VariableControllerThread;
64 QThread m_VariableControllerThread;
@@ -98,6 +104,11 DataSourceController &SqpApplication::dataSourceController() noexcept
98 return *impl->m_DataSourceController;
104 return *impl->m_DataSourceController;
99 }
105 }
100
106
107 TimeController &SqpApplication::timeController() noexcept
108 {
109 return *impl->m_TimeController;
110 }
111
101 VariableController &SqpApplication::variableController() noexcept
112 VariableController &SqpApplication::variableController() noexcept
102 {
113 {
103 return *impl->m_VariableController;
114 return *impl->m_VariableController;
@@ -1,12 +1,29
1 #include "TimeWidget/TimeWidget.h"
1 #include "TimeWidget/TimeWidget.h"
2 #include "ui_TimeWidget.h"
2 #include "ui_TimeWidget.h"
3
3
4
4 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
5 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
5 {
6 {
6 ui->setupUi(this);
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 TimeWidget::~TimeWidget()
17 TimeWidget::~TimeWidget()
10 {
18 {
11 delete ui;
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 }
@@ -22,13 +22,17 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
22 std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap;
22 std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap;
23 };
23 };
24
24
25 VisualizationGraphWidget::VisualizationGraphWidget(QWidget *parent)
25 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent)
26 : QWidget{parent},
26 : QWidget{parent},
27 ui{new Ui::VisualizationGraphWidget},
27 ui{new Ui::VisualizationGraphWidget},
28 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
28 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
29 {
29 {
30 ui->setupUi(this);
30 ui->setupUi(this);
31
31
32 // qcpplot title
33 ui->widget->plotLayout()->insertRow(0);
34 ui->widget->plotLayout()->addElement(0, 0, new QCPTextElement{ui->widget, name});
35
32 // Set qcpplot properties :
36 // Set qcpplot properties :
33 // - Drag (on x-axis) and zoom are enabled
37 // - Drag (on x-axis) and zoom are enabled
34 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
38 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
@@ -65,7 +69,12 void VisualizationGraphWidget::close()
65
69
66 QString VisualizationGraphWidget::name() const
70 QString VisualizationGraphWidget::name() const
67 {
71 {
68 return QStringLiteral("MainView");
72 if (auto title = dynamic_cast<QCPTextElement *>(ui->widget->plotLayout()->elementAt(0))) {
73 return title->text();
74 }
75 else {
76 return QString{};
77 }
69 }
78 }
70
79
71 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
80 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
@@ -3,9 +3,34
3
3
4 #include "Visualization/VisualizationZoneWidget.h"
4 #include "Visualization/VisualizationZoneWidget.h"
5
5
6 namespace {
6
7
7 VisualizationTabWidget::VisualizationTabWidget(QWidget *parent)
8 /// Generates a default name for a new zone, according to the number of zones already displayed in
8 : QWidget{parent}, ui{new Ui::VisualizationTabWidget}
9 /// the tab
10 QString defaultZoneName(const QLayout &layout)
11 {
12 auto count = 0;
13 for (auto i = 0; i < layout.count(); ++i) {
14 if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) {
15 count++;
16 }
17 }
18
19 return QObject::tr("Zone %1").arg(count + 1);
20 }
21
22 } // namespace
23
24 struct VisualizationTabWidget::VisualizationTabWidgetPrivate {
25 explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {}
26
27 QString m_Name;
28 };
29
30 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent)
31 : QWidget{parent},
32 ui{new Ui::VisualizationTabWidget},
33 impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)}
9 {
34 {
10 ui->setupUi(this);
35 ui->setupUi(this);
11 }
36 }
@@ -20,11 +45,14 void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget)
20 this->layout()->addWidget(zoneWidget);
45 this->layout()->addWidget(zoneWidget);
21 }
46 }
22
47
23 VisualizationZoneWidget *VisualizationTabWidget::createZone()
48 VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable)
24 {
49 {
25 auto zoneWidget = new VisualizationZoneWidget{this};
50 auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this};
26 this->addZone(zoneWidget);
51 this->addZone(zoneWidget);
27
52
53 // Creates a new graph into the zone
54 zoneWidget->createGraph(variable);
55
28 return zoneWidget;
56 return zoneWidget;
29 }
57 }
30
58
@@ -45,5 +73,5 void VisualizationTabWidget::close()
45
73
46 QString VisualizationTabWidget::name() const
74 QString VisualizationTabWidget::name() const
47 {
75 {
48 return QStringLiteral("MainView");
76 return impl->m_Name;
49 }
77 }
@@ -32,8 +32,9 VisualizationWidget::VisualizationWidget(QWidget *parent)
32 };
32 };
33
33
34 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
34 auto addTabView = [this, enableMinimumCornerWidgetSize]() {
35 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
35 auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1),
36 QString("View %1").arg(ui->tabWidget->count() + 1));
36 ui->tabWidget};
37 auto index = ui->tabWidget->addTab(widget, widget->name());
37 if (ui->tabWidget->count() > 0) {
38 if (ui->tabWidget->count() > 0) {
38 enableMinimumCornerWidgetSize(false);
39 enableMinimumCornerWidgetSize(false);
39 }
40 }
@@ -54,6 +55,9 VisualizationWidget::VisualizationWidget(QWidget *parent)
54
55
55 connect(addTabViewButton, &QToolButton::clicked, addTabView);
56 connect(addTabViewButton, &QToolButton::clicked, addTabView);
56 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
57 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
58
59 // Adds default tab
60 addTabView();
57 }
61 }
58
62
59 VisualizationWidget::~VisualizationWidget()
63 VisualizationWidget::~VisualizationWidget()
@@ -96,16 +100,7 QString VisualizationWidget::name() const
96 void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
100 void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
97 {
101 {
98 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
102 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
99 if (auto newZone = currentTab->createZone()) {
103 if (!currentTab->createZone(variable)) {
100 if (auto newGraph = newZone->createGraph()) {
101 newGraph->addVariable(variable);
102 }
103 else {
104 qCCritical(LOG_VisualizationWidget())
105 << tr("Can't display the variable : can't create the graph");
106 }
107 }
108 else {
109 qCCritical(LOG_VisualizationWidget())
104 qCCritical(LOG_VisualizationWidget())
110 << tr("Can't display the variable : can't create a new zone in the current tab");
105 << tr("Can't display the variable : can't create a new zone in the current tab");
111 }
106 }
@@ -3,10 +3,30
3
3
4 #include "Visualization/VisualizationGraphWidget.h"
4 #include "Visualization/VisualizationGraphWidget.h"
5
5
6 VisualizationZoneWidget::VisualizationZoneWidget(QWidget *parent)
6 namespace {
7
8 /// Generates a default name for a new graph, according to the number of graphs already displayed in
9 /// the zone
10 QString defaultGraphName(const QLayout &layout)
11 {
12 auto count = 0;
13 for (auto i = 0; i < layout.count(); ++i) {
14 if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) {
15 count++;
16 }
17 }
18
19 return QObject::tr("Graph %1").arg(count + 1);
20 }
21
22 } // namespace
23
24 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent)
7 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
25 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
8 {
26 {
9 ui->setupUi(this);
27 ui->setupUi(this);
28
29 ui->zoneNameLabel->setText(name);
10 }
30 }
11
31
12 VisualizationZoneWidget::~VisualizationZoneWidget()
32 VisualizationZoneWidget::~VisualizationZoneWidget()
@@ -19,11 +39,14 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
19 ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
39 ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
20 }
40 }
21
41
22 VisualizationGraphWidget *VisualizationZoneWidget::createGraph()
42 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable)
23 {
43 {
24 auto graphWidget = new VisualizationGraphWidget{this};
44 auto graphWidget = new VisualizationGraphWidget{
45 defaultGraphName(*ui->visualizationZoneFrame->layout()), this};
25 this->addGraph(graphWidget);
46 this->addGraph(graphWidget);
26
47
48 graphWidget->addVariable(variable);
49
27 return graphWidget;
50 return graphWidget;
28 }
51 }
29
52
@@ -44,5 +67,5 void VisualizationZoneWidget::close()
44
67
45 QString VisualizationZoneWidget::name() const
68 QString VisualizationZoneWidget::name() const
46 {
69 {
47 return QStringLiteral("MainView");
70 return ui->zoneNameLabel->text();
48 }
71 }
@@ -17,25 +17,12
17 <item>
17 <item>
18 <widget class="QTabWidget" name="tabWidget">
18 <widget class="QTabWidget" name="tabWidget">
19 <property name="currentIndex">
19 <property name="currentIndex">
20 <number>0</number>
20 <number>-1</number>
21 </property>
21 </property>
22 <widget class="VisualizationTabWidget" name="firstView">
23 <attribute name="title">
24 <string>View 1</string>
25 </attribute>
26 </widget>
27 </widget>
22 </widget>
28 </item>
23 </item>
29 </layout>
24 </layout>
30 </widget>
25 </widget>
31 <customwidgets>
32 <customwidget>
33 <class>VisualizationTabWidget</class>
34 <extends>QWidget</extends>
35 <header location="global">Visualization/VisualizationTabWidget.h</header>
36 <container>1</container>
37 </customwidget>
38 </customwidgets>
39 <resources/>
26 <resources/>
40 <connections/>
27 <connections/>
41 </ui>
28 </ui>
@@ -14,23 +14,49
14 <string>Form</string>
14 <string>Form</string>
15 </property>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout_2">
16 <layout class="QVBoxLayout" name="verticalLayout_2">
17 <property name="spacing">
17 <item>
18 <number>3</number>
18 <widget class="QWidget" name="infobar" native="true">
19 </property>
19 <property name="sizePolicy">
20 <property name="leftMargin">
20 <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
21 <number>0</number>
21 <horstretch>0</horstretch>
22 </property>
22 <verstretch>0</verstretch>
23 <property name="topMargin">
23 </sizepolicy>
24 <number>0</number>
24 </property>
25 </property>
25 <layout class="QHBoxLayout" name="horizontalLayout">
26 <property name="rightMargin">
26 <property name="leftMargin">
27 <number>0</number>
27 <number>0</number>
28 </property>
28 </property>
29 <property name="bottomMargin">
29 <property name="topMargin">
30 <number>0</number>
30 <number>0</number>
31 </property>
31 </property>
32 <property name="rightMargin">
33 <number>0</number>
34 </property>
35 <property name="bottomMargin">
36 <number>0</number>
37 </property>
38 <item>
39 <widget class="QLabel" name="zoneNameLabel">
40 <property name="styleSheet">
41 <string notr="true">color: rgb(127, 127, 127);
42 </string>
43 </property>
44 <property name="text">
45 <string>TextLabel</string>
46 </property>
47 </widget>
48 </item>
49 </layout>
50 </widget>
51 </item>
32 <item>
52 <item>
33 <widget class="QFrame" name="visualizationZoneFrame">
53 <widget class="QFrame" name="visualizationZoneFrame">
54 <property name="sizePolicy">
55 <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
56 <horstretch>0</horstretch>
57 <verstretch>0</verstretch>
58 </sizepolicy>
59 </property>
34 <property name="frameShape">
60 <property name="frameShape">
35 <enum>QFrame::Box</enum>
61 <enum>QFrame::Box</enum>
36 </property>
62 </property>
@@ -8,4 +8,6 SqpApplication\.h:\d+:.IPSIS_S04_VARIABLE.*found: sqpApp
8
8
9 # Ignore false positive relative to unnamed namespace
9 # Ignore false positive relative to unnamed namespace
10 DataSourceTreeWidgetItem\.cpp:\d+:.*IPSIS_F13.*
10 DataSourceTreeWidgetItem\.cpp:\d+:.*IPSIS_F13.*
11 VisualizationTabWidget\.cpp:\d+:.*IPSIS_F13.*
12 VisualizationZoneWidget\.cpp:\d+:.*IPSIS_F13.*
11
13
@@ -8,9 +8,11
8 std::unique_ptr<IDataSeries>
8 std::unique_ptr<IDataSeries>
9 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
9 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
10 {
10 {
11 auto dateTime = parameters.m_Time;
12
11 // Gets the timerange from the parameters
13 // Gets the timerange from the parameters
12 auto start = parameters.m_TStart;
14 auto start = dateTime.m_TStart;
13 auto end = parameters.m_TEnd;
15 auto end = dateTime.m_TEnd;
14
16
15 // We assure that timerange is valid
17 // We assure that timerange is valid
16 if (end < start) {
18 if (end < start) {
General Comments 0
You need to be logged in to leave comments. Login now