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
depthcolorrampsublayer.h
Go to the documentation of this file.
1
7#ifndef OPENSWMM_RENDER_SUBLAYERS_DEPTHCOLORRAMPSUBLAYER_H
8#define OPENSWMM_RENDER_SUBLAYERS_DEPTHCOLORRAMPSUBLAYER_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(double minValue READ minValue WRITE setMinValue NOTIFY styleChanged)
26 Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue NOTIFY styleChanged)
27 // VS.8 — named built-in/custom ramp ("" = two-colour low→high
28 // gradient, the legacy default), optionally inverted.
29 Q_PROPERTY(QString colorRampName READ colorRampName WRITE setColorRampName NOTIFY styleChanged)
30 Q_PROPERTY(bool invertRamp READ invertRamp WRITE setInvertRamp NOTIFY styleChanged)
31 Q_PROPERTY(QColor lowColor READ lowColor WRITE setLowColor NOTIFY styleChanged)
32 Q_PROPERTY(QColor highColor READ highColor WRITE setHighColor NOTIFY styleChanged)
33 Q_PROPERTY(QColor belowMinColor READ belowMinColor WRITE setBelowMinColor NOTIFY styleChanged)
34 Q_PROPERTY(QColor aboveMaxColor READ aboveMaxColor WRITE setAboveMaxColor NOTIFY styleChanged)
35 Q_PROPERTY(bool useLogScale READ useLogScale WRITE setUseLogScale NOTIFY styleChanged)
36
37 Q_CLASSINFO("group:attribute", "Classification")
38 Q_CLASSINFO("group:minValue", "Range")
39 Q_CLASSINFO("group:maxValue", "Range")
40 Q_CLASSINFO("group:colorRampName", "Ramp")
41 Q_CLASSINFO("group:invertRamp", "Ramp")
42 Q_CLASSINFO("group:lowColor", "Ramp")
43 Q_CLASSINFO("group:highColor", "Ramp")
44 Q_CLASSINFO("group:belowMinColor", "Out of range")
45 Q_CLASSINFO("group:aboveMaxColor", "Out of range")
46 Q_CLASSINFO("group:useLogScale", "Range")
47
48public:
49 // Slice US.2 — the ramp/range/class knobs live in a shared
50 // ClassificationScheme (mode Continuous = smooth Gouraud, Classified =
51 // graduated). The legacy accessors are pure forwards so the property grid
52 // and every renderer / legend call site keep working.
53 explicit DepthColorRampStyle(QObject *parent = nullptr);
54
55 [[nodiscard]] QString attribute() const { return m_attribute; }
56 [[nodiscard]] double minValue() const { return m_scheme.rangeMin(); }
57 [[nodiscard]] double maxValue() const { return m_scheme.rangeMax(); }
58 [[nodiscard]] QString colorRampName() const { return m_scheme.rampName(); }
59 [[nodiscard]] bool invertRamp() const { return m_scheme.invertRamp(); }
60 [[nodiscard]] QColor lowColor() const { return m_scheme.lowColor(); }
61 [[nodiscard]] QColor highColor() const { return m_scheme.highColor(); }
62 [[nodiscard]] QColor belowMinColor() const { return m_belowMinColor; }
63 [[nodiscard]] QColor aboveMaxColor() const { return m_aboveMaxColor; }
64 [[nodiscard]] bool useLogScale() const { return m_useLogScale; }
65
66 void setAttribute(const QString &v);
67 void setMinValue(double v);
68 void setMaxValue(double v);
69 void setColorRampName(const QString &v);
70 void setInvertRamp(bool v);
71 void setLowColor(const QColor &v);
72 void setHighColor(const QColor &v);
73 void setBelowMinColor(const QColor &v);
74 void setAboveMaxColor(const QColor &v);
75 void setUseLogScale(bool v);
76
79 [[nodiscard]] const ClassificationScheme &scheme() const { return m_scheme; }
80 void setScheme(const ClassificationScheme &s);
81
85 [[nodiscard]] QColor colorAtF(double f) const;
86
87 [[nodiscard]] QJsonObject toJson() const override;
88 void fromJson(const QJsonObject &j) override;
89
90private:
91 QString m_attribute = QStringLiteral("depth");
92 QColor m_belowMinColor = QColor( 0, 0, 0, 0); // transparent (dry)
93 QColor m_aboveMaxColor = QColor(255, 255, 255, 200);
94 bool m_useLogScale = false;
95 ClassificationScheme m_scheme;
96};
97
99{
100 Q_OBJECT
101public:
102 explicit DepthColorRampSublayer(QString id_, QObject *parent = nullptr);
103
104 Kind kind() const override { return ColorRampFillKind; }
105 QString id() const override { return m_id; }
106 QString displayName() const override { return tr("Depth color ramp"); }
107
108 bool isVisible() const override { return m_visible; }
109 void setVisible(bool v) override;
110 qreal opacity() const override { return m_opacity; }
111 void setOpacity(qreal o) override;
112
113 bool isDynamic() const override { return true; }
114
115 SublayerStyle *style() override { return m_style; }
116
117 QList<LegendSymbolItem> legendSymbolItems() const override;
118 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
119
120 [[nodiscard]] DepthColorRampStyle *rampStyle() const { return m_style; }
121
122private:
123 QString m_id;
124 bool m_visible = true;
125 qreal m_opacity = 1.0;
126 DepthColorRampStyle *m_style;
127};
128
129} // namespace OpenSWMM::Render
130
131#endif
Shared classification model: mode + binner + ramp + range + per-class overrides, with a revision stam...
Definition classificationscheme.h:61
QColor highColor() const
Definition classificationscheme.h:114
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 depthcolorrampsublayer.h:22
QColor belowMinColor() const
Definition depthcolorrampsublayer.h:62
double maxValue
Definition depthcolorrampsublayer.h:26
void setScheme(const ClassificationScheme &s)
Definition depthcolorrampsublayer.cpp:65
bool invertRamp() const
Definition depthcolorrampsublayer.h:59
double minValue
Definition depthcolorrampsublayer.h:25
bool useLogScale() const
Definition depthcolorrampsublayer.h:64
QColor lowColor
Definition depthcolorrampsublayer.h:31
void setMaxValue(double v)
Definition depthcolorrampsublayer.cpp:44
QColor aboveMaxColor
Definition depthcolorrampsublayer.h:34
double maxValue() const
Definition depthcolorrampsublayer.h:57
QJsonObject toJson() const override
Serialize the style to JSON.
Definition depthcolorrampsublayer.cpp:77
QColor highColor() const
Definition depthcolorrampsublayer.h:61
double minValue() const
Definition depthcolorrampsublayer.h:56
void setInvertRamp(bool v)
Definition depthcolorrampsublayer.cpp:52
QString attribute
Definition depthcolorrampsublayer.h:24
void setAttribute(const QString &v)
Definition depthcolorrampsublayer.cpp:30
QColor colorAtF(double f) const
Definition depthcolorrampsublayer.cpp:72
const ClassificationScheme & scheme() const
Definition depthcolorrampsublayer.h:79
bool useLogScale
Definition depthcolorrampsublayer.h:35
void setMinValue(double v)
Definition depthcolorrampsublayer.cpp:37
QColor belowMinColor
Definition depthcolorrampsublayer.h:33
QString colorRampName
Definition depthcolorrampsublayer.h:29
bool invertRamp
Definition depthcolorrampsublayer.h:30
void setAboveMaxColor(const QColor &v)
Definition depthcolorrampsublayer.cpp:56
void setUseLogScale(bool v)
Definition depthcolorrampsublayer.cpp:58
void setBelowMinColor(const QColor &v)
Definition depthcolorrampsublayer.cpp:55
QColor highColor
Definition depthcolorrampsublayer.h:32
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition depthcolorrampsublayer.cpp:88
QColor lowColor() const
Definition depthcolorrampsublayer.h:60
QColor aboveMaxColor() const
Definition depthcolorrampsublayer.h:63
QString colorRampName() const
Definition depthcolorrampsublayer.h:58
void setColorRampName(const QString &v)
Definition depthcolorrampsublayer.cpp:51
Definition depthcolorrampsublayer.h:99
bool isVisible() const override
Definition depthcolorrampsublayer.h:108
void setVisible(bool v) override
Definition depthcolorrampsublayer.cpp:112
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition depthcolorrampsublayer.h:115
Kind kind() const override
Definition depthcolorrampsublayer.h:104
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition depthcolorrampsublayer.h:113
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition depthcolorrampsublayer.cpp:128
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition depthcolorrampsublayer.cpp:159
void setOpacity(qreal o) override
Definition depthcolorrampsublayer.cpp:119
QString displayName() const override
Definition depthcolorrampsublayer.h:106
QString id() const override
Definition depthcolorrampsublayer.h:105
qreal opacity() const override
Definition depthcolorrampsublayer.h:110
DepthColorRampStyle * rampStyle() const
Definition depthcolorrampsublayer.h:120
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Kind
Coarse taxonomy of sublayer paint behaviours.
Definition isublayer.h:100
@ ColorRampFillKind
Definition isublayer.h:105
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.
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