##// END OF EJS Templates
Updated meson build defs...
jeandet -
r1437:614fe4639a50
parent child
Show More
@@ -1,1 +1,1
1 Subproject commit 7c86e13f8a6242eb5fe07f0da91a96a4cf68b5bf
1 Subproject commit bf13292f0caf950333841131d023ed7cd96a97a2
@@ -1,168 +1,169
1
1
2 gui_moc_headers = [
2 gui_moc_headers = [
3 './include/Common/VisualizationDef.h',
3 './include/Common/VisualizationDef.h',
4 './include/Common/ColorUtils.h',
4 './include/Common/ColorUtils.h',
5 './include/DragAndDrop/DragDropGuiController.h',
5 './include/DragAndDrop/DragDropGuiController.h',
6 './include/DragAndDrop/DragDropTabSwitcher.h',
6 './include/DragAndDrop/DragDropTabSwitcher.h',
7 './include/DragAndDrop/DragDropScroller.h',
7 './include/DragAndDrop/DragDropScroller.h',
8 './include/Settings/SqpSettingsDialog.h',
8 './include/Settings/SqpSettingsDialog.h',
9 './include/Settings/SqpSettingsGeneralWidget.h',
9 './include/Settings/SqpSettingsGeneralWidget.h',
10 './include/DataSource/DataSourceTreeWidgetHelper.h',
10 './include/DataSource/DataSourceTreeWidgetHelper.h',
11 './include/DataSource/DataSourceTreeWidget.h',
11 './include/DataSource/DataSourceTreeWidget.h',
12 './include/DataSource/DataSourceTreeWidgetItem.h',
12 './include/DataSource/DataSourceTreeWidgetItem.h',
13 './include/DataSource/DataSourceWidget.h',
13 './include/DataSource/DataSourceWidget.h',
14 './include/Catalogue2/repositoriestreeview.h',
14 './include/Catalogue2/repositoriestreeview.h',
15 './include/Catalogue2/browser.h',
15 './include/Catalogue2/browser.h',
16 './include/Catalogue2/eventeditor.h',
16 './include/Catalogue2/eventeditor.h',
17 './include/Catalogue2/eventsmodel.h',
17 './include/Catalogue2/eventsmodel.h',
18 './include/Catalogue2/eventstreeview.h',
18 './include/Catalogue2/eventstreeview.h',
19 './include/Catalogue2/repositoriesmodel.h',
19 './include/Catalogue2/repositoriesmodel.h',
20 './include/TimeWidget/TimeWidget.h',
20 './include/TimeWidget/TimeWidget.h',
21 './include/SqpApplication.h',
21 './include/SqpApplication.h',
22 './include/SidePane/SqpSidePane.h',
22 './include/SidePane/SqpSidePane.h',
23 './include/Variable/RenameVariableDialog.h',
23 './include/Variable/RenameVariableDialog.h',
24 './include/Variable/VariableInspectorWidget.h',
24 './include/Variable/VariableInspectorWidget.h',
25 './include/Variable/VariableInspectorTableView.h',
25 './include/Variable/VariableInspectorTableView.h',
26 './include/Variable/VariableMenuHeaderWidget.h',
26 './include/Variable/VariableMenuHeaderWidget.h',
27 './include/Visualization/VisualizationDragWidget.h',
27 './include/Visualization/VisualizationDragWidget.h',
28 './include/Visualization/VisualizationZoneWidget.h',
28 './include/Visualization/VisualizationZoneWidget.h',
29 './include/Visualization/operations/GenerateVariableMenuOperation.h',
29 './include/Visualization/operations/GenerateVariableMenuOperation.h',
30 './include/Visualization/operations/RescaleAxeOperation.h',
30 './include/Visualization/operations/RescaleAxeOperation.h',
31 './include/Visualization/operations/RemoveVariableOperation.h',
31 './include/Visualization/operations/RemoveVariableOperation.h',
32 './include/Visualization/operations/MenuBuilder.h',
32 './include/Visualization/operations/MenuBuilder.h',
33 './include/Visualization/operations/FindVariableOperation.h',
33 './include/Visualization/operations/FindVariableOperation.h',
34 './include/Visualization/VisualizationDefs.h',
34 './include/Visualization/VisualizationDefs.h',
35 './include/Visualization/IVisualizationWidgetVisitor.h',
35 './include/Visualization/IVisualizationWidgetVisitor.h',
36 './include/Visualization/SqpColorScale.h',
36 './include/Visualization/SqpColorScale.h',
37 './include/Visualization/VisualizationGraphRenderingDelegate.h',
37 './include/Visualization/VisualizationGraphRenderingDelegate.h',
38 './include/Visualization/VisualizationGraphWidget.h',
38 './include/Visualization/VisualizationGraphWidget.h',
39 './include/Visualization/MacScrollBarStyle.h',
39 './include/Visualization/MacScrollBarStyle.h',
40 './include/Visualization/IVisualizationWidget.h',
40 './include/Visualization/IVisualizationWidget.h',
41 './include/Visualization/qcustomplot.h',
41 './include/Visualization/qcustomplot.h',
42 './include/Visualization/IGraphSynchronizer.h',
42 './include/Visualization/IGraphSynchronizer.h',
43 './include/Visualization/QCPColorMapIterator.h',
43 './include/Visualization/QCPColorMapIterator.h',
44 './include/Visualization/VisualizationActionManager.h',
44 './include/Visualization/VisualizationActionManager.h',
45 './include/Visualization/VisualizationTabWidget.h',
45 './include/Visualization/VisualizationTabWidget.h',
46 './include/Visualization/IVariableContainer.h',
46 './include/Visualization/IVariableContainer.h',
47 './include/Visualization/AxisRenderingUtils.h',
47 './include/Visualization/AxisRenderingUtils.h',
48 './include/Visualization/VisualizationMultiZoneSelectionDialog.h',
48 './include/Visualization/VisualizationMultiZoneSelectionDialog.h',
49 './include/Visualization/VisualizationCursorItem.h',
49 './include/Visualization/VisualizationCursorItem.h',
50 './include/Visualization/VisualizationWidget.h',
50 './include/Visualization/VisualizationWidget.h',
51 './include/Visualization/PlottablesRenderingUtils.h',
51 './include/Visualization/PlottablesRenderingUtils.h',
52 './include/Visualization/VisualizationSelectionZoneManager.h',
52 './include/Visualization/VisualizationSelectionZoneManager.h',
53 './include/Visualization/QCustomPlotSynchronizer.h',
53 './include/Visualization/QCustomPlotSynchronizer.h',
54 './include/Visualization/VisualizationSelectionZoneItem.h',
54 './include/Visualization/VisualizationSelectionZoneItem.h',
55 './include/Visualization/VisualizationDragDropContainer.h',
55 './include/Visualization/VisualizationDragDropContainer.h',
56 './include/Visualization/ColorScaleEditor.h',
56 './include/Visualization/ColorScaleEditor.h',
57 './include/Visualization/VisualizationGraphHelper.h',
57 './include/Visualization/VisualizationGraphHelper.h',
58 './include/Actions/ActionsGuiController.h',
58 './include/Actions/ActionsGuiController.h',
59 './include/Actions/FilteringAction.h',
59 './include/Actions/FilteringAction.h',
60 './include/Actions/SelectionZoneAction.h'
60 './include/Actions/SelectionZoneAction.h'
61 ]
61 ]
62
62
63
63 gui_ui_files = [
64 gui_ui_files = [
64 './ui/Settings/SqpSettingsGeneralWidget.ui',
65 './ui/Settings/SqpSettingsGeneralWidget.ui',
65 './ui/Settings/SqpSettingsDialog.ui',
66 './ui/Settings/SqpSettingsDialog.ui',
66 './ui/DataSource/DataSourceWidget.ui',
67 './ui/DataSource/DataSourceWidget.ui',
67 './ui/Catalogue2/browser.ui',
68 './ui/Catalogue2/browser.ui',
68 './ui/Catalogue2/eventeditor.ui',
69 './ui/Catalogue2/eventeditor.ui',
69 './ui/TimeWidget/TimeWidget.ui',
70 './ui/TimeWidget/TimeWidget.ui',
70 './ui/SidePane/SqpSidePane.ui',
71 './ui/SidePane/SqpSidePane.ui',
71 './ui/Variable/RenameVariableDialog.ui',
72 './ui/Variable/RenameVariableDialog.ui',
72 './ui/Variable/VariableInspectorWidget.ui',
73 './ui/Variable/VariableInspectorWidget.ui',
73 './ui/Variable/VariableMenuHeaderWidget.ui',
74 './ui/Variable/VariableMenuHeaderWidget.ui',
74 './ui/Visualization/ColorScaleEditor.ui',
75 './ui/Visualization/ColorScaleEditor.ui',
75 './ui/Visualization/VisualizationZoneWidget.ui',
76 './ui/Visualization/VisualizationZoneWidget.ui',
76 './ui/Visualization/VisualizationMultiZoneSelectionDialog.ui',
77 './ui/Visualization/VisualizationMultiZoneSelectionDialog.ui',
77 './ui/Visualization/VisualizationGraphWidget.ui',
78 './ui/Visualization/VisualizationGraphWidget.ui',
78 './ui/Visualization/VisualizationWidget.ui',
79 './ui/Visualization/VisualizationWidget.ui',
79 './ui/Visualization/VisualizationTabWidget.ui'
80 './ui/Visualization/VisualizationTabWidget.ui'
80 ]
81 ]
81
82
82 gui_qresources = ['resources/sqpguiresources.qrc']
83 gui_qresources = ['resources/sqpguiresources.qrc']
83
84
84 rcc_gen = generator(rcc,
85 rcc_gen = generator(rcc,
85 output : 'qrc_@BASENAME@.cpp',
86 output : 'qrc_@BASENAME@.cpp',
86 arguments : [
87 arguments : [
87 '--output',
88 '--output',
88 '@OUTPUT@',
89 '@OUTPUT@',
89 '@INPUT@',
90 '@INPUT@',
90 '@EXTRA_ARGS@'])
91 '@EXTRA_ARGS@'])
91
92
92 rcc_files = rcc_gen.process(gui_qresources, extra_args : ['-name', 'sqpguiresources'])
93 rcc_files = rcc_gen.process(gui_qresources, extra_args : ['-name', 'sqpguiresources'])
93
94
94 gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers,
95 gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers,
95 ui_files : gui_ui_files)
96 ui_files : gui_ui_files)
96
97
97 gui_sources = [
98 gui_sources = [
98 './src/Common/ColorUtils.cpp',
99 './src/Common/ColorUtils.cpp',
99 './src/Common/VisualizationDef.cpp',
100 './src/Common/VisualizationDef.cpp',
100 './src/SqpApplication.cpp',
101 './src/SqpApplication.cpp',
101 './src/DragAndDrop/DragDropTabSwitcher.cpp',
102 './src/DragAndDrop/DragDropTabSwitcher.cpp',
102 './src/DragAndDrop/DragDropScroller.cpp',
103 './src/DragAndDrop/DragDropScroller.cpp',
103 './src/DragAndDrop/DragDropGuiController.cpp',
104 './src/DragAndDrop/DragDropGuiController.cpp',
104 './src/Settings/SqpSettingsGeneralWidget.cpp',
105 './src/Settings/SqpSettingsGeneralWidget.cpp',
105 './src/Settings/SqpSettingsDialog.cpp',
106 './src/Settings/SqpSettingsDialog.cpp',
106 './src/DataSource/DataSourceTreeWidgetItem.cpp',
107 './src/DataSource/DataSourceTreeWidgetItem.cpp',
107 './src/DataSource/DataSourceTreeWidgetHelper.cpp',
108 './src/DataSource/DataSourceTreeWidgetHelper.cpp',
108 './src/DataSource/DataSourceWidget.cpp',
109 './src/DataSource/DataSourceWidget.cpp',
109 './src/DataSource/DataSourceTreeWidget.cpp',
110 './src/DataSource/DataSourceTreeWidget.cpp',
110 './src/Catalogue2/eventstreeview.cpp',
111 './src/Catalogue2/eventstreeview.cpp',
111 './src/Catalogue2/eventeditor.cpp',
112 './src/Catalogue2/eventeditor.cpp',
112 './src/Catalogue2/repositoriestreeview.cpp',
113 './src/Catalogue2/repositoriestreeview.cpp',
113 './src/Catalogue2/browser.cpp',
114 './src/Catalogue2/browser.cpp',
114 './src/Catalogue2/eventsmodel.cpp',
115 './src/Catalogue2/eventsmodel.cpp',
115 './src/Catalogue2/repositoriesmodel.cpp',
116 './src/Catalogue2/repositoriesmodel.cpp',
116 './src/TimeWidget/TimeWidget.cpp',
117 './src/TimeWidget/TimeWidget.cpp',
117 './src/SidePane/SqpSidePane.cpp',
118 './src/SidePane/SqpSidePane.cpp',
118 './src/Variable/VariableInspectorTableView.cpp',
119 './src/Variable/VariableInspectorTableView.cpp',
119 './src/Variable/VariableInspectorWidget.cpp',
120 './src/Variable/VariableInspectorWidget.cpp',
120 './src/Variable/RenameVariableDialog.cpp',
121 './src/Variable/RenameVariableDialog.cpp',
121 './src/Variable/VariableMenuHeaderWidget.cpp',
122 './src/Variable/VariableMenuHeaderWidget.cpp',
122 './src/Visualization/VisualizationGraphWidget.cpp',
123 './src/Visualization/VisualizationGraphWidget.cpp',
123 './src/Visualization/PlottablesRenderingUtils.cpp',
124 './src/Visualization/PlottablesRenderingUtils.cpp',
124 './src/Visualization/AxisRenderingUtils.cpp',
125 './src/Visualization/AxisRenderingUtils.cpp',
125 './src/Visualization/VisualizationWidget.cpp',
126 './src/Visualization/VisualizationWidget.cpp',
126 './src/Visualization/qcustomplot.cpp',
127 './src/Visualization/qcustomplot.cpp',
127 './src/Visualization/VisualizationDragWidget.cpp',
128 './src/Visualization/VisualizationDragWidget.cpp',
128 './src/Visualization/VisualizationActionManager.cpp',
129 './src/Visualization/VisualizationActionManager.cpp',
129 './src/Visualization/MacScrollBarStyle.cpp',
130 './src/Visualization/MacScrollBarStyle.cpp',
130 './src/Visualization/VisualizationSelectionZoneManager.cpp',
131 './src/Visualization/VisualizationSelectionZoneManager.cpp',
131 './src/Visualization/operations/FindVariableOperation.cpp',
132 './src/Visualization/operations/FindVariableOperation.cpp',
132 './src/Visualization/operations/RescaleAxeOperation.cpp',
133 './src/Visualization/operations/RescaleAxeOperation.cpp',
133 './src/Visualization/operations/MenuBuilder.cpp',
134 './src/Visualization/operations/MenuBuilder.cpp',
134 './src/Visualization/operations/GenerateVariableMenuOperation.cpp',
135 './src/Visualization/operations/GenerateVariableMenuOperation.cpp',
135 './src/Visualization/operations/RemoveVariableOperation.cpp',
136 './src/Visualization/operations/RemoveVariableOperation.cpp',
136 './src/Visualization/VisualizationSelectionZoneItem.cpp',
137 './src/Visualization/VisualizationSelectionZoneItem.cpp',
137 './src/Visualization/VisualizationCursorItem.cpp',
138 './src/Visualization/VisualizationCursorItem.cpp',
138 './src/Visualization/QCPColorMapIterator.cpp',
139 './src/Visualization/QCPColorMapIterator.cpp',
139 './src/Visualization/QCustomPlotSynchronizer.cpp',
140 './src/Visualization/QCustomPlotSynchronizer.cpp',
140 './src/Visualization/ColorScaleEditor.cpp',
141 './src/Visualization/ColorScaleEditor.cpp',
141 './src/Visualization/VisualizationMultiZoneSelectionDialog.cpp',
142 './src/Visualization/VisualizationMultiZoneSelectionDialog.cpp',
142 './src/Visualization/VisualizationTabWidget.cpp',
143 './src/Visualization/VisualizationTabWidget.cpp',
143 './src/Visualization/VisualizationGraphHelper.cpp',
144 './src/Visualization/VisualizationGraphHelper.cpp',
144 './src/Visualization/VisualizationGraphRenderingDelegate.cpp',
145 './src/Visualization/VisualizationGraphRenderingDelegate.cpp',
145 './src/Visualization/VisualizationDragDropContainer.cpp',
146 './src/Visualization/VisualizationDragDropContainer.cpp',
146 './src/Visualization/VisualizationZoneWidget.cpp',
147 './src/Visualization/VisualizationZoneWidget.cpp',
147 './src/Visualization/SqpColorScale.cpp',
148 './src/Visualization/SqpColorScale.cpp',
148 './src/Actions/FilteringAction.cpp',
149 './src/Actions/FilteringAction.cpp',
149 './src/Actions/SelectionZoneAction.cpp',
150 './src/Actions/SelectionZoneAction.cpp',
150 './src/Actions/ActionsGuiController.cpp',
151 './src/Actions/ActionsGuiController.cpp'
151 ]
152 ]
152
153
153 gui_inc = include_directories(['include', 'include/Visualization'])
154 gui_inc = include_directories(['include', 'include/Visualization'])
154
155
155 sciqlop_gui_lib = library('sciqlopgui',
156 sciqlop_gui_lib = library('sciqlopgui',
156 gui_sources,
157 gui_sources,
157 gui_moc_files,
158 gui_moc_files,
158 rcc_files,
159 rcc_files,
159 include_directories : [gui_inc],
160 include_directories : [gui_inc],
160 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core],
161 dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core],
161 install : true
162 install : true
162 )
163 )
163
164
164 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
165 sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib,
165 include_directories : gui_inc,
166 include_directories : gui_inc,
166 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core])
167 dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core])
167
168
168
169
@@ -1,524 +1,523
1 #include "Visualization/VisualizationGraphHelper.h"
1 #include "Visualization/VisualizationGraphHelper.h"
2 #include "Visualization/qcustomplot.h"
2 #include "Visualization/qcustomplot.h"
3
3
4 #include <Data/ScalarTimeSerie.h>
4 #include <Data/ScalarTimeSerie.h>
5 #include <Data/SpectrogramTimeSerie.h>
5 #include <Data/SpectrogramTimeSerie.h>
6 #include <Data/VectorTimeSerie.h>
6 #include <Data/VectorTimeSerie.h>
7
7
8 #include <Variable/Variable2.h>
8 #include <Variable/Variable2.h>
9
9
10 Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper")
10 Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper")
11
11
12 namespace
12 namespace
13 {
13 {
14
14
15 class SqpDataContainer : public QCPGraphDataContainer
15 class SqpDataContainer : public QCPGraphDataContainer
16 {
16 {
17 public:
17 public:
18 void appendGraphData(const QCPGraphData& data) { mData.append(data); }
18 void appendGraphData(const QCPGraphData& data) { mData.append(data); }
19 };
19 };
20
20
21 /**
21 /**
22 * Struct used to create plottables, depending on the type of the data series from which to create
22 * Struct used to create plottables, depending on the type of the data series from which to create
23 * them
23 * them
24 * @tparam T the data series' type
24 * @tparam T the data series' type
25 * @remarks Default implementation can't create plottables
25 * @remarks Default implementation can't create plottables
26 */
26 */
27 template <typename T, typename Enabled = void>
27 template <typename T, typename Enabled = void>
28 struct PlottablesCreator
28 struct PlottablesCreator
29 {
29 {
30 static PlottablesMap createPlottables(QCustomPlot&, const std::shared_ptr<T>& dataSeries)
30 static PlottablesMap createPlottables(QCustomPlot&, const std::shared_ptr<T>& dataSeries)
31 {
31 {
32 return {};
32 return {};
33 }
33 }
34 };
34 };
35
35
36 PlottablesMap createGraphs(QCustomPlot& plot, int nbGraphs)
36 PlottablesMap createGraphs(QCustomPlot& plot, int nbGraphs)
37 {
37 {
38 PlottablesMap result {};
38 PlottablesMap result {};
39
39
40 // Creates {nbGraphs} QCPGraph to add to the plot
40 // Creates {nbGraphs} QCPGraph to add to the plot
41 for (auto i = 0; i < nbGraphs; ++i)
41 for (auto i = 0; i < nbGraphs; ++i)
42 {
42 {
43 auto graph = plot.addGraph();
43 auto graph = plot.addGraph();
44 result.insert({ i, graph });
44 result.insert({ i, graph });
45 }
45 }
46
46
47 plot.replot();
47 plot.replot();
48
48
49 return result;
49 return result;
50 }
50 }
51
51
52 /**
52 /**
53 * Specialization of PlottablesCreator for scalars
53 * Specialization of PlottablesCreator for scalars
54 * @sa ScalarSeries
54 * @sa ScalarSeries
55 */
55 */
56 template <typename T>
56 template <typename T>
57 struct PlottablesCreator<T, typename std::enable_if_t<std::is_base_of<ScalarTimeSerie, T>::value>>
57 struct PlottablesCreator<T, typename std::enable_if_t<std::is_base_of<ScalarTimeSerie, T>::value>>
58 {
58 {
59 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
59 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
60 {
60 {
61 return createGraphs(plot, 1);
61 return createGraphs(plot, 1);
62 }
62 }
63 };
63 };
64
64
65 /**
65 /**
66 * Specialization of PlottablesCreator for vectors
66 * Specialization of PlottablesCreator for vectors
67 * @sa VectorSeries
67 * @sa VectorSeries
68 */
68 */
69 template <typename T>
69 template <typename T>
70 struct PlottablesCreator<T, typename std::enable_if_t<std::is_base_of<VectorTimeSerie, T>::value>>
70 struct PlottablesCreator<T, typename std::enable_if_t<std::is_base_of<VectorTimeSerie, T>::value>>
71 {
71 {
72 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
72 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
73 {
73 {
74 return createGraphs(plot, 3);
74 return createGraphs(plot, 3);
75 }
75 }
76 };
76 };
77
77
78 /**
78 /**
79 * Specialization of PlottablesCreator for MultiComponentTimeSeries
79 * Specialization of PlottablesCreator for MultiComponentTimeSeries
80 * @sa VectorSeries
80 * @sa VectorSeries
81 */
81 */
82 template <typename T>
82 template <typename T>
83 struct PlottablesCreator<T,
83 struct PlottablesCreator<T,
84 typename std::enable_if_t<std::is_base_of<MultiComponentTimeSerie, T>::value>>
84 typename std::enable_if_t<std::is_base_of<MultiComponentTimeSerie, T>::value>>
85 {
85 {
86 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
86 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
87 {
87 {
88 return createGraphs(plot, dataSeries->size(1));
88 return createGraphs(plot, dataSeries->size(1));
89 }
89 }
90 };
90 };
91
91
92 /**
92 /**
93 * Specialization of PlottablesCreator for spectrograms
93 * Specialization of PlottablesCreator for spectrograms
94 * @sa SpectrogramSeries
94 * @sa SpectrogramSeries
95 */
95 */
96 template <typename T>
96 template <typename T>
97 struct PlottablesCreator<T,
97 struct PlottablesCreator<T,
98 typename std::enable_if_t<std::is_base_of<SpectrogramTimeSerie, T>::value>>
98 typename std::enable_if_t<std::is_base_of<SpectrogramTimeSerie, T>::value>>
99 {
99 {
100 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
100 static PlottablesMap createPlottables(QCustomPlot& plot, const std::shared_ptr<T>& dataSeries)
101 {
101 {
102 PlottablesMap result {};
102 PlottablesMap result {};
103 result.insert({ 0, new QCPColorMap { plot.xAxis, plot.yAxis } });
103 result.insert({ 0, new QCPColorMap { plot.xAxis, plot.yAxis } });
104
104
105 plot.replot();
105 plot.replot();
106
106
107 return result;
107 return result;
108 }
108 }
109 };
109 };
110
110
111 /**
111 /**
112 * Struct used to update plottables, depending on the type of the data series from which to update
112 * Struct used to update plottables, depending on the type of the data series from which to update
113 * them
113 * them
114 * @tparam T the data series' type
114 * @tparam T the data series' type
115 * @remarks Default implementation can't update plottables
115 * @remarks Default implementation can't update plottables
116 */
116 */
117 template <typename T, typename Enabled = void>
117 template <typename T, typename Enabled = void>
118 struct PlottablesUpdater
118 struct PlottablesUpdater
119 {
119 {
120 static void setPlotYAxisRange(T&, const DateTimeRange&, QCustomPlot&)
120 static void setPlotYAxisRange(T&, const DateTimeRange&, QCustomPlot&)
121 {
121 {
122 qCCritical(LOG_VisualizationGraphHelper())
122 qCCritical(LOG_VisualizationGraphHelper())
123 << QObject::tr("Can't set plot y-axis range: unmanaged data series type");
123 << QObject::tr("Can't set plot y-axis range: unmanaged data series type");
124 }
124 }
125
125
126 static void updatePlottables(T&, PlottablesMap&, const DateTimeRange&, bool)
126 static void updatePlottables(T&, PlottablesMap&, const DateTimeRange&, bool)
127 {
127 {
128 qCCritical(LOG_VisualizationGraphHelper())
128 qCCritical(LOG_VisualizationGraphHelper())
129 << QObject::tr("Can't update plottables: unmanaged data series type");
129 << QObject::tr("Can't update plottables: unmanaged data series type");
130 }
130 }
131 };
131 };
132
132
133 /**
133 /**
134 * Specialization of PlottablesUpdater for scalars and vectors
134 * Specialization of PlottablesUpdater for scalars and vectors
135 * @sa ScalarSeries
135 * @sa ScalarSeries
136 * @sa VectorSeries
136 * @sa VectorSeries
137 */
137 */
138 template <typename T>
138 template <typename T>
139 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<ScalarTimeSerie, T>::value>>
139 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<ScalarTimeSerie, T>::value>>
140 {
140 {
141 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
141 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
142 {
142 {
143 auto minValue = 0., maxValue = 0.;
143 auto minValue = 0., maxValue = 0.;
144 if (auto serie = dynamic_cast<ScalarTimeSerie*>(&dataSeries))
144 if (auto serie = dynamic_cast<ScalarTimeSerie*>(&dataSeries))
145 {
145 {
146 if (serie->size())
146 if (serie->size())
147 {
147 {
148 maxValue = (*std::max_element(std::begin(*serie), std::end(*serie))).v();
148 maxValue = (*std::max_element(std::begin(*serie), std::end(*serie))).v();
149 minValue = (*std::min_element(std::begin(*serie), std::end(*serie))).v();
149 minValue = (*std::min_element(std::begin(*serie), std::end(*serie))).v();
150 }
150 }
151 }
151 }
152 plot.yAxis->setRange(QCPRange { minValue, maxValue });
152 plot.yAxis->setRange(QCPRange { minValue, maxValue });
153 }
153 }
154
154
155 static void updatePlottables(
155 static void updatePlottables(
156 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
156 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
157 {
157 {
158
158
159 // For each plottable to update, resets its data
159 // For each plottable to update, resets its data
160 for (const auto& plottable : plottables)
160 for (const auto& plottable : plottables)
161 {
161 {
162 if (auto graph = dynamic_cast<QCPGraph*>(plottable.second))
162 if (auto graph = dynamic_cast<QCPGraph*>(plottable.second))
163 {
163 {
164 auto dataContainer = QSharedPointer<SqpDataContainer>::create();
164 auto dataContainer = QSharedPointer<SqpDataContainer>::create();
165 if (auto serie = dynamic_cast<ScalarTimeSerie*>(&dataSeries))
165 if (auto serie = dynamic_cast<ScalarTimeSerie*>(&dataSeries))
166 {
166 {
167 std::for_each(
167 std::for_each(
168 std::begin(*serie), std::end(*serie), [&dataContainer](const auto& value) {
168 std::begin(*serie), std::end(*serie), [&dataContainer](const auto& value) {
169 dataContainer->appendGraphData(QCPGraphData(value.t(), value.v()));
169 dataContainer->appendGraphData(QCPGraphData(value.t(), value.v()));
170 });
170 });
171 }
171 }
172 graph->setData(dataContainer);
172 graph->setData(dataContainer);
173 }
173 }
174 }
174 }
175
175
176 if (!plottables.empty())
176 if (!plottables.empty())
177 {
177 {
178 auto plot = plottables.begin()->second->parentPlot();
178 auto plot = plottables.begin()->second->parentPlot();
179
179
180 if (rescaleAxes)
180 if (rescaleAxes)
181 {
181 {
182 plot->rescaleAxes();
182 plot->rescaleAxes();
183 }
183 }
184 }
184 }
185 }
185 }
186 };
186 };
187
187
188
188
189 template <typename T>
189 template <typename T>
190 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<VectorTimeSerie, T>::value>>
190 struct PlottablesUpdater<T, typename std::enable_if_t<std::is_base_of<VectorTimeSerie, T>::value>>
191 {
191 {
192 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
192 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
193 {
193 {
194 double minValue = 0., maxValue = 0.;
194 double minValue = 0., maxValue = 0.;
195 if (auto serie = dynamic_cast<VectorTimeSerie*>(&dataSeries))
195 if (auto serie = dynamic_cast<VectorTimeSerie*>(&dataSeries))
196 {
196 {
197 std::for_each(
197 std::for_each(
198 std::begin(*serie), std::end(*serie), [&minValue, &maxValue](const auto& v) {
198 std::begin(*serie), std::end(*serie), [&minValue, &maxValue](const auto& v) {
199 minValue = std::min({ minValue, v.v().x, v.v().y, v.v().z });
199 minValue = std::min({ minValue, v.v().x, v.v().y, v.v().z });
200 maxValue = std::max({ maxValue, v.v().x, v.v().y, v.v().z });
200 maxValue = std::max({ maxValue, v.v().x, v.v().y, v.v().z });
201 });
201 });
202 }
202 }
203
203
204 plot.yAxis->setRange(QCPRange { minValue, maxValue });
204 plot.yAxis->setRange(QCPRange { minValue, maxValue });
205 }
205 }
206
206
207 static void updatePlottables(
207 static void updatePlottables(
208 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
208 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
209 {
209 {
210
210
211 // For each plottable to update, resets its data
211 // For each plottable to update, resets its data
212 for (const auto& plottable : plottables)
212 for (const auto& plottable : plottables)
213 {
213 {
214 if (auto graph = dynamic_cast<QCPGraph*>(plottable.second))
214 if (auto graph = dynamic_cast<QCPGraph*>(plottable.second))
215 {
215 {
216 auto dataContainer = QSharedPointer<SqpDataContainer>::create();
216 auto dataContainer = QSharedPointer<SqpDataContainer>::create();
217 if (auto serie = dynamic_cast<VectorTimeSerie*>(&dataSeries))
217 if (auto serie = dynamic_cast<VectorTimeSerie*>(&dataSeries))
218 {
218 {
219 switch (plottable.first)
219 switch (plottable.first)
220 {
220 {
221 case 0:
221 case 0:
222 std::for_each(std::begin(*serie), std::end(*serie),
222 std::for_each(std::begin(*serie), std::end(*serie),
223 [&dataContainer](const auto& value) {
223 [&dataContainer](const auto& value) {
224 dataContainer->appendGraphData(
224 dataContainer->appendGraphData(
225 QCPGraphData(value.t(), value.v().x));
225 QCPGraphData(value.t(), value.v().x));
226 });
226 });
227 break;
227 break;
228 case 1:
228 case 1:
229 std::for_each(std::begin(*serie), std::end(*serie),
229 std::for_each(std::begin(*serie), std::end(*serie),
230 [&dataContainer](const auto& value) {
230 [&dataContainer](const auto& value) {
231 dataContainer->appendGraphData(
231 dataContainer->appendGraphData(
232 QCPGraphData(value.t(), value.v().y));
232 QCPGraphData(value.t(), value.v().y));
233 });
233 });
234 break;
234 break;
235 case 2:
235 case 2:
236 std::for_each(std::begin(*serie), std::end(*serie),
236 std::for_each(std::begin(*serie), std::end(*serie),
237 [&dataContainer](const auto& value) {
237 [&dataContainer](const auto& value) {
238 dataContainer->appendGraphData(
238 dataContainer->appendGraphData(
239 QCPGraphData(value.t(), value.v().z));
239 QCPGraphData(value.t(), value.v().z));
240 });
240 });
241 break;
241 break;
242 default:
242 default:
243 break;
243 break;
244 }
244 }
245 }
245 }
246 graph->setData(dataContainer);
246 graph->setData(dataContainer);
247 }
247 }
248 }
248 }
249
249
250 if (!plottables.empty())
250 if (!plottables.empty())
251 {
251 {
252 auto plot = plottables.begin()->second->parentPlot();
252 auto plot = plottables.begin()->second->parentPlot();
253
253
254 if (rescaleAxes)
254 if (rescaleAxes)
255 {
255 {
256 plot->rescaleAxes();
256 plot->rescaleAxes();
257 }
257 }
258 }
258 }
259 }
259 }
260 };
260 };
261
261
262
262
263 template <typename T>
263 template <typename T>
264 struct PlottablesUpdater<T,
264 struct PlottablesUpdater<T,
265 typename std::enable_if_t<std::is_base_of<MultiComponentTimeSerie, T>::value>>
265 typename std::enable_if_t<std::is_base_of<MultiComponentTimeSerie, T>::value>>
266 {
266 {
267 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
267 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
268 {
268 {
269 double minValue = 0., maxValue = 0.;
269 double minValue = 0., maxValue = 0.;
270 if (auto serie = dynamic_cast<MultiComponentTimeSerie*>(&dataSeries))
270 if (auto serie = dynamic_cast<MultiComponentTimeSerie*>(&dataSeries))
271 {
271 {
272 std::for_each(
272 std::for_each(
273 std::begin(*serie), std::end(*serie), [&minValue, &maxValue](const auto& v) {
273 std::begin(*serie), std::end(*serie), [&minValue, &maxValue](const auto& v) {
274 minValue = std::min( minValue, std::min_element(v.begin(), v.end())->v() );
274 minValue = std::min( minValue, std::min_element(v.begin(), v.end())->v() );
275 maxValue = std::max( maxValue, std::max_element(v.begin(), v.end())->v() );
275 maxValue = std::max( maxValue, std::max_element(v.begin(), v.end())->v() );
276 });
276 });
277 }
277 }
278
279 plot.yAxis->setRange(QCPRange { minValue, maxValue });
278 plot.yAxis->setRange(QCPRange { minValue, maxValue });
280 }
279 }
281
280
282 static void updatePlottables(
281 static void updatePlottables(
283 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
282 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
284 {
283 {
285 for (const auto& plottable : plottables)
284 for (const auto& plottable : plottables)
286 {
285 {
287 if (auto graph = dynamic_cast<QCPGraph*>(plottable.second))
286 if (auto graph = dynamic_cast<QCPGraph*>(plottable.second))
288 {
287 {
289 auto dataContainer = QSharedPointer<SqpDataContainer>::create();
288 auto dataContainer = QSharedPointer<SqpDataContainer>::create();
290 if (auto serie = dynamic_cast<MultiComponentTimeSerie*>(&dataSeries))
289 if (auto serie = dynamic_cast<MultiComponentTimeSerie*>(&dataSeries))
291 {
290 {
292 // TODO
291 // TODO
293 std::for_each(std::begin(*serie), std::end(*serie),
292 std::for_each(std::begin(*serie), std::end(*serie),
294 [&dataContainer, component = plottable.first](const auto& value) {
293 [&dataContainer, component = plottable.first](const auto& value) {
295 dataContainer->appendGraphData(
294 dataContainer->appendGraphData(
296 QCPGraphData(value.t(), value[component]));
295 QCPGraphData(value.t(), value[component]));
297 });
296 });
298 }
297 }
299 graph->setData(dataContainer);
298 graph->setData(dataContainer);
300 }
299 }
301 }
300 }
302
301
303 if (!plottables.empty())
302 if (!plottables.empty())
304 {
303 {
305 auto plot = plottables.begin()->second->parentPlot();
304 auto plot = plottables.begin()->second->parentPlot();
306
305
307 if (rescaleAxes)
306 if (rescaleAxes)
308 {
307 {
309 plot->rescaleAxes();
308 plot->rescaleAxes();
310 }
309 }
311 }
310 }
312 }
311 }
313 };
312 };
314
313
315 /**
314 /**
316 * Specialization of PlottablesUpdater for spectrograms
315 * Specialization of PlottablesUpdater for spectrograms
317 * @sa SpectrogramSeries
316 * @sa SpectrogramSeries
318 */
317 */
319 template <typename T>
318 template <typename T>
320 struct PlottablesUpdater<T,
319 struct PlottablesUpdater<T,
321 typename std::enable_if_t<std::is_base_of<SpectrogramTimeSerie, T>::value>>
320 typename std::enable_if_t<std::is_base_of<SpectrogramTimeSerie, T>::value>>
322 {
321 {
323 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
322 static void setPlotYAxisRange(T& dataSeries, const DateTimeRange& xAxisRange, QCustomPlot& plot)
324 {
323 {
325 // TODO
324 // TODO
326 // double min, max;
325 // double min, max;
327 // std::tie(min, max) = dataSeries.yBounds();
326 // std::tie(min, max) = dataSeries.yBounds();
328
327
329 // if (!std::isnan(min) && !std::isnan(max))
328 // if (!std::isnan(min) && !std::isnan(max))
330 // {
329 // {
331 // plot.yAxis->setRange(QCPRange { min, max });
330 // plot.yAxis->setRange(QCPRange { min, max });
332 // }
331 // }
333 }
332 }
334
333
335 static void updatePlottables(
334 static void updatePlottables(
336 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
335 T& dataSeries, PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes)
337 {
336 {
338 // TODO
337 // TODO
339 // if (plottables.empty())
338 // if (plottables.empty())
340 // {
339 // {
341 // qCDebug(LOG_VisualizationGraphHelper())
340 // qCDebug(LOG_VisualizationGraphHelper())
342 // << QObject::tr("Can't update spectrogram: no colormap has been
341 // << QObject::tr("Can't update spectrogram: no colormap has been
343 // associated");
342 // associated");
344 // return;
343 // return;
345 // }
344 // }
346
345
347 // // Gets the colormap to update (normally there is only one colormap)
346 // // Gets the colormap to update (normally there is only one colormap)
348 // Q_ASSERT(plottables.size() == 1);
347 // Q_ASSERT(plottables.size() == 1);
349 // auto colormap = dynamic_cast<QCPColorMap*>(plottables.at(0));
348 // auto colormap = dynamic_cast<QCPColorMap*>(plottables.at(0));
350 // Q_ASSERT(colormap != nullptr);
349 // Q_ASSERT(colormap != nullptr);
351
350
352 // dataSeries.lockRead();
351 // dataSeries.lockRead();
353
352
354 // // Processing spectrogram data for display in QCustomPlot
353 // // Processing spectrogram data for display in QCustomPlot
355 // auto its = dataSeries.xAxisRange(range.m_TStart, range.m_TEnd);
354 // auto its = dataSeries.xAxisRange(range.m_TStart, range.m_TEnd);
356
355
357 // // Computes logarithmic y-axis resolution for the spectrogram
356 // // Computes logarithmic y-axis resolution for the spectrogram
358 // auto yData = its.first->y();
357 // auto yData = its.first->y();
359 // auto yResolution = DataSeriesUtils::resolution(yData.begin(), yData.end(), true);
358 // auto yResolution = DataSeriesUtils::resolution(yData.begin(), yData.end(), true);
360
359
361 // // Generates mesh for colormap
360 // // Generates mesh for colormap
362 // auto mesh = DataSeriesUtils::regularMesh(its.first, its.second,
361 // auto mesh = DataSeriesUtils::regularMesh(its.first, its.second,
363 // DataSeriesUtils::Resolution { dataSeries.xResolution() }, yResolution);
362 // DataSeriesUtils::Resolution { dataSeries.xResolution() }, yResolution);
364
363
365 // dataSeries.unlock();
364 // dataSeries.unlock();
366
365
367 // colormap->data()->setSize(mesh.m_NbX, mesh.m_NbY);
366 // colormap->data()->setSize(mesh.m_NbX, mesh.m_NbY);
368 // if (!mesh.isEmpty())
367 // if (!mesh.isEmpty())
369 // {
368 // {
370 // colormap->data()->setRange(QCPRange { mesh.m_XMin, mesh.xMax() },
369 // colormap->data()->setRange(QCPRange { mesh.m_XMin, mesh.xMax() },
371 // // y-axis range is converted to linear values
370 // // y-axis range is converted to linear values
372 // QCPRange { std::pow(10, mesh.m_YMin), std::pow(10, mesh.yMax()) });
371 // QCPRange { std::pow(10, mesh.m_YMin), std::pow(10, mesh.yMax()) });
373
372
374 // // Sets values
373 // // Sets values
375 // auto index = 0;
374 // auto index = 0;
376 // for (auto it = mesh.m_Data.begin(), end = mesh.m_Data.end(); it != end; ++it,
375 // for (auto it = mesh.m_Data.begin(), end = mesh.m_Data.end(); it != end; ++it,
377 // ++index)
376 // ++index)
378 // {
377 // {
379 // auto xIndex = index % mesh.m_NbX;
378 // auto xIndex = index % mesh.m_NbX;
380 // auto yIndex = index / mesh.m_NbX;
379 // auto yIndex = index / mesh.m_NbX;
381
380
382 // colormap->data()->setCell(xIndex, yIndex, *it);
381 // colormap->data()->setCell(xIndex, yIndex, *it);
383
382
384 // // Makes the NaN values to be transparent in the colormap
383 // // Makes the NaN values to be transparent in the colormap
385 // if (std::isnan(*it))
384 // if (std::isnan(*it))
386 // {
385 // {
387 // colormap->data()->setAlpha(xIndex, yIndex, 0);
386 // colormap->data()->setAlpha(xIndex, yIndex, 0);
388 // }
387 // }
389 // }
388 // }
390 // }
389 // }
391
390
392 // // Rescales axes
391 // // Rescales axes
393 // auto plot = colormap->parentPlot();
392 // auto plot = colormap->parentPlot();
394
393
395 // if (rescaleAxes)
394 // if (rescaleAxes)
396 // {
395 // {
397 // plot->rescaleAxes();
396 // plot->rescaleAxes();
398 // }
397 // }
399 }
398 }
400 };
399 };
401
400
402 /**
401 /**
403 * Helper used to create/update plottables
402 * Helper used to create/update plottables
404 */
403 */
405 struct IPlottablesHelper
404 struct IPlottablesHelper
406 {
405 {
407 virtual ~IPlottablesHelper() noexcept = default;
406 virtual ~IPlottablesHelper() noexcept = default;
408 virtual PlottablesMap create(QCustomPlot& plot) const = 0;
407 virtual PlottablesMap create(QCustomPlot& plot) const = 0;
409 virtual void setYAxisRange(const DateTimeRange& xAxisRange, QCustomPlot& plot) const = 0;
408 virtual void setYAxisRange(const DateTimeRange& xAxisRange, QCustomPlot& plot) const = 0;
410 virtual void update(
409 virtual void update(
411 PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes = false) const = 0;
410 PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes = false) const = 0;
412 };
411 };
413
412
414 /**
413 /**
415 * Default implementation of IPlottablesHelper, which takes data series to create/update plottables
414 * Default implementation of IPlottablesHelper, which takes data series to create/update plottables
416 * @tparam T the data series' type
415 * @tparam T the data series' type
417 */
416 */
418 template <typename T>
417 template <typename T>
419 struct PlottablesHelper : public IPlottablesHelper
418 struct PlottablesHelper : public IPlottablesHelper
420 {
419 {
421 explicit PlottablesHelper(std::shared_ptr<T> dataSeries) : m_DataSeries { dataSeries } {}
420 explicit PlottablesHelper(std::shared_ptr<T> dataSeries) : m_DataSeries { dataSeries } {}
422
421
423 PlottablesMap create(QCustomPlot& plot) const override
422 PlottablesMap create(QCustomPlot& plot) const override
424 {
423 {
425 return PlottablesCreator<T>::createPlottables(plot, m_DataSeries);
424 return PlottablesCreator<T>::createPlottables(plot, m_DataSeries);
426 }
425 }
427
426
428 void update(
427 void update(
429 PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes) const override
428 PlottablesMap& plottables, const DateTimeRange& range, bool rescaleAxes) const override
430 {
429 {
431 if (m_DataSeries)
430 if (m_DataSeries)
432 {
431 {
433 PlottablesUpdater<T>::updatePlottables(*m_DataSeries, plottables, range, rescaleAxes);
432 PlottablesUpdater<T>::updatePlottables(*m_DataSeries, plottables, range, rescaleAxes);
434 }
433 }
435 else
434 else
436 {
435 {
437 qCCritical(LOG_VisualizationGraphHelper()) << "Can't update plottables: inconsistency "
436 qCCritical(LOG_VisualizationGraphHelper()) << "Can't update plottables: inconsistency "
438 "between the type of data series and the "
437 "between the type of data series and the "
439 "type supposed";
438 "type supposed";
440 }
439 }
441 }
440 }
442
441
443 void setYAxisRange(const DateTimeRange& xAxisRange, QCustomPlot& plot) const override
442 void setYAxisRange(const DateTimeRange& xAxisRange, QCustomPlot& plot) const override
444 {
443 {
445 if (m_DataSeries)
444 if (m_DataSeries)
446 {
445 {
447 PlottablesUpdater<T>::setPlotYAxisRange(*m_DataSeries, xAxisRange, plot);
446 PlottablesUpdater<T>::setPlotYAxisRange(*m_DataSeries, xAxisRange, plot);
448 }
447 }
449 else
448 else
450 {
449 {
451 qCCritical(LOG_VisualizationGraphHelper()) << "Can't update plottables: inconsistency "
450 qCCritical(LOG_VisualizationGraphHelper()) << "Can't update plottables: inconsistency "
452 "between the type of data series and the "
451 "between the type of data series and the "
453 "type supposed";
452 "type supposed";
454 }
453 }
455 }
454 }
456
455
457 std::shared_ptr<T> m_DataSeries;
456 std::shared_ptr<T> m_DataSeries;
458 };
457 };
459
458
460 /// Creates IPlottablesHelper according to the type of data series a variable holds
459 /// Creates IPlottablesHelper according to the type of data series a variable holds
461 std::unique_ptr<IPlottablesHelper> createHelper(std::shared_ptr<Variable2> variable) noexcept
460 std::unique_ptr<IPlottablesHelper> createHelper(std::shared_ptr<Variable2> variable) noexcept
462 {
461 {
463 switch (variable->type())
462 switch (variable->type())
464 {
463 {
465 case DataSeriesType::SCALAR:
464 case DataSeriesType::SCALAR:
466 return std::make_unique<PlottablesHelper<ScalarTimeSerie>>(
465 return std::make_unique<PlottablesHelper<ScalarTimeSerie>>(
467 std::dynamic_pointer_cast<ScalarTimeSerie>(variable->data()));
466 std::dynamic_pointer_cast<ScalarTimeSerie>(variable->data()));
468 case DataSeriesType::SPECTROGRAM:
467 case DataSeriesType::SPECTROGRAM:
469 return std::make_unique<PlottablesHelper<SpectrogramTimeSerie>>(
468 return std::make_unique<PlottablesHelper<SpectrogramTimeSerie>>(
470 std::dynamic_pointer_cast<SpectrogramTimeSerie>(variable->data()));
469 std::dynamic_pointer_cast<SpectrogramTimeSerie>(variable->data()));
471 case DataSeriesType::VECTOR:
470 case DataSeriesType::VECTOR:
472 return std::make_unique<PlottablesHelper<VectorTimeSerie>>(
471 return std::make_unique<PlottablesHelper<VectorTimeSerie>>(
473 std::dynamic_pointer_cast<VectorTimeSerie>(variable->data()));
472 std::dynamic_pointer_cast<VectorTimeSerie>(variable->data()));
474 case DataSeriesType::MULTICOMPONENT:
473 case DataSeriesType::MULTICOMPONENT:
475 return std::make_unique<PlottablesHelper<MultiComponentTimeSerie>>(
474 return std::make_unique<PlottablesHelper<MultiComponentTimeSerie>>(
476 std::dynamic_pointer_cast<MultiComponentTimeSerie>(variable->data()));
475 std::dynamic_pointer_cast<MultiComponentTimeSerie>(variable->data()));
477 default:
476 default:
478 // Creates default helper
477 // Creates default helper
479 break;
478 break;
480 }
479 }
481
480
482 return std::make_unique<PlottablesHelper<TimeSeries::ITimeSerie>>(nullptr);
481 return std::make_unique<PlottablesHelper<TimeSeries::ITimeSerie>>(nullptr);
483 }
482 }
484
483
485 } // namespace
484 } // namespace
486
485
487 PlottablesMap VisualizationGraphHelper::create(
486 PlottablesMap VisualizationGraphHelper::create(
488 std::shared_ptr<Variable2> variable, QCustomPlot& plot) noexcept
487 std::shared_ptr<Variable2> variable, QCustomPlot& plot) noexcept
489 {
488 {
490 if (variable)
489 if (variable)
491 {
490 {
492 auto helper = createHelper(variable);
491 auto helper = createHelper(variable);
493 auto plottables = helper->create(plot);
492 auto plottables = helper->create(plot);
494 return plottables;
493 return plottables;
495 }
494 }
496 else
495 else
497 {
496 {
498 qCDebug(LOG_VisualizationGraphHelper())
497 qCDebug(LOG_VisualizationGraphHelper())
499 << QObject::tr("Can't create graph plottables : the variable is null");
498 << QObject::tr("Can't create graph plottables : the variable is null");
500 return PlottablesMap {};
499 return PlottablesMap {};
501 }
500 }
502 }
501 }
503
502
504 void VisualizationGraphHelper::setYAxisRange(
503 void VisualizationGraphHelper::setYAxisRange(
505 std::shared_ptr<Variable2> variable, QCustomPlot& plot) noexcept
504 std::shared_ptr<Variable2> variable, QCustomPlot& plot) noexcept
506 {
505 {
507 if (variable)
506 if (variable)
508 {
507 {
509 auto helper = createHelper(variable);
508 auto helper = createHelper(variable);
510 helper->setYAxisRange(variable->range(), plot);
509 helper->setYAxisRange(variable->range(), plot);
511 }
510 }
512 else
511 else
513 {
512 {
514 qCDebug(LOG_VisualizationGraphHelper())
513 qCDebug(LOG_VisualizationGraphHelper())
515 << QObject::tr("Can't set y-axis range of plot: the variable is null");
514 << QObject::tr("Can't set y-axis range of plot: the variable is null");
516 }
515 }
517 }
516 }
518
517
519 void VisualizationGraphHelper::updateData(
518 void VisualizationGraphHelper::updateData(
520 PlottablesMap& plottables, std::shared_ptr<Variable2> variable, const DateTimeRange& dateTime)
519 PlottablesMap& plottables, std::shared_ptr<Variable2> variable, const DateTimeRange& dateTime)
521 {
520 {
522 auto helper = createHelper(variable);
521 auto helper = createHelper(variable);
523 helper->update(plottables, dateTime);
522 helper->update(plottables, dateTime);
524 }
523 }
@@ -1,24 +1,23
1 #include <Data/DateTimeRange.h>
2 #include <TimeSeries.h>
1 #include <TimeSeries.h>
3 #include <functional>
2 #include <functional>
4 #include <iostream>
3 #include <iostream>
5 #include <memory>
4 #include <memory>
6
5
7
6
8 class PythonInterpreter
7 class PythonInterpreter
9 {
8 {
10 public:
9 public:
11 using provider_funct_t = std::function<std::shared_ptr<TimeSeries::ITimeSerie>(
10 using provider_funct_t = std::function<std::shared_ptr<TimeSeries::ITimeSerie>(
12 std::vector<std::tuple<std::string, std::string>>&, double, double)>;
11 std::vector<std::tuple<std::string, std::string>>&, double, double)>;
13 using product_t = std::tuple<std::string, std::vector<std::string>,
12 using product_t = std::tuple<std::string, std::vector<std::string>,
14 std::vector<std::pair<std::string, std::string>>>;
13 std::vector<std::pair<std::string, std::string>>>;
15
14
16 PythonInterpreter();
15 PythonInterpreter();
17 void add_register_callback(
16 void add_register_callback(
18 std::function<void(const std::vector<product_t>&, provider_funct_t)> callback);
17 std::function<void(const std::vector<product_t>&, provider_funct_t)> callback);
19 ~PythonInterpreter();
18 ~PythonInterpreter();
20 void eval(const std::string& file);
19 void eval(const std::string& file);
21 void release();
20 void release();
22
21
23 private:
22 private:
24 };
23 };
@@ -1,38 +1,49
1
1
2 pybind11_dep = dependency('pybind11', required : true, fallback:['pybind11','pybind11_dep'])
2 pybind11_dep = dependency('pybind11', required : true, fallback:['pybind11','pybind11_dep'])
3
3
4 python_providers_moc_headers = [
4 python_providers_moc_headers = [
5 'include/python_providers.h'
5 'include/python_providers.h'
6 ]
6 ]
7
7
8 python_providers_sources = [
8 python_providers_sources = [
9 'src/python_providers.cpp'
9 'src/python_providers.cpp'
10 ]
10 ]
11
11
12 python_providers_inc = include_directories(['include'])
12 python_providers_inc = include_directories(['include'])
13
13
14
14
15 gen = generator(moc,
15 gen = generator(moc,
16 output : 'moc_@BASENAME@.cpp',
16 output : 'moc_@BASENAME@.cpp',
17 arguments : ['@INPUT@',
17 arguments : ['@INPUT@',
18 '-DSCIQLOP_PLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/python_providers/resources/python_providers.json"',
18 '-DSCIQLOP_PLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/python_providers/resources/python_providers.json"',
19 '-I', meson.current_source_dir()+'/include',
19 '-I', meson.current_source_dir()+'/include',
20 '-I', meson.current_source_dir()+'/../../core/include/',
20 '-I', meson.current_source_dir()+'/../../core/include/',
21 '-o', '@OUTPUT@'])
21 '-o', '@OUTPUT@'])
22
22
23 python_providers_moc_files = gen.process(python_providers_moc_headers)
23 python_providers_moc_files = gen.process(python_providers_moc_headers)
24
24
25 cpp_args = ['-DPYTHON_PROVIDERS_LIB','-DQT_PLUGIN', '-DQT_NO_KEYWORDS']
25 cpp_args = ['-DPYTHON_PROVIDERS_LIB','-DQT_PLUGIN']
26 if(get_option('default_library')=='static')
26 if(get_option('default_library')=='static')
27 cpp_args += ['-DQT_STATICPLUGIN']
27 cpp_args += ['-DQT_STATICPLUGIN']
28 endif
28 endif
29
29
30 sciqlop_python_interpreter = library('python_interpreter',
31 ['src/python_interpreter.cpp'],
32 include_directories : [python_providers_inc],
33 dependencies : [pybind11_dep, sciqlop_core],
34 cpp_args : ['-DQT_NO_KEYWORDS'],
35 install : true,
36 install_dir : join_paths(get_option('libdir'), 'SciQLop')
37 )
38
39
30 sciqlop_python_providers = library('pythonproviders',
40 sciqlop_python_providers = library('pythonproviders',
31 python_providers_sources,
41 python_providers_sources,
32 python_providers_moc_files,
42 python_providers_moc_files,
33 cpp_args : cpp_args,
43 cpp_args : cpp_args,
34 include_directories : [python_providers_inc],
44 include_directories : [python_providers_inc],
45 link_with : [sciqlop_python_interpreter],
35 dependencies : [sciqlop_core, sciqlop_gui, pybind11_dep],
46 dependencies : [sciqlop_core, sciqlop_gui, pybind11_dep],
36 install : true,
47 install : true,
37 install_dir : join_paths(get_option('libdir'), 'SciQLop')
48 install_dir : join_paths(get_option('libdir'), 'SciQLop')
38 )
49 )
General Comments 0
You need to be logged in to leave comments. Login now