QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgscolorschemeregistry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscolorschemeregistry.h
3 ------------------------
4 begin : July 2014
5 copyright : (C) 2014 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSCOLORSCHEMEREGISTRY_H
19#define QGSCOLORSCHEMEREGISTRY_H
20
21#include "qgis_core.h"
22#include "qgscolorscheme.h"
23
24#include <QList>
25
34class CORE_EXPORT QgsColorSchemeRegistry
35{
36 public:
41
43
50
57 void addDefaultSchemes();
58
63 void initStyleScheme();
64
71 void addUserSchemes();
72
81
88 bool removeColorScheme( QgsColorScheme *scheme );
89
94 QList<QgsColorScheme *> schemes() const;
95
101 QList<QgsColorScheme *> schemes( QgsColorScheme::SchemeFlag flag ) const;
102
103
109#ifndef SIP_RUN
110 template<class T> void schemes( QList<T *> &schemeList ) const
111 {
112 schemeList.clear();
113 QList<QgsColorScheme *> schemeInstanceList = schemes();
114 QList<QgsColorScheme *>::iterator schemeIt = schemeInstanceList.begin();
115 for ( ; schemeIt != schemeInstanceList.end(); ++schemeIt )
116 {
117 T *scheme = dynamic_cast<T *>( *schemeIt );
118 if ( scheme )
119 {
120 schemeList.push_back( scheme );
121 }
122 }
123 }
124#endif
125
142 void setRandomStyleColorScheme( QgsColorScheme *scheme );
143
154 QgsColorScheme *randomStyleColorScheme();
155
177 QColor fetchRandomStyleColor() const;
178
179 private:
180 QList< QgsColorScheme * > mColorSchemeList;
181
182 QgsColorScheme *mRandomStyleColorScheme = nullptr;
183 QgsNamedColorList mRandomStyleColors;
184
185 mutable int mNextRandomStyleColorIndex = 0;
186
187 int mNextRandomStyleColorDirection = 1;
188};
189
190
191#endif
void addDefaultSchemes()
Adds all default color schemes to this color scheme.
void addColorScheme(QgsColorScheme *scheme)
Adds a color scheme to the registry.
QList< QgsColorScheme * > schemes() const
Returns all color schemes in the registry.
void populateFromInstance()
Adds all color schemes from the global instance to this color scheme.
bool removeColorScheme(QgsColorScheme *scheme)
Removes all matching color schemes from the registry.
void initStyleScheme()
Initializes the default random style color scheme for the user.
void addUserSchemes()
Creates schemes for all gpl palettes in the user's palettes folder.
QgsColorSchemeRegistry()=default
Constructor for an empty color scheme registry.
void schemes(QList< T * > &schemeList) const
Returns color schemes of a specific type.
Abstract base class for color schemes.
SchemeFlag
Flags for controlling behavior of color scheme.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
#define SIP_TRANSFER
Definition qgis_sip.h:35