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
singlebandpseudocolorrenderer.h
Go to the documentation of this file.
1
26#ifndef OPENSWMM_RENDER_SINGLEBANDPSEUDOCOLORRENDERER_H
27#define OPENSWMM_RENDER_SINGLEBANDPSEUDOCOLORRENDERER_H
28
30#include "render/colorramp.h" // RampInterp — match legacy ramp fidelity (P5/R-1)
31
32#include <QColor>
33#include <QList>
34#include <QPair>
35
36namespace OpenSWMM::Render
37{
38
44{
45public:
49 using Stop = QPair<double, QColor>;
50
52 ~SingleBandPseudoColorRenderer() override = default;
53
60 [[nodiscard]] double minValue() const { return m_minValue; }
61 [[nodiscard]] double maxValue() const { return m_maxValue; }
62 void setRange(double minValue, double maxValue);
63
68 [[nodiscard]] const QList<Stop> &stops() const { return m_stops; }
69 void setStops(QList<Stop> stops);
70
75 [[nodiscard]] bool clampMin() const { return m_clampMin; }
76 void setClampMin(bool clamp) { m_clampMin = clamp; }
77
82 [[nodiscard]] bool clampMax() const { return m_clampMax; }
83 void setClampMax(bool clamp) { m_clampMax = clamp; }
84
91 [[nodiscard]] RampInterp interp() const { return m_interp; }
92 void setInterp(RampInterp i) { m_interp = i; }
93
94 // IRasterRenderer.
95 [[nodiscard]] QString rendererId() const override
96 {
97 return QStringLiteral("singlebandpseudocolor");
98 }
99 [[nodiscard]] QColor colorForValue(double value,
100 bool isNoData = false) const override;
101 [[nodiscard]] QList<LegendSymbolItem> legendSymbolItems() const override;
102 [[nodiscard]] QJsonObject toJson() const override;
103 void fromJson(const QJsonObject &j) override;
104 [[nodiscard]] std::unique_ptr<IRasterRenderer> clone() const override;
105
106private:
107 double m_minValue = 0.0;
108 double m_maxValue = 1.0;
109 QList<Stop> m_stops;
110 bool m_clampMin = false;
111 bool m_clampMax = false;
112 RampInterp m_interp = RampInterp::Rgb;
113};
114
115} // namespace OpenSWMM::Render
116
117#endif // OPENSWMM_RENDER_SINGLEBANDPSEUDOCOLORRENDERER_H
Abstract interface — every raster layer's paint path goes here.
Definition irasterrenderer.h:66
Continuous colour ramp for single-band raster data.
Definition singlebandpseudocolorrenderer.h:44
bool clampMin() const
When true, values strictly below minValue render as transparent instead of clamping to the first stop...
Definition singlebandpseudocolorrenderer.h:75
QList< LegendSymbolItem > legendSymbolItems() const override
Returns one LegendSymbolItem per visible legend row. Drives the legend dock, the on-canvas legend ove...
Definition singlebandpseudocolorrenderer.cpp:200
QJsonObject toJson() const override
Serialises this renderer to a JSON object. The "id" field equals rendererId(); remaining keys are ren...
Definition singlebandpseudocolorrenderer.cpp:225
QColor colorForValue(double value, bool isNoData=false) const override
Returns the display colour for one raw pixel value.
Definition singlebandpseudocolorrenderer.cpp:144
double minValue() const
The numeric range covered by the ramp. Values outside [minValue, maxValue] are clamped to the nearest...
Definition singlebandpseudocolorrenderer.h:60
void setClampMin(bool clamp)
Definition singlebandpseudocolorrenderer.h:76
void setRange(double minValue, double maxValue)
Definition singlebandpseudocolorrenderer.cpp:133
void setStops(QList< Stop > stops)
Definition singlebandpseudocolorrenderer.cpp:139
QPair< double, QColor > Stop
One ramp stop — a normalised position in [0,1] paired with a colour.
Definition singlebandpseudocolorrenderer.h:49
QString rendererId() const override
Stable string id ("singlebandpseudocolor", "singlebandgray", "paletted", "hillshade",...
Definition singlebandpseudocolorrenderer.h:95
void fromJson(const QJsonObject &j) override
Restores this renderer from a JSON object previously produced by toJson(). Implementations should tol...
Definition singlebandpseudocolorrenderer.cpp:238
const QList< Stop > & stops() const
Stops in ascending-position order. Callers must keep this invariant; setStops() does not sort.
Definition singlebandpseudocolorrenderer.h:68
double maxValue() const
Definition singlebandpseudocolorrenderer.h:61
void setClampMax(bool clamp)
Definition singlebandpseudocolorrenderer.h:83
void setInterp(RampInterp i)
Definition singlebandpseudocolorrenderer.h:92
bool clampMax() const
When true, values strictly above maxValue render as transparent instead of clamping to the last stop'...
Definition singlebandpseudocolorrenderer.h:82
RampInterp interp() const
Colour-space used between adjacent stops (Rgb / HsvShort / HsvLong). Carried so the renderer reproduc...
Definition singlebandpseudocolorrenderer.h:91
std::unique_ptr< IRasterRenderer > clone() const override
Deep copy. Owning layers / map presets / undo stack call this when they need a renderer snapshot deco...
Definition singlebandpseudocolorrenderer.cpp:249
RasterColorRamp — gradient mapping from a normalised value in [0,1] to a display QColor.
RampInterp
Colour-space used when interpolating between two adjacent ramp stops.
Definition colorramp.h:60
size_t i
Definition contourjob.cpp:27
Sister interface to IFeatureRenderer for single-band raster layers.
Definition gisrasterlayer.h:40