@@ -0,0 +1,30 | |||||
|
1 | #ifndef SCIQLOP_VECTORSERIES_H | |||
|
2 | #define SCIQLOP_VECTORSERIES_H | |||
|
3 | ||||
|
4 | #include "CoreGlobal.h" | |||
|
5 | ||||
|
6 | #include <Data/DataSeries.h> | |||
|
7 | ||||
|
8 | /** | |||
|
9 | * @brief The VectorSeries class is the implementation for a data series representing a vector. | |||
|
10 | */ | |||
|
11 | class SCIQLOP_CORE_EXPORT VectorSeries : public DataSeries<2> { | |||
|
12 | public: | |||
|
13 | /** | |||
|
14 | * Ctor. The vectors must have the same size, otherwise a ScalarSeries with no values will be | |||
|
15 | * created. | |||
|
16 | * @param xAxisData x-axis data | |||
|
17 | * @param xvaluesData x-values data | |||
|
18 | * @param yvaluesData y-values data | |||
|
19 | * @param zvaluesData z-values data | |||
|
20 | */ | |||
|
21 | explicit VectorSeries(QVector<double> xAxisData, QVector<double> xValuesData, | |||
|
22 | QVector<double> yValuesData, QVector<double> zValuesData, | |||
|
23 | const Unit &xAxisUnit, const Unit &valuesUnit); | |||
|
24 | ||||
|
25 | std::unique_ptr<IDataSeries> clone() const; | |||
|
26 | ||||
|
27 | std::shared_ptr<IDataSeries> subDataSeries(const SqpRange &range) override; | |||
|
28 | }; | |||
|
29 | ||||
|
30 | #endif // SCIQLOP_VECTORSERIES_H |
@@ -0,0 +1,39 | |||||
|
1 | #include "Data/VectorSeries.h" | |||
|
2 | ||||
|
3 | VectorSeries::VectorSeries(QVector<double> xAxisData, QVector<double> xValuesData, | |||
|
4 | QVector<double> yValuesData, QVector<double> zValuesData, | |||
|
5 | const Unit &xAxisUnit, const Unit &valuesUnit) | |||
|
6 | : DataSeries{std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit, | |||
|
7 | std::make_shared<ArrayData<2> >(QVector<QVector<double> >{ | |||
|
8 | std::move(xValuesData), std::move(yValuesData), std::move(zValuesData)}), | |||
|
9 | valuesUnit} | |||
|
10 | { | |||
|
11 | } | |||
|
12 | ||||
|
13 | std::unique_ptr<IDataSeries> VectorSeries::clone() const | |||
|
14 | { | |||
|
15 | return std::make_unique<VectorSeries>(*this); | |||
|
16 | } | |||
|
17 | ||||
|
18 | std::shared_ptr<IDataSeries> VectorSeries::subDataSeries(const SqpRange &range) | |||
|
19 | { | |||
|
20 | auto subXAxisData = QVector<double>(); | |||
|
21 | auto subXValuesData = QVector<double>(); | |||
|
22 | auto subYValuesData = QVector<double>(); | |||
|
23 | auto subZValuesData = QVector<double>(); | |||
|
24 | ||||
|
25 | this->lockRead(); | |||
|
26 | { | |||
|
27 | auto bounds = subData(range.m_TStart, range.m_TEnd); | |||
|
28 | for (auto it = bounds.first; it != bounds.second; ++it) { | |||
|
29 | subXAxisData.append(it->x()); | |||
|
30 | subXValuesData.append(it->value(0)); | |||
|
31 | subYValuesData.append(it->value(1)); | |||
|
32 | subZValuesData.append(it->value(2)); | |||
|
33 | } | |||
|
34 | } | |||
|
35 | this->unlock(); | |||
|
36 | ||||
|
37 | return std::make_shared<VectorSeries>(subXAxisData, subXValuesData, subYValuesData, | |||
|
38 | subZValuesData, this->xAxisUnit(), this->valuesUnit()); | |||
|
39 | } |
@@ -18,20 +18,10 std::shared_ptr<IDataSeries> ScalarSeries::subDataSeries(const SqpRange &range) | |||||
18 | auto subValuesData = QVector<double>(); |
|
18 | auto subValuesData = QVector<double>(); | |
19 | this->lockRead(); |
|
19 | this->lockRead(); | |
20 | { |
|
20 | { | |
21 | const auto ¤tXData = this->xAxisData()->cdata(); |
|
21 | auto bounds = subData(range.m_TStart, range.m_TEnd); | |
22 | const auto ¤tValuesData = this->valuesData()->cdata(); |
|
22 | for (auto it = bounds.first; it != bounds.second; ++it) { | |
23 |
|
23 | subXAxisData.append(it->x()); | ||
24 | auto xDataBegin = currentXData.cbegin(); |
|
24 | subValuesData.append(it->value()); | |
25 | auto xDataEnd = currentXData.cend(); |
|
|||
26 |
|
||||
27 | auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, range.m_TStart); |
|
|||
28 | auto upperIt = std::upper_bound(xDataBegin, xDataEnd, range.m_TEnd); |
|
|||
29 | auto distance = std::distance(xDataBegin, lowerIt); |
|
|||
30 |
|
||||
31 | auto valuesDataIt = currentValuesData.cbegin() + distance; |
|
|||
32 | for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt; ++xAxisDataIt, ++valuesDataIt) { |
|
|||
33 | subXAxisData.append(*xAxisDataIt); |
|
|||
34 | subValuesData.append(*valuesDataIt); |
|
|||
35 | } |
|
25 | } | |
36 | } |
|
26 | } | |
37 | this->unlock(); |
|
27 | this->unlock(); |
General Comments 0
You need to be logged in to leave comments.
Login now