Auto status change to "Under Review"
@@ -1,157 +1,157 | |||
|
1 | 1 | #include "Visualization/VisualizationGraphHelper.h" |
|
2 | 2 | #include "Visualization/qcustomplot.h" |
|
3 | 3 | |
|
4 | 4 | #include <Data/ScalarSeries.h> |
|
5 | 5 | |
|
6 | 6 | #include <Variable/Variable.h> |
|
7 | 7 | |
|
8 | 8 | #include <QElapsedTimer> |
|
9 | 9 | |
|
10 | 10 | Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper") |
|
11 | 11 | |
|
12 | 12 | namespace { |
|
13 | 13 | |
|
14 | 14 | /// Format for datetimes on a axis |
|
15 | 15 | const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss"); |
|
16 | 16 | |
|
17 | 17 | /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or |
|
18 | 18 | /// non-time data |
|
19 | 19 | QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis) |
|
20 | 20 | { |
|
21 | 21 | if (isTimeAxis) { |
|
22 | 22 | auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create(); |
|
23 | 23 | dateTicker->setDateTimeFormat(DATETIME_TICKER_FORMAT); |
|
24 | 24 | |
|
25 | 25 | return dateTicker; |
|
26 | 26 | } |
|
27 | 27 | else { |
|
28 | 28 | // default ticker |
|
29 | 29 | return QSharedPointer<QCPAxisTicker>::create(); |
|
30 | 30 | } |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | 33 | void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSeries, |
|
34 | 34 | const SqpDateTime &dateTime) |
|
35 | 35 | { |
|
36 | 36 | QElapsedTimer timer; |
|
37 | 37 | timer.start(); |
|
38 | 38 | if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) { |
|
39 | 39 | // Clean the graph |
|
40 | 40 | // NAIVE approch |
|
41 | 41 | const auto &xData = scalarSeries.xAxisData()->data(); |
|
42 | 42 | const auto &valuesData = scalarSeries.valuesData()->data(); |
|
43 | 43 | const auto count = xData.count(); |
|
44 | 44 | qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache" << xData.count(); |
|
45 | 45 | |
|
46 | 46 | auto xValue = QVector<double>(count); |
|
47 | 47 | auto vValue = QVector<double>(count); |
|
48 | 48 | |
|
49 | 49 | int n = 0; |
|
50 | 50 | for (auto i = 0; i < count; ++i) { |
|
51 | 51 | const auto x = xData[i]; |
|
52 | 52 | if (x >= dateTime.m_TStart && x <= dateTime.m_TEnd) { |
|
53 | 53 | xValue[n] = x; |
|
54 | 54 | vValue[n] = valuesData[i]; |
|
55 | 55 | ++n; |
|
56 | 56 | } |
|
57 | 57 | } |
|
58 | 58 | |
|
59 | 59 | xValue.resize(n); |
|
60 | 60 | vValue.resize(n); |
|
61 | 61 | |
|
62 |
qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points displayed" |
|
|
63 |
<< |
|
|
62 | qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points displayed" | |
|
63 | << xValue.count(); | |
|
64 | 64 | |
|
65 | 65 | qcpGraph->setData(xValue, vValue); |
|
66 | 66 | |
|
67 | 67 | // Display all data |
|
68 | 68 | // component->parentPlot()->xAxis->setRange(dateTime.m_TStart, dateTime.m_TEnd); |
|
69 | 69 | component->rescaleAxes(); |
|
70 | 70 | component->parentPlot()->replot(); |
|
71 | 71 | } |
|
72 | 72 | else { |
|
73 | 73 | /// @todo DEBUG |
|
74 | 74 | } |
|
75 | 75 | } |
|
76 | 76 | |
|
77 | 77 | QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QCustomPlot &plot, |
|
78 | 78 | const SqpDateTime &dateTime) |
|
79 | 79 | { |
|
80 | 80 | auto component = plot.addGraph(); |
|
81 | 81 | |
|
82 | 82 | if (component) { |
|
83 | 83 | // // Graph data |
|
84 | 84 | component->setData(scalarSeries.xAxisData()->data(), scalarSeries.valuesData()->data(), |
|
85 | 85 | true); |
|
86 | 86 | |
|
87 | 87 | updateScalarData(component, scalarSeries, dateTime); |
|
88 | 88 | |
|
89 | 89 | // Axes properties |
|
90 | 90 | /// @todo : for the moment, no control is performed on the axes: the units and the tickers |
|
91 | 91 | /// are fixed for the default x-axis and y-axis of the plot, and according to the new graph |
|
92 | 92 | |
|
93 | 93 | auto setAxisProperties = [](auto axis, const auto &unit) { |
|
94 | 94 | // label (unit name) |
|
95 | 95 | axis->setLabel(unit.m_Name); |
|
96 | 96 | |
|
97 | 97 | // ticker (depending on the type of unit) |
|
98 | 98 | axis->setTicker(axisTicker(unit.m_TimeUnit)); |
|
99 | 99 | }; |
|
100 | 100 | setAxisProperties(plot.xAxis, scalarSeries.xAxisUnit()); |
|
101 | 101 | setAxisProperties(plot.yAxis, scalarSeries.valuesUnit()); |
|
102 | 102 | |
|
103 | 103 | // Display all data |
|
104 | 104 | component->rescaleAxes(); |
|
105 | 105 | plot.replot(); |
|
106 | 106 | } |
|
107 | 107 | else { |
|
108 | 108 | qCDebug(LOG_VisualizationGraphHelper()) |
|
109 | 109 | << QObject::tr("Can't create graph for the scalar series"); |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | 112 | return component; |
|
113 | 113 | } |
|
114 | 114 | |
|
115 | 115 | } // namespace |
|
116 | 116 | |
|
117 | 117 | QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable, |
|
118 | 118 | QCustomPlot &plot) noexcept |
|
119 | 119 | { |
|
120 | 120 | auto result = QVector<QCPAbstractPlottable *>{}; |
|
121 | 121 | |
|
122 | 122 | if (variable) { |
|
123 | 123 | // Gets the data series of the variable to call the creation of the right components |
|
124 | 124 | // according to its type |
|
125 | 125 | if (auto scalarSeries = dynamic_cast<ScalarSeries *>(variable->dataSeries())) { |
|
126 | 126 | result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime())); |
|
127 | 127 | } |
|
128 | 128 | else { |
|
129 | 129 | qCDebug(LOG_VisualizationGraphHelper()) |
|
130 | 130 | << QObject::tr("Can't create graph plottables : unmanaged data series type"); |
|
131 | 131 | } |
|
132 | 132 | } |
|
133 | 133 | else { |
|
134 | 134 | qCDebug(LOG_VisualizationGraphHelper()) |
|
135 | 135 | << QObject::tr("Can't create graph plottables : the variable is null"); |
|
136 | 136 | } |
|
137 | 137 | |
|
138 | 138 | return result; |
|
139 | 139 | } |
|
140 | 140 | |
|
141 | 141 | void VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *> plotableVect, |
|
142 | 142 | IDataSeries *dataSeries, const SqpDateTime &dateTime) |
|
143 | 143 | { |
|
144 | 144 | if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) { |
|
145 | 145 | if (plotableVect.size() == 1) { |
|
146 | 146 | updateScalarData(plotableVect.at(0), *scalarSeries, dateTime); |
|
147 | 147 | } |
|
148 | 148 | else { |
|
149 | 149 | qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr( |
|
150 | 150 | "Can't update Data of a scalarSeries because there is not only one component " |
|
151 | 151 | "associated"); |
|
152 | 152 | } |
|
153 | 153 | } |
|
154 | 154 | else { |
|
155 | 155 | /// @todo DEBUG |
|
156 | 156 | } |
|
157 | 157 | } |
@@ -1,269 +1,263 | |||
|
1 | 1 | #include "Visualization/VisualizationGraphWidget.h" |
|
2 | 2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
3 | 3 | #include "Visualization/VisualizationGraphHelper.h" |
|
4 | 4 | #include "ui_VisualizationGraphWidget.h" |
|
5 | 5 | |
|
6 | 6 | #include <Data/ArrayData.h> |
|
7 | 7 | #include <Data/IDataSeries.h> |
|
8 | 8 | #include <SqpApplication.h> |
|
9 | 9 | #include <Variable/Variable.h> |
|
10 | 10 | #include <Variable/VariableController.h> |
|
11 | 11 | |
|
12 | 12 | #include <unordered_map> |
|
13 | 13 | |
|
14 | 14 | Q_LOGGING_CATEGORY(LOG_VisualizationGraphWidget, "VisualizationGraphWidget") |
|
15 | 15 | |
|
16 | 16 | namespace { |
|
17 | 17 | |
|
18 | 18 | /// Key pressed to enable zoom on horizontal axis |
|
19 | 19 | const auto HORIZONTAL_ZOOM_MODIFIER = Qt::NoModifier; |
|
20 | 20 | |
|
21 | 21 | /// Key pressed to enable zoom on vertical axis |
|
22 | 22 | const auto VERTICAL_ZOOM_MODIFIER = Qt::ControlModifier; |
|
23 | 23 | |
|
24 | 24 | } // namespace |
|
25 | 25 | |
|
26 | 26 | struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { |
|
27 | 27 | |
|
28 | 28 | // 1 variable -> n qcpplot |
|
29 | 29 | std::multimap<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMultiMap; |
|
30 | 30 | }; |
|
31 | 31 | |
|
32 | 32 | VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent) |
|
33 | 33 | : QWidget{parent}, |
|
34 | 34 | ui{new Ui::VisualizationGraphWidget}, |
|
35 | 35 | impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()} |
|
36 | 36 | { |
|
37 | 37 | ui->setupUi(this); |
|
38 | 38 | |
|
39 | 39 | ui->graphNameLabel->setText(name); |
|
40 | 40 | |
|
41 | 41 | // 'Close' options : widget is deleted when closed |
|
42 | 42 | setAttribute(Qt::WA_DeleteOnClose); |
|
43 | 43 | connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationGraphWidget::close); |
|
44 | 44 | ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton)); |
|
45 | 45 | |
|
46 | 46 | // Set qcpplot properties : |
|
47 | 47 | // - Drag (on x-axis) and zoom are enabled |
|
48 | 48 | // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation |
|
49 | 49 | ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); |
|
50 | 50 | ui->widget->axisRect()->setRangeDrag(Qt::Horizontal); |
|
51 | 51 | connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel); |
|
52 | 52 | connect(ui->widget->xAxis, |
|
53 | 53 | static_cast<void (QCPAxis::*)(const QCPRange &)>(&QCPAxis::rangeChanged), this, |
|
54 | 54 | &VisualizationGraphWidget::onRangeChanged); |
|
55 | 55 | |
|
56 | 56 | // Activates menu when right clicking on the graph |
|
57 | 57 | ui->widget->setContextMenuPolicy(Qt::CustomContextMenu); |
|
58 | 58 | connect(ui->widget, &QCustomPlot::customContextMenuRequested, this, |
|
59 | 59 | &VisualizationGraphWidget::onGraphMenuRequested); |
|
60 | 60 | |
|
61 | 61 | connect(this, &VisualizationGraphWidget::requestDataLoading, &sqpApp->variableController(), |
|
62 | 62 | &VariableController::onRequestDataLoading); |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | |
|
66 | 66 | VisualizationGraphWidget::~VisualizationGraphWidget() |
|
67 | 67 | { |
|
68 | 68 | delete ui; |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) |
|
72 | 72 | { |
|
73 | 73 | // Uses delegate to create the qcpplot components according to the variable |
|
74 | 74 | auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget); |
|
75 | 75 | |
|
76 | 76 | for (auto createdPlottable : qAsConst(createdPlottables)) { |
|
77 | 77 | impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | void VisualizationGraphWidget::addVariableUsingGraph(std::shared_ptr<Variable> variable) |
|
84 | 84 | { |
|
85 | 85 | |
|
86 | 86 | // when adding a variable, we need to set its time range to the current graph range |
|
87 | 87 | auto grapheRange = ui->widget->xAxis->range(); |
|
88 | 88 | auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper}; |
|
89 | 89 | variable->setDateTime(dateTime); |
|
90 | qCInfo(LOG_VisualizationGraphWidget()) << "ADD Variable with range : " << dateTime; | |
|
91 | 90 | |
|
92 | 91 | auto variableDateTimeWithTolerance = dateTime; |
|
93 | 92 | |
|
94 | 93 | // add 10% tolerance for each side |
|
95 | 94 | auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart); |
|
96 | 95 | variableDateTimeWithTolerance.m_TStart -= tolerance; |
|
97 | 96 | variableDateTimeWithTolerance.m_TEnd += tolerance; |
|
98 | 97 | |
|
99 | qCInfo(LOG_VisualizationGraphWidget()) << "ADD Variable with range TOL: " | |
|
100 | << variableDateTimeWithTolerance; | |
|
101 | ||
|
102 | 98 | // Uses delegate to create the qcpplot components according to the variable |
|
103 | 99 | auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget); |
|
104 | 100 | |
|
105 | 101 | for (auto createdPlottable : qAsConst(createdPlottables)) { |
|
106 | 102 | impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); |
|
107 | 103 | } |
|
108 | 104 | |
|
109 | 105 | connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); |
|
110 | 106 | |
|
111 | 107 | // CHangement detected, we need to ask controller to request data loading |
|
112 | 108 | emit requestDataLoading(variable, variableDateTimeWithTolerance); |
|
113 | 109 | } |
|
114 | 110 | |
|
115 | 111 | void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept |
|
116 | 112 | { |
|
117 | 113 | // Each component associated to the variable : |
|
118 | 114 | // - is removed from qcpplot (which deletes it) |
|
119 | 115 | // - is no longer referenced in the map |
|
120 | 116 | auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable); |
|
121 | 117 | for (auto it = componentsIt.first; it != componentsIt.second;) { |
|
122 | 118 | ui->widget->removePlottable(it->second); |
|
123 | 119 | it = impl->m_VariableToPlotMultiMap.erase(it); |
|
124 | 120 | } |
|
125 | 121 | |
|
126 | 122 | // Updates graph |
|
127 | 123 | ui->widget->replot(); |
|
128 | 124 | } |
|
129 | 125 | |
|
130 | 126 | void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
131 | 127 | { |
|
132 | 128 | if (visitor) { |
|
133 | 129 | visitor->visit(this); |
|
134 | 130 | } |
|
135 | 131 | else { |
|
136 | 132 | qCCritical(LOG_VisualizationGraphWidget()) |
|
137 | 133 | << tr("Can't visit widget : the visitor is null"); |
|
138 | 134 | } |
|
139 | 135 | } |
|
140 | 136 | |
|
141 | 137 | bool VisualizationGraphWidget::canDrop(const Variable &variable) const |
|
142 | 138 | { |
|
143 | 139 | /// @todo : for the moment, a graph can always accomodate a variable |
|
144 | 140 | Q_UNUSED(variable); |
|
145 | 141 | return true; |
|
146 | 142 | } |
|
147 | 143 | |
|
148 | 144 | QString VisualizationGraphWidget::name() const |
|
149 | 145 | { |
|
150 | 146 | return ui->graphNameLabel->text(); |
|
151 | 147 | } |
|
152 | 148 | |
|
153 | 149 | void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept |
|
154 | 150 | { |
|
155 | 151 | QMenu graphMenu{}; |
|
156 | 152 | |
|
157 | 153 | // Iterates on variables (unique keys) |
|
158 | 154 | for (auto it = impl->m_VariableToPlotMultiMap.cbegin(), |
|
159 | 155 | end = impl->m_VariableToPlotMultiMap.cend(); |
|
160 | 156 | it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) { |
|
161 | 157 | // 'Remove variable' action |
|
162 | 158 | graphMenu.addAction(tr("Remove variable %1").arg(it->first->name()), |
|
163 | 159 | [ this, var = it->first ]() { removeVariable(var); }); |
|
164 | 160 | } |
|
165 | 161 | |
|
166 | 162 | if (!graphMenu.isEmpty()) { |
|
167 | 163 | graphMenu.exec(mapToGlobal(pos)); |
|
168 | 164 | } |
|
169 | 165 | } |
|
170 | 166 | |
|
171 | 167 | void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1) |
|
172 | 168 | { |
|
173 | ||
|
174 | qCInfo(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged"); | |
|
169 | qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged"); | |
|
175 | 170 | |
|
176 | 171 | for (auto it = impl->m_VariableToPlotMultiMap.cbegin(); |
|
177 | 172 | it != impl->m_VariableToPlotMultiMap.cend(); ++it) { |
|
178 | 173 | |
|
179 | 174 | auto variable = it->first; |
|
180 | 175 | auto dateTime = SqpDateTime{t1.lower, t1.upper}; |
|
181 | 176 | |
|
182 | 177 | if (!variable->contains(dateTime)) { |
|
183 | qCInfo(LOG_VisualizationGraphWidget()) << dateTime << variable->dateTime(); | |
|
184 | 178 | |
|
185 | 179 | auto variableDateTimeWithTolerance = dateTime; |
|
186 | 180 | if (variable->intersect(dateTime)) { |
|
187 | 181 | auto variableDateTime = variable->dateTime(); |
|
188 | 182 | if (variableDateTime.m_TStart < dateTime.m_TStart) { |
|
189 | 183 | |
|
190 | 184 | auto diffEndToKeepDelta = dateTime.m_TEnd - variableDateTime.m_TEnd; |
|
191 | 185 | dateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta; |
|
192 | 186 | // Tolerance have to be added to the right |
|
193 | 187 | // add 10% tolerance for right (end) side |
|
194 | 188 | auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart); |
|
195 | 189 | variableDateTimeWithTolerance.m_TEnd += tolerance; |
|
196 | 190 | } |
|
197 | 191 | if (variableDateTime.m_TEnd > dateTime.m_TEnd) { |
|
198 | 192 | auto diffStartToKeepDelta = variableDateTime.m_TStart - dateTime.m_TStart; |
|
199 | 193 | dateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta; |
|
200 | 194 | // Tolerance have to be added to the left |
|
201 | 195 | // add 10% tolerance for left (start) side |
|
202 | 196 | auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart); |
|
203 | 197 | variableDateTimeWithTolerance.m_TStart -= tolerance; |
|
204 | 198 | } |
|
205 | 199 | } |
|
206 | 200 | else { |
|
207 | 201 | // add 10% tolerance for each side |
|
208 | 202 | auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart); |
|
209 | 203 | variableDateTimeWithTolerance.m_TStart -= tolerance; |
|
210 | 204 | variableDateTimeWithTolerance.m_TEnd += tolerance; |
|
211 | 205 | } |
|
212 | 206 | variable->setDateTime(dateTime); |
|
213 | 207 | |
|
214 | 208 | // CHangement detected, we need to ask controller to request data loading |
|
215 | 209 | emit requestDataLoading(variable, variableDateTimeWithTolerance); |
|
216 | 210 | } |
|
217 | 211 | } |
|
218 | 212 | } |
|
219 | 213 | |
|
220 | 214 | void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept |
|
221 | 215 | { |
|
222 | 216 | auto zoomOrientations = QFlags<Qt::Orientation>{}; |
|
223 | 217 | |
|
224 | 218 | // Lambda that enables a zoom orientation if the key modifier related to this orientation |
|
225 | 219 | // has |
|
226 | 220 | // been pressed |
|
227 | 221 | auto enableOrientation |
|
228 | 222 | = [&zoomOrientations, event](const auto &orientation, const auto &modifier) { |
|
229 | 223 | auto orientationEnabled = event->modifiers().testFlag(modifier); |
|
230 | 224 | zoomOrientations.setFlag(orientation, orientationEnabled); |
|
231 | 225 | }; |
|
232 | 226 | enableOrientation(Qt::Vertical, VERTICAL_ZOOM_MODIFIER); |
|
233 | 227 | enableOrientation(Qt::Horizontal, HORIZONTAL_ZOOM_MODIFIER); |
|
234 | 228 | |
|
235 | 229 | ui->widget->axisRect()->setRangeZoom(zoomOrientations); |
|
236 | 230 | } |
|
237 | 231 | |
|
238 | 232 | void VisualizationGraphWidget::onDataCacheVariableUpdated() |
|
239 | 233 | { |
|
240 | 234 | // NOTE: |
|
241 | 235 | // We don't want to call the method for each component of a variable unitarily, but for |
|
242 | 236 | // all |
|
243 | 237 | // its components at once (eg its three components in the case of a vector). |
|
244 | 238 | |
|
245 | 239 | // The unordered_multimap does not do this easily, so the question is whether to: |
|
246 | 240 | // - use an ordered_multimap and the algos of std to group the values by key |
|
247 | 241 | // - use a map (unique keys) and store as values directly the list of components |
|
248 | 242 | |
|
249 | 243 | for (auto it = impl->m_VariableToPlotMultiMap.cbegin(); |
|
250 | 244 | it != impl->m_VariableToPlotMultiMap.cend(); ++it) { |
|
251 | 245 | auto variable = it->first; |
|
252 | 246 | VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second, |
|
253 | 247 | variable->dataSeries(), variable->dateTime()); |
|
254 | 248 | } |
|
255 | 249 | } |
|
256 | 250 | |
|
257 | 251 | void VisualizationGraphWidget::updateDisplay(std::shared_ptr<Variable> variable) |
|
258 | 252 | { |
|
259 | 253 | auto abstractPlotableItPair = impl->m_VariableToPlotMultiMap.equal_range(variable); |
|
260 | 254 | |
|
261 | 255 | auto abstractPlotableVect = QVector<QCPAbstractPlottable *>{}; |
|
262 | 256 | |
|
263 | 257 | for (auto it = abstractPlotableItPair.first; it != abstractPlotableItPair.second; ++it) { |
|
264 | 258 | abstractPlotableVect.push_back(it->second); |
|
265 | 259 | } |
|
266 | 260 | |
|
267 | 261 | VisualizationGraphHelper::updateData(abstractPlotableVect, variable->dataSeries(), |
|
268 | 262 | variable->dateTime()); |
|
269 | 263 | } |
General Comments 2
Pull request updated. Auto status change to "Under Review"
Changed commits: * 3 added * 0 removed Changed files: * M core/include/Data/SqpDateTime.h * M core/include/Variable/Variable.h * M core/include/Variable/VariableModel.h * M core/src/Variable/Variable.cpp * M core/src/Variable/VariableCacheController.cpp * M core/src/Variable/VariableController.cpp * M core/src/Variable/VariableModel.cpp * M gui/include/Visualization/VisualizationGraphWidget.h * M gui/src/Visualization/VisualizationGraphHelper.cpp * M gui/src/Visualization/VisualizationGraphWidget.cpp * M gui/src/Visualization/operations/GenerateVariableMenuOperation.cpp * R COPYING * R app/src/MainWindow.cpp * R app/ui/MainWindow.ui * R cmake/sciqlop_package_qt.cmake * R core/include/Common/MetaTypes.h * R core/include/Data/ArrayData.h * R core/include/Data/DataProviderParameters.h * R core/include/Data/DataSeries.h * R core/include/Data/IDataProvider.h * R core/include/Data/IDataSeries.h * R core/include/Data/ScalarSeries.h * R core/include/DataSource/DataSourceItemAction.h * R core/include/Plugin/PluginManager.h * R core/include/Time/TimeController.h * R core/include/Variable/VariableCacheController.h * R core/include/Variable/VariableController.h * R core/include/Visualization/VisualizationController.h * R core/src/Data/ScalarSeries.cpp * R core/src/DataSource/DataSourceItemAction.cpp * R core/src/Plugin/PluginManager.cpp * R core/src/Time/TimeController.cpp * R core/src/Visualization/VisualizationController.cpp * R core/tests/Variable/TestVariableCacheController.cpp * R gui/include/DataSource/DataSourceTreeWidgetItem.h * R gui/include/DataSource/DataSourceWidget.h * R gui/include/SidePane/SqpSidePane.h * R gui/include/TimeWidget/TimeWidget.h * R gui/include/Variable/VariableInspectorWidget.h * R gui/include/Variable/VariableMenuHeaderWidget.h * R gui/include/Visualization/IVariableContainer.h * R gui/include/Visualization/IVisualizationWidget.h * R gui/include/Visualization/IVisualizationWidgetVisitor.h * R gui/include/Visualization/VisualizationGraphHelper.h * R gui/include/Visualization/VisualizationTabWidget.h * R gui/include/Visualization/VisualizationWidget.h * R gui/include/Visualization/VisualizationZoneWidget.h * R gui/include/Visualization/operations/GenerateVariableMenuOperation.h * R gui/include/Visualization/operations/MenuBuilder.h * R gui/include/Visualization/qcustomplot.h * R gui/resources/icones/delete.png * R gui/resources/icones/next.png * R gui/resources/icones/openInspector.png * R gui/resources/icones/previous.png * R gui/resources/icones/sciqlop2PNG_1024.png * R gui/resources/sqpguiresources.qrc * R gui/src/DataSource/DataSourceTreeWidgetItem.cpp * R gui/src/DataSource/DataSourceWidget.cpp * R gui/src/SidePane/SqpSidePane.cpp * R gui/src/TimeWidget/TimeWidget.cpp * R gui/src/Variable/VariableInspectorWidget.cpp * R gui/src/Variable/VariableMenuHeaderWidget.cpp * R gui/src/Visualization/VisualizationTabWidget.cpp * R gui/src/Visualization/VisualizationWidget.cpp * R gui/src/Visualization/VisualizationZoneWidget.cpp * R gui/src/Visualization/operations/MenuBuilder.cpp * R gui/src/Visualization/qcustomplot.cpp * R gui/ui/DataSource/DataSourceWidget.ui * R gui/ui/SidePane/SqpSidePane.ui * R gui/ui/TimeWidget/TimeWidget.ui * R gui/ui/Variable/VariableInspectorWidget.ui * R gui/ui/Variable/VariableMenuHeaderWidget.ui * R gui/ui/Visualization/VisualizationGraphWidget.ui * R gui/ui/Visualization/VisualizationTabWidget.ui * R gui/ui/Visualization/VisualizationWidget.ui * R gui/ui/Visualization/VisualizationZoneWidget.ui * R gui/vera-exclusions/exclusions.txt * R plugin/CMakeLists.txt * R plugin/cmake/Findsciqlop-plugin.cmake * R plugin/include/Plugin/IPlugin.h * R plugins/mockplugin/CMakeLists.txt * R plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake * R plugins/mockplugin/include/CosinusProvider.h * R plugins/mockplugin/include/MockPlugin.h * R plugins/mockplugin/resources/mockplugin.json * R plugins/mockplugin/src/CosinusProvider.cpp * R plugins/mockplugin/src/MockPlugin.cpp * R README.md * R app/CMakeLists.txt * R app/include/MainWindow.h * R app/src/Main.cpp * R app/vera-exclusions/exclusions.txt * R cmake/sciqlop.cmake * R cmake/sciqlop_applications.cmake * R cmake/sciqlop_package.cmake * R cmake/sciqlop_params.cmake * R core/CMakeLists.txt * R core/include/Common/spimpl.h * R core/include/DataSource/DataSourceController.h * R core/include/DataSource/DataSourceItem.h * R core/src/DataSource/DataSourceController.cpp * R core/src/DataSource/DataSourceItem.cpp * R core/tests/DataSource/TestDataSourceController.cpp * R core/vera-exclusions/exclusions.txt * R formatting/cmake/use_clangformat.cmake * R formatting/vera-exclusions/exclusions.txt * R gui/CMakeLists.txt * R gui/include/SqpApplication.h * R gui/src/SqpApplication.cpp * R LICENSE * R app/src/mainwindow.cpp * R app/src/mainwindow.ui
You need to be logged in to leave comments.
Login now