QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
QgsLimitedRandomColorRamp Class Reference

Constrained random color ramp, which returns random colors based on preset parameters. More...

#include <qgscolorrampimpl.h>

Inheritance diagram for QgsLimitedRandomColorRamp:
Inheritance graph
[legend]

Public Member Functions

 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. More...
 
QgsLimitedRandomColorRampclone () const override
 Creates a clone of the color ramp. More...
 
QColor color (double value) const override
 Returns the color corresponding to a specified value. More...
 
int count () const override
 Returns number of defined colors, or -1 if undefined. More...
 
int hueMax () const
 Returns the maximum hue for generated colors. More...
 
int hueMin () const
 Returns the minimum hue for generated colors. More...
 
QVariantMap properties () const override
 Returns a string map containing all the color ramp's properties. More...
 
int satMax () const
 Returns the maximum saturation for generated colors. More...
 
int satMin () const
 Returns the minimum saturation for generated colors. More...
 
void setCount (int val)
 Sets the number of colors contained in the ramp. More...
 
void setHueMax (int val)
 Sets the maximum hue for generated colors. More...
 
void setHueMin (int val)
 Sets the minimum hue for generated colors. More...
 
void setSatMax (int val)
 Sets the maximum saturation for generated colors. More...
 
void setSatMin (int val)
 Sets the minimum saturation for generated colors. More...
 
void setValMax (int val)
 Sets the maximum value for generated colors. More...
 
void setValMin (int val)
 Sets the minimum value for generated colors. More...
 
QString type () const override
 Returns a string representing the color ramp type. More...
 
void updateColors ()
 Must be called after changing the properties of the color ramp to regenerate the list of random colors. More...
 
int valMax () const
 Returns the maximum value for generated colors. More...
 
int valMin () const
 Returns the minimum value for generated colors. More...
 
double value (int index) const override
 Returns relative value between [0,1] of color at specified index. More...
 
- Public Member Functions inherited from QgsColorRamp
virtual ~QgsColorRamp ()
 
virtual QgsColorRampclone () const =0
 Creates a clone of the color ramp. More...
 
virtual QColor color (double value) const =0
 Returns the color corresponding to a specified value. More...
 
virtual int count () const =0
 Returns number of defined colors, or -1 if undefined. More...
 
virtual void invert ()
 Inverts the ordering of the color ramp. More...
 
virtual QVariantMap properties () const =0
 Returns a string map containing all the color ramp's properties. More...
 
virtual QString type () const =0
 Returns a string representing the color ramp type. More...
 
virtual double value (int index) const =0
 Returns relative value between [0,1] of color at specified index. More...
 

Static Public Member Functions

static QgsColorRampcreate (const QVariantMap &properties=QVariantMap())
 Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string map. More...
 
static QList< QColor > randomColors (int count, int hueMax=DEFAULT_RANDOM_HUE_MAX, int hueMin=DEFAULT_RANDOM_HUE_MIN, int satMax=DEFAULT_RANDOM_SAT_MAX, int satMin=DEFAULT_RANDOM_SAT_MIN, int valMax=DEFAULT_RANDOM_VAL_MAX, int valMin=DEFAULT_RANDOM_VAL_MIN)
 Gets a list of random colors. More...
 
static QString typeString ()
 Returns the string identifier for QgsLimitedRandomColorRamp. More...
 
- Static Public Member Functions inherited from QgsColorRamp
static QList< QPair< QString, QString > > rampTypes ()
 Returns a list of available ramp types, where the first value in each item is the QgsColorRamp::type() string and the second is a user friendly, translated name for the color ramp type. More...
 

Protected Attributes

QList< QColor > mColors
 
int mCount
 
int mHueMax
 
int mHueMin
 
int mSatMax
 
int mSatMin
 
int mValMax
 
int mValMin
 

Detailed Description

Constrained random color ramp, which returns random colors based on preset parameters.

Since
QGIS 3.0

Definition at line 340 of file qgscolorrampimpl.h.

Constructor & Destructor Documentation

◆ QgsLimitedRandomColorRamp()

QgsLimitedRandomColorRamp::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.

Parameters
countnumber of colors in ramp
hueMinminimum hue
hueMaxmaximum hue
satMinminimum saturation
satMaxmaximum saturation
valMinminimum color value
valMaxmaximum color value

Definition at line 615 of file qgscolorrampimpl.cpp.

Member Function Documentation

◆ clone()

QgsLimitedRandomColorRamp * QgsLimitedRandomColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

Definition at line 669 of file qgscolorrampimpl.cpp.

◆ color()

QColor QgsLimitedRandomColorRamp::color ( double  value) const
overridevirtual

Returns the color corresponding to a specified value.

Parameters
valuevalue between [0, 1] inclusive
Returns
color for value

Implements QgsColorRamp.

Definition at line 650 of file qgscolorrampimpl.cpp.

◆ count()

int QgsLimitedRandomColorRamp::count ( ) const
inlineoverridevirtual

Returns number of defined colors, or -1 if undefined.

Implements QgsColorRamp.

Definition at line 380 of file qgscolorrampimpl.h.

◆ create()

QgsColorRamp * QgsLimitedRandomColorRamp::create ( const QVariantMap &  properties = QVariantMap())
static

Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string map.

Parameters
propertiescolor ramp properties
See also
properties()

Definition at line 625 of file qgscolorrampimpl.cpp.

◆ hueMax()

int QgsLimitedRandomColorRamp::hueMax ( ) const
inline

Returns the maximum hue for generated colors.

See also
setHueMax()

Definition at line 407 of file qgscolorrampimpl.h.

◆ hueMin()

int QgsLimitedRandomColorRamp::hueMin ( ) const
inline

Returns the minimum hue for generated colors.

See also
setHueMin()

Definition at line 401 of file qgscolorrampimpl.h.

◆ properties()

QVariantMap QgsLimitedRandomColorRamp::properties ( ) const
overridevirtual

Returns a string map containing all the color ramp's properties.

Implements QgsColorRamp.

Definition at line 674 of file qgscolorrampimpl.cpp.

◆ randomColors()

QList< QColor > QgsLimitedRandomColorRamp::randomColors ( int  count,
int  hueMax = DEFAULT_RANDOM_HUE_MAX,
int  hueMin = DEFAULT_RANDOM_HUE_MIN,
int  satMax = DEFAULT_RANDOM_SAT_MAX,
int  satMin = DEFAULT_RANDOM_SAT_MIN,
int  valMax = DEFAULT_RANDOM_VAL_MAX,
int  valMin = DEFAULT_RANDOM_VAL_MIN 
)
static

Gets a list of random colors.

Since
QGIS 2.4

Definition at line 688 of file qgscolorrampimpl.cpp.

◆ satMax()

int QgsLimitedRandomColorRamp::satMax ( ) const
inline

Returns the maximum saturation for generated colors.

See also
setSatMax()

Definition at line 419 of file qgscolorrampimpl.h.

◆ satMin()

int QgsLimitedRandomColorRamp::satMin ( ) const
inline

Returns the minimum saturation for generated colors.

See also
setSatMin()

Definition at line 413 of file qgscolorrampimpl.h.

◆ setCount()

void QgsLimitedRandomColorRamp::setCount ( int  val)
inline

Sets the number of colors contained in the ramp.

Definition at line 436 of file qgscolorrampimpl.h.

◆ setHueMax()

void QgsLimitedRandomColorRamp::setHueMax ( int  val)
inline

Sets the maximum hue for generated colors.

See also
hueMax()

Definition at line 448 of file qgscolorrampimpl.h.

◆ setHueMin()

void QgsLimitedRandomColorRamp::setHueMin ( int  val)
inline

Sets the minimum hue for generated colors.

See also
hueMin()

Definition at line 442 of file qgscolorrampimpl.h.

◆ setSatMax()

void QgsLimitedRandomColorRamp::setSatMax ( int  val)
inline

Sets the maximum saturation for generated colors.

See also
satMax()

Definition at line 460 of file qgscolorrampimpl.h.

◆ setSatMin()

void QgsLimitedRandomColorRamp::setSatMin ( int  val)
inline

Sets the minimum saturation for generated colors.

See also
satMin()

Definition at line 454 of file qgscolorrampimpl.h.

◆ setValMax()

void QgsLimitedRandomColorRamp::setValMax ( int  val)
inline

Sets the maximum value for generated colors.

See also
valMax()

Definition at line 472 of file qgscolorrampimpl.h.

◆ setValMin()

void QgsLimitedRandomColorRamp::setValMin ( int  val)
inline

Sets the minimum value for generated colors.

See also
valMin()

Definition at line 466 of file qgscolorrampimpl.h.

◆ type()

QString QgsLimitedRandomColorRamp::type ( ) const
overridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 664 of file qgscolorrampimpl.cpp.

◆ typeString()

static QString QgsLimitedRandomColorRamp::typeString ( )
inlinestatic

Returns the string identifier for QgsLimitedRandomColorRamp.

Since
QGIS 3.16

Definition at line 375 of file qgscolorrampimpl.h.

◆ updateColors()

void QgsLimitedRandomColorRamp::updateColors ( )

Must be called after changing the properties of the color ramp to regenerate the list of random colors.

Definition at line 721 of file qgscolorrampimpl.cpp.

◆ valMax()

int QgsLimitedRandomColorRamp::valMax ( ) const
inline

Returns the maximum value for generated colors.

See also
setValMax()

Definition at line 431 of file qgscolorrampimpl.h.

◆ valMin()

int QgsLimitedRandomColorRamp::valMin ( ) const
inline

Returns the minimum value for generated colors.

See also
setValMin()

Definition at line 425 of file qgscolorrampimpl.h.

◆ value()

double QgsLimitedRandomColorRamp::value ( int  index) const
overridevirtual

Returns relative value between [0,1] of color at specified index.

Implements QgsColorRamp.

Definition at line 643 of file qgscolorrampimpl.cpp.

Member Data Documentation

◆ mColors

QList<QColor> QgsLimitedRandomColorRamp::mColors
protected

Definition at line 482 of file qgscolorrampimpl.h.

◆ mCount

int QgsLimitedRandomColorRamp::mCount
protected

Definition at line 475 of file qgscolorrampimpl.h.

◆ mHueMax

int QgsLimitedRandomColorRamp::mHueMax
protected

Definition at line 477 of file qgscolorrampimpl.h.

◆ mHueMin

int QgsLimitedRandomColorRamp::mHueMin
protected

Definition at line 476 of file qgscolorrampimpl.h.

◆ mSatMax

int QgsLimitedRandomColorRamp::mSatMax
protected

Definition at line 479 of file qgscolorrampimpl.h.

◆ mSatMin

int QgsLimitedRandomColorRamp::mSatMin
protected

Definition at line 478 of file qgscolorrampimpl.h.

◆ mValMax

int QgsLimitedRandomColorRamp::mValMax
protected

Definition at line 481 of file qgscolorrampimpl.h.

◆ mValMin

int QgsLimitedRandomColorRamp::mValMin
protected

Definition at line 480 of file qgscolorrampimpl.h.


The documentation for this class was generated from the following files: