##// END OF EJS Templates
Update DataSeries to make it compatible with the new arraydata
perrinel -
r295:93cf201f35ca
parent child
Show More
@@ -1,70 +1,70
1 #ifndef SCIQLOP_DATASERIES_H
1 #ifndef SCIQLOP_DATASERIES_H
2 #define SCIQLOP_DATASERIES_H
2 #define SCIQLOP_DATASERIES_H
3
3
4 #include <Data/ArrayData.h>
4 #include <Data/ArrayData.h>
5 #include <Data/IDataSeries.h>
5 #include <Data/IDataSeries.h>
6
6
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8
8
9 #include <memory>
9 #include <memory>
10
10
11
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSeries)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSeries)
13 Q_LOGGING_CATEGORY(LOG_DataSeries, "DataSeries")
13 Q_LOGGING_CATEGORY(LOG_DataSeries, "DataSeries")
14
14
15
15
16 /**
16 /**
17 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
17 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
18 *
18 *
19 * It proposes to set a dimension for the values ​​data
19 * It proposes to set a dimension for the values ​​data
20 *
20 *
21 * @tparam Dim The dimension of the values data
21 * @tparam Dim The dimension of the values data
22 *
22 *
23 */
23 */
24 template <int Dim>
24 template <int Dim>
25 class DataSeries : public IDataSeries {
25 class DataSeries : public IDataSeries {
26 public:
26 public:
27 /// @sa IDataSeries::xAxisData()
27 /// @sa IDataSeries::xAxisData()
28 std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; }
28 std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; }
29
29
30 /// @sa IDataSeries::xAxisUnit()
30 /// @sa IDataSeries::xAxisUnit()
31 Unit xAxisUnit() const override { return m_XAxisUnit; }
31 Unit xAxisUnit() const override { return m_XAxisUnit; }
32
32
33 /// @return the values dataset
33 /// @return the values dataset
34 std::shared_ptr<ArrayData<Dim> > valuesData() const { return m_ValuesData; }
34 std::shared_ptr<ArrayData<Dim> > valuesData() const { return m_ValuesData; }
35
35
36 /// @sa IDataSeries::valuesUnit()
36 /// @sa IDataSeries::valuesUnit()
37 Unit valuesUnit() const override { return m_ValuesUnit; }
37 Unit valuesUnit() const override { return m_ValuesUnit; }
38
38
39 /// @sa IDataSeries::merge()
39 /// @sa IDataSeries::merge()
40 void merge(IDataSeries *dataSeries) override
40 void merge(IDataSeries *dataSeries) override
41 {
41 {
42 if (auto dimDataSeries = dynamic_cast<DataSeries<Dim> *>(dataSeries)) {
42 if (auto dimDataSeries = dynamic_cast<DataSeries<Dim> *>(dataSeries)) {
43 m_XAxisData->merge(dimDataSeries->xAxisData().get());
43 m_XAxisData->merge(*dimDataSeries->xAxisData());
44 m_ValuesData->merge(dimDataSeries->valuesData().get());
44 m_ValuesData->merge(*dimDataSeries->valuesData());
45 }
45 }
46 else {
46 else {
47 qCWarning(LOG_DataSeries())
47 qCWarning(LOG_DataSeries())
48 << QObject::tr("Dection of a type of IDataSeries we cannot merge with !");
48 << QObject::tr("Dection of a type of IDataSeries we cannot merge with !");
49 }
49 }
50 }
50 }
51
51
52 protected:
52 protected:
53 /// Protected ctor (DataSeries is abstract)
53 /// Protected ctor (DataSeries is abstract)
54 explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit,
54 explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit,
55 std::shared_ptr<ArrayData<Dim> > valuesData, const Unit &valuesUnit)
55 std::shared_ptr<ArrayData<Dim> > valuesData, const Unit &valuesUnit)
56 : m_XAxisData{xAxisData},
56 : m_XAxisData{xAxisData},
57 m_XAxisUnit{xAxisUnit},
57 m_XAxisUnit{xAxisUnit},
58 m_ValuesData{valuesData},
58 m_ValuesData{valuesData},
59 m_ValuesUnit{valuesUnit}
59 m_ValuesUnit{valuesUnit}
60 {
60 {
61 }
61 }
62
62
63 private:
63 private:
64 std::shared_ptr<ArrayData<1> > m_XAxisData;
64 std::shared_ptr<ArrayData<1> > m_XAxisData;
65 Unit m_XAxisUnit;
65 Unit m_XAxisUnit;
66 std::shared_ptr<ArrayData<Dim> > m_ValuesData;
66 std::shared_ptr<ArrayData<Dim> > m_ValuesData;
67 Unit m_ValuesUnit;
67 Unit m_ValuesUnit;
68 };
68 };
69
69
70 #endif // SCIQLOP_DATASERIES_H
70 #endif // SCIQLOP_DATASERIES_H
General Comments 0
You need to be logged in to leave comments. Login now