##// END OF EJS Templates
Implémentation timewidget
perrinel -
r811:b41b5a9346eb
parent child
Show More
@@ -83,7 +83,7 signals:
83 public slots:
83 public slots:
84 /// Request the data loading of the variable whithin range
84 /// Request the data loading of the variable whithin range
85 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
85 void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range,
86 const SqpRange &oldRange, bool synchronise);
86 bool synchronise);
87 /**
87 /**
88 * Creates a new variable and adds it to the model
88 * Creates a new variable and adds it to the model
89 * @param name the name of the new variable
89 * @param name the name of the new variable
@@ -299,22 +299,24 VariableController::createVariable(const QString &name, const QVariantHash &meta
299
299
300 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
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 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
303 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
304 << QThread::currentThread()->objectName();
304 << QThread::currentThread()->objectName();
305 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
305 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
306 auto varRequestId = QUuid::createUuid();
306 auto variables = QVector<std::shared_ptr<Variable> >{};
307
307
308 for (const auto &selectedRow : qAsConst(selectedRows)) {
308 for (const auto &selectedRow : qAsConst(selectedRows)) {
309 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
309 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
310 selectedVariable->setRange(dateTime);
310 variables << selectedVariable;
311 impl->processRequest(selectedVariable, dateTime, varRequestId);
312
311
313 // notify that rescale operation has to be done
312 // notify that rescale operation has to be done
314 emit rangeChanged(selectedVariable, dateTime);
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 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
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 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables,
463 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables,
462 const SqpRange &range, const SqpRange &oldRange,
464 const SqpRange &range, bool synchronise)
463 bool synchronise)
464 {
465 {
465 // NOTE: oldRange isn't really necessary since oldRange == variable->range().
466 // NOTE: oldRange isn't really necessary since oldRange == variable->range().
466
467
@@ -105,8 +105,7 struct Move : public IOperation {
105 void exec(VariableController &variableController) const override
105 void exec(VariableController &variableController) const override
106 {
106 {
107 if (auto variable = variableController.variableModel()->variable(m_Index)) {
107 if (auto variable = variableController.variableModel()->variable(m_Index)) {
108 variableController.onRequestDataLoading({variable}, m_NewRange, variable->range(),
108 variableController.onRequestDataLoading({variable}, m_NewRange, !m_Shift);
109 !m_Shift);
110 }
109 }
111 }
110 }
112
111
@@ -39,7 +39,6 public:
39 /// Removes a variable from the graph
39 /// Removes a variable from the graph
40 void removeVariable(std::shared_ptr<Variable> variable) noexcept;
40 void removeVariable(std::shared_ptr<Variable> variable) noexcept;
41
41
42 void setRange(std::shared_ptr<Variable> variable, const SqpRange &range);
43 void setYRange(const SqpRange &range);
42 void setYRange(const SqpRange &range);
44 SqpRange graphRange() const noexcept;
43 SqpRange graphRange() const noexcept;
45 void setGraphRange(const SqpRange &range);
44 void setGraphRange(const SqpRange &range);
@@ -54,7 +53,7 public:
54 signals:
53 signals:
55 void synchronize(const SqpRange &range, const SqpRange &oldRange);
54 void synchronize(const SqpRange &range, const SqpRange &oldRange);
56 void requestDataLoading(QVector<std::shared_ptr<Variable> > variable, const SqpRange &range,
55 void requestDataLoading(QVector<std::shared_ptr<Variable> > variable, const SqpRange &range,
57 const SqpRange &oldRange, bool synchronise);
56 bool synchronise);
58
57
59 /// Signal emitted when the variable is about to be removed from the graph
58 /// Signal emitted when the variable is about to be removed from the graph
60 void variableAboutToBeRemoved(std::shared_ptr<Variable> var);
59 void variableAboutToBeRemoved(std::shared_ptr<Variable> var);
@@ -119,14 +119,11 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, S
119
119
120 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
120 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
121
121
122 auto varRange = variable->range();
123
124 this->enableAcquisition(false);
122 this->enableAcquisition(false);
125 this->setGraphRange(range);
123 this->setGraphRange(range);
126 this->enableAcquisition(true);
124 this->enableAcquisition(true);
127
125
128 emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, range, varRange,
126 emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, range, false);
129 false);
130
127
131 emit variableAdded(variable);
128 emit variableAdded(variable);
132 }
129 }
@@ -155,17 +152,6 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable
155 ui->widget->replot();
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 void VisualizationGraphWidget::setYRange(const SqpRange &range)
155 void VisualizationGraphWidget::setYRange(const SqpRange &range)
170 {
156 {
171 ui->widget->yAxis->setRange(range.m_TStart, range.m_TEnd);
157 ui->widget->yAxis->setRange(range.m_TStart, range.m_TEnd);
@@ -282,7 +268,7 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
282 it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) {
268 it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) {
283 variableUnderGraphVector.push_back(it->first);
269 variableUnderGraphVector.push_back(it->first);
284 }
270 }
285 emit requestDataLoading(std::move(variableUnderGraphVector), graphRange, oldGraphRange,
271 emit requestDataLoading(std::move(variableUnderGraphVector), graphRange,
286 !impl->m_IsCalibration);
272 !impl->m_IsCalibration);
287
273
288 if (!impl->m_IsCalibration) {
274 if (!impl->m_IsCalibration) {
@@ -59,7 +59,9 void RescaleAxeOperation::visit(VisualizationGraphWidget *graphWidget)
59 if (graphWidget) {
59 if (graphWidget) {
60 // If the widget contains the variable, rescale it
60 // If the widget contains the variable, rescale it
61 if (impl->m_Variable && graphWidget->contains(*impl->m_Variable)) {
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 else {
67 else {
@@ -123,8 +123,7 void TestAmdaAcquisition::testAcquisition()
123
123
124 auto nextSqpR
124 auto nextSqpR
125 = SqpRange{DateUtils::secondsSinceEpoch(tStart), DateUtils::secondsSinceEpoch(tEnd)};
125 = SqpRange{DateUtils::secondsSinceEpoch(tStart), DateUtils::secondsSinceEpoch(tEnd)};
126 vc.onRequestDataLoading(QVector<std::shared_ptr<Variable> >{} << var, nextSqpR,
126 vc.onRequestDataLoading(QVector<std::shared_ptr<Variable> >{} << var, nextSqpR, true);
127 var->range(), true);
128
127
129 QEventLoop loop;
128 QEventLoop loop;
130 QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit);
129 QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit);
General Comments 0
You need to be logged in to leave comments. Login now