00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef QGSCOLORRAMPSHADER_H
00022 #define QGSCOLORRAMPSHADER_H
00023
00024 #include <QColor>
00025 #include <QMap>
00026
00027 #include "qgsrastershaderfunction.h"
00028
00032 class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
00033 {
00034
00035 public:
00036 QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 );
00037
00038
00039
00040
00041
00042 struct ColorRampItem
00043 {
00045 ColorRampItem() {}
00047 ColorRampItem( double val, QColor col, QString lbl = QString() ) : label( lbl ), value( val ), color( col ) {}
00048
00049 QString label;
00050 double value;
00051 QColor color;
00052
00053
00054 bool operator<( const ColorRampItem& other ) const { return value < other.value; }
00055 };
00056
00057 enum ColorRamp_TYPE
00058 {
00059 INTERPOLATED,
00060 DISCRETE,
00061 EXACT
00062 };
00063
00065 QList<QgsColorRampShader::ColorRampItem> colorRampItemList() const {return mColorRampItemList;}
00066
00068 QgsColorRampShader::ColorRamp_TYPE colorRampType() {return mColorRampType;}
00069
00071 QString colorRampTypeAsQString();
00072
00074 int maximumColorCacheSize() { return mMaximumColorCacheSize; }
00075
00077 void setColorRampItemList( const QList<QgsColorRampShader::ColorRampItem>& theList );
00078
00080 void setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType );
00081
00083 void setColorRampType( QString );
00084
00086 void setMaximumColorCacheSize( int theSize ) { mMaximumColorCacheSize = theSize; }
00087
00089 bool shade( double, int*, int*, int* );
00090
00092 bool shade( double, double, double, int*, int*, int* );
00093
00094 private:
00096 int mCurrentColorRampItemIndex;
00097
00098
00100 QList<QgsColorRampShader::ColorRampItem> mColorRampItemList;
00101
00103 QgsColorRampShader::ColorRamp_TYPE mColorRampType;
00104
00106 QMap<double, QColor> mColorCache;
00107
00109 int mMaximumColorCacheSize;
00110
00111
00112
00114 bool discreteColor( double, int*, int*, int* );
00115
00117 bool exactColor( double, int*, int*, int* );
00118
00120 bool interpolatedColor( double, int*, int*, int* );
00121 };
00122
00123 #endif