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
profileplotdialog.h
Go to the documentation of this file.
1
17#ifndef PROFILE_PLOT_DIALOG_H
18#define PROFILE_PLOT_DIALOG_H
19
20#include "plot/plotattribute.h"
23#include "plot/profilebuilder.h"
24#include "plot/profilerouter.h"
27#include "selection/selectionmanager.h" // SWMMObjectRef (AT.3)
28
29#include <QDateTime>
30#include <QDialog>
31#include <QBrush>
32#include <QHash>
33#include <QPointer>
34#include <QTimer>
35#include <QPen>
36#include <QPointF>
37#include <QPointer>
38#include <QSet>
39#include <QVector>
40
41#include <functional>
42#include <memory>
43
45class GISRasterLayer;
46class MapCanvas;
50class QAction;
51class QMenu;
52class QProgressBar;
53class QScrollArea;
54class QSplitter;
55class QToolButton;
57class SWMMModelLayer;
60
61class ProfilePlotDialog : public QDialog
62{
63 Q_OBJECT
64
65public:
83 SWMMVisProjectWindow *projectWindow,
84 QWidget *parent = nullptr);
85
93 ~ProfilePlotDialog() override;
94
95protected:
102 void showEvent(QShowEvent *event) override;
103
109 bool eventFilter(QObject *watched, QEvent *event) override;
110
111signals:
121 const openswmmvis::plot::ResultDescriptor &descriptor);
122
123private slots:
128 void rebindSources();
129
134 void onAnimationTimeChanged(const QDateTime &dt);
135
139 void onSourceActionToggled();
140
141private:
142 void buildLayout();
143 void populateSourcesPanel();
144
145 // ── Attribute tracks (synced pane below the profile) ────────────────
146
150 void buildAttributeTracksUi(class QToolBar *toolbar);
151
155 void rebuildTracks();
156
159 void updateTracksPaneVisibility();
160
164 void ensureTracksPaneExpanded();
165
168 void syncTracksAxes();
169
175 void syncTracksGutter();
176
184 void rebuildTerrainSamples();
185
192 void forEachPathStation(
193 const std::function<void(double, double, double)> &fn) const;
194
198 void forEachPathStationScene(
199 const std::function<void(double, const QPointF &)> &fn) const;
200
203 class SWMM2DMeshLayer *firstMeshLayer() const;
204
207 ProfilePlotOptions::GroundSource resolvedGroundSource() const;
208
209 QPointer<class SWMM2DMeshLayer> m_groundMesh;
211
212 // ── 2D inundation overlay ───────────────────────────────────────────
213
216 struct Surface2DStation
217 {
218 double chainage = 0.0;
219 QPointF scenePt;
220 int triIdx = -1;
221 double bed = 0.0;
222 };
223
231 void rebuildSurface2DStations();
232
235 void refreshSurface2DDepths();
236
237 QVector<Surface2DStation> m_surface2D;
238 QPointer<class SWMM2DResultsLayer> m_surface2DLayer;
239 QAction *m_actShow2D = nullptr;
240
241 QPointer<SWMMModelLayer> m_model;
242 QPointer<MapCanvas> m_canvas;
243 QPointer<SWMMVisProjectWindow> m_projectWindow;
244 QPointer<AnimationController> m_anim;
245 ProfileRouter::Path m_routerPath;
246 ProfileBuilder::PathStatic m_pathStatic;
247
248 // Project windows we've subscribed to `aboutToClose` (deduped). May
249 // include the primary `m_projectWindow` plus any project that owns a
250 // result layer currently bound as a source. Raw pointers are safe
251 // here because we manually remove entries in our handler before any
252 // project teardown begins (see `onObservedProjectAboutToClose`).
253 QSet<SWMMVisProjectWindow *> m_observedProjects;
254
255 void subscribeProjectClose(SWMMVisProjectWindow *pw);
256 void onObservedProjectAboutToClose(SWMMVisProjectWindow *pw);
257
258 ProfilePlotWidget *m_plot = nullptr;
259 ProfileLayerPanel *m_layerPanel = nullptr;
260 QToolButton *m_sourceButton = nullptr;
261 QMenu *m_sourceMenu = nullptr;
262 QProgressBar *m_loadingBar = nullptr;
263 int m_loadCookie = 0; // ignores stale watcher returns
264 ProfilePlotOptions *m_options = nullptr;
265
266 // ── Attribute tracks state ──────────────────────────────────────────
267 ProfileAttributeTrackOptions *m_trackOptions = nullptr;
268 ProfileAttributeTracksWidget *m_tracks = nullptr;
269 QScrollArea *m_tracksScroll = nullptr;
270 QWidget *m_plotHolder = nullptr;
271 QSplitter *m_profileSplit = nullptr;
272 QMenu *m_tracksMenu = nullptr;
273 QAction *m_actShowTracks = nullptr;
277 QAction *m_tracksLinkSection = nullptr;
280 QList<QAction *> m_speciesTrackActions;
281 int m_trackLoadCookie = 0;
282 bool m_syncingX = false;
283 QList<int> m_lastSplitSizes;
284
287 void refreshTracksMenuSpecies();
288
294 QHash<QPair<SWMMResultsLayer *, QString>,
295 std::shared_ptr<const ProfileAttributeSampler::AttributeProfile>>
296 m_attrCache;
297 // Live-run throttle for the attribute-track re-read (appendLivePeriods):
298 // the tracks re-fetch their whole period range from the .out, so at most
299 // once per 2 s (leading edge; a pending tick re-reads at expiry).
300 QTimer m_liveTracksThrottle;
301 bool m_liveTracksPending = false;
302 bool m_liveTracksWired = false;
303 QPointer<SWMMResultsLayer> m_liveTracksLayer;
304
305 // Layer pointer (non-owning) per menu action.
306 QHash<QAction *, QPointer<SWMMResultsLayer>> m_actionLayer;
307
308 // Per-layer cache of computed profile data. Populated lazily by
309 // rebindSources(); invalidated on `resultsOpened`,
310 // `resultsFilePathChanged`, or layer destruction so subsequent UI
311 // option toggles reuse the cached `SourceDerived` instead of
312 // refetching the .out file every time. `m_cacheWired` tracks the
313 // layers we've already connected invalidation signals on to avoid
314 // duplicate connections.
315 QHash<SWMMResultsLayer *,
316 std::shared_ptr<ProfileBuilder::SourceDerived>> m_sourceCache;
321 QHash<SWMMResultsLayer *,
322 std::shared_ptr<ProfileBuilder::SourceSeries>> m_sourceSeriesCache;
326 int m_rebindsInFlight = 0;
327 QSet<SWMMResultsLayer *> m_cacheWired;
328 void invalidateSourceCacheFor(SWMMResultsLayer *layer);
329 void ensureCacheInvalidationWired(SWMMResultsLayer *layer);
330
335 void appendLivePeriods(SWMMResultsLayer *layer);
336
355 bool pushEditedPlotStylesToSources();
356
359 struct PlotStyleSnapshot {
360 QPen hglLinePen;
361 QBrush hglFillBrush;
362 QPen eglLinePen;
363 QPen maxHglLinePen;
364 QBrush maxHglFillBrush;
365 QPen maxEglLinePen;
366 bool seeded = false;
367 } m_lastPlotStyle;
368};
369
370#endif // PROFILE_PLOT_DIALOG_H
Central coordinator for result-layer time-stepping and playback.
Definition animationcontroller.h:43
A map layer backed by a GDAL raster dataset.
Definition gisrasterlayer.h:61
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
Definition profileattributetrackoptions.h:35
Definition profileattributetrackswidget.h:45
Definition profilelayerpanel.h:31
Definition profileplotdialog.h:62
bool eventFilter(QObject *watched, QEvent *event) override
Watches the tracks widget for resizes so the profile's right gutter can absorb the tracks scroll area...
Definition profileplotdialog.cpp:1959
void showEvent(QShowEvent *event) override
After DialogLayoutWatcher restores the splitter state on this first Show, makes sure a shown attribut...
Definition profileplotdialog.cpp:1945
void plotAttributeRequested(const SWMMObjectRef &ref, const openswmmvis::plot::ResultDescriptor &descriptor)
Emitted when the user picks a specific variable from the "Plot Time Series…" submenu on a node / link...
~ProfilePlotDialog() override
Sever every external signal/slot connection while children are still alive so that any cross-window t...
Definition profileplotdialog.cpp:189
Definition profileplotoptions.h:28
GroundSource
Ground-line source. Auto resolves to Mesh2D when the project has a 2D mesh layer, else NodeRims.
Definition profileplotoptions.h:79
@ NodeRims
Definition profileplotoptions.h:79
Definition profileplotwidget.h:58
Definition swmm2dmeshlayer.h:64
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
Overlays time-stepped simulation results on the SWMM network geometry.
Definition swmmresultslayer.h:96
MDI sub-window owning a MapCanvas, SWMMModelLayer, and map tools.
Definition swmmvisprojectwindow.h:58
Represents a coordinate reference system backed by a GDAL OGRSpatialReference.
Definition spatialreferencesystem.h:28
Slice BL — canonical enumeration of plottable result attributes.
Attribute-tracks feature — fetches an along-the-path profile of one generic result attribute (node de...
Pure-logic data assembly for Slice BC's longitudinal profile plot: chainage, HGL/EGL time-series,...
Q_OBJECT facade for every user-configurable display option on the profile plot. Both the per-dialog L...
Slice BC's longitudinal section renderer.
Path-routing primitives over an abstract weighted graph, used by Slice BC's profile-path picker.
EdgeRef ref
Definition pslgminsize.cpp:377
int path
Definition pslgminsize.cpp:234
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Y2b-1 (amendment D-Y4) — one plottable result, fixed or species.
A fully-resolved profile path: ordered nodes, joining links, and cumulative chainage from nodes[0] to...
Definition profilebuilder.h:242
A single candidate path: ordered node sequence (length N+1) of engine node indices,...
Definition profilerouter.h:80
Identifies a single SWMM object.
Definition selectionmanager.h:32
One plottable result: a fixed attribute OR a species by name.
Definition resultdescriptor.h:39