@@ -1,28 +1,30 | |||||
1 | #include "CosinusProvider.h" |
|
1 | #include "CosinusProvider.h" | |
2 |
|
2 | |||
3 | #include <Data/DataProviderParameters.h> |
|
3 | #include <Data/DataProviderParameters.h> | |
4 | #include <Data/ScalarSeries.h> |
|
4 | #include <Data/ScalarSeries.h> | |
5 |
|
5 | |||
|
6 | #include <cmath> | |||
|
7 | ||||
6 | std::unique_ptr<IDataSeries> |
|
8 | std::unique_ptr<IDataSeries> | |
7 | CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const |
|
9 | CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const | |
8 | { |
|
10 | { | |
9 | // Gets the timerange from the parameters |
|
11 | // Gets the timerange from the parameters | |
10 | auto start = parameters.m_TStart; |
|
12 | auto start = parameters.m_TStart; | |
11 | auto end = parameters.m_TEnd; |
|
13 | auto end = parameters.m_TEnd; | |
12 |
|
14 | |||
13 | // We assure that timerange is valid |
|
15 | // We assure that timerange is valid | |
14 | if (end < start) { |
|
16 | if (end < start) { | |
15 | std::swap(start, end); |
|
17 | std::swap(start, end); | |
16 | } |
|
18 | } | |
17 |
|
19 | |||
18 | // Generates scalar series containing cosinus values (one value per second) |
|
20 | // Generates scalar series containing cosinus values (one value per second) | |
19 | auto scalarSeries |
|
21 | auto scalarSeries | |
20 | = std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), QStringLiteral("")); |
|
22 | = std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), QStringLiteral("")); | |
21 |
|
23 | |||
22 | for (auto time = start; time < end; ++time) { |
|
24 | for (auto time = start; time < end; ++time) { | |
23 | auto dataIndex = time - start; |
|
25 | auto dataIndex = time - start; | |
24 | scalarSeries->setData(dataIndex, time, std::cos(time)); |
|
26 | scalarSeries->setData(dataIndex, time, std::cos(time)); | |
25 | } |
|
27 | } | |
26 |
|
28 | |||
27 | return scalarSeries; |
|
29 | return scalarSeries; | |
28 | } |
|
30 | } |
General Comments 0
You need to be logged in to leave comments.
Login now