QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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#include <QList>
24
33class CORE_EXPORT QgsColorSchemeRegistry
34{
35
36 public:
37
42
44
50 void populateFromInstance();
51
58 void addDefaultSchemes();
59
64 void initStyleScheme();
65
72 void addUserSchemes();
73
81 void addColorScheme( QgsColorScheme *scheme SIP_TRANSFER );
82
89 bool removeColorScheme( QgsColorScheme *scheme );
90
95 QList<QgsColorScheme *> schemes() const;
96
102 QList<QgsColorScheme *> schemes( QgsColorScheme::SchemeFlag flag ) const;
103
104
110#ifndef SIP_RUN
111 template<class T> void schemes( QList<T *> &schemeList ) const
112 {
113 schemeList.clear();
114 QList<QgsColorScheme *> schemeInstanceList = schemes();
115 QList<QgsColorScheme *>::iterator schemeIt = schemeInstanceList.begin();
116 for ( ; schemeIt != schemeInstanceList.end(); ++schemeIt )
117 {
118 T *scheme = dynamic_cast<T *>( *schemeIt );
119 if ( scheme )
120 {
121 schemeList.push_back( scheme );
122 }
123 }
124 }
125#endif
126
143 void setRandomStyleColorScheme( QgsColorScheme *scheme );
144
155 QgsColorScheme *randomStyleColorScheme();
156
178 QColor fetchRandomStyleColor() const;
179
180 private:
181
182 QList< QgsColorScheme * > mColorSchemeList;
183
184 QgsColorScheme *mRandomStyleColorScheme = nullptr;
185 QgsNamedColorList mRandomStyleColors;
186
187 mutable int mNextRandomStyleColorIndex = 0;
188
189 int mNextRandomStyleColorDirection = 1;
190
191};
192
193
194
195#endif
Registry of color schemes.
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:36