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
velocityvectorsublayer.h
Go to the documentation of this file.
1
7#ifndef OPENSWMM_RENDER_SUBLAYERS_VELOCITYVECTORSUBLAYER_H
8#define OPENSWMM_RENDER_SUBLAYERS_VELOCITYVECTORSUBLAYER_H
9
11#include "render/isublayer.h"
13#include "render/colorramp.h"
14
15#include <QColor>
16#include <QJsonObject>
17#include <QString>
18
19namespace OpenSWMM::Render
20{
21
23{
24 Q_OBJECT
25public:
30 enum class LengthScaling { Linear = 0, SquareRoot = 1, Log = 2 };
31 Q_ENUM(LengthScaling)
32
33private:
38 Q_PROPERTY(double glyphSpacingPx READ glyphSpacingPx WRITE setGlyphSpacingPx NOTIFY styleChanged)
39 Q_PROPERTY(double headSizePx READ headSizePx WRITE setHeadSizePx NOTIFY styleChanged)
40 Q_PROPERTY(double shaftWidthPx READ shaftWidthPx WRITE setShaftWidthPx NOTIFY styleChanged)
41 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY styleChanged)
42 Q_PROPERTY(double dryDepthCutoff READ dryDepthCutoff WRITE setDryDepthCutoff NOTIFY styleChanged)
43 // VS.7 — colour arrows by speed magnitude through a ramp.
45 Q_PROPERTY(QString colorRampName READ colorRampName WRITE setColorRampName NOTIFY styleChanged)
46 Q_PROPERTY(double speedMinMps READ speedMinMps WRITE setSpeedMinMps NOTIFY styleChanged)
47 Q_PROPERTY(double speedMaxMps READ speedMaxMps WRITE setSpeedMaxMps NOTIFY styleChanged)
48 // VS.8 — 0 = continuous gradient; >= 2 = discretise the ramp into
49 // colour bands (one legend row per band).
51
52 Q_CLASSINFO("group:glyphLengthScalePxPerMps", "Glyph")
53 Q_CLASSINFO("group:lengthScaling", "Glyph")
54 Q_CLASSINFO("group:glyphLengthMinPx", "Glyph")
55 Q_CLASSINFO("group:glyphLengthMaxPx", "Glyph")
56 Q_CLASSINFO("group:glyphSpacingPx", "Placement")
57 Q_CLASSINFO("group:headSizePx", "Glyph")
58 Q_CLASSINFO("group:shaftWidthPx", "Glyph")
59 Q_CLASSINFO("group:color", "Glyph")
60 Q_CLASSINFO("group:dryDepthCutoff", "Filtering")
61 Q_CLASSINFO("group:colorByMagnitude", "Colour")
62 Q_CLASSINFO("group:colorRampName", "Colour")
63 Q_CLASSINFO("group:speedMinMps", "Colour")
64 Q_CLASSINFO("group:speedMaxMps", "Colour")
65 Q_CLASSINFO("group:colorClassCount", "Colour")
66
67public:
68 explicit VelocityVectorStyle(QObject *parent = nullptr);
69
70 [[nodiscard]] double glyphLengthScalePxPerMps() const { return m_glyphLengthScalePxPerMps; }
71 [[nodiscard]] LengthScaling lengthScaling() const { return m_lengthScaling; }
72 [[nodiscard]] double glyphLengthMinPx() const { return m_glyphLengthMinPx; }
73 [[nodiscard]] double glyphLengthMaxPx() const { return m_glyphLengthMaxPx; }
74 [[nodiscard]] double glyphSpacingPx() const { return m_glyphSpacingPx; }
75 [[nodiscard]] double headSizePx() const { return m_headSizePx; }
76 [[nodiscard]] double shaftWidthPx() const { return m_shaftWidthPx; }
77 [[nodiscard]] QColor color() const { return m_color; }
78 [[nodiscard]] double dryDepthCutoff() const { return m_dryDepthCutoff; }
79 [[nodiscard]] bool colorByMagnitude() const { return m_colorByMagnitude; }
80 // Slice US.2 — the ramp / speed range / class count knobs live in a shared
81 // ClassificationScheme. The legacy accessors are pure forwards so
82 // colorForSpeed(), the legend, the property grid, and JSON keep working.
83 [[nodiscard]] QString colorRampName() const { return m_scheme.rampName(); }
84 [[nodiscard]] double speedMinMps() const { return m_scheme.rangeMin(); }
85 [[nodiscard]] double speedMaxMps() const { return m_scheme.rangeMax(); }
86 [[nodiscard]] int colorClassCount() const
87 {
89 ? m_scheme.classCount()
90 : 0;
91 }
92
93 void setGlyphLengthScalePxPerMps(double v);
95 void setGlyphLengthMinPx(double v);
96 void setGlyphLengthMaxPx(double v);
97 void setGlyphSpacingPx(double v);
98 void setHeadSizePx(double v);
99 void setShaftWidthPx(double v);
100 void setColor(const QColor &v);
101 void setDryDepthCutoff(double v);
102 void setColorByMagnitude(bool v);
103 void setColorRampName(const QString &v);
104 void setSpeedMinMps(double v);
105 void setSpeedMaxMps(double v);
106 void setColorClassCount(int v);
107
110 [[nodiscard]] const ClassificationScheme &scheme() const { return m_scheme; }
111 void setScheme(const ClassificationScheme &s);
112
118 [[nodiscard]] QColor colorForSpeed(double speedMps) const;
119
123 [[nodiscard]] double glyphLengthPxForSpeed(double speedMps) const;
124
125 [[nodiscard]] QJsonObject toJson() const override;
126 void fromJson(const QJsonObject &j) override;
127
128private:
129 double m_glyphLengthScalePxPerMps = 20.0;
130 LengthScaling m_lengthScaling = LengthScaling::Log;
131 double m_glyphLengthMinPx = 20.0;
132 double m_glyphLengthMaxPx = 44.0;
133 double m_glyphSpacingPx = 30.0;
134 double m_headSizePx = 8.0;
135 double m_shaftWidthPx = 2.5;
136 QColor m_color = QColor(20, 20, 20, 220);
137 double m_dryDepthCutoff = 0.01;
138 // VS.7 — colour-by-magnitude. VS.8 — default ON: the legacy painter
139 // always encoded |v| as colour, so a flat default would regress it.
140 bool m_colorByMagnitude = true;
141 // Slice US.2 — ramp / speed range / class count consolidated here. The ctor
142 // seeds it to the legacy defaults (Continuous, viridis, [0,2], 5 classes).
143 ClassificationScheme m_scheme;
144};
145
147{
148 Q_OBJECT
149public:
150 explicit VelocityVectorSublayer(QString id_, QObject *parent = nullptr);
151
152 Kind kind() const override { return VectorGlyphKind; }
153 QString id() const override { return m_id; }
154 QString displayName() const override { return tr("Flow Velocity"); }
155
156 bool isVisible() const override { return m_visible; }
157 void setVisible(bool v) override;
158 qreal opacity() const override { return m_opacity; }
159 void setOpacity(qreal o) override;
160
161 bool isDynamic() const override { return true; }
162
163 SublayerStyle *style() override { return m_style; }
164
165 QList<LegendSymbolItem> legendSymbolItems() const override;
166 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
167
168 [[nodiscard]] VelocityVectorStyle *vectorStyle() const { return m_style; }
169
170private:
171 QString m_id;
172 bool m_visible = false; // default off per plan §3
173 qreal m_opacity = 1.0;
174 VelocityVectorStyle *m_style;
175};
176
177} // namespace OpenSWMM::Render
178
179#endif
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
int classCount() const
Definition classificationscheme.h:95
QString rampName() const
Definition classificationscheme.h:104
double rangeMin() const
Definition classificationscheme.h:137
double rangeMax() const
Definition classificationscheme.h:139
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Kind
Coarse taxonomy of sublayer paint behaviours.
Definition isublayer.h:100
@ VectorGlyphKind
Definition isublayer.h:108
Base class for per-sublayer style property bags.
Definition sublayerstyle.h:56
void styleChanged()
Emitted when any property changes.
Definition velocityvectorsublayer.h:23
double speedMinMps() const
Definition velocityvectorsublayer.h:84
double glyphSpacingPx
Definition velocityvectorsublayer.h:38
double glyphLengthPxForSpeed(double speedMps) const
Definition velocityvectorsublayer.cpp:117
const ClassificationScheme & scheme() const
Definition velocityvectorsublayer.h:110
bool colorByMagnitude() const
Definition velocityvectorsublayer.h:79
void setHeadSizePx(double v)
Definition velocityvectorsublayer.cpp:60
LengthScaling
Definition velocityvectorsublayer.h:30
double glyphLengthScalePxPerMps
Definition velocityvectorsublayer.h:34
void setSpeedMinMps(double v)
Definition velocityvectorsublayer.cpp:84
void setColorRampName(const QString &v)
Definition velocityvectorsublayer.cpp:77
double shaftWidthPx() const
Definition velocityvectorsublayer.h:76
void setGlyphLengthMinPx(double v)
Definition velocityvectorsublayer.cpp:57
void setColor(const QColor &v)
Definition velocityvectorsublayer.cpp:63
QColor color
Definition velocityvectorsublayer.h:41
void setShaftWidthPx(double v)
Definition velocityvectorsublayer.cpp:38
double speedMaxMps() const
Definition velocityvectorsublayer.h:85
double glyphLengthMaxPx() const
Definition velocityvectorsublayer.h:73
void setScheme(const ClassificationScheme &s)
Definition velocityvectorsublayer.cpp:29
void setGlyphLengthScalePxPerMps(double v)
Definition velocityvectorsublayer.cpp:36
bool colorByMagnitude
Definition velocityvectorsublayer.h:44
void setSpeedMaxMps(double v)
Definition velocityvectorsublayer.cpp:92
double headSizePx
Definition velocityvectorsublayer.h:39
double speedMaxMps
Definition velocityvectorsublayer.h:47
QColor color() const
Definition velocityvectorsublayer.h:77
double headSizePx() const
Definition velocityvectorsublayer.h:75
void setGlyphLengthMaxPx(double v)
Definition velocityvectorsublayer.cpp:58
LengthScaling lengthScaling
Definition velocityvectorsublayer.h:35
int colorClassCount() const
Definition velocityvectorsublayer.h:86
double shaftWidthPx
Definition velocityvectorsublayer.h:40
void setColorByMagnitude(bool v)
Definition velocityvectorsublayer.cpp:70
double dryDepthCutoff() const
Definition velocityvectorsublayer.h:78
int colorClassCount
Definition velocityvectorsublayer.h:50
void setColorClassCount(int v)
Definition velocityvectorsublayer.cpp:39
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition velocityvectorsublayer.cpp:160
void setLengthScaling(LengthScaling v)
Definition velocityvectorsublayer.cpp:37
QColor colorForSpeed(double speedMps) const
Definition velocityvectorsublayer.cpp:100
double glyphSpacingPx() const
Definition velocityvectorsublayer.h:74
double speedMinMps
Definition velocityvectorsublayer.h:46
QJsonObject toJson() const override
Serialize the style to JSON.
Definition velocityvectorsublayer.cpp:137
double glyphLengthMaxPx
Definition velocityvectorsublayer.h:37
void setGlyphSpacingPx(double v)
Definition velocityvectorsublayer.cpp:59
QString colorRampName
Definition velocityvectorsublayer.h:45
double glyphLengthMinPx() const
Definition velocityvectorsublayer.h:72
LengthScaling lengthScaling() const
Definition velocityvectorsublayer.h:71
QString colorRampName() const
Definition velocityvectorsublayer.h:83
double glyphLengthMinPx
Definition velocityvectorsublayer.h:36
double dryDepthCutoff
Definition velocityvectorsublayer.h:42
void setDryDepthCutoff(double v)
Definition velocityvectorsublayer.cpp:61
Definition velocityvectorsublayer.h:147
void setOpacity(qreal o) override
Definition velocityvectorsublayer.cpp:214
Kind kind() const override
Definition velocityvectorsublayer.h:152
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition velocityvectorsublayer.cpp:223
bool isVisible() const override
Definition velocityvectorsublayer.h:156
QString id() const override
Definition velocityvectorsublayer.h:153
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition velocityvectorsublayer.h:161
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition velocityvectorsublayer.cpp:271
QString displayName() const override
Definition velocityvectorsublayer.h:154
void setVisible(bool v) override
Definition velocityvectorsublayer.cpp:207
VelocityVectorStyle * vectorStyle() const
Definition velocityvectorsublayer.h:168
qreal opacity() const override
Definition velocityvectorsublayer.h:158
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition velocityvectorsublayer.h:163
Slice US.1 (UNIFIED_STYLING_AND_UI_CONSISTENCY_PLAN.md S1) — the shared classification value type emb...
RasterColorRamp — gradient mapping from a normalised value in [0,1] to a display QColor.
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.