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
meshfillsublayer.h
Go to the documentation of this file.
1
25#ifndef OPENSWMM_RENDER_SUBLAYERS_MESHFILLSUBLAYER_H
26#define OPENSWMM_RENDER_SUBLAYERS_MESHFILLSUBLAYER_H
27
29#include "render/isublayer.h"
31
32#include <QColor>
33#include <QJsonObject>
34#include <QString>
35#include <QVector>
36
37namespace OpenSWMM::Render
38{
39
41{
42 Q_OBJECT
43
44public:
57 enum class CellAttribute : int
58 {
59 Elevation = 0,
60 Mannings,
61 InitDepth,
62 // Per-cell infiltration (GUI plan §3.5(5)). The METHOD is categorical
63 // and colours through categoryColorForValue(); the parameters are
64 // ordinary graduated attributes. Values resolve through
65 // mesh::resolveInfil, so a cell inheriting from its region tag paints
66 // its region's numbers — which is the point: an assignment can be
67 // checked visually before a run.
69 InfilF0,
70 InfilFmin,
73 InfilFmax,
75 InfilKs,
76 InfilIMD,
77 InfilCN,
78 InfilRate,
79 GwKs,
80 GwZs,
81 GwThetaS,
82 GwHu0,
83 GwHg0,
84 };
85 Q_ENUM(CellAttribute)
86
87private:
88 Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY styleChanged)
91 // Slice US (mesh) — terrain fill is classified by bed elevation through
92 // the shared ClassificationScheme (Continuous = smooth elevation ramp,
93 // Classified = discrete bands). useElevationRamp stays the on/off gate.
97 // Colour for cells whose selected attribute is unset (NaN). Every gw.*
98 // key is 100% NaN until the engine grows a soil column, so this is what
99 // the whole mesh renders as when one of them is selected.
100 Q_PROPERTY(QColor noDataColor READ noDataColor WRITE setNoDataColor NOTIFY styleChanged)
101 // Palette used when colorByAttribute names a CATEGORICAL attribute (the
102 // infiltration method). A ClassificationScheme has only Continuous and
103 // Classified modes, both numeric — binning a seven-value enumeration at
104 // 0.5/1.5/… is a lie about the data and leaks into the legend labels, the
105 // same reasoning that gave the edge BC colours their own properties.
107
108 Q_CLASSINFO("group:fillColor", "Fill")
109 Q_CLASSINFO("group:hillshadeStrength", "Shading")
110 Q_CLASSINFO("group:useElevationRamp", "Fill")
111 Q_CLASSINFO("group:colorByAttribute", "Fill")
112 Q_CLASSINFO("group:noDataColor", "Fill")
113 Q_CLASSINFO("group:categoryPalette", "Fill")
114 Q_CLASSINFO("group:classification", "Classification")
115
116public:
119 [[nodiscard]] static QByteArray attributeKey(CellAttribute a);
121 [[nodiscard]] static CellAttribute attributeFromKey(const QByteArray &key);
122
123 explicit MeshFillStyle(QObject *parent = nullptr);
124
125 [[nodiscard]] QColor fillColor() const { return m_fillColor; }
126 [[nodiscard]] double hillshadeStrength() const { return m_hillshadeStrength; }
131 [[nodiscard]] bool useElevationRamp() const { return m_useElevationRamp; }
132 [[nodiscard]] CellAttribute colorByAttribute() const { return m_colorByAttribute; }
133 [[nodiscard]] QColor noDataColor() const { return m_noDataColor; }
134 [[nodiscard]] QString categoryPalette() const { return m_categoryPalette; }
135
138 [[nodiscard]] QByteArray colorByAttributeKey() const
139 { return attributeKey(m_colorByAttribute); }
140
142 [[nodiscard]] bool colorsByElevation() const
143 { return m_colorByAttribute == CellAttribute::Elevation; }
144
149 [[nodiscard]] bool colorsByCategory() const;
150
155 [[nodiscard]] QColor categoryColorForValue(int v) const;
156
157 void setFillColor(const QColor &v);
158 void setHillshadeStrength(double v);
159 void setUseElevationRamp(bool v);
161 void setNoDataColor(const QColor &v);
162 void setCategoryPalette(const QString &v);
163
166 [[nodiscard]] const ClassificationScheme &scheme() const { return m_scheme; }
167 void setScheme(const ClassificationScheme &s);
168
169 [[nodiscard]] QJsonObject toJson() const override;
170 void fromJson(const QJsonObject &j) override;
171
172private:
173 QColor m_fillColor = QColor(190, 180, 150);
174 double m_hillshadeStrength = 0.5;
175 bool m_useElevationRamp = true;
176 CellAttribute m_colorByAttribute = CellAttribute::Elevation;
177 QColor m_noDataColor = QColor(205, 205, 205, 120);
178 QString m_categoryPalette = QStringLiteral("Tab10");
179 ClassificationScheme m_scheme;
180};
181
183{
184 Q_OBJECT
185public:
186 explicit MeshFillSublayer(QString id_, QObject *parent = nullptr);
187
188 Kind kind() const override { return FillKind; }
189 QString id() const override { return m_id; }
190 QString displayName() const override { return tr("Mesh Terrain"); }
191
192 bool isVisible() const override { return m_visible; }
193 void setVisible(bool v) override;
194 qreal opacity() const override { return m_opacity; }
195 void setOpacity(qreal o) override;
196
197 bool isDynamic() const override { return false; }
198
199 SublayerStyle *style() override { return m_style; }
200
201 QList<LegendSymbolItem> legendSymbolItems() const override;
202 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
203
204 [[nodiscard]] MeshFillStyle *fillStyle() const { return m_style; }
205
210 void setAttributeHasData(bool hasData);
211 [[nodiscard]] bool attributeHasData() const { return m_attributeHasData; }
212
215 void setDepthUnitLabel(const QString &l) { m_depthUnitLabel = l; }
216
225 void setCategoriesPresent(const QVector<int> &values);
226 [[nodiscard]] const QVector<int> &categoriesPresent() const
227 { return m_categoriesPresent; }
228
229private:
230 QString m_id;
231 bool m_visible = true;
232 qreal m_opacity = 1.0;
233 MeshFillStyle *m_style;
234 bool m_attributeHasData = true;
235 QString m_depthUnitLabel;
236 QVector<int> m_categoriesPresent;
237};
238
239} // namespace OpenSWMM::Render
240
241#endif
Shared classification model: mode + binner + ramp + range + per-class overrides, with a revision stam...
Definition classificationscheme.h:61
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Kind
Coarse taxonomy of sublayer paint behaviours.
Definition isublayer.h:100
@ FillKind
Definition isublayer.h:103
Definition meshfillsublayer.h:41
QColor fillColor
Definition meshfillsublayer.h:88
QString categoryPalette() const
Definition meshfillsublayer.h:134
void setColorByAttribute(CellAttribute v)
Definition meshfillsublayer.cpp:95
QColor noDataColor() const
Definition meshfillsublayer.h:133
void setCategoryPalette(const QString &v)
Definition meshfillsublayer.cpp:119
void setScheme(const ClassificationScheme &s)
Definition meshfillsublayer.cpp:65
static QByteArray attributeKey(CellAttribute a)
Definition meshfillsublayer.cpp:38
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition meshfillsublayer.cpp:164
void setHillshadeStrength(double v)
Definition meshfillsublayer.cpp:79
bool useElevationRamp
Definition meshfillsublayer.h:90
bool useElevationRamp() const
Definition meshfillsublayer.h:131
void setFillColor(const QColor &v)
Definition meshfillsublayer.cpp:72
void setNoDataColor(const QColor &v)
Definition meshfillsublayer.cpp:112
QString categoryPalette
Definition meshfillsublayer.h:106
QColor categoryColorForValue(int v) const
Colour for enumeration value v of the current categorical attribute. v is the enum's own integer (mes...
Definition meshfillsublayer.cpp:135
void setUseElevationRamp(bool v)
Definition meshfillsublayer.cpp:88
bool colorsByCategory() const
Definition meshfillsublayer.cpp:128
QColor noDataColor
Definition meshfillsublayer.h:100
double hillshadeStrength() const
Definition meshfillsublayer.h:126
CellAttribute colorByAttribute() const
Definition meshfillsublayer.h:132
const ClassificationScheme & scheme() const
Definition meshfillsublayer.h:166
QByteArray colorByAttributeKey() const
Definition meshfillsublayer.h:138
double hillshadeStrength
Definition meshfillsublayer.h:89
CellAttribute
Definition meshfillsublayer.h:58
@ GwHg0
"gw.hg0" (engine support pending)
@ InfilMethod
"infil.method" (categorical)
@ Elevation
bed elevation — the historic default
@ GwHu0
"gw.hu0" (engine support pending)
@ GwThetaS
"gw.thetaS" (engine support pending)
@ GwZs
"gw.zs" (engine support pending)
@ GwKs
"gw.Ks" (engine support pending)
OpenSWMM::Render::MeshFillStyle::CellAttribute colorByAttribute
Definition meshfillsublayer.h:96
QJsonObject toJson() const override
Serialize the style to JSON.
Definition meshfillsublayer.cpp:149
bool colorsByElevation() const
Definition meshfillsublayer.h:142
OpenSWMM::Render::ClassificationScheme classification
Definition meshfillsublayer.h:94
static CellAttribute attributeFromKey(const QByteArray &key)
Definition meshfillsublayer.cpp:44
Definition meshfillsublayer.h:183
bool isVisible() const override
Definition meshfillsublayer.h:192
QString displayName() const override
Definition meshfillsublayer.h:190
qreal opacity() const override
Definition meshfillsublayer.h:194
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition meshfillsublayer.cpp:234
QString id() const override
Definition meshfillsublayer.h:189
void setAttributeHasData(bool hasData)
Whether the currently selected attribute has any non-NaN value in the host mesh. Pushed by SWMM2DMesh...
Definition meshfillsublayer.cpp:220
void setOpacity(qreal o) override
Definition meshfillsublayer.cpp:211
void setCategoriesPresent(const QVector< int > &values)
Enumeration values of the selected CATEGORICAL attribute that actually occur in the host mesh,...
Definition meshfillsublayer.cpp:227
const QVector< int > & categoriesPresent() const
Definition meshfillsublayer.h:226
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition meshfillsublayer.h:199
Kind kind() const override
Definition meshfillsublayer.h:188
MeshFillStyle * fillStyle() const
Definition meshfillsublayer.h:204
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition meshfillsublayer.h:197
void setDepthUnitLabel(const QString &l)
Project depth-unit label ("m" / "ft"), used to suffix the legend title for length-valued attributes....
Definition meshfillsublayer.h:215
bool attributeHasData() const
Definition meshfillsublayer.h:211
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition meshfillsublayer.cpp:300
void setVisible(bool v) override
Definition meshfillsublayer.cpp:204
Base class for per-sublayer style property bags.
Definition sublayerstyle.h:56
void styleChanged()
Emitted when any property changes.
Slice US.1 (UNIFIED_STYLING_AND_UI_CONSISTENCY_PLAN.md S1) — the shared classification value type emb...
double s
Scene px per model length unit.
Definition inletdrawingview.cpp:82
Toggleable visual aspect of an output layer.
const char * key
Definition meshcellparams.cpp:24
int a
Definition meshquadmatch.cpp:46
Definition gisrasterlayer.h:40
Definition contourchain.h:23
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Per-frame parameters handed to ISublayer::buildOrUpdateNode().
Definition isublayer.h:73
QObject base class for per-sublayer style property bags.