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