##// END OF EJS Templates
Merge pull request 244 from SCIQLOP-Initialisation develop...
leroux -
r659:4aefc1be8ed4 merge
parent child
Show More
@@ -26,8 +26,21 struct SqpRange {
26 26 {
27 27 return (m_TEnd >= dateTime.m_TStart && m_TStart <= dateTime.m_TEnd);
28 28 }
29
30 bool operator==(const SqpRange &other) const
31 {
32 auto equals = [](const auto &v1, const auto &v2) {
33 return (std::isnan(v1) && std::isnan(v2)) || v1 == v2;
34 };
35
36 return equals(m_TStart, other.m_TStart) && equals(m_TEnd, other.m_TEnd);
37 }
38 bool operator!=(const SqpRange &other) const { return !(*this == other); }
29 39 };
30 40
41 const auto INVALID_RANGE
42 = SqpRange{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
43
31 44 inline QDebug operator<<(QDebug d, SqpRange obj)
32 45 {
33 46 auto tendDateTimeStart = DateUtils::dateTime(obj.m_TStart);
@@ -3,6 +3,7
3 3
4 4 #include "CoreGlobal.h"
5 5
6 #include <Data/DataSeriesIterator.h>
6 7 #include <Data/SqpRange.h>
7 8
8 9 #include <QLoggingCategory>
@@ -33,6 +34,14 public:
33 34 SqpRange cacheRange() const noexcept;
34 35 void setCacheRange(const SqpRange &cacheRange) noexcept;
35 36
37 /// Returns the real range of the variable, i.e. the min and max x-axis values of the data
38 /// series between the range of the variable. The real range is updated each time the variable
39 /// range or the data series changed
40 /// @return the real range, invalid range if the data series is null or empty
41 /// @sa setDataSeries()
42 /// @sa setRange()
43 SqpRange realRange() const noexcept;
44
36 45 /// @return the data of the variable, nullptr if there is no data
37 46 std::shared_ptr<IDataSeries> dataSeries() const noexcept;
38 47
@@ -48,14 +48,14 public slots:
48 48 SqpRange dataRangeAcquired);
49 49 void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress);
50 50
51 private slots:
52 void onExecuteRequest(QUuid acqIdentifier);
53
54 51 private:
55 52 void waitForFinish();
56 53
57 54 class VariableAcquisitionWorkerPrivate;
58 55 spimpl::unique_impl_ptr<VariableAcquisitionWorkerPrivate> impl;
56
57 private slots:
58 void onExecuteRequest(QUuid acqIdentifier);
59 59 };
60 60
61 61 #endif // SCIQLOP_VARIABLEACQUISITIONWORKER_H
@@ -12,7 +12,11 Q_LOGGING_CATEGORY(LOG_Variable, "Variable")
12 12 struct Variable::VariablePrivate {
13 13 explicit VariablePrivate(const QString &name, const SqpRange &dateTime,
14 14 const QVariantHash &metadata)
15 : m_Name{name}, m_Range{dateTime}, m_Metadata{metadata}, m_DataSeries{nullptr}
15 : m_Name{name},
16 m_Range{dateTime},
17 m_Metadata{metadata},
18 m_DataSeries{nullptr},
19 m_RealRange{INVALID_RANGE}
16 20 {
17 21 }
18 22
@@ -20,12 +24,32 struct Variable::VariablePrivate {
20 24 void lockWrite() { m_Lock.lockForWrite(); }
21 25 void unlock() { m_Lock.unlock(); }
22 26
27 /// Updates real range according to current variable range and data series
28 void updateRealRange()
29 {
30 if (m_DataSeries) {
31 m_DataSeries->lockRead();
32 auto end = m_DataSeries->cend();
33 auto minXAxisIt = m_DataSeries->minXAxisData(m_Range.m_TStart);
34 auto maxXAxisIt = m_DataSeries->maxXAxisData(m_Range.m_TEnd);
35
36 m_RealRange = (minXAxisIt != end && maxXAxisIt != end)
37 ? SqpRange{minXAxisIt->x(), maxXAxisIt->x()}
38 : INVALID_RANGE;
39 m_DataSeries->unlock();
40 }
41 else {
42 m_RealRange = INVALID_RANGE;
43 }
44 }
45
23 46 QString m_Name;
24 47
25 48 SqpRange m_Range;
26 49 SqpRange m_CacheRange;
27 50 QVariantHash m_Metadata;
28 51 std::shared_ptr<IDataSeries> m_DataSeries;
52 SqpRange m_RealRange;
29 53
30 54 QReadWriteLock m_Lock;
31 55 };
@@ -55,6 +79,7 void Variable::setRange(const SqpRange &range) noexcept
55 79 {
56 80 impl->lockWrite();
57 81 impl->m_Range = range;
82 impl->updateRealRange();
58 83 impl->unlock();
59 84 }
60 85
@@ -73,6 +98,11 void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
73 98 impl->unlock();
74 99 }
75 100
101 SqpRange Variable::realRange() const noexcept
102 {
103 return impl->m_RealRange;
104 }
105
76 106 void Variable::setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
77 107 {
78 108 qCDebug(LOG_Variable()) << "TORM Variable::setDataSeries"
@@ -83,6 +113,7 void Variable::setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
83 113 }
84 114 impl->lockWrite();
85 115 impl->m_DataSeries = dataSeries->clone();
116 impl->updateRealRange();
86 117 impl->unlock();
87 118 }
88 119
@@ -184,22 +184,6 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier,
184 184 impl->unlock();
185 185 }
186 186
187 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier)
188 {
189 qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
190 impl->lockRead();
191 auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier);
192 if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
193 auto request = it->second;
194 impl->unlock();
195 request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters);
196 }
197 else {
198 impl->unlock();
199 // TODO log no acqIdentifier recognized
200 }
201 }
202
203 187 void VariableAcquisitionWorker::initialize()
204 188 {
205 189 qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init")
@@ -236,3 +220,19 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeVariable
236 220 m_VIdentifierToCurrrentAcqIdNextIdPairMap.erase(vIdentifier);
237 221 unlock();
238 222 }
223
224 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier)
225 {
226 qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
227 impl->lockRead();
228 auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier);
229 if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
230 auto request = it->second;
231 impl->unlock();
232 request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters);
233 }
234 else {
235 impl->unlock();
236 // TODO log no acqIdentifier recognized
237 }
238 }
@@ -153,35 +153,21 QVariant VariableModel::data(const QModelIndex &index, int role) const
153 153
154 154 if (role == Qt::DisplayRole) {
155 155 if (auto variable = impl->m_Variables.at(index.row()).get()) {
156 /// Lambda function that builds the variant to return for a time value
157 /// @param getValueFun function used to get for a data series the iterator on the entry
158 /// that contains the time value to display
159 auto dateTimeVariant = [variable](const auto &getValueFun) {
160 if (auto dataSeries = variable->dataSeries()) {
161 dataSeries->lockRead();
162 auto it = getValueFun(*dataSeries);
163 auto resVariant = (it != dataSeries->cend())
164 ? DateUtils::dateTime(it->x()).toString(DATETIME_FORMAT)
165 : QVariant{};
166 dataSeries->unlock();
167 return resVariant;
168 }
169 else {
170 return QVariant{};
171 }
172 };
173
174 156 switch (index.column()) {
175 157 case NAME_COLUMN:
176 158 return variable->name();
177 case TSTART_COLUMN:
178 // Shows the min value of the data series above the range tstart
179 return dateTimeVariant([min = variable->range().m_TStart](
180 const auto &dataSeries) { return dataSeries.minXAxisData(min); });
181 case TEND_COLUMN:
182 // Shows the max value of the data series under the range tend
183 return dateTimeVariant([max = variable->range().m_TEnd](
184 const auto &dataSeries) { return dataSeries.maxXAxisData(max); });
159 case TSTART_COLUMN: {
160 auto range = variable->realRange();
161 return range != INVALID_RANGE
162 ? DateUtils::dateTime(range.m_TStart).toString(DATETIME_FORMAT)
163 : QVariant{};
164 }
165 case TEND_COLUMN: {
166 auto range = variable->realRange();
167 return range != INVALID_RANGE
168 ? DateUtils::dateTime(range.m_TEnd).toString(DATETIME_FORMAT)
169 : QVariant{};
170 }
185 171 case UNIT_COLUMN:
186 172 return variable->metadata().value(QStringLiteral("units"));
187 173 case MISSION_COLUMN:
@@ -2,6 +2,8
2 2 Common/spimpl\.h:\d+:.*
3 3
4 4 # Ignore false positive relative to two class definitions in a same file
5 ArrayData\.h:\d+:.*IPSIS_S01.*
6 ArrayDataIterator\.h:\d+:.*IPSIS_S01.*
5 7 DataSourceItem\.h:\d+:.*IPSIS_S01.*
6 8 DataSeries\.h:\d+:.*IPSIS_S01.*
7 9 DataSeriesIterator\.h:\d+:.*IPSIS_S01.*
@@ -16,34 +18,19 DataSeries\.h:\d+:.*IPSIS_S04_VARIABLE.*
16 18 DataSeries\.h:\d+:.*IPSIS_S04_NAMESPACE.*found: (dataseries_detail)
17 19
18 20 # Ignore false positive relative to iterators
19 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag)
20 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (IteratorValue)
21 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (ptrdiff_t)
22 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (value_type)
23 ArrayData\.h:\d+:.*IPSIS_S05.*
24 ArrayData\.h:\d+:.*IPSIS_S06.*found: (iterator_category)
25 ArrayData\.h:\d+:.*IPSIS_S06.*found: (forward_iterator_tag)
26 ArrayData\.h:\d+:.*IPSIS_S06.*found: (value_type)
27 ArrayData\.h:\d+:.*IPSIS_S06.*found: (IteratorValue)
28 ArrayData\.h:\d+:.*IPSIS_S06.*found: (difference_type)
29 ArrayData\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t)
30 ArrayData\.h:\d+:.*IPSIS_S06.*found: (pointer)
31 ArrayData\.h:\d+:.*IPSIS_S06.*found: (reference)
32 ArrayData\.h:\d+:.*IPSIS_S06.*found: (value_type)
33 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag)
34 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (DataSeriesIteratorValue)
35 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (ptrdiff_t)
36 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (value_type)
37 DataSeriesIterator\.h:\d+:.*IPSIS_S05.*
38 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (iterator_category)
39 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (forward_iterator_tag)
40 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
41 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (DataSeriesIteratorValue)
42 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (difference_type)
43 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t)
44 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (pointer)
45 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (reference)
46 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
21 SqpIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag)
22 SqpIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (T)
23 SqpIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (ptrdiff_t)
24 SqpIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (value_type)
25 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (iterator_category)
26 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (forward_iterator_tag)
27 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
28 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (T)
29 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (difference_type)
30 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t)
31 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (pointer)
32 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (reference)
33 SqpIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
47 34
48 35 # Ignore false positive relative to an alias
49 36 DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction)
@@ -42,15 +42,14 public:
42 42 bool contains(const Variable &variable) const override;
43 43 QString name() const override;
44 44
45
46 private slots:
47 void onVariableAdded(std::shared_ptr<Variable> variable);
48
49 45 private:
50 46 Ui::VisualizationZoneWidget *ui;
51 47
52 48 class VisualizationZoneWidgetPrivate;
53 49 spimpl::unique_impl_ptr<VisualizationZoneWidgetPrivate> impl;
50
51 private slots:
52 void onVariableAdded(std::shared_ptr<Variable> variable);
54 53 };
55 54
56 55 #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H
@@ -94,7 +94,7 void DataSourceWidget::onTreeMenuRequested(const QPoint &pos) noexcept
94 94 treeMenu.addActions(selectedItem->actions());
95 95
96 96 if (!treeMenu.isEmpty()) {
97 treeMenu.exec(mapToGlobal(pos));
97 treeMenu.exec(QCursor::pos());
98 98 }
99 99 }
100 100 }
@@ -8,6 +8,12 SqpSettingsGeneralWidget::SqpSettingsGeneralWidget(QWidget *parent)
8 8 : QWidget{parent}, ui{new Ui::SqpSettingsGeneralWidget}
9 9 {
10 10 ui->setupUi(this);
11
12 // Value limits
13 ui->toleranceInitSpinBox->setMinimum(0.);
14 ui->toleranceInitSpinBox->setMaximum(std::numeric_limits<double>::max());
15 ui->toleranceUpdateSpinBox->setMinimum(0.);
16 ui->toleranceUpdateSpinBox->setMaximum(std::numeric_limits<double>::max());
11 17 }
12 18
13 19 SqpSettingsGeneralWidget::~SqpSettingsGeneralWidget() noexcept
@@ -189,7 +189,7 void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept
189 189 tableMenu.insertAction(firstAction, headerAction);
190 190
191 191 // Displays menu
192 tableMenu.exec(mapToGlobal(pos));
192 tableMenu.exec(QCursor::pos());
193 193 }
194 194 }
195 195
@@ -218,7 +218,7 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept
218 218 }
219 219
220 220 if (!graphMenu.isEmpty()) {
221 graphMenu.exec(mapToGlobal(pos));
221 graphMenu.exec(QCursor::pos());
222 222 }
223 223 }
224 224
@@ -32,12 +32,6
32 32 <property name="suffix">
33 33 <string> %</string>
34 34 </property>
35 <property name="minimum">
36 <double>0.000000000000000</double>
37 </property>
38 <property name="maximum">
39 <double>500.000000000000000</double>
40 </property>
41 35 </widget>
42 36 </item>
43 37 <item row="1" column="0">
@@ -58,12 +52,6
58 52 <property name="suffix">
59 53 <string> %</string>
60 54 </property>
61 <property name="minimum">
62 <double>0.000000000000000</double>
63 </property>
64 <property name="maximum">
65 <double>500.000000000000000</double>
66 </property>
67 55 </widget>
68 56 </item>
69 57 <item row="2" column="0">
General Comments 0
You need to be logged in to leave comments. Login now