@@ -182,10 +182,16 MainWindow::MainWindow(QWidget *parent) | |||||
182 | connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(), |
|
182 | connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(), | |
183 | SLOT(onTimeToUpdate(SqpDateTime))); |
|
183 | SLOT(onTimeToUpdate(SqpDateTime))); | |
184 |
|
184 | |||
185 | // Variable |
|
185 | // Widgets / widgets connections | |
186 | qRegisterMetaType<std::shared_ptr<Variable> >(); |
|
186 | qRegisterMetaType<std::shared_ptr<Variable> >(); | |
187 | connect(&sqpApp->visualizationController(), SIGNAL(variableCreated(std::shared_ptr<Variable>)), |
|
187 | ||
188 | m_Ui->view, SLOT(displayVariable(std::shared_ptr<Variable>))); |
|
188 | // For the following connections, we use DirectConnection to allow each widget that can | |
|
189 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. | |||
|
190 | // The order of connections is also important, since it determines the order in which each | |||
|
191 | // widget will attach its menu | |||
|
192 | connect(m_Ui->variableInspectorWidget, | |||
|
193 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, std::shared_ptr<Variable>)), m_Ui->view, | |||
|
194 | SLOT(attachVariableMenu(QMenu *, std::shared_ptr<Variable>)), Qt::DirectConnection); | |||
189 |
|
195 | |||
190 | /* QLopGUI::registerMenuBar(menuBar()); |
|
196 | /* QLopGUI::registerMenuBar(menuBar()); | |
191 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
|
197 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
@@ -26,11 +26,11 SET (CPACK_PACKAGE_VERSION_MAJOR "${SCIQLOP_VERSION_MAJOR}") | |||||
26 | SET (CPACK_PACKAGE_VERSION_MINOR "${SCIQLOP_VERSION_MINOR}") |
|
26 | SET (CPACK_PACKAGE_VERSION_MINOR "${SCIQLOP_VERSION_MINOR}") | |
27 | SET (CPACK_PACKAGE_VERSION_PATCH "${SCIQLOP_VERSION_PATCH}${SCIQLOP_VERSION_SUFFIX}") |
|
27 | SET (CPACK_PACKAGE_VERSION_PATCH "${SCIQLOP_VERSION_PATCH}${SCIQLOP_VERSION_SUFFIX}") | |
28 | SET (CPACK_PACKAGE_VERSION "${SCIQLOP_VERSION}") |
|
28 | SET (CPACK_PACKAGE_VERSION "${SCIQLOP_VERSION}") | |
29 |
SET (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/ |
|
29 | SET (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING) | |
30 | SET (CPACK_PACKAGE_CONTACT "nicolas.aunai@lpp.polytechnique.fr") |
|
30 | SET (CPACK_PACKAGE_CONTACT "nicolas.aunai@lpp.polytechnique.fr") | |
31 | SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md) |
|
31 | SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md) | |
32 | # SET(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_SOURCE_DIR}/WARN.txt) |
|
32 | # SET(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_SOURCE_DIR}/WARN.txt) | |
33 |
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/ |
|
33 | SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) | |
34 | # SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME}-${PROJECT_VERSION}) |
|
34 | # SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME}-${PROJECT_VERSION}) | |
35 | SET(FULLBUILD ON) |
|
35 | SET(FULLBUILD ON) | |
36 |
|
36 |
@@ -4,8 +4,15 | |||||
4 | #include <Data/ArrayData.h> |
|
4 | #include <Data/ArrayData.h> | |
5 | #include <Data/IDataSeries.h> |
|
5 | #include <Data/IDataSeries.h> | |
6 |
|
6 | |||
|
7 | #include <QLoggingCategory> | |||
|
8 | ||||
7 | #include <memory> |
|
9 | #include <memory> | |
8 |
|
10 | |||
|
11 | ||||
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSeries) | |||
|
13 | Q_LOGGING_CATEGORY(LOG_DataSeries, "DataSeries") | |||
|
14 | ||||
|
15 | ||||
9 | /** |
|
16 | /** | |
10 | * @brief The DataSeries class is the base (abstract) implementation of IDataSeries. |
|
17 | * @brief The DataSeries class is the base (abstract) implementation of IDataSeries. | |
11 | * |
|
18 | * | |
@@ -36,6 +43,10 public: | |||||
36 | m_XAxisData->merge(dimDataSeries->xAxisData().get()); |
|
43 | m_XAxisData->merge(dimDataSeries->xAxisData().get()); | |
37 | m_ValuesData->merge(dimDataSeries->valuesData().get()); |
|
44 | m_ValuesData->merge(dimDataSeries->valuesData().get()); | |
38 | } |
|
45 | } | |
|
46 | else { | |||
|
47 | qCWarning(LOG_DataSeries()) | |||
|
48 | << QObject::tr("Dection of a type of IDataSeries we cannot merge with !"); | |||
|
49 | } | |||
39 | } |
|
50 | } | |
40 |
|
51 | |||
41 | protected: |
|
52 | protected: |
@@ -31,7 +31,7 public: | |||||
31 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; |
|
31 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; | |
32 |
|
32 | |||
33 | signals: |
|
33 | signals: | |
34 | void dataProvided(std::shared_ptr<IDataSeries> dateSerie, SqpDateTime dateTime); |
|
34 | void dataProvided(std::shared_ptr<IDataSeries> dateSerie, const SqpDateTime &dateTime); | |
35 | }; |
|
35 | }; | |
36 | // Required for using shared_ptr in signals/slots |
|
36 | // Required for using shared_ptr in signals/slots | |
37 | Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>) |
|
37 | Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>) |
@@ -33,7 +33,7 public: | |||||
33 | /// @return the data of the variable, nullptr if there is no data |
|
33 | /// @return the data of the variable, nullptr if there is no data | |
34 | IDataSeries *dataSeries() const noexcept; |
|
34 | IDataSeries *dataSeries() const noexcept; | |
35 |
|
35 | |||
36 | bool contains(SqpDateTime dateTime); |
|
36 | bool contains(const SqpDateTime &dateTime); | |
37 | void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept; |
|
37 | void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept; | |
38 |
|
38 | |||
39 | public slots: |
|
39 | public slots: |
@@ -9,7 +9,7 | |||||
9 |
|
9 | |||
10 | class Variable; |
|
10 | class Variable; | |
11 |
|
11 | |||
12 |
/// This class aims to store in the ca |
|
12 | /// This class aims to store in the cache all of the dateTime already requested to the variable. | |
13 | class VariableCacheController : public QObject { |
|
13 | class VariableCacheController : public QObject { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 | public: |
|
15 | public: |
@@ -32,6 +32,8 public: | |||||
32 | createVariable(const QString &name, const SqpDateTime &dateTime, |
|
32 | createVariable(const QString &name, const SqpDateTime &dateTime, | |
33 | std::unique_ptr<IDataSeries> defaultDataSeries) noexcept; |
|
33 | std::unique_ptr<IDataSeries> defaultDataSeries) noexcept; | |
34 |
|
34 | |||
|
35 | std::shared_ptr<Variable> variable(int index) const; | |||
|
36 | ||||
35 | // /////////////////////////// // |
|
37 | // /////////////////////////// // | |
36 | // QAbstractTableModel methods // |
|
38 | // QAbstractTableModel methods // | |
37 | // /////////////////////////// // |
|
39 | // /////////////////////////// // |
@@ -71,7 +71,7 IDataSeries *Variable::dataSeries() const noexcept | |||||
71 | return impl->m_DataSeries.get(); |
|
71 | return impl->m_DataSeries.get(); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | bool Variable::contains(SqpDateTime dateTime) |
|
74 | bool Variable::contains(const SqpDateTime &dateTime) | |
75 | { |
|
75 | { | |
76 | if (!impl->m_DateTime.contains(dateTime)) { |
|
76 | if (!impl->m_DateTime.contains(dateTime)) { | |
77 | // The current variable dateTime isn't enough to display the dateTime requested. |
|
77 | // The current variable dateTime isn't enough to display the dateTime requested. |
@@ -23,7 +23,7 struct VariableCacheController::VariableCacheControllerPrivate { | |||||
23 |
|
23 | |||
24 |
|
24 | |||
25 | VariableCacheController::VariableCacheController(QObject *parent) |
|
25 | VariableCacheController::VariableCacheController(QObject *parent) | |
26 |
: QObject |
|
26 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableCacheControllerPrivate>()} | |
27 | { |
|
27 | { | |
28 | } |
|
28 | } | |
29 |
|
29 | |||
@@ -48,9 +48,8 void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable, | |||||
48 | // will be compared to the next interval. The old one is remove from the list |
|
48 | // will be compared to the next interval. The old one is remove from the list | |
49 | // C: if it is superior, we do the same with the next interval of the list |
|
49 | // C: if it is superior, we do the same with the next interval of the list | |
50 |
|
50 | |||
51 | int cacheIndex = 0; |
|
|||
52 | impl->addDateTimeRecurse(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable), |
|
51 | impl->addDateTimeRecurse(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable), | |
53 |
|
|
52 | 0); | |
54 | } |
|
53 | } | |
55 | } |
|
54 | } | |
56 | } |
|
55 | } | |
@@ -94,7 +93,6 void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse | |||||
94 | // The compared one is < to current one compared, we can insert it |
|
93 | // The compared one is < to current one compared, we can insert it | |
95 | dateTimeList.insert(cacheIndex, dateTime); |
|
94 | dateTimeList.insert(cacheIndex, dateTime); | |
96 | } |
|
95 | } | |
97 |
|
||||
98 | else if (dateTime.m_TStart > currentDateTime.m_TEnd) { |
|
96 | else if (dateTime.m_TStart > currentDateTime.m_TEnd) { | |
99 | // The compared one is > to current one compared we can comparet if to the next one |
|
97 | // The compared one is > to current one compared we can comparet if to the next one | |
100 | addDateTimeRecurse(dateTime, dateTimeList, ++cacheIndex); |
|
98 | addDateTimeRecurse(dateTime, dateTimeList, ++cacheIndex); | |
@@ -153,11 +151,10 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataBySt | |||||
153 | } |
|
151 | } | |
154 |
|
152 | |||
155 | auto currentDateTimeI = dateTimeList[cacheIndex]; |
|
153 | auto currentDateTimeI = dateTimeList[cacheIndex]; | |
156 | auto cacheIndexJ = cacheIndex; |
|
|||
157 | if (currentTStart < currentDateTimeI.m_TStart) { |
|
154 | if (currentTStart < currentDateTimeI.m_TStart) { | |
158 |
|
155 | |||
159 | // ts localised between to interval: let's localized te |
|
156 | // ts localised between to interval: let's localized te | |
160 |
addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex |
|
157 | addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex, currentTStart); | |
161 | } |
|
158 | } | |
162 | else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) { |
|
159 | else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) { | |
163 | // ts not localised before the current interval: we need to look at the next interval |
|
160 | // ts not localised before the current interval: we need to look at the next interval |
@@ -122,22 +122,22 void VariableController::requestDataLoading(std::shared_ptr<Variable> variable, | |||||
122 |
|
122 | |||
123 | QElapsedTimer timer; |
|
123 | QElapsedTimer timer; | |
124 | timer.start(); |
|
124 | timer.start(); | |
125 | qCInfo(LOG_VariableController()) << "The slow s0 operation took" << timer.elapsed() |
|
125 | qCInfo(LOG_VariableController()) << "TORM: The slow s0 operation took" << timer.elapsed() | |
126 | << "milliseconds"; |
|
126 | << "milliseconds"; | |
127 | auto dateTimeListNotInCache |
|
127 | auto dateTimeListNotInCache | |
128 | = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime); |
|
128 | = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime); | |
129 | qCInfo(LOG_VariableController()) << "The slow s1 operation took" << timer.elapsed() |
|
129 | qCInfo(LOG_VariableController()) << "TORM: The slow s1 operation took" << timer.elapsed() | |
130 | << "milliseconds"; |
|
130 | << "milliseconds"; | |
131 |
|
131 | |||
132 | // Ask the provider for each data on the dateTimeListNotInCache |
|
132 | // Ask the provider for each data on the dateTimeListNotInCache | |
133 | impl->m_VariableToProviderMap.at(variable)->requestDataLoading(dateTimeListNotInCache); |
|
133 | impl->m_VariableToProviderMap.at(variable)->requestDataLoading(dateTimeListNotInCache); | |
134 |
|
134 | |||
135 | qCInfo(LOG_VariableController()) << "The slow s2 operation took" << timer.elapsed() |
|
135 | qCInfo(LOG_VariableController()) << "TORM: The slow s2 operation took" << timer.elapsed() | |
136 | << "milliseconds"; |
|
136 | << "milliseconds"; | |
137 |
|
137 | |||
138 | // store in cache |
|
138 | // store in cache | |
139 | impl->m_VariableCacheController->addDateTime(variable, dateTime); |
|
139 | impl->m_VariableCacheController->addDateTime(variable, dateTime); | |
140 | qCInfo(LOG_VariableController()) << "The slow s3 operation took" << timer.elapsed() |
|
140 | qCInfo(LOG_VariableController()) << "TORM: The slow s3 operation took" << timer.elapsed() | |
141 | << "milliseconds"; |
|
141 | << "milliseconds"; | |
142 | } |
|
142 | } | |
143 | else { |
|
143 | else { |
@@ -44,6 +44,11 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime, | |||||
44 | return variable; |
|
44 | return variable; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
|
47 | std::shared_ptr<Variable> VariableModel::variable(int index) const | |||
|
48 | { | |||
|
49 | return (index >= 0 && index < impl->m_Variables.size()) ? impl->m_Variables[index] : nullptr; | |||
|
50 | } | |||
|
51 | ||||
47 | int VariableModel::columnCount(const QModelIndex &parent) const |
|
52 | int VariableModel::columnCount(const QModelIndex &parent) const | |
48 | { |
|
53 | { | |
49 | Q_UNUSED(parent); |
|
54 | Q_UNUSED(parent); |
@@ -51,9 +51,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
51 | auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
51 | auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
52 |
|
52 | |||
53 | QCOMPARE(notInCach.size(), 1); |
|
53 | QCOMPARE(notInCach.size(), 1); | |
54 |
auto notInCa |
|
54 | auto notInCacheSqp = notInCach.first(); | |
55 |
QCOMPARE(notInCa |
|
55 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
56 |
QCOMPARE(notInCa |
|
56 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
57 |
|
57 | |||
58 |
|
58 | |||
59 | // second case ts < ts0 && ts0 < te <= te0 |
|
59 | // second case ts < ts0 && ts0 < te <= te0 | |
@@ -66,9 +66,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
66 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
66 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
67 |
|
67 | |||
68 | QCOMPARE(notInCach.size(), 1); |
|
68 | QCOMPARE(notInCach.size(), 1); | |
69 |
notInCa |
|
69 | notInCacheSqp = notInCach.first(); | |
70 |
QCOMPARE(notInCa |
|
70 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
71 |
QCOMPARE(notInCa |
|
71 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch())); | |
72 |
|
72 | |||
73 | // 3th case ts < ts0 && te0 < te <= ts1 |
|
73 | // 3th case ts < ts0 && te0 < te <= ts1 | |
74 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
74 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
@@ -80,13 +80,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
80 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
80 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
81 |
|
81 | |||
82 | QCOMPARE(notInCach.size(), 2); |
|
82 | QCOMPARE(notInCach.size(), 2); | |
83 |
notInCa |
|
83 | notInCacheSqp = notInCach.first(); | |
84 |
QCOMPARE(notInCa |
|
84 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
85 |
QCOMPARE(notInCa |
|
85 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch())); | |
86 |
|
86 | |||
87 |
notInCa |
|
87 | notInCacheSqp = notInCach.at(1); | |
88 |
QCOMPARE(notInCa |
|
88 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch())); | |
89 |
QCOMPARE(notInCa |
|
89 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
90 |
|
90 | |||
91 | // 4th case ts < ts0 && ts1 < te <= te1 |
|
91 | // 4th case ts < ts0 && ts1 < te <= te1 | |
92 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
92 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
@@ -98,13 +98,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
98 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
98 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
99 |
|
99 | |||
100 | QCOMPARE(notInCach.size(), 2); |
|
100 | QCOMPARE(notInCach.size(), 2); | |
101 |
notInCa |
|
101 | notInCacheSqp = notInCach.first(); | |
102 |
QCOMPARE(notInCa |
|
102 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
103 |
QCOMPARE(notInCa |
|
103 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch())); | |
104 |
|
104 | |||
105 |
notInCa |
|
105 | notInCacheSqp = notInCach.at(1); | |
106 |
QCOMPARE(notInCa |
|
106 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch())); | |
107 |
QCOMPARE(notInCa |
|
107 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch())); | |
108 |
|
108 | |||
109 | // 5th case ts < ts0 && te3 < te |
|
109 | // 5th case ts < ts0 && te3 < te | |
110 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
110 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; | |
@@ -116,21 +116,21 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
116 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
116 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
117 |
|
117 | |||
118 | QCOMPARE(notInCach.size(), 4); |
|
118 | QCOMPARE(notInCach.size(), 4); | |
119 |
notInCa |
|
119 | notInCacheSqp = notInCach.first(); | |
120 |
QCOMPARE(notInCa |
|
120 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
121 |
QCOMPARE(notInCa |
|
121 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch())); | |
122 |
|
122 | |||
123 |
notInCa |
|
123 | notInCacheSqp = notInCach.at(1); | |
124 |
QCOMPARE(notInCa |
|
124 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch())); | |
125 |
QCOMPARE(notInCa |
|
125 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch())); | |
126 |
|
126 | |||
127 |
notInCa |
|
127 | notInCacheSqp = notInCach.at(2); | |
128 |
QCOMPARE(notInCa |
|
128 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch())); | |
129 |
QCOMPARE(notInCa |
|
129 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch())); | |
130 |
|
130 | |||
131 |
notInCa |
|
131 | notInCacheSqp = notInCach.at(3); | |
132 |
QCOMPARE(notInCa |
|
132 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch())); | |
133 |
QCOMPARE(notInCa |
|
133 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
134 |
|
134 | |||
135 |
|
135 | |||
136 | // 6th case ts2 < ts |
|
136 | // 6th case ts2 < ts | |
@@ -143,9 +143,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
143 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
143 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
144 |
|
144 | |||
145 | QCOMPARE(notInCach.size(), 1); |
|
145 | QCOMPARE(notInCach.size(), 1); | |
146 |
notInCa |
|
146 | notInCacheSqp = notInCach.first(); | |
147 |
QCOMPARE(notInCa |
|
147 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
148 |
QCOMPARE(notInCa |
|
148 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
149 |
|
149 | |||
150 | // 7th case ts = te0 && te < ts1 |
|
150 | // 7th case ts = te0 && te < ts1 | |
151 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
151 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; | |
@@ -157,9 +157,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
157 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
157 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
158 |
|
158 | |||
159 | QCOMPARE(notInCach.size(), 1); |
|
159 | QCOMPARE(notInCach.size(), 1); | |
160 |
notInCa |
|
160 | notInCacheSqp = notInCach.first(); | |
161 |
QCOMPARE(notInCa |
|
161 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch())); | |
162 |
QCOMPARE(notInCa |
|
162 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
163 |
|
163 | |||
164 | // 8th case ts0 < ts < te0 && te < ts1 |
|
164 | // 8th case ts0 < ts < te0 && te < ts1 | |
165 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
165 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
@@ -171,9 +171,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
171 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
171 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
172 |
|
172 | |||
173 | QCOMPARE(notInCach.size(), 1); |
|
173 | QCOMPARE(notInCach.size(), 1); | |
174 |
notInCa |
|
174 | notInCacheSqp = notInCach.first(); | |
175 |
QCOMPARE(notInCa |
|
175 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch())); | |
176 |
QCOMPARE(notInCa |
|
176 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
177 |
|
177 | |||
178 | // 9th case ts0 < ts < te0 && ts1 < te < te1 |
|
178 | // 9th case ts0 < ts < te0 && ts1 < te < te1 | |
179 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
179 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; | |
@@ -185,9 +185,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
185 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
185 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
186 |
|
186 | |||
187 | QCOMPARE(notInCach.size(), 1); |
|
187 | QCOMPARE(notInCach.size(), 1); | |
188 |
notInCa |
|
188 | notInCacheSqp = notInCach.first(); | |
189 |
QCOMPARE(notInCa |
|
189 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch())); | |
190 |
QCOMPARE(notInCa |
|
190 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch())); | |
191 |
|
191 | |||
192 | // 10th case te1 < ts < te < ts2 |
|
192 | // 10th case te1 < ts < te < ts2 | |
193 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}}; |
|
193 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}}; | |
@@ -199,9 +199,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
199 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
199 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
200 |
|
200 | |||
201 | QCOMPARE(notInCach.size(), 1); |
|
201 | QCOMPARE(notInCach.size(), 1); | |
202 |
notInCa |
|
202 | notInCacheSqp = notInCach.first(); | |
203 |
QCOMPARE(notInCa |
|
203 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
204 |
QCOMPARE(notInCa |
|
204 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
205 |
|
205 | |||
206 | // 11th case te0 < ts < ts1 && te3 < te |
|
206 | // 11th case te0 < ts < ts1 && te3 < te | |
207 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
207 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
@@ -213,17 +213,17 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
213 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
213 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
214 |
|
214 | |||
215 | QCOMPARE(notInCach.size(), 3); |
|
215 | QCOMPARE(notInCach.size(), 3); | |
216 |
notInCa |
|
216 | notInCacheSqp = notInCach.first(); | |
217 |
QCOMPARE(notInCa |
|
217 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
218 |
QCOMPARE(notInCa |
|
218 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch())); | |
219 |
|
219 | |||
220 |
notInCa |
|
220 | notInCacheSqp = notInCach.at(1); | |
221 |
QCOMPARE(notInCa |
|
221 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch())); | |
222 |
QCOMPARE(notInCa |
|
222 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch())); | |
223 |
|
223 | |||
224 |
notInCa |
|
224 | notInCacheSqp = notInCach.at(2); | |
225 |
QCOMPARE(notInCa |
|
225 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch())); | |
226 |
QCOMPARE(notInCa |
|
226 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
227 |
|
227 | |||
228 | // 12th case te0 < ts < ts1 && te3 < te |
|
228 | // 12th case te0 < ts < ts1 && te3 < te | |
229 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
229 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; | |
@@ -234,13 +234,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||||
234 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
234 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); | |
235 |
|
235 | |||
236 | QCOMPARE(notInCach.size(), 2); |
|
236 | QCOMPARE(notInCach.size(), 2); | |
237 |
notInCa |
|
237 | notInCacheSqp = notInCach.first(); | |
238 |
QCOMPARE(notInCa |
|
238 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch())); | |
239 |
QCOMPARE(notInCa |
|
239 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch())); | |
240 |
|
240 | |||
241 |
notInCa |
|
241 | notInCacheSqp = notInCach.at(1); | |
242 |
QCOMPARE(notInCa |
|
242 | QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch())); | |
243 |
QCOMPARE(notInCa |
|
243 | QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch())); | |
244 | } |
|
244 | } | |
245 |
|
245 | |||
246 |
|
246 |
@@ -91,7 +91,6 FUNCTION(ADD_CLANGFORMAT_TARGETS) | |||||
91 | ENDFOREACH(item ${globs}) |
|
91 | ENDFOREACH(item ${globs}) | |
92 |
|
92 | |||
93 | LIST(REMOVE_ITEM srcs ${UIS}) |
|
93 | LIST(REMOVE_ITEM srcs ${UIS}) | |
94 | message("format lang: ${srcs}" ) |
|
|||
95 | FOREACH (s ${srcs}) |
|
94 | FOREACH (s ${srcs}) | |
96 | SET(touchedFile ${formatDirectory}/format_touchedfile_${reportNb}) |
|
95 | SET(touchedFile ${formatDirectory}/format_touchedfile_${reportNb}) | |
97 | IF(addToAll) |
|
96 | IF(addToAll) |
@@ -1,8 +1,16 | |||||
1 | #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H |
|
1 | #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H | |
2 | #define SCIQLOP_VARIABLEINSPECTORWIDGET_H |
|
2 | #define SCIQLOP_VARIABLEINSPECTORWIDGET_H | |
3 |
|
3 | |||
|
4 | #include <QLoggingCategory> | |||
|
5 | #include <QMenu> | |||
4 | #include <QWidget> |
|
6 | #include <QWidget> | |
5 |
|
7 | |||
|
8 | #include <memory> | |||
|
9 | ||||
|
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableInspectorWidget) | |||
|
11 | ||||
|
12 | class Variable; | |||
|
13 | ||||
6 | namespace Ui { |
|
14 | namespace Ui { | |
7 | class VariableInspectorWidget; |
|
15 | class VariableInspectorWidget; | |
8 | } // Ui |
|
16 | } // Ui | |
@@ -19,8 +27,23 public: | |||||
19 | explicit VariableInspectorWidget(QWidget *parent = 0); |
|
27 | explicit VariableInspectorWidget(QWidget *parent = 0); | |
20 | virtual ~VariableInspectorWidget(); |
|
28 | virtual ~VariableInspectorWidget(); | |
21 |
|
29 | |||
|
30 | signals: | |||
|
31 | /** | |||
|
32 | * Signal emitted before a menu concerning a variable is displayed. It is used for other widgets | |||
|
33 | * to complete the menu. | |||
|
34 | * @param tableMenu the menu to be completed | |||
|
35 | * @param variable the variable concerned by the menu | |||
|
36 | * @remarks To make the dynamic addition of menus work, the connections to this signal must be | |||
|
37 | * in Qt :: DirectConnection | |||
|
38 | */ | |||
|
39 | void tableMenuAboutToBeDisplayed(QMenu *tableMenu, std::shared_ptr<Variable> variable); | |||
|
40 | ||||
22 | private: |
|
41 | private: | |
23 | Ui::VariableInspectorWidget *ui; |
|
42 | Ui::VariableInspectorWidget *ui; | |
|
43 | ||||
|
44 | private slots: | |||
|
45 | /// Slot called when right clicking on an variable in the table (displays a menu) | |||
|
46 | void onTableMenuRequested(const QPoint &pos) noexcept; | |||
24 | }; |
|
47 | }; | |
25 |
|
48 | |||
26 | #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H |
|
49 | #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H |
@@ -1,5 +1,5 | |||||
1 |
#ifndef SCIQLOP_ |
|
1 | #ifndef SCIQLOP_VISUALIZATIONGRAPHHELPER_H | |
2 |
#define SCIQLOP_ |
|
2 | #define SCIQLOP_VISUALIZATIONGRAPHHELPER_H | |
3 |
|
3 | |||
4 | #include <Data/SqpDateTime.h> |
|
4 | #include <Data/SqpDateTime.h> | |
5 |
|
5 | |||
@@ -8,7 +8,7 | |||||
8 |
|
8 | |||
9 | #include <memory> |
|
9 | #include <memory> | |
10 |
|
10 | |||
11 |
Q_DECLARE_LOGGING_CATEGORY(LOG_ |
|
11 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphHelper) | |
12 |
|
12 | |||
13 | class IDataSeries; |
|
13 | class IDataSeries; | |
14 | class QCPAbstractPlottable; |
|
14 | class QCPAbstractPlottable; | |
@@ -16,10 +16,10 class QCustomPlot; | |||||
16 | class Variable; |
|
16 | class Variable; | |
17 |
|
17 | |||
18 | /** |
|
18 | /** | |
19 |
* @brief The |
|
19 | * @brief The VisualizationGraphHelper class aims to create the QCustomPlot components relative to a | |
20 | * variable, depending on the data series of this variable |
|
20 | * variable, depending on the data series of this variable | |
21 | */ |
|
21 | */ | |
22 | struct GraphPlottablesFactory { |
|
22 | struct VisualizationGraphHelper { | |
23 | /** |
|
23 | /** | |
24 | * Creates (if possible) the QCustomPlot components relative to the variable passed in |
|
24 | * Creates (if possible) the QCustomPlot components relative to the variable passed in | |
25 | * parameter, and adds these to the plot passed in parameter. |
|
25 | * parameter, and adds these to the plot passed in parameter. | |
@@ -35,4 +35,4 struct GraphPlottablesFactory { | |||||
35 | const SqpDateTime &dateTime); |
|
35 | const SqpDateTime &dateTime); | |
36 | }; |
|
36 | }; | |
37 |
|
37 | |||
38 |
#endif // SCIQLOP_ |
|
38 | #endif // SCIQLOP_VISUALIZATIONGRAPHHELPER_H |
@@ -8,6 +8,7 | |||||
8 |
|
8 | |||
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) |
|
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) | |
10 |
|
10 | |||
|
11 | class QMenu; | |||
11 | class Variable; |
|
12 | class Variable; | |
12 | class VisualizationTabWidget; |
|
13 | class VisualizationTabWidget; | |
13 |
|
14 | |||
@@ -39,12 +40,11 public: | |||||
39 |
|
40 | |||
40 | public slots: |
|
41 | public slots: | |
41 | /** |
|
42 | /** | |
42 | * Displays a variable in a new graph of a new zone of the current tab |
|
43 | * Attaches to a menu the menu relating to the visualization of a variable | |
43 | * @param variable the variable to display |
|
44 | * @param menu the parent menu of the generated menu | |
44 | * @todo this is a temporary method that will be replaced by own actions for each type of |
|
45 | * @param variable the variable for which to generate the menu | |
45 | * visualization widget |
|
|||
46 | */ |
|
46 | */ | |
47 |
void |
|
47 | void attachVariableMenu(QMenu *menu, std::shared_ptr<Variable> variable) noexcept; | |
48 |
|
48 | |||
49 | private: |
|
49 | private: | |
50 | Ui::VisualizationWidget *ui; |
|
50 | Ui::VisualizationWidget *ui; |
@@ -8,6 +8,8 | |||||
8 |
|
8 | |||
9 | #include <SqpApplication.h> |
|
9 | #include <SqpApplication.h> | |
10 |
|
10 | |||
|
11 | Q_LOGGING_CATEGORY(LOG_VariableInspectorWidget, "VariableInspectorWidget") | |||
|
12 | ||||
11 | VariableInspectorWidget::VariableInspectorWidget(QWidget *parent) |
|
13 | VariableInspectorWidget::VariableInspectorWidget(QWidget *parent) | |
12 | : QWidget{parent}, ui{new Ui::VariableInspectorWidget} |
|
14 | : QWidget{parent}, ui{new Ui::VariableInspectorWidget} | |
13 | { |
|
15 | { | |
@@ -18,9 +20,38 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent) | |||||
18 | sortFilterModel->setSourceModel(sqpApp->variableController().variableModel()); |
|
20 | sortFilterModel->setSourceModel(sqpApp->variableController().variableModel()); | |
19 |
|
21 | |||
20 | ui->tableView->setModel(sortFilterModel); |
|
22 | ui->tableView->setModel(sortFilterModel); | |
|
23 | ||||
|
24 | // Connection to show a menu when right clicking on the tree | |||
|
25 | ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu); | |||
|
26 | connect(ui->tableView, &QTableView::customContextMenuRequested, this, | |||
|
27 | &VariableInspectorWidget::onTableMenuRequested); | |||
21 | } |
|
28 | } | |
22 |
|
29 | |||
23 | VariableInspectorWidget::~VariableInspectorWidget() |
|
30 | VariableInspectorWidget::~VariableInspectorWidget() | |
24 | { |
|
31 | { | |
25 | delete ui; |
|
32 | delete ui; | |
26 | } |
|
33 | } | |
|
34 | ||||
|
35 | void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept | |||
|
36 | { | |||
|
37 | auto selectedIndex = ui->tableView->indexAt(pos); | |||
|
38 | if (selectedIndex.isValid()) { | |||
|
39 | // Gets the model to retrieve the underlying selected variable | |||
|
40 | auto model = sqpApp->variableController().variableModel(); | |||
|
41 | if (auto selectedVariable = model->variable(selectedIndex.row())) { | |||
|
42 | QMenu tableMenu{}; | |||
|
43 | ||||
|
44 | // Emit a signal so that potential receivers can populate the menu before displaying it | |||
|
45 | emit tableMenuAboutToBeDisplayed(&tableMenu, selectedVariable); | |||
|
46 | ||||
|
47 | if (!tableMenu.isEmpty()) { | |||
|
48 | tableMenu.exec(mapToGlobal(pos)); | |||
|
49 | } | |||
|
50 | } | |||
|
51 | } | |||
|
52 | else { | |||
|
53 | qCCritical(LOG_VariableInspectorWidget()) | |||
|
54 | << tr("Can't display menu : invalid index (%1;%2)") | |||
|
55 | .arg(selectedIndex.row(), selectedIndex.column()); | |||
|
56 | } | |||
|
57 | } |
@@ -1,4 +1,4 | |||||
1 |
#include "Visualization/ |
|
1 | #include "Visualization/VisualizationGraphHelper.h" | |
2 | #include "Visualization/qcustomplot.h" |
|
2 | #include "Visualization/qcustomplot.h" | |
3 |
|
3 | |||
4 | #include <Data/ScalarSeries.h> |
|
4 | #include <Data/ScalarSeries.h> | |
@@ -7,7 +7,7 | |||||
7 |
|
7 | |||
8 | #include <QElapsedTimer> |
|
8 | #include <QElapsedTimer> | |
9 |
|
9 | |||
10 | Q_LOGGING_CATEGORY(LOG_GraphPlottablesFactory, "GraphPlottablesFactory") |
|
10 | Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper") | |
11 |
|
11 | |||
12 | namespace { |
|
12 | namespace { | |
13 |
|
13 | |||
@@ -37,8 +37,8 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie | |||||
37 | timer.start(); |
|
37 | timer.start(); | |
38 | if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) { |
|
38 | if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) { | |
39 | // Clean the graph |
|
39 | // Clean the graph | |
40 |
qCDebug(LOG_ |
|
40 | qCDebug(LOG_VisualizationGraphHelper()) << "The slow s1 operation took" << timer.elapsed() | |
41 | << "milliseconds"; |
|
41 | << "milliseconds"; | |
42 | // NAIVE approch |
|
42 | // NAIVE approch | |
43 | const auto &xData = scalarSeries.xAxisData()->data(); |
|
43 | const auto &xData = scalarSeries.xAxisData()->data(); | |
44 | const auto &valuesData = scalarSeries.valuesData()->data(); |
|
44 | const auto &valuesData = scalarSeries.valuesData()->data(); | |
@@ -59,8 +59,8 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie | |||||
59 |
|
59 | |||
60 | qcpGraph->setData(xValue, vValue); |
|
60 | qcpGraph->setData(xValue, vValue); | |
61 |
|
61 | |||
62 |
qCDebug(LOG_ |
|
62 | qCDebug(LOG_VisualizationGraphHelper()) << "The slow s2 operation took" << timer.elapsed() | |
63 | << "milliseconds"; |
|
63 | << "milliseconds"; | |
64 | } |
|
64 | } | |
65 | else { |
|
65 | else { | |
66 | /// @todo DEBUG |
|
66 | /// @todo DEBUG | |
@@ -99,7 +99,7 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC | |||||
99 | plot.replot(); |
|
99 | plot.replot(); | |
100 | } |
|
100 | } | |
101 | else { |
|
101 | else { | |
102 |
qCDebug(LOG_ |
|
102 | qCDebug(LOG_VisualizationGraphHelper()) | |
103 | << QObject::tr("Can't create graph for the scalar series"); |
|
103 | << QObject::tr("Can't create graph for the scalar series"); | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
@@ -108,8 +108,8 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC | |||||
108 |
|
108 | |||
109 | } // namespace |
|
109 | } // namespace | |
110 |
|
110 | |||
111 |
QVector<QCPAbstractPlottable *> |
|
111 | QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable, | |
112 | QCustomPlot &plot) noexcept |
|
112 | QCustomPlot &plot) noexcept | |
113 | { |
|
113 | { | |
114 | auto result = QVector<QCPAbstractPlottable *>{}; |
|
114 | auto result = QVector<QCPAbstractPlottable *>{}; | |
115 |
|
115 | |||
@@ -120,27 +120,27 QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(std::shared_ptr<V | |||||
120 | result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime())); |
|
120 | result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime())); | |
121 | } |
|
121 | } | |
122 | else { |
|
122 | else { | |
123 |
qCDebug(LOG_ |
|
123 | qCDebug(LOG_VisualizationGraphHelper()) | |
124 | << QObject::tr("Can't create graph plottables : unmanaged data series type"); |
|
124 | << QObject::tr("Can't create graph plottables : unmanaged data series type"); | |
125 | } |
|
125 | } | |
126 | } |
|
126 | } | |
127 | else { |
|
127 | else { | |
128 |
qCDebug(LOG_ |
|
128 | qCDebug(LOG_VisualizationGraphHelper()) | |
129 | << QObject::tr("Can't create graph plottables : the variable is null"); |
|
129 | << QObject::tr("Can't create graph plottables : the variable is null"); | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | return result; |
|
132 | return result; | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 |
void |
|
135 | void VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *> plotableVect, | |
136 | IDataSeries *dataSeries, const SqpDateTime &dateTime) |
|
136 | IDataSeries *dataSeries, const SqpDateTime &dateTime) | |
137 | { |
|
137 | { | |
138 | if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) { |
|
138 | if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) { | |
139 | if (plotableVect.size() == 1) { |
|
139 | if (plotableVect.size() == 1) { | |
140 | updateScalarData(plotableVect.at(0), *scalarSeries, dateTime); |
|
140 | updateScalarData(plotableVect.at(0), *scalarSeries, dateTime); | |
141 | } |
|
141 | } | |
142 | else { |
|
142 | else { | |
143 |
qCCritical(LOG_ |
|
143 | qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr( | |
144 | "Can't update Data of a scalarSeries because there is not only one component " |
|
144 | "Can't update Data of a scalarSeries because there is not only one component " | |
145 | "associated"); |
|
145 | "associated"); | |
146 | } |
|
146 | } |
@@ -1,6 +1,6 | |||||
1 | #include "Visualization/VisualizationGraphWidget.h" |
|
1 | #include "Visualization/VisualizationGraphWidget.h" | |
2 | #include "Visualization/GraphPlottablesFactory.h" |
|
|||
3 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
|
3 | #include "Visualization/VisualizationGraphHelper.h" | |||
4 | #include "ui_VisualizationGraphWidget.h" |
|
4 | #include "ui_VisualizationGraphWidget.h" | |
5 |
|
5 | |||
6 | #include <Data/ArrayData.h> |
|
6 | #include <Data/ArrayData.h> | |
@@ -61,7 +61,7 VisualizationGraphWidget::~VisualizationGraphWidget() | |||||
61 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) |
|
61 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) | |
62 | { |
|
62 | { | |
63 | // Uses delegate to create the qcpplot components according to the variable |
|
63 | // Uses delegate to create the qcpplot components according to the variable | |
64 |
auto createdPlottables = |
|
64 | auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget); | |
65 |
|
65 | |||
66 | for (auto createdPlottable : qAsConst(createdPlottables)) { |
|
66 | for (auto createdPlottable : qAsConst(createdPlottables)) { | |
67 | impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); |
|
67 | impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); | |
@@ -142,11 +142,19 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept | |||||
142 |
|
142 | |||
143 | void VisualizationGraphWidget::onDataCacheVariableUpdated() |
|
143 | void VisualizationGraphWidget::onDataCacheVariableUpdated() | |
144 | { |
|
144 | { | |
|
145 | // NOTE: | |||
|
146 | // We don't want to call the method for each component of a variable unitarily, but for all | |||
|
147 | // its components at once (eg its three components in the case of a vector). | |||
|
148 | ||||
|
149 | // The unordered_multimap does not do this easily, so the question is whether to: | |||
|
150 | // - use an ordered_multimap and the algos of std to group the values by key | |||
|
151 | // - use a map (unique keys) and store as values directly the list of components | |||
|
152 | ||||
145 | for (auto it = impl->m_VariableToPlotMultiMap.cbegin(); |
|
153 | for (auto it = impl->m_VariableToPlotMultiMap.cbegin(); | |
146 | it != impl->m_VariableToPlotMultiMap.cend(); ++it) { |
|
154 | it != impl->m_VariableToPlotMultiMap.cend(); ++it) { | |
147 | auto variable = it->first; |
|
155 | auto variable = it->first; | |
148 |
|
|
156 | VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second, | |
149 | variable->dataSeries(), variable->dateTime()); |
|
157 | variable->dataSeries(), variable->dateTime()); | |
150 | } |
|
158 | } | |
151 | } |
|
159 | } | |
152 |
|
160 | |||
@@ -160,6 +168,6 void VisualizationGraphWidget::updateDisplay(std::shared_ptr<Variable> variable) | |||||
160 | abstractPlotableVect.push_back(it->second); |
|
168 | abstractPlotableVect.push_back(it->second); | |
161 | } |
|
169 | } | |
162 |
|
170 | |||
163 |
|
|
171 | VisualizationGraphHelper::updateData(abstractPlotableVect, variable->dataSeries(), | |
164 | variable->dateTime()); |
|
172 | variable->dateTime()); | |
165 | } |
|
173 | } |
@@ -3,6 +3,7 | |||||
3 | #include "Visualization/VisualizationGraphWidget.h" |
|
3 | #include "Visualization/VisualizationGraphWidget.h" | |
4 | #include "Visualization/VisualizationTabWidget.h" |
|
4 | #include "Visualization/VisualizationTabWidget.h" | |
5 | #include "Visualization/VisualizationZoneWidget.h" |
|
5 | #include "Visualization/VisualizationZoneWidget.h" | |
|
6 | #include "Visualization/operations/GenerateVariableMenuOperation.h" | |||
6 | #include "Visualization/qcustomplot.h" |
|
7 | #include "Visualization/qcustomplot.h" | |
7 |
|
8 | |||
8 | #include "ui_VisualizationWidget.h" |
|
9 | #include "ui_VisualizationWidget.h" | |
@@ -121,16 +122,10 QString VisualizationWidget::name() const | |||||
121 | return QStringLiteral("MainView"); |
|
122 | return QStringLiteral("MainView"); | |
122 | } |
|
123 | } | |
123 |
|
124 | |||
124 | void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept |
|
125 | void VisualizationWidget::attachVariableMenu(QMenu *menu, | |
|
126 | std::shared_ptr<Variable> variable) noexcept | |||
125 | { |
|
127 | { | |
126 | if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) { |
|
128 | // Generates the actions that make it possible to visualize the variable | |
127 | if (!currentTab->createZone(variable)) { |
|
129 | auto generateVariableMenuOperation = GenerateVariableMenuOperation{menu, variable}; | |
128 | qCCritical(LOG_VisualizationWidget()) |
|
130 | accept(&generateVariableMenuOperation); | |
129 | << tr("Can't display the variable : can't create a new zone in the current tab"); |
|
|||
130 | } |
|
|||
131 | } |
|
|||
132 | else { |
|
|||
133 | qCCritical(LOG_VisualizationWidget()) |
|
|||
134 | << tr("Can't display the variable : there is no current tab"); |
|
|||
135 | } |
|
|||
136 | } |
|
131 | } |
@@ -36,7 +36,7 CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const | |||||
36 | void CosinusProvider::requestDataLoading(const QVector<SqpDateTime> &dateTimeList) |
|
36 | void CosinusProvider::requestDataLoading(const QVector<SqpDateTime> &dateTimeList) | |
37 | { |
|
37 | { | |
38 | // NOTE: Try to use multithread if possible |
|
38 | // NOTE: Try to use multithread if possible | |
39 |
for |
|
39 | for (const auto &dateTime : dateTimeList) { | |
40 |
|
40 | |||
41 | auto scalarSeries = this->retrieveDataSeries(dateTime); |
|
41 | auto scalarSeries = this->retrieveDataSeries(dateTime); | |
42 |
|
42 |
General Comments 0
You need to be logged in to leave comments.
Login now