QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscolorbrewerpalette.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscolorbrewerpalette.h
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSCOLORBREWERPALETTE_H
16 #define QGSCOLORBREWERPALETTE_H
17 
18 #include <QList>
19 #include <QColor>
20 
21 #include "qgssymbollayerv2utils.h"
22 
23 class CORE_EXPORT QgsColorBrewerPalette
24 {
25  public:
26  static QList<QColor> listSchemeColors( QString schemeName, int colors )
27  {
28  QList<QColor> pal;
29  QString palette( brewerString );
30  QStringList list = palette.split( QChar( '\n' ) );
31  foreach ( QString entry, list )
32  {
33  QStringList items = entry.split( QChar( '-' ) );
34  if ( items.count() != 3 || items[0] != schemeName || items[1].toInt() != colors )
35  continue;
36  QStringList colors = items[2].split( QChar( ' ' ) );
37  foreach ( QString clr, colors )
38  {
40  }
41  }
42  return pal;
43  }
44 
45  static QStringList listSchemes()
46  {
47  QStringList schemes;
48 
49  QString palette( brewerString );
50  QStringList list = palette.split( QChar( '\n' ) );
51  foreach ( QString entry, list )
52  {
53  QStringList items = entry.split( QChar( '-' ) );
54  if ( items.count() != 3 )
55  continue;
56  if ( !schemes.contains( items[0] ) )
57  schemes << items[0];
58  }
59  return schemes;
60  }
61 
62  static QList<int> listSchemeVariants( QString schemeName )
63  {
64  QList<int> variants;
65 
66  QString palette( brewerString );
67  QStringList list = palette.split( QChar( '\n' ) );
68  foreach ( QString entry, list )
69  {
70  QStringList items = entry.split( QChar( '-' ) );
71  if ( items.count() != 3 || items[0] != schemeName )
72  continue;
73  variants << items[1].toInt();
74  }
75 
76  return variants;
77  }
78 
79  // extracted ColorBrewer data
80  static const char *brewerString;
81 };
82 
83 #endif // QGSCOLORBREWERPALETTE_H