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
unclassedcolorsrenderer.h
Go to the documentation of this file.
1
28#ifndef OPENSWMM_RENDER_UNCLASSEDCOLORSRENDERER_H
29#define OPENSWMM_RENDER_UNCLASSEDCOLORSRENDERER_H
30
31#include "render/colorramp.h"
33
34#include <QColor>
35#include <QString>
36
37namespace OpenSWMM::Render
38{
39
46{
47public:
49 ~UnclassedColorsRenderer() override = default;
50
52 [[nodiscard]] QString classifyAttribute() const { return m_classifyAttribute; }
53 void setClassifyAttribute(QString name) { m_classifyAttribute = std::move(name); }
54
56 [[nodiscard]] const RasterColorRamp &ramp() const { return m_ramp; }
58
60 [[nodiscard]] double minValue() const { return m_ramp.minValue; }
61 [[nodiscard]] double maxValue() const { return m_ramp.maxValue; }
62 void setRange(double minValue, double maxValue);
63
67 [[nodiscard]] const SymbolStyle &baseSymbol() const { return m_baseSymbol; }
68 void setBaseSymbol(SymbolStyle s) { m_baseSymbol = std::move(s); }
69
72 [[nodiscard]] QColor belowRangeColor() const { return m_belowRange; }
73 void setBelowRangeColor(QColor c) { m_belowRange = c; }
74
76 [[nodiscard]] QColor aboveRangeColor() const { return m_aboveRange; }
77 void setAboveRangeColor(QColor c) { m_aboveRange = c; }
78
81 [[nodiscard]] QColor noDataColor() const { return m_noData; }
82 void setNoDataColor(QColor c) { m_noData = c; }
83
88 [[nodiscard]] int legendLabelCount() const { return m_legendLabelCount; }
89 void setLegendLabelCount(int n) { m_legendLabelCount = (n < 2) ? 2 : n; }
90
94 [[nodiscard]] QColor colorForValue(double v) const;
95
96 // IFeatureRenderer.
97 [[nodiscard]] QString rendererId() const override { return QStringLiteral("unclassed"); }
98 [[nodiscard]] SymbolStyle symbolFor(const FeatureRef &f,
99 const QVariantMap &attrs) const override;
100 [[nodiscard]] QList<LegendSymbolItem> legendSymbolItems() const override;
101 [[nodiscard]] QJsonObject toJson() const override;
102 void fromJson(const QJsonObject &j) override;
103 [[nodiscard]] std::unique_ptr<IFeatureRenderer> clone() const override;
104
105private:
106 QString m_classifyAttribute;
107 RasterColorRamp m_ramp = RasterColorRamp::viridis(0.0, 1.0);
108 SymbolStyle m_baseSymbol;
109 QColor m_belowRange;
110 QColor m_aboveRange;
111 QColor m_noData = QColor(0, 0, 0, 0);
112 int m_legendLabelCount = 5;
113};
114
115} // namespace OpenSWMM::Render
116
117#endif // OPENSWMM_RENDER_UNCLASSEDCOLORSRENDERER_H
Abstract interface — every vector layer's paint path goes here.
Definition ifeaturerenderer.h:85
Maps a continuous numeric attribute to a continuous colour ramp, no bin discretisation.
Definition unclassedcolorsrenderer.h:46
QJsonObject toJson() const override
Serialises this renderer to a JSON object. The "id" field equals rendererId(); remaining keys are ren...
Definition unclassedcolorsrenderer.cpp:125
const RasterColorRamp & ramp() const
Definition unclassedcolorsrenderer.h:56
void setClassifyAttribute(QString name)
Definition unclassedcolorsrenderer.h:53
void fromJson(const QJsonObject &j) override
Restores this renderer from a JSON object previously produced by toJson(). Implementations should tol...
Definition unclassedcolorsrenderer.cpp:144
QColor aboveRangeColor() const
Definition unclassedcolorsrenderer.h:76
QColor colorForValue(double v) const
Definition unclassedcolorsrenderer.cpp:54
void setBaseSymbol(SymbolStyle s)
Definition unclassedcolorsrenderer.h:68
QString classifyAttribute() const
Definition unclassedcolorsrenderer.h:52
const SymbolStyle & baseSymbol() const
Definition unclassedcolorsrenderer.h:67
double minValue() const
Definition unclassedcolorsrenderer.h:60
void setLegendLabelCount(int n)
Definition unclassedcolorsrenderer.h:89
QList< LegendSymbolItem > legendSymbolItems() const override
Returns one LegendSymbolItem per visible legend row. Drives the legend dock, the on-canvas legend ove...
Definition unclassedcolorsrenderer.cpp:100
void setAboveRangeColor(QColor c)
Definition unclassedcolorsrenderer.h:77
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 unclassedcolorsrenderer.cpp:164
void setBelowRangeColor(QColor c)
Definition unclassedcolorsrenderer.h:73
SymbolStyle symbolFor(const FeatureRef &f, const QVariantMap &attrs) const override
Returns the SymbolStyle to paint for one feature.
Definition unclassedcolorsrenderer.cpp:78
void setRamp(RasterColorRamp ramp)
Definition unclassedcolorsrenderer.cpp:41
QString rendererId() const override
Stable string id ("single", "graduated", "categorized", "rule"). Used as the discriminator in JSON ro...
Definition unclassedcolorsrenderer.h:97
void setNoDataColor(QColor c)
Definition unclassedcolorsrenderer.h:82
QColor belowRangeColor() const
Definition unclassedcolorsrenderer.h:72
void setRange(double minValue, double maxValue)
Definition unclassedcolorsrenderer.cpp:46
int legendLabelCount() const
Definition unclassedcolorsrenderer.h:88
QColor noDataColor() const
Definition unclassedcolorsrenderer.h:81
double maxValue() const
Definition unclassedcolorsrenderer.h:61
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
std::size_t n
Definition mesh2dresultsexport.cpp:426
Definition gisrasterlayer.h:40
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
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