|
@@
-177,37
+177,48
void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept
|
|
177
|
|
|
177
|
|
|
178
|
void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
|
|
178
|
void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
|
|
179
|
{
|
|
179
|
{
|
|
180
|
qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged")
|
|
180
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged")
|
|
181
|
<< QThread::currentThread()->objectName();
|
|
181
|
<< QThread::currentThread()->objectName();
|
|
182
|
|
|
182
|
|
|
183
|
for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
|
|
183
|
for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
|
|
184
|
it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
|
|
184
|
it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
|
|
185
|
|
|
185
|
|
|
186
|
auto variable = it->first;
|
|
186
|
auto variable = it->first;
|
|
187
|
auto dateTime = SqpDateTime{t1.lower, t1.upper};
|
|
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
|
auto variableDateTimeWithTolerance = dateTime;
|
|
201
|
auto variableDateTimeWithTolerance = dateTime;
|
|
192
|
if (!variable->isInside(dateTime)) {
|
|
202
|
if (!variable->isInside(dateTime)) {
|
|
193
|
auto variableDateTime = variable->dateTime();
|
|
203
|
auto variableDateTime = variable->dateTime();
|
|
194
|
if (variableDateTime.m_TStart < dateTime.m_TStart) {
|
|
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
|
auto diffEndToKeepDelta = dateTime.m_TEnd - variableDateTime.m_TEnd;
|
|
207
|
auto diffEndToKeepDelta = dateTime.m_TEnd - variableDateTime.m_TEnd;
|
|
198
|
dateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta;
|
|
208
|
dateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta;
|
|
199
|
// Tolerance have to be added to the right
|
|
209
|
// Tolerance have to be added to the right
|
|
200
|
// add 10% tolerance for right (end) side
|
|
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
|
variableDateTimeWithTolerance.m_TEnd += tolerance;
|
|
213
|
variableDateTimeWithTolerance.m_TEnd += tolerance;
|
|
203
|
}
|
|
214
|
}
|
|
204
|
else if (variableDateTime.m_TEnd > dateTime.m_TEnd) {
|
|
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
|
auto diffStartToKeepDelta = variableDateTime.m_TStart - dateTime.m_TStart;
|
|
217
|
auto diffStartToKeepDelta = variableDateTime.m_TStart - dateTime.m_TStart;
|
|
207
|
dateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
|
|
218
|
dateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
|
|
208
|
// Tolerance have to be added to the left
|
|
219
|
// Tolerance have to be added to the left
|
|
209
|
// add 10% tolerance for left (start) side
|
|
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
|
variableDateTimeWithTolerance.m_TStart -= tolerance;
|
|
222
|
variableDateTimeWithTolerance.m_TStart -= tolerance;
|
|
212
|
}
|
|
223
|
}
|
|
213
|
else {
|
|
224
|
else {
|
|
@@
-216,19
+227,23
void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1)
|
|
216
|
}
|
|
227
|
}
|
|
217
|
}
|
|
228
|
}
|
|
218
|
else {
|
|
229
|
else {
|
|
219
|
qCDebug(LOG_VisualizationGraphWidget()) << tr("Detection zoom out: ");
|
|
230
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("Detection zoom out: ");
|
|
220
|
// add 10% tolerance for each side
|
|
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
|
variableDateTimeWithTolerance.m_TStart -= tolerance;
|
|
233
|
variableDateTimeWithTolerance.m_TStart -= tolerance;
|
|
223
|
variableDateTimeWithTolerance.m_TEnd += tolerance;
|
|
234
|
variableDateTimeWithTolerance.m_TEnd += tolerance;
|
|
224
|
}
|
|
235
|
}
|
|
225
|
variable->setDateTime(dateTime);
|
|
236
|
if (!variable->contains(dateTimeRange)) {
|
|
|
|
|
237
|
qCInfo(LOG_VisualizationGraphWidget()) << "newv" << dateTime;
|
|
|
|
|
238
|
variable->setDateTime(dateTime);
|
|
|
|
|
239
|
}
|
|
226
|
|
|
240
|
|
|
|
|
|
241
|
qCInfo(LOG_VisualizationGraphWidget()) << tr("Request data detection: ");
|
|
227
|
// CHangement detected, we need to ask controller to request data loading
|
|
242
|
// CHangement detected, we need to ask controller to request data loading
|
|
228
|
emit requestDataLoading(variable, variableDateTimeWithTolerance);
|
|
243
|
emit requestDataLoading(variable, variableDateTimeWithTolerance);
|
|
229
|
}
|
|
244
|
}
|
|
230
|
else {
|
|
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,11
+277,22
void VisualizationGraphWidget::onDataCacheVariableUpdated()
|
|
262
|
// - use an ordered_multimap and the algos of std to group the values by key
|
|
277
|
// - use an ordered_multimap and the algos of std to group the values by key
|
|
263
|
// - use a map (unique keys) and store as values directly the list of components
|
|
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
|
for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
|
|
283
|
for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
|
|
266
|
it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
|
|
284
|
it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
|
|
267
|
auto variable = it->first;
|
|
285
|
auto variable = it->first;
|
|
268
|
VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
|
|
286
|
qCInfo(LOG_VisualizationGraphWidget())
|
|
269
|
variable->dataSeries(), variable->dateTime());
|
|
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
|
|
|
|
|
|
293
|
VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
|
|
|
|
|
294
|
variable->dataSeries(), variable->dateTime());
|
|
|
|
|
295
|
}
|
|
270
|
}
|
|
296
|
}
|
|
271
|
}
|
|
297
|
}
|
|
272
|
|
|
298
|
|