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
scalarfillsublayer.h
Go to the documentation of this file.
1
15#ifndef OPENSWMM_RENDER_SUBLAYERS_SCALARFILLSUBLAYER_H
16#define OPENSWMM_RENDER_SUBLAYERS_SCALARFILLSUBLAYER_H
17
19#include "render/isublayer.h"
21
22#include <QColor>
23#include <QJsonObject>
24#include <QString>
25
26namespace OpenSWMM::Render
27{
28
34{
35 Q_OBJECT
36 Q_PROPERTY(QString attribute READ attribute WRITE setAttribute NOTIFY styleChanged)
37 Q_PROPERTY(bool classified READ classified WRITE setClassified NOTIFY styleChanged)
38 Q_PROPERTY(int bandCount READ bandCount WRITE setBandCount NOTIFY styleChanged)
39 Q_PROPERTY(QString colorRampName READ colorRampName WRITE setColorRampName NOTIFY styleChanged)
40 Q_PROPERTY(bool invertRamp READ invertRamp WRITE setInvertRamp NOTIFY styleChanged)
41 Q_PROPERTY(QColor lowColor READ lowColor WRITE setLowColor NOTIFY styleChanged)
42 Q_PROPERTY(QColor highColor READ highColor WRITE setHighColor NOTIFY styleChanged)
44 Q_PROPERTY(double rangeMin READ rangeMin WRITE setRangeMin NOTIFY styleChanged)
45 Q_PROPERTY(double rangeMax READ rangeMax WRITE setRangeMax NOTIFY styleChanged)
46
47 Q_CLASSINFO("group:attribute", "Classification")
48 Q_CLASSINFO("group:classified", "Classification")
49 Q_CLASSINFO("group:bandCount", "Classification")
50 Q_CLASSINFO("group:useCustomRange","Classification")
51 Q_CLASSINFO("group:rangeMin", "Classification")
52 Q_CLASSINFO("group:rangeMax", "Classification")
53 Q_CLASSINFO("group:colorRampName", "Ramp")
54 Q_CLASSINFO("group:invertRamp", "Ramp")
55 Q_CLASSINFO("group:lowColor", "Ramp")
56 Q_CLASSINFO("group:highColor", "Ramp")
57
58public:
59 explicit ScalarFillStyle(QObject *parent = nullptr);
60
61 [[nodiscard]] QString attribute() const { return m_attribute; }
62 [[nodiscard]] bool classified() const
64 [[nodiscard]] int bandCount() const { return m_scheme.classCount(); }
65 [[nodiscard]] QString colorRampName() const { return m_scheme.rampName(); }
66 [[nodiscard]] bool invertRamp() const { return m_scheme.invertRamp(); }
67 [[nodiscard]] QColor lowColor() const { return m_scheme.lowColor(); }
68 [[nodiscard]] QColor highColor() const { return m_scheme.highColor(); }
69 [[nodiscard]] bool useCustomRange() const { return m_scheme.useCustomRange(); }
70 [[nodiscard]] double rangeMin() const { return m_scheme.rangeMin(); }
71 [[nodiscard]] double rangeMax() const { return m_scheme.rangeMax(); }
72
73 void setAttribute(const QString &v);
74 void setClassified(bool v);
75 void setBandCount(int v);
76 void setColorRampName(const QString &v);
77 void setInvertRamp(bool v);
78 void setLowColor(const QColor &v);
79 void setHighColor(const QColor &v);
80 void setUseCustomRange(bool v);
81 void setRangeMin(double v);
82 void setRangeMax(double v);
83
84 [[nodiscard]] const ClassificationScheme &scheme() const { return m_scheme; }
85 void setScheme(const ClassificationScheme &s);
86
88 [[nodiscard]] QColor colorForValue(double v, double dataMin, double dataMax) const
89 { return m_scheme.colorForValue(v, dataMin, dataMax); }
91 [[nodiscard]] QColor colorForClass(int classIndex, int count) const
92 { return m_scheme.colorForClass(classIndex, std::max(1, count)); }
93
94 [[nodiscard]] QJsonObject toJson() const override;
95 void fromJson(const QJsonObject &j) override;
96
97private:
98 QString m_attribute = QStringLiteral("depth");
99 ClassificationScheme m_scheme;
100};
101
104{
105 Q_OBJECT
106public:
107 explicit CellDepthFillSublayer(QString id_, QObject *parent = nullptr);
108
109 Kind kind() const override { return FillKind; }
110 QString id() const override { return m_id; }
111 QString displayName() const override
112 {
113 const QString a = m_style ? m_style->attribute() : QString();
114 if (a.compare(QLatin1String("elevation"), Qt::CaseInsensitive) == 0)
115 return tr("Cell Elevation Fill");
116 return tr("Cell Depth Fill");
117 }
118
119 bool isVisible() const override { return m_visible; }
120 void setVisible(bool v) override;
121 qreal opacity() const override { return m_opacity; }
122 void setOpacity(qreal o) override;
123 bool isDynamic() const override { return true; }
124
125 SublayerStyle *style() override { return m_style; }
126 QList<LegendSymbolItem> legendSymbolItems() const override;
127 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
128
129 [[nodiscard]] ScalarFillStyle *fillStyle() const { return m_style; }
130
131private:
132 QString m_id;
133 bool m_visible = false;
134 qreal m_opacity = 1.0;
135 ScalarFillStyle *m_style;
136};
137
142{
143 Q_OBJECT
144public:
145 explicit SmoothDepthFillSublayer(QString id_, QObject *parent = nullptr);
146
147 Kind kind() const override { return ColorRampFillKind; }
148 QString id() const override { return m_id; }
149 QString displayName() const override
150 {
151 const QString a = m_style ? m_style->attribute() : QString();
152 if (a.compare(QLatin1String("elevation"), Qt::CaseInsensitive) == 0)
153 return tr("Smooth Elevation Fill");
154 return tr("Smooth Depth Fill");
155 }
156
157 bool isVisible() const override { return m_visible; }
158 void setVisible(bool v) override;
159 qreal opacity() const override { return m_opacity; }
160 void setOpacity(qreal o) override;
161 bool isDynamic() const override { return true; }
162
163 SublayerStyle *style() override { return m_style; }
164 QList<LegendSymbolItem> legendSymbolItems() const override;
165 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
166
167 [[nodiscard]] ScalarFillStyle *fillStyle() const { return m_style; }
168
169private:
170 QString m_id;
171 bool m_visible = false;
172 qreal m_opacity = 0.60; // basemap stays visible under the fill
173 ScalarFillStyle *m_style;
174};
175
176} // namespace OpenSWMM::Render
177
178#endif
Definition scalarfillsublayer.h:104
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition scalarfillsublayer.h:123
QString displayName() const override
Definition scalarfillsublayer.h:111
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition scalarfillsublayer.cpp:155
QString id() const override
Definition scalarfillsublayer.h:110
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition scalarfillsublayer.h:125
Kind kind() const override
Definition scalarfillsublayer.h:109
bool isVisible() const override
Definition scalarfillsublayer.h:119
void setVisible(bool v) override
Definition scalarfillsublayer.cpp:147
qreal opacity() const override
Definition scalarfillsublayer.h:121
void setOpacity(qreal o) override
Definition scalarfillsublayer.cpp:149
ScalarFillStyle * fillStyle() const
Definition scalarfillsublayer.h:129
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition scalarfillsublayer.cpp:157
Shared classification model: mode + binner + ramp + range + per-class overrides, with a revision stam...
Definition classificationscheme.h:61
ClassMode mode() const
Definition classificationscheme.h:85
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
QColor colorForValue(double value, double dataMin, double dataMax) const
Definition classificationscheme.cpp:380
double rangeMin() const
Definition classificationscheme.h:137
double rangeMax() const
Definition classificationscheme.h:139
QColor colorForClass(int classIndex) const
Definition classificationscheme.cpp:365
bool invertRamp() const
Definition classificationscheme.h:107
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
@ ColorRampFillKind
Definition isublayer.h:105
Definition scalarfillsublayer.h:34
void setColorRampName(const QString &v)
Definition scalarfillsublayer.cpp:53
bool invertRamp() const
Definition scalarfillsublayer.h:66
QColor highColor
Definition scalarfillsublayer.h:42
QColor highColor() const
Definition scalarfillsublayer.h:68
const ClassificationScheme & scheme() const
Definition scalarfillsublayer.h:84
void setUseCustomRange(bool v)
Definition scalarfillsublayer.cpp:61
QColor lowColor
Definition scalarfillsublayer.h:41
void setAttribute(const QString &v)
Definition scalarfillsublayer.cpp:35
void setRangeMax(double v)
Definition scalarfillsublayer.cpp:65
QColor colorForClass(int classIndex, int count) const
Definition scalarfillsublayer.h:91
bool invertRamp
Definition scalarfillsublayer.h:40
void setClassified(bool v)
Definition scalarfillsublayer.cpp:38
QColor colorForValue(double v, double dataMin, double dataMax) const
Definition scalarfillsublayer.h:88
bool classified() const
Definition scalarfillsublayer.h:62
int bandCount() const
Definition scalarfillsublayer.h:64
bool useCustomRange
Definition scalarfillsublayer.h:43
bool classified
Definition scalarfillsublayer.h:37
QString attribute
Definition scalarfillsublayer.h:36
int bandCount
Definition scalarfillsublayer.h:38
QColor lowColor() const
Definition scalarfillsublayer.h:67
void setInvertRamp(bool v)
Definition scalarfillsublayer.cpp:55
QJsonObject toJson() const override
Serialize the style to JSON.
Definition scalarfillsublayer.cpp:71
QString colorRampName() const
Definition scalarfillsublayer.h:65
void setBandCount(int v)
Definition scalarfillsublayer.cpp:45
double rangeMax() const
Definition scalarfillsublayer.h:71
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition scalarfillsublayer.cpp:79
bool useCustomRange() const
Definition scalarfillsublayer.h:69
QString colorRampName
Definition scalarfillsublayer.h:39
double rangeMin
Definition scalarfillsublayer.h:44
double rangeMax
Definition scalarfillsublayer.h:45
void setScheme(const ClassificationScheme &s)
Definition scalarfillsublayer.cpp:68
double rangeMin() const
Definition scalarfillsublayer.h:70
void setRangeMin(double v)
Definition scalarfillsublayer.cpp:63
Definition scalarfillsublayer.h:142
ScalarFillStyle * fillStyle() const
Definition scalarfillsublayer.h:167
bool isVisible() const override
Definition scalarfillsublayer.h:157
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition scalarfillsublayer.cpp:178
void setVisible(bool v) override
Definition scalarfillsublayer.cpp:170
qreal opacity() const override
Definition scalarfillsublayer.h:159
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition scalarfillsublayer.h:163
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition scalarfillsublayer.h:161
void setOpacity(qreal o) override
Definition scalarfillsublayer.cpp:172
QString id() const override
Definition scalarfillsublayer.h:148
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition scalarfillsublayer.cpp:180
QString displayName() const override
Definition scalarfillsublayer.h:149
Kind kind() const override
Definition scalarfillsublayer.h:147
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
int count
Definition numberformat.cpp:101
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