QGIS API Documentation
3.6.0-Noosa (5873452)
|
Registry of color schemes. More...
#include <qgscolorschemeregistry.h>
Public Member Functions | |
QgsColorSchemeRegistry ()=default | |
Constructor for an empty color scheme registry. More... | |
virtual | ~QgsColorSchemeRegistry () |
void | addColorScheme (QgsColorScheme *scheme) |
Adds a color scheme to the registry. More... | |
void | addDefaultSchemes () |
Adds all default color schemes to this color scheme. More... | |
void | addUserSchemes () |
Creates schemes for all gpl palettes in the user's palettes folder. More... | |
QColor | fetchRandomStyleColor () const |
Returns a random color for use with a new symbol style (e.g. More... | |
void | initStyleScheme () |
Initializes the default random style color scheme for the user. More... | |
void | populateFromInstance () |
Adds all color schemes from the global instance to this color scheme. More... | |
QgsColorScheme * | randomStyleColorScheme () |
Returns the color scheme used when fetching random colors to use for symbol styles. More... | |
bool | removeColorScheme (QgsColorScheme *scheme) |
Removes all matching color schemes from the registry. More... | |
QList< QgsColorScheme * > | schemes () const |
Returns all color schemes in the registry. More... | |
QList< QgsColorScheme * > | schemes (QgsColorScheme::SchemeFlag flag) const |
Returns all color schemes in the registry which have a specified flag set. More... | |
template<class T > | |
void | schemes (QList< T *> &schemeList) |
Returns color schemes of a specific type. More... | |
void | setRandomStyleColorScheme (QgsColorScheme *scheme) |
Sets the color scheme to use when fetching random colors to use for symbol styles. More... | |
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 34 of file qgscolorschemeregistry.h.
|
default |
Constructor for an empty color scheme registry.
|
virtual |
Definition at line 26 of file qgscolorschemeregistry.cpp.
void QgsColorSchemeRegistry::addColorScheme | ( | QgsColorScheme * | scheme | ) |
Adds a color scheme to the registry.
Ownership of the scheme is transferred to the registry.
scheme | color scheme to add |
Definition at line 83 of file qgscolorschemeregistry.cpp.
void QgsColorSchemeRegistry::addDefaultSchemes | ( | ) |
Adds all default color schemes to this color scheme.
Definition at line 45 of file qgscolorschemeregistry.cpp.
void QgsColorSchemeRegistry::addUserSchemes | ( | ) |
Creates schemes for all gpl palettes in the user's palettes folder.
Definition at line 65 of file qgscolorschemeregistry.cpp.
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.
Definition at line 141 of file qgscolorschemeregistry.cpp.
void QgsColorSchemeRegistry::initStyleScheme | ( | ) |
Initializes the default random style color scheme for the user.
Definition at line 54 of file qgscolorschemeregistry.cpp.
void QgsColorSchemeRegistry::populateFromInstance | ( | ) |
Adds all color schemes from the global instance to this color scheme.
Definition at line 32 of file qgscolorschemeregistry.cpp.
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.
Definition at line 136 of file qgscolorschemeregistry.cpp.
bool QgsColorSchemeRegistry::removeColorScheme | ( | QgsColorScheme * | scheme | ) |
Removes all matching color schemes from the registry.
scheme | color scheme to remove |
Definition at line 169 of file qgscolorschemeregistry.cpp.
QList< QgsColorScheme * > QgsColorSchemeRegistry::schemes | ( | ) | const |
Returns all color schemes in the registry.
Definition at line 88 of file qgscolorschemeregistry.cpp.
QList< QgsColorScheme * > QgsColorSchemeRegistry::schemes | ( | QgsColorScheme::SchemeFlag | flag | ) | const |
Returns all color schemes in the registry which have a specified flag set.
flag | flag to match |
Definition at line 99 of file qgscolorschemeregistry.cpp.
|
inline |
Returns color schemes of a specific type.
schemeList | destination list for matching schemes |
Definition at line 112 of file qgscolorschemeregistry.h.
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.
Definition at line 113 of file qgscolorschemeregistry.cpp.