##// END OF EJS Templates
Add int data index in CosinusProvider
Alexandre Leroux -
r137:a659cfcd7e23
parent child
Show More
@@ -1,30 +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>
6 #include <cmath>
7
7
8 std::unique_ptr<IDataSeries>
8 std::unique_ptr<IDataSeries>
9 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
9 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
10 {
10 {
11 // Gets the timerange from the parameters
11 // Gets the timerange from the parameters
12 auto start = parameters.m_TStart;
12 auto start = parameters.m_TStart;
13 auto end = parameters.m_TEnd;
13 auto end = parameters.m_TEnd;
14
14
15 // We assure that timerange is valid
15 // We assure that timerange is valid
16 if (end < start) {
16 if (end < start) {
17 std::swap(start, end);
17 std::swap(start, end);
18 }
18 }
19
19
20 // Generates scalar series containing cosinus values (one value per second)
20 // Generates scalar series containing cosinus values (one value per second)
21 auto scalarSeries
21 auto scalarSeries
22 = std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), QStringLiteral(""));
22 = std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), QStringLiteral(""));
23
23
24 for (auto time = start; time < end; ++time) {
24 auto dataIndex = 0;
25 auto dataIndex = time - start;
25 for (auto time = start; time < end; ++time, ++dataIndex) {
26 scalarSeries->setData(dataIndex, time, std::cos(time));
26 scalarSeries->setData(dataIndex, time, std::cos(time));
27 }
27 }
28
28
29 return scalarSeries;
29 return scalarSeries;
30 }
30 }
General Comments 0
You need to be logged in to leave comments. Login now