##// END OF EJS Templates
Adds name to a graph...
Adds name to a graph - The name is passed as a parameter in the ctor - It is used as a title of the graph and will also be used to be displayed in menus related to a variable

File last commit:

r191:e7b5abd4403a
r196:8ddc77b998a0
Show More
CosinusProvider.cpp
32 lines | 871 B | text/x-c | CppLexer
#include "CosinusProvider.h"
#include <Data/DataProviderParameters.h>
#include <Data/ScalarSeries.h>
#include <cmath>
std::unique_ptr<IDataSeries>
CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
{
auto dateTime = parameters.m_Time;
// Gets the timerange from the parameters
auto start = dateTime.m_TStart;
auto end = dateTime.m_TEnd;
// We assure that timerange is valid
if (end < start) {
std::swap(start, end);
}
// Generates scalar series containing cosinus values (one value per second)
auto scalarSeries
= std::make_unique<ScalarSeries>(end - start, Unit{QStringLiteral("t"), true}, Unit{});
auto dataIndex = 0;
for (auto time = start; time < end; ++time, ++dataIndex) {
scalarSeries->setData(dataIndex, time, std::cos(time));
}
return scalarSeries;
}