QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Member Functions | Static Public Member Functions | List of all members
QgsPresetSchemeColorRamp Class Reference

A scheme based color ramp consisting of a list of predefined colors. More...

#include <qgscolorrampimpl.h>

Inheritance diagram for QgsPresetSchemeColorRamp:
Inheritance graph
[legend]

Public Member Functions

 QgsPresetSchemeColorRamp (const QgsNamedColorList &colors)
 Constructor for QgsPresetColorRamp. More...
 
 QgsPresetSchemeColorRamp (const QList< QColor > &colors=QList< QColor >())
 Constructor for QgsPresetSchemeColorRamp. More...
 
QgsPresetSchemeColorRampclone () 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...
 
QList< QColor > colors () const
 Returns the list of colors used by the ramp. More...
 
int count () const override
 Returns number of defined colors, or -1 if undefined. More...
 
QgsNamedColorList fetchColors (const QString &context=QString(), const QColor &baseColor=QColor()) override
 Gets a list of colors from the scheme. More...
 
void invert () override
 Inverts the ordering of the color ramp. More...
 
bool isEditable () const override
 Returns whether the color scheme is editable. More...
 
QVariantMap properties () const override
 Returns a string map containing all the color ramp's properties. More...
 
QString schemeName () const override
 Gets the name for the color scheme. More...
 
bool setColors (const QgsNamedColorList &colors, const QString &=QString(), const QColor &=QColor()) override
 Sets the list of colors used by the ramp. 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 ()
 
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...
 
- Public Member Functions inherited from QgsColorScheme
 QgsColorScheme ()=default
 Constructor for QgsColorScheme. More...
 
virtual ~QgsColorScheme ()=default
 
virtual QgsColorSchemeclone () const =0
 Clones a color scheme. More...
 
virtual QgsNamedColorList fetchColors (const QString &context=QString(), const QColor &baseColor=QColor())=0
 Gets a list of colors from the scheme. More...
 
virtual SchemeFlags flags () const
 Returns the current flags for the color scheme. More...
 
virtual bool isEditable () const
 Returns whether the color scheme is editable. More...
 
virtual QString schemeName () const =0
 Gets the name for the color scheme. More...
 
virtual bool setColors (const QgsNamedColorList &colors, const QString &context=QString(), const QColor &baseColor=QColor())
 Sets the colors for the scheme. More...
 

Static Public Member Functions

static QgsColorRampcreate (const QVariantMap &properties=QVariantMap())
 Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string map. More...
 
static QString typeString ()
 Returns the string identifier for QgsPresetSchemeColorRamp. 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...
 

Additional Inherited Members

- Public Types inherited from QgsColorScheme
enum  SchemeFlag { ShowInColorDialog = 0x01 , ShowInColorButtonMenu = 0x02 , ShowInAllContexts = ShowInColorDialog | ShowInColorButtonMenu }
 Flags for controlling behavior of color scheme. More...
 
typedef QFlags< SchemeFlagSchemeFlags
 

Detailed Description

A scheme based color ramp consisting of a list of predefined colors.

Definition at line 535 of file qgscolorrampimpl.h.

Constructor & Destructor Documentation

◆ QgsPresetSchemeColorRamp() [1/2]

QgsPresetSchemeColorRamp::QgsPresetSchemeColorRamp ( const QList< QColor > &  colors = QList< QColor >())

Constructor for QgsPresetSchemeColorRamp.

Parameters
colorslist of colors in ramp

Definition at line 1146 of file qgscolorrampimpl.cpp.

◆ QgsPresetSchemeColorRamp() [2/2]

QgsPresetSchemeColorRamp::QgsPresetSchemeColorRamp ( const QgsNamedColorList colors)

Constructor for QgsPresetColorRamp.

Parameters
colorslist of named colors in ramp

Definition at line 1158 of file qgscolorrampimpl.cpp.

Member Function Documentation

◆ clone()

QgsPresetSchemeColorRamp * QgsPresetSchemeColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

Definition at line 1232 of file qgscolorrampimpl.cpp.

◆ color()

QColor QgsPresetSchemeColorRamp::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 1202 of file qgscolorrampimpl.cpp.

◆ colors()

QList< QColor > QgsPresetSchemeColorRamp::colors ( ) const

Returns the list of colors used by the ramp.

See also
setColors()

Definition at line 1184 of file qgscolorrampimpl.cpp.

◆ count()

int QgsPresetSchemeColorRamp::count ( ) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 1249 of file qgscolorrampimpl.cpp.

◆ create()

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

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

Parameters
propertiescolor ramp properties
See also
properties()

Definition at line 1166 of file qgscolorrampimpl.cpp.

◆ fetchColors()

QgsNamedColorList QgsPresetSchemeColorRamp::fetchColors ( const QString &  context = QString(),
const QColor &  baseColor = QColor() 
)
overridevirtual

Gets a list of colors from the scheme.

The colors can optionally be generated using the supplied context and base color.

Parameters
contextstring specifying an optional context for the returned colors. For instance, a "recent colors" scheme may filter returned colors by context so that colors used only in a "composer" context are returned.
baseColorbase color for the scheme's colors. Some color schemes may take advantage of this to filter or modify their returned colors to colors related to the base color.
Returns
a list of QPairs of color and color name

Implements QgsColorScheme.

Definition at line 1254 of file qgscolorrampimpl.cpp.

◆ invert()

void QgsPresetSchemeColorRamp::invert ( )
overridevirtual

Inverts the ordering of the color ramp.

Reimplemented from QgsColorRamp.

Definition at line 1221 of file qgscolorrampimpl.cpp.

◆ isEditable()

bool QgsPresetSchemeColorRamp::isEditable ( ) const
inlineoverridevirtual

Returns whether the color scheme is editable.

Returns
true if scheme is editable
See also
setColors

Reimplemented from QgsColorScheme.

Definition at line 590 of file qgscolorrampimpl.h.

◆ properties()

QVariantMap QgsPresetSchemeColorRamp::properties ( ) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 1237 of file qgscolorrampimpl.cpp.

◆ schemeName()

QString QgsPresetSchemeColorRamp::schemeName ( ) const
inlineoverridevirtual

Gets the name for the color scheme.

Returns
color scheme name

Implements QgsColorScheme.

Definition at line 588 of file qgscolorrampimpl.h.

◆ setColors()

bool QgsPresetSchemeColorRamp::setColors ( const QgsNamedColorList colors,
const QString &  = QString(),
const QColor &  = QColor() 
)
inlineoverridevirtual

Sets the list of colors used by the ramp.

Parameters
colorslist of colors
See also
colors()

Reimplemented from QgsColorScheme.

Definition at line 564 of file qgscolorrampimpl.h.

◆ type()

QString QgsPresetSchemeColorRamp::type ( ) const
overridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 1216 of file qgscolorrampimpl.cpp.

◆ typeString()

static QString QgsPresetSchemeColorRamp::typeString ( )
inlinestatic

Returns the string identifier for QgsPresetSchemeColorRamp.

Since
QGIS 3.16

Definition at line 580 of file qgscolorrampimpl.h.

◆ value()

double QgsPresetSchemeColorRamp::value ( int  index) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 1195 of file qgscolorrampimpl.cpp.


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