QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsrasterrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterrenderer.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 QGSRASTERRENDERER_H
19 #define QGSRASTERRENDERER_H
20 
21 #include <QPair>
22 
23 #include "qgsrasterdataprovider.h"
24 #include "qgsrasterinterface.h"
25 
26 class QDomElement;
27 
28 class QPainter;
30 
34 class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
35 {
36 
37  Q_DECLARE_TR_FUNCTIONS( QgsRasterRenderer );
38 
39  public:
40  // Origin of min / max values
42  {
43  MinMaxUnknown = 0,
44  MinMaxUser = 1, // entered by user
45  // method
46  MinMaxMinMax = 1 << 1,
47  MinMaxCumulativeCut = 1 << 2,
48  MinMaxStdDev = 1 << 3,
49  // Extent
50  MinMaxFullExtent = 1 << 4,
51  MinMaxSubExtent = 1 << 5,
52  // Precision
53  MinMaxEstimated = 1 << 6,
54  MinMaxExact = 1 << 7
55  };
56 
57  static const QRgb NODATA_COLOR;
58 
59  QgsRasterRenderer( QgsRasterInterface* input = nullptr, const QString& type = "" );
60  virtual ~QgsRasterRenderer();
61 
62  QgsRasterRenderer * clone() const override = 0;
63 
64  virtual int bandCount() const override;
65 
66  virtual QGis::DataType dataType( int bandNo ) const override;
67 
68  virtual QString type() const { return mType; }
69 
70  virtual bool setInput( QgsRasterInterface* input ) override;
71 
72  bool usesTransparency() const;
73 
74  void setOpacity( double opacity ) { mOpacity = opacity; }
75  double opacity() const { return mOpacity; }
76 
77  void setRasterTransparency( QgsRasterTransparency* t );
78  const QgsRasterTransparency* rasterTransparency() const { return mRasterTransparency; }
79 
80  void setAlphaBand( int band ) { mAlphaBand = band; }
81  int alphaBand() const { return mAlphaBand; }
82 
84  virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }
85 
87  void readXML( const QDomElement& rendererElem ) override;
88 
92  void copyCommonProperties( const QgsRasterRenderer* other );
93 
95  virtual QList<int> usesBands() const { return QList<int>(); }
96 
97  static QString minMaxOriginName( int theOrigin );
98  static QString minMaxOriginLabel( int theOrigin );
99  static int minMaxOriginFromName( const QString& theName );
100 
101  protected:
102 
104  void _writeXML( QDomDocument& doc, QDomElement& rasterRendererElem ) const;
105 
107 
109  double mOpacity;
115 
116  private:
117 
119  const QgsRasterRenderer& operator=( const QgsRasterRenderer& );
120 };
121 
122 #endif // QGSRASTERRENDERER_H
virtual int bandCount() const =0
Get number of bands.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
double opacity() const
virtual void readXML(const QDomElement &filterElem)
Sets base class members from xml.
virtual QString type() const
const QgsRasterTransparency * rasterTransparency() const
QgsRasterTransparency * mRasterTransparency
Raster transparency per color or value.
static const QRgb NODATA_COLOR
int mAlphaBand
Read alpha value from band.
virtual QGis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
void setAlphaBand(int band)
Base class for processing filters like renderers, reprojector, resampler etc.
virtual bool setInput(QgsRasterInterface *input)
Set input.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
DataType
Raster data types.
Definition: qgis.h:133
double mOpacity
Global alpha value (0-1)
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
void setOpacity(double opacity)
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Get symbology items if provided by renderer.
Raster renderer pipe that applies colors to a raster.