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
colorramp.h
Go to the documentation of this file.
1
33#ifndef OPENSWMM_RENDER_COLORRAMP_H
34#define OPENSWMM_RENDER_COLORRAMP_H
35
36#include <QColor>
37#include <QGradientStops>
38#include <QJsonObject>
39#include <QMetaType>
40#include <QString>
41#include <QStringList>
42
59enum class RampInterp : int
60{
61 Rgb = 0,
62 HsvShort = 1,
63 HsvLong = 2
64};
65
71{
72 double minValue = 0.0;
73 double maxValue = 1.0;
74 QGradientStops stops;
75 bool clampMin = false;
76 bool clampMax = false;
80 [[nodiscard]] QColor colorAt(double normalisedPos) const;
81
83 [[nodiscard]] QColor colorForValue(double value) const;
84
86 [[nodiscard]] QJsonObject toJson() const;
87 static RasterColorRamp fromJson(const QJsonObject &j);
88
89 // ── Built-in catalogue ───────────────────────────────────────────────
90 //
91 // Stops for all built-ins are authored assuming RGB interpolation (the
92 // published palettes were tuned that way). The `interp` field defaults
93 // to Rgb to honour that.
94
95 [[nodiscard]] static RasterColorRamp grayscale(double min = 0.0, double max = 255.0);
96 [[nodiscard]] static RasterColorRamp viridis(double min = 0.0, double max = 1.0);
97 [[nodiscard]] static RasterColorRamp plasma(double min = 0.0, double max = 1.0);
98 [[nodiscard]] static RasterColorRamp magma(double min = 0.0, double max = 1.0);
99 [[nodiscard]] static RasterColorRamp inferno(double min = 0.0, double max = 1.0);
100 [[nodiscard]] static RasterColorRamp cividis(double min = 0.0, double max = 1.0);
101 [[nodiscard]] static RasterColorRamp turbo(double min = 0.0, double max = 1.0);
102 [[nodiscard]] static RasterColorRamp rdBu(double min = 0.0, double max = 1.0);
103 [[nodiscard]] static RasterColorRamp rdYlGn(double min = 0.0, double max = 1.0);
104 [[nodiscard]] static RasterColorRamp spectral(double min = 0.0, double max = 1.0);
105 [[nodiscard]] static RasterColorRamp brBG(double min = 0.0, double max = 1.0);
106 [[nodiscard]] static RasterColorRamp legacySWMM5Interval(double min = 0.0, double max = 1.0);
107 [[nodiscard]] static RasterColorRamp legacySWMMPollutant(double min = 0.0, double max = 1.0);
112 [[nodiscard]] static RasterColorRamp terrain(double min = 0.0, double max = 1.0);
113
114 // Slice BB-β (2026-05-25) — Plotly's continuous palettes from
115 // plotly.colors.sequential / .diverging. Stops authored per Plotly's
116 // reference; all RGB-interp by default.
117 [[nodiscard]] static RasterColorRamp plotly3(double min = 0.0, double max = 1.0);
118 [[nodiscard]] static RasterColorRamp iceFire(double min = 0.0, double max = 1.0);
119 [[nodiscard]] static RasterColorRamp blackbody(double min = 0.0, double max = 1.0);
120 [[nodiscard]] static RasterColorRamp electric(double min = 0.0, double max = 1.0);
121 [[nodiscard]] static RasterColorRamp hot(double min = 0.0, double max = 1.0);
122 [[nodiscard]] static RasterColorRamp jet(double min = 0.0, double max = 1.0);
123 [[nodiscard]] static RasterColorRamp picnic(double min = 0.0, double max = 1.0);
124 [[nodiscard]] static RasterColorRamp portland(double min = 0.0, double max = 1.0);
125 [[nodiscard]] static RasterColorRamp rainbow(double min = 0.0, double max = 1.0);
126 [[nodiscard]] static RasterColorRamp bluered(double min = 0.0, double max = 1.0);
127
135 [[nodiscard]] static RasterColorRamp waterDepth(double min = 0.0, double max = 1.0);
136
145 [[nodiscard]] static RasterColorRamp builtin(const QString &name);
146
149 [[nodiscard]] static QStringList builtinNames();
150};
151
152Q_DECLARE_METATYPE(RasterColorRamp)
153
154#endif // OPENSWMM_RENDER_COLORRAMP_H
RampInterp
Colour-space used when interpolating between two adjacent ramp stops.
Definition colorramp.h:60
std::vector< float > max
empty unless hasMax
Definition mesh2dresultsexport.cpp:296
double min
Definition meshcellparams.cpp:26
QString name
Definition sectionmodelbuilders.cpp:474
Gradient mapping from a normalised value in [0,1] to a QColor.
Definition colorramp.h:71
static RasterColorRamp picnic(double min=0.0, double max=1.0)
Definition colorramp.cpp:518
static RasterColorRamp terrain(double min=0.0, double max=1.0)
Definition colorramp.cpp:391
static RasterColorRamp rdYlGn(double min=0.0, double max=1.0)
Definition colorramp.cpp:310
static RasterColorRamp waterDepth(double min=0.0, double max=1.0)
Definition colorramp.cpp:587
static RasterColorRamp legacySWMMPollutant(double min=0.0, double max=1.0)
Definition colorramp.cpp:375
double minValue
Definition colorramp.h:72
static RasterColorRamp portland(double min=0.0, double max=1.0)
Definition colorramp.cpp:540
static RasterColorRamp rainbow(double min=0.0, double max=1.0)
Definition colorramp.cpp:555
RampInterp interp
Definition colorramp.h:77
static RasterColorRamp electric(double min=0.0, double max=1.0)
Definition colorramp.cpp:471
static RasterColorRamp blackbody(double min=0.0, double max=1.0)
Definition colorramp.cpp:456
static QStringList builtinNames()
Definition colorramp.cpp:669
static RasterColorRamp grayscale(double min=0.0, double max=255.0)
Definition colorramp.cpp:191
static RasterColorRamp spectral(double min=0.0, double max=1.0)
Definition colorramp.cpp:325
static RasterColorRamp magma(double min=0.0, double max=1.0)
Definition colorramp.cpp:234
static RasterColorRamp fromJson(const QJsonObject &j)
Definition colorramp.cpp:152
static RasterColorRamp plotly3(double min=0.0, double max=1.0)
Definition colorramp.cpp:418
static RasterColorRamp viridis(double min=0.0, double max=1.0)
Definition colorramp.cpp:200
bool clampMax
Definition colorramp.h:76
QColor colorAt(double normalisedPos) const
Definition colorramp.cpp:78
static RasterColorRamp brBG(double min=0.0, double max=1.0)
Definition colorramp.cpp:342
static RasterColorRamp builtin(const QString &name)
Definition colorramp.cpp:655
static RasterColorRamp plasma(double min=0.0, double max=1.0)
Definition colorramp.cpp:219
QGradientStops stops
Definition colorramp.h:74
static RasterColorRamp cividis(double min=0.0, double max=1.0)
Definition colorramp.cpp:264
static RasterColorRamp bluered(double min=0.0, double max=1.0)
Definition colorramp.cpp:574
bool clampMin
Definition colorramp.h:75
static RasterColorRamp rdBu(double min=0.0, double max=1.0)
Definition colorramp.cpp:294
static RasterColorRamp iceFire(double min=0.0, double max=1.0)
Definition colorramp.cpp:436
static RasterColorRamp legacySWMM5Interval(double min=0.0, double max=1.0)
Definition colorramp.cpp:358
double maxValue
Definition colorramp.h:73
static RasterColorRamp turbo(double min=0.0, double max=1.0)
Definition colorramp.cpp:279
static RasterColorRamp hot(double min=0.0, double max=1.0)
Definition colorramp.cpp:486
static RasterColorRamp inferno(double min=0.0, double max=1.0)
Definition colorramp.cpp:249
static RasterColorRamp jet(double min=0.0, double max=1.0)
Definition colorramp.cpp:500
QColor colorForValue(double value) const
Definition colorramp.cpp:115
QJsonObject toJson() const
Definition colorramp.cpp:131