QGIS API Documentation  2.15.0-Master (02a0ebe)
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  virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) override = 0;
73 
74  bool usesTransparency() const;
75 
76  void setOpacity( double opacity ) { mOpacity = opacity; }
77  double opacity() const { return mOpacity; }
78 
79  void setRasterTransparency( QgsRasterTransparency* t );
80  const QgsRasterTransparency* rasterTransparency() const { return mRasterTransparency; }
81 
82  void setAlphaBand( int band ) { mAlphaBand = band; }
83  int alphaBand() const { return mAlphaBand; }
84 
86  virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }
87 
89  void readXML( const QDomElement& rendererElem ) override;
90 
92  virtual QList<int> usesBands() const { return QList<int>(); }
93 
94  static QString minMaxOriginName( int theOrigin );
95  static QString minMaxOriginLabel( int theOrigin );
96  static int minMaxOriginFromName( const QString& theName );
97 
98  protected:
99 
101  void _writeXML( QDomDocument& doc, QDomElement& rasterRendererElem ) const;
102 
104 
106  double mOpacity;
112 
113  private:
114 
116  const QgsRasterRenderer& operator=( const QgsRasterRenderer& );
117 };
118 
119 #endif // QGSRASTERRENDERER_H
virtual int bandCount() const =0
Get number of bands.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
virtual void readXML(const QDomElement &filterElem)
Sets base class members from xml.
double opacity() const
const QgsRasterTransparency * rasterTransparency() const
QgsRasterTransparency * mRasterTransparency
Raster transparency per color or value.
static const QRgb NODATA_COLOR
Raster data container.
int alphaBand() const
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 void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Get symbology items if provided by renderer.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
virtual QString type() const
DataType
Raster data types.
Definition: qgis.h:133
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)=0
Read block of data using given extent and size.
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)
Raster renderer pipe that applies colors to a raster.