QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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 <qgscolorrampimpl.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.
 
QgsColorBrewerColorRampclone () const override
 Creates a clone of the color ramp.
 
QColor color (double value) const override
 Returns the color corresponding to a specified value.
 
int colors () const
 Returns the number of colors in the ramp.
 
int count () const override
 Returns number of defined colors, or -1 if undefined.
 
void invert () override
 Inverts the ordering of the color ramp.
 
QVariantMap properties () const override
 Returns a string map containing all the color ramp's properties.
 
QString schemeName () const
 Returns the name of the color brewer color scheme.
 
void setColors (int colors)
 Sets the number of colors in the ramp.
 
void setSchemeName (const QString &schemeName)
 Sets the name of the color brewer color scheme.
 
QString type () const override
 Returns a string representing the color ramp type.
 
double value (int index) const override
 Returns relative value between [0,1] of color at specified index.
 
- Public Member Functions inherited from QgsColorRamp
virtual ~QgsColorRamp ()
 

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.
 
static QStringList listSchemeNames ()
 Returns a list of all valid color brewer scheme names.
 
static QList< int > listSchemeVariants (const QString &schemeName)
 Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name.
 
static QString typeString ()
 Returns the string identifier for QgsColorBrewerColorRamp.
 
- 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.
 

Protected Member Functions

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

Protected Attributes

int mColors
 
bool mInverted
 
QList< QColor > mPalette
 
QString mSchemeName
 

Detailed Description

Color ramp utilising "Color Brewer" preset color schemes.

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

Member Function Documentation

◆ clone()

QgsColorBrewerColorRamp * QgsColorBrewerColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

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

◆ colors()

int QgsColorBrewerColorRamp::colors ( ) const
inline

Returns the number of colors in the ramp.

See also
setColors()

Definition at line 651 of file qgscolorrampimpl.h.

◆ count()

int QgsColorBrewerColorRamp::count ( ) const
inlineoverridevirtual

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

Implements QgsColorRamp.

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

◆ invert()

void QgsColorBrewerColorRamp::invert ( )
overridevirtual

Inverts the ordering of the color ramp.

Reimplemented from QgsColorRamp.

Definition at line 922 of file qgscolorrampimpl.cpp.

◆ listSchemeNames()

QStringList QgsColorBrewerColorRamp::listSchemeNames ( )
static

Returns a list of all valid color brewer scheme names.

See also
listSchemeVariants()

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

◆ loadPalette()

void QgsColorBrewerColorRamp::loadPalette ( )
protected

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

Definition at line 878 of file qgscolorrampimpl.cpp.

◆ properties()

QVariantMap QgsColorBrewerColorRamp::properties ( ) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 933 of file qgscolorrampimpl.cpp.

◆ schemeName()

QString QgsColorBrewerColorRamp::schemeName ( ) const
inline

Returns the name of the color brewer color scheme.

See also
setSchemeName()

Definition at line 645 of file qgscolorrampimpl.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 667 of file qgscolorrampimpl.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 659 of file qgscolorrampimpl.h.

◆ type()

QString QgsColorBrewerColorRamp::type ( ) const
inlineoverridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 635 of file qgscolorrampimpl.h.

◆ typeString()

static QString QgsColorBrewerColorRamp::typeString ( )
inlinestatic

Returns the string identifier for QgsColorBrewerColorRamp.

Since
QGIS 3.16

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

Member Data Documentation

◆ mColors

int QgsColorBrewerColorRamp::mColors
protected

Definition at line 689 of file qgscolorrampimpl.h.

◆ mInverted

bool QgsColorBrewerColorRamp::mInverted
protected

Definition at line 691 of file qgscolorrampimpl.h.

◆ mPalette

QList<QColor> QgsColorBrewerColorRamp::mPalette
protected

Definition at line 690 of file qgscolorrampimpl.h.

◆ mSchemeName

QString QgsColorBrewerColorRamp::mSchemeName
protected

Definition at line 688 of file qgscolorrampimpl.h.


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