30#ifndef OPENSWMM_RENDER_MULTIKINDRENDERER_H
31#define OPENSWMM_RENDER_MULTIKINDRENDERER_H
40#include <unordered_map>
53 return static_cast<std::size_t
>(
qHash(
s));
97 void setFallback(std::unique_ptr<IFeatureRenderer> r);
104 [[nodiscard]] std::vector<QString>
kinds()
const;
107 [[nodiscard]]
int kindCount()
const {
return m_perKind.size(); }
110 [[nodiscard]] QString
rendererId()
const override {
return QStringLiteral(
"multikind"); }
112 const QVariantMap &attrs)
const override;
114 [[nodiscard]] QJsonObject
toJson()
const override;
115 void fromJson(
const QJsonObject &j)
override;
116 [[nodiscard]] std::unique_ptr<IFeatureRenderer>
clone()
const override;
122 std::unordered_map<QString,
123 std::unique_ptr<IFeatureRenderer>,
125 std::unique_ptr<IFeatureRenderer> m_fallback;
Abstract interface — every vector layer's paint path goes here.
Definition ifeaturerenderer.h:85
Per-kind IFeatureRenderer dispatch for multi-kind layers.
Definition multikindrenderer.h:66
int kindCount() const
Number of registered per-kind renderers (excludes fallback).
Definition multikindrenderer.h:107
const IFeatureRenderer * rendererFor(const QString &kind) const
Returns the renderer registered for kind, or nullptr if no per-kind renderer exists for that key (cal...
Definition multikindrenderer.cpp:52
~MultiKindRenderer() override=default
SymbolStyle symbolFor(const FeatureRef &f, const QVariantMap &attrs) const override
Returns the SymbolStyle to paint for one feature.
Definition multikindrenderer.cpp:101
MultiKindRenderer()
Definition multikindrenderer.cpp:47
std::vector< QString > kinds() const
All registered kind keys in deterministic (sorted) order. Used by the legend pipeline and serialisati...
Definition multikindrenderer.cpp:91
IFeatureRenderer * fallback()
Definition multikindrenderer.h:96
void setFallback(std::unique_ptr< IFeatureRenderer > r)
Definition multikindrenderer.cpp:83
QString rendererId() const override
Stable string id ("single", "graduated", "categorized", "rule"). Used as the discriminator in JSON ro...
Definition multikindrenderer.h:110
QJsonObject toJson() const override
Serialises this renderer to a JSON object. The "id" field equals rendererId(); remaining keys are ren...
Definition multikindrenderer.cpp:143
const IFeatureRenderer * fallback() const
Renderer used when no per-kind entry matches the feature's categoryHint. Defaults to a SingleSymbolRe...
Definition multikindrenderer.h:95
void fromJson(const QJsonObject &j) override
Restores this renderer from a JSON object previously produced by toJson(). Implementations should tol...
Definition multikindrenderer.cpp:163
QList< LegendSymbolItem > legendSymbolItems() const override
Returns one LegendSymbolItem per visible legend row. Drives the legend dock, the on-canvas legend ove...
Definition multikindrenderer.cpp:114
void clearRendererFor(const QString &kind)
Removes the renderer for kind (no-op if not present).
Definition multikindrenderer.cpp:78
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 multikindrenderer.cpp:182
void setRendererFor(const QString &kind, std::unique_ptr< IFeatureRenderer > renderer)
Registers renderer as the per-kind renderer for kind, replacing any prior entry. Null renderer remove...
Definition multikindrenderer.cpp:64
The single seam every layer paint path goes through.
double s
Scene px per model length unit.
Definition inletdrawingview.cpp:82
Definition multikindrenderer.h:44
Definition gisrasterlayer.h:40
TokenKind kind
Definition queryparser.cpp:34
size_t qHash(const SWMMObjectRef &r, size_t seed=0)
Definition selectionmanager.h:89
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
std-style hash for QString so unordered_map can key on it without round-tripping through std::string....
Definition multikindrenderer.h:50
std::size_t operator()(const QString &s) const noexcept
Definition multikindrenderer.h:51