QGIS API Documentation  2.99.0-Master (7fe5405)
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 "qgis_core.h"
22 #include <QPair>
23 
24 #include "qgsrasterinterface.h"
25 #include "qgsrasterminmaxorigin.h"
26 
27 class QDomElement;
28 
29 class QPainter;
31 
35 class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
36 {
37 
38  Q_DECLARE_TR_FUNCTIONS( QgsRasterRenderer );
39 
40  public:
41 
42  static const QRgb NODATA_COLOR;
43 
44  QgsRasterRenderer( QgsRasterInterface* input = nullptr, const QString& type = "" );
45  virtual ~QgsRasterRenderer();
46 
48  QgsRasterRenderer( const QgsRasterRenderer& ) = delete;
50  const QgsRasterRenderer& operator=( const QgsRasterRenderer& ) = delete;
51 
52  QgsRasterRenderer * clone() const override = 0;
53 
54  virtual int bandCount() const override;
55 
56  virtual Qgis::DataType dataType( int bandNo ) const override;
57 
58  virtual QString type() const { return mType; }
59 
60  virtual bool setInput( QgsRasterInterface* input ) override;
61 
62  virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override = 0;
63 
64  bool usesTransparency() const;
65 
66  void setOpacity( double opacity ) { mOpacity = opacity; }
67  double opacity() const { return mOpacity; }
68 
69  void setRasterTransparency( QgsRasterTransparency* t );
70  const QgsRasterTransparency* rasterTransparency() const { return mRasterTransparency; }
71 
72  void setAlphaBand( int band ) { mAlphaBand = band; }
73  int alphaBand() const { return mAlphaBand; }
74 
76  virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }
77 
79  void readXml( const QDomElement& rendererElem ) override;
80 
84  void copyCommonProperties( const QgsRasterRenderer* other, bool copyMinMaxOrigin = true );
85 
87  virtual QList<int> usesBands() const { return QList<int>(); }
88 
90  const QgsRasterMinMaxOrigin& minMaxOrigin() const { return mMinMaxOrigin; }
91 
93  void setMinMaxOrigin( const QgsRasterMinMaxOrigin& theOrigin ) { mMinMaxOrigin = theOrigin; }
94 
95  protected:
96 
98  void _writeXml( QDomDocument& doc, QDomElement& rasterRendererElem ) const;
99 
100  QString mType;
101 
103  double mOpacity;
106 
110 
113 
114 };
115 
116 #endif // QGSRASTERRENDERER_H
virtual int bandCount() const =0
Get number of bands.
A rectangle specified with double values.
Definition: qgsrectangle.h:36
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:61
QgsRasterMinMaxOrigin mMinMaxOrigin
Origin of min/max values.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &theOrigin)
Sets origin of min/max values.
const QgsRasterTransparency * rasterTransparency() const
QgsRasterTransparency * mRasterTransparency
Raster transparency per color or value. Overwrites global alpha value.
static const QRgb NODATA_COLOR
This class describes the origin of min/max values.
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.