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
swmmlinkpropertyadapter.h
Go to the documentation of this file.
1
15#ifndef SWMMLINKPROPERTYADAPTER_H
16#define SWMMLINKPROPERTYADAPTER_H
17
18#include <QObject>
19#include <QString>
20#include <QUuid> // Stats-source identity (QA.2 mirror)
21
22#include <openswmm/engine/openswmm_engine.h>
23
24#include "ui/properties/culvertcoderef.h" // ATTRIBUTE_EDITOR_WIRING Phase 0
26#include "ui/properties/initialqualityeditref.h" // Initial-quality UI round
27#include "ui/properties/linkcompoundeditref.h" // Slice SC.1
28#include "ui/properties/userflagseditref.h" // USER_FLAGS Phase 4
29
30class SWMMModelLayer;
31
32namespace openswmmvis { class OutputStatsRegistry; } // QA.2 mirror
33
38class SWMMLinkPropertyAdapter : public QObject
39{
40 Q_OBJECT
41
42public:
47 enum LinkKind { Conduit = 0, Pump = 1, Orifice = 2, Weir = 3, Outlet = 4 };
48 enum FlapGate { NO = 0, YES = 1 };
49 enum PumpInitState { OFF = 0, ON = 1 };
50 // Slice SD partial — orifice flow-attack classification. Mirrors
51 // SWMM_OrificeType in openswmm_links.h:34 and the legacy SWMM-GUI
52 // combo order in SWMM-GUI/Epaswmm5/objprops.txt:862.
53 enum OrificeType { SIDE = 0, BOTTOM = 1 };
54 // Slice SD partial (BN-LINK-03) — weir flow classification. Mirrors
55 // SWMM_WeirType in openswmm_links.h and the legacy combo at
56 // SWMM-GUI/Epaswmm5/objprops.txt:160. The companion "Shape" combo
57 // is derived from the type (see objprops.txt:162) — no separate
58 // Q_ENUM needed on the GUI side.
66 // Slice SD partial (BN-LINK-04) — outlet rating-curve classification.
67 // Mirrors SWMM_OutletRatingType in openswmm_links.h and the legacy
68 // combo at SWMM-GUI/Epaswmm5/objprops.txt:913. The four-value
69 // FUNCTIONAL×{HEAD,DEPTH} / TABULAR×{HEAD,DEPTH} grid drives
70 // conditional visibility of the exponent / curve picker rows.
77 Q_ENUM(LinkKind)
78 Q_ENUM(FlapGate)
79 Q_ENUM(PumpInitState)
80 Q_ENUM(OrificeType)
81 Q_ENUM(WeirType)
82 Q_ENUM(OutletRatingType)
83
84 // Common to every link type.
85 Q_PROPERTY(QString name READ name WRITE setName)
86 Q_PROPERTY(LinkKind linkKind READ linkKind)
87 Q_PROPERTY(QString fromNode READ fromNode)
88 Q_PROPERTY(QString toNode READ toNode)
95 Q_PROPERTY(QString tag READ tag WRITE setTag NOTIFY changed)
96
98 QObject *parent = nullptr);
99
104 void setModelLayer(SWMMModelLayer *layer) { m_layer = layer; }
105 [[nodiscard]] SWMMModelLayer *modelLayer() const { return m_layer; }
106
107 [[nodiscard]] QString name() const { return m_name; }
108 [[nodiscard]] LinkKind linkKind() const;
109 [[nodiscard]] QString fromNode() const;
110 [[nodiscard]] QString toNode() const;
111 [[nodiscard]] QString tag() const;
112
113 [[nodiscard]] double length() const;
114 [[nodiscard]] double roughness() const;
115 [[nodiscard]] double offsetUp() const;
116 [[nodiscard]] double offsetDn() const;
117 [[nodiscard]] double crestHeight() const;
118 [[nodiscard]] double dischargeCoeff() const;
119 [[nodiscard]] double endContractions() const;
120 [[nodiscard]] FlapGate flapGate() const;
121 [[nodiscard]] PumpInitState pumpInitState() const;
122 [[nodiscard]] QString pumpCurveName() const;
123 [[nodiscard]] OrificeType orificeType() const;
124 [[nodiscard]] WeirType weirType() const;
125 [[nodiscard]] OutletRatingType outletRatingType() const;
126 [[nodiscard]] double outletExpon() const;
127 [[nodiscard]] double pumpStartupDepth() const;
128 [[nodiscard]] double pumpShutoffDepth() const;
129 [[nodiscard]] double orificeOpenCloseRate() const;
130
131 // Slice SB — conduit scalar parity (matches legacy ConduitProps in
132 // SWMM-GUI/Epaswmm5/objprops.txt rows 12-17, 21). All accessors live
133 // on the base so the GETTER_D macro can be reused; only the
134 // SWMMConduitPropertyAdapter subclass exposes them as Q_PROPERTY rows
135 // because pumps / orifices / weirs / outlets don't carry these
136 // fields on the legacy editor side.
137 [[nodiscard]] double initialFlow() const;
138 [[nodiscard]] double maxFlow() const;
139 [[nodiscard]] double lossInlet() const;
140 [[nodiscard]] double lossOutlet() const;
141 [[nodiscard]] double lossAvg() const;
142 [[nodiscard]] double seepRate() const;
143 [[nodiscard]] int barrels() const;
144
145 // Direct inline cross-section geometry — geom1..geom4 of the engine
146 // xsect tuple, exposed alongside the compound `xsection` editor so the
147 // user can tweak a single dimension without opening the dialog. The
148 // engine has no per-geom setter, so each setter read-modify-writes the
149 // whole tuple (mirrors the loss-coeff slots). `xsectShapeId` lets the
150 // Property Browser grey out geoms that don't apply to the current
151 // shape (see openswmmvis::xsectGeomApplies).
152 [[nodiscard]] int xsectShapeId() const;
153 [[nodiscard]] double xsectGeom1() const;
154 [[nodiscard]] double xsectGeom2() const;
155 [[nodiscard]] double xsectGeom3() const;
156 [[nodiscard]] double xsectGeom4() const;
157
158 // Read-only post-run summary statistics (mirror of the node adapter's
159 // Slice QA.2 block and the Attribute Table's link dynamics columns).
160 // Zero until a run's results are bound via setStatsSource; the three
161 // pump utilisation getters are meaningful only on pumps.
162 [[nodiscard]] double statMaxFlow() const;
163 [[nodiscard]] double statMaxVelocity() const;
164 [[nodiscard]] double statMaxFilling() const;
165 [[nodiscard]] double statVolFlow() const;
166 [[nodiscard]] double statSurchargeTime() const;
167 [[nodiscard]] double statPumpCycles() const;
168 [[nodiscard]] double statPumpOnTime() const;
169 [[nodiscard]] double statPumpVolume() const;
170
176 [[nodiscard]] DataObjectRef pumpCurveRef() const;
177
182 [[nodiscard]] LinkCompoundEditRef xsectionRef() const;
183 [[nodiscard]] LinkCompoundEditRef inletUsageRef() const;
184
188 [[nodiscard]] CulvertCodeRef culvertCodeRef() const;
189
192 [[nodiscard]] UserFlagsEditRef userFlagsRef() const;
193
196 [[nodiscard]] InitialQualityEditRef initialQualityRef() const;
197
200 Q_INVOKABLE QString displayLabelFor(const QString &property) const;
201
202public slots:
203 void setName(const QString &newName);
204 void setTag(const QString &t);
205 void setLength(double v);
206 void setRoughness(double v);
207 void setOffsetUp(double v);
208 void setOffsetDn(double v);
209 void setCrestHeight(double v);
210 void setDischargeCoeff(double v);
211 void setEndContractions(double v);
212 void setFlapGate(FlapGate v);
215 void setWeirType(WeirType v);
217 void setOutletExpon(double v);
218 void setPumpStartupDepth(double v);
219 void setPumpShutoffDepth(double v);
220 void setOrificeOpenCloseRate(double v);
221 // Slice SB — conduit scalar setters. Loss-coefficient setters read
222 // the other two coefficients from the engine first then write the
223 // full triple via `swmm_link_set_loss_coeff` (atomic from a caller's
224 // view); the three rows look independent in the Property Browser
225 // but the three-coeff write is one engine call.
226 void setInitialFlow(double v);
227 void setMaxFlow(double v);
228 void setLossInlet(double v);
229 void setLossOutlet(double v);
230 void setLossAvg(double v);
231 void setSeepRate(double v);
232 void setBarrels(int v);
233 // Inline cross-section geom setters — read-modify-write the engine
234 // xsect tuple (shape + the other three geoms preserved). No-op when
235 // the geom doesn't apply to the current shape, so a stray write from
236 // a greyed cell can't corrupt the section.
237 void setXsectGeom1(double v);
238 void setXsectGeom2(double v);
239 void setXsectGeom3(double v);
240 void setXsectGeom4(double v);
244 void setPumpCurveRef(const DataObjectRef &ref);
245
259 void setUserFlagsRef(const UserFlagsEditRef &) { emit changed(); }
261 void setCulvertCodeRef(const CulvertCodeRef &) { emit changed(); }
263
265 void refresh() { emit changed(); }
266
268 void updateStoredName(const QString &newName) { m_name = newName; }
269
275 void setStatsSource(const QUuid &id);
276 [[nodiscard]] QUuid statsSourceId() const { return m_statsSourceId; }
277
278signals:
279 void changed();
280 void renameRequested(const QString &oldName, const QString &newName);
283
284protected:
285 [[nodiscard]] int linkIdx() const;
288 void writeXsectGeom(int ordinal, double v);
290 QString m_name;
292
296};
297
306{
307 Q_OBJECT
308 Q_PROPERTY(double length READ length WRITE setLength NOTIFY changed)
309 Q_PROPERTY(double roughness READ roughness WRITE setRoughness NOTIFY changed)
310 Q_PROPERTY(double offsetUp READ offsetUp WRITE setOffsetUp NOTIFY changed)
311 Q_PROPERTY(double offsetDn READ offsetDn WRITE setOffsetDn NOTIFY changed)
312 // Slice SB — conduit scalar parity rows. Loss coefficients are
313 // exposed as three separate Q_PROPERTYs per §S.1 Q-S4 decision.
314 Q_PROPERTY(double initialFlow READ initialFlow WRITE setInitialFlow NOTIFY changed)
315 Q_PROPERTY(double maxFlow READ maxFlow WRITE setMaxFlow NOTIFY changed)
316 Q_PROPERTY(double lossInlet READ lossInlet WRITE setLossInlet NOTIFY changed)
317 Q_PROPERTY(double lossOutlet READ lossOutlet WRITE setLossOutlet NOTIFY changed)
318 Q_PROPERTY(double lossAvg READ lossAvg WRITE setLossAvg NOTIFY changed)
319 Q_PROPERTY(double seepRate READ seepRate WRITE setSeepRate NOTIFY changed)
320 Q_PROPERTY(int barrels READ barrels WRITE setBarrels NOTIFY changed)
322 READ flapGate WRITE setFlapGate NOTIFY changed)
323 // Slice SC.1 — compound-attribute "Edit…" cells.
325 READ xsectionRef WRITE setXsectionRef NOTIFY changed)
326 // Direct inline geom1..geom4 (generic labels; PropertiesPanel greys
327 // out the ones that don't apply to the current shape).
328 Q_PROPERTY(double geom1 READ xsectGeom1 WRITE setXsectGeom1 NOTIFY changed)
329 Q_PROPERTY(double geom2 READ xsectGeom2 WRITE setXsectGeom2 NOTIFY changed)
330 Q_PROPERTY(double geom3 READ xsectGeom3 WRITE setXsectGeom3 NOTIFY changed)
331 Q_PROPERTY(double geom4 READ xsectGeom4 WRITE setXsectGeom4 NOTIFY changed)
333 READ culvertCodeRef WRITE setCulvertCodeRef NOTIFY changed)
335 READ inletUsageRef WRITE setInletUsageRef NOTIFY changed)
336 // Read-only post-run summary (no WRITE → non-editable). Mirrors the
337 // Attribute Table's link dynamics columns; values follow the bound
338 // stats source (see the base class).
339 Q_PROPERTY(double statMaxFlow READ statMaxFlow NOTIFY changed)
340 Q_PROPERTY(double statMaxVelocity READ statMaxVelocity NOTIFY changed)
341 Q_PROPERTY(double statMaxFilling READ statMaxFilling NOTIFY changed)
342 Q_PROPERTY(double statVolFlow READ statVolFlow NOTIFY changed)
343 Q_PROPERTY(double statSurchargeTime READ statSurchargeTime NOTIFY changed)
347 READ userFlagsRef WRITE setUserFlagsRef NOTIFY changed)
348public:
350};
351
357{
358 Q_OBJECT
359 // Slice BM.0-Browse-Edit (2026-05-25) — typed as DataObjectRef so the
360 // QPropertyItemDelegate hands out the picker editor (combo + browse
361 // button + right-click menu). Engine setter is swmm_link_set_pump_curve.
362 Q_PROPERTY(DataObjectRef pumpCurve
363 READ pumpCurveRef WRITE setPumpCurveRef NOTIFY changed)
365 READ pumpInitState WRITE setPumpInitState NOTIFY changed)
366 Q_PROPERTY(double startupDepth
368 Q_PROPERTY(double shutoffDepth
370 // Read-only post-run summary — the shared link block plus the pump
371 // utilisation trio (Attribute Table parity; see the base class).
372 Q_PROPERTY(double statMaxFlow READ statMaxFlow NOTIFY changed)
373 Q_PROPERTY(double statMaxVelocity READ statMaxVelocity NOTIFY changed)
374 Q_PROPERTY(double statMaxFilling READ statMaxFilling NOTIFY changed)
375 Q_PROPERTY(double statVolFlow READ statVolFlow NOTIFY changed)
376 Q_PROPERTY(double statSurchargeTime READ statSurchargeTime NOTIFY changed)
377 Q_PROPERTY(double statPumpCycles READ statPumpCycles NOTIFY changed)
378 Q_PROPERTY(double statPumpOnTime READ statPumpOnTime NOTIFY changed)
379 Q_PROPERTY(double statPumpVolume READ statPumpVolume NOTIFY changed)
383 READ userFlagsRef WRITE setUserFlagsRef NOTIFY changed)
384public:
386};
387
395{
396 Q_OBJECT
397 // Slice SD partial (2026-05-25) — orifice TYPE row, engine-backed via
398 // BN-LINK-02 (swmm_link_get/set_orifice_type). Sits at the top of the
399 // form matching legacy OrificeProps[5] row order.
401 READ orificeType WRITE setOrificeType NOTIFY changed)
402 Q_PROPERTY(double offset READ offsetUp WRITE setOffsetUp NOTIFY changed)
403 Q_PROPERTY(double dischargeCoeff READ dischargeCoeff WRITE setDischargeCoeff NOTIFY changed)
405 READ flapGate WRITE setFlapGate NOTIFY changed)
406 // Slice SD partial (BN-LINK-06) — orifice open/close rate (1/s).
407 // 0 = instantaneous. Legacy SWMM-GUI surfaces this as "Time to
408 // Open/Close (hr)" — clients that want the hours UX should
409 // convert before/after calling the setter.
410 Q_PROPERTY(double openCloseRate
413 READ xsectionRef WRITE setXsectionRef NOTIFY changed)
414 // Direct inline geom1..geom4 (orifices use CIRCULAR / RECT_CLOSED, so
415 // only geom1/geom2 ever apply; the rest grey out).
416 Q_PROPERTY(double geom1 READ xsectGeom1 WRITE setXsectGeom1 NOTIFY changed)
417 Q_PROPERTY(double geom2 READ xsectGeom2 WRITE setXsectGeom2 NOTIFY changed)
418 Q_PROPERTY(double geom3 READ xsectGeom3 WRITE setXsectGeom3 NOTIFY changed)
419 Q_PROPERTY(double geom4 READ xsectGeom4 WRITE setXsectGeom4 NOTIFY changed)
420 // Read-only post-run summary (Attribute Table parity; see base class).
421 Q_PROPERTY(double statMaxFlow READ statMaxFlow NOTIFY changed)
422 Q_PROPERTY(double statMaxVelocity READ statMaxVelocity NOTIFY changed)
423 Q_PROPERTY(double statMaxFilling READ statMaxFilling NOTIFY changed)
424 Q_PROPERTY(double statVolFlow READ statVolFlow NOTIFY changed)
425 Q_PROPERTY(double statSurchargeTime READ statSurchargeTime NOTIFY changed)
429 READ userFlagsRef WRITE setUserFlagsRef NOTIFY changed)
430public:
432};
433
443{
444 Q_OBJECT
445 // Slice SD partial (BN-LINK-03, 2026-05-25) — weir TYPE row sits at
446 // the top of the form matching legacy WeirProps[5] row order.
448 READ weirType WRITE setWeirType NOTIFY changed)
449 Q_PROPERTY(double offsetUp READ offsetUp WRITE setOffsetUp NOTIFY changed)
450 Q_PROPERTY(double offsetDn READ offsetDn WRITE setOffsetDn NOTIFY changed)
451 Q_PROPERTY(double crestHeight READ crestHeight WRITE setCrestHeight NOTIFY changed)
452 Q_PROPERTY(double dischargeCoeff READ dischargeCoeff WRITE setDischargeCoeff NOTIFY changed)
453 Q_PROPERTY(double endContractions READ endContractions WRITE setEndContractions NOTIFY changed)
455 READ flapGate WRITE setFlapGate NOTIFY changed)
457 READ xsectionRef WRITE setXsectionRef NOTIFY changed)
458 // Direct inline geom1..geom4 (weirs use RECT_OPEN / TRAPEZOIDAL /
459 // TRIANGULAR; inapplicable geoms grey out per shape).
460 Q_PROPERTY(double geom1 READ xsectGeom1 WRITE setXsectGeom1 NOTIFY changed)
461 Q_PROPERTY(double geom2 READ xsectGeom2 WRITE setXsectGeom2 NOTIFY changed)
462 Q_PROPERTY(double geom3 READ xsectGeom3 WRITE setXsectGeom3 NOTIFY changed)
463 Q_PROPERTY(double geom4 READ xsectGeom4 WRITE setXsectGeom4 NOTIFY changed)
464 // Read-only post-run summary (Attribute Table parity; see base class).
465 Q_PROPERTY(double statMaxFlow READ statMaxFlow NOTIFY changed)
466 Q_PROPERTY(double statMaxVelocity READ statMaxVelocity NOTIFY changed)
467 Q_PROPERTY(double statMaxFilling READ statMaxFilling NOTIFY changed)
468 Q_PROPERTY(double statVolFlow READ statVolFlow NOTIFY changed)
469 Q_PROPERTY(double statSurchargeTime READ statSurchargeTime NOTIFY changed)
473 READ userFlagsRef WRITE setUserFlagsRef NOTIFY changed)
474public:
476};
477
485{
486 Q_OBJECT
487 // Slice SD partial — rating-curve TYPE sits at the top to match
488 // legacy OutletProps[7] row order.
491 Q_PROPERTY(double offset READ offsetUp WRITE setOffsetUp NOTIFY changed)
492 // Functional-form coefficient (legacy "Coefficient" row) reuses
493 // the shared discharge-coeff scalar — same engine field (cd) used
494 // by orifices and weirs.
495 Q_PROPERTY(double coefficient READ dischargeCoeff WRITE setDischargeCoeff NOTIFY changed)
496 Q_PROPERTY(double expon READ outletExpon WRITE setOutletExpon NOTIFY changed)
497 // Tabular curve picker reuses the existing DataObjectRef pump-curve
498 // accessor (the engine shares the curve-index slot between pumps
499 // and tabular outlets per `LinksHandler::handle_outlets:229`).
500 Q_PROPERTY(DataObjectRef outletCurve
501 READ pumpCurveRef WRITE setPumpCurveRef NOTIFY changed)
503 READ flapGate WRITE setFlapGate NOTIFY changed)
504 // Read-only post-run summary (Attribute Table parity; see base class).
505 Q_PROPERTY(double statMaxFlow READ statMaxFlow NOTIFY changed)
506 Q_PROPERTY(double statMaxVelocity READ statMaxVelocity NOTIFY changed)
507 Q_PROPERTY(double statMaxFilling READ statMaxFilling NOTIFY changed)
508 Q_PROPERTY(double statVolFlow READ statVolFlow NOTIFY changed)
509 Q_PROPERTY(double statSurchargeTime READ statSurchargeTime NOTIFY changed)
513 READ userFlagsRef WRITE setUserFlagsRef NOTIFY changed)
514public:
516};
517
518#endif // SWMMLINKPROPERTYADAPTER_H
Definition swmmlinkpropertyadapter.h:306
int barrels
Definition swmmlinkpropertyadapter.h:320
double lossAvg
Definition swmmlinkpropertyadapter.h:318
SWMMLinkPropertyAdapter::FlapGate flapGate
Definition swmmlinkpropertyadapter.h:322
double statVolFlow
Definition swmmlinkpropertyadapter.h:342
double maxFlow
Definition swmmlinkpropertyadapter.h:315
double offsetUp
Definition swmmlinkpropertyadapter.h:310
double length
Definition swmmlinkpropertyadapter.h:308
double geom1
Definition swmmlinkpropertyadapter.h:328
UserFlagsEditRef userFlags
Definition swmmlinkpropertyadapter.h:347
double statMaxVelocity
Definition swmmlinkpropertyadapter.h:340
double roughness
Definition swmmlinkpropertyadapter.h:309
LinkCompoundEditRef xsection
Definition swmmlinkpropertyadapter.h:325
double offsetDn
Definition swmmlinkpropertyadapter.h:311
double lossOutlet
Definition swmmlinkpropertyadapter.h:317
double geom4
Definition swmmlinkpropertyadapter.h:331
double seepRate
Definition swmmlinkpropertyadapter.h:319
double statMaxFilling
Definition swmmlinkpropertyadapter.h:341
double lossInlet
Definition swmmlinkpropertyadapter.h:316
LinkCompoundEditRef inletUsage
Definition swmmlinkpropertyadapter.h:335
double geom3
Definition swmmlinkpropertyadapter.h:330
double statMaxFlow
Definition swmmlinkpropertyadapter.h:339
CulvertCodeRef culvertCode
Definition swmmlinkpropertyadapter.h:333
double geom2
Definition swmmlinkpropertyadapter.h:329
double initialFlow
Definition swmmlinkpropertyadapter.h:314
InitialQualityEditRef initialQuality
Definition swmmlinkpropertyadapter.h:345
double statSurchargeTime
Definition swmmlinkpropertyadapter.h:343
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
Definition swmmlinkpropertyadapter.h:395
Definition swmmlinkpropertyadapter.h:485
Definition swmmlinkpropertyadapter.h:357
Definition swmmlinkpropertyadapter.h:443
Definition outputstatsregistry.h:70
DiagramType t
Definition diagramspec.cpp:20
Definition aquiferprovider.h:21
void * SWMM_Engine
Definition objectdefaultsapplier.h:19
EdgeRef ref
Definition pslgminsize.cpp:377
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Definition culvertcoderef.h:32
Definition dataobjectref.h:34
Definition initialqualityeditref.h:27
Definition userflagseditref.h:29