16#ifndef QGSCOLORRAMPIMPL_H 
   17#define QGSCOLORRAMPIMPL_H 
   28typedef QColor( *InterpolateColorFunc )( 
const QColor &c1, 
const QColor &c2, 
const double value, 
Qgis::AngularDirection direction );
 
   55      return other.
color == color && 
qgsDoubleNear( other.
offset, offset ) && other.mColorSpec == mColorSpec && other.mDirection == mDirection;
 
 
   60      return !( *
this == other );
 
 
   72    QColor::Spec 
colorSpec()
 const { 
return mColorSpec; }
 
   85    void setColorSpec( QColor::Spec spec );
 
  113    QColor::Spec mColorSpec = QColor::Spec::Rgb;
 
  115    InterpolateColorFunc mFunc = 
nullptr;
 
 
  125#define DEFAULT_GRADIENT_COLOR1 QColor(69, 116, 40) 
  126#define DEFAULT_GRADIENT_COLOR2 QColor(188, 220, 60) 
  148                          bool discrete = 
false,
 
  154    int count()
 const override { 
return mStops.count() + 2; }
 
  155    double value( 
int index ) 
const override;
 
  156    QColor color( 
double value ) 
const override;
 
  163    static QString 
typeString() { 
return QStringLiteral( 
"gradient" ); }
 
  165    QString type() 
const override;
 
  166    void invert() 
override;
 
  168    QVariantMap properties() const override;
 
  175    QColor color1()
 const { 
return mColor1; }
 
  182    QColor 
color2()
 const { 
return mColor2; }
 
  190    void setColor1( 
const QColor &color ) { mColor1 = color; }
 
  198    void setColor2( 
const QColor &color ) { mColor2 = color; }
 
  223    void convertToDiscrete( 
bool discrete );
 
  259    void addStopsToGradient( QGradient *gradient, 
double opacity = 1 ) 
const;
 
  283    void setColorSpec( QColor::Spec spec );
 
  315    QColor::Spec mColorSpec = QColor::Spec::Rgb;
 
  318    InterpolateColorFunc mFunc = 
nullptr;
 
 
  323#define DEFAULT_RANDOM_COUNT   10 
  324#define DEFAULT_RANDOM_HUE_MIN 0 
  325#define DEFAULT_RANDOM_HUE_MAX 359 
  326#define DEFAULT_RANDOM_VAL_MIN 200 
  327#define DEFAULT_RANDOM_VAL_MAX 240 
  328#define DEFAULT_RANDOM_SAT_MIN 100 
  329#define DEFAULT_RANDOM_SAT_MAX 240 
  363    double value( 
int index ) 
const override;
 
  364    QColor color( 
double value ) 
const override;
 
  371    static QString 
typeString() { 
return QStringLiteral( 
"random" ); }
 
  373    QString type() 
const override;
 
  375    QVariantMap properties() const override;
 
  376    int count()
 const override { 
return mCount; }
 
  381    static QList<QColor> randomColors( 
int count,
 
 
  495    int count() 
const override;
 
  497    double value( 
int index ) 
const override;
 
  499    QColor color( 
double value ) 
const override;
 
  507    virtual void setTotalColorCount( 
int colorCount );
 
  514    static QString 
typeString() { 
return QStringLiteral( 
"randomcolors" ); }
 
  516    QString type() 
const override;
 
  520    QVariantMap properties() const override;
 
  524    int mTotalColorCount = 0;
 
  525    QList<QColor> mPrecalculatedColors;
 
 
  564    bool setColors( 
const QgsNamedColorList &colors, 
const QString & = QString(), 
const QColor & = QColor() )
 override { mColors = colors; 
return true; }
 
  570    QList< QColor > colors() 
const;
 
  572    double value( 
int index ) 
const override;
 
  573    QColor color( 
double value ) 
const override;
 
  580    static QString 
typeString() { 
return QStringLiteral( 
"preset" ); }
 
  582    QString type() 
const override;
 
  583    void invert() 
override;
 
  585    QVariantMap properties() const override;
 
  586    int count() const override;
 
  588    QString schemeName()
 const override { 
return QStringLiteral( 
"preset" ); }
 
  589    QgsNamedColorList fetchColors( 
const QString &context = QString(), 
const QColor &baseColor = QColor() ) 
override;
 
 
  598#define DEFAULT_COLORBREWER_SCHEMENAME "Spectral" 
  599#define DEFAULT_COLORBREWER_COLORS     5 
  618                             bool inverted = 
false );
 
  628    double value( 
int index ) 
const override;
 
  629    QColor color( 
double value ) 
const override;
 
  636    static QString 
typeString() { 
return QStringLiteral( 
"colorbrewer" ); }
 
  639    void invert() 
override;
 
  641    QVariantMap properties() const override;
 
  642    int count()
 const override { 
return mColors; }
 
  662    void setSchemeName( 
const QString &schemeName ) { mSchemeName = schemeName; loadPalette(); }
 
  670    void setColors( 
int colors ) { mColors = colors; loadPalette(); }
 
  676    static QStringList listSchemeNames();
 
  684    static QList<int> listSchemeVariants( 
const QString &schemeName );
 
 
  698#define DEFAULT_CPTCITY_SCHEMENAME "cb/div/BrBG_"  
  699#define DEFAULT_CPTCITY_VARIANTNAME "05" 
  718                         bool inverted = 
false,
 
  719                         bool doLoadFile = 
true );
 
  730                         const QString &variantName = QString(), 
bool inverted = 
false,
 
  731                         bool doLoadFile = 
true );
 
  741    static QString 
typeString() { 
return QStringLiteral( 
"cpt-city" ); }
 
  743    QString type() 
const override;
 
  745    void invert() 
override;
 
  751    QVariantMap properties() const override;
 
  753    QString schemeName()
 const { 
return mSchemeName; }
 
  758    void setSchemeName( 
const QString &schemeName ) { mSchemeName = schemeName; mFileLoaded = 
false; }
 
  759    void setVariantName( 
const QString &variantName ) { mVariantName = variantName; mFileLoaded = 
false; }
 
  760    void setVariantList( 
const QStringList &variantList ) { mVariantList = variantList; }
 
  761    void setName( 
const QString &schemeName, 
const QString &variantName = QString(), 
const QStringList &variantList = QStringList() )
 
  762    { mSchemeName = schemeName; mVariantName = variantName; mVariantList = variantList; mFileLoaded = 
false; }
 
 
  773    static QString fileNameForVariant( 
const QString &schema, 
const QString &variant ) 
SIP_SKIP;
 
  775    QString fileName() 
const;
 
  779    QString copyingFileName() 
const;
 
  780    QString descFileName() 
const;
 
  787    bool mFileLoaded = 
false;
 
  788    bool mMultiStops = 
false;
 
 
AngularDirection
Angular directions.
@ CounterClockwise
Counter-clockwise direction.
Color ramp utilising "Color Brewer" preset color schemes.
static QString typeString()
Returns the string identifier for QgsColorBrewerColorRamp.
QString type() const override
Returns a string representing the color ramp type.
QString schemeName() const
Returns the name of the color brewer color scheme.
int colors() const
Returns the number of colors in the ramp.
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.
Abstract base class for color ramps.
Abstract base class for color schemes.
void setName(const QString &schemeName, const QString &variantName=QString(), const QStringList &variantList=QStringList())
void setSchemeName(const QString &schemeName)
void setVariantList(const QStringList &variantList)
QStringList variantList() const
void setVariantName(const QString &variantName)
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
bool hasMultiStops() 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.
QgsStringMap info() const
Returns any additional info attached to the gradient ramp (e.g., authorship notes)
QColor::Spec colorSpec() const
Returns the color specification in which the color component interpolation will occur.
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
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...
QColor color2() const
Returns the gradient end color.
Represents a color stop within a QgsGradientColorRamp color ramp.
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...
QColor color
Gradient color at stop.
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.
void setHueMin(int val)
Sets the minimum hue for generated colors.
void setSatMax(int val)
Sets the maximum saturation for generated colors.
int valMax() const
Returns the maximum value for generated colors.
int satMax() const
Returns the maximum saturation for generated colors.
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.
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.
static QString typeString()
Returns the string identifier for QgsPresetSchemeColorRamp.
bool isEditable() const override
Returns whether the color scheme is editable.
Totally random color ramp.
QgsRandomColorRamp()=default
Constructor for QgsRandomColorRamp.
static QString typeString()
Returns the string identifier for QgsRandomColorRamp.
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)