diff --git a/core/include/Data/ScalarSeries.h b/core/include/Data/ScalarSeries.h index bbc2168..6be68df 100644 --- a/core/include/Data/ScalarSeries.h +++ b/core/include/Data/ScalarSeries.h @@ -9,14 +9,6 @@ class ScalarSeries : public DataSeries<1> { public: /** - * Ctor - * @param size the number of data the series will hold - * @param xAxisUnit x-axis unit - * @param valuesUnit values unit - */ - explicit ScalarSeries(int size, const Unit &xAxisUnit, const Unit &valuesUnit); - - /** * Ctor with two vectors. The vectors must have the same size, otherwise a ScalarSeries with no * values will be created. * @param xAxisData x-axis data @@ -25,14 +17,6 @@ public: explicit ScalarSeries(QVector xAxisData, QVector valuesData, const Unit &xAxisUnit, const Unit &valuesUnit); - /** - * Sets data for a specific index. The index has to be valid to be effective - * @param index the index to which the data will be set - * @param x the x-axis data - * @param value the value data - */ - void setData(int index, double x, double value) noexcept; - std::unique_ptr clone() const; }; diff --git a/core/src/Data/ScalarSeries.cpp b/core/src/Data/ScalarSeries.cpp index b38d8b0..8080c67 100644 --- a/core/src/Data/ScalarSeries.cpp +++ b/core/src/Data/ScalarSeries.cpp @@ -1,11 +1,5 @@ #include -ScalarSeries::ScalarSeries(int size, const Unit &xAxisUnit, const Unit &valuesUnit) - : DataSeries{std::make_shared >(size), xAxisUnit, - std::make_shared >(size), valuesUnit} -{ -} - ScalarSeries::ScalarSeries(QVector xAxisData, QVector valuesData, const Unit &xAxisUnit, const Unit &valuesUnit) : DataSeries{std::make_shared >(std::move(xAxisData)), xAxisUnit, @@ -13,12 +7,6 @@ ScalarSeries::ScalarSeries(QVector xAxisData, QVector valuesData { } -void ScalarSeries::setData(int index, double x, double value) noexcept -{ - xAxisData()->setData(index, x); - valuesData()->setData(index, value); -} - std::unique_ptr ScalarSeries::clone() const { return std::make_unique(*this); diff --git a/plugins/mockplugin/src/CosinusProvider.cpp b/plugins/mockplugin/src/CosinusProvider.cpp index 82a8bdd..d49bd10 100644 --- a/plugins/mockplugin/src/CosinusProvider.cpp +++ b/plugins/mockplugin/src/CosinusProvider.cpp @@ -19,8 +19,8 @@ std::shared_ptr CosinusProvider::retrieveData(QUuid token, const Sq // Gets the timerange from the parameters double freq = 100.0; - double start = dateTime.m_TStart * freq; // 100 htz - double end = dateTime.m_TEnd * freq; // 100 htz + double start = std::ceil(dateTime.m_TStart * freq); // 100 htz + double end = std::floor(dateTime.m_TEnd * freq); // 100 htz // We assure that timerange is valid if (end < start) { @@ -28,17 +28,23 @@ std::shared_ptr CosinusProvider::retrieveData(QUuid token, const Sq } // Generates scalar series containing cosinus values (one value per second) - auto scalarSeries - = std::make_shared(end - start, Unit{QStringLiteral("t"), true}, Unit{}); + auto dataCount = end - start; + auto xAxisData = QVector{}; + xAxisData.resize(dataCount); + + auto valuesData = QVector{}; + valuesData.resize(dataCount); int progress = 0; - auto progressEnd = end - start; + auto progressEnd = dataCount; for (auto time = start; time < end; ++time, ++dataIndex) { auto it = m_VariableToEnableProvider.find(token); if (it != m_VariableToEnableProvider.end() && it.value()) { const auto timeOnFreq = time / freq; - scalarSeries->setData(dataIndex, timeOnFreq, std::cos(timeOnFreq)); + + xAxisData.replace(dataIndex, timeOnFreq); + valuesData.replace(dataIndex, std::cos(timeOnFreq)); // progression int currentProgress = (time - start) * 100.0 / progressEnd; @@ -58,8 +64,8 @@ std::shared_ptr CosinusProvider::retrieveData(QUuid token, const Sq } emit dataProvidedProgress(token, 0.0); - - return scalarSeries; + return std::make_shared(std::move(xAxisData), std::move(valuesData), + Unit{QStringLiteral("t"), true}, Unit{}); } void CosinusProvider::requestDataLoading(QUuid token, const DataProviderParameters ¶meters)