SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
comparisonplotdialog.h
Go to the documentation of this file.
1
20#ifndef OPENSWMMVIS_UI_DIALOGS_COMPARISONPLOTDIALOG_H
21#define OPENSWMMVIS_UI_DIALOGS_COMPARISONPLOTDIALOG_H
22
24
25#include <QDateTime>
26#include <QDialog>
27#include <QHash>
28#include <QPointer>
29#include <QString>
30
31#include <memory>
32
33class QAction;
34class QActionGroup;
35class QChartView;
36class QLabel;
37class QChart;
38class QLineSeries;
39class QScatterSeries;
40namespace openswmmvis::plot { class UtcTimeAxis; }
41class QValueAxis;
42class QSplitter;
43class QTreeWidget;
44class QTreeWidgetItem;
45class QGridLayout;
46class QScrollArea;
47class QToolBar;
48class QWidget;
49class QComboBox;
50class QPushButton;
51
52// Forward declarations — these classes live in the global namespace, so they
53// must be declared here at file scope (not inline inside the openswmmvis::ui
54// namespace below, which would create phantom openswmmvis::ui::* types).
57
58namespace openswmmvis::ui {
59
60class InteractiveChartView;
61class RangeSliderWidget;
62class StatsSummaryPanel;
63
64class ComparisonPlotDialog : public QDialog
65{
66 Q_OBJECT
67public:
68 explicit ComparisonPlotDialog(QWidget *parent = nullptr);
70
73 openswmmvis::plot::ComparisonPlotModel* model() noexcept { return m_model.get(); }
74
79 bool makeBaseline = false);
80
84
87 int addSeries(int runIndex,
90
94 int addSeries(int runIndex,
96 const openswmmvis::plot::ResultDescriptor& descriptor);
97
100 int addCellSeries(int runIndex,
101 const QVector<int>& triIdxList,
102 const QVector<openswmmvis::plot::PlotAttribute>& attributes);
103
107 void setAddFromMapChecked(bool checked);
108
109signals:
113 void addFromMapToggled(bool active);
114
115private slots:
116 void onRunSourceAdded(int runIndex);
117 void onRunSourceRemoved(int runIndex);
118 void onSeriesAdded(int seriesIndex);
119 void onSeriesRemoved(int seriesIndex);
120 void onStyleChanged(int seriesIndex);
121 void onRowsChanged();
122 void onAnimationTimeChanged(QDateTime t);
123
128 void appendChartTails();
129
130 void onAddSeriesClicked();
131 void onLoadObservedClicked();
132 void onRemoveSelectedClicked();
133 void onSeriesItemSelectionChanged();
134 void onSeriesItemDoubleClicked(QTreeWidgetItem *item, int column);
135
136 // Slice AT.3 — series-tree visibility + context menu.
137 void onSeriesItemChanged(QTreeWidgetItem *item, int column);
138 void onSeriesTreeContextMenu(const QPoint &pos);
139
140 // Slice AT.2 — toolbar slots.
141 void onModeActionTriggered();
142 void onFitClicked();
143 void onExportPngClicked();
144 void onExportDataClicked();
145 void onAnimationCursorToggled(bool checked);
146 void onAddSystemSeriesClicked();
147
148 // CP.1 — view-pane visibility toggles. Each persists splitter sizes
149 // before hiding so the previous user-set width restores on re-show.
150 void onShowSeriesToggled(bool show);
151 void onShowStatsToggled(bool show);
152 void onShowSliderToggled(bool show);
153 void onChartsOnlyToggled(bool chartsOnly);
154
155 // COMPARISON_PLOT_1V1_AND_TREE_PLAN Phase 4 — optional 1v1 column.
156 void onShow1v1Toggled(bool show);
157
158 // COMPARISON_PLOT_1V1_AND_TREE_PLAN Phase 5 — pair configuration.
159 void onConfigure1v1Clicked();
160
161private:
162 void buildUi();
163 void buildToolBar();
164 void rebuildSeriesTree();
165 void rebuildCharts();
168 QString legendNameFor(const openswmmvis::plot::SeriesSpec& spec) const;
169 void updateChartForRow(int rowIndex);
170 void applyAnimationCursorToCharts();
173 void propagateModeToRows();
175 void equaliseChartSplitterSizes();
177 void wireXAxisSync(int rowIndex);
181 void exportSeriesData(const QVector<int>& seriesIndices);
182
183 std::unique_ptr<openswmmvis::plot::ComparisonPlotModel> m_model;
184
185 // UI
186 QSplitter *m_splitter = nullptr;
187 QTreeWidget *m_seriesTree = nullptr;
188 QPushButton *m_addBtn = nullptr;
189 QPushButton *m_loadObsBtn = nullptr;
190 QPushButton *m_removeBtn = nullptr;
191 QScrollArea *m_chartsScroll = nullptr;
192 QSplitter *m_chartsSplitter = nullptr;
193 QSplitter *m_chartsOuter = nullptr;
194 RangeSliderWidget *m_rangeSlider = nullptr;
195 QLabel *m_rangeLabel = nullptr;
196 QWidget *m_sliderHost = nullptr;
197 QWidget *m_leftHost = nullptr;
198 StatsSummaryPanel *m_statsPanel = nullptr;
199
200 // Slice AT.2 — top toolbar
201 QToolBar *m_toolBar = nullptr;
202 QActionGroup *m_modeActions = nullptr;
203 QAction *m_actSelect = nullptr;
204 QAction *m_actPan = nullptr;
205 QAction *m_actZoomIn = nullptr;
206 QAction *m_actZoomOut = nullptr;
207 QAction *m_actFit = nullptr;
208 QAction *m_actExport = nullptr;
209 QAction *m_actExportData = nullptr;
210 QAction *m_actAnimCursor = nullptr;
211 QAction *m_actAddSystem = nullptr;
212 QAction *m_actAddFromMap = nullptr;
213
214 // CP.1 — View toggles. Each is checkable + persistent across the
215 // session. Toggling "Charts Only" off snapshots the current visible
216 // state so the previous user-set splitter sizes restore on toggle-on.
217 QAction *m_actShowSeries = nullptr;
218 QAction *m_actShowStats = nullptr;
219 QAction *m_actShowSlider = nullptr;
220 QAction *m_actChartsOnly = nullptr;
221 QAction *m_actShow1v1 = nullptr;
222 QAction *m_actConfig1v1 = nullptr;
223
224 // Cached splitter sizes for restore when a pane is re-shown.
225 QList<int> m_savedSplitterSizes;
226 QList<int> m_savedChartsOuterSizes;
227
228 // Per-row chart bookkeeping. Key = row index in model->rows().
229 struct RowWidgets {
230 // Outer per-row frame placed into m_chartsSplitter.
231 QWidget *rowFrame = nullptr;
232
233 // Column 0 — time series.
234 InteractiveChartView *view = nullptr;
235 QChart *chart = nullptr;
236 openswmmvis::plot::UtcTimeAxis *xAxis = nullptr;
237 QValueAxis *yAxis = nullptr;
238 QLineSeries *cursorLine = nullptr;
239 QVector<QLineSeries*> series;
240 QVector<int> consumed;
241
242 // Column 1 — 1v1 scatter (visible only when ≥2 runs produce
243 // baseline↔comparison pairs). InteractiveChartView so toolbar
244 // modes + wheel zoom apply (COMPARISON_PLOT_1V1_AND_TREE_PLAN).
245 InteractiveChartView *scatterView = nullptr;
246 QChart *scatterChart = nullptr;
247 QValueAxis *scatterXAxis = nullptr;
248 QValueAxis *scatterYAxis = nullptr;
249 QLineSeries *identityLine = nullptr;
250 QVector<QScatterSeries*> scatterSeries;
251 };
252 QVector<RowWidgets> m_rowWidgets;
253
254 QDateTime m_curAnimTime;
255 bool m_syncingX = false;
256 bool m_showCursor = true;
257
258 // Slice AT.3 — full X-range of all loaded data, captured at rebuildCharts;
259 // used to map [0..1] from the range slider to absolute QDateTime bounds.
260 QDateTime m_xFullMin;
261 QDateTime m_xFullMax;
262 bool m_syncingSlider = false;
263
264 // AT.3 polish — cached Shift-drag X selection so Fit can refit Y to the
265 // windowed data when a selection is active.
266 QDateTime m_xSelLo;
267 QDateTime m_xSelHi;
268};
269
270} // namespace openswmmvis::ui
271
272#endif // OPENSWMMVIS_UI_DIALOGS_COMPARISONPLOTDIALOG_H
Definition swmm2dresultslayer.h:550
Overlays time-stepped simulation results on the SWMM network geometry.
Definition swmmresultslayer.h:96
Model layer for the Comparison Plot Dialog.
Definition comparisonplotmodel.h:118
Definition utctimeaxis.h:57
Definition comparisonplotdialog.h:65
void addFromMapToggled(bool active)
Slice AT.2 — emitted when the user toggles the "Add from Map…" toolbar action. The dialog itself does...
void setAddFromMapChecked(bool checked)
Slice AT.2 — programmatically set the Add-from-Map toolbar action's checked state....
Definition comparisonplotdialog.cpp:422
int addSeries(int runIndex, const openswmmvis::plot::ObjectRef &ref, openswmmvis::plot::PlotAttribute attr)
Convenience helper: add a series in one call. Returns the new series index, or -1 on failure.
Definition comparisonplotdialog.cpp:793
int ensureRunSourceForLayer(::SWMMResultsLayer *layer, bool makeBaseline=false)
Convenience helper: add a 1D RunSource for the given results layer (or update the existing one if alr...
Definition comparisonplotdialog.cpp:765
openswmmvis::plot::ComparisonPlotModel * model() noexcept
Underlying model — exposed so callers (Object Browser wiring, CF.3's openComparisonPlotForCells) can ...
Definition comparisonplotdialog.h:73
int addCellSeries(int runIndex, const QVector< int > &triIdxList, const QVector< openswmmvis::plot::PlotAttribute > &attributes)
CF.3 — add per-cell series for the supplied attribute list. Returns the count of series successfully ...
Definition comparisonplotdialog.cpp:838
int ensureRunSourceForMeshLayer(::SWMM2DResultsLayer *layer)
CF.3 — add a 2D RunSource for the given mesh results layer (or return the existing one) and return it...
Definition comparisonplotdialog.cpp:817
Definition interactivechartview.h:43
Definition rangeslider.h:32
Definition statssummarypanel.h:42
Slice BL — model layer for the Comparison Plot Dialog.
DiagramType t
Definition diagramspec.cpp:20
Definition chartproperties.h:34
PlotAttribute
What a series plots. One row per attribute in the Nx2 grid.
Definition plotattribute.h:38
Definition openswmmvislayer.h:43
EdgeRef ref
Definition pslgminsize.cpp:377
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
int pos
Definition queryparser.cpp:36
Identifies what object a series is about. Kind is the discriminator; the active union member is impli...
Definition irunlayer.h:38
One plottable result: a fixed attribute OR a species by name.
Definition resultdescriptor.h:39
One chart series — points at a RunSource via index and identifies what to read from it.
Definition comparisonplotmodel.h:51