16#ifndef QGSCOLORRAMPIMPL_H
17#define QGSCOLORRAMPIMPL_H
28using namespace Qt::StringLiterals;
32typedef QColor( *InterpolateColorFunc )(
const QColor &c1,
const QColor &c2,
const double value,
Qgis::AngularDirection direction );
64 return !( *
this == other );
76 QColor::Spec
colorSpec()
const {
return mColorSpec; }
89 void setColorSpec( QColor::Spec spec );
117 QColor::Spec mColorSpec = QColor::Spec::Rgb;
119 InterpolateColorFunc mFunc =
nullptr;
129#define DEFAULT_GRADIENT_COLOR1 QColor(69, 116, 40)
130#define DEFAULT_GRADIENT_COLOR2 QColor(188, 220, 60)
152 bool discrete =
false,
159 double value(
int index )
const override;
160 QColor color(
double value )
const override;
169 QString type()
const override;
170 void invert()
override;
172 QVariantMap properties() const override;
227 void convertToDiscrete(
bool discrete );
263 void addStopsToGradient( QGradient *gradient,
double opacity = 1 )
const;
287 void setColorSpec( QColor::Spec spec );
322 InterpolateColorFunc
mFunc =
nullptr;
327#define DEFAULT_RANDOM_COUNT 10
328#define DEFAULT_RANDOM_HUE_MIN 0
329#define DEFAULT_RANDOM_HUE_MAX 359
330#define DEFAULT_RANDOM_VAL_MIN 200
331#define DEFAULT_RANDOM_VAL_MAX 240
332#define DEFAULT_RANDOM_SAT_MIN 100
333#define DEFAULT_RANDOM_SAT_MAX 240
367 double value(
int index )
const override;
377 QString type()
const override;
379 QVariantMap properties() const override;
385 static QList<QColor> randomColors(
int count,
498 int count()
const override;
500 double value(
int index )
const override;
519 QString type()
const override;
523 QVariantMap properties() const override;
573 QList< QColor > colors()
const;
575 double value(
int index )
const override;
576 QColor color(
double value )
const override;
585 QString type()
const override;
586 void invert()
override;
588 QVariantMap properties() const override;
589 int count() const override;
592 QgsNamedColorList fetchColors(
const QString &context = QString(),
const QColor &baseColor = QColor() )
override;
601#define DEFAULT_COLORBREWER_SCHEMENAME "Spectral"
602#define DEFAULT_COLORBREWER_COLORS 5
621 bool inverted =
false );
631 double value(
int index )
const override;
642 void invert()
override;
644 QVariantMap properties() const override;
679 static QStringList listSchemeNames();
687 static QList<int> listSchemeVariants(
const QString &schemeName );
701#define DEFAULT_CPTCITY_SCHEMENAME "cb/div/BrBG_"
702#define DEFAULT_CPTCITY_VARIANTNAME "05"
723 bool inverted =
false,
724 bool doLoadFile =
true );
735 const QString &
variantName = QString(),
bool inverted =
false,
736 bool doLoadFile =
true );
748 QString type()
const override;
750 void invert()
override;
756 QVariantMap properties() const override;
778 static QString fileNameForVariant(
const QString &schema,
const QString &variant )
SIP_SKIP;
780 QString fileName()
const;
784 QString copyingFileName()
const;
785 QString descFileName()
const;
AngularDirection
Angular directions.
@ CounterClockwise
Counter-clockwise direction.
Color ramp utilising "Color Brewer" preset color schemes.
QColor color(double value) const override
Returns the color corresponding to a specified value.
int count() const override
Returns number of defined colors, or -1 if undefined.
static QString typeString()
Returns the string identifier for QgsColorBrewerColorRamp.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map...
QString type() const override
Returns a string representing the color ramp type.
double value(int index) const override
Returns relative value between [0,1] of color at specified index.
QString schemeName() const
Returns the name of the color brewer color scheme.
int colors() const
Returns the number of colors in the ramp.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
QgsColorBrewerColorRamp(const QString &schemeName=DEFAULT_COLORBREWER_SCHEMENAME, int colors=DEFAULT_COLORBREWER_COLORS, bool inverted=false)
Constructor for QgsColorBrewerColorRamp.
void setSchemeName(const QString &schemeName)
Sets the name of the color brewer color scheme.
void setColors(int colors)
Sets the number of colors in the ramp.
void loadPalette()
Generates the scheme using the current name and number of colors.
Abstract base class for color ramps.
A color ramp from the CPT City collection.
void setName(const QString &schemeName, const QString &variantName=QString(), const QStringList &variantList=QStringList())
void setSchemeName(const QString &schemeName)
void setVariantList(const QStringList &variantList)
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
QgsCptCityColorRamp(const QString &schemeName=DEFAULT_CPTCITY_SCHEMENAME, const QString &variantName=DEFAULT_CPTCITY_VARIANTNAME, bool inverted=false, bool doLoadFile=true)
Constructor for QgsCptCityColorRamp.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
QStringList variantList() const
void setVariantName(const QString &variantName)
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
bool hasMultiStops() const
QString schemeName() const
QString variantName() const
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
QgsGradientStopsList mStops
void setColor1(const QColor &color)
Sets the gradient start color.
void setColor2(const QColor &color)
Sets the gradient end color.
void setInfo(const QgsStringMap &info)
Sets additional info to attach to the gradient ramp (e.g., authorship notes).
bool isDiscrete() const
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating betw...
int count() const override
Returns number of defined colors, or -1 if undefined.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsColorRamp from a map of properties.
QgsStringMap info() const
Returns any additional info attached to the gradient ramp (e.g., authorship notes).
Qgis::AngularDirection mDirection
QColor::Spec colorSpec() const
Returns the color specification in which the color component interpolation will occur.
QColor color(double value) const override
Returns the color corresponding to a specified value.
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
QgsGradientColorRamp(const QColor &color1=DEFAULT_GRADIENT_COLOR1, const QColor &color2=DEFAULT_GRADIENT_COLOR2, bool discrete=false, const QgsGradientStopsList &stops=QgsGradientStopsList())
Constructor for QgsGradientColorRamp.
QColor color1() const
Returns the gradient start color.
void setDirection(Qgis::AngularDirection direction)
Sets the direction to traverse the color wheel using when interpolating hue-based color specification...
Qgis::AngularDirection direction() const
Returns the direction to traverse the color wheel using when interpolating hue-based color specificat...
QgsGradientStopsList stops() const
Returns the list of intermediate gradient stops for the ramp.
void setDiscrete(bool discrete)
Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating betwe...
InterpolateColorFunc mFunc
QColor color2() const
Returns the gradient end color.
Qgis::AngularDirection direction() const
Returns the direction to traverse the color wheel using when interpolating hue-based color specificat...
bool operator==(const QgsGradientStop &other) const
QColor::Spec colorSpec() const
Returns the color specification in which the color component interpolation will occur.
double offset
Relative positional offset, between 0 and 1.
bool operator!=(const QgsGradientStop &other) const
void setDirection(Qgis::AngularDirection direction)
Sets the direction to traverse the color wheel using when interpolating hue-based color specification...
friend class QgsGradientColorRamp
QColor color
Gradient color at stop.
QgsGradientStop(double offset, const QColor &color)
Constructor for QgsGradientStop.
Constrained random color ramp, which returns random colors based on preset parameters.
static QString typeString()
Returns the string identifier for QgsLimitedRandomColorRamp.
void setSatMin(int val)
Sets the minimum saturation for generated colors.
int count() const override
Returns number of defined colors, or -1 if undefined.
void setHueMin(int val)
Sets the minimum hue for generated colors.
void setSatMax(int val)
Sets the maximum saturation for generated colors.
QColor color(double value) const override
Returns the color corresponding to a specified value.
double value(int index) const override
Returns relative value between [0,1] of color at specified index.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
int valMax() const
Returns the maximum value for generated colors.
int satMax() const
Returns the maximum saturation for generated colors.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string m...
void setHueMax(int val)
Sets the maximum hue for generated colors.
void setCount(int val)
Sets the number of colors contained in the ramp.
int hueMax() const
Returns the maximum hue for generated colors.
int hueMin() const
Returns the minimum hue for generated colors.
void setValMax(int val)
Sets the maximum value for generated colors.
int valMin() const
Returns the minimum value for generated colors.
QgsLimitedRandomColorRamp(int count=DEFAULT_RANDOM_COUNT, int hueMin=DEFAULT_RANDOM_HUE_MIN, int hueMax=DEFAULT_RANDOM_HUE_MAX, int satMin=DEFAULT_RANDOM_SAT_MIN, int satMax=DEFAULT_RANDOM_SAT_MAX, int valMin=DEFAULT_RANDOM_VAL_MIN, int valMax=DEFAULT_RANDOM_VAL_MAX)
Constructor for QgsLimitedRandomColorRamp.
void setValMin(int val)
Sets the minimum value for generated colors.
int satMin() const
Returns the minimum saturation for generated colors.
A scheme based color ramp consisting of a list of predefined colors.
bool setColors(const QgsNamedColorList &colors, const QString &=QString(), const QColor &=QColor()) override
Sets the list of colors used by the ramp.
QList< QColor > colors() const
Returns the list of colors used by the ramp.
QString schemeName() const override
Gets the name for the color scheme.
static QString typeString()
Returns the string identifier for QgsPresetSchemeColorRamp.
QVariantMap properties() const override
Returns a string map containing all the color ramp's properties.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string ma...
QgsPresetSchemeColorRamp(const QList< QColor > &colors=QList< QColor >())
Constructor for QgsPresetSchemeColorRamp.
bool isEditable() const override
Returns whether the color scheme is editable.
A color ramp consisting of random colors, constrained within component ranges.
double value(int index) const override
Returns relative value between [0,1] of color at specified index.
QList< QColor > mPrecalculatedColors
QgsRandomColorRamp()=default
static QString typeString()
Returns the string identifier for QgsRandomColorRamp.
int count() const override
Returns number of defined colors, or -1 if undefined.
virtual void setTotalColorCount(int colorCount)
Sets the desired total number of unique colors for the resultant ramp.
QColor color(double value) const override
Returns the color corresponding to a specified value.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
QMap< QString, QString > QgsStringMap
#define DEFAULT_COLORBREWER_COLORS
#define DEFAULT_COLORBREWER_SCHEMENAME
#define DEFAULT_RANDOM_HUE_MAX
#define DEFAULT_CPTCITY_SCHEMENAME
#define DEFAULT_RANDOM_HUE_MIN
#define DEFAULT_RANDOM_COUNT
#define DEFAULT_RANDOM_SAT_MAX
#define DEFAULT_RANDOM_SAT_MIN
#define DEFAULT_CPTCITY_VARIANTNAME
#define DEFAULT_GRADIENT_COLOR1
#define DEFAULT_RANDOM_VAL_MIN
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
#define DEFAULT_GRADIENT_COLOR2
#define DEFAULT_RANDOM_VAL_MAX
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)