##// END OF EJS Templates
Add implementation for the range rescale. Variable is ignored here...
perrinel -
r438:4113f5669532
parent child
Show More
@@ -122,6 +122,15 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable
122 ui->widget->replot();
122 ui->widget->replot();
123 }
123 }
124
124
125 void VisualizationGraphWidget::setRange(std::shared_ptr<Variable> variable,
126 const SqpDateTime &range)
127 {
128 // auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable);
129 // for (auto it = componentsIt.first; it != componentsIt.second;) {
130 // }
131 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
132 }
133
125 void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor)
134 void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor)
126 {
135 {
127 if (visitor) {
136 if (visitor) {
@@ -187,7 +196,8 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
187 auto dateTime = SqpDateTime{t1.lower, t1.upper};
196 auto dateTime = SqpDateTime{t1.lower, t1.upper};
188 auto dateTimeRange = dateTime;
197 auto dateTimeRange = dateTime;
189
198
190 auto tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart);
199 auto toleranceFactor = 0.2;
200 auto tolerance = toleranceFactor * (dateTime.m_TEnd - dateTime.m_TStart);
191 auto variableDateTimeWithTolerance = dateTime;
201 auto variableDateTimeWithTolerance = dateTime;
192 variableDateTimeWithTolerance.m_TStart -= tolerance;
202 variableDateTimeWithTolerance.m_TStart -= tolerance;
193 variableDateTimeWithTolerance.m_TEnd += tolerance;
203 variableDateTimeWithTolerance.m_TEnd += tolerance;
@@ -207,9 +217,8 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
207 auto diffEndToKeepDelta = dateTime.m_TEnd - variableDateTime.m_TEnd;
217 auto diffEndToKeepDelta = dateTime.m_TEnd - variableDateTime.m_TEnd;
208 dateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta;
218 dateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta;
209 // Tolerance have to be added to the right
219 // Tolerance have to be added to the right
210 // add 10% tolerance for right (end) side
220 // add tolerance for right (end) side
211 // auto tolerance = 0.1 * (dateTime.m_TEnd -
221 tolerance = toleranceFactor * (dateTime.m_TEnd - dateTime.m_TStart);
212 // dateTime.m_TStart);
213 variableDateTimeWithTolerance.m_TEnd += tolerance;
222 variableDateTimeWithTolerance.m_TEnd += tolerance;
214 }
223 }
215 else if (variableDateTime.m_TEnd > dateTime.m_TEnd) {
224 else if (variableDateTime.m_TEnd > dateTime.m_TEnd) {
@@ -217,8 +226,8 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
217 auto diffStartToKeepDelta = variableDateTime.m_TStart - dateTime.m_TStart;
226 auto diffStartToKeepDelta = variableDateTime.m_TStart - dateTime.m_TStart;
218 dateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
227 dateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
219 // Tolerance have to be added to the left
228 // Tolerance have to be added to the left
220 // add 10% tolerance for left (start) side
229 // add tolerance for left (start) side
221 tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart);
230 tolerance = toleranceFactor * (dateTime.m_TEnd - dateTime.m_TStart);
222 variableDateTimeWithTolerance.m_TStart -= tolerance;
231 variableDateTimeWithTolerance.m_TStart -= tolerance;
223 }
232 }
224 else {
233 else {
@@ -234,7 +243,8 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
234 variableDateTimeWithTolerance.m_TEnd += tolerance;
243 variableDateTimeWithTolerance.m_TEnd += tolerance;
235 }
244 }
236 if (!variable->contains(dateTimeRange)) {
245 if (!variable->contains(dateTimeRange)) {
237 qCInfo(LOG_VisualizationGraphWidget()) << "newv" << dateTime;
246 qCInfo(LOG_VisualizationGraphWidget())
247 << "TORM: Modif on variable datetime detected" << dateTime;
238 variable->setDateTime(dateTime);
248 variable->setDateTime(dateTime);
239 }
249 }
240
250
@@ -295,17 +305,3 void VisualizationGraphWidget::onDataCacheVariableUpdated()
295 }
305 }
296 }
306 }
297 }
307 }
298
299 void VisualizationGraphWidget::updateDisplay(std::shared_ptr<Variable> variable)
300 {
301 auto abstractPlotableItPair = impl->m_VariableToPlotMultiMap.equal_range(variable);
302
303 auto abstractPlotableVect = QVector<QCPAbstractPlottable *>{};
304
305 for (auto it = abstractPlotableItPair.first; it != abstractPlotableItPair.second; ++it) {
306 abstractPlotableVect.push_back(it->second);
307 }
308
309 VisualizationGraphHelper::updateData(abstractPlotableVect, variable->dataSeries(),
310 variable->dateTime());
311 }
General Comments 0
You need to be logged in to leave comments. Login now