@@ -21,30 +21,30 public: | |||
|
21 | 21 | std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; } |
|
22 | 22 | |
|
23 | 23 | /// @sa IDataSeries::xAxisUnit() |
|
24 |
|
|
|
24 | Unit xAxisUnit() const override { return m_XAxisUnit; } | |
|
25 | 25 | |
|
26 | 26 | /// @return the values dataset |
|
27 | 27 | std::shared_ptr<ArrayData<Dim> > valuesData() const { return m_ValuesData; } |
|
28 | 28 | |
|
29 | 29 | /// @sa IDataSeries::valuesUnit() |
|
30 |
|
|
|
30 | Unit valuesUnit() const override { return m_ValuesUnit; } | |
|
31 | 31 | |
|
32 | 32 | protected: |
|
33 | 33 | /// Protected ctor (DataSeries is abstract) |
|
34 |
explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, |
|
|
35 |
std::shared_ptr<ArrayData<Dim> > valuesData, |
|
|
34 | explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, Unit xAxisUnit, | |
|
35 | std::shared_ptr<ArrayData<Dim> > valuesData, Unit valuesUnit) | |
|
36 | 36 | : m_XAxisData{xAxisData}, |
|
37 | m_XAxisUnit{xAxisUnit}, | |
|
37 | m_XAxisUnit{std::move(xAxisUnit)}, | |
|
38 | 38 | m_ValuesData{valuesData}, |
|
39 | m_ValuesUnit{valuesUnit} | |
|
39 | m_ValuesUnit{std::move(valuesUnit)} | |
|
40 | 40 | { |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | private: |
|
44 | 44 | std::shared_ptr<ArrayData<1> > m_XAxisData; |
|
45 |
|
|
|
45 | Unit m_XAxisUnit; | |
|
46 | 46 | std::shared_ptr<ArrayData<Dim> > m_ValuesData; |
|
47 |
|
|
|
47 | Unit m_ValuesUnit; | |
|
48 | 48 | }; |
|
49 | 49 | |
|
50 | 50 | #endif // SCIQLOP_DATASERIES_H |
@@ -8,6 +8,16 | |||
|
8 | 8 | template <int Dim> |
|
9 | 9 | class ArrayData; |
|
10 | 10 | |
|
11 | struct Unit { | |
|
12 | explicit Unit(const QString &name = {}, bool timeUnit = false) | |
|
13 | : m_Name{name}, m_TimeUnit{timeUnit} | |
|
14 | { | |
|
15 | } | |
|
16 | ||
|
17 | QString m_Name; ///< Unit name | |
|
18 | bool m_TimeUnit; ///< The unit is a unit of time | |
|
19 | }; | |
|
20 | ||
|
11 | 21 | /** |
|
12 | 22 | * @brief The IDataSeries aims to declare a data series. |
|
13 | 23 | * |
@@ -29,9 +39,9 public: | |||
|
29 | 39 | /// Returns the x-axis dataset |
|
30 | 40 | virtual std::shared_ptr<ArrayData<1> > xAxisData() = 0; |
|
31 | 41 | |
|
32 |
virtual |
|
|
42 | virtual Unit xAxisUnit() const = 0; | |
|
33 | 43 | |
|
34 |
virtual |
|
|
44 | virtual Unit valuesUnit() const = 0; | |
|
35 | 45 | }; |
|
36 | 46 | |
|
37 | 47 | #endif // SCIQLOP_IDATASERIES_H |
@@ -14,7 +14,7 public: | |||
|
14 | 14 | * @param xAxisUnit x-axis unit |
|
15 | 15 | * @param valuesUnit values unit |
|
16 | 16 | */ |
|
17 |
explicit ScalarSeries(int size, |
|
|
17 | explicit ScalarSeries(int size, Unit xAxisUnit, Unit valuesUnit); | |
|
18 | 18 | |
|
19 | 19 | /** |
|
20 | 20 | * Sets data for a specific index. The index has to be valid to be effective |
@@ -1,8 +1,8 | |||
|
1 | 1 | #include <Data/ScalarSeries.h> |
|
2 | 2 | |
|
3 |
ScalarSeries::ScalarSeries(int size, |
|
|
4 | : DataSeries{std::make_shared<ArrayData<1> >(size), xAxisUnit, | |
|
5 | std::make_shared<ArrayData<1> >(size), valuesUnit} | |
|
3 | ScalarSeries::ScalarSeries(int size, Unit xAxisUnit, Unit valuesUnit) | |
|
4 | : DataSeries{std::make_shared<ArrayData<1> >(size), std::move(xAxisUnit), | |
|
5 | std::make_shared<ArrayData<1> >(size), std::move(valuesUnit)} | |
|
6 | 6 | { |
|
7 | 7 | } |
|
8 | 8 |
@@ -19,7 +19,7 CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const | |||
|
19 | 19 | |
|
20 | 20 | // Generates scalar series containing cosinus values (one value per second) |
|
21 | 21 | auto scalarSeries |
|
22 |
= std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), |
|
|
22 | = std::make_unique<ScalarSeries>(end - start, Unit{QStringLiteral("t"), true}, Unit{}); | |
|
23 | 23 | |
|
24 | 24 | auto dataIndex = 0; |
|
25 | 25 | for (auto time = start; time < end; ++time, ++dataIndex) { |
General Comments 0
You need to be logged in to leave comments.
Login now