QGIS API Documentation  2.99.0-Master (8ec3eaf)
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 "qgsrasterinterface.h"
24 
25 class QDomElement;
26 
27 class QPainter;
29 
33 class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
34 {
35 
36  Q_DECLARE_TR_FUNCTIONS( QgsRasterRenderer );
37 
38  public:
39  // Origin of min / max values
41  {
42  MinMaxUnknown = 0,
43  MinMaxUser = 1, // entered by user
44  // method
45  MinMaxMinMax = 1 << 1,
46  MinMaxCumulativeCut = 1 << 2,
47  MinMaxStdDev = 1 << 3,
48  // Extent
49  MinMaxFullExtent = 1 << 4,
50  MinMaxSubExtent = 1 << 5,
51  // Precision
52  MinMaxEstimated = 1 << 6,
53  MinMaxExact = 1 << 7
54  };
55 
56  static const QRgb NODATA_COLOR;
57 
58  QgsRasterRenderer( QgsRasterInterface* input = nullptr, const QString& type = "" );
59  virtual ~QgsRasterRenderer();
60 
61  QgsRasterRenderer * clone() const override = 0;
62 
63  virtual int bandCount() const override;
64 
65  virtual Qgis::DataType dataType( int bandNo ) const override;
66 
67  virtual QString type() const { return mType; }
68 
69  virtual bool setInput( QgsRasterInterface* input ) override;
70 
71  virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override = 0;
72 
73  bool usesTransparency() const;
74 
75  void setOpacity( double opacity ) { mOpacity = opacity; }
76  double opacity() const { return mOpacity; }
77 
78  void setRasterTransparency( QgsRasterTransparency* t );
79  const QgsRasterTransparency* rasterTransparency() const { return mRasterTransparency; }
80 
81  void setAlphaBand( int band ) { mAlphaBand = band; }
82  int alphaBand() const { return mAlphaBand; }
83 
85  virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }
86 
88  void readXml( const QDomElement& rendererElem ) override;
89 
93  void copyCommonProperties( const QgsRasterRenderer* other );
94 
96  virtual QList<int> usesBands() const { return QList<int>(); }
97 
98  static QString minMaxOriginName( int theOrigin );
99  static QString minMaxOriginLabel( int theOrigin );
100  static int minMaxOriginFromName( const QString& theName );
101 
102  protected:
103 
105  void _writeXml( QDomDocument& doc, QDomElement& rasterRendererElem ) const;
106 
107  QString mType;
108 
110  double mOpacity;
113 
117 
118  private:
119 
121  const QgsRasterRenderer& operator=( const QgsRasterRenderer& );
122 };
123 
124 #endif // QGSRASTERRENDERER_H
virtual int bandCount() const =0
Get number of bands.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual void readXml(const QDomElement &filterElem)
Sets base class members from xml. Usually called from create() methods of subclasses.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
double opacity() const
virtual QString type() const
DataType
Raster data types.
Definition: qgis.h:60
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
const QgsRasterTransparency * rasterTransparency() const
QgsRasterTransparency * mRasterTransparency
Raster transparency per color or value. Overwrites global alpha value.
static const QRgb NODATA_COLOR
Raster data container.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)=0
Read block of data using given extent and size.
int mAlphaBand
Read alpha value from band.
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.
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.
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.