From 2c63a29c9c11ae0c7f0b74282a9c9fba55402312 2017-06-14 12:52:22 From: Alexandre Leroux Date: 2017-06-14 12:52:22 Subject: [PATCH] Creates scalar series --- diff --git a/core/include/Data/ScalarSeries.h b/core/include/Data/ScalarSeries.h new file mode 100644 index 0000000..5dd39b0 --- /dev/null +++ b/core/include/Data/ScalarSeries.h @@ -0,0 +1,28 @@ +#ifndef SCIQLOP_SCALARSERIES_H +#define SCIQLOP_SCALARSERIES_H + +#include + +/** + * @brief The ScalarSeries class is the implementation for a data series representing a scalar. + */ +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 QString &xAxisUnit, const QString &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; +}; + +#endif // SCIQLOP_SCALARSERIES_H diff --git a/core/src/Data/ScalarSeries.cpp b/core/src/Data/ScalarSeries.cpp new file mode 100644 index 0000000..f3f4fc2 --- /dev/null +++ b/core/src/Data/ScalarSeries.cpp @@ -0,0 +1,13 @@ +#include + +ScalarSeries::ScalarSeries(int size, const QString &xAxisUnit, const QString &valuesUnit) + : DataSeries{std::make_shared >(size), xAxisUnit, + std::make_shared >(size), valuesUnit} +{ +} + +void ScalarSeries::setData(int index, double x, double value) noexcept +{ + xAxisData()->setData(index, x); + valuesData()->setData(index, value); +}