##// END OF EJS Templates
Creates constructor for ScalarSeries that directly takes vectors...
Alexandre Leroux -
r361:cae900f78dff
parent child
Show More
@@ -27,6 +27,17 public:
27 m_Data[0].resize(nbColumns);
27 m_Data[0].resize(nbColumns);
28 }
28 }
29
29
30 /**
31 * Ctor for a unidimensional ArrayData
32 * @param data the data the ArrayData will hold
33 */
34 template <int D = Dim, typename = std::enable_if_t<D == 1> >
35 explicit ArrayData(QVector<double> data) : m_Data{1, QVector<double>{}}
36 {
37 QWriteLocker locker{&m_Lock};
38 m_Data[0] = std::move(data);
39 }
40
30 /// Copy ctor
41 /// Copy ctor
31 explicit ArrayData(const ArrayData &other)
42 explicit ArrayData(const ArrayData &other)
32 {
43 {
@@ -17,6 +17,15 public:
17 explicit ScalarSeries(int size, const Unit &xAxisUnit, const Unit &valuesUnit);
17 explicit ScalarSeries(int size, const Unit &xAxisUnit, const Unit &valuesUnit);
18
18
19 /**
19 /**
20 * Ctor with two vectors. The vectors must have the same size, otherwise a ScalarSeries with no
21 * values will be created.
22 * @param xAxisData x-axis data
23 * @param valuesData values data
24 */
25 explicit ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData,
26 const Unit &xAxisUnit, const Unit &valuesUnit);
27
28 /**
20 * Sets data for a specific index. The index has to be valid to be effective
29 * Sets data for a specific index. The index has to be valid to be effective
21 * @param index the index to which the data will be set
30 * @param index the index to which the data will be set
22 * @param x the x-axis data
31 * @param x the x-axis data
@@ -6,6 +6,13 ScalarSeries::ScalarSeries(int size, const Unit &xAxisUnit, const Unit &valuesUn
6 {
6 {
7 }
7 }
8
8
9 ScalarSeries::ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData,
10 const Unit &xAxisUnit, const Unit &valuesUnit)
11 : DataSeries{std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit,
12 std::make_shared<ArrayData<1> >(std::move(valuesData)), valuesUnit}
13 {
14 }
15
9 void ScalarSeries::setData(int index, double x, double value) noexcept
16 void ScalarSeries::setData(int index, double x, double value) noexcept
10 {
17 {
11 xAxisData()->setData(index, x);
18 xAxisData()->setData(index, x);
@@ -59,12 +59,6 std::shared_ptr<IDataSeries> AmdaResultParser::readTxt(const QString &filePath)
59 }
59 }
60
60
61 /// @todo ALX : handle units
61 /// @todo ALX : handle units
62 auto scalarSeries = std::make_shared<ScalarSeries>(xData.size(), Unit{"nT", true}, Unit{});
62 return std::make_shared<ScalarSeries>(std::move(xData), std::move(valuesData), Unit{"nT", true},
63
63 Unit{});
64 const auto count = xData.size();
65 for (auto i = 0; i < count; ++i) {
66 scalarSeries->setData(i, xData.at(i), valuesData.at(i));
67 }
68
69 return scalarSeries;
70 }
64 }
General Comments 0
You need to be logged in to leave comments. Login now