QGIS API Documentation  2.99.0-Master (cd0ba91)
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 <qgscolorramp.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...
 
virtual QgsLimitedRandomColorRampclone () const override
 Creates a clone of the color ramp. More...
 
virtual 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...
 
virtual QgsStringMap 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...
 
virtual 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...
 
virtual 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 ()=default
 
virtual void invert ()
 Inverts the ordering of the color ramp. More...
 

Static Public Member Functions

static QgsColorRampcreate (const QgsStringMap &properties=QgsStringMap())
 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)
 Get a list of random colors. 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 283 of file qgscolorramp.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 307 of file qgscolorramp.cpp.

Member Function Documentation

◆ clone()

QgsLimitedRandomColorRamp * QgsLimitedRandomColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

Definition at line 356 of file qgscolorramp.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 342 of file qgscolorramp.cpp.

◆ count()

int QgsLimitedRandomColorRamp::count ( ) const
inlineoverridevirtual

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

Implements QgsColorRamp.

Definition at line 315 of file qgscolorramp.h.

◆ create()

QgsColorRamp * QgsLimitedRandomColorRamp::create ( const QgsStringMap properties = QgsStringMap())
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 317 of file qgscolorramp.cpp.

◆ hueMax()

int QgsLimitedRandomColorRamp::hueMax ( ) const
inline

Returns the maximum hue for generated colors.

See also
setHueMax()

Definition at line 342 of file qgscolorramp.h.

◆ hueMin()

int QgsLimitedRandomColorRamp::hueMin ( ) const
inline

Returns the minimum hue for generated colors.

See also
setHueMin()

Definition at line 336 of file qgscolorramp.h.

◆ properties()

QgsStringMap QgsLimitedRandomColorRamp::properties ( ) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 361 of file qgscolorramp.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

Get a list of random colors.

Since
QGIS 2.4

Definition at line 375 of file qgscolorramp.cpp.

◆ satMax()

int QgsLimitedRandomColorRamp::satMax ( ) const
inline

Returns the maximum saturation for generated colors.

See also
setSatMax()

Definition at line 354 of file qgscolorramp.h.

◆ satMin()

int QgsLimitedRandomColorRamp::satMin ( ) const
inline

Returns the minimum saturation for generated colors.

See also
setSatMin()

Definition at line 348 of file qgscolorramp.h.

◆ setCount()

void QgsLimitedRandomColorRamp::setCount ( int  val)
inline

Sets the number of colors contained in the ramp.

Definition at line 371 of file qgscolorramp.h.

◆ setHueMax()

void QgsLimitedRandomColorRamp::setHueMax ( int  val)
inline

Sets the maximum hue for generated colors.

See also
hueMax()

Definition at line 383 of file qgscolorramp.h.

◆ setHueMin()

void QgsLimitedRandomColorRamp::setHueMin ( int  val)
inline

Sets the minimum hue for generated colors.

See also
hueMin()

Definition at line 377 of file qgscolorramp.h.

◆ setSatMax()

void QgsLimitedRandomColorRamp::setSatMax ( int  val)
inline

Sets the maximum saturation for generated colors.

See also
satMax()

Definition at line 395 of file qgscolorramp.h.

◆ setSatMin()

void QgsLimitedRandomColorRamp::setSatMin ( int  val)
inline

Sets the minimum saturation for generated colors.

See also
satMin()

Definition at line 389 of file qgscolorramp.h.

◆ setValMax()

void QgsLimitedRandomColorRamp::setValMax ( int  val)
inline

Sets the maximum value for generated colors.

See also
valMax()

Definition at line 407 of file qgscolorramp.h.

◆ setValMin()

void QgsLimitedRandomColorRamp::setValMin ( int  val)
inline

Sets the minimum value for generated colors.

See also
valMin()

Definition at line 401 of file qgscolorramp.h.

◆ type()

virtual QString QgsLimitedRandomColorRamp::type ( ) const
inlineoverridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 312 of file qgscolorramp.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 408 of file qgscolorramp.cpp.

◆ valMax()

int QgsLimitedRandomColorRamp::valMax ( ) const
inline

Returns the maximum value for generated colors.

See also
setValMax()

Definition at line 366 of file qgscolorramp.h.

◆ valMin()

int QgsLimitedRandomColorRamp::valMin ( ) const
inline

Returns the minimum value for generated colors.

See also
setValMin()

Definition at line 360 of file qgscolorramp.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 335 of file qgscolorramp.cpp.

Member Data Documentation

◆ mColors

QList<QColor> QgsLimitedRandomColorRamp::mColors
protected

Definition at line 417 of file qgscolorramp.h.

◆ mCount

int QgsLimitedRandomColorRamp::mCount
protected

Definition at line 410 of file qgscolorramp.h.

◆ mHueMax

int QgsLimitedRandomColorRamp::mHueMax
protected

Definition at line 412 of file qgscolorramp.h.

◆ mHueMin

int QgsLimitedRandomColorRamp::mHueMin
protected

Definition at line 411 of file qgscolorramp.h.

◆ mSatMax

int QgsLimitedRandomColorRamp::mSatMax
protected

Definition at line 414 of file qgscolorramp.h.

◆ mSatMin

int QgsLimitedRandomColorRamp::mSatMin
protected

Definition at line 413 of file qgscolorramp.h.

◆ mValMax

int QgsLimitedRandomColorRamp::mValMax
protected

Definition at line 416 of file qgscolorramp.h.

◆ mValMin

int QgsLimitedRandomColorRamp::mValMin
protected

Definition at line 415 of file qgscolorramp.h.


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