##// END OF EJS Templates
Implémentation timewidget
perrinel -
r816:b41b5a9346eb
parent child
Show More
@@ -83,7 +83,7 signals:
83 83 public slots:
84 84 /// Request the data loading of the variable whithin range
85 85 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
86 const SqpRange &oldRange, bool synchronise);
86 bool synchronise);
87 87 /**
88 88 * Creates a new variable and adds it to the model
89 89 * @param name the name of the new variable
@@ -299,22 +299,24 VariableController::createVariable(const QString &name, const QVariantHash &meta
299 299
300 300 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
301 301 {
302 // TODO check synchronisation and Rescale
302 // NOTE: Even if acquisition request is aborting, the graphe range will be changed
303 303 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
304 304 << QThread::currentThread()->objectName();
305 305 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
306 auto varRequestId = QUuid::createUuid();
306 auto variables = QVector<std::shared_ptr<Variable> >{};
307 307
308 308 for (const auto &selectedRow : qAsConst(selectedRows)) {
309 309 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
310 selectedVariable->setRange(dateTime);
311 impl->processRequest(selectedVariable, dateTime, varRequestId);
310 variables << selectedVariable;
312 311
313 312 // notify that rescale operation has to be done
314 313 emit rangeChanged(selectedVariable, dateTime);
315 314 }
316 315 }
317 impl->updateVariableRequest(varRequestId);
316
317 if (!variables.isEmpty()) {
318 this->onRequestDataLoading(variables, dateTime, true);
319 }
318 320 }
319 321
320 322 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
@@ -459,8 +461,7 void VariableController::desynchronize(std::shared_ptr<Variable> variable,
459 461 }
460 462
461 463 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables,
462 const SqpRange &range, const SqpRange &oldRange,
463 bool synchronise)
464 const SqpRange &range, bool synchronise)
464 465 {
465 466 // NOTE: oldRange isn't really necessary since oldRange == variable->range().
466 467
@@ -105,8 +105,7 struct Move : public IOperation {
105 105 void exec(VariableController &variableController) const override
106 106 {
107 107 if (auto variable = variableController.variableModel()->variable(m_Index)) {
108 variableController.onRequestDataLoading({variable}, m_NewRange, variable->range(),
109 !m_Shift);
108 variableController.onRequestDataLoading({variable}, m_NewRange, !m_Shift);
110 109 }
111 110 }
112 111
@@ -39,7 +39,6 public:
39 39 /// Removes a variable from the graph
40 40 void removeVariable(std::shared_ptr<Variable> variable) noexcept;
41 41
42 void setRange(std::shared_ptr<Variable> variable, const SqpRange &range);
43 42 void setYRange(const SqpRange &range);
44 43 SqpRange graphRange() const noexcept;
45 44 void setGraphRange(const SqpRange &range);
@@ -54,7 +53,7 public:
54 53 signals:
55 54 void synchronize(const SqpRange &range, const SqpRange &oldRange);
56 55 void requestDataLoading(QVector<std::shared_ptr<Variable> > variable, const SqpRange &range,
57 const SqpRange &oldRange, bool synchronise);
56 bool synchronise);
58 57
59 58 /// Signal emitted when the variable is about to be removed from the graph
60 59 void variableAboutToBeRemoved(std::shared_ptr<Variable> var);
@@ -119,14 +119,11 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, S
119 119
120 120 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
121 121
122 auto varRange = variable->range();
123
124 122 this->enableAcquisition(false);
125 123 this->setGraphRange(range);
126 124 this->enableAcquisition(true);
127 125
128 emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, range, varRange,
129 false);
126 emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, range, false);
130 127
131 128 emit variableAdded(variable);
132 129 }
@@ -155,17 +152,6 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable
155 152 ui->widget->replot();
156 153 }
157 154
158 void VisualizationGraphWidget::setRange(std::shared_ptr<Variable> variable, const SqpRange &range)
159 {
160 // Note: in case of different axes that depends on variable, we could start with a code like
161 // that:
162 // auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable);
163 // for (auto it = componentsIt.first; it != componentsIt.second;) {
164 // }
165 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
166 ui->widget->replot();
167 }
168
169 155 void VisualizationGraphWidget::setYRange(const SqpRange &range)
170 156 {
171 157 ui->widget->yAxis->setRange(range.m_TStart, range.m_TEnd);
@@ -282,7 +268,7 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
282 268 it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) {
283 269 variableUnderGraphVector.push_back(it->first);
284 270 }
285 emit requestDataLoading(std::move(variableUnderGraphVector), graphRange, oldGraphRange,
271 emit requestDataLoading(std::move(variableUnderGraphVector), graphRange,
286 272 !impl->m_IsCalibration);
287 273
288 274 if (!impl->m_IsCalibration) {
@@ -59,7 +59,9 void RescaleAxeOperation::visit(VisualizationGraphWidget *graphWidget)
59 59 if (graphWidget) {
60 60 // If the widget contains the variable, rescale it
61 61 if (impl->m_Variable && graphWidget->contains(*impl->m_Variable)) {
62 graphWidget->setRange(impl->m_Variable, impl->m_Range);
62 graphWidget->enableAcquisition(false);
63 graphWidget->setGraphRange(impl->m_Range);
64 graphWidget->enableAcquisition(true);
63 65 }
64 66 }
65 67 else {
@@ -123,8 +123,7 void TestAmdaAcquisition::testAcquisition()
123 123
124 124 auto nextSqpR
125 125 = SqpRange{DateUtils::secondsSinceEpoch(tStart), DateUtils::secondsSinceEpoch(tEnd)};
126 vc.onRequestDataLoading(QVector<std::shared_ptr<Variable> >{} << var, nextSqpR,
127 var->range(), true);
126 vc.onRequestDataLoading(QVector<std::shared_ptr<Variable> >{} << var, nextSqpR, true);
128 127
129 128 QEventLoop loop;
130 129 QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit);
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

Status change > Approved

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