##// END OF EJS Templates
Merge pull request 161 from SCIQLOP-Initialisation develop...
leroux -
r252:e54ef254edaa merge
parent child
Show More
@@ -182,10 +182,16 MainWindow::MainWindow(QWidget *parent)
182 182 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 183 SLOT(onTimeToUpdate(SqpDateTime)));
184 184
185 // Variable
185 // Widgets / widgets connections
186 186 qRegisterMetaType<std::shared_ptr<Variable> >();
187 connect(&sqpApp->visualizationController(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
188 m_Ui->view, SLOT(displayVariable(std::shared_ptr<Variable>)));
187
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 196 /* QLopGUI::registerMenuBar(menuBar());
191 197 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
@@ -26,11 +26,11 SET (CPACK_PACKAGE_VERSION_MAJOR "${SCIQLOP_VERSION_MAJOR}")
26 26 SET (CPACK_PACKAGE_VERSION_MINOR "${SCIQLOP_VERSION_MINOR}")
27 27 SET (CPACK_PACKAGE_VERSION_PATCH "${SCIQLOP_VERSION_PATCH}${SCIQLOP_VERSION_SUFFIX}")
28 28 SET (CPACK_PACKAGE_VERSION "${SCIQLOP_VERSION}")
29 SET (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
29 SET (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
30 30 SET (CPACK_PACKAGE_CONTACT "nicolas.aunai@lpp.polytechnique.fr")
31 31 SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
32 32 # SET(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_SOURCE_DIR}/WARN.txt)
33 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
33 SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
34 34 # SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME}-${PROJECT_VERSION})
35 35 SET(FULLBUILD ON)
36 36
@@ -4,8 +4,15
4 4 #include <Data/ArrayData.h>
5 5 #include <Data/IDataSeries.h>
6 6
7 #include <QLoggingCategory>
8
7 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 17 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
11 18 *
@@ -36,6 +43,10 public:
36 43 m_XAxisData->merge(dimDataSeries->xAxisData().get());
37 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 52 protected:
@@ -31,7 +31,7 public:
31 31 virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0;
32 32
33 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 36 // Required for using shared_ptr in signals/slots
37 37 Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>)
@@ -33,7 +33,7 public:
33 33 /// @return the data of the variable, nullptr if there is no data
34 34 IDataSeries *dataSeries() const noexcept;
35 35
36 bool contains(SqpDateTime dateTime);
36 bool contains(const SqpDateTime &dateTime);
37 37 void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
38 38
39 39 public slots:
@@ -9,7 +9,7
9 9
10 10 class Variable;
11 11
12 /// This class aims to store in the cash all of the dateTime already requested to the variable.
12 /// This class aims to store in the cache all of the dateTime already requested to the variable.
13 13 class VariableCacheController : public QObject {
14 14 Q_OBJECT
15 15 public:
@@ -32,6 +32,8 public:
32 32 createVariable(const QString &name, const SqpDateTime &dateTime,
33 33 std::unique_ptr<IDataSeries> defaultDataSeries) noexcept;
34 34
35 std::shared_ptr<Variable> variable(int index) const;
36
35 37 // /////////////////////////// //
36 38 // QAbstractTableModel methods //
37 39 // /////////////////////////// //
@@ -71,7 +71,7 IDataSeries *Variable::dataSeries() const noexcept
71 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 76 if (!impl->m_DateTime.contains(dateTime)) {
77 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 25 VariableCacheController::VariableCacheController(QObject *parent)
26 : QObject(parent), impl{spimpl::make_unique_impl<VariableCacheControllerPrivate>()}
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 48 // will be compared to the next interval. The old one is remove from the list
49 49 // C: if it is superior, we do the same with the next interval of the list
50 50
51 int cacheIndex = 0;
52 51 impl->addDateTimeRecurse(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable),
53 cacheIndex);
52 0);
54 53 }
55 54 }
56 55 }
@@ -94,7 +93,6 void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse
94 93 // The compared one is < to current one compared, we can insert it
95 94 dateTimeList.insert(cacheIndex, dateTime);
96 95 }
97
98 96 else if (dateTime.m_TStart > currentDateTime.m_TEnd) {
99 97 // The compared one is > to current one compared we can comparet if to the next one
100 98 addDateTimeRecurse(dateTime, dateTimeList, ++cacheIndex);
@@ -153,11 +151,10 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataBySt
153 151 }
154 152
155 153 auto currentDateTimeI = dateTimeList[cacheIndex];
156 auto cacheIndexJ = cacheIndex;
157 154 if (currentTStart < currentDateTimeI.m_TStart) {
158 155
159 156 // ts localised between to interval: let's localized te
160 addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndexJ, currentTStart);
157 addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex, currentTStart);
161 158 }
162 159 else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) {
163 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 123 QElapsedTimer timer;
124 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 126 << "milliseconds";
127 127 auto dateTimeListNotInCache
128 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 130 << "milliseconds";
131 131
132 132 // Ask the provider for each data on the dateTimeListNotInCache
133 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 136 << "milliseconds";
137 137
138 138 // store in cache
139 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 141 << "milliseconds";
142 142 }
143 143 else {
@@ -44,6 +44,11 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
44 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 52 int VariableModel::columnCount(const QModelIndex &parent) const
48 53 {
49 54 Q_UNUSED(parent);
@@ -51,9 +51,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
51 51 auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
52 52
53 53 QCOMPARE(notInCach.size(), 1);
54 auto notInCashSqp = notInCach.first();
55 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
56 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
54 auto notInCacheSqp = notInCach.first();
55 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
56 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
57 57
58 58
59 59 // second case ts < ts0 && ts0 < te <= te0
@@ -66,9 +66,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
66 66 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
67 67
68 68 QCOMPARE(notInCach.size(), 1);
69 notInCashSqp = notInCach.first();
70 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
71 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
69 notInCacheSqp = notInCach.first();
70 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
71 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
72 72
73 73 // 3th case ts < ts0 && te0 < te <= ts1
74 74 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
@@ -80,13 +80,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
80 80 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
81 81
82 82 QCOMPARE(notInCach.size(), 2);
83 notInCashSqp = notInCach.first();
84 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
85 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
83 notInCacheSqp = notInCach.first();
84 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
85 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
86 86
87 notInCashSqp = notInCach.at(1);
88 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
89 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
87 notInCacheSqp = notInCach.at(1);
88 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
89 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
90 90
91 91 // 4th case ts < ts0 && ts1 < te <= te1
92 92 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
@@ -98,13 +98,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
98 98 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
99 99
100 100 QCOMPARE(notInCach.size(), 2);
101 notInCashSqp = notInCach.first();
102 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
103 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
101 notInCacheSqp = notInCach.first();
102 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
103 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
104 104
105 notInCashSqp = notInCach.at(1);
106 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
107 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
105 notInCacheSqp = notInCach.at(1);
106 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
107 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
108 108
109 109 // 5th case ts < ts0 && te3 < te
110 110 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
@@ -116,21 +116,21 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
116 116 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
117 117
118 118 QCOMPARE(notInCach.size(), 4);
119 notInCashSqp = notInCach.first();
120 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
121 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
119 notInCacheSqp = notInCach.first();
120 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
121 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
122 122
123 notInCashSqp = notInCach.at(1);
124 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
125 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
123 notInCacheSqp = notInCach.at(1);
124 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
125 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
126 126
127 notInCashSqp = notInCach.at(2);
128 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
129 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
127 notInCacheSqp = notInCach.at(2);
128 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
129 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
130 130
131 notInCashSqp = notInCach.at(3);
132 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
133 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
131 notInCacheSqp = notInCach.at(3);
132 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
133 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
134 134
135 135
136 136 // 6th case ts2 < ts
@@ -143,9 +143,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
143 143 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
144 144
145 145 QCOMPARE(notInCach.size(), 1);
146 notInCashSqp = notInCach.first();
147 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
148 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
146 notInCacheSqp = notInCach.first();
147 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
148 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
149 149
150 150 // 7th case ts = te0 && te < ts1
151 151 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
@@ -157,9 +157,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
157 157 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
158 158
159 159 QCOMPARE(notInCach.size(), 1);
160 notInCashSqp = notInCach.first();
161 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
162 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
160 notInCacheSqp = notInCach.first();
161 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
162 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
163 163
164 164 // 8th case ts0 < ts < te0 && te < ts1
165 165 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
@@ -171,9 +171,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
171 171 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
172 172
173 173 QCOMPARE(notInCach.size(), 1);
174 notInCashSqp = notInCach.first();
175 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
176 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
174 notInCacheSqp = notInCach.first();
175 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
176 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
177 177
178 178 // 9th case ts0 < ts < te0 && ts1 < te < te1
179 179 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
@@ -185,9 +185,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
185 185 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
186 186
187 187 QCOMPARE(notInCach.size(), 1);
188 notInCashSqp = notInCach.first();
189 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
190 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
188 notInCacheSqp = notInCach.first();
189 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
190 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
191 191
192 192 // 10th case te1 < ts < te < ts2
193 193 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}};
@@ -199,9 +199,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
199 199 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
200 200
201 201 QCOMPARE(notInCach.size(), 1);
202 notInCashSqp = notInCach.first();
203 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
204 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
202 notInCacheSqp = notInCach.first();
203 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
204 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
205 205
206 206 // 11th case te0 < ts < ts1 && te3 < te
207 207 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
@@ -213,17 +213,17 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
213 213 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
214 214
215 215 QCOMPARE(notInCach.size(), 3);
216 notInCashSqp = notInCach.first();
217 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
218 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
216 notInCacheSqp = notInCach.first();
217 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
218 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
219 219
220 notInCashSqp = notInCach.at(1);
221 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
222 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
220 notInCacheSqp = notInCach.at(1);
221 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
222 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
223 223
224 notInCashSqp = notInCach.at(2);
225 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
226 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
224 notInCacheSqp = notInCach.at(2);
225 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
226 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
227 227
228 228 // 12th case te0 < ts < ts1 && te3 < te
229 229 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
@@ -234,13 +234,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
234 234 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
235 235
236 236 QCOMPARE(notInCach.size(), 2);
237 notInCashSqp = notInCach.first();
238 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
239 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
237 notInCacheSqp = notInCach.first();
238 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
239 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
240 240
241 notInCashSqp = notInCach.at(1);
242 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
243 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
241 notInCacheSqp = notInCach.at(1);
242 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
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 91 ENDFOREACH(item ${globs})
92 92
93 93 LIST(REMOVE_ITEM srcs ${UIS})
94 message("format lang: ${srcs}" )
95 94 FOREACH (s ${srcs})
96 95 SET(touchedFile ${formatDirectory}/format_touchedfile_${reportNb})
97 96 IF(addToAll)
@@ -1,8 +1,16
1 1 #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H
2 2 #define SCIQLOP_VARIABLEINSPECTORWIDGET_H
3 3
4 #include <QLoggingCategory>
5 #include <QMenu>
4 6 #include <QWidget>
5 7
8 #include <memory>
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableInspectorWidget)
11
12 class Variable;
13
6 14 namespace Ui {
7 15 class VariableInspectorWidget;
8 16 } // Ui
@@ -19,8 +27,23 public:
19 27 explicit VariableInspectorWidget(QWidget *parent = 0);
20 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 41 private:
23 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 49 #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H
@@ -1,5 +1,5
1 #ifndef SCIQLOP_GRAPHPLOTTABLESFACTORY_H
2 #define SCIQLOP_GRAPHPLOTTABLESFACTORY_H
1 #ifndef SCIQLOP_VISUALIZATIONGRAPHHELPER_H
2 #define SCIQLOP_VISUALIZATIONGRAPHHELPER_H
3 3
4 4 #include <Data/SqpDateTime.h>
5 5
@@ -8,7 +8,7
8 8
9 9 #include <memory>
10 10
11 Q_DECLARE_LOGGING_CATEGORY(LOG_GraphPlottablesFactory)
11 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphHelper)
12 12
13 13 class IDataSeries;
14 14 class QCPAbstractPlottable;
@@ -16,10 +16,10 class QCustomPlot;
16 16 class Variable;
17 17
18 18 /**
19 * @brief The GraphPlottablesFactory class aims to create the QCustomPlot components relative to a
19 * @brief The VisualizationGraphHelper class aims to create the QCustomPlot components relative to a
20 20 * variable, depending on the data series of this variable
21 21 */
22 struct GraphPlottablesFactory {
22 struct VisualizationGraphHelper {
23 23 /**
24 24 * Creates (if possible) the QCustomPlot components relative to the variable passed in
25 25 * parameter, and adds these to the plot passed in parameter.
@@ -35,4 +35,4 struct GraphPlottablesFactory {
35 35 const SqpDateTime &dateTime);
36 36 };
37 37
38 #endif // SCIQLOP_GRAPHPLOTTABLESFACTORY_H
38 #endif // SCIQLOP_VISUALIZATIONGRAPHHELPER_H
@@ -8,6 +8,7
8 8
9 9 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
10 10
11 class QMenu;
11 12 class Variable;
12 13 class VisualizationTabWidget;
13 14
@@ -39,12 +40,11 public:
39 40
40 41 public slots:
41 42 /**
42 * Displays a variable in a new graph of a new zone of the current tab
43 * @param variable the variable to display
44 * @todo this is a temporary method that will be replaced by own actions for each type of
45 * visualization widget
43 * Attaches to a menu the menu relating to the visualization of a variable
44 * @param menu the parent menu of the generated menu
45 * @param variable the variable for which to generate the menu
46 46 */
47 void displayVariable(std::shared_ptr<Variable> variable) noexcept;
47 void attachVariableMenu(QMenu *menu, std::shared_ptr<Variable> variable) noexcept;
48 48
49 49 private:
50 50 Ui::VisualizationWidget *ui;
@@ -8,6 +8,8
8 8
9 9 #include <SqpApplication.h>
10 10
11 Q_LOGGING_CATEGORY(LOG_VariableInspectorWidget, "VariableInspectorWidget")
12
11 13 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
12 14 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
13 15 {
@@ -18,9 +20,38 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
18 20 sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
19 21
20 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 30 VariableInspectorWidget::~VariableInspectorWidget()
24 31 {
25 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/GraphPlottablesFactory.h"
1 #include "Visualization/VisualizationGraphHelper.h"
2 2 #include "Visualization/qcustomplot.h"
3 3
4 4 #include <Data/ScalarSeries.h>
@@ -7,7 +7,7
7 7
8 8 #include <QElapsedTimer>
9 9
10 Q_LOGGING_CATEGORY(LOG_GraphPlottablesFactory, "GraphPlottablesFactory")
10 Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper")
11 11
12 12 namespace {
13 13
@@ -37,8 +37,8 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
37 37 timer.start();
38 38 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
39 39 // Clean the graph
40 qCDebug(LOG_GraphPlottablesFactory()) << "The slow s1 operation took" << timer.elapsed()
41 << "milliseconds";
40 qCDebug(LOG_VisualizationGraphHelper()) << "The slow s1 operation took" << timer.elapsed()
41 << "milliseconds";
42 42 // NAIVE approch
43 43 const auto &xData = scalarSeries.xAxisData()->data();
44 44 const auto &valuesData = scalarSeries.valuesData()->data();
@@ -59,8 +59,8 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
59 59
60 60 qcpGraph->setData(xValue, vValue);
61 61
62 qCDebug(LOG_GraphPlottablesFactory()) << "The slow s2 operation took" << timer.elapsed()
63 << "milliseconds";
62 qCDebug(LOG_VisualizationGraphHelper()) << "The slow s2 operation took" << timer.elapsed()
63 << "milliseconds";
64 64 }
65 65 else {
66 66 /// @todo DEBUG
@@ -99,7 +99,7 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC
99 99 plot.replot();
100 100 }
101 101 else {
102 qCDebug(LOG_GraphPlottablesFactory())
102 qCDebug(LOG_VisualizationGraphHelper())
103 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 109 } // namespace
110 110
111 QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(std::shared_ptr<Variable> variable,
112 QCustomPlot &plot) noexcept
111 QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable,
112 QCustomPlot &plot) noexcept
113 113 {
114 114 auto result = QVector<QCPAbstractPlottable *>{};
115 115
@@ -120,27 +120,27 QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(std::shared_ptr<V
120 120 result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime()));
121 121 }
122 122 else {
123 qCDebug(LOG_GraphPlottablesFactory())
123 qCDebug(LOG_VisualizationGraphHelper())
124 124 << QObject::tr("Can't create graph plottables : unmanaged data series type");
125 125 }
126 126 }
127 127 else {
128 qCDebug(LOG_GraphPlottablesFactory())
128 qCDebug(LOG_VisualizationGraphHelper())
129 129 << QObject::tr("Can't create graph plottables : the variable is null");
130 130 }
131 131
132 132 return result;
133 133 }
134 134
135 void GraphPlottablesFactory::updateData(QVector<QCPAbstractPlottable *> plotableVect,
136 IDataSeries *dataSeries, const SqpDateTime &dateTime)
135 void VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *> plotableVect,
136 IDataSeries *dataSeries, const SqpDateTime &dateTime)
137 137 {
138 138 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) {
139 139 if (plotableVect.size() == 1) {
140 140 updateScalarData(plotableVect.at(0), *scalarSeries, dateTime);
141 141 }
142 142 else {
143 qCCritical(LOG_GraphPlottablesFactory()) << QObject::tr(
143 qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr(
144 144 "Can't update Data of a scalarSeries because there is not only one component "
145 145 "associated");
146 146 }
@@ -1,6 +1,6
1 1 #include "Visualization/VisualizationGraphWidget.h"
2 #include "Visualization/GraphPlottablesFactory.h"
3 2 #include "Visualization/IVisualizationWidgetVisitor.h"
3 #include "Visualization/VisualizationGraphHelper.h"
4 4 #include "ui_VisualizationGraphWidget.h"
5 5
6 6 #include <Data/ArrayData.h>
@@ -61,7 +61,7 VisualizationGraphWidget::~VisualizationGraphWidget()
61 61 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
62 62 {
63 63 // Uses delegate to create the qcpplot components according to the variable
64 auto createdPlottables = GraphPlottablesFactory::create(variable, *ui->widget);
64 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
65 65
66 66 for (auto createdPlottable : qAsConst(createdPlottables)) {
67 67 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
@@ -142,11 +142,19 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
142 142
143 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 153 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
146 154 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
147 155 auto variable = it->first;
148 GraphPlottablesFactory::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
149 variable->dataSeries(), variable->dateTime());
156 VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
157 variable->dataSeries(), variable->dateTime());
150 158 }
151 159 }
152 160
@@ -160,6 +168,6 void VisualizationGraphWidget::updateDisplay(std::shared_ptr<Variable> variable)
160 168 abstractPlotableVect.push_back(it->second);
161 169 }
162 170
163 GraphPlottablesFactory::updateData(abstractPlotableVect, variable->dataSeries(),
164 variable->dateTime());
171 VisualizationGraphHelper::updateData(abstractPlotableVect, variable->dataSeries(),
172 variable->dateTime());
165 173 }
@@ -3,6 +3,7
3 3 #include "Visualization/VisualizationGraphWidget.h"
4 4 #include "Visualization/VisualizationTabWidget.h"
5 5 #include "Visualization/VisualizationZoneWidget.h"
6 #include "Visualization/operations/GenerateVariableMenuOperation.h"
6 7 #include "Visualization/qcustomplot.h"
7 8
8 9 #include "ui_VisualizationWidget.h"
@@ -121,16 +122,10 QString VisualizationWidget::name() const
121 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())) {
127 if (!currentTab->createZone(variable)) {
128 qCCritical(LOG_VisualizationWidget())
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 }
128 // Generates the actions that make it possible to visualize the variable
129 auto generateVariableMenuOperation = GenerateVariableMenuOperation{menu, variable};
130 accept(&generateVariableMenuOperation);
136 131 }
@@ -36,7 +36,7 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
36 36 void CosinusProvider::requestDataLoading(const QVector<SqpDateTime> &dateTimeList)
37 37 {
38 38 // NOTE: Try to use multithread if possible
39 foreach (const auto &dateTime, dateTimeList) {
39 for (const auto &dateTime : dateTimeList) {
40 40
41 41 auto scalarSeries = this->retrieveDataSeries(dateTime);
42 42
General Comments 0
You need to be logged in to leave comments. Login now