@@ -21,6 +21,9 public: | |||
|
21 | 21 | |
|
22 | 22 | void addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept; |
|
23 | 23 | |
|
24 | /// @return the data of the variable, nullptr if there is no data | |
|
25 | IDataSeries *dataSeries() const noexcept; | |
|
26 | ||
|
24 | 27 | private: |
|
25 | 28 | class VariablePrivate; |
|
26 | 29 | spimpl::unique_impl_ptr<VariablePrivate> impl; |
@@ -41,3 +41,8 void Variable::addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept | |||
|
41 | 41 | } |
|
42 | 42 | /// @todo : else, merge the two data series (if possible) |
|
43 | 43 | } |
|
44 | ||
|
45 | IDataSeries *Variable::dataSeries() const noexcept | |
|
46 | { | |
|
47 | return impl->m_DataSeries.get(); | |
|
48 | } |
@@ -1,17 +1,54 | |||
|
1 | 1 | #include "Visualization/GraphPlottablesFactory.h" |
|
2 | 2 | #include "Visualization/qcustomplot.h" |
|
3 | 3 | |
|
4 | #include <Data/ScalarSeries.h> | |
|
5 | ||
|
4 | 6 | #include <Variable/Variable.h> |
|
5 | 7 | |
|
6 | 8 | Q_LOGGING_CATEGORY(LOG_GraphPlottablesFactory, "GraphPlottablesFactory") |
|
7 | 9 | |
|
10 | namespace { | |
|
11 | ||
|
12 | ||
|
13 | QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QCustomPlot &plot) | |
|
14 | { | |
|
15 | auto component = plot.addGraph(); | |
|
16 | ||
|
17 | if (component) { | |
|
18 | // Graph data | |
|
19 | component->setData(scalarSeries.xAxisData()->data(), scalarSeries.valuesData()->data(), | |
|
20 | true); | |
|
21 | ||
|
22 | // Display all data | |
|
23 | component->rescaleAxes(); | |
|
24 | ||
|
25 | plot.replot(); | |
|
26 | } | |
|
27 | else { | |
|
28 | qCDebug(LOG_GraphPlottablesFactory()) | |
|
29 | << QObject::tr("Can't create graph for the scalar series"); | |
|
30 | } | |
|
31 | ||
|
32 | return component; | |
|
33 | } | |
|
34 | ||
|
35 | } // namespace | |
|
36 | ||
|
8 | 37 | QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(const Variable *variable, |
|
9 | 38 | QCustomPlot &plot) noexcept |
|
10 | 39 | { |
|
11 | 40 | auto result = QVector<QCPAbstractPlottable *>{}; |
|
12 | 41 | |
|
13 | 42 | if (variable) { |
|
14 | /// @todo ALX | |
|
43 | // Gets the data series of the variable to call the creation of the right components | |
|
44 | // according to its type | |
|
45 | if (auto scalarSeries = dynamic_cast<ScalarSeries *>(variable->dataSeries())) { | |
|
46 | result.append(createScalarSeriesComponent(*scalarSeries, plot)); | |
|
47 | } | |
|
48 | else { | |
|
49 | qCDebug(LOG_GraphPlottablesFactory()) | |
|
50 | << QObject::tr("Can't create graph plottables : unmanaged data series type"); | |
|
51 | } | |
|
15 | 52 | } |
|
16 | 53 | else { |
|
17 | 54 | qCDebug(LOG_GraphPlottablesFactory()) |
General Comments 0
You need to be logged in to leave comments.
Login now