##// END OF EJS Templates
Uses variable range in graph
Alexandre Leroux -
r615:e608cd04beb8
parent child
Show More
@@ -188,8 +188,20 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
188 188 this->addGraph(graphWidget);
189 189
190 190 graphWidget->addVariable(variable, range);
191 // TODO: get y using variable range
192 graphWidget->setYRange(SqpRange{-10, 10});
191
192 // get y using variable range
193 if (auto dataSeries = variable->dataSeries()) {
194 auto valuesBounds = dataSeries->valuesBounds(range.m_TStart, range.m_TEnd);
195 auto end = dataSeries->cend();
196 if (valuesBounds.first != end && valuesBounds.second != end) {
197 auto rangeValue = [](const auto &value) { return std::isnan(value) ? 0. : value; };
198
199 auto minValue = rangeValue(valuesBounds.first->minValue());
200 auto maxValue = rangeValue(valuesBounds.second->maxValue());
201
202 graphWidget->setYRange(SqpRange{minValue, maxValue});
203 }
204 }
193 205
194 206 return graphWidget;
195 207 }
@@ -45,7 +45,7 bool compareDataSeries(std::shared_ptr<IDataSeries> candidate, SqpRange candidat
45 45 if (candidateDS && referenceDS) {
46 46
47 47 auto itRefs
48 = referenceDS->subData(candidateCacheRange.m_TStart, candidateCacheRange.m_TEnd);
48 = referenceDS->xAxisRange(candidateCacheRange.m_TStart, candidateCacheRange.m_TEnd);
49 49 qDebug() << " DISTANCE" << std::distance(candidateDS->cbegin(), candidateDS->cend())
50 50 << std::distance(itRefs.first, itRefs.second);
51 51
General Comments 0
You need to be logged in to leave comments. Login now