|
@@
-177,7
+177,7
void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept
|
|
177
|
177
|
|
|
178
|
178
|
void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
|
|
179
|
179
|
{
|
|
180
|
|
qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged")
|
|
|
180
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged")
|
|
181
|
181
|
<< QThread::currentThread()->objectName();
|
|
182
|
182
|
|
|
183
|
183
|
for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
|
|
@@
-185,29
+185,40
void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
|
|
185
|
185
|
|
|
186
|
186
|
auto variable = it->first;
|
|
187
|
187
|
auto dateTime = SqpDateTime{t1.lower, t1.upper};
|
|
|
188
|
auto dateTimeRange = dateTime;
|
|
188
|
189
|
|
|
189
|
|
if (!variable->contains(dateTime)) {
|
|
|
190
|
auto tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart);
|
|
|
191
|
auto variableDateTimeWithTolerance = dateTime;
|
|
|
192
|
variableDateTimeWithTolerance.m_TStart -= tolerance;
|
|
|
193
|
variableDateTimeWithTolerance.m_TEnd += tolerance;
|
|
|
194
|
|
|
|
195
|
qCInfo(LOG_VisualizationGraphWidget()) << "v" << dateTime;
|
|
|
196
|
qCInfo(LOG_VisualizationGraphWidget()) << "vtol" << variableDateTimeWithTolerance;
|
|
|
197
|
// If new range with tol is upper than variable datetime parameters. we need to request new
|
|
|
198
|
// data
|
|
|
199
|
if (!variable->contains(variableDateTimeWithTolerance)) {
|
|
190
|
200
|
|
|
191
|
201
|
auto variableDateTimeWithTolerance = dateTime;
|
|
192
|
202
|
if (!variable->isInside(dateTime)) {
|
|
193
|
203
|
auto variableDateTime = variable->dateTime();
|
|
194
|
204
|
if (variableDateTime.m_TStart < dateTime.m_TStart) {
|
|
195
|
|
qCDebug(LOG_VisualizationGraphWidget()) << tr("TDetection pan to right:");
|
|
|
205
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to right:");
|
|
196
|
206
|
|
|
197
|
207
|
auto diffEndToKeepDelta = dateTime.m_TEnd - variableDateTime.m_TEnd;
|
|
198
|
208
|
dateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta;
|
|
199
|
209
|
// Tolerance have to be added to the right
|
|
200
|
210
|
// add 10% tolerance for right (end) side
|
|
201
|
|
auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart);
|
|
|
211
|
// auto tolerance = 0.1 * (dateTime.m_TEnd -
|
|
|
212
|
// dateTime.m_TStart);
|
|
202
|
213
|
variableDateTimeWithTolerance.m_TEnd += tolerance;
|
|
203
|
214
|
}
|
|
204
|
215
|
else if (variableDateTime.m_TEnd > dateTime.m_TEnd) {
|
|
205
|
|
qCDebug(LOG_VisualizationGraphWidget()) << tr("Detection pan to left: ");
|
|
|
216
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to left: ");
|
|
206
|
217
|
auto diffStartToKeepDelta = variableDateTime.m_TStart - dateTime.m_TStart;
|
|
207
|
218
|
dateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
|
|
208
|
219
|
// Tolerance have to be added to the left
|
|
209
|
220
|
// add 10% tolerance for left (start) side
|
|
210
|
|
auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart);
|
|
|
221
|
tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart);
|
|
211
|
222
|
variableDateTimeWithTolerance.m_TStart -= tolerance;
|
|
212
|
223
|
}
|
|
213
|
224
|
else {
|
|
@@
-216,19
+227,23
void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
|
|
216
|
227
|
}
|
|
217
|
228
|
}
|
|
218
|
229
|
else {
|
|
219
|
|
qCDebug(LOG_VisualizationGraphWidget()) << tr("Detection zoom out: ");
|
|
|
230
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("Detection zoom out: ");
|
|
220
|
231
|
// add 10% tolerance for each side
|
|
221
|
|
auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart);
|
|
|
232
|
tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart);
|
|
222
|
233
|
variableDateTimeWithTolerance.m_TStart -= tolerance;
|
|
223
|
234
|
variableDateTimeWithTolerance.m_TEnd += tolerance;
|
|
224
|
235
|
}
|
|
|
236
|
if (!variable->contains(dateTimeRange)) {
|
|
|
237
|
qCInfo(LOG_VisualizationGraphWidget()) << "newv" << dateTime;
|
|
225
|
238
|
variable->setDateTime(dateTime);
|
|
|
239
|
}
|
|
226
|
240
|
|
|
|
241
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("Request data detection: ");
|
|
227
|
242
|
// CHangement detected, we need to ask controller to request data loading
|
|
228
|
243
|
emit requestDataLoading(variable, variableDateTimeWithTolerance);
|
|
229
|
244
|
}
|
|
230
|
245
|
else {
|
|
231
|
|
qCDebug(LOG_VisualizationGraphWidget()) << tr("Detection zoom in: ");
|
|
|
246
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("Detection zoom in: ");
|
|
232
|
247
|
}
|
|
233
|
248
|
}
|
|
234
|
249
|
}
|
|
@@
-262,13
+277,24
void VisualizationGraphWidget::onDataCacheVariableUpdated()
|
|
262
|
277
|
// - use an ordered_multimap and the algos of std to group the values by key
|
|
263
|
278
|
// - use a map (unique keys) and store as values directly the list of components
|
|
264
|
279
|
|
|
|
280
|
auto grapheRange = ui->widget->xAxis->range();
|
|
|
281
|
auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper};
|
|
|
282
|
|
|
265
|
283
|
for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
|
|
266
|
284
|
it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
|
|
267
|
285
|
auto variable = it->first;
|
|
|
286
|
qCInfo(LOG_VisualizationGraphWidget())
|
|
|
287
|
<< "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated S"
|
|
|
288
|
<< variable->dateTime();
|
|
|
289
|
qCInfo(LOG_VisualizationGraphWidget())
|
|
|
290
|
<< "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated E" << dateTime;
|
|
|
291
|
if (dateTime.contains(variable->dateTime()) || dateTime.intersect(variable->dateTime())) {
|
|
|
292
|
|
|
268
|
293
|
VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
|
|
269
|
294
|
variable->dataSeries(), variable->dateTime());
|
|
270
|
295
|
}
|
|
271
|
296
|
}
|
|
|
297
|
}
|
|
272
|
298
|
|
|
273
|
299
|
void VisualizationGraphWidget::updateDisplay(std::shared_ptr<Variable> variable)
|
|
274
|
300
|
{
|