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
categorizedrenderer.h
Go to the documentation of this file.
1
23#ifndef OPENSWMM_RENDER_CATEGORIZEDRENDERER_H
24#define OPENSWMM_RENDER_CATEGORIZEDRENDERER_H
25
27
28#include <QHash>
29#include <QString>
30
31namespace OpenSWMM::Render
32{
33
41{
42public:
47 struct Category
48 {
49 QString value;
50 QString label;
52 };
53
55 ~CategorizedRenderer() override = default;
56
60 [[nodiscard]] QString classifyAttribute() const { return m_classifyAttribute; }
61 void setClassifyAttribute(QString name) { m_classifyAttribute = std::move(name); }
62
63 [[nodiscard]] const QList<Category> &categories() const { return m_categories; }
64 void setCategories(QList<Category> cats);
65 void addCategory(Category c);
66
71 [[nodiscard]] const SymbolStyle &fallbackSymbol() const { return m_fallback; }
72 void setFallbackSymbol(SymbolStyle s) { m_fallback = std::move(s); }
73
74 // IFeatureRenderer.
75 [[nodiscard]] QString rendererId() const override { return QStringLiteral("categorized"); }
76 [[nodiscard]] SymbolStyle symbolFor(const FeatureRef &f,
77 const QVariantMap &attrs) const override;
78 [[nodiscard]] QList<LegendSymbolItem> legendSymbolItems() const override;
79 [[nodiscard]] QJsonObject toJson() const override;
80 void fromJson(const QJsonObject &j) override;
81 [[nodiscard]] std::unique_ptr<IFeatureRenderer> clone() const override;
82
83 // ── Per-class editing (Slice BB Phase 8.6.16) ──────────────────────
84 // classKey is the category index as a string ("0", "1", …). The
85 // per-class color edit writes the colour into every layer of
86 // m_categories[idx].symbol that already has a "color" slot. Symbol
87 // swap replaces the whole SymbolStyle on that category. Size / width
88 // are not editable here (use setSymbolForClass for full control).
89 [[nodiscard]] bool supportsClassEdit(ClassEditKind kind) const override
90 {
92 }
93 [[nodiscard]] QColor colorForClass(const QString &classKey) const override;
94 void setColorForClass(const QString &classKey, const QColor &color) override;
95 void setSymbolForClass(const QString &classKey, const SymbolStyle &style) override;
96
97private:
98 QString m_classifyAttribute;
99 QList<Category> m_categories;
100 SymbolStyle m_fallback;
101};
102
103} // namespace OpenSWMM::Render
104
105#endif // OPENSWMM_RENDER_CATEGORIZEDRENDERER_H
Distinct symbol per unique value of a string / enum attribute.
Definition categorizedrenderer.h:41
std::unique_ptr< IFeatureRenderer > clone() const override
Deep copy. Owning layers / map presets / undo stack call this when they need a renderer snapshot deco...
Definition categorizedrenderer.cpp:95
const QList< Category > & categories() const
Definition categorizedrenderer.h:63
void setCategories(QList< Category > cats)
Definition categorizedrenderer.cpp:17
void setFallbackSymbol(SymbolStyle s)
Definition categorizedrenderer.h:72
QString rendererId() const override
Stable string id ("single", "graduated", "categorized", "rule"). Used as the discriminator in JSON ro...
Definition categorizedrenderer.h:75
void setClassifyAttribute(QString name)
Definition categorizedrenderer.h:61
void setColorForClass(const QString &classKey, const QColor &color) override
Override the colour for the class identified by classKey. Has no effect when supportsClassEdit(Color)...
Definition categorizedrenderer.cpp:112
QList< LegendSymbolItem > legendSymbolItems() const override
Returns one LegendSymbolItem per visible legend row. Drives the legend dock, the on-canvas legend ove...
Definition categorizedrenderer.cpp:38
SymbolStyle symbolFor(const FeatureRef &f, const QVariantMap &attrs) const override
Returns the SymbolStyle to paint for one feature.
Definition categorizedrenderer.cpp:27
QColor colorForClass(const QString &classKey) const override
Read the current colour for classKey. Returns an invalid QColor when the renderer has no explicit val...
Definition categorizedrenderer.cpp:102
bool supportsClassEdit(ClassEditKind kind) const override
True if this renderer can mutate kind on a per-class basis. Defaults to false so opt-in is explicit.
Definition categorizedrenderer.h:89
QString classifyAttribute() const
Name of the attribute key (in QVariantMap attrs) to look up.
Definition categorizedrenderer.h:60
void setSymbolForClass(const QString &classKey, const SymbolStyle &style) override
Wholesale-replace the SymbolStyle for classKey. No-op when supportsClassEdit(Symbol) is false.
Definition categorizedrenderer.cpp:121
void addCategory(Category c)
Definition categorizedrenderer.cpp:22
QJsonObject toJson() const override
Serialises this renderer to a JSON object. The "id" field equals rendererId(); remaining keys are ren...
Definition categorizedrenderer.cpp:56
const SymbolStyle & fallbackSymbol() const
Symbol returned when a feature's attribute value does not match any category. Defaults to an empty Sy...
Definition categorizedrenderer.h:71
void fromJson(const QJsonObject &j) override
Restores this renderer from a JSON object previously produced by toJson(). Implementations should tol...
Definition categorizedrenderer.cpp:77
Abstract interface — every vector layer's paint path goes here.
Definition ifeaturerenderer.h:85
The single seam every layer paint path goes through.
double s
Scene px per model length unit.
Definition inletdrawingview.cpp:82
Definition gisrasterlayer.h:40
ClassEditKind
Categories of per-class mutation that a renderer may support.
Definition ifeaturerenderer.h:64
TokenKind kind
Definition queryparser.cpp:34
QString name
Definition sectionmodelbuilders.cpp:474
One named category and its symbol.
Definition categorizedrenderer.h:48
SymbolStyle symbol
Definition categorizedrenderer.h:51
QString value
Definition categorizedrenderer.h:49
QString label
Definition categorizedrenderer.h:50
Identifies one feature in one layer for the renderer pipeline.
Definition featureref.h:35
Stack of SymbolLayer paint passes (bottom-up) plus an overall opacity.
Definition symbolstyle.h:39