Auto status change to "Under Review"
@@ -30,6 +30,8 struct VisualizationGraphHelper { | |||||
30 | */ |
|
30 | */ | |
31 | static QVector<QCPAbstractPlottable *> create(std::shared_ptr<Variable> variable, |
|
31 | static QVector<QCPAbstractPlottable *> create(std::shared_ptr<Variable> variable, | |
32 | QCustomPlot &plot) noexcept; |
|
32 | QCustomPlot &plot) noexcept; | |
|
33 | static QVector<QCPAbstractPlottable *> createV2(std::shared_ptr<Variable> variable, | |||
|
34 | QCustomPlot &plot) noexcept; | |||
33 |
|
35 | |||
34 | static void updateData(QVector<QCPAbstractPlottable *> plotableVect, |
|
36 | static void updateData(QVector<QCPAbstractPlottable *> plotableVect, | |
35 | std::shared_ptr<IDataSeries> dataSeries, const SqpRange &dateTime); |
|
37 | std::shared_ptr<IDataSeries> dataSeries, const SqpRange &dateTime); |
@@ -30,12 +30,13 public: | |||||
30 | /// If acquisition isn't enable, requestDataLoading signal cannot be emit |
|
30 | /// If acquisition isn't enable, requestDataLoading signal cannot be emit | |
31 | void enableAcquisition(bool enable); |
|
31 | void enableAcquisition(bool enable); | |
32 |
|
32 | |||
33 | void addVariable(std::shared_ptr<Variable> variable); |
|
33 | void addVariable(std::shared_ptr<Variable> variable, SqpRange range); | |
34 | void addVariableUsingGraph(std::shared_ptr<Variable> variable); |
|
34 | ||
35 | /// Removes a variable from the graph |
|
35 | /// Removes a variable from the graph | |
36 | void removeVariable(std::shared_ptr<Variable> variable) noexcept; |
|
36 | void removeVariable(std::shared_ptr<Variable> variable) noexcept; | |
37 |
|
37 | |||
38 | void setRange(std::shared_ptr<Variable> variable, const SqpRange &range); |
|
38 | void setRange(std::shared_ptr<Variable> variable, const SqpRange &range); | |
|
39 | void setYRange(const SqpRange &range); | |||
39 | SqpRange graphRange() const noexcept; |
|
40 | SqpRange graphRange() const noexcept; | |
40 | void setGraphRange(const SqpRange &range); |
|
41 | void setGraphRange(const SqpRange &range); | |
41 |
|
42 |
@@ -79,6 +79,29 void updateScalarData(QCPAbstractPlottable *component, std::shared_ptr<ScalarSer | |||||
79 | } |
|
79 | } | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
|
82 | QCPAbstractPlottable *createScalarSeriesComponentV2(std::shared_ptr<ScalarSeries> scalarSeries, | |||
|
83 | QCustomPlot &plot) | |||
|
84 | { | |||
|
85 | auto component = plot.addGraph(); | |||
|
86 | ||||
|
87 | if (component) { | |||
|
88 | // Axes properties | |||
|
89 | /// @todo : for the moment, no control is performed on the axes: the units and the tickers | |||
|
90 | /// are fixed for the default x-axis and y-axis of the plot, and according to the new graph | |||
|
91 | ||||
|
92 | auto setAxisProperties = [](auto axis, const auto &unit) { | |||
|
93 | // label (unit name) | |||
|
94 | axis->setLabel(unit.m_Name); | |||
|
95 | ||||
|
96 | // ticker (depending on the type of unit) | |||
|
97 | axis->setTicker(axisTicker(unit.m_TimeUnit)); | |||
|
98 | }; | |||
|
99 | setAxisProperties(plot.xAxis, scalarSeries->xAxisUnit()); | |||
|
100 | setAxisProperties(plot.yAxis, scalarSeries->valuesUnit()); | |||
|
101 | } | |||
|
102 | return component; | |||
|
103 | } | |||
|
104 | ||||
82 | QCPAbstractPlottable *createScalarSeriesComponent(std::shared_ptr<ScalarSeries> scalarSeries, |
|
105 | QCPAbstractPlottable *createScalarSeriesComponent(std::shared_ptr<ScalarSeries> scalarSeries, | |
83 | QCustomPlot &plot, const SqpRange &dateTime) |
|
106 | QCustomPlot &plot, const SqpRange &dateTime) | |
84 | { |
|
107 | { | |
@@ -119,6 +142,30 QCPAbstractPlottable *createScalarSeriesComponent(std::shared_ptr<ScalarSeries> | |||||
119 |
|
142 | |||
120 | } // namespace |
|
143 | } // namespace | |
121 |
|
144 | |||
|
145 | QVector<QCPAbstractPlottable *> | |||
|
146 | VisualizationGraphHelper::createV2(std::shared_ptr<Variable> variable, QCustomPlot &plot) noexcept | |||
|
147 | { | |||
|
148 | auto result = QVector<QCPAbstractPlottable *>{}; | |||
|
149 | ||||
|
150 | if (variable) { | |||
|
151 | // Gets the data series of the variable to call the creation of the right components | |||
|
152 | // according to its type | |||
|
153 | if (auto scalarSeries = std::dynamic_pointer_cast<ScalarSeries>(variable->dataSeries())) { | |||
|
154 | result.append(createScalarSeriesComponentV2(scalarSeries, plot)); | |||
|
155 | } | |||
|
156 | else { | |||
|
157 | qCDebug(LOG_VisualizationGraphHelper()) | |||
|
158 | << QObject::tr("Can't create graph plottables : unmanaged data series type"); | |||
|
159 | } | |||
|
160 | } | |||
|
161 | else { | |||
|
162 | qCDebug(LOG_VisualizationGraphHelper()) | |||
|
163 | << QObject::tr("Can't create graph plottables : the variable is null"); | |||
|
164 | } | |||
|
165 | ||||
|
166 | return result; | |||
|
167 | } | |||
|
168 | ||||
122 | QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable, |
|
169 | QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable, | |
123 | QCustomPlot &plot) noexcept |
|
170 | QCustomPlot &plot) noexcept | |
124 | { |
|
171 | { |
@@ -93,13 +93,10 void VisualizationGraphWidget::enableAcquisition(bool enable) | |||||
93 | impl->m_DoAcquisition = enable; |
|
93 | impl->m_DoAcquisition = enable; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) |
|
96 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, SqpRange range) | |
97 | { |
|
97 | { | |
98 | auto calibrationState = impl->m_IsCalibration; |
|
|||
99 | impl->m_IsCalibration = true; |
|
|||
100 | // Uses delegate to create the qcpplot components according to the variable |
|
98 | // Uses delegate to create the qcpplot components according to the variable | |
101 | auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget); |
|
99 | auto createdPlottables = VisualizationGraphHelper::createV2(variable, *ui->widget); | |
102 | impl->m_IsCalibration = calibrationState; |
|
|||
103 |
|
100 | |||
104 | for (auto createdPlottable : qAsConst(createdPlottables)) { |
|
101 | for (auto createdPlottable : qAsConst(createdPlottables)) { | |
105 | impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); |
|
102 | impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); | |
@@ -107,18 +104,16 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) | |||||
107 |
|
104 | |||
108 | connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); |
|
105 | connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); | |
109 |
|
106 | |||
110 | emit variableAdded(variable); |
|
107 | auto varRange = variable->range(); | |
111 | } |
|
|||
112 | void VisualizationGraphWidget::addVariableUsingGraph(std::shared_ptr<Variable> variable) |
|
|||
113 | { |
|
|||
114 | // Uses delegate to create the qcpplot components according to the variable |
|
|||
115 | this->addVariable(variable); |
|
|||
116 |
|
108 | |||
117 | // Request range for the variable |
|
109 | this->enableAcquisition(false); | |
118 | auto graphRange = ui->widget->xAxis->range(); |
|
110 | this->setGraphRange(range); | |
|
111 | this->enableAcquisition(true); | |||
119 |
|
112 | |||
120 | emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, |
|
113 | emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, range, varRange, | |
121 | SqpRange{graphRange.lower, graphRange.upper}, variable->range(), false); |
|
114 | false); | |
|
115 | ||||
|
116 | emit variableAdded(variable); | |||
122 | } |
|
117 | } | |
123 |
|
118 | |||
124 | void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept |
|
119 | void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept | |
@@ -147,6 +142,11 void VisualizationGraphWidget::setRange(std::shared_ptr<Variable> variable, cons | |||||
147 | ui->widget->replot(); |
|
142 | ui->widget->replot(); | |
148 | } |
|
143 | } | |
149 |
|
144 | |||
|
145 | void VisualizationGraphWidget::setYRange(const SqpRange &range) | |||
|
146 | { | |||
|
147 | ui->widget->yAxis->setRange(range.m_TStart, range.m_TEnd); | |||
|
148 | } | |||
|
149 | ||||
150 | SqpRange VisualizationGraphWidget::graphRange() const noexcept |
|
150 | SqpRange VisualizationGraphWidget::graphRange() const noexcept | |
151 | { |
|
151 | { | |
152 | auto graphRange = ui->widget->xAxis->range(); |
|
152 | auto graphRange = ui->widget->xAxis->range(); |
@@ -6,6 +6,7 | |||||
6 | #include "ui_VisualizationZoneWidget.h" |
|
6 | #include "ui_VisualizationZoneWidget.h" | |
7 |
|
7 | |||
8 | #include <Data/SqpRange.h> |
|
8 | #include <Data/SqpRange.h> | |
|
9 | #include <Variable/Variable.h> | |||
9 | #include <Variable/VariableController.h> |
|
10 | #include <Variable/VariableController.h> | |
10 |
|
11 | |||
11 | #include <QUuid> |
|
12 | #include <QUuid> | |
@@ -168,9 +169,27 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
168 | connect(graphWidget, &VisualizationGraphWidget::variableAdded, this, |
|
169 | connect(graphWidget, &VisualizationGraphWidget::variableAdded, this, | |
169 | &VisualizationZoneWidget::onVariableAdded); |
|
170 | &VisualizationZoneWidget::onVariableAdded); | |
170 |
|
171 | |||
|
172 | auto range = SqpRange{}; | |||
|
173 | ||||
|
174 | // Apply visitor to graph children | |||
|
175 | auto layout = ui->visualizationZoneFrame->layout(); | |||
|
176 | if (layout->count() > 0) { | |||
|
177 | // Case of a new graph in a existant zone | |||
|
178 | if (auto visualizationGraphWidget | |||
|
179 | = dynamic_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) { | |||
|
180 | range = visualizationGraphWidget->graphRange(); | |||
|
181 | } | |||
|
182 | } | |||
|
183 | else { | |||
|
184 | // Case of a new graph as the first of the zone | |||
|
185 | range = variable->range(); | |||
|
186 | } | |||
|
187 | ||||
171 | this->addGraph(graphWidget); |
|
188 | this->addGraph(graphWidget); | |
172 |
|
189 | |||
173 | graphWidget->addVariable(variable); |
|
190 | graphWidget->addVariable(variable, range); | |
|
191 | // TODO: get y using variable range | |||
|
192 | graphWidget->setYRange(SqpRange{-10, 10}); | |||
174 |
|
193 | |||
175 | return graphWidget; |
|
194 | return graphWidget; | |
176 | } |
|
195 | } |
@@ -155,6 +155,7 void GenerateVariableMenuOperation::visitEnter(VisualizationZoneWidget *zoneWidg | |||||
155 |
|
155 | |||
156 | void GenerateVariableMenuOperation::visitLeave(VisualizationZoneWidget *zoneWidget) |
|
156 | void GenerateVariableMenuOperation::visitLeave(VisualizationZoneWidget *zoneWidget) | |
157 | { |
|
157 | { | |
|
158 | qCCritical(LOG_GenerateVariableMenuOperation(), "Open in a new graph DETECTED !!"); | |||
158 | if (zoneWidget) { |
|
159 | if (zoneWidget) { | |
159 | // 'Plot' menu |
|
160 | // 'Plot' menu | |
160 | impl->visitNodeLeavePlot( |
|
161 | impl->visitNodeLeavePlot( | |
@@ -181,7 +182,7 void GenerateVariableMenuOperation::visit(VisualizationGraphWidget *graphWidget) | |||||
181 | impl->visitLeafPlot(*graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()), |
|
182 | impl->visitLeafPlot(*graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()), | |
182 | [ varW = std::weak_ptr<Variable>{impl->m_Variable}, graphWidget ]() { |
|
183 | [ varW = std::weak_ptr<Variable>{impl->m_Variable}, graphWidget ]() { | |
183 | if (auto var = varW.lock()) { |
|
184 | if (auto var = varW.lock()) { | |
184 |
graphWidget->addVariable |
|
185 | graphWidget->addVariable(var, graphWidget->graphRange()); | |
185 | } |
|
186 | } | |
186 | }); |
|
187 | }); | |
187 |
|
188 |
@@ -73,7 +73,7 void CosinusProvider::requestDataLoading(QUuid acqIdentifier, | |||||
73 | { |
|
73 | { | |
74 | // TODO: Add Mutex |
|
74 | // TODO: Add Mutex | |
75 | m_VariableToEnableProvider[acqIdentifier] = true; |
|
75 | m_VariableToEnableProvider[acqIdentifier] = true; | |
76 | qCDebug(LOG_CosinusProvider()) << "CosinusProvider::requestDataLoading" |
|
76 | qCDebug(LOG_CosinusProvider()) << "TORM: CosinusProvider::requestDataLoading" | |
77 | << QThread::currentThread()->objectName(); |
|
77 | << QThread::currentThread()->objectName(); | |
78 | // NOTE: Try to use multithread if possible |
|
78 | // NOTE: Try to use multithread if possible | |
79 | const auto times = parameters.m_Times; |
|
79 | const auto times = parameters.m_Times; | |
@@ -81,7 +81,7 void CosinusProvider::requestDataLoading(QUuid acqIdentifier, | |||||
81 | for (const auto &dateTime : qAsConst(times)) { |
|
81 | for (const auto &dateTime : qAsConst(times)) { | |
82 | if (m_VariableToEnableProvider[acqIdentifier]) { |
|
82 | if (m_VariableToEnableProvider[acqIdentifier]) { | |
83 | auto scalarSeries = this->retrieveData(acqIdentifier, dateTime); |
|
83 | auto scalarSeries = this->retrieveData(acqIdentifier, dateTime); | |
84 |
qC |
|
84 | qCDebug(LOG_CosinusProvider()) << "TORM: CosinusProvider::dataProvided"; | |
85 | emit dataProvided(acqIdentifier, scalarSeries, dateTime); |
|
85 | emit dataProvided(acqIdentifier, scalarSeries, dateTime); | |
86 | } |
|
86 | } | |
87 | } |
|
87 | } |
General Comments 1
You need to be logged in to leave comments.
Login now