QGIS API Documentation  2.99.0-Master (08c2e66)
qgssinglebandpseudocolorrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssinglebandpseudocolorrenderer.h
3  ----------------------------------
4  begin : January 2012
5  copyright : (C) 2012 by Marco Hugentobler
6  email : marco at sourcepole dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSSINGLEBANDPSEUDOCOLORRENDERER_H
19 #define QGSSINGLEBANDPSEUDOCOLORRENDERER_H
20 
21 #include "qgis_core.h"
22 #include "qgscolorramp.h"
23 #include "qgscolorrampshader.h"
24 #include "qgsrasterrenderer.h"
25 #include "qgsrectangle.h"
26 
27 class QDomElement;
28 class QgsRasterShader;
29 
34 {
35 
36  public:
37 
39  QgsSingleBandPseudoColorRenderer( QgsRasterInterface* input, int band = -1, QgsRasterShader* shader = nullptr );
41 
46 
47  QgsSingleBandPseudoColorRenderer * clone() const override;
48 
49  static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );
50 
51  QgsRasterBlock* block( int bandNo, const QgsRectangle & extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override;
52 
54  void setShader( QgsRasterShader* shader );
55 
57  QgsRasterShader* shader() { return mShader; }
58 
60  const QgsRasterShader* shader() const { return mShader; }
61 
70  void createShader( QgsColorRamp* colorRamp = nullptr, QgsColorRampShader::Type colorRampType = QgsColorRampShader::Interpolated, QgsColorRampShader::ClassificationMode classificationMode = QgsColorRampShader::Continuous, int classes = 0, bool clip = false, const QgsRectangle& extent = QgsRectangle() );
71 
72  void writeXml( QDomDocument& doc, QDomElement& parentElem ) const override;
73 
74  void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const override;
75 
76  QList<int> usesBands() const override;
77 
81  int band() const { return mBand; }
82 
87  void setBand( int bandNo );
88 
89  double classificationMin() const { return mClassificationMin; }
90  double classificationMax() const { return mClassificationMax; }
91  void setClassificationMin( double min );
92  void setClassificationMax( double max );
93 
94  private:
95 
96  QgsRasterShader* mShader = nullptr;
97  int mBand;
98 
99  // Minimum and maximum values used for automatic classification, these
100  // values are not used by renderer in rendering process
101  double mClassificationMin;
102  double mClassificationMax;
103 
104 };
105 
106 #endif // QGSSINGLEBANDPSEUDOCOLORRENDERER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:36
Interface for all raster shaders.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
Abstract base class for color ramps.
Definition: qgscolorramp.h:30
QgsRasterShader * shader()
Returns the raster shader.
Type
Supported methods for color interpolation.
Raster data container.
int band() const
Returns the band used by the renderer.
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Raster renderer pipe for single band pseudocolor.
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:452
Base class for processing filters like renderers, reprojector, resampler etc.
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:437
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Get symbology items if provided by renderer.
const QgsRasterRenderer & operator=(const QgsRasterRenderer &)=delete
QgsRasterRenderer cannot be copied. Use clone() instead.
Uses breaks from color palette.
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
Interpolates the color between two class breaks linearly.
ClassificationMode
Classification modes used to create the color ramp shader.
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override=0
Read block of data using given extent and size.