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
flowarrowsublayer.h
Go to the documentation of this file.
1
19#ifndef OPENSWMM_RENDER_SUBLAYERS_FLOWARROWSUBLAYER_H
20#define OPENSWMM_RENDER_SUBLAYERS_FLOWARROWSUBLAYER_H
21
22#include "render/isublayer.h"
24#include "render/colorramp.h"
25
26#include <QColor>
27#include <QJsonObject>
28#include <QString>
29
30namespace OpenSWMM::Render
31{
32
34{
35 Q_OBJECT
36 Q_PROPERTY(double arrowLengthPx READ arrowLengthPx WRITE setArrowLengthPx NOTIFY styleChanged)
37 Q_PROPERTY(double arrowSpacingPx READ arrowSpacingPx WRITE setArrowSpacingPx NOTIFY styleChanged)
38 Q_PROPERTY(double headSizePx READ headSizePx WRITE setHeadSizePx NOTIFY styleChanged)
39 Q_PROPERTY(double shaftWidthPx READ shaftWidthPx WRITE setShaftWidthPx NOTIFY styleChanged)
40 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY styleChanged)
41 Q_PROPERTY(QColor outlineColor READ outlineColor WRITE setOutlineColor NOTIFY styleChanged)
42 Q_PROPERTY(double dryDepthCutoff READ dryDepthCutoff WRITE setDryDepthCutoff NOTIFY styleChanged)
44 // VS.7 — colour direction arrows by speed magnitude through a ramp.
46 Q_PROPERTY(QString colorRampName READ colorRampName WRITE setColorRampName NOTIFY styleChanged)
47 Q_PROPERTY(double speedMinMps READ speedMinMps WRITE setSpeedMinMps NOTIFY styleChanged)
48 Q_PROPERTY(double speedMaxMps READ speedMaxMps WRITE setSpeedMaxMps NOTIFY styleChanged)
49
50 Q_CLASSINFO("group:arrowLengthPx", "Arrow")
51 Q_CLASSINFO("group:headSizePx", "Arrow")
52 Q_CLASSINFO("group:shaftWidthPx", "Arrow")
53 Q_CLASSINFO("group:color", "Arrow")
54 Q_CLASSINFO("group:outlineColor", "Arrow")
55 Q_CLASSINFO("group:arrowSpacingPx", "Placement")
56 Q_CLASSINFO("group:placeAtCellCenters", "Placement")
57 Q_CLASSINFO("group:dryDepthCutoff", "Filtering")
58 Q_CLASSINFO("group:colorByMagnitude", "Colour")
59 Q_CLASSINFO("group:colorRampName", "Colour")
60 Q_CLASSINFO("group:speedMinMps", "Colour")
61 Q_CLASSINFO("group:speedMaxMps", "Colour")
62
63public:
64 explicit FlowArrowStyle(QObject *parent = nullptr) : SublayerStyle(parent) {}
65
66 [[nodiscard]] double arrowLengthPx() const { return m_arrowLengthPx; }
67 [[nodiscard]] double arrowSpacingPx() const { return m_arrowSpacingPx; }
68 [[nodiscard]] double headSizePx() const { return m_headSizePx; }
69 [[nodiscard]] double shaftWidthPx() const { return m_shaftWidthPx; }
70 [[nodiscard]] QColor color() const { return m_color; }
71 [[nodiscard]] QColor outlineColor() const { return m_outlineColor; }
72 [[nodiscard]] double dryDepthCutoff() const { return m_dryDepthCutoff; }
73 [[nodiscard]] bool placeAtCellCenters() const { return m_placeAtCellCenters; }
74 [[nodiscard]] bool colorByMagnitude() const { return m_colorByMagnitude; }
75 [[nodiscard]] QString colorRampName() const { return m_colorRampName; }
76 [[nodiscard]] double speedMinMps() const { return m_speedMinMps; }
77 [[nodiscard]] double speedMaxMps() const { return m_speedMaxMps; }
78
79 void setArrowLengthPx(double v);
80 void setArrowSpacingPx(double v);
81 void setHeadSizePx(double v);
82 void setShaftWidthPx(double v);
83 void setColor(const QColor &v) { if (m_color == v) return; m_color = v; setDirty(); }
84 void setOutlineColor(const QColor &v) { if (m_outlineColor == v) return; m_outlineColor = v; setDirty(); }
85 void setDryDepthCutoff(double v);
86 void setPlaceAtCellCenters(bool v) { if (m_placeAtCellCenters == v) return; m_placeAtCellCenters = v; setDirty(); }
87 void setColorByMagnitude(bool v) { if (m_colorByMagnitude == v) return; m_colorByMagnitude = v; setDirty(); }
88 void setColorRampName(const QString &v){ if (m_colorRampName == v) return; m_colorRampName = v; setDirty(); }
89 void setSpeedMinMps(double v) { if (qFuzzyCompare(m_speedMinMps+1.0, v+1.0)) return; m_speedMinMps = v; setDirty(); }
90 void setSpeedMaxMps(double v) { if (qFuzzyCompare(m_speedMaxMps+1.0, v+1.0)) return; m_speedMaxMps = v; setDirty(); }
91
94 [[nodiscard]] QColor colorForSpeed(double speedMps) const;
95
96 [[nodiscard]] QJsonObject toJson() const override;
97 void fromJson(const QJsonObject &j) override;
98
99private:
100 double m_arrowLengthPx = 20.0;
101 double m_arrowSpacingPx = 36.0;
102 double m_headSizePx = 6.0;
103 double m_shaftWidthPx = 1.6;
104 QColor m_color = QColor(20, 20, 20, 230);
105 QColor m_outlineColor = QColor(255, 255, 255, 200);
106 double m_dryDepthCutoff = 0.01;
107 bool m_placeAtCellCenters = false; // false = regular screen grid
108 // VS.7 — colour-by-magnitude.
109 bool m_colorByMagnitude = false;
110 QString m_colorRampName = QStringLiteral("viridis");
111 double m_speedMinMps = 0.0;
112 double m_speedMaxMps = 2.0;
113};
114
116{
117 Q_OBJECT
118public:
119 explicit FlowArrowSublayer(QString id_, QObject *parent = nullptr);
120
121 Kind kind() const override { return ArrowKind; }
122 QString id() const override { return m_id; }
123 QString displayName() const override { return tr("Flow direction arrows"); }
124
125 bool isVisible() const override { return m_visible; }
126 void setVisible(bool v) override;
127 qreal opacity() const override { return m_opacity; }
128 void setOpacity(qreal o) override;
129
130 bool isDynamic() const override { return true; }
131
132 SublayerStyle *style() override { return m_style; }
133
134 QList<LegendSymbolItem> legendSymbolItems() const override;
135 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
136
137 [[nodiscard]] FlowArrowStyle *flowArrowStyle() const { return m_style; }
138
139private:
140 QString m_id;
141 bool m_visible = false; // off by default — opt-in alongside VelocityVector
142 qreal m_opacity = 1.0;
143 FlowArrowStyle *m_style;
144};
145
146} // namespace OpenSWMM::Render
147
148#endif
Definition flowarrowsublayer.h:34
void setColor(const QColor &v)
Definition flowarrowsublayer.h:83
void setArrowLengthPx(double v)
Definition flowarrowsublayer.cpp:18
void setShaftWidthPx(double v)
Definition flowarrowsublayer.cpp:42
double speedMaxMps
Definition flowarrowsublayer.h:48
QString colorRampName
Definition flowarrowsublayer.h:46
double headSizePx
Definition flowarrowsublayer.h:38
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition flowarrowsublayer.cpp:87
double dryDepthCutoff() const
Definition flowarrowsublayer.h:72
double arrowSpacingPx
Definition flowarrowsublayer.h:37
QColor color() const
Definition flowarrowsublayer.h:70
QJsonObject toJson() const override
Serialize the style to JSON.
Definition flowarrowsublayer.cpp:69
double arrowSpacingPx() const
Definition flowarrowsublayer.h:67
double speedMaxMps() const
Definition flowarrowsublayer.h:77
void setArrowSpacingPx(double v)
Definition flowarrowsublayer.cpp:26
void setHeadSizePx(double v)
Definition flowarrowsublayer.cpp:34
bool placeAtCellCenters
Definition flowarrowsublayer.h:43
QColor color
Definition flowarrowsublayer.h:40
void setColorByMagnitude(bool v)
Definition flowarrowsublayer.h:87
QColor outlineColor() const
Definition flowarrowsublayer.h:71
void setSpeedMinMps(double v)
Definition flowarrowsublayer.h:89
double speedMinMps() const
Definition flowarrowsublayer.h:76
void setColorRampName(const QString &v)
Definition flowarrowsublayer.h:88
double arrowLengthPx() const
Definition flowarrowsublayer.h:66
double headSizePx() const
Definition flowarrowsublayer.h:68
void setOutlineColor(const QColor &v)
Definition flowarrowsublayer.h:84
bool colorByMagnitude() const
Definition flowarrowsublayer.h:74
double shaftWidthPx
Definition flowarrowsublayer.h:39
bool placeAtCellCenters() const
Definition flowarrowsublayer.h:73
double shaftWidthPx() const
Definition flowarrowsublayer.h:69
QString colorRampName() const
Definition flowarrowsublayer.h:75
double speedMinMps
Definition flowarrowsublayer.h:47
void setPlaceAtCellCenters(bool v)
Definition flowarrowsublayer.h:86
bool colorByMagnitude
Definition flowarrowsublayer.h:45
void setDryDepthCutoff(double v)
Definition flowarrowsublayer.cpp:50
QColor outlineColor
Definition flowarrowsublayer.h:41
double dryDepthCutoff
Definition flowarrowsublayer.h:42
void setSpeedMaxMps(double v)
Definition flowarrowsublayer.h:90
QColor colorForSpeed(double speedMps) const
Definition flowarrowsublayer.cpp:58
double arrowLengthPx
Definition flowarrowsublayer.h:36
Definition flowarrowsublayer.h:116
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition flowarrowsublayer.h:130
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition flowarrowsublayer.cpp:137
QString displayName() const override
Definition flowarrowsublayer.h:123
Kind kind() const override
Definition flowarrowsublayer.h:121
bool isVisible() const override
Definition flowarrowsublayer.h:125
FlowArrowStyle * flowArrowStyle() const
Definition flowarrowsublayer.h:137
qreal opacity() const override
Definition flowarrowsublayer.h:127
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition flowarrowsublayer.h:132
QString id() const override
Definition flowarrowsublayer.h:122
void setOpacity(qreal o) override
Definition flowarrowsublayer.cpp:129
void setVisible(bool v) override
Definition flowarrowsublayer.cpp:122
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition flowarrowsublayer.cpp:152
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Kind
Coarse taxonomy of sublayer paint behaviours.
Definition isublayer.h:100
@ ArrowKind
Definition isublayer.h:104
Base class for per-sublayer style property bags.
Definition sublayerstyle.h:56
void styleChanged()
Emitted when any property changes.
void setDirty()
Definition sublayerstyle.h:97
RasterColorRamp — gradient mapping from a normalised value in [0,1] to a display QColor.
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.