27#ifndef OPENSWMM_RENDER_GRADUATEDRENDERER_H
28#define OPENSWMM_RENDER_GRADUATEDRENDERER_H
86 if (
name == m_sizeAttribute)
return;
87 m_sizeAttribute = std::move(
name);
90 m_sizeValueMin = m_sizeValueMax = 0.0;
96 return m_sizeAttribute.isEmpty() ? m_classifyAttribute : m_sizeAttribute;
103 return !m_sizeAttribute.isEmpty()
104 && m_sizeAttribute != m_classifyAttribute;
112 {
return m_sizeValueMax > m_sizeValueMin; }
114 { m_sizeValueMin = mn; m_sizeValueMax = mx; }
159 [[nodiscard]]
const QVector<double> &
lastBreaks()
const {
return m_lastBreaks; }
178 if (g && g->
lastBreaks().isEmpty() && !samples.isEmpty())
187 [[nodiscard]] QList<QColor>
binColors()
const;
243 [[nodiscard]]
double sizeForBin(
int bin)
const;
282 [[nodiscard]] QString
rendererId()
const override {
return QStringLiteral(
"graduated"); }
284 const QVariantMap &attrs)
const override;
286 [[nodiscard]] QJsonObject
toJson()
const override;
287 void fromJson(
const QJsonObject &j)
override;
288 [[nodiscard]] std::unique_ptr<IFeatureRenderer>
clone()
const override;
300 [[nodiscard]] QColor
colorForClass(
const QString &classKey)
const override;
301 void setColorForClass(
const QString &classKey,
const QColor &color)
override;
307 {
return m_binColorOverrides; }
310 QString m_classifyAttribute;
313 QString m_sizeAttribute;
314 double m_sizeValueMin = 0.0;
315 double m_sizeValueMax = 0.0;
318 QVector<double> m_lastBreaks;
322 bool m_outputColorEnabled =
true;
323 bool m_outputSizeEnabled =
false;
324 double m_outputSizeMin = 2.0;
325 double m_outputSizeMax = 14.0;
328 bool m_outputWidthEnabled =
false;
329 double m_outputWidthMin = 0.5;
330 double m_outputWidthMax = 6.0;
337 QHash<int, QColor> m_binColorOverrides;
P2 — the static/dynamic styling spine.
Classifies a numeric attribute into bins and assigns a colour per bin.
Definition graduatedrenderer.h:63
double minValue() const
Convenience accessor for the ramp's value range. Equivalent to ramp().minValue / ....
Definition graduatedrenderer.h:137
QColor colorForBin(int bin) const
Returns the colour for one already-computed bin index. Sampled from the ramp at midpoint (i + 0....
Definition graduatedrenderer.cpp:183
double sizeForValue(double v) const
Value-interpolated size for the independent size axis: linear map of v (clamped) from [sizeValueMin,...
Definition graduatedrenderer.cpp:148
bool sizeValueRangeValid() const
Definition graduatedrenderer.h:111
QString sizeAttribute() const
Independent attribute driving the size / width output axes. Empty (the default) = follow classifyAttr...
Definition graduatedrenderer.h:83
double widthForValue(double v) const
Definition graduatedrenderer.cpp:174
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 graduatedrenderer.h:296
void clearClassEditOverrides() override
Drop every per-class override applied via the setters above. The renderer falls back to its ramp / ca...
Definition graduatedrenderer.cpp:222
double widthForBin(int bin) const
Bin-mapped line width, mirroring sizeForBin over the width range. Returns outputWidthMin for single-b...
Definition graduatedrenderer.cpp:163
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 graduatedrenderer.cpp:211
RangeMode rangeMode() const
P2 — how the value range behaves over the time axis. The owning results layer consumes this on each t...
Definition graduatedrenderer.h:129
bool outputWidthEnabled() const
VS.4 — independent line-WIDTH output axis. Marker "size" and line "width" are distinct visual channel...
Definition graduatedrenderer.h:264
void setSourceKind(AttributeSourceKind k)
Definition graduatedrenderer.h:122
void setRangeMode(RangeMode m)
Definition graduatedrenderer.h:130
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 graduatedrenderer.cpp:487
double sizeValueMax() const
Definition graduatedrenderer.h:110
bool outputSizeEnabled() const
Slice BI Phase 8.13.43-α — Graduated tab's "Output axes" toggle for size/width. When outputSizeEnable...
Definition graduatedrenderer.h:227
double outputSizeMin() const
Definition graduatedrenderer.h:233
QString effectiveSizeAttribute() const
Definition graduatedrenderer.h:94
void setBinner(IntervalBinner b)
Definition graduatedrenderer.cpp:68
QColor colorForValue(double v) const
Returns the colour for one raw attribute value. Clamps to [bin 0, bin N−1]. Returns Qt::transparent w...
Definition graduatedrenderer.cpp:227
void fromJson(const QJsonObject &j) override
Restores this renderer from a JSON object previously produced by toJson(). Implementations should tol...
Definition graduatedrenderer.cpp:394
bool sizeAxisIndependent() const
Definition graduatedrenderer.h:101
void setSizeValueRange(double mn, double mx)
Definition graduatedrenderer.h:113
SymbolStyle symbolFor(const FeatureRef &f, const QVariantMap &attrs) const override
Returns the SymbolStyle to paint for one feature.
Definition graduatedrenderer.cpp:249
void setClassifyAttribute(QString name)
Definition graduatedrenderer.h:73
void setOutputWidthEnabled(bool on)
Definition graduatedrenderer.h:265
void setOutputWidthRange(double minPx, double maxPx)
Definition graduatedrenderer.cpp:157
void setBinColors(QList< QColor > colors)
Definition graduatedrenderer.cpp:89
double outputWidthMax() const
Definition graduatedrenderer.h:268
QList< QColor > binColors() const
Per-bin colours (derived view). Computed from the ramp + binCount at request time; kept on the legacy...
Definition graduatedrenderer.cpp:79
double outputWidthMin() const
Definition graduatedrenderer.h:267
void setBaseSymbol(SymbolStyle s)
Definition graduatedrenderer.cpp:100
QList< LegendSymbolItem > legendSymbolItems() const override
Returns one LegendSymbolItem per visible legend row. Drives the legend dock, the on-canvas legend ove...
Definition graduatedrenderer.cpp:318
QString classifyAttribute() const
Name of the attribute key (in QVariantMap attrs) to classify on. Typical SWMM values: "depth",...
Definition graduatedrenderer.h:72
void setRange(double minValue, double maxValue)
Definition graduatedrenderer.cpp:57
const SymbolStyle & baseSymbol() const
The SymbolStyle template. At paint time the renderer overrides the "color" property of every SymbolLa...
Definition graduatedrenderer.h:196
QString rendererId() const override
Stable string id ("single", "graduated", "categorized", "rule"). Used as the discriminator in JSON ro...
Definition graduatedrenderer.h:282
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 graduatedrenderer.cpp:200
const IntervalBinner & binner() const
The interval binner that maps attribute values → bin indices.
Definition graduatedrenderer.h:151
void autoClassify(const QVector< double > &samples)
Recomputes interval breaks + ramp range from a sample of attribute values. NaNs and infinities are sk...
Definition graduatedrenderer.cpp:105
~GraduatedRenderer() override=default
bool outputColorEnabled() const
Definition graduatedrenderer.h:230
int binCount() const
Definition graduatedrenderer.h:189
void clearBreaks()
Drops the cached breaks so the next classify pass (driven by the owning layer's rebuild) re-derives t...
Definition graduatedrenderer.h:167
GraduatedRenderer()=default
void setRamp(RasterColorRamp ramp)
Definition graduatedrenderer.cpp:63
double maxValue() const
Definition graduatedrenderer.h:138
const QHash< int, QColor > & binColorOverrides() const noexcept
Inspect currently-stored per-bin colour overrides — primarily for unit tests + the property dialog's ...
Definition graduatedrenderer.h:306
void setOutputColorEnabled(bool on)
Definition graduatedrenderer.h:231
double outputSizeMax() const
Definition graduatedrenderer.h:234
QJsonObject toJson() const override
Serialises this renderer to a JSON object. The "id" field equals rendererId(); remaining keys are ren...
Definition graduatedrenderer.cpp:352
void setOutputSizeEnabled(bool on)
Definition graduatedrenderer.h:228
const RasterColorRamp & ramp() const
The colour ramp used to derive per-bin colours. Sampled at each bin's midpoint (i + 0....
Definition graduatedrenderer.h:145
AttributeSourceKind sourceKind() const
P2 — whether classifyAttribute() is a STATIC model/GIS field (classified once) or a DYNAMIC SWMM outp...
Definition graduatedrenderer.h:121
const QVector< double > & lastBreaks() const
The last set of interior break values computed by the binner. Kept on the renderer so paint-time binF...
Definition graduatedrenderer.h:159
double sizeForBin(int bin) const
Returns the bin-midpoint-mapped size for a bin index, when outputSizeEnabled. Linear interpolation be...
Definition graduatedrenderer.cpp:137
double sizeValueMin() const
Definition graduatedrenderer.h:109
void setSizeAttribute(QString name)
Definition graduatedrenderer.h:84
void setOutputSizeRange(double minPx, double maxPx)
Definition graduatedrenderer.cpp:131
static void classifyIfNeeded(GraduatedRenderer *g, const QVector< double > &samples)
Shared classify gate used by every owning layer's rebuild so the model + results paths cannot drift....
Definition graduatedrenderer.h:176
Abstract interface — every vector layer's paint path goes here.
Definition ifeaturerenderer.h:85
Computes break values + maps a value to a bin index.
Definition intervalbinner.h:49
int binCount() const
Definition intervalbinner.h:56
RasterColorRamp — gradient mapping from a normalised value in [0,1] to a display QColor.
The single seam every layer paint path goes through.
double s
Scene px per model length unit.
Definition inletdrawingview.cpp:82
Slice BB-α — classifies a set of numeric samples into N bins.
MaskMode m
Definition maskspec.cpp:18
int k
Definition mesh2dresultsexport.cpp:549
int b
local residual indices, a < b
Definition meshquadmatch.cpp:46
Definition gisrasterlayer.h:40
RangeMode
Definition attributesource.h:39
ClassEditKind
Categories of per-class mutation that a renderer may support.
Definition ifeaturerenderer.h:64
AttributeSourceKind
Definition attributesource.h:34
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
TokenKind kind
Definition queryparser.cpp:34
QString name
Definition sectionmodelbuilders.cpp:474
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
Gradient mapping from a normalised value in [0,1] to a QColor.
Definition colorramp.h:71
double minValue
Definition colorramp.h:72
static RasterColorRamp viridis(double min=0.0, double max=1.0)
Definition colorramp.cpp:200
double maxValue
Definition colorramp.h:73