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
xsectshapegeom.h
Go to the documentation of this file.
1
18#ifndef XSECTSHAPEGEOM_H
19#define XSECTSHAPEGEOM_H
20
21#include <QString>
22
23#include <openswmm/engine/openswmm_links.h>
24
25namespace openswmmvis {
26
40 const char *name;
42 const char *geom1Label;
43 const char *geom2Label;
44 const char *geom3Label;
45 const char *geom4Label;
46};
47
51inline constexpr int kXsectIrregularId = SWMM_XSECT_IRREGULAR;
52inline constexpr int kXsectStreetId = SWMM_XSECT_STREET;
57inline constexpr int kXsectCustomId = SWMM_XSECT_CUSTOM;
58
59inline constexpr XsectShapeRow kXsectShapes[] = {
60 { "CIRCULAR", SWMM_XSECT_CIRCULAR, "Diameter", "", "", "" },
61 { "FILLED_CIRCULAR", SWMM_XSECT_FILLED_CIRCULAR,"Diameter", "Filled Depth", "", "" },
62 { "RECT_CLOSED", SWMM_XSECT_RECT_CLOSED, "Max Depth", "Width", "", "" },
63 { "RECT_OPEN", SWMM_XSECT_RECT_OPEN, "Max Depth", "Width", "", "" },
64 { "TRAPEZOIDAL", SWMM_XSECT_TRAPEZOIDAL, "Max Depth", "Bottom Width", "Left Slope", "Right Slope" },
65 { "TRIANGULAR", SWMM_XSECT_TRIANGULAR, "Max Depth", "Top Width", "", "" },
66 { "PARABOLIC", SWMM_XSECT_PARABOLIC, "Max Depth", "Top Width", "", "" },
67 { "POWER", SWMM_XSECT_POWER, "Max Depth", "Top Width", "Exponent", "" },
68 { "RECT_TRIANGULAR", SWMM_XSECT_RECT_TRIANG, "Max Depth", "Top Width", "Triangle Height","" },
69 { "RECT_ROUND", SWMM_XSECT_RECT_ROUND, "Max Depth", "Top Width", "Bottom Radius", "" },
70 { "MOD_BASKETHANDLE",SWMM_XSECT_MOD_BASKET, "Max Depth", "Bottom Width", "Top Radius", "" },
71 { "HORIZ_ELLIPSE", SWMM_XSECT_HORIZ_ELLIPSE, "Max Height","Max Width", "", "" },
72 { "VERT_ELLIPSE", SWMM_XSECT_VERT_ELLIPSE, "Max Height","Max Width", "", "" },
73 { "ARCH", SWMM_XSECT_ARCH, "Max Height","Max Width", "", "" },
74 { "EGGSHAPED", SWMM_XSECT_EGGSHAPED, "Max Depth", "", "", "" },
75 { "HORSESHOE", SWMM_XSECT_HORSESHOE, "Max Depth", "", "", "" },
76 { "GOTHIC", SWMM_XSECT_GOTHIC, "Max Depth", "", "", "" },
77 { "CATENARY", SWMM_XSECT_CATENARY, "Max Depth", "", "", "" },
78 { "SEMIELLIPTICAL", SWMM_XSECT_SEMIELLIPTICAL, "Max Depth", "", "", "" },
79 // Slice SP.3 — the five shapes the engine has always supported but the
80 // picker never surfaced (they had no SVG artwork; the section preview now
81 // draws every shape procedurally, so the gap is closed).
82 { "BASKETHANDLE", SWMM_XSECT_BASKETHANDLE, "Max Depth", "", "", "" },
83 { "SEMICIRCULAR", SWMM_XSECT_SEMICIRCULAR, "Max Depth", "", "", "" },
84 // FORCE_MAIN is geometrically a circular pipe; geom2 selects the friction
85 // law's coefficient (Hazen-Williams C or Darcy-Weisbach roughness height),
86 // NOT a dimension — hence the explicit label.
87 { "FORCE_MAIN", SWMM_XSECT_FORCE_MAIN, "Diameter", "Roughness (C or e)", "", "" },
88 { "IRREGULAR", SWMM_XSECT_IRREGULAR, "Transect (index)", "", "", "" },
89 { "CUSTOM", SWMM_XSECT_CUSTOM, "Max Depth", "Shape Curve (index)", "", "" },
90 { "STREET", SWMM_XSECT_STREET, "Street (index)", "", "", "" },
91 // DUMMY carries no geometry at all: it exists so a link can be routed
92 // without conveyance. No geom is editable.
93 { "DUMMY", SWMM_XSECT_DUMMY, "", "", "", "" },
94};
95
98inline const XsectShapeRow *findXsectShapeRow(int engineId)
99{
100 for (const auto &r : kXsectShapes) {
101 if (r.engineId == engineId) return &r;
102 }
103 return &kXsectShapes[0];
104}
105
112inline QString xsectShapeName(int engineId)
113{
114 for (const auto &r : kXsectShapes) {
115 if (r.engineId == engineId) return QString::fromLatin1(r.name);
116 }
117 return {};
118}
119
123inline QString xsectGeomLabel(int shapeId, int ordinal)
124{
125 const XsectShapeRow *r = findXsectShapeRow(shapeId);
126 const char *lbl = nullptr;
127 switch (ordinal) {
128 case 1: lbl = r->geom1Label; break;
129 case 2: lbl = r->geom2Label; break;
130 case 3: lbl = r->geom3Label; break;
131 case 4: lbl = r->geom4Label; break;
132 default: return {};
133 }
134 return (lbl && *lbl) ? QString::fromLatin1(lbl) : QString();
135}
136
148inline bool xsectGeomApplies(int shapeId, int ordinal)
149{
150 if (shapeId == kXsectIrregularId || shapeId == kXsectStreetId)
151 return false;
152 if (shapeId == kXsectCustomId && ordinal == 2)
153 return false;
154 return !xsectGeomLabel(shapeId, ordinal).isEmpty();
155}
156
168inline bool xsectGeomIsPickerIndex(int shapeId, int ordinal)
169{
170 if (ordinal == 1
171 && (shapeId == kXsectIrregularId || shapeId == kXsectStreetId))
172 return true;
173 return shapeId == kXsectCustomId && ordinal == 2;
174}
175
176} // namespace openswmmvis
177
178#endif // XSECTSHAPEGEOM_H
Definition aquiferprovider.h:21
constexpr int kXsectStreetId
Definition xsectshapegeom.h:52
QString xsectGeomLabel(int shapeId, int ordinal)
Definition xsectshapegeom.h:123
const XsectShapeRow * findXsectShapeRow(int engineId)
Definition xsectshapegeom.h:98
QString xsectShapeName(int engineId)
Definition xsectshapegeom.h:112
constexpr int kXsectIrregularId
Definition xsectshapegeom.h:51
constexpr XsectShapeRow kXsectShapes[]
Definition xsectshapegeom.h:59
constexpr int kXsectCustomId
Definition xsectshapegeom.h:57
bool xsectGeomApplies(int shapeId, int ordinal)
Definition xsectshapegeom.h:148
bool xsectGeomIsPickerIndex(int shapeId, int ordinal)
Definition xsectshapegeom.h:168
Definition xsectshapegeom.h:39
const char * geom1Label
"Diameter", "Max Depth", … ("" if unused).
Definition xsectshapegeom.h:42
const char * geom3Label
Definition xsectshapegeom.h:44
int engineId
SWMM_XSECT_* numeric.
Definition xsectshapegeom.h:41
const char * name
"CIRCULAR", "RECT_CLOSED", …
Definition xsectshapegeom.h:40
const char * geom2Label
Definition xsectshapegeom.h:43
const char * geom4Label
Definition xsectshapegeom.h:45