##// END OF EJS Templates
Adds logs to axe and plottable rendering utils
Alexandre Leroux -
r927:c91efb7c50ed
parent child
Show More
@@ -1,34 +1,37
1 #ifndef SCIQLOP_AXISRENDERINGUTILS_H
1 #ifndef SCIQLOP_AXISRENDERINGUTILS_H
2 #define SCIQLOP_AXISRENDERINGUTILS_H
2 #define SCIQLOP_AXISRENDERINGUTILS_H
3
3
4 #include <memory>
4 #include <memory>
5
5
6 #include <QtCore/QLoggingCategory>
6 #include <QtCore/QString>
7 #include <QtCore/QString>
7
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_AxisRenderingUtils)
10
8 class IDataSeries;
11 class IDataSeries;
9 class QCPAxis;
12 class QCPAxis;
10 class QCPColorScale;
13 class QCPColorScale;
11 class QCustomPlot;
14 class QCustomPlot;
12
15
13 /// Formats a data value according to the axis on which it is present
16 /// Formats a data value according to the axis on which it is present
14 QString formatValue(double value, const QCPAxis &axis);
17 QString formatValue(double value, const QCPAxis &axis);
15
18
16 /**
19 /**
17 * Helper used to handle axes rendering
20 * Helper used to handle axes rendering
18 */
21 */
19 struct IAxisHelper {
22 struct IAxisHelper {
20 virtual ~IAxisHelper() noexcept = default;
23 virtual ~IAxisHelper() noexcept = default;
21
24
22 /// Set properties of the plot's axes and the color scale associated to plot passed as
25 /// Set properties of the plot's axes and the color scale associated to plot passed as
23 /// parameters
26 /// parameters
24 /// @param plot the plot for which to set axe properties
27 /// @param plot the plot for which to set axe properties
25 /// @param colorScale the color scale for which to set properties
28 /// @param colorScale the color scale for which to set properties
26 virtual void setProperties(QCustomPlot &plot, QCPColorScale &colorScale) = 0;
29 virtual void setProperties(QCustomPlot &plot, QCPColorScale &colorScale) = 0;
27 };
30 };
28
31
29 struct IAxisHelperFactory {
32 struct IAxisHelperFactory {
30 /// Creates IAxisHelper according to a data series
33 /// Creates IAxisHelper according to a data series
31 static std::unique_ptr<IAxisHelper> create(std::shared_ptr<IDataSeries> dataSeries) noexcept;
34 static std::unique_ptr<IAxisHelper> create(std::shared_ptr<IDataSeries> dataSeries) noexcept;
32 };
35 };
33
36
34 #endif // SCIQLOP_AXISRENDERINGUTILS_H
37 #endif // SCIQLOP_AXISRENDERINGUTILS_H
@@ -1,29 +1,33
1 #ifndef SCIQLOP_PLOTTABLESRENDERINGUTILS_H
1 #ifndef SCIQLOP_PLOTTABLESRENDERINGUTILS_H
2 #define SCIQLOP_PLOTTABLESRENDERINGUTILS_H
2 #define SCIQLOP_PLOTTABLESRENDERINGUTILS_H
3
3
4 #include <Visualization/VisualizationDefs.h>
4 #include <Visualization/VisualizationDefs.h>
5
5
6 #include <memory>
6 #include <memory>
7
7
8 #include <QtCore/QLoggingCategory>
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_PlottablesRenderingUtils)
11
8 class IDataSeries;
12 class IDataSeries;
9 class QCPColorScale;
13 class QCPColorScale;
10 class QCustomPlot;
14 class QCustomPlot;
11
15
12 /**
16 /**
13 * Helper used to handle plottables rendering
17 * Helper used to handle plottables rendering
14 */
18 */
15 struct IPlottablesHelper {
19 struct IPlottablesHelper {
16 virtual ~IPlottablesHelper() noexcept = default;
20 virtual ~IPlottablesHelper() noexcept = default;
17
21
18 /// Set properties of the plottables passed as parameter
22 /// Set properties of the plottables passed as parameter
19 /// @param plottables the plottables for which to set properties
23 /// @param plottables the plottables for which to set properties
20 virtual void setProperties(PlottablesMap &plottables) = 0;
24 virtual void setProperties(PlottablesMap &plottables) = 0;
21 };
25 };
22
26
23 struct IPlottablesHelperFactory {
27 struct IPlottablesHelperFactory {
24 /// Creates IPlottablesHelper according to a data series
28 /// Creates IPlottablesHelper according to a data series
25 static std::unique_ptr<IPlottablesHelper>
29 static std::unique_ptr<IPlottablesHelper>
26 create(std::shared_ptr<IDataSeries> dataSeries) noexcept;
30 create(std::shared_ptr<IDataSeries> dataSeries) noexcept;
27 };
31 };
28
32
29 #endif // SCIQLOP_PLOTTABLESRENDERINGUTILS_H
33 #endif // SCIQLOP_PLOTTABLESRENDERINGUTILS_H
@@ -1,163 +1,166
1 #include "Visualization/AxisRenderingUtils.h"
1 #include "Visualization/AxisRenderingUtils.h"
2
2
3 #include <Data/ScalarSeries.h>
3 #include <Data/ScalarSeries.h>
4 #include <Data/SpectrogramSeries.h>
4 #include <Data/SpectrogramSeries.h>
5 #include <Data/VectorSeries.h>
5 #include <Data/VectorSeries.h>
6
6
7 #include <Visualization/qcustomplot.h>
7 #include <Visualization/qcustomplot.h>
8
8
9 Q_LOGGING_CATEGORY(LOG_AxisRenderingUtils, "AxisRenderingUtils")
10
9 namespace {
11 namespace {
10
12
11 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz");
13 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz");
12
14
13 /// Format for datetimes on a axis
15 /// Format for datetimes on a axis
14 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
16 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
15
17
16 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
18 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
17 /// non-time data
19 /// non-time data
18 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
20 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
19 {
21 {
20 if (isTimeAxis) {
22 if (isTimeAxis) {
21 auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create();
23 auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create();
22 dateTicker->setDateTimeFormat(DATETIME_TICKER_FORMAT);
24 dateTicker->setDateTimeFormat(DATETIME_TICKER_FORMAT);
23 dateTicker->setDateTimeSpec(Qt::UTC);
25 dateTicker->setDateTimeSpec(Qt::UTC);
24
26
25 return dateTicker;
27 return dateTicker;
26 }
28 }
27 else {
29 else {
28 // default ticker
30 // default ticker
29 return QSharedPointer<QCPAxisTicker>::create();
31 return QSharedPointer<QCPAxisTicker>::create();
30 }
32 }
31 }
33 }
32
34
33 /**
35 /**
34 * Sets properties of the axis passed as parameter
36 * Sets properties of the axis passed as parameter
35 * @param axis the axis to set
37 * @param axis the axis to set
36 * @param unit the unit to set for the axis
38 * @param unit the unit to set for the axis
37 * @param scaleType the scale type to set for the axis
39 * @param scaleType the scale type to set for the axis
38 */
40 */
39 void setAxisProperties(QCPAxis &axis, const Unit &unit,
41 void setAxisProperties(QCPAxis &axis, const Unit &unit,
40 QCPAxis::ScaleType scaleType = QCPAxis::stLinear)
42 QCPAxis::ScaleType scaleType = QCPAxis::stLinear)
41 {
43 {
42 // label (unit name)
44 // label (unit name)
43 axis.setLabel(unit.m_Name);
45 axis.setLabel(unit.m_Name);
44
46
45 // scale type
47 // scale type
46 axis.setScaleType(scaleType);
48 axis.setScaleType(scaleType);
47
49
48 // ticker (depending on the type of unit)
50 // ticker (depending on the type of unit)
49 axis.setTicker(axisTicker(unit.m_TimeUnit));
51 axis.setTicker(axisTicker(unit.m_TimeUnit));
50 }
52 }
51
53
52 /**
54 /**
53 * Delegate used to set axes properties
55 * Delegate used to set axes properties
54 */
56 */
55 template <typename T, typename Enabled = void>
57 template <typename T, typename Enabled = void>
56 struct AxisSetter {
58 struct AxisSetter {
57 static void setProperties(T &, QCustomPlot &, QCPColorScale &)
59 static void setProperties(T &, QCustomPlot &, QCPColorScale &)
58 {
60 {
59 // Default implementation does nothing
61 // Default implementation does nothing
62 qCCritical(LOG_AxisRenderingUtils()) << "Can't set axis properties: unmanaged type of data";
60 }
63 }
61 };
64 };
62
65
63 /**
66 /**
64 * Specialization of AxisSetter for scalars and vectors
67 * Specialization of AxisSetter for scalars and vectors
65 * @sa ScalarSeries
68 * @sa ScalarSeries
66 * @sa VectorSeries
69 * @sa VectorSeries
67 */
70 */
68 template <typename T>
71 template <typename T>
69 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<ScalarSeries, T>::value
72 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<ScalarSeries, T>::value
70 or std::is_base_of<VectorSeries, T>::value> > {
73 or std::is_base_of<VectorSeries, T>::value> > {
71 static void setProperties(T &dataSeries, QCustomPlot &plot, QCPColorScale &)
74 static void setProperties(T &dataSeries, QCustomPlot &plot, QCPColorScale &)
72 {
75 {
73 dataSeries.lockRead();
76 dataSeries.lockRead();
74 auto xAxisUnit = dataSeries.xAxisUnit();
77 auto xAxisUnit = dataSeries.xAxisUnit();
75 auto valuesUnit = dataSeries.valuesUnit();
78 auto valuesUnit = dataSeries.valuesUnit();
76 dataSeries.unlock();
79 dataSeries.unlock();
77
80
78 setAxisProperties(*plot.xAxis, xAxisUnit);
81 setAxisProperties(*plot.xAxis, xAxisUnit);
79 setAxisProperties(*plot.yAxis, valuesUnit);
82 setAxisProperties(*plot.yAxis, valuesUnit);
80 }
83 }
81 };
84 };
82
85
83 /**
86 /**
84 * Specialization of AxisSetter for spectrograms
87 * Specialization of AxisSetter for spectrograms
85 * @sa SpectrogramSeries
88 * @sa SpectrogramSeries
86 */
89 */
87 template <typename T>
90 template <typename T>
88 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<SpectrogramSeries, T>::value> > {
91 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<SpectrogramSeries, T>::value> > {
89 static void setProperties(T &dataSeries, QCustomPlot &plot, QCPColorScale &colorScale)
92 static void setProperties(T &dataSeries, QCustomPlot &plot, QCPColorScale &colorScale)
90 {
93 {
91 dataSeries.lockRead();
94 dataSeries.lockRead();
92 auto xAxisUnit = dataSeries.xAxisUnit();
95 auto xAxisUnit = dataSeries.xAxisUnit();
93 /// @todo ALX: use iterators here
96 /// @todo ALX: use iterators here
94 auto yAxisUnit = dataSeries.yAxis().unit();
97 auto yAxisUnit = dataSeries.yAxis().unit();
95 auto valuesUnit = dataSeries.valuesUnit();
98 auto valuesUnit = dataSeries.valuesUnit();
96 dataSeries.unlock();
99 dataSeries.unlock();
97
100
98 setAxisProperties(*plot.xAxis, xAxisUnit);
101 setAxisProperties(*plot.xAxis, xAxisUnit);
99 setAxisProperties(*plot.yAxis, yAxisUnit);
102 setAxisProperties(*plot.yAxis, yAxisUnit);
100
103
101 // Displays color scale in plot
104 // Displays color scale in plot
102 plot.plotLayout()->insertRow(0);
105 plot.plotLayout()->insertRow(0);
103 plot.plotLayout()->addElement(0, 0, &colorScale);
106 plot.plotLayout()->addElement(0, 0, &colorScale);
104 colorScale.setType(QCPAxis::atTop);
107 colorScale.setType(QCPAxis::atTop);
105 colorScale.setMinimumMargins(QMargins{0, 0, 0, 0});
108 colorScale.setMinimumMargins(QMargins{0, 0, 0, 0});
106
109
107 // Aligns color scale with axes
110 // Aligns color scale with axes
108 auto marginGroups = plot.axisRect()->marginGroups();
111 auto marginGroups = plot.axisRect()->marginGroups();
109 for (auto it = marginGroups.begin(), end = marginGroups.end(); it != end; ++it) {
112 for (auto it = marginGroups.begin(), end = marginGroups.end(); it != end; ++it) {
110 colorScale.setMarginGroup(it.key(), it.value());
113 colorScale.setMarginGroup(it.key(), it.value());
111 }
114 }
112
115
113 // Set color scale properties
116 // Set color scale properties
114 colorScale.setLabel(valuesUnit.m_Name);
117 colorScale.setLabel(valuesUnit.m_Name);
115 colorScale.setDataScaleType(QCPAxis::stLogarithmic); // Logarithmic scale
118 colorScale.setDataScaleType(QCPAxis::stLogarithmic); // Logarithmic scale
116 }
119 }
117 };
120 };
118
121
119 /**
122 /**
120 * Default implementation of IAxisHelper, which takes data series to set axes properties
123 * Default implementation of IAxisHelper, which takes data series to set axes properties
121 * @tparam T the data series' type
124 * @tparam T the data series' type
122 */
125 */
123 template <typename T>
126 template <typename T>
124 struct AxisHelper : public IAxisHelper {
127 struct AxisHelper : public IAxisHelper {
125 explicit AxisHelper(T &dataSeries) : m_DataSeries{dataSeries} {}
128 explicit AxisHelper(T &dataSeries) : m_DataSeries{dataSeries} {}
126
129
127 void setProperties(QCustomPlot &plot, QCPColorScale &colorScale) override
130 void setProperties(QCustomPlot &plot, QCPColorScale &colorScale) override
128 {
131 {
129 AxisSetter<T>::setProperties(m_DataSeries, plot, colorScale);
132 AxisSetter<T>::setProperties(m_DataSeries, plot, colorScale);
130 }
133 }
131
134
132 T &m_DataSeries;
135 T &m_DataSeries;
133 };
136 };
134
137
135 } // namespace
138 } // namespace
136
139
137 QString formatValue(double value, const QCPAxis &axis)
140 QString formatValue(double value, const QCPAxis &axis)
138 {
141 {
139 // If the axis is a time axis, formats the value as a date
142 // If the axis is a time axis, formats the value as a date
140 if (auto axisTicker = qSharedPointerDynamicCast<QCPAxisTickerDateTime>(axis.ticker())) {
143 if (auto axisTicker = qSharedPointerDynamicCast<QCPAxisTickerDateTime>(axis.ticker())) {
141 return DateUtils::dateTime(value, axisTicker->dateTimeSpec()).toString(DATETIME_FORMAT);
144 return DateUtils::dateTime(value, axisTicker->dateTimeSpec()).toString(DATETIME_FORMAT);
142 }
145 }
143 else {
146 else {
144 return QString::number(value);
147 return QString::number(value);
145 }
148 }
146 }
149 }
147
150
148 std::unique_ptr<IAxisHelper>
151 std::unique_ptr<IAxisHelper>
149 IAxisHelperFactory::create(std::shared_ptr<IDataSeries> dataSeries) noexcept
152 IAxisHelperFactory::create(std::shared_ptr<IDataSeries> dataSeries) noexcept
150 {
153 {
151 if (auto scalarSeries = std::dynamic_pointer_cast<ScalarSeries>(dataSeries)) {
154 if (auto scalarSeries = std::dynamic_pointer_cast<ScalarSeries>(dataSeries)) {
152 return std::make_unique<AxisHelper<ScalarSeries> >(*scalarSeries);
155 return std::make_unique<AxisHelper<ScalarSeries> >(*scalarSeries);
153 }
156 }
154 else if (auto spectrogramSeries = std::dynamic_pointer_cast<SpectrogramSeries>(dataSeries)) {
157 else if (auto spectrogramSeries = std::dynamic_pointer_cast<SpectrogramSeries>(dataSeries)) {
155 return std::make_unique<AxisHelper<SpectrogramSeries> >(*spectrogramSeries);
158 return std::make_unique<AxisHelper<SpectrogramSeries> >(*spectrogramSeries);
156 }
159 }
157 else if (auto vectorSeries = std::dynamic_pointer_cast<VectorSeries>(dataSeries)) {
160 else if (auto vectorSeries = std::dynamic_pointer_cast<VectorSeries>(dataSeries)) {
158 return std::make_unique<AxisHelper<VectorSeries> >(*vectorSeries);
161 return std::make_unique<AxisHelper<VectorSeries> >(*vectorSeries);
159 }
162 }
160 else {
163 else {
161 return std::make_unique<AxisHelper<IDataSeries> >(*dataSeries);
164 return std::make_unique<AxisHelper<IDataSeries> >(*dataSeries);
162 }
165 }
163 }
166 }
@@ -1,120 +1,127
1 #include "Visualization/PlottablesRenderingUtils.h"
1 #include "Visualization/PlottablesRenderingUtils.h"
2
2
3 #include <Common/ColorUtils.h>
3 #include <Common/ColorUtils.h>
4
4
5 #include <Data/ScalarSeries.h>
5 #include <Data/ScalarSeries.h>
6 #include <Data/SpectrogramSeries.h>
6 #include <Data/SpectrogramSeries.h>
7 #include <Data/VectorSeries.h>
7 #include <Data/VectorSeries.h>
8
8
9 #include <Visualization/qcustomplot.h>
9 #include <Visualization/qcustomplot.h>
10
10
11 Q_LOGGING_CATEGORY(LOG_PlottablesRenderingUtils, "PlottablesRenderingUtils")
12
11 namespace {
13 namespace {
12
14
13 /// Default gradient used for colormap
15 /// Default gradient used for colormap
14 const auto DEFAULT_COLORMAP_GRADIENT = QCPColorGradient::gpJet;
16 const auto DEFAULT_COLORMAP_GRADIENT = QCPColorGradient::gpJet;
15
17
16 /**
18 /**
17 * Delegate used to set plottables properties
19 * Delegate used to set plottables properties
18 */
20 */
19 template <typename T, typename Enabled = void>
21 template <typename T, typename Enabled = void>
20 struct PlottablesSetter {
22 struct PlottablesSetter {
21 static void setProperties(T &, PlottablesMap &)
23 static void setProperties(T &, PlottablesMap &)
22 {
24 {
23 // Default implementation does nothing
25 // Default implementation does nothing
26 qCCritical(LOG_PlottablesRenderingUtils())
27 << "Can't set plottables properties: unmanaged type of data";
24 }
28 }
25 };
29 };
26
30
27 /**
31 /**
28 * Specialization of PlottablesSetter for scalars and vectors
32 * Specialization of PlottablesSetter for scalars and vectors
29 * @sa ScalarSeries
33 * @sa ScalarSeries
30 * @sa VectorSeries
34 * @sa VectorSeries
31 */
35 */
32 template <typename T>
36 template <typename T>
33 struct PlottablesSetter<T, typename std::enable_if_t<std::is_base_of<ScalarSeries, T>::value
37 struct PlottablesSetter<T, typename std::enable_if_t<std::is_base_of<ScalarSeries, T>::value
34 or std::is_base_of<VectorSeries, T>::value> > {
38 or std::is_base_of<VectorSeries, T>::value> > {
35 static void setProperties(T &dataSeries, PlottablesMap &plottables)
39 static void setProperties(T &dataSeries, PlottablesMap &plottables)
36 {
40 {
37 // Gets the number of components of the data series
41 // Gets the number of components of the data series
38 dataSeries.lockRead();
42 dataSeries.lockRead();
39 auto componentCount = dataSeries.valuesData()->componentCount();
43 auto componentCount = dataSeries.valuesData()->componentCount();
40 dataSeries.unlock();
44 dataSeries.unlock();
41
45
42 // Generates colors for each component
46 // Generates colors for each component
43 auto colors = ColorUtils::colors(Qt::blue, Qt::red, componentCount);
47 auto colors = ColorUtils::colors(Qt::blue, Qt::red, componentCount);
44
48
45 // For each component of the data series, creates a QCPGraph to add to the plot
49 // For each component of the data series, creates a QCPGraph to add to the plot
46 for (auto i = 0; i < componentCount; ++i) {
50 for (auto i = 0; i < componentCount; ++i) {
47 auto graph = plottables.at(i);
51 auto graph = plottables.at(i);
48 graph->setPen(QPen{colors.at(i)});
52 graph->setPen(QPen{colors.at(i)});
49 }
53 }
50 }
54 }
51 };
55 };
52
56
53 /**
57 /**
54 * Specialization of PlottablesSetter for spectrograms
58 * Specialization of PlottablesSetter for spectrograms
55 * @sa SpectrogramSeries
59 * @sa SpectrogramSeries
56 */
60 */
57 template <typename T>
61 template <typename T>
58 struct PlottablesSetter<T,
62 struct PlottablesSetter<T,
59 typename std::enable_if_t<std::is_base_of<SpectrogramSeries, T>::value> > {
63 typename std::enable_if_t<std::is_base_of<SpectrogramSeries, T>::value> > {
60 static void setProperties(T &, PlottablesMap &plottables)
64 static void setProperties(T &, PlottablesMap &plottables)
61 {
65 {
62 // Checks that for a spectrogram there is only one plottable, that is a colormap
66 // Checks that for a spectrogram there is only one plottable, that is a colormap
63 if (plottables.size() != 1) {
67 if (plottables.size() != 1) {
64 return;
68 return;
65 }
69 }
66
70
67 if (auto colormap = dynamic_cast<QCPColorMap *>(plottables.begin()->second)) {
71 if (auto colormap = dynamic_cast<QCPColorMap *>(plottables.begin()->second)) {
68 colormap->setInterpolate(false); // No value interpolation
72 colormap->setInterpolate(false); // No value interpolation
69 colormap->setTightBoundary(true);
73 colormap->setTightBoundary(true);
70
74
71 // Finds color scale in the colormap's plot to associate with it
75 // Finds color scale in the colormap's plot to associate with it
72 auto plot = colormap->parentPlot();
76 auto plot = colormap->parentPlot();
73 auto plotElements = plot->plotLayout()->elements(false);
77 auto plotElements = plot->plotLayout()->elements(false);
74 for (auto plotElement : plotElements) {
78 for (auto plotElement : plotElements) {
75 if (auto colorScale = dynamic_cast<QCPColorScale *>(plotElement)) {
79 if (auto colorScale = dynamic_cast<QCPColorScale *>(plotElement)) {
76 colormap->setColorScale(colorScale);
80 colormap->setColorScale(colorScale);
77 }
81 }
78 }
82 }
79
83
80 // Sets gradient used for color scale
84 // Sets gradient used for color scale
81 colormap->setGradient(DEFAULT_COLORMAP_GRADIENT);
85 colormap->setGradient(DEFAULT_COLORMAP_GRADIENT);
82 colormap->rescaleDataRange();
86 colormap->rescaleDataRange();
83 }
87 }
88 else {
89 qCCritical(LOG_PlottablesRenderingUtils()) << "Can't get colormap of the spectrogram";
90 }
84 }
91 }
85 };
92 };
86
93
87 /**
94 /**
88 * Default implementation of IPlottablesHelper, which takes data series to set plottables properties
95 * Default implementation of IPlottablesHelper, which takes data series to set plottables properties
89 * @tparam T the data series' type
96 * @tparam T the data series' type
90 */
97 */
91 template <typename T>
98 template <typename T>
92 struct PlottablesHelper : public IPlottablesHelper {
99 struct PlottablesHelper : public IPlottablesHelper {
93 explicit PlottablesHelper(T &dataSeries) : m_DataSeries{dataSeries} {}
100 explicit PlottablesHelper(T &dataSeries) : m_DataSeries{dataSeries} {}
94
101
95 void setProperties(PlottablesMap &plottables) override
102 void setProperties(PlottablesMap &plottables) override
96 {
103 {
97 PlottablesSetter<T>::setProperties(m_DataSeries, plottables);
104 PlottablesSetter<T>::setProperties(m_DataSeries, plottables);
98 }
105 }
99
106
100 T &m_DataSeries;
107 T &m_DataSeries;
101 };
108 };
102
109
103 } // namespace
110 } // namespace
104
111
105 std::unique_ptr<IPlottablesHelper>
112 std::unique_ptr<IPlottablesHelper>
106 IPlottablesHelperFactory::create(std::shared_ptr<IDataSeries> dataSeries) noexcept
113 IPlottablesHelperFactory::create(std::shared_ptr<IDataSeries> dataSeries) noexcept
107 {
114 {
108 if (auto scalarSeries = std::dynamic_pointer_cast<ScalarSeries>(dataSeries)) {
115 if (auto scalarSeries = std::dynamic_pointer_cast<ScalarSeries>(dataSeries)) {
109 return std::make_unique<PlottablesHelper<ScalarSeries> >(*scalarSeries);
116 return std::make_unique<PlottablesHelper<ScalarSeries> >(*scalarSeries);
110 }
117 }
111 else if (auto spectrogramSeries = std::dynamic_pointer_cast<SpectrogramSeries>(dataSeries)) {
118 else if (auto spectrogramSeries = std::dynamic_pointer_cast<SpectrogramSeries>(dataSeries)) {
112 return std::make_unique<PlottablesHelper<SpectrogramSeries> >(*spectrogramSeries);
119 return std::make_unique<PlottablesHelper<SpectrogramSeries> >(*spectrogramSeries);
113 }
120 }
114 else if (auto vectorSeries = std::dynamic_pointer_cast<VectorSeries>(dataSeries)) {
121 else if (auto vectorSeries = std::dynamic_pointer_cast<VectorSeries>(dataSeries)) {
115 return std::make_unique<PlottablesHelper<VectorSeries> >(*vectorSeries);
122 return std::make_unique<PlottablesHelper<VectorSeries> >(*vectorSeries);
116 }
123 }
117 else {
124 else {
118 return std::make_unique<PlottablesHelper<IDataSeries> >(*dataSeries);
125 return std::make_unique<PlottablesHelper<IDataSeries> >(*dataSeries);
119 }
126 }
120 }
127 }
General Comments 1
Under Review
author

Auto status change to "Under Review"

You need to be logged in to leave comments. Login now