QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsColorBrewerColorRamp Class Reference

Color ramp utilising "Color Brewer" preset color schemes. More...

#include <qgscolorramp.h>

Inheritance diagram for QgsColorBrewerColorRamp:
Inheritance graph
[legend]

Public Member Functions

 QgsColorBrewerColorRamp (const QString &schemeName=DEFAULT_COLORBREWER_SCHEMENAME, int colors=DEFAULT_COLORBREWER_COLORS, bool inverted=false)
 Constructor for QgsColorBrewerColorRamp. More...
 
QgsColorBrewerColorRampclone () 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 colors () const
 Returns the number of colors in the ramp. More...
 
int count () const override
 Returns number of defined colors, or -1 if undefined. More...
 
void invert () override
 Inverts the ordering of the color ramp. More...
 
QVariantMap properties () const override
 Returns a string map containing all the color ramp's properties. More...
 
QString schemeName () const
 Returns the name of the color brewer color scheme. More...
 
void setColors (int colors)
 Sets the number of colors in the ramp. More...
 
void setSchemeName (const QString &schemeName)
 Sets the name of the color brewer color scheme. More...
 
QString type () const override
 Returns a string representing the color ramp type. 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
 

Static Public Member Functions

static QgsColorRampcreate (const QVariantMap &properties=QVariantMap())
 Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map. More...
 
static QStringList listSchemeNames ()
 Returns a list of all valid color brewer scheme names. More...
 
static QList< int > listSchemeVariants (const QString &schemeName)
 Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name. More...
 
static QString typeString ()
 Returns the string identifier for QgsColorBrewerColorRamp. 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 Member Functions

void loadPalette ()
 Generates the scheme using the current name and number of colors. More...
 

Protected Attributes

int mColors
 
bool mInverted
 
QList< QColor > mPalette
 
QString mSchemeName
 

Detailed Description

Color ramp utilising "Color Brewer" preset color schemes.

Since
QGIS 3.0

Definition at line 577 of file qgscolorramp.h.

Constructor & Destructor Documentation

◆ QgsColorBrewerColorRamp()

QgsColorBrewerColorRamp::QgsColorBrewerColorRamp ( const QString &  schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
int  colors = DEFAULT_COLORBREWER_COLORS,
bool  inverted = false 
)

Constructor for QgsColorBrewerColorRamp.

Parameters
schemeNamecolor brewer scheme name
colorsnumber of colors in ramp
invertedinvert ramp ordering

Definition at line 509 of file qgscolorramp.cpp.

Member Function Documentation

◆ clone()

QgsColorBrewerColorRamp * QgsColorBrewerColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

Definition at line 583 of file qgscolorramp.cpp.

◆ color()

QColor QgsColorBrewerColorRamp::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 566 of file qgscolorramp.cpp.

◆ colors()

int QgsColorBrewerColorRamp::colors ( ) const
inline

Returns the number of colors in the ramp.

See also
setColors()

Definition at line 625 of file qgscolorramp.h.

◆ count()

int QgsColorBrewerColorRamp::count ( ) const
inlineoverridevirtual

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

Implements QgsColorRamp.

Definition at line 613 of file qgscolorramp.h.

◆ create()

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

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

Parameters
propertiescolor ramp properties
See also
properties()

Definition at line 517 of file qgscolorramp.cpp.

◆ invert()

void QgsColorBrewerColorRamp::invert ( )
overridevirtual

Inverts the ordering of the color ramp.

Reimplemented from QgsColorRamp.

Definition at line 577 of file qgscolorramp.cpp.

◆ listSchemeNames()

QStringList QgsColorBrewerColorRamp::listSchemeNames ( )
static

Returns a list of all valid color brewer scheme names.

See also
listSchemeVariants()

Definition at line 549 of file qgscolorramp.cpp.

◆ listSchemeVariants()

QList< int > QgsColorBrewerColorRamp::listSchemeVariants ( const QString &  schemeName)
static

Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name.

Parameters
schemeNamecolor brewer scheme name
See also
listSchemeNames()

Definition at line 554 of file qgscolorramp.cpp.

◆ loadPalette()

void QgsColorBrewerColorRamp::loadPalette ( )
protected

Generates the scheme using the current name and number of colors.

Definition at line 533 of file qgscolorramp.cpp.

◆ properties()

QVariantMap QgsColorBrewerColorRamp::properties ( ) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 588 of file qgscolorramp.cpp.

◆ schemeName()

QString QgsColorBrewerColorRamp::schemeName ( ) const
inline

Returns the name of the color brewer color scheme.

See also
setSchemeName()

Definition at line 619 of file qgscolorramp.h.

◆ setColors()

void QgsColorBrewerColorRamp::setColors ( int  colors)
inline

Sets the number of colors in the ramp.

Parameters
colorsnumber of colors. Must match a valid value for the scheme, which can be retrieved using listSchemeVariants()
See also
colors()

Definition at line 641 of file qgscolorramp.h.

◆ setSchemeName()

void QgsColorBrewerColorRamp::setSchemeName ( const QString &  schemeName)
inline

Sets the name of the color brewer color scheme.

Parameters
schemeNamescheme name, must match a valid color brewer scheme name
See also
schemeName()
listSchemeNames()

Definition at line 633 of file qgscolorramp.h.

◆ type()

QString QgsColorBrewerColorRamp::type ( ) const
inlineoverridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 609 of file qgscolorramp.h.

◆ typeString()

static QString QgsColorBrewerColorRamp::typeString ( )
inlinestatic

Returns the string identifier for QgsColorBrewerColorRamp.

Since
QGIS 3.16

Definition at line 607 of file qgscolorramp.h.

◆ value()

double QgsColorBrewerColorRamp::value ( int  index) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 559 of file qgscolorramp.cpp.

Member Data Documentation

◆ mColors

int QgsColorBrewerColorRamp::mColors
protected

Definition at line 663 of file qgscolorramp.h.

◆ mInverted

bool QgsColorBrewerColorRamp::mInverted
protected

Definition at line 665 of file qgscolorramp.h.

◆ mPalette

QList<QColor> QgsColorBrewerColorRamp::mPalette
protected

Definition at line 664 of file qgscolorramp.h.

◆ mSchemeName

QString QgsColorBrewerColorRamp::mSchemeName
protected

Definition at line 662 of file qgscolorramp.h.


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