QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsColorSchemeRegistry Class Reference

Registry of color schemes. More...

#include <qgscolorschemeregistry.h>

Public Member Functions

 QgsColorSchemeRegistry ()=default
 Constructor for an empty color scheme registry.
 
virtual ~QgsColorSchemeRegistry ()
 
void addColorScheme (QgsColorScheme *scheme)
 Adds a color scheme to the registry.
 
void addDefaultSchemes ()
 Adds all default color schemes to this color scheme.
 
void addUserSchemes ()
 Creates schemes for all gpl palettes in the user's palettes folder.
 
QColor fetchRandomStyleColor () const
 Returns a random color for use with a new symbol style (e.g.
 
void initStyleScheme ()
 Initializes the default random style color scheme for the user.
 
void populateFromInstance ()
 Adds all color schemes from the global instance to this color scheme.
 
QgsColorSchemerandomStyleColorScheme ()
 Returns the color scheme used when fetching random colors to use for symbol styles.
 
bool removeColorScheme (QgsColorScheme *scheme)
 Removes all matching color schemes from the registry.
 
QList< QgsColorScheme * > schemes () const
 Returns all color schemes in the registry.
 
QList< QgsColorScheme * > schemes (QgsColorScheme::SchemeFlag flag) const
 Returns all color schemes in the registry which have a specified flag set.
 
template<class T >
void schemes (QList< T * > &schemeList) const
 Returns color schemes of a specific type.
 
void setRandomStyleColorScheme (QgsColorScheme *scheme)
 Sets the color scheme to use when fetching random colors to use for symbol styles.
 

Detailed Description

Registry of color schemes.

A registry of QgsColorScheme color schemes. This class can be created directly, or accessed via a QgsApplication::colorSchemeRegistry().

Definition at line 33 of file qgscolorschemeregistry.h.

Constructor & Destructor Documentation

◆ QgsColorSchemeRegistry()

QgsColorSchemeRegistry::QgsColorSchemeRegistry ( )
default

Constructor for an empty color scheme registry.

◆ ~QgsColorSchemeRegistry()

QgsColorSchemeRegistry::~QgsColorSchemeRegistry ( )
virtual

Definition at line 26 of file qgscolorschemeregistry.cpp.

Member Function Documentation

◆ addColorScheme()

void QgsColorSchemeRegistry::addColorScheme ( QgsColorScheme scheme)

Adds a color scheme to the registry.

Ownership of the scheme is transferred to the registry.

Parameters
schemecolor scheme to add
See also
populateFromInstance
removeColorScheme

Definition at line 83 of file qgscolorschemeregistry.cpp.

◆ addDefaultSchemes()

void QgsColorSchemeRegistry::addDefaultSchemes ( )

Adds all default color schemes to this color scheme.

See also
populateFromInstance
addColorScheme
addUserSchemes

Definition at line 45 of file qgscolorschemeregistry.cpp.

◆ addUserSchemes()

void QgsColorSchemeRegistry::addUserSchemes ( )

Creates schemes for all gpl palettes in the user's palettes folder.

See also
populateFromInstance
addDefaultSchemes
addColorScheme

Definition at line 65 of file qgscolorschemeregistry.cpp.

◆ fetchRandomStyleColor()

QColor QgsColorSchemeRegistry::fetchRandomStyleColor ( ) const

Returns a random color for use with a new symbol style (e.g.

for a newly created map layer).

If a randomStyleColorScheme() is set then this color will be randomly taken from that color scheme. If no randomStyleColorScheme() is set then a totally random color will be generated.

Note that calling setRandomStyleColorScheme() takes a snapshot of the colors from the scheme's QgsColorScheme::fetchColors() list. Accordingly, any future changes to the colors in the scheme are not automatically reflected by calls to fetchRandomStyleColor(). If the scheme is updated, then another call to setRandomStyleColorScheme() must be made in order to update the cached list of available style colors from which fetchRandomStyleColor() selects colors.

This method is thread safe.

See also
randomStyleColorScheme()
setRandomStyleColorScheme()
Since
QGIS 3.2

Definition at line 141 of file qgscolorschemeregistry.cpp.

◆ initStyleScheme()

void QgsColorSchemeRegistry::initStyleScheme ( )

Initializes the default random style color scheme for the user.

Since
QGIS 3.2

Definition at line 54 of file qgscolorschemeregistry.cpp.

◆ populateFromInstance()

void QgsColorSchemeRegistry::populateFromInstance ( )

Adds all color schemes from the global instance to this color scheme.

See also
addDefaultSchemes
addColorScheme

Definition at line 32 of file qgscolorschemeregistry.cpp.

◆ randomStyleColorScheme()

QgsColorScheme * QgsColorSchemeRegistry::randomStyleColorScheme ( )

Returns the color scheme used when fetching random colors to use for symbol styles.

This may be nullptr, in which case totally random colors are used for styles.

See also
setRandomStyleColorScheme()
fetchRandomStyleColor()
Since
QGIS 3.2

Definition at line 136 of file qgscolorschemeregistry.cpp.

◆ removeColorScheme()

bool QgsColorSchemeRegistry::removeColorScheme ( QgsColorScheme scheme)

Removes all matching color schemes from the registry.

Parameters
schemecolor scheme to remove
Returns
true if scheme was found and removed
See also
addColorScheme

Definition at line 169 of file qgscolorschemeregistry.cpp.

◆ schemes() [1/3]

QList< QgsColorScheme * > QgsColorSchemeRegistry::schemes ( ) const

Returns all color schemes in the registry.

Returns
list of color schemes

Definition at line 88 of file qgscolorschemeregistry.cpp.

◆ schemes() [2/3]

QList< QgsColorScheme * > QgsColorSchemeRegistry::schemes ( QgsColorScheme::SchemeFlag  flag) const

Returns all color schemes in the registry which have a specified flag set.

Parameters
flagflag to match
Returns
list of color schemes with flag set

Definition at line 99 of file qgscolorschemeregistry.cpp.

◆ schemes() [3/3]

template<class T >
void QgsColorSchemeRegistry::schemes ( QList< T * > &  schemeList) const
inline

Returns color schemes of a specific type.

Parameters
schemeListdestination list for matching schemes
Note
not available in Python bindings

Definition at line 111 of file qgscolorschemeregistry.h.

◆ setRandomStyleColorScheme()

void QgsColorSchemeRegistry::setRandomStyleColorScheme ( QgsColorScheme scheme)

Sets the color scheme to use when fetching random colors to use for symbol styles.

scheme should match a color scheme which is already present in the registry.

Note that calling this method takes a snapshot of the colors from the scheme's QgsColorScheme::fetchColors() list. Accordingly, any future changes to the colors in scheme are not automatically reflected by calls to fetchRandomStyleColor(). If scheme is updated, then another call to setRandomStyleColorScheme() must be made in order to update the cached list of available style colors.

See also
randomStyleColorScheme()
fetchRandomStyleColor()
Since
QGIS 3.2

Definition at line 113 of file qgscolorschemeregistry.cpp.


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