QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgssinglebandgrayrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssinglebandgrayrenderer.h
3  ---------------------------
4  begin : December 2011
5  copyright : (C) 2011 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 QGSSINGLEBANDGRAYRENDERER_H
19 #define QGSSINGLEBANDGRAYRENDERER_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgsrasterrenderer.h"
25 
26 #include <memory>
27 
29 class QDomElement;
30 
36 {
37  public:
38  enum Gradient
39  {
41  WhiteToBlack
42  };
43 
44  QgsSingleBandGrayRenderer( QgsRasterInterface *input, int grayBand );
45 
50 
52 
53  static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input ) SIP_FACTORY;
54 
55  QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback = nullptr ) override SIP_FACTORY;
56 
57  int grayBand() const { return mGrayBand; }
58  void setGrayBand( int band ) { mGrayBand = band; }
59  const QgsContrastEnhancement *contrastEnhancement() const { return mContrastEnhancement.get(); }
61  void setContrastEnhancement( QgsContrastEnhancement *ce SIP_TRANSFER );
62 
63  void setGradient( Gradient gradient ) { mGradient = gradient; }
64  Gradient gradient() const { return mGradient; }
65 
66  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const override;
67 
68  QList< QPair< QString, QColor > > legendSymbologyItems() const override;
69  QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) SIP_FACTORY override;
70 
71  QList<int> usesBands() const override;
72 
73  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props = QVariantMap() ) const override;
74 
81  const QgsColorRampLegendNodeSettings *legendSettings() const;
82 
91  void setLegendSettings( QgsColorRampLegendNodeSettings *settings SIP_TRANSFER );
92 
93  private:
94 #ifdef SIP_RUN
97 #endif
98 
99  int mGrayBand;
100  Gradient mGradient;
101  std::unique_ptr< QgsContrastEnhancement > mContrastEnhancement;
102  std::unique_ptr< QgsColorRampLegendNodeSettings > mLegendSettings;
103 };
104 
105 #endif // QGSSINGLEBANDGRAYRENDERER_H
Settings for a color ramp legend node.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
Layer tree node points to a map layer.
Feedback object tailored for raster block reading.
Raster data container.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Raster renderer pipe that applies colors to a raster.
const QgsRasterRenderer & operator=(const QgsRasterRenderer &)=delete
QgsRasterRenderer cannot be copied. Use clone() instead.
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer)
Creates a set of legend nodes representing the renderer.
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.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
virtual QList< QPair< QString, QColor > > legendSymbologyItems() const
Returns symbology items if provided by renderer.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Raster renderer pipe for single band gray.
const QgsSingleBandGrayRenderer & operator=(const QgsSingleBandGrayRenderer &)=delete
QgsSingleBandGrayRenderer cannot be copied. Use clone() instead.
QgsSingleBandGrayRenderer(const QgsSingleBandGrayRenderer &)=delete
QgsSingleBandGrayRenderer cannot be copied. Use clone() instead.
const QgsContrastEnhancement * contrastEnhancement() const
void setGradient(Gradient gradient)
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76