##// END OF EJS Templates
Remove old graph from selected zones
trabillard -
r1345:4139acc0b06b
parent child
Show More
@@ -48,26 +48,6 public:
48 */
48 */
49 std::shared_ptr<Variable> cloneVariable(std::shared_ptr<Variable> variable) noexcept;
49 std::shared_ptr<Variable> cloneVariable(std::shared_ptr<Variable> variable) noexcept;
50
50
51 /**
52 * Deletes from the controller the variable passed in parameter.
53 *
54 * Delete a variable includes:
55 * - the deletion of the various references to the variable in SciQlop
56 * - the deletion of the model variable
57 * - the deletion of the provider associated with the variable
58 * - removing the cache associated with the variable
59 *
60 * @param variable the variable to delete from the controller.
61 */
62 void deleteVariable(std::shared_ptr<Variable> variable) noexcept;
63
64 /**
65 * Deletes from the controller the variables passed in parameter.
66 * @param variables the variables to delete from the controller.
67 * @sa deleteVariable()
68 */
69 void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept;
70
71 /// Returns the MIME data associated to a list of variables
51 /// Returns the MIME data associated to a list of variables
72 QByteArray mimeDataForVariables(const QList<std::shared_ptr<Variable> > &variables) const;
52 QByteArray mimeDataForVariables(const QList<std::shared_ptr<Variable> > &variables) const;
73
53
@@ -92,6 +72,26 signals:
92 void variableAdded(const std::shared_ptr<Variable> &variable);
72 void variableAdded(const std::shared_ptr<Variable> &variable);
93
73
94 public slots:
74 public slots:
75 /**
76 * Deletes from the controller the variable passed in parameter.
77 *
78 * Delete a variable includes:
79 * - the deletion of the various references to the variable in SciQlop
80 * - the deletion of the model variable
81 * - the deletion of the provider associated with the variable
82 * - removing the cache associated with the variable
83 *
84 * @param variable the variable to delete from the controller.
85 */
86 void deleteVariable(std::shared_ptr<Variable> variable) noexcept;
87
88 /**
89 * Deletes from the controller the variables passed in parameter.
90 * @param variables the variables to delete from the controller.
91 * @sa deleteVariable()
92 */
93 void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept;
94
95 /// Request the data loading of the variable whithin range
95 /// Request the data loading of the variable whithin range
96 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
96 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
97 bool synchronise);
97 bool synchronise);
@@ -69,7 +69,7 public:
69 /// Sets the y-axis range based on the data of a variable
69 /// Sets the y-axis range based on the data of a variable
70 void setYRange(std::shared_ptr<Variable> variable);
70 void setYRange(std::shared_ptr<Variable> variable);
71 SqpRange graphRange() const noexcept;
71 SqpRange graphRange() const noexcept;
72 void setGraphRange(const SqpRange &range);
72 void setGraphRange(const SqpRange &range, bool calibration = false);
73
73
74 // Zones
74 // Zones
75 /// Returns the ranges of all the selection zones on the graph
75 /// Returns the ranges of all the selection zones on the graph
@@ -8,13 +8,14
8 #include <DBCatalogue.h>
8 #include <DBCatalogue.h>
9 #include <DBEventProduct.h>
9 #include <DBEventProduct.h>
10 #include <DataSource/DataSourceController.h>
10 #include <DataSource/DataSourceController.h>
11 #include <DataSource/DataSourceItem.h>
11 #include <SqpApplication.h>
12 #include <SqpApplication.h>
12 #include <Variable/Variable.h>
13 #include <Variable/Variable.h>
13 #include <Variable/VariableController.h>
14 #include <Variable/VariableController.h>
15 #include <Visualization/VisualizationGraphWidget.h>
14 #include <Visualization/VisualizationTabWidget.h>
16 #include <Visualization/VisualizationTabWidget.h>
15 #include <Visualization/VisualizationWidget.h>
17 #include <Visualization/VisualizationWidget.h>
16 #include <Visualization/VisualizationZoneWidget.h>
18 #include <Visualization/VisualizationZoneWidget.h>
17 #include <Visualization/VisualizationGraphWidget.h>
18
19
19 #include <QDialog>
20 #include <QDialog>
20 #include <QDialogButtonBox>
21 #include <QDialogButtonBox>
@@ -190,25 +191,71 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
190
191
191 if (selectedRows.count() == 1) {
192 if (selectedRows.count() == 1) {
192 auto event = m_Model->getEvent(selectedRows.first());
193 auto event = m_Model->getEvent(selectedRows.first());
193 if (m_VisualizationWidget) {
194 if (m_VisualizationWidget && event) {
194 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
195 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
195 if (auto zone = tab->getZoneWithName(m_ZoneForGraphMode)) {
196 if (auto zone = tab->getZoneWithName(m_ZoneForGraphMode)) {
196
197
197 for (auto graph : m_CustomGraphs) {
198 for (auto graph : m_CustomGraphs) {
198 graph->close();
199 graph->close();
200 auto variables = graph->variables().toVector();
201
202 QMetaObject::invokeMethod(
203 &sqpApp->variableController(), "deleteVariables",
204 Qt::QueuedConnection,
205 Q_ARG(QVector<std::shared_ptr<Variable> >, variables));
199 }
206 }
200 m_CustomGraphs.clear();
207 m_CustomGraphs.clear();
201
208
209 QVector<SqpRange> graphRanges;
210 double maxDt = 0;
211 for (auto eventProduct : event->getEventProducts()) {
212 SqpRange eventRange;
213 eventRange.m_TStart = eventProduct.getTStart();
214 eventRange.m_TEnd = eventProduct.getTEnd();
215 graphRanges << eventRange;
216
217 auto dt = eventRange.m_TEnd - eventRange.m_TStart;
218 if (dt > maxDt) {
219 maxDt = dt;
220 }
221 }
222
223 QVector<SqpRange> correctedGraphRanges;
224 for (auto range : graphRanges) {
225 auto dt = range.m_TEnd - range.m_TStart;
226 auto diff = qAbs((maxDt - dt) / 2.0);
227
228 SqpRange correctedRange;
229 correctedRange.m_TStart = range.m_TStart - diff;
230 correctedRange.m_TEnd = range.m_TEnd + diff;
231
232 correctedGraphRanges << correctedRange;
233 }
234
235 auto itRange = correctedGraphRanges.cbegin();
202 for (auto eventProduct : event->getEventProducts()) {
236 for (auto eventProduct : event->getEventProducts()) {
203 auto productId = eventProduct.getProductId();
237 auto productId = eventProduct.getProductId();
204
238
239 auto range = *itRange;
240 ++itRange;
241
205 auto context = new QObject{treeView};
242 auto context = new QObject{treeView};
206 QObject::connect(&sqpApp->variableController(),
243 QObject::connect(
207 &VariableController::variableAdded, context,
244 &sqpApp->variableController(), &VariableController::variableAdded,
208 [this, zone, context](auto variable) {
245 context,
246 [this, zone, context, range, productId](auto variable) {
247
248 if (variable->metadata()
249 .value(DataSourceItem::ID_DATA_KEY, "UnknownID")
250 .toString()
251 == productId) {
209 auto graph = zone->createGraph(variable);
252 auto graph = zone->createGraph(variable);
210 m_CustomGraphs << graph;
253 m_CustomGraphs << graph;
254
255 graph->setGraphRange(range, true);
256
211 delete context; // removes the connection
257 delete context; // removes the connection
258 }
212 },
259 },
213 Qt::QueuedConnection);
260 Qt::QueuedConnection);
214
261
@@ -388,11 +388,21 SqpRange VisualizationGraphWidget::graphRange() const noexcept
388 return SqpRange{graphRange.lower, graphRange.upper};
388 return SqpRange{graphRange.lower, graphRange.upper};
389 }
389 }
390
390
391 void VisualizationGraphWidget::setGraphRange(const SqpRange &range)
391 void VisualizationGraphWidget::setGraphRange(const SqpRange &range, bool calibration)
392 {
392 {
393 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange START");
393 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange START");
394
395 if (calibration) {
396 impl->m_IsCalibration = true;
397 }
398
394 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
399 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
395 ui->widget->replot();
400 ui->widget->replot();
401
402 if (calibration) {
403 impl->m_IsCalibration = false;
404 }
405
396 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange END");
406 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange END");
397 }
407 }
398
408
General Comments 0
You need to be logged in to leave comments. Login now