QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
Public Types | Public Member Functions | List of all members
QgsColorScheme Class Referenceabstract

Abstract base class for color schemes. More...

#include <qgscolorscheme.h>

Inheritance diagram for QgsColorScheme:
Inheritance graph
[legend]

Public Types

enum  SchemeFlag { ShowInColorDialog = 0x01 , ShowInColorButtonMenu = 0x02 , ShowInAllContexts = ShowInColorDialog | ShowInColorButtonMenu }
 Flags for controlling behavior of color scheme. More...
 

Public Member Functions

 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...
 

Detailed Description

Abstract base class for color schemes.

A color scheme for display in QgsColorButton. Color schemes return lists of colors with an optional associated color name. The colors returned can be generated using an optional base color.

Since
QGIS 2.5

Definition at line 46 of file qgscolorscheme.h.

Member Enumeration Documentation

◆ SchemeFlag

Flags for controlling behavior of color scheme.

Enumerator
ShowInColorDialog 

Show scheme in color picker dialog.

ShowInColorButtonMenu 

Show scheme in color button drop-down menu.

ShowInAllContexts 

Show scheme in all contexts.

Definition at line 71 of file qgscolorscheme.h.

Constructor & Destructor Documentation

◆ QgsColorScheme()

QgsColorScheme::QgsColorScheme ( )
default

Constructor for QgsColorScheme.

◆ ~QgsColorScheme()

virtual QgsColorScheme::~QgsColorScheme ( )
virtualdefault

Member Function Documentation

◆ clone()

virtual QgsColorScheme * QgsColorScheme::clone ( ) const
pure virtual

Clones a color scheme.

Returns
copy of color scheme

Implemented in QgsPresetSchemeColorRamp, QgsUserColorScheme, QgsRecentColorScheme, QgsCustomColorScheme, and QgsProjectColorScheme.

◆ fetchColors()

virtual QgsNamedColorList QgsColorScheme::fetchColors ( const QString &  context = QString(),
const QColor &  baseColor = QColor() 
)
pure virtual

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

Implemented in QgsPresetSchemeColorRamp, QgsGplColorScheme, QgsRecentColorScheme, QgsCustomColorScheme, and QgsProjectColorScheme.

◆ flags()

virtual SchemeFlags QgsColorScheme::flags ( ) const
inlinevirtual

Returns the current flags for the color scheme.

Returns
current flags

Reimplemented in QgsUserColorScheme, QgsRecentColorScheme, QgsCustomColorScheme, and QgsProjectColorScheme.

Definition at line 96 of file qgscolorscheme.h.

◆ isEditable()

virtual bool QgsColorScheme::isEditable ( ) const
inlinevirtual

Returns whether the color scheme is editable.

Returns
true if scheme is editable
See also
setColors

Reimplemented in QgsPresetSchemeColorRamp, QgsUserColorScheme, QgsCustomColorScheme, and QgsProjectColorScheme.

Definition at line 117 of file qgscolorscheme.h.

◆ schemeName()

virtual QString QgsColorScheme::schemeName ( ) const
pure virtual

Gets the name for the color scheme.

Returns
color scheme name

Implemented in QgsPresetSchemeColorRamp, QgsUserColorScheme, QgsRecentColorScheme, QgsCustomColorScheme, and QgsProjectColorScheme.

◆ setColors()

bool QgsColorScheme::setColors ( const QgsNamedColorList colors,
const QString &  context = QString(),
const QColor &  baseColor = QColor() 
)
virtual

Sets the colors for the scheme.

This method is only valid for editable color schemes.

Parameters
colorslist of colors for the scheme
contextto set colors for
baseColorbase color to set colors for
Returns
true if colors were set successfully
See also
isEditable

Reimplemented in QgsPresetSchemeColorRamp, QgsGplColorScheme, QgsCustomColorScheme, and QgsProjectColorScheme.

Definition at line 30 of file qgscolorscheme.cpp.


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