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
mesheditingtoolbar.h
Go to the documentation of this file.
1
23#ifndef OPENSWMMVIS_UI_TOOLBARS_MESHEDITINGTOOLBAR_H
24#define OPENSWMMVIS_UI_TOOLBARS_MESHEDITINGTOOLBAR_H
25
26#include <QPair>
27#include <QPointF>
28#include <QPointer>
29#include <QToolBar>
30#include <QVector>
31
32#include <functional>
33
34namespace openswmmvis::ui { class RibbonGroup; }
35
36class MapCanvas;
38class SWMM2DMeshLayer;
39
40class QAction;
41class QActionGroup;
42class QComboBox;
43class QDoubleSpinBox;
44class QLabel;
45class QLineEdit;
46class QStackedWidget;
47class QToolButton;
48
49namespace mesh { class MeshHoverProbe; }
50
52struct SWMMObjectRef;
53
54class MeshEditingToolbar : public QToolBar
55{
56 Q_OBJECT
57public:
58 explicit MeshEditingToolbar(const QString &title, QWidget *parent = nullptr);
60
61protected:
63 void showEvent(QShowEvent *event) override;
64
65public:
66
72 void rebindCanvas(MapCanvas *canvas);
73
79
86 using PickerFn = std::function<QString(const QString &currentName)>;
87 void setStageTimeseriesPicker(PickerFn fn) { m_stageTSPicker = std::move(fn); }
88 void setFlowTimeseriesPicker(PickerFn fn) { m_flowTSPicker = std::move(fn); }
89 void setRatingCurvePicker(PickerFn fn) { m_curvePicker = std::move(fn); }
90
96 using ListerFn = std::function<QStringList()>;
97 void setTimeseriesLister(ListerFn fn) { m_tsLister = std::move(fn); }
98 void setCurveLister(ListerFn fn) { m_curveLister = std::move(fn); }
100 void setNodeLister(ListerFn fn) { m_nodeLister = std::move(fn); }
103 using NodeLocatorFn = std::function<QVector<QPair<QString, QPointF>>()>;
104 void setNodeLocator(NodeLocatorFn fn) { m_nodeLocator = std::move(fn); }
105 void refreshBCNameLists(); // re-query listers + repopulate combos
106 void refreshNodeList(); // re-query node lister + repopulate the combo
107
112 void addToolAction(QAction *action);
113 void addToolSeparator();
114
118 void addProfileAction(QAction *action);
119
123 QAction *addToolWidget(QWidget *widget);
124
127 [[nodiscard]] QLabel *cellInfoLabel() const { return m_cellInfoLbl; }
128
138 [[nodiscard]] QWidget *cellParamEditorWidget() const;
139 [[nodiscard]] QWidget *cellTagWidget() const;
140 void setCellEditorActions(QAction *paramAct, QAction *tagAct);
141
149 void addCellAction(QAction *action);
150
153 [[nodiscard]] QByteArray currentCellParamKey() const;
154
157 void setDepthUnitLabel(const QString &label);
158
159 [[nodiscard]] SWMM2DMeshLayer *activeMesh() const { return m_activeMesh; }
160
161signals:
165 void editVertexToggled(bool active);
166
168 void editEdgeToggled(bool active);
169
174 void hoverElevationChanged(double z, bool finite);
175
176private slots:
177 void onActiveMeshComboChanged(int index);
178 void onLayerAdded(OpenSWMMVisLayer *layer);
179 void onLayerRemoved(OpenSWMMVisLayer *layer);
180 void onActiveMeshFlagChanged(bool isActive);
181 void onAttributeChanged(const QString &refName);
182 void onHoverElevation(double z, bool finite);
183 void onZSpinChanged(double z);
184 void onVertexTagCommit(); // descriptive vertex tag → selected vertex
185 void onVertexCoupledCommit(); // coupled SWMM node → selected vertex
186 void onVertexCdCommit(); // coupling Cd → selected coupled vertices
187 void onVertexAreaCommit(); // coupling area → selected coupled vertices
188 void onAutoCoupleClicked(); // couple vertices to coincident SWMM nodes
189 void onRemapClicked(); // Remap 1D↔2D: vertex + cell coupling (Plan C.4)
190
193 [[nodiscard]] QString meshAreaUnitLabel() const;
194 void onCellParamCommit(); // selected parameter → selected cells
195 void onCellEnumCommit(int index); // Kind::Enum editor → selected cells
196 void onCellParamChanged(int index); // reconfigure the value editor
197 void onCellTagCommit(); // descriptive triangle tag → selected cell
198 void onSelectionChanged();
199 void onBCTypeChanged(int index);
200 void commitBCParam(); // apply-as-you-go: write current param to selected edges
201 void commitConveyance(); // apply-as-you-go: ψ → every selected edge (interior + boundary)
202 void onBrowseBCObject(); // shared "…" → dispatches to right CRUD picker
203 void onPickStageTseries();
204 void onPickFlowTseries();
205 void onPickRatingCurve();
206
207private:
213 bool m_bcListsStale = false;
214
219 bool m_nodeListStale = false;
220
221 void rebuildMeshCombo();
222 void refreshGroupWidths(); // re-measure the ribbon groups after
223 // contextual clusters show/hide
224 void connectMeshLayer(SWMM2DMeshLayer *layer);
225 void disconnectMeshLayer(SWMM2DMeshLayer *layer);
226 void refreshVertexEditor();
227 void refreshEdgeEditor();
228 void refreshCellEditor();
229 void updateEnabledState();
237 void commitCellParam(double value);
238
239 QList<int> currentSelectedVertices() const; // all selected vertex indices
240 QList<QPair<int,int>> currentSelectedEdges() const; // (tri, eLocal) pairs
241 QList<int> currentSelectedCells() const; // all selected triangle indices
242
243 // Iteration 3 — captioned ribbon groups, each hosting a mini
244 // toolbar so the action-based show/hide machinery keeps working.
245 QList<openswmmvis::ui::RibbonGroup *> m_groups;
246 QToolBar *m_barMesh = nullptr;
247 QToolBar *m_barVertices = nullptr;
248 QToolBar *m_barEdges = nullptr;
249 QToolBar *m_barCoupling = nullptr;
250 QToolBar *m_barResults = nullptr; // Pick cells cluster (SWMMVis inserts)
251 QToolBar *m_barProfile = nullptr; // standalone profile plotter
252
253 QPointer<MapCanvas> m_canvas;
254 QPointer<SelectionManager> m_selection;
255 QPointer<SWMM2DMeshLayer> m_activeMesh;
256 mesh::MeshHoverProbe *m_hover = nullptr;
257
258 // Top row
259 QComboBox *m_meshCombo = nullptr;
260 QLabel *m_hoverLabel = nullptr;
261 QAction *m_spacerAction = nullptr; // trailing stretch; tool actions insert before it
262
263 // Edit mode toggles
264 QAction *m_actEditVertex = nullptr;
265 QAction *m_actEditEdge = nullptr;
266 QActionGroup *m_editGroup = nullptr;
267
268 // Vertex Z editor
269 QLabel *m_vertexInfoLbl = nullptr;
270 QDoubleSpinBox*m_zSpin = nullptr;
271 QLineEdit *m_vertexTagEdit = nullptr; // descriptive tag
272 QComboBox *m_vertexCoupledCombo = nullptr;// coupled SWMM node (dropdown)
273 QAction *m_actVertexTag = nullptr; // embedding actions for hide
274 QAction *m_actVertexCoupled = nullptr;
275 QDoubleSpinBox*m_vertexCdSpin = nullptr; // coupling Cd ([2D_VERTEX_NODE_MAP] CD)
276 QDoubleSpinBox*m_vertexAreaSpin = nullptr; // coupling exchange area, m² (AREA)
277 QAction *m_actVertexCd = nullptr; // embedding actions for hide
278 QAction *m_actVertexArea = nullptr;
279 QAction *m_actAutoCouple = nullptr; // couple vertices to coincident nodes
280 QAction *m_actRemap = nullptr; // Remap 1D↔2D (Plan C.4)
281
282 // BC controls (Slice §V.VC — fully wired for all 7 GUI BC types).
283 QComboBox *m_bcTypeCombo = nullptr;
284 QStackedWidget*m_bcParamStack = nullptr;
285 QAction *m_actBrowseObj = nullptr; // launches TS / Curve CRUD dialog
286 QLabel *m_edgeInfoLbl = nullptr;
287 // addWidget() handles for the BC combo + param stack so they can be
288 // shown/hidden contextually (hiding the QAction collapses the gap).
289 QAction *m_actBCTypeCombo = nullptr;
290 QAction *m_actBCParamStack = nullptr;
291
292 // Cell-selection info label (after the Select-2D-Cells tool).
293 QLabel *m_cellInfoLbl = nullptr;
294 // Cell parameter page: "<parameter> [value]" — one editor for every
295 // per-cell attribute in mesh::cellParamSpecs().
296 QWidget *m_cellParamPage = nullptr;
297 QComboBox *m_cellParamCombo = nullptr;
298 QDoubleSpinBox*m_cellValueSpin = nullptr;
299 // Value editor for CellParamSpec::Kind::Enum parameters (infiltration
300 // method). Shares the slot the spin box occupies — exactly one of the two
301 // is visible, chosen by the selected parameter's kind. A −1…5 numeric
302 // spinner for an enumeration is not an editor, it is a puzzle.
303 QComboBox *m_cellEnumCombo = nullptr;
304 QLineEdit *m_cellTagEdit = nullptr; // descriptive triangle tag
305 QAction *m_actCellParam = nullptr; // embedding actions for hide
306 QAction *m_actCellTag = nullptr;
307 QAction *m_actCellInfil = nullptr; // "Assign Infiltration to Selection…"
308 // Project depth unit ("ft"/"m") shown on length-valued parameters.
309 QString m_depthUnitLabel = QStringLiteral("m");
310
311 // Param-page widgets (held directly so the apply path reads values
312 // without going through QStackedWidget::currentWidget casts).
313 QDoubleSpinBox*m_slopeSpin = nullptr; // NormalFlow
314 QDoubleSpinBox*m_stageSpin = nullptr; // SpecifiedStageConst
315 QComboBox *m_stageTSCombo = nullptr; // SpecifiedStageTS — editable combo over registry
316 QDoubleSpinBox*m_flowSpin = nullptr; // SpecifiedFlowConst
317 QComboBox *m_flowTSCombo = nullptr; // SpecifiedFlowTS — editable combo over registry
318 QComboBox *m_curveCombo = nullptr; // RatingCurve — editable combo over registry
319
320 // Engine §11A — per-edge flux attenuation (conveyance) widget. Lives
321 // OUTSIDE the BC param stack because it applies to every edge (interior
322 // and boundary), not just boundary edges. Visibility tracks edgeMode +
323 // any selected edge (independent of haveBoundaryEdge).
324 QDoubleSpinBox*m_conveySpin = nullptr;
325 QAction *m_actConveySpin = nullptr;
326
327 bool m_suppressZSignal = false;
332 bool m_refreshingEdgeEditor = false;
333
334 PickerFn m_stageTSPicker;
335 PickerFn m_flowTSPicker;
336 PickerFn m_curvePicker;
337
338 ListerFn m_tsLister;
339 ListerFn m_curveLister;
340 ListerFn m_nodeLister;
341 NodeLocatorFn m_nodeLocator;
342};
343
344#endif // OPENSWMMVIS_UI_TOOLBARS_MESHEDITINGTOOLBAR_H
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
Definition mesheditingtoolbar.h:55
void setRatingCurvePicker(PickerFn fn)
Definition mesheditingtoolbar.h:89
void setFlowTimeseriesPicker(PickerFn fn)
Definition mesheditingtoolbar.h:88
QLabel * cellInfoLabel() const
The cell-selection info label (created in the ctor; placed by SWMMVis right after the Select-2D-Cells...
Definition mesheditingtoolbar.h:127
void rebindCanvas(MapCanvas *canvas)
Bind the toolbar to a new project canvas. Disconnects from the previous canvas's signals,...
Definition mesheditingtoolbar.cpp:605
SWMM2DMeshLayer * activeMesh() const
Definition mesheditingtoolbar.h:159
void addToolAction(QAction *action)
Add a trailing tool action (e.g. Pick 2D Cells / Trace Profile) to the left of the expanding spacer s...
Definition mesheditingtoolbar.cpp:568
void showEvent(QShowEvent *event) override
Flushes a node-list refresh that was deferred while hidden.
Definition mesheditingtoolbar.cpp:1806
void setTimeseriesLister(ListerFn fn)
Definition mesheditingtoolbar.h:97
QWidget * cellTagWidget() const
Definition mesheditingtoolbar.cpp:543
~MeshEditingToolbar() override
void rebindSelectionManager(SelectionManager *sel)
Bind the toolbar to a project's SelectionManager so the spinbox / edge-info label update when selecti...
Definition mesheditingtoolbar.cpp:651
void refreshNodeList()
Definition mesheditingtoolbar.cpp:1812
void addToolSeparator()
Definition mesheditingtoolbar.cpp:575
void editVertexToggled(bool active)
Emitted when the user toggles the Edit Vertex action. SWMMVis hooks this to activate / deactivate Map...
std::function< QString(const QString &currentName)> PickerFn
Install a callback that opens a timeseries picker dialog and returns the picked name (empty = user ca...
Definition mesheditingtoolbar.h:86
QByteArray currentCellParamKey() const
Key of the parameter currently shown in the cell editor (mesh::CellParamSpec::key)....
Definition mesheditingtoolbar.cpp:545
std::function< QStringList()> ListerFn
Install lister callbacks that return the available timeseries / curve names for the project....
Definition mesheditingtoolbar.h:96
QAction * addToolWidget(QWidget *widget)
Add a trailing widget (e.g. the cell-selection info label) to the left of the expanding spacer,...
Definition mesheditingtoolbar.cpp:581
void setNodeLister(ListerFn fn)
Lister of couplable SWMM node ids for the coupled-node dropdown.
Definition mesheditingtoolbar.h:100
void addProfileAction(QAction *action)
Add the mesh profile-plot action to its standalone "Profile" ribbon group (iteration 4 — kept apart f...
Definition mesheditingtoolbar.cpp:595
void editEdgeToggled(bool active)
Emitted when the user toggles the Edit Edge action.
void refreshBCNameLists()
Definition mesheditingtoolbar.cpp:1778
void setStageTimeseriesPicker(PickerFn fn)
Definition mesheditingtoolbar.h:87
void hoverElevationChanged(double z, bool finite)
Mirrors the mesh hover-Z probe outward (finite false = cursor off-mesh). SWMMVis feeds this into the ...
QWidget * cellParamEditorWidget() const
Per-cell editor widgets. The first is a parameter page — a combo naming the attribute to prescribe (M...
Definition mesheditingtoolbar.cpp:542
void setNodeLocator(NodeLocatorFn fn)
Definition mesheditingtoolbar.h:104
void setDepthUnitLabel(const QString &label)
Project depth unit ("ft" / "m") shown on length-valued cell parameters. Set by SWMMVis on each projec...
Definition mesheditingtoolbar.cpp:558
void addCellAction(QAction *action)
Place a cell-scoped action (currently "Assign Infiltration to Selection…") in the 2D-cell cluster,...
Definition mesheditingtoolbar.cpp:587
std::function< QVector< QPair< QString, QPointF > >()> NodeLocatorFn
Locator of SWMM node ids + map coordinates ([COORDINATES], same CRS as the mesh vertices) for the Aut...
Definition mesheditingtoolbar.h:103
void setCurveLister(ListerFn fn)
Definition mesheditingtoolbar.h:98
void setCellEditorActions(QAction *paramAct, QAction *tagAct)
Definition mesheditingtoolbar.cpp:551
Abstract base class for all layers displayed in the MapCanvas.
Definition openswmmvislayer.h:116
Definition swmm2dmeshlayer.h:64
Owner of the canonical selection set for one SWMM project.
Definition selectionmanager.h:112
Definition meshhoverprobe.h:31
const char * label
Human label for the filter entry.
Definition gdaldrivers.cpp:22
int index
Position in m_quadRegions / m_quadReports.
Definition meshgenerator.cpp:153
Definition meshcommands.h:302
Definition openswmmvislayer.h:43
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
const char * title
Definition snowpackeditordialog.cpp:71
Identifies a single SWMM object.
Definition selectionmanager.h:32