Quantum GIS API Documentation
1.7.4
|
00001 00002 #ifndef QGSVECTORCOLORRAMPV2_H 00003 #define QGSVECTORCOLORRAMPV2_H 00004 00005 #include <QColor> 00006 00007 #include "qgssymbollayerv2.h" // for QgsStringMap 00008 00009 class CORE_EXPORT QgsVectorColorRampV2 00010 { 00011 public: 00012 virtual ~QgsVectorColorRampV2() {} 00013 00014 virtual QColor color( double value ) const = 0; 00015 00016 virtual QString type() const = 0; 00017 00018 virtual QgsVectorColorRampV2* clone() const = 0; 00019 00020 virtual QgsStringMap properties() const = 0; 00021 00022 }; 00023 00024 #define DEFAULT_GRADIENT_COLOR1 QColor(0,0,255) 00025 #define DEFAULT_GRADIENT_COLOR2 QColor(0,255,0) 00026 00027 class CORE_EXPORT QgsVectorGradientColorRampV2 : public QgsVectorColorRampV2 00028 { 00029 public: 00030 QgsVectorGradientColorRampV2( QColor color1 = DEFAULT_GRADIENT_COLOR1, 00031 QColor color2 = DEFAULT_GRADIENT_COLOR2 ); 00032 00033 static QgsVectorColorRampV2* create( const QgsStringMap& properties = QgsStringMap() ); 00034 00035 virtual QColor color( double value ) const; 00036 00037 virtual QString type() const { return "gradient"; } 00038 00039 virtual QgsVectorColorRampV2* clone() const; 00040 00041 virtual QgsStringMap properties() const; 00042 00043 QColor color1() const { return mColor1; } 00044 QColor color2() const { return mColor2; } 00045 00046 void setColor1( QColor color ) { mColor1 = color; } 00047 void setColor2( QColor color ) { mColor2 = color; } 00048 00049 typedef QMap<double, QColor> StopsMap; 00050 00051 void setStops( const StopsMap& stops ) { mStops = stops; } 00052 const StopsMap& stops() const { return mStops; } 00053 00054 protected: 00055 QColor mColor1, mColor2; 00056 StopsMap mStops; 00057 }; 00058 00059 #define DEFAULT_RANDOM_COUNT 10 00060 #define DEFAULT_RANDOM_HUE_MIN 0 00061 #define DEFAULT_RANDOM_HUE_MAX 359 00062 #define DEFAULT_RANDOM_VAL_MIN 0 00063 #define DEFAULT_RANDOM_VAL_MAX 255 00064 #define DEFAULT_RANDOM_SAT_MIN 0 00065 #define DEFAULT_RANDOM_SAT_MAX 255 00066 00067 class CORE_EXPORT QgsVectorRandomColorRampV2 : public QgsVectorColorRampV2 00068 { 00069 public: 00070 QgsVectorRandomColorRampV2( int count = DEFAULT_RANDOM_COUNT, 00071 int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX, 00072 int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX, 00073 int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX ); 00074 00075 static QgsVectorColorRampV2* create( const QgsStringMap& properties = QgsStringMap() ); 00076 00077 virtual QColor color( double value ) const; 00078 00079 virtual QString type() const { return "random"; } 00080 00081 virtual QgsVectorColorRampV2* clone() const; 00082 00083 virtual QgsStringMap properties() const; 00084 00085 void updateColors(); 00086 00087 int count() const { return mCount; } 00088 int hueMin() const { return mHueMin; } 00089 int hueMax() const { return mHueMax; } 00090 int satMin() const { return mSatMin; } 00091 int satMax() const { return mSatMax; } 00092 int valMin() const { return mValMin; } 00093 int valMax() const { return mValMax; } 00094 00095 void setCount( int val ) { mCount = val; } 00096 void setHueMin( int val ) { mHueMin = val; } 00097 void setHueMax( int val ) { mHueMax = val; } 00098 void setSatMin( int val ) { mSatMin = val; } 00099 void setSatMax( int val ) { mSatMax = val; } 00100 void setValMin( int val ) { mValMin = val; } 00101 void setValMax( int val ) { mValMax = val; } 00102 00103 protected: 00104 int mCount; 00105 int mHueMin, mHueMax, mSatMin, mSatMax, mValMin, mValMax; 00106 QList<QColor> mColors; 00107 }; 00108 00109 00110 #define DEFAULT_COLORBREWER_SCHEMENAME "Spectral" 00111 #define DEFAULT_COLORBREWER_COLORS 5 00112 00113 class CORE_EXPORT QgsVectorColorBrewerColorRampV2 : public QgsVectorColorRampV2 00114 { 00115 public: 00116 QgsVectorColorBrewerColorRampV2( QString schemeName = DEFAULT_COLORBREWER_SCHEMENAME, 00117 int colors = DEFAULT_COLORBREWER_COLORS ); 00118 00119 static QgsVectorColorRampV2* create( const QgsStringMap& properties = QgsStringMap() ); 00120 00121 virtual QColor color( double value ) const; 00122 00123 virtual QString type() const { return "colorbrewer"; } 00124 00125 virtual QgsVectorColorRampV2* clone() const; 00126 00127 virtual QgsStringMap properties() const; 00128 00129 QString schemeName() const { return mSchemeName; } 00130 int colors() const { return mColors; } 00131 00132 void setSchemeName( QString schemeName ) { mSchemeName = schemeName; loadPalette(); } 00133 void setColors( int colors ) { mColors = colors; loadPalette(); } 00134 00135 static QStringList listSchemeNames(); 00136 static QList<int> listSchemeVariants( QString schemeName ); 00137 00138 protected: 00139 00140 void loadPalette(); 00141 00142 QString mSchemeName; 00143 int mColors; 00144 QList<QColor> mPalette; 00145 }; 00146 00147 #endif