Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsvectorcolorrampv2.h
Go to the documentation of this file.
1 
2 #ifndef QGSVECTORCOLORRAMPV2_H
3 #define QGSVECTORCOLORRAMPV2_H
4 
5 #include <QColor>
6 
7 #include "qgssymbollayerv2.h" // for QgsStringMap
8 
9 class CORE_EXPORT QgsVectorColorRampV2
10 {
11  public:
12  virtual ~QgsVectorColorRampV2() {}
13 
14  virtual QColor color( double value ) const = 0;
15 
16  virtual QString type() const = 0;
17 
18  virtual QgsVectorColorRampV2* clone() const = 0;
19 
20  virtual QgsStringMap properties() const = 0;
21 
22 };
23 
24 #define DEFAULT_GRADIENT_COLOR1 QColor(0,0,255)
25 #define DEFAULT_GRADIENT_COLOR2 QColor(0,255,0)
26 
28 {
29  public:
31  QColor color2 = DEFAULT_GRADIENT_COLOR2 );
32 
33  static QgsVectorColorRampV2* create( const QgsStringMap& properties = QgsStringMap() );
34 
35  virtual QColor color( double value ) const;
36 
37  virtual QString type() const { return "gradient"; }
38 
39  virtual QgsVectorColorRampV2* clone() const;
40 
41  virtual QgsStringMap properties() const;
42 
43  QColor color1() const { return mColor1; }
44  QColor color2() const { return mColor2; }
45 
46  void setColor1( QColor color ) { mColor1 = color; }
47  void setColor2( QColor color ) { mColor2 = color; }
48 
49  typedef QMap<double, QColor> StopsMap;
50 
51  void setStops( const StopsMap& stops ) { mStops = stops; }
52  const StopsMap& stops() const { return mStops; }
53 
54  protected:
55  QColor mColor1, mColor2;
57 };
58 
59 #define DEFAULT_RANDOM_COUNT 10
60 #define DEFAULT_RANDOM_HUE_MIN 0
61 #define DEFAULT_RANDOM_HUE_MAX 359
62 #define DEFAULT_RANDOM_VAL_MIN 0
63 #define DEFAULT_RANDOM_VAL_MAX 255
64 #define DEFAULT_RANDOM_SAT_MIN 0
65 #define DEFAULT_RANDOM_SAT_MAX 255
66 
68 {
69  public:
71  int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX,
72  int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX,
73  int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX );
74 
75  static QgsVectorColorRampV2* create( const QgsStringMap& properties = QgsStringMap() );
76 
77  virtual QColor color( double value ) const;
78 
79  virtual QString type() const { return "random"; }
80 
81  virtual QgsVectorColorRampV2* clone() const;
82 
83  virtual QgsStringMap properties() const;
84 
85  void updateColors();
86 
87  int count() const { return mCount; }
88  int hueMin() const { return mHueMin; }
89  int hueMax() const { return mHueMax; }
90  int satMin() const { return mSatMin; }
91  int satMax() const { return mSatMax; }
92  int valMin() const { return mValMin; }
93  int valMax() const { return mValMax; }
94 
95  void setCount( int val ) { mCount = val; }
96  void setHueMin( int val ) { mHueMin = val; }
97  void setHueMax( int val ) { mHueMax = val; }
98  void setSatMin( int val ) { mSatMin = val; }
99  void setSatMax( int val ) { mSatMax = val; }
100  void setValMin( int val ) { mValMin = val; }
101  void setValMax( int val ) { mValMax = val; }
102 
103  protected:
104  int mCount;
105  int mHueMin, mHueMax, mSatMin, mSatMax, mValMin, mValMax;
106  QList<QColor> mColors;
107 };
108 
109 
110 #define DEFAULT_COLORBREWER_SCHEMENAME "Spectral"
111 #define DEFAULT_COLORBREWER_COLORS 5
112 
114 {
115  public:
117  int colors = DEFAULT_COLORBREWER_COLORS );
118 
119  static QgsVectorColorRampV2* create( const QgsStringMap& properties = QgsStringMap() );
120 
121  virtual QColor color( double value ) const;
122 
123  virtual QString type() const { return "colorbrewer"; }
124 
125  virtual QgsVectorColorRampV2* clone() const;
126 
127  virtual QgsStringMap properties() const;
128 
129  QString schemeName() const { return mSchemeName; }
130  int colors() const { return mColors; }
131 
132  void setSchemeName( QString schemeName ) { mSchemeName = schemeName; loadPalette(); }
133  void setColors( int colors ) { mColors = colors; loadPalette(); }
134 
135  static QStringList listSchemeNames();
136  static QList<int> listSchemeVariants( QString schemeName );
137 
138  protected:
139 
140  void loadPalette();
141 
142  QString mSchemeName;
143  int mColors;
144  QList<QColor> mPalette;
145 };
146 
147 #endif