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
contourbandsublayer.h
Go to the documentation of this file.
1
7#ifndef OPENSWMM_RENDER_SUBLAYERS_CONTOURBANDSUBLAYER_H
8#define OPENSWMM_RENDER_SUBLAYERS_CONTOURBANDSUBLAYER_H
9
11#include "render/isublayer.h"
13
14#include <QColor>
15#include <QJsonObject>
16#include <QString>
17
18namespace OpenSWMM::Render
19{
20
22{
23 Q_OBJECT
24 Q_PROPERTY(QString attribute READ attribute WRITE setAttribute NOTIFY styleChanged)
25 Q_PROPERTY(int bandCount READ bandCount WRITE setBandCount NOTIFY styleChanged)
26 // VS.8 — colour source: a named built-in/custom ramp ("" = use the
27 // two-colour lowColor→highColor gradient), optionally inverted.
28 Q_PROPERTY(QString colorRampName READ colorRampName WRITE setColorRampName NOTIFY styleChanged)
29 Q_PROPERTY(bool invertRamp READ invertRamp WRITE setInvertRamp NOTIFY styleChanged)
30 Q_PROPERTY(QColor lowColor READ lowColor WRITE setLowColor NOTIFY styleChanged)
31 Q_PROPERTY(QColor highColor READ highColor WRITE setHighColor NOTIFY styleChanged)
32 Q_PROPERTY(QColor belowMinColor READ belowMinColor WRITE setBelowMinColor NOTIFY styleChanged)
33 Q_PROPERTY(QColor aboveMaxColor READ aboveMaxColor WRITE setAboveMaxColor NOTIFY styleChanged)
34 Q_PROPERTY(bool smoothBands READ smoothBands WRITE setSmoothBands NOTIFY styleChanged)
35 // VS.8 — fixed classification range. Off = auto-track the layer's
36 // [dryDepth, maxDepth] range (legacy behaviour).
38 Q_PROPERTY(double rangeMin READ rangeMin WRITE setRangeMin NOTIFY styleChanged)
39 Q_PROPERTY(double rangeMax READ rangeMax WRITE setRangeMax NOTIFY styleChanged)
40
41 Q_CLASSINFO("group:attribute", "Classification")
42 Q_CLASSINFO("group:bandCount", "Classification")
43 Q_CLASSINFO("group:useCustomRange","Classification")
44 Q_CLASSINFO("group:rangeMin", "Classification")
45 Q_CLASSINFO("group:rangeMax", "Classification")
46 Q_CLASSINFO("group:colorRampName", "Ramp")
47 Q_CLASSINFO("group:invertRamp", "Ramp")
48 Q_CLASSINFO("group:lowColor", "Ramp")
49 Q_CLASSINFO("group:highColor", "Ramp")
50 Q_CLASSINFO("group:belowMinColor", "Out of range")
51 Q_CLASSINFO("group:aboveMaxColor", "Out of range")
52 Q_CLASSINFO("group:smoothBands", "Rendering")
53
54public:
55 // Slice US.2 — the classification knobs (band count, ramp, invert,
56 // custom range) now live in a shared ClassificationScheme; the legacy
57 // Q_PROPERTY accessors are pure forwards into it so the property grid +
58 // every QSG / legend call site keep working while the scheme drives the
59 // method-aware level edges.
60 explicit ContourBandStyle(QObject *parent = nullptr);
61
62 [[nodiscard]] QString attribute() const { return m_attribute; }
63 [[nodiscard]] int bandCount() const { return m_scheme.classCount(); }
64 [[nodiscard]] QString colorRampName() const { return m_scheme.rampName(); }
65 [[nodiscard]] bool invertRamp() const { return m_scheme.invertRamp(); }
66 [[nodiscard]] QColor lowColor() const { return m_scheme.lowColor(); }
67 [[nodiscard]] QColor highColor() const { return m_scheme.highColor(); }
68 [[nodiscard]] QColor belowMinColor() const { return m_belowMinColor; }
69 [[nodiscard]] QColor aboveMaxColor() const { return m_aboveMaxColor; }
70 [[nodiscard]] bool smoothBands() const { return m_smoothBands; }
71 [[nodiscard]] bool useCustomRange() const { return m_scheme.useCustomRange(); }
72 [[nodiscard]] double rangeMin() const { return m_scheme.rangeMin(); }
73 [[nodiscard]] double rangeMax() const { return m_scheme.rangeMax(); }
74
75 void setAttribute(const QString &v);
76 void setBandCount(int v);
77 void setColorRampName(const QString &v);
78 void setInvertRamp(bool v);
79 void setLowColor(const QColor &v);
80 void setHighColor(const QColor &v);
81 void setBelowMinColor(const QColor &v);
82 void setAboveMaxColor(const QColor &v);
83 void setSmoothBands(bool v);
84 void setUseCustomRange(bool v);
85 void setRangeMin(double v);
86 void setRangeMax(double v);
87
90 [[nodiscard]] const ClassificationScheme &scheme() const { return m_scheme; }
91 void setScheme(const ClassificationScheme &s);
92
97 [[nodiscard]] QColor colorForBand(int bandIndex, int bandCount) const;
98
99 [[nodiscard]] QJsonObject toJson() const override;
100 void fromJson(const QJsonObject &j) override;
101
102private:
103 QString m_attribute = QStringLiteral("depth");
104 QColor m_belowMinColor = QColor( 0, 0, 0, 0);
105 QColor m_aboveMaxColor = QColor(255, 255, 255, 200);
106 bool m_smoothBands = true;
107 ClassificationScheme m_scheme;
108};
109
111{
112 Q_OBJECT
113public:
114 explicit ContourBandSublayer(QString id_, QObject *parent = nullptr);
115
116 Kind kind() const override { return ContourBandKind; }
117 QString id() const override { return m_id; }
118 // Label tracks the classified attribute: the terrain mesh classifies bed
119 // ELEVATION, the results layer classifies water DEPTH. Hardcoding "Depth"
120 // mislabelled the terrain sublayer.
121 QString displayName() const override
122 {
123 const QString a = m_style ? m_style->attribute() : QString();
124 if (a.compare(QLatin1String("elevation"), Qt::CaseInsensitive) == 0)
125 return tr("Elevation Contours");
126 return tr("Depth Contours");
127 }
128
129 bool isVisible() const override { return m_visible; }
130 void setVisible(bool v) override;
131 qreal opacity() const override { return m_opacity; }
132 void setOpacity(qreal o) override;
133
134 bool isDynamic() const override { return true; }
135
136 SublayerStyle *style() override { return m_style; }
137
138 QList<LegendSymbolItem> legendSymbolItems() const override;
139 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
140
141 [[nodiscard]] ContourBandStyle *bandStyle() const { return m_style; }
142
143private:
144 QString m_id;
145 bool m_visible = false; // off by default per plan §3
146 qreal m_opacity = 0.60; // basemap stays visible under bands
147 ContourBandStyle *m_style;
148};
149
150} // namespace OpenSWMM::Render
151
152#endif
Shared classification model: mode + binner + ramp + range + per-class overrides, with a revision stam...
Definition classificationscheme.h:61
bool useCustomRange() const
Definition classificationscheme.h:135
QColor highColor() const
Definition classificationscheme.h:114
int classCount() const
Definition classificationscheme.h:95
QColor lowColor() const
Definition classificationscheme.h:112
QString rampName() const
Definition classificationscheme.h:104
double rangeMin() const
Definition classificationscheme.h:137
double rangeMax() const
Definition classificationscheme.h:139
bool invertRamp() const
Definition classificationscheme.h:107
Definition contourbandsublayer.h:22
QColor highColor() const
Definition contourbandsublayer.h:67
int bandCount() const
Definition contourbandsublayer.h:63
QJsonObject toJson() const override
Serialize the style to JSON.
Definition contourbandsublayer.cpp:60
QString colorRampName
Definition contourbandsublayer.h:28
double rangeMax() const
Definition contourbandsublayer.h:73
bool useCustomRange() const
Definition contourbandsublayer.h:71
void setScheme(const ClassificationScheme &s)
Definition contourbandsublayer.cpp:48
void setAttribute(const QString &v)
Definition contourbandsublayer.cpp:29
QColor belowMinColor() const
Definition contourbandsublayer.h:68
QColor aboveMaxColor
Definition contourbandsublayer.h:33
bool smoothBands() const
Definition contourbandsublayer.h:70
QString colorRampName() const
Definition contourbandsublayer.h:64
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition contourbandsublayer.cpp:71
const ClassificationScheme & scheme() const
Definition contourbandsublayer.h:90
bool useCustomRange
Definition contourbandsublayer.h:37
QColor aboveMaxColor() const
Definition contourbandsublayer.h:69
void setInvertRamp(bool v)
Definition contourbandsublayer.cpp:38
int bandCount
Definition contourbandsublayer.h:25
double rangeMax
Definition contourbandsublayer.h:39
void setSmoothBands(bool v)
Definition contourbandsublayer.cpp:43
void setBelowMinColor(const QColor &v)
Definition contourbandsublayer.cpp:41
double rangeMin() const
Definition contourbandsublayer.h:72
void setBandCount(int v)
Definition contourbandsublayer.cpp:30
QColor highColor
Definition contourbandsublayer.h:31
QColor colorForBand(int bandIndex, int bandCount) const
Definition contourbandsublayer.cpp:55
bool smoothBands
Definition contourbandsublayer.h:34
void setRangeMax(double v)
Definition contourbandsublayer.cpp:46
bool invertRamp() const
Definition contourbandsublayer.h:65
void setUseCustomRange(bool v)
Definition contourbandsublayer.cpp:44
double rangeMin
Definition contourbandsublayer.h:38
void setAboveMaxColor(const QColor &v)
Definition contourbandsublayer.cpp:42
QString attribute
Definition contourbandsublayer.h:24
QColor belowMinColor
Definition contourbandsublayer.h:32
QColor lowColor
Definition contourbandsublayer.h:30
bool invertRamp
Definition contourbandsublayer.h:29
void setColorRampName(const QString &v)
Definition contourbandsublayer.cpp:37
QColor lowColor() const
Definition contourbandsublayer.h:66
void setRangeMin(double v)
Definition contourbandsublayer.cpp:45
Definition contourbandsublayer.h:111
void setOpacity(qreal o) override
Definition contourbandsublayer.cpp:102
QString id() const override
Definition contourbandsublayer.h:117
Kind kind() const override
Definition contourbandsublayer.h:116
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition contourbandsublayer.h:134
void setVisible(bool v) override
Definition contourbandsublayer.cpp:95
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition contourbandsublayer.cpp:148
bool isVisible() const override
Definition contourbandsublayer.h:129
qreal opacity() const override
Definition contourbandsublayer.h:131
ContourBandStyle * bandStyle() const
Definition contourbandsublayer.h:141
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition contourbandsublayer.h:136
QString displayName() const override
Definition contourbandsublayer.h:121
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition contourbandsublayer.cpp:111
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Kind
Coarse taxonomy of sublayer paint behaviours.
Definition isublayer.h:100
@ ContourBandKind
Definition isublayer.h:107
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.
int a
Definition meshquadmatch.cpp:46
Definition gisrasterlayer.h:40
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.
std::function< void(const QColor &)> setLowColor
Definition swmm2dresultsstylepanel.cpp:67
std::function< void(const QColor &)> setHighColor
Definition swmm2dresultsstylepanel.cpp:69