16 #ifndef QGSVECTORCOLORRAMPV2_H 17 #define QGSVECTORCOLORRAMPV2_H 38 virtual int count()
const = 0;
42 virtual double value(
int index )
const = 0;
48 virtual QColor color(
double value )
const = 0;
52 virtual QString type()
const = 0;
94 #define DEFAULT_GRADIENT_COLOR1 QColor(0,0,255) 95 #define DEFAULT_GRADIENT_COLOR2 QColor(0,255,0) 116 bool discrete =
false,
122 virtual int count()
const override {
return mStops.count() + 2; }
123 virtual double value(
int index )
const override;
124 virtual QColor color(
double value )
const override;
175 void convertToDiscrete(
bool discrete );
207 void addStopsToGradient(
QGradient* gradient,
double alpha = 1 );
217 #define DEFAULT_RANDOM_COUNT 10 218 #define DEFAULT_RANDOM_HUE_MIN 0 219 #define DEFAULT_RANDOM_HUE_MAX 359 220 #define DEFAULT_RANDOM_VAL_MIN 200 221 #define DEFAULT_RANDOM_VAL_MAX 240 222 #define DEFAULT_RANDOM_SAT_MIN 100 223 #define DEFAULT_RANDOM_SAT_MAX 240 240 virtual double value(
int index )
const override;
242 virtual QColor color(
double value )
const override;
260 int count()
const override {
return mCount; }
278 int mHueMin, mHueMax, mSatMin, mSatMax,
mValMin, mValMax;
291 int count()
const override;
303 virtual void setTotalColorCount(
const int colorCount );
319 #define DEFAULT_COLORBREWER_SCHEMENAME "Spectral" 320 #define DEFAULT_COLORBREWER_COLORS 5 333 virtual double value(
int index )
const override;
335 virtual QColor color(
double value )
const override;
344 virtual int count()
const override {
return mColors; }
348 void setColors(
int colors ) { mColors = colors; loadPalette(); }
363 #define DEFAULT_CPTCITY_SCHEMENAME "cb/div/BrBG_" //change this 364 #define DEFAULT_CPTCITY_VARIANTNAME "05" 374 bool doLoadFile =
true );
397 { mSchemeName = schemeName; mVariantName = variantName; mVariantList = variantList; mFileLoaded =
false; }
406 QString copyingFileName()
const;
QString schemeName() const
int count() const override
Returns number of defined colors, or -1 if undefined.
virtual QString type() const =0
Returns a string representing the color ramp type.
void setName(const QString &schemeName, const QString &variantName="", const QStringList &variantList=QStringList())
#define DEFAULT_CPTCITY_VARIANTNAME
Represents a color stop within a gradient color ramp.
#define DEFAULT_COLORBREWER_SCHEMENAME
#define DEFAULT_RANDOM_HUE_MIN
QColor color2() const
Returns the gradient end color.
void setInfo(const QgsStringMap &info)
Sets additional info to attach to the gradient ramp (eg authorship notes)
QColor color1() const
Returns the gradient start color.
virtual QgsVectorGradientColorRampV2 * clone() const override
Creates a clone of the color ramp.
virtual QgsStringMap properties() const =0
Returns a string map containing all the color ramp's properties.
bool isDiscrete() const
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating betw...
#define DEFAULT_CPTCITY_SCHEMENAME
QgsGradientStopsList stops() const
Returns the list of intermediate gradient stops for the ramp.
void setColor2(const QColor &color)
Sets the gradient end color.
virtual QString type() const override
Returns a string representing the color ramp type.
QMap< QString, QString > QgsStringMap
#define DEFAULT_RANDOM_SAT_MAX
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
void setColor1(const QColor &color)
Sets the gradient start color.
virtual QgsStringMap properties() const override
Returns a string map containing all the color ramp's properties.
virtual int count() const override
Returns number of defined colors, or -1 if undefined.
void setColors(int colors)
QgsStringMap info() const
Returns any additional info attached to the gradient ramp (eg authorship notes)
void setVariantName(const QString &variantName)
#define DEFAULT_GRADIENT_COLOR2
void setSchemeName(const QString &schemeName)
virtual double value(int index) const =0
Returns relative value between [0,1] of color at specified index.
virtual QgsVectorColorRampV2 * clone() const =0
Creates a clone of the color ramp.
double offset
Relative positional offset, between 0 and 1.
virtual QString type() const override
Returns a string representing the color ramp type.
#define DEFAULT_GRADIENT_COLOR1
#define DEFAULT_RANDOM_VAL_MAX
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
bool hasMultiStops() const
QgsGradientStop(double o, const QColor &c)
Constructor for QgsGradientStop.
virtual QString type() const override
Returns a string representing the color ramp type.
#define DEFAULT_RANDOM_SAT_MIN
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsVectorColorRampV2 from a map of properties.
Random color ramp, which returns random colors based on preset parameters.
QString schemeName() const
virtual int count() const =0
Returns number of defined colors, or -1 if undefined.
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
void setSchemeName(const QString &schemeName)
virtual QString type() const override
Returns a string representing the color ramp type.
#define DEFAULT_COLORBREWER_COLORS
virtual ~QgsVectorColorRampV2()
bool operator==(const QgsGradientStop &other) const
QList< QColor > mPrecalculatedColors
#define DEFAULT_RANDOM_HUE_MAX
QString variantName() const
#define DEFAULT_RANDOM_VAL_MIN
Abstract base class for color ramps.
void setVariantList(const QStringList &variantList)
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
QgsGradientStopsList mStops
virtual int count() const override
Returns number of defined colors, or -1 if undefined.
void setDiscrete(bool discrete)
Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating betwe...
#define DEFAULT_RANDOM_COUNT
QStringList variantList() const
QColor color
Gradient color at stop.