@@ -77,7 +77,7 struct SortUtils { | |||||
77 | for (auto i = 0, componentIndex = 0, permutationIndex = 0; i < containerSize; |
|
77 | for (auto i = 0, componentIndex = 0, permutationIndex = 0; i < containerSize; | |
78 | ++i, componentIndex = i % nbValues, permutationIndex = i / nbValues) { |
|
78 | ++i, componentIndex = i % nbValues, permutationIndex = i / nbValues) { | |
79 | auto insertIndex = sortPermutation.at(permutationIndex) * nbValues + componentIndex; |
|
79 | auto insertIndex = sortPermutation.at(permutationIndex) * nbValues + componentIndex; | |
80 |
sortedData. |
|
80 | sortedData.push_back(container.at(insertIndex)); | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | return sortedData; |
|
83 | return sortedData; |
@@ -13,7 +13,7 | |||||
13 | template <int Dim> |
|
13 | template <int Dim> | |
14 | class ArrayData; |
|
14 | class ArrayData; | |
15 |
|
15 | |||
16 |
using DataContainer = |
|
16 | using DataContainer = std::vector<double>; | |
17 |
|
17 | |||
18 | namespace arraydata_detail { |
|
18 | namespace arraydata_detail { | |
19 |
|
19 | |||
@@ -363,9 +363,8 public: | |||||
363 | * @remarks this method is only available for a unidimensional ArrayData |
|
363 | * @remarks this method is only available for a unidimensional ArrayData | |
364 | */ |
|
364 | */ | |
365 | template <int D = Dim, typename = std::enable_if_t<D == 1> > |
|
365 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
366 |
|
|
366 | DataContainer cdata() const noexcept | |
367 | { |
|
367 | { | |
368 | QReadLocker locker{&m_Lock}; |
|
|||
369 | return m_Data; |
|
368 | return m_Data; | |
370 | } |
|
369 | } | |
371 |
|
370 |
@@ -155,8 +155,8 public: | |||||
155 |
|
155 | |||
156 | SqpRange range() const override |
|
156 | SqpRange range() const override | |
157 | { |
|
157 | { | |
158 |
if (!m_XAxisData->cdata(). |
|
158 | if (!m_XAxisData->cdata().empty()) { | |
159 |
return SqpRange{m_XAxisData->cdata().f |
|
159 | return SqpRange{m_XAxisData->cdata().front(), m_XAxisData->cdata().back()}; | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | return SqpRange{}; |
|
162 | return SqpRange{}; |
@@ -16,7 +16,7 public: | |||||
16 | * @param xAxisData x-axis data |
|
16 | * @param xAxisData x-axis data | |
17 | * @param valuesData values data |
|
17 | * @param valuesData values data | |
18 | */ |
|
18 | */ | |
19 |
explicit ScalarSeries( |
|
19 | explicit ScalarSeries(std::vector<double> xAxisData, std::vector<double> valuesData, | |
20 | const Unit &xAxisUnit, const Unit &valuesUnit); |
|
20 | const Unit &xAxisUnit, const Unit &valuesUnit); | |
21 |
|
21 | |||
22 | std::unique_ptr<IDataSeries> clone() const override; |
|
22 | std::unique_ptr<IDataSeries> clone() const override; |
@@ -18,12 +18,12 public: | |||||
18 | * @param yvaluesData y-values data |
|
18 | * @param yvaluesData y-values data | |
19 | * @param zvaluesData z-values data |
|
19 | * @param zvaluesData z-values data | |
20 | */ |
|
20 | */ | |
21 |
explicit VectorSeries( |
|
21 | explicit VectorSeries(std::vector<double> xAxisData, std::vector<double> xValuesData, | |
22 |
|
|
22 | std::vector<double> yValuesData, std::vector<double> zValuesData, | |
23 | const Unit &xAxisUnit, const Unit &valuesUnit); |
|
23 | const Unit &xAxisUnit, const Unit &valuesUnit); | |
24 |
|
24 | |||
25 | /// Default Ctor |
|
25 | /// Default Ctor | |
26 |
explicit VectorSeries( |
|
26 | explicit VectorSeries(std::vector<double> xAxisData, std::vector<double> valuesData, | |
27 | const Unit &xAxisUnit, const Unit &valuesUnit); |
|
27 | const Unit &xAxisUnit, const Unit &valuesUnit); | |
28 |
|
28 | |||
29 | std::unique_ptr<IDataSeries> clone() const; |
|
29 | std::unique_ptr<IDataSeries> clone() const; |
@@ -1,6 +1,6 | |||||
1 | #include <Data/ScalarSeries.h> |
|
1 | #include <Data/ScalarSeries.h> | |
2 |
|
2 | |||
3 |
ScalarSeries::ScalarSeries( |
|
3 | ScalarSeries::ScalarSeries(std::vector<double> xAxisData, std::vector<double> valuesData, | |
4 | const Unit &xAxisUnit, const Unit &valuesUnit) |
|
4 | const Unit &xAxisUnit, const Unit &valuesUnit) | |
5 | : DataSeries{std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit, |
|
5 | : DataSeries{std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit, | |
6 | std::make_shared<ArrayData<1> >(std::move(valuesData)), valuesUnit} |
|
6 | std::make_shared<ArrayData<1> >(std::move(valuesData)), valuesUnit} | |
@@ -14,18 +14,18 std::unique_ptr<IDataSeries> ScalarSeries::clone() const | |||||
14 |
|
14 | |||
15 | std::shared_ptr<IDataSeries> ScalarSeries::subDataSeries(const SqpRange &range) |
|
15 | std::shared_ptr<IDataSeries> ScalarSeries::subDataSeries(const SqpRange &range) | |
16 | { |
|
16 | { | |
17 |
auto subXAxisData = |
|
17 | auto subXAxisData = std::vector<double>(); | |
18 |
auto subValuesData = |
|
18 | auto subValuesData = std::vector<double>(); | |
19 | this->lockRead(); |
|
19 | this->lockRead(); | |
20 | { |
|
20 | { | |
21 | auto bounds = xAxisRange(range.m_TStart, range.m_TEnd); |
|
21 | auto bounds = xAxisRange(range.m_TStart, range.m_TEnd); | |
22 | for (auto it = bounds.first; it != bounds.second; ++it) { |
|
22 | for (auto it = bounds.first; it != bounds.second; ++it) { | |
23 |
subXAxisData. |
|
23 | subXAxisData.push_back(it->x()); | |
24 |
subValuesData. |
|
24 | subValuesData.push_back(it->value()); | |
25 | } |
|
25 | } | |
26 | } |
|
26 | } | |
27 | this->unlock(); |
|
27 | this->unlock(); | |
28 |
|
28 | |||
29 |
return std::make_shared<ScalarSeries>(subXAxisData, subValuesData |
|
29 | return std::make_shared<ScalarSeries>(std::move(subXAxisData), std::move(subValuesData), | |
30 | this->valuesUnit()); |
|
30 | this->xAxisUnit(), this->valuesUnit()); | |
31 | } |
|
31 | } |
@@ -19,18 +19,22 namespace { | |||||
19 | * @remarks the three components are consumed |
|
19 | * @remarks the three components are consumed | |
20 | * @sa ArrayData |
|
20 | * @sa ArrayData | |
21 | */ |
|
21 | */ | |
22 |
|
|
22 | std::vector<double> flatten(std::vector<double> xValues, std::vector<double> yValues, | |
|
23 | std::vector<double> zValues) | |||
23 | { |
|
24 | { | |
24 | if (xValues.size() != yValues.size() || xValues.size() != zValues.size()) { |
|
25 | if (xValues.size() != yValues.size() || xValues.size() != zValues.size()) { | |
25 | /// @todo ALX : log |
|
26 | /// @todo ALX : log | |
26 | return {}; |
|
27 | return {}; | |
27 | } |
|
28 | } | |
28 |
|
29 | |||
29 |
auto result = |
|
30 | auto result = std::vector<double>(); | |
30 | result.reserve(xValues.size() * 3); |
|
31 | result.reserve(xValues.size() * 3); | |
31 |
|
32 | |||
32 |
while (!xValues. |
|
33 | while (!xValues.empty()) { | |
33 |
result. |
|
34 | result.insert(result.cend(), {xValues.front(), yValues.front(), zValues.front()}); | |
|
35 | xValues.erase(xValues.begin()); | |||
|
36 | yValues.erase(yValues.begin()); | |||
|
37 | zValues.erase(zValues.begin()); | |||
34 | } |
|
38 | } | |
35 |
|
39 | |||
36 | return result; |
|
40 | return result; | |
@@ -38,8 +42,8 QVector<double> flatten(QVector<double> xValues, QVector<double> yValues, QVecto | |||||
38 |
|
42 | |||
39 | } // namespace |
|
43 | } // namespace | |
40 |
|
44 | |||
41 |
VectorSeries::VectorSeries( |
|
45 | VectorSeries::VectorSeries(std::vector<double> xAxisData, std::vector<double> xValuesData, | |
42 |
|
|
46 | std::vector<double> yValuesData, std::vector<double> zValuesData, | |
43 | const Unit &xAxisUnit, const Unit &valuesUnit) |
|
47 | const Unit &xAxisUnit, const Unit &valuesUnit) | |
44 | : VectorSeries{std::move(xAxisData), flatten(std::move(xValuesData), std::move(yValuesData), |
|
48 | : VectorSeries{std::move(xAxisData), flatten(std::move(xValuesData), std::move(yValuesData), | |
45 | std::move(zValuesData)), |
|
49 | std::move(zValuesData)), | |
@@ -47,7 +51,7 VectorSeries::VectorSeries(QVector<double> xAxisData, QVector<double> xValuesDat | |||||
47 | { |
|
51 | { | |
48 | } |
|
52 | } | |
49 |
|
53 | |||
50 |
VectorSeries::VectorSeries( |
|
54 | VectorSeries::VectorSeries(std::vector<double> xAxisData, std::vector<double> valuesData, | |
51 | const Unit &xAxisUnit, const Unit &valuesUnit) |
|
55 | const Unit &xAxisUnit, const Unit &valuesUnit) | |
52 | : DataSeries{std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit, |
|
56 | : DataSeries{std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit, | |
53 | std::make_shared<ArrayData<2> >(std::move(valuesData), 3), valuesUnit} |
|
57 | std::make_shared<ArrayData<2> >(std::move(valuesData), 3), valuesUnit} | |
@@ -61,23 +65,24 std::unique_ptr<IDataSeries> VectorSeries::clone() const | |||||
61 |
|
65 | |||
62 | std::shared_ptr<IDataSeries> VectorSeries::subDataSeries(const SqpRange &range) |
|
66 | std::shared_ptr<IDataSeries> VectorSeries::subDataSeries(const SqpRange &range) | |
63 | { |
|
67 | { | |
64 |
auto subXAxisData = |
|
68 | auto subXAxisData = std::vector<double>(); | |
65 |
auto subXValuesData = |
|
69 | auto subXValuesData = std::vector<double>(); | |
66 |
auto subYValuesData = |
|
70 | auto subYValuesData = std::vector<double>(); | |
67 |
auto subZValuesData = |
|
71 | auto subZValuesData = std::vector<double>(); | |
68 |
|
72 | |||
69 | this->lockRead(); |
|
73 | this->lockRead(); | |
70 | { |
|
74 | { | |
71 | auto bounds = xAxisRange(range.m_TStart, range.m_TEnd); |
|
75 | auto bounds = xAxisRange(range.m_TStart, range.m_TEnd); | |
72 | for (auto it = bounds.first; it != bounds.second; ++it) { |
|
76 | for (auto it = bounds.first; it != bounds.second; ++it) { | |
73 |
subXAxisData. |
|
77 | subXAxisData.push_back(it->x()); | |
74 |
subXValuesData. |
|
78 | subXValuesData.push_back(it->value(0)); | |
75 |
subYValuesData. |
|
79 | subYValuesData.push_back(it->value(1)); | |
76 |
subZValuesData. |
|
80 | subZValuesData.push_back(it->value(2)); | |
77 | } |
|
81 | } | |
78 | } |
|
82 | } | |
79 | this->unlock(); |
|
83 | this->unlock(); | |
80 |
|
84 | |||
81 |
return std::make_shared<VectorSeries>(subXAxisData, subXValuesData |
|
85 | return std::make_shared<VectorSeries>(std::move(subXAxisData), std::move(subXValuesData), | |
82 |
s |
|
86 | std::move(subYValuesData), std::move(subZValuesData), | |
|
87 | this->xAxisUnit(), this->valuesUnit()); | |||
83 | } |
|
88 | } |
@@ -194,15 +194,16 std::shared_ptr<IDataSeries> AmdaResultParser::readTxt(const QString &filePath, | |||||
194 | case ValueType::SCALAR: |
|
194 | case ValueType::SCALAR: | |
195 | Q_ASSERT(results.second.size() == 1); |
|
195 | Q_ASSERT(results.second.size() == 1); | |
196 | return std::make_shared<ScalarSeries>( |
|
196 | return std::make_shared<ScalarSeries>( | |
197 |
std::move(results.first |
|
197 | std::move(results.first.toStdVector()), | |
|
198 | std::move(results.second.takeFirst().toStdVector()), xAxisUnit, Unit{}); | |||
198 | case ValueType::VECTOR: { |
|
199 | case ValueType::VECTOR: { | |
199 | Q_ASSERT(results.second.size() == 3); |
|
200 | Q_ASSERT(results.second.size() == 3); | |
200 | auto xValues = results.second.takeFirst(); |
|
201 | auto xValues = results.second.takeFirst().toStdVector(); | |
201 | auto yValues = results.second.takeFirst(); |
|
202 | auto yValues = results.second.takeFirst().toStdVector(); | |
202 | auto zValues = results.second.takeFirst(); |
|
203 | auto zValues = results.second.takeFirst().toStdVector(); | |
203 |
return std::make_shared<VectorSeries>(std::move(results.first) |
|
204 | return std::make_shared<VectorSeries>(std::move(results.first.toStdVector()), | |
204 |
std::move(yValues), |
|
205 | std::move(xValues), std::move(yValues), | |
205 | Unit{}); |
|
206 | std::move(zValues), xAxisUnit, Unit{}); | |
206 | } |
|
207 | } | |
207 | case ValueType::UNKNOWN: |
|
208 | case ValueType::UNKNOWN: | |
208 | // Invalid case |
|
209 | // Invalid case |
@@ -18,7 +18,7 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||||
18 | auto dataIndex = 0; |
|
18 | auto dataIndex = 0; | |
19 |
|
19 | |||
20 | // Gets the timerange from the parameters |
|
20 | // Gets the timerange from the parameters | |
21 | double freq = 1.0; |
|
21 | double freq = 100.0; | |
22 | double start = std::ceil(dataRangeRequested.m_TStart * freq); // 100 htz |
|
22 | double start = std::ceil(dataRangeRequested.m_TStart * freq); // 100 htz | |
23 | double end = std::floor(dataRangeRequested.m_TEnd * freq); // 100 htz |
|
23 | double end = std::floor(dataRangeRequested.m_TEnd * freq); // 100 htz | |
24 |
|
24 | |||
@@ -30,10 +30,10 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||||
30 | // Generates scalar series containing cosinus values (one value per second) |
|
30 | // Generates scalar series containing cosinus values (one value per second) | |
31 | auto dataCount = end - start; |
|
31 | auto dataCount = end - start; | |
32 |
|
32 | |||
33 |
auto xAxisData = |
|
33 | auto xAxisData = std::vector<double>{}; | |
34 | xAxisData.resize(dataCount); |
|
34 | xAxisData.resize(dataCount); | |
35 |
|
35 | |||
36 |
auto valuesData = |
|
36 | auto valuesData = std::vector<double>{}; | |
37 | valuesData.resize(dataCount); |
|
37 | valuesData.resize(dataCount); | |
38 |
|
38 | |||
39 | int progress = 0; |
|
39 | int progress = 0; | |
@@ -43,8 +43,8 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||||
43 | if (it != m_VariableToEnableProvider.end() && it.value()) { |
|
43 | if (it != m_VariableToEnableProvider.end() && it.value()) { | |
44 | const auto timeOnFreq = time / freq; |
|
44 | const auto timeOnFreq = time / freq; | |
45 |
|
45 | |||
46 |
xAxisData |
|
46 | xAxisData[dataIndex] = timeOnFreq; | |
47 |
valuesData |
|
47 | valuesData[dataIndex] = std::cos(timeOnFreq); | |
48 |
|
48 | |||
49 | // progression |
|
49 | // progression | |
50 | int currentProgress = (time - start) * 100.0 / progressEnd; |
|
50 | int currentProgress = (time - start) * 100.0 / progressEnd; |
General Comments 0
You need to be logged in to leave comments.
Login now