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
meshedgesublayer.h
Go to the documentation of this file.
1
18#ifndef OPENSWMM_RENDER_SUBLAYERS_MESHEDGESUBLAYER_H
19#define OPENSWMM_RENDER_SUBLAYERS_MESHEDGESUBLAYER_H
20
22#include "render/isublayer.h"
24
25#include <QColor>
26#include <QJsonObject>
27#include <QString>
28#include <Qt>
29
30namespace OpenSWMM::Render
31{
32
34{
35 Q_OBJECT
36 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY styleChanged)
37 Q_PROPERTY(double lineWidthPx READ lineWidthPx WRITE setLineWidthPx NOTIFY styleChanged)
38 Q_PROPERTY(Qt::PenStyle dashPattern READ dashPattern WRITE setDashPattern NOTIFY styleChanged)
40 Q_PROPERTY(double slopeBreak READ slopeBreak WRITE setSlopeBreak NOTIFY styleChanged)
41 Q_PROPERTY(double wideWidthPx READ wideWidthPx WRITE setWideWidthPx NOTIFY styleChanged)
42 Q_PROPERTY(QColor wideColor READ wideColor WRITE setWideColor NOTIFY styleChanged)
43
44 // Boundary-condition colouring moved to MeshBcStyle (meshbcsublayer.h)
45 // — BC indicators are their own sublayer now, with per-type visibility.
46 // Legacy "bc*"-prefixed JSON keys migrate in
47 // SWMM2DMeshLayer::onSublayersJsonLoaded.
48 // Slice US (mesh) — edges can be classified by slope through the shared
49 // ClassificationScheme. The default 2-class scheme mirrors the legacy
50 // thin/wide slope split (colour = colour, wideColor = high class); the
51 // renderer keeps the historic two-tier path until the scheme is
52 // customized. useSlopeDrivenWidth stays the on/off gate.
54
55 Q_CLASSINFO("group:color", "Symbology")
56 Q_CLASSINFO("group:lineWidthPx", "Symbology")
57 Q_CLASSINFO("group:dashPattern", "Symbology")
58 Q_CLASSINFO("group:useSlopeDrivenWidth", "Slope emphasis")
59 Q_CLASSINFO("group:slopeBreak", "Slope emphasis")
60 Q_CLASSINFO("group:wideWidthPx", "Slope emphasis")
61 Q_CLASSINFO("group:wideColor", "Slope emphasis")
62 Q_CLASSINFO("group:classification", "Classification")
63
64public:
65 explicit MeshEdgeStyle(QObject *parent = nullptr);
66
67 [[nodiscard]] QColor color() const { return m_color; }
68 [[nodiscard]] double lineWidthPx() const { return m_lineWidthPx; }
69 [[nodiscard]] Qt::PenStyle dashPattern() const { return m_dashPattern; }
70 [[nodiscard]] bool useSlopeDrivenWidth() const { return m_useSlopeDrivenWidth; }
71 [[nodiscard]] double slopeBreak() const { return m_slopeBreak; }
72 [[nodiscard]] double wideWidthPx() const { return m_wideWidthPx; }
73 [[nodiscard]] QColor wideColor() const { return m_wideColor; }
74
75 void setColor(const QColor &v) { if (m_color == v) return; m_color = v; setDirty(); }
76 void setLineWidthPx(double v);
77 void setDashPattern(Qt::PenStyle v) { if (m_dashPattern == v) return; m_dashPattern = v; setDirty(); }
78 void setUseSlopeDrivenWidth(bool v) { if (m_useSlopeDrivenWidth == v) return; m_useSlopeDrivenWidth = v; setDirty(); }
79 void setSlopeBreak(double v);
80 void setWideWidthPx(double v);
81 void setWideColor(const QColor &v) { if (m_wideColor == v) return; m_wideColor = v; setDirty(); }
82
86 [[nodiscard]] const ClassificationScheme &scheme() const { return m_scheme; }
87 void setScheme(const ClassificationScheme &s);
88
89 [[nodiscard]] QJsonObject toJson() const override;
90 void fromJson(const QJsonObject &j) override;
91
92private:
95 void seedSchemeFromLegacy();
96
97
98
99 QColor m_color = QColor(0, 0, 0, 130);
100 double m_lineWidthPx = 0.35;
101 Qt::PenStyle m_dashPattern = Qt::SolidLine;
102 bool m_useSlopeDrivenWidth = true;
103 double m_slopeBreak = 0.35; // fraction of maxSlope above which edges go wide
104 double m_wideWidthPx = 0.90;
105 QColor m_wideColor = QColor(0, 0, 0, 210);
106 ClassificationScheme m_scheme;
107};
108
110{
111 Q_OBJECT
112public:
113 explicit MeshEdgeSublayer(QString id_, QObject *parent = nullptr);
114
115 Kind kind() const override { return LineKind; }
116 QString id() const override { return m_id; }
117 QString displayName() const override { return tr("Mesh Edges"); }
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
124 bool isDynamic() const override { return false; }
125
126 SublayerStyle *style() override { return m_style; }
127
128 QList<LegendSymbolItem> legendSymbolItems() const override;
129 QSGNode *buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override;
130
131 [[nodiscard]] MeshEdgeStyle *edgeStyle() const { return m_style; }
132
133private:
134 QString m_id;
135 bool m_visible = true;
136 qreal m_opacity = 1.0;
137 MeshEdgeStyle *m_style;
138};
139
140} // namespace OpenSWMM::Render
141
142#endif
Shared classification model: mode + binner + ramp + range + per-class overrides, with a revision stam...
Definition classificationscheme.h:61
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Kind
Coarse taxonomy of sublayer paint behaviours.
Definition isublayer.h:100
@ LineKind
Definition isublayer.h:102
Definition meshedgesublayer.h:34
double lineWidthPx
Definition meshedgesublayer.h:37
QJsonObject toJson() const override
Serialize the style to JSON.
Definition meshedgesublayer.cpp:75
double slopeBreak() const
Definition meshedgesublayer.h:71
void setScheme(const ClassificationScheme &s)
Definition meshedgesublayer.cpp:44
void setWideWidthPx(double v)
Definition meshedgesublayer.cpp:67
void setWideColor(const QColor &v)
Definition meshedgesublayer.h:81
void setDashPattern(Qt::PenStyle v)
Definition meshedgesublayer.h:77
void setLineWidthPx(double v)
Definition meshedgesublayer.cpp:51
double wideWidthPx
Definition meshedgesublayer.h:41
double lineWidthPx() const
Definition meshedgesublayer.h:68
QColor wideColor() const
Definition meshedgesublayer.h:73
Qt::PenStyle dashPattern
Definition meshedgesublayer.h:38
QColor wideColor
Definition meshedgesublayer.h:42
void setSlopeBreak(double v)
Definition meshedgesublayer.cpp:59
void fromJson(const QJsonObject &j) override
Restore the style from JSON.
Definition meshedgesublayer.cpp:89
void setColor(const QColor &v)
Definition meshedgesublayer.h:75
bool useSlopeDrivenWidth() const
Definition meshedgesublayer.h:70
double slopeBreak
Definition meshedgesublayer.h:40
QColor color
Definition meshedgesublayer.h:36
OpenSWMM::Render::ClassificationScheme classification
Definition meshedgesublayer.h:53
double wideWidthPx() const
Definition meshedgesublayer.h:72
Qt::PenStyle dashPattern() const
Definition meshedgesublayer.h:69
void setUseSlopeDrivenWidth(bool v)
Definition meshedgesublayer.h:78
const ClassificationScheme & scheme() const
Definition meshedgesublayer.h:86
bool useSlopeDrivenWidth
Definition meshedgesublayer.h:39
Definition meshedgesublayer.h:110
QSGNode * buildOrUpdateNode(QSGNode *existing, const SublayerContext &) override
Build (or update) the QSG node tree for this sublayer.
Definition meshedgesublayer.cpp:159
SublayerStyle * style() override
Returns the property-bag QObject that owns this sublayer's style knobs.
Definition meshedgesublayer.h:126
void setVisible(bool v) override
Definition meshedgesublayer.cpp:127
bool isVisible() const override
Definition meshedgesublayer.h:119
MeshEdgeStyle * edgeStyle() const
Definition meshedgesublayer.h:131
QList< LegendSymbolItem > legendSymbolItems() const override
Returns the legend rows this sublayer contributes.
Definition meshedgesublayer.cpp:142
void setOpacity(qreal o) override
Definition meshedgesublayer.cpp:134
QString displayName() const override
Definition meshedgesublayer.h:117
Kind kind() const override
Definition meshedgesublayer.h:115
qreal opacity() const override
Definition meshedgesublayer.h:121
QString id() const override
Definition meshedgesublayer.h:116
bool isDynamic() const override
Whether this sublayer's output depends on the current animation period.
Definition meshedgesublayer.h:124
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
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
Definition contourchain.h:23
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.