QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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.

Definition at line 336 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 622 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 676 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 657 of file qgscolorrampimpl.cpp.

◆ count()

int QgsLimitedRandomColorRamp::count ( ) const
inlineoverridevirtual

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

Implements QgsColorRamp.

Definition at line 376 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 632 of file qgscolorrampimpl.cpp.

◆ hueMax()

int QgsLimitedRandomColorRamp::hueMax ( ) const
inline

Returns the maximum hue for generated colors.

See also
setHueMax()

Definition at line 402 of file qgscolorrampimpl.h.

◆ hueMin()

int QgsLimitedRandomColorRamp::hueMin ( ) const
inline

Returns the minimum hue for generated colors.

See also
setHueMin()

Definition at line 396 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 681 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.

Definition at line 695 of file qgscolorrampimpl.cpp.

◆ satMax()

int QgsLimitedRandomColorRamp::satMax ( ) const
inline

Returns the maximum saturation for generated colors.

See also
setSatMax()

Definition at line 414 of file qgscolorrampimpl.h.

◆ satMin()

int QgsLimitedRandomColorRamp::satMin ( ) const
inline

Returns the minimum saturation for generated colors.

See also
setSatMin()

Definition at line 408 of file qgscolorrampimpl.h.

◆ setCount()

void QgsLimitedRandomColorRamp::setCount ( int  val)
inline

Sets the number of colors contained in the ramp.

Definition at line 431 of file qgscolorrampimpl.h.

◆ setHueMax()

void QgsLimitedRandomColorRamp::setHueMax ( int  val)
inline

Sets the maximum hue for generated colors.

See also
hueMax()

Definition at line 443 of file qgscolorrampimpl.h.

◆ setHueMin()

void QgsLimitedRandomColorRamp::setHueMin ( int  val)
inline

Sets the minimum hue for generated colors.

See also
hueMin()

Definition at line 437 of file qgscolorrampimpl.h.

◆ setSatMax()

void QgsLimitedRandomColorRamp::setSatMax ( int  val)
inline

Sets the maximum saturation for generated colors.

See also
satMax()

Definition at line 455 of file qgscolorrampimpl.h.

◆ setSatMin()

void QgsLimitedRandomColorRamp::setSatMin ( int  val)
inline

Sets the minimum saturation for generated colors.

See also
satMin()

Definition at line 449 of file qgscolorrampimpl.h.

◆ setValMax()

void QgsLimitedRandomColorRamp::setValMax ( int  val)
inline

Sets the maximum value for generated colors.

See also
valMax()

Definition at line 467 of file qgscolorrampimpl.h.

◆ setValMin()

void QgsLimitedRandomColorRamp::setValMin ( int  val)
inline

Sets the minimum value for generated colors.

See also
valMin()

Definition at line 461 of file qgscolorrampimpl.h.

◆ type()

QString QgsLimitedRandomColorRamp::type ( ) const
overridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 671 of file qgscolorrampimpl.cpp.

◆ typeString()

static QString QgsLimitedRandomColorRamp::typeString ( )
inlinestatic

Returns the string identifier for QgsLimitedRandomColorRamp.

Since
QGIS 3.16

Definition at line 371 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 728 of file qgscolorrampimpl.cpp.

◆ valMax()

int QgsLimitedRandomColorRamp::valMax ( ) const
inline

Returns the maximum value for generated colors.

See also
setValMax()

Definition at line 426 of file qgscolorrampimpl.h.

◆ valMin()

int QgsLimitedRandomColorRamp::valMin ( ) const
inline

Returns the minimum value for generated colors.

See also
setValMin()

Definition at line 420 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 650 of file qgscolorrampimpl.cpp.

Member Data Documentation

◆ mColors

QList<QColor> QgsLimitedRandomColorRamp::mColors
protected

Definition at line 477 of file qgscolorrampimpl.h.

◆ mCount

int QgsLimitedRandomColorRamp::mCount
protected

Definition at line 470 of file qgscolorrampimpl.h.

◆ mHueMax

int QgsLimitedRandomColorRamp::mHueMax
protected

Definition at line 472 of file qgscolorrampimpl.h.

◆ mHueMin

int QgsLimitedRandomColorRamp::mHueMin
protected

Definition at line 471 of file qgscolorrampimpl.h.

◆ mSatMax

int QgsLimitedRandomColorRamp::mSatMax
protected

Definition at line 474 of file qgscolorrampimpl.h.

◆ mSatMin

int QgsLimitedRandomColorRamp::mSatMin
protected

Definition at line 473 of file qgscolorrampimpl.h.

◆ mValMax

int QgsLimitedRandomColorRamp::mValMax
protected

Definition at line 476 of file qgscolorrampimpl.h.

◆ mValMin

int QgsLimitedRandomColorRamp::mValMin
protected

Definition at line 475 of file qgscolorrampimpl.h.


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