@@ -5,7 +5,31 @@ class QgsColorRampShader : QgsRasterShaderFunction
55%End
66
77 public:
8- QgsColorRampShader ( double theMinimumValue = 0.0 , double theMaximumValue = 255.0 );
8+ // ! Supported methods for color interpolation.
9+ enum Type
10+ {
11+ Interpolated, // !< Interpolates the color between two class breaks linearly.
12+ Discrete, // !< Assigns the color of the higher class for every pixel between two class breaks.
13+ Exact // !< Assigns the color of the exact matching value in the color ramp item list
14+ };
15+
16+ // ! Classification modes used to create the color ramp shader
17+ enum ClassificationMode
18+ {
19+ Continuous = 1 , // !< Uses breaks from color palette
20+ EqualInterval = 2 , // !< Uses equal interval
21+ Quantile = 3 // !< Uses quantile (i.e. equal pixel) count
22+ };
23+
24+ /* * Creates a new color ramp shader.
25+ * @param theMinimumValue minimum value for the raster shader
26+ * @param theMaximumValue maximum value for the raster shader
27+ * @param theType interpolation type used
28+ * @param theClassificationMode method used to classify the color ramp shader
29+ * @param theColorRamp vector color ramp used to classify the color ramp shader
30+ * @returns new QgsColorRampShader
31+ */
32+ QgsColorRampShader ( double theMinimumValue = 0.0 , double theMaximumValue = 255.0 , QgsColorRamp* theColorRamp = nullptr , Type theType = Interpolated, ClassificationMode theClassificationMode = Continuous );
933
1034 ~QgsColorRampShader ();
1135
@@ -28,19 +52,11 @@ class QgsColorRampShader : QgsRasterShaderFunction
2852 bool operator <( const QgsColorRampShader::ColorRampItem& other ) const ;
2953 };
3054
31- /* * Supported methods for color interpolation. */
32- enum ColorRamp_TYPE
33- {
34- INTERPOLATED , // !< Interpolates the color between two class breaks linearly.
35- DISCRETE , // !< Assigns the color of the higher class for every pixel between two class breaks.
36- EXACT // !< Assigns the color of the exact matching value in the color ramp item list
37- };
38-
3955 /* * \brief Get the custom colormap*/
4056 QList<QgsColorRampShader::ColorRampItem> colorRampItemList () const ;
4157
4258 /* * \brief Get the color ramp type */
43- QgsColorRampShader::ColorRamp_TYPE colorRampType () const ;
59+ Type colorRampType () const ;
4460
4561 /* * Get the source color ramp
4662 * @note added in QGIS 3.0
@@ -61,11 +77,27 @@ class QgsColorRampShader : QgsRasterShaderFunction
6177 void setColorRampItemList ( const QList<QgsColorRampShader::ColorRampItem>& theList ); // TODO: sort on set
6278
6379 /* * \brief Set the color ramp type*/
64- void setColorRampType ( QgsColorRampShader::ColorRamp_TYPE theColorRampType );
80+ void setColorRampType ( QgsColorRampShader::Type theColorRampType );
6581
6682 /* * \brief Set the color ramp type*/
6783 void setColorRampType ( const QString& theType );
6884
85+ /* * Classify color ramp shader
86+ * @param classes number of classes
87+ * @param band raster band used in classification (only used in quantile mode)
88+ * @param extent extent used in classification (only used in quantile mode)
89+ * @param input raster input used in classification (only used in quantile mode)
90+ */
91+ void classifyColorRamp ( const int classes = 0 , const int band = -1 , const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr );
92+
93+ /* * Classify color ramp shader
94+ * @param band raster band used in classification (only used in quantile mode)
95+ * @param extent extent used in classification (only used in quantile mode)
96+ * @param input raster input used in classification (only used in quantile mode)
97+ */
98+ void classifyColorRamp ( const int band = -1 , const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr ) /PyName=classifyColorRampV2/;
99+
100+
69101 /* * \brief Generates and new RGB value based on one input value */
70102 bool shade ( double , int * /Out/, int * /Out/, int * /Out/, int * /Out/ );
71103
@@ -74,6 +106,12 @@ class QgsColorRampShader : QgsRasterShaderFunction
74106
75107 void legendSymbologyItems ( QList< QPair< QString, QColor > >& symbolItems ) const ;
76108
109+ // ! Sets classification mode
110+ void setClassificationMode ( ClassificationMode classificationMode );
111+
112+ // ! Returns the classification mode
113+ ClassificationMode classificationMode () const ;
114+
77115 /* * Sets whether the shader should not render values out of range.
78116 * @param clip set to true to clip values which are out of range.
79117 * @see clip()
0 commit comments