diff --git a/core/include/Data/DataSeries.h b/core/include/Data/DataSeries.h index 6232a63..31825bd 100644 --- a/core/include/Data/DataSeries.h +++ b/core/include/Data/DataSeries.h @@ -4,8 +4,15 @@ #include #include +#include + #include + +Q_DECLARE_LOGGING_CATEGORY(LOG_DataSeries) +Q_LOGGING_CATEGORY(LOG_DataSeries, "DataSeries") + + /** * @brief The DataSeries class is the base (abstract) implementation of IDataSeries. * @@ -36,6 +43,10 @@ public: m_XAxisData->merge(dimDataSeries->xAxisData().get()); m_ValuesData->merge(dimDataSeries->valuesData().get()); } + else { + qCWarning(LOG_DataSeries()) + << QObject::tr("Dection of a type of IDataSeries we cannot merge with !"); + } } protected: diff --git a/core/include/Data/IDataProvider.h b/core/include/Data/IDataProvider.h index 5d025cf..cde7f5e 100644 --- a/core/include/Data/IDataProvider.h +++ b/core/include/Data/IDataProvider.h @@ -31,7 +31,7 @@ public: virtual void requestDataLoading(const QVector &dateTimeList) = 0; signals: - void dataProvided(std::shared_ptr dateSerie, SqpDateTime dateTime); + void dataProvided(std::shared_ptr dateSerie, const SqpDateTime &dateTime); }; // Required for using shared_ptr in signals/slots Q_DECLARE_METATYPE(std::shared_ptr) diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h index c233bde..7ac0c1c 100644 --- a/core/include/Variable/Variable.h +++ b/core/include/Variable/Variable.h @@ -33,7 +33,7 @@ public: /// @return the data of the variable, nullptr if there is no data IDataSeries *dataSeries() const noexcept; - bool contains(SqpDateTime dateTime); + bool contains(const SqpDateTime &dateTime); void setDataSeries(std::unique_ptr dataSeries) noexcept; public slots: diff --git a/core/include/Variable/VariableCacheController.h b/core/include/Variable/VariableCacheController.h index edcc65d..2fd48b2 100644 --- a/core/include/Variable/VariableCacheController.h +++ b/core/include/Variable/VariableCacheController.h @@ -9,7 +9,7 @@ class Variable; -/// This class aims to store in the cash all of the dateTime already requested to the variable. +/// This class aims to store in the cache all of the dateTime already requested to the variable. class VariableCacheController : public QObject { Q_OBJECT public: diff --git a/core/src/Variable/Variable.cpp b/core/src/Variable/Variable.cpp index 43864d5..9db3be1 100644 --- a/core/src/Variable/Variable.cpp +++ b/core/src/Variable/Variable.cpp @@ -71,7 +71,7 @@ IDataSeries *Variable::dataSeries() const noexcept return impl->m_DataSeries.get(); } -bool Variable::contains(SqpDateTime dateTime) +bool Variable::contains(const SqpDateTime &dateTime) { if (!impl->m_DateTime.contains(dateTime)) { // The current variable dateTime isn't enough to display the dateTime requested. diff --git a/core/src/Variable/VariableCacheController.cpp b/core/src/Variable/VariableCacheController.cpp index 63209ce..34cb514 100644 --- a/core/src/Variable/VariableCacheController.cpp +++ b/core/src/Variable/VariableCacheController.cpp @@ -23,7 +23,7 @@ struct VariableCacheController::VariableCacheControllerPrivate { VariableCacheController::VariableCacheController(QObject *parent) - : QObject(parent), impl{spimpl::make_unique_impl()} + : QObject{parent}, impl{spimpl::make_unique_impl()} { } @@ -48,9 +48,8 @@ void VariableCacheController::addDateTime(std::shared_ptr variable, // will be compared to the next interval. The old one is remove from the list // C: if it is superior, we do the same with the next interval of the list - int cacheIndex = 0; impl->addDateTimeRecurse(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable), - cacheIndex); + 0); } } } @@ -94,7 +93,6 @@ void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse // The compared one is < to current one compared, we can insert it dateTimeList.insert(cacheIndex, dateTime); } - else if (dateTime.m_TStart > currentDateTime.m_TEnd) { // The compared one is > to current one compared we can comparet if to the next one addDateTimeRecurse(dateTime, dateTimeList, ++cacheIndex); @@ -153,11 +151,10 @@ void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataBySt } auto currentDateTimeI = dateTimeList[cacheIndex]; - auto cacheIndexJ = cacheIndex; if (currentTStart < currentDateTimeI.m_TStart) { // ts localised between to interval: let's localized te - addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndexJ, currentTStart); + addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex, currentTStart); } else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) { // ts not localised before the current interval: we need to look at the next interval diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index 54124b6..90d1368 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -122,22 +122,22 @@ void VariableController::requestDataLoading(std::shared_ptr variable, QElapsedTimer timer; timer.start(); - qCInfo(LOG_VariableController()) << "The slow s0 operation took" << timer.elapsed() + qCInfo(LOG_VariableController()) << "TORM: The slow s0 operation took" << timer.elapsed() << "milliseconds"; auto dateTimeListNotInCache = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime); - qCInfo(LOG_VariableController()) << "The slow s1 operation took" << timer.elapsed() + qCInfo(LOG_VariableController()) << "TORM: The slow s1 operation took" << timer.elapsed() << "milliseconds"; // Ask the provider for each data on the dateTimeListNotInCache impl->m_VariableToProviderMap.at(variable)->requestDataLoading(dateTimeListNotInCache); - qCInfo(LOG_VariableController()) << "The slow s2 operation took" << timer.elapsed() + qCInfo(LOG_VariableController()) << "TORM: The slow s2 operation took" << timer.elapsed() << "milliseconds"; // store in cache impl->m_VariableCacheController->addDateTime(variable, dateTime); - qCInfo(LOG_VariableController()) << "The slow s3 operation took" << timer.elapsed() + qCInfo(LOG_VariableController()) << "TORM: The slow s3 operation took" << timer.elapsed() << "milliseconds"; } else { diff --git a/core/tests/Variable/TestVariableCacheController.cpp b/core/tests/Variable/TestVariableCacheController.cpp index ab5e726..37e357d 100644 --- a/core/tests/Variable/TestVariableCacheController.cpp +++ b/core/tests/Variable/TestVariableCacheController.cpp @@ -51,9 +51,9 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); - auto notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + auto notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // second case ts < ts0 && ts0 < te <= te0 @@ -66,9 +66,9 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); // 3th case ts < ts0 && te0 < te <= ts1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; @@ -80,13 +80,13 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 2); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(1); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(1); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // 4th case ts < ts0 && ts1 < te <= te1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; @@ -98,13 +98,13 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 2); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(1); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(1); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); // 5th case ts < ts0 && te3 < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; @@ -116,21 +116,21 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 4); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(1); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(1); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(2); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts2.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(2); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts2.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(3); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te2.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(3); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te2.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // 6th case ts2 < ts @@ -143,9 +143,9 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // 7th case ts = te0 && te < ts1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; @@ -157,9 +157,9 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // 8th case ts0 < ts < te0 && te < ts1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; @@ -171,9 +171,9 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // 9th case ts0 < ts < te0 && ts1 < te < te1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; @@ -185,9 +185,9 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); // 10th case te1 < ts < te < ts2 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}}; @@ -199,9 +199,9 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // 11th case te0 < ts < ts1 && te3 < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; @@ -213,17 +213,17 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 3); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(1); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts2.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(1); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts2.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(2); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te2.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(2); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te2.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); // 12th case te0 < ts < ts1 && te3 < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; @@ -234,13 +234,13 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 2); - notInCashSqp = notInCach.first(); - QCOMPARE(notInCashSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.first(); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); - notInCashSqp = notInCach.at(1); - QCOMPARE(notInCashSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); - QCOMPARE(notInCashSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + notInCacheSqp = notInCach.at(1); + QCOMPARE(notInCacheSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); } diff --git a/gui/include/Visualization/GraphPlottablesFactory.h b/gui/include/Visualization/VisualizationGraphHelper.h similarity index 80% rename from gui/include/Visualization/GraphPlottablesFactory.h rename to gui/include/Visualization/VisualizationGraphHelper.h index 35126e5..f8f5687 100644 --- a/gui/include/Visualization/GraphPlottablesFactory.h +++ b/gui/include/Visualization/VisualizationGraphHelper.h @@ -1,5 +1,5 @@ -#ifndef SCIQLOP_GRAPHPLOTTABLESFACTORY_H -#define SCIQLOP_GRAPHPLOTTABLESFACTORY_H +#ifndef SCIQLOP_VISUALIZATIONGRAPHHELPER_H +#define SCIQLOP_VISUALIZATIONGRAPHHELPER_H #include @@ -8,7 +8,7 @@ #include -Q_DECLARE_LOGGING_CATEGORY(LOG_GraphPlottablesFactory) +Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphHelper) class IDataSeries; class QCPAbstractPlottable; @@ -16,10 +16,10 @@ class QCustomPlot; class Variable; /** - * @brief The GraphPlottablesFactory class aims to create the QCustomPlot components relative to a + * @brief The VisualizationGraphHelper class aims to create the QCustomPlot components relative to a * variable, depending on the data series of this variable */ -struct GraphPlottablesFactory { +struct VisualizationGraphHelper { /** * Creates (if possible) the QCustomPlot components relative to the variable passed in * parameter, and adds these to the plot passed in parameter. @@ -35,4 +35,4 @@ struct GraphPlottablesFactory { const SqpDateTime &dateTime); }; -#endif // SCIQLOP_GRAPHPLOTTABLESFACTORY_H +#endif // SCIQLOP_VISUALIZATIONGRAPHHELPER_H diff --git a/gui/src/Visualization/GraphPlottablesFactory.cpp b/gui/src/Visualization/VisualizationGraphHelper.cpp similarity index 90% rename from gui/src/Visualization/GraphPlottablesFactory.cpp rename to gui/src/Visualization/VisualizationGraphHelper.cpp index 3748d8f..f4a0122 100644 --- a/gui/src/Visualization/GraphPlottablesFactory.cpp +++ b/gui/src/Visualization/VisualizationGraphHelper.cpp @@ -1,4 +1,4 @@ -#include "Visualization/GraphPlottablesFactory.h" +#include "Visualization/VisualizationGraphHelper.h" #include "Visualization/qcustomplot.h" #include @@ -7,7 +7,7 @@ #include -Q_LOGGING_CATEGORY(LOG_GraphPlottablesFactory, "GraphPlottablesFactory") +Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper") namespace { @@ -37,8 +37,8 @@ void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie timer.start(); if (auto qcpGraph = dynamic_cast(component)) { // Clean the graph - qCDebug(LOG_GraphPlottablesFactory()) << "The slow s1 operation took" << timer.elapsed() - << "milliseconds"; + qCDebug(LOG_VisualizationGraphHelper()) << "The slow s1 operation took" << timer.elapsed() + << "milliseconds"; // NAIVE approch const auto &xData = scalarSeries.xAxisData()->data(); const auto &valuesData = scalarSeries.valuesData()->data(); @@ -59,8 +59,8 @@ void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie qcpGraph->setData(xValue, vValue); - qCDebug(LOG_GraphPlottablesFactory()) << "The slow s2 operation took" << timer.elapsed() - << "milliseconds"; + qCDebug(LOG_VisualizationGraphHelper()) << "The slow s2 operation took" << timer.elapsed() + << "milliseconds"; } else { /// @todo DEBUG @@ -99,7 +99,7 @@ QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC plot.replot(); } else { - qCDebug(LOG_GraphPlottablesFactory()) + qCDebug(LOG_VisualizationGraphHelper()) << QObject::tr("Can't create graph for the scalar series"); } @@ -108,8 +108,8 @@ QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC } // namespace -QVector GraphPlottablesFactory::create(std::shared_ptr variable, - QCustomPlot &plot) noexcept +QVector VisualizationGraphHelper::create(std::shared_ptr variable, + QCustomPlot &plot) noexcept { auto result = QVector{}; @@ -120,27 +120,27 @@ QVector GraphPlottablesFactory::create(std::shared_ptrdateTime())); } else { - qCDebug(LOG_GraphPlottablesFactory()) + qCDebug(LOG_VisualizationGraphHelper()) << QObject::tr("Can't create graph plottables : unmanaged data series type"); } } else { - qCDebug(LOG_GraphPlottablesFactory()) + qCDebug(LOG_VisualizationGraphHelper()) << QObject::tr("Can't create graph plottables : the variable is null"); } return result; } -void GraphPlottablesFactory::updateData(QVector plotableVect, - IDataSeries *dataSeries, const SqpDateTime &dateTime) +void VisualizationGraphHelper::updateData(QVector plotableVect, + IDataSeries *dataSeries, const SqpDateTime &dateTime) { if (auto scalarSeries = dynamic_cast(dataSeries)) { if (plotableVect.size() == 1) { updateScalarData(plotableVect.at(0), *scalarSeries, dateTime); } else { - qCCritical(LOG_GraphPlottablesFactory()) << QObject::tr( + qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr( "Can't update Data of a scalarSeries because there is not only one component " "associated"); } diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index c60b0f4..8f909b5 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -1,6 +1,6 @@ #include "Visualization/VisualizationGraphWidget.h" -#include "Visualization/GraphPlottablesFactory.h" #include "Visualization/IVisualizationWidgetVisitor.h" +#include "Visualization/VisualizationGraphHelper.h" #include "ui_VisualizationGraphWidget.h" #include @@ -61,7 +61,7 @@ VisualizationGraphWidget::~VisualizationGraphWidget() void VisualizationGraphWidget::addVariable(std::shared_ptr variable) { // Uses delegate to create the qcpplot components according to the variable - auto createdPlottables = GraphPlottablesFactory::create(variable, *ui->widget); + auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget); for (auto createdPlottable : qAsConst(createdPlottables)) { impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); @@ -142,11 +142,19 @@ void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept void VisualizationGraphWidget::onDataCacheVariableUpdated() { + // NOTE: + // We don't want to call the method for each component of a variable unitarily, but for all + // its components at once (eg its three components in the case of a vector). + + // The unordered_multimap does not do this easily, so the question is whether to: + // - use an ordered_multimap and the algos of std to group the values by key + // - use a map (unique keys) and store as values directly the list of components + for (auto it = impl->m_VariableToPlotMultiMap.cbegin(); it != impl->m_VariableToPlotMultiMap.cend(); ++it) { auto variable = it->first; - GraphPlottablesFactory::updateData(QVector{} << it->second, - variable->dataSeries(), variable->dateTime()); + VisualizationGraphHelper::updateData(QVector{} << it->second, + variable->dataSeries(), variable->dateTime()); } } @@ -160,6 +168,6 @@ void VisualizationGraphWidget::updateDisplay(std::shared_ptr variable) abstractPlotableVect.push_back(it->second); } - GraphPlottablesFactory::updateData(abstractPlotableVect, variable->dataSeries(), - variable->dateTime()); + VisualizationGraphHelper::updateData(abstractPlotableVect, variable->dataSeries(), + variable->dateTime()); } diff --git a/plugins/mockplugin/src/CosinusProvider.cpp b/plugins/mockplugin/src/CosinusProvider.cpp index d142c18..cd9ef2b 100644 --- a/plugins/mockplugin/src/CosinusProvider.cpp +++ b/plugins/mockplugin/src/CosinusProvider.cpp @@ -36,7 +36,7 @@ CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const void CosinusProvider::requestDataLoading(const QVector &dateTimeList) { // NOTE: Try to use multithread if possible - foreach (const auto &dateTime, dateTimeList) { + for (const auto &dateTime : dateTimeList) { auto scalarSeries = this->retrieveDataSeries(dateTime);