QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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...
 
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...
 
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...
 
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 ()=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)
 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 302 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 313 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 367 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 348 of file qgscolorramp.cpp.

◆ count()

int QgsLimitedRandomColorRamp::count ( ) const
inlineoverridevirtual

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

Implements QgsColorRamp.

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

◆ hueMax()

int QgsLimitedRandomColorRamp::hueMax ( ) const
inline

Returns the maximum hue for generated colors.

See also
setHueMax()

Definition at line 369 of file qgscolorramp.h.

◆ hueMin()

int QgsLimitedRandomColorRamp::hueMin ( ) const
inline

Returns the minimum hue for generated colors.

See also
setHueMin()

Definition at line 363 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 372 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

Gets a list of random colors.

Since
QGIS 2.4

Definition at line 386 of file qgscolorramp.cpp.

◆ satMax()

int QgsLimitedRandomColorRamp::satMax ( ) const
inline

Returns the maximum saturation for generated colors.

See also
setSatMax()

Definition at line 381 of file qgscolorramp.h.

◆ satMin()

int QgsLimitedRandomColorRamp::satMin ( ) const
inline

Returns the minimum saturation for generated colors.

See also
setSatMin()

Definition at line 375 of file qgscolorramp.h.

◆ setCount()

void QgsLimitedRandomColorRamp::setCount ( int  val)
inline

Sets the number of colors contained in the ramp.

Definition at line 398 of file qgscolorramp.h.

◆ setHueMax()

void QgsLimitedRandomColorRamp::setHueMax ( int  val)
inline

Sets the maximum hue for generated colors.

See also
hueMax()

Definition at line 410 of file qgscolorramp.h.

◆ setHueMin()

void QgsLimitedRandomColorRamp::setHueMin ( int  val)
inline

Sets the minimum hue for generated colors.

See also
hueMin()

Definition at line 404 of file qgscolorramp.h.

◆ setSatMax()

void QgsLimitedRandomColorRamp::setSatMax ( int  val)
inline

Sets the maximum saturation for generated colors.

See also
satMax()

Definition at line 422 of file qgscolorramp.h.

◆ setSatMin()

void QgsLimitedRandomColorRamp::setSatMin ( int  val)
inline

Sets the minimum saturation for generated colors.

See also
satMin()

Definition at line 416 of file qgscolorramp.h.

◆ setValMax()

void QgsLimitedRandomColorRamp::setValMax ( int  val)
inline

Sets the maximum value for generated colors.

See also
valMax()

Definition at line 434 of file qgscolorramp.h.

◆ setValMin()

void QgsLimitedRandomColorRamp::setValMin ( int  val)
inline

Sets the minimum value for generated colors.

See also
valMin()

Definition at line 428 of file qgscolorramp.h.

◆ type()

QString QgsLimitedRandomColorRamp::type ( ) const
overridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 362 of file qgscolorramp.cpp.

◆ typeString()

static QString QgsLimitedRandomColorRamp::typeString ( )
inlinestatic

Returns the string identifier for QgsLimitedRandomColorRamp.

Since
QGIS 3.16

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

◆ valMax()

int QgsLimitedRandomColorRamp::valMax ( ) const
inline

Returns the maximum value for generated colors.

See also
setValMax()

Definition at line 393 of file qgscolorramp.h.

◆ valMin()

int QgsLimitedRandomColorRamp::valMin ( ) const
inline

Returns the minimum value for generated colors.

See also
setValMin()

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

Member Data Documentation

◆ mColors

QList<QColor> QgsLimitedRandomColorRamp::mColors
protected

Definition at line 444 of file qgscolorramp.h.

◆ mCount

int QgsLimitedRandomColorRamp::mCount
protected

Definition at line 437 of file qgscolorramp.h.

◆ mHueMax

int QgsLimitedRandomColorRamp::mHueMax
protected

Definition at line 439 of file qgscolorramp.h.

◆ mHueMin

int QgsLimitedRandomColorRamp::mHueMin
protected

Definition at line 438 of file qgscolorramp.h.

◆ mSatMax

int QgsLimitedRandomColorRamp::mSatMax
protected

Definition at line 441 of file qgscolorramp.h.

◆ mSatMin

int QgsLimitedRandomColorRamp::mSatMin
protected

Definition at line 440 of file qgscolorramp.h.

◆ mValMax

int QgsLimitedRandomColorRamp::mValMax
protected

Definition at line 443 of file qgscolorramp.h.

◆ mValMin

int QgsLimitedRandomColorRamp::mValMin
protected

Definition at line 442 of file qgscolorramp.h.


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