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
meshnodesublayer.h
Go to the documentation of this file.
1
16#ifndef OPENSWMM_RENDER_SUBLAYERS_MESHNODESUBLAYER_H
17#define OPENSWMM_RENDER_SUBLAYERS_MESHNODESUBLAYER_H
18
19#include "render/isublayer.h"
21
22#include <QColor>
23#include <QJsonObject>
24#include <QString>
25
26namespace OpenSWMM::Render
27{
28
30{
31 Q_OBJECT
32public:
34 Q_ENUM(MarkerShape)
35
36private:
37 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY styleChanged)
38 Q_PROPERTY(double markerSizePx READ markerSizePx WRITE setMarkerSizePx NOTIFY styleChanged)
39 Q_PROPERTY(MarkerShape shape READ shape WRITE setShape NOTIFY styleChanged)
40 Q_PROPERTY(QColor outlineColor READ outlineColor WRITE setOutlineColor NOTIFY styleChanged)
41 Q_PROPERTY(double outlineWidthPx READ outlineWidthPx WRITE setOutlineWidthPx NOTIFY styleChanged)
42 // Tagged (SWMM-coupled) vertex styling moved to CoupledNodeStyle
43 // (couplednodesublayer.h) — coupled markers are their own sublayer now.
44 // Legacy "tagged*" JSON keys migrate in
45 // SWMM2DMeshLayer::onSublayersJsonLoaded.
46
47 Q_CLASSINFO("group:color", "Symbology")
48 Q_CLASSINFO("group:markerSizePx", "Symbology")
49 Q_CLASSINFO("group:shape", "Symbology")
50 Q_CLASSINFO("group:outlineColor", "Outline")
51 Q_CLASSINFO("group:outlineWidthPx", "Outline")
52
53public:
54 explicit MeshNodeStyle(QObject *parent = nullptr) : SublayerStyle(parent) {}
55
56 [[nodiscard]] QColor color() const { return m_color; }
57 [[nodiscard]] double markerSizePx() const { return m_markerSizePx; }
58 [[nodiscard]] MarkerShape shape() const { return m_shape; }
59 [[nodiscard]] QColor outlineColor() const { return m_outlineColor; }
60 [[nodiscard]] double outlineWidthPx() const { return m_outlineWidthPx; }
61
62 void setColor(const QColor &v) { if (m_color == v) return; m_color = v; setDirty(); }
63 void setMarkerSizePx(double v);
64 void setShape(MarkerShape v) { if (m_shape == v) return; m_shape = v; setDirty(); }
65 void setOutlineColor(const QColor &v) { if (m_outlineColor == v) return; m_outlineColor = v; setDirty(); }
66 void setOutlineWidthPx(double v);
67
68 [[nodiscard]] QJsonObject toJson() const override;
69 void fromJson(const QJsonObject &j) override;
70
71private:
72 QColor m_color = QColor(40, 40, 40, 220);
73 double m_markerSizePx = 3.0;
74 MarkerShape m_shape = Circle;
75 QColor m_outlineColor = QColor(255, 255, 255, 220);
76 double m_outlineWidthPx = 0.5;
77};
78
80{
81 Q_OBJECT
82public:
83 explicit MeshNodeSublayer(QString id_, QObject *parent = nullptr);
84
85 Kind kind() const override { return MarkerKind; }
86 QString id() const override { return m_id; }
87 QString displayName() const override { return tr("Mesh Vertices"); }
88
89 bool isVisible() const override { return m_visible; }
90 void setVisible(bool v) override;
91 qreal opacity() const override { return m_opacity; }
92 void setOpacity(qreal o) override;
93
94 bool isDynamic() const override { return false; }
95
96 SublayerStyle *style() override { return m_style; }
97
98 QList<LegendSymbolItem> legendSymbolItems() const override;
99 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
100
101 [[nodiscard]] MeshNodeStyle *nodeStyle() const { return m_style; }
102
103private:
104 QString m_id;
105 bool m_visible = false; // matches historic showMeshNodes default
106 qreal m_opacity = 1.0;
107 MeshNodeStyle *m_style;
108};
109
110} // namespace OpenSWMM::Render
111
112#endif
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Kind
Coarse taxonomy of sublayer paint behaviours.
Definition isublayer.h:100
@ MarkerKind
Definition isublayer.h:101
Definition meshnodesublayer.h:30
void setColor(const QColor &v)
Definition meshnodesublayer.h:62
QColor outlineColor
Definition meshnodesublayer.h:40
QColor outlineColor() const
Definition meshnodesublayer.h:59
QColor color
Definition meshnodesublayer.h:37
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition meshnodesublayer.cpp:39
QColor color() const
Definition meshnodesublayer.h:56
double outlineWidthPx() const
Definition meshnodesublayer.h:60
MarkerShape shape
Definition meshnodesublayer.h:39
QJsonObject toJson() const override
Serialize the style to JSON.
Definition meshnodesublayer.cpp:28
MarkerShape shape() const
Definition meshnodesublayer.h:58
double markerSizePx() const
Definition meshnodesublayer.h:57
void setOutlineWidthPx(double v)
Definition meshnodesublayer.cpp:20
void setMarkerSizePx(double v)
Definition meshnodesublayer.cpp:12
double outlineWidthPx
Definition meshnodesublayer.h:41
MarkerShape
Definition meshnodesublayer.h:33
@ Diamond
Definition meshnodesublayer.h:33
@ Square
Definition meshnodesublayer.h:33
@ Circle
Definition meshnodesublayer.h:33
@ Triangle
Definition meshnodesublayer.h:33
void setShape(MarkerShape v)
Definition meshnodesublayer.h:64
double markerSizePx
Definition meshnodesublayer.h:38
void setOutlineColor(const QColor &v)
Definition meshnodesublayer.h:65
Definition meshnodesublayer.h:80
MeshNodeStyle * nodeStyle() const
Definition meshnodesublayer.h:101
void setVisible(bool v) override
Definition meshnodesublayer.cpp:67
qreal opacity() const override
Definition meshnodesublayer.h:91
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition meshnodesublayer.cpp:98
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition meshnodesublayer.h:94
void setOpacity(qreal o) override
Definition meshnodesublayer.cpp:74
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition meshnodesublayer.h:96
bool isVisible() const override
Definition meshnodesublayer.h:89
QString displayName() const override
Definition meshnodesublayer.h:87
QString id() const override
Definition meshnodesublayer.h:86
Kind kind() const override
Definition meshnodesublayer.h:85
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition meshnodesublayer.cpp:82
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
Toggleable visual aspect of an output layer.
Definition gisrasterlayer.h:40
MarkerShape
13 canonical marker shapes the Rule Model's Marker Symbol Layer supports (per RENDERING_RULE_MODEL_PL...
Definition markershape.h:53
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.