QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgis_sip.h"
23 #include "qgscolorramp.h"
24 #include "qgscolorrampshader.h"
25 #include "qgsrasterrenderer.h"
26 #include "qgsrectangle.h"
27 
28 class QDomElement;
29 class QgsRasterShader;
30 
36 {
37 
38  public:
39 
41  QgsSingleBandPseudoColorRenderer( QgsRasterInterface *input, int band = -1, QgsRasterShader *shader SIP_TRANSFER = nullptr );
42 
47 
49 
50  static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input ) SIP_FACTORY;
51 
52  QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback = nullptr ) override SIP_FACTORY;
53 
55  void setShader( QgsRasterShader *shader SIP_TRANSFER );
56 
58  QgsRasterShader *shader() { return mShader.get(); }
59 
61  const QgsRasterShader *shader() const SIP_PYNAME( constShader ) { return mShader.get(); }
62 
72  void createShader( QgsColorRamp *colorRamp SIP_TRANSFER = nullptr,
75  int classes = 0,
76  bool clip = false,
77  const QgsRectangle &extent = QgsRectangle() );
78 
79  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const override;
80  QList< QPair< QString, QColor > > legendSymbologyItems() const override;
81  QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) SIP_FACTORY override;
82  QList<int> usesBands() const override;
83  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props = QVariantMap() ) const override;
84  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
85 
90  int band() const { return mBand; }
91 
97  void setBand( int bandNo );
98 
99  double classificationMin() const { return mClassificationMin; }
100  double classificationMax() const { return mClassificationMax; }
101  void setClassificationMin( double min );
102  void setClassificationMax( double max );
103 
104  private:
105 #ifdef SIP_RUN
108 #endif
109 
110  std::unique_ptr< QgsRasterShader > mShader;
111  int mBand;
112 
113  // Minimum and maximum values used for automatic classification, these
114  // values are not used by renderer in rendering process
115  double mClassificationMin;
116  double mClassificationMax;
117 
118 };
119 
120 #endif // QGSSINGLEBANDPSEUDOCOLORRENDERER_H
SIP_PYNAME
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81
QgsColorRamp
Abstract base class for color ramps.
Definition: qgscolorramp.h:29
QgsRasterRenderer::block
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.
QgsRasterRenderer::legendSymbologyItems
virtual QList< QPair< QString, QColor > > legendSymbologyItems() const
Returns symbology items if provided by renderer.
Definition: qgsrasterrenderer.cpp:105
QgsSingleBandPseudoColorRenderer::shader
const QgsRasterShader * shader() const
Definition: qgssinglebandpseudocolorrenderer.h:61
QgsRasterInterface::writeXml
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Definition: qgsrasterinterface.h:494
qgsrectangle.h
QgsRasterRenderer::accept
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Definition: qgsrasterrenderer.cpp:223
QgsSingleBandPseudoColorRenderer::classificationMin
double classificationMin() const
Definition: qgssinglebandpseudocolorrenderer.h:99
qgscolorrampshader.h
QgsStyleEntityVisitorInterface
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
Definition: qgsstyleentityvisitor.h:33
qgsrasterrenderer.h
QgsSingleBandPseudoColorRenderer::band
int band() const
Returns the band used by the renderer.
Definition: qgssinglebandpseudocolorrenderer.h:90
QgsRasterRenderer::usesBands
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
Definition: qgsrasterrenderer.h:151
QgsColorRampShader::Type
Type
Supported methods for color interpolation.
Definition: qgscolorrampshader.h:48
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSingleBandPseudoColorRenderer::classificationMax
double classificationMax() const
Definition: qgssinglebandpseudocolorrenderer.h:100
QgsColorRampShader::Continuous
@ Continuous
Uses breaks from color palette.
Definition: qgscolorrampshader.h:58
QgsRasterRenderer
Raster renderer pipe that applies colors to a raster.
Definition: qgsrasterrenderer.h:40
qgscolorramp.h
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:43
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsRasterRenderer::toSld
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
Used from subclasses to create SLD Rule elements following SLD v1.0 specs.
Definition: qgsrasterrenderer.cpp:209
QgsRasterRenderer::clone
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
QgsColorRampShader::ClassificationMode
ClassificationMode
Classification modes used to create the color ramp shader.
Definition: qgscolorrampshader.h:56
QgsRasterInterface
Base class for processing filters like renderers, reprojector, resampler etc.
Definition: qgsrasterinterface.h:135
QgsRasterBlockFeedback
Feedback object tailored for raster block reading.
Definition: qgsrasterinterface.h:41
QgsSingleBandPseudoColorRenderer
Raster renderer pipe for single band pseudocolor.
Definition: qgssinglebandpseudocolorrenderer.h:35
QgsRasterRenderer::operator=
const QgsRasterRenderer & operator=(const QgsRasterRenderer &)=delete
QgsRasterRenderer cannot be copied. Use clone() instead.
QgsRasterShader
Interface for all raster shaders.
Definition: qgsrastershader.h:35
QgsSingleBandPseudoColorRenderer::shader
QgsRasterShader * shader()
Returns the raster shader.
Definition: qgssinglebandpseudocolorrenderer.h:58
QgsColorRampShader::Interpolated
@ Interpolated
Interpolates the color between two class breaks linearly.
Definition: qgscolorrampshader.h:50
QgsRasterRenderer::createLegendNodes
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer)
Creates a set of legend nodes representing the renderer.
Definition: qgsrasterrenderer.cpp:110
QgsRasterBlock
Raster data container.
Definition: qgsrasterblock.h:36