QGIS API Documentation  3.6.0-Noosa (5873452)
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 "qgis_sip.h"
23 #include <QPair>
24 
25 #include "qgsrasterinterface.h"
26 #include "qgsrasterminmaxorigin.h"
27 
28 class QDomElement;
29 
30 class QPainter;
32 
37 class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
38 {
39 
40  Q_DECLARE_TR_FUNCTIONS( QgsRasterRenderer )
41 
42  public:
43 
44  static const QRgb NODATA_COLOR;
45 
49  QgsRasterRenderer( QgsRasterInterface *input = nullptr, const QString &type = QString() );
50  ~QgsRasterRenderer() override;
51 
53  QgsRasterRenderer( const QgsRasterRenderer & ) = delete;
55  const QgsRasterRenderer &operator=( const QgsRasterRenderer & ) = delete;
56 
57  QgsRasterRenderer *clone() const override = 0 SIP_FACTORY;
58 
59  int bandCount() const override;
60 
61  Qgis::DataType dataType( int bandNo ) const override;
62 
63  virtual QString type() const { return mType; }
64 
65  bool setInput( QgsRasterInterface *input ) override;
66 
67  QgsRasterBlock *block( int bandNo,
68  const QgsRectangle &extent,
69  int width,
70  int height,
71  QgsRasterBlockFeedback *feedback = nullptr ) override = 0 SIP_FACTORY;
72 
73  bool usesTransparency() const;
74 
80  void setOpacity( double opacity ) { mOpacity = opacity; }
81 
87  double opacity() const { return mOpacity; }
88 
89  void setRasterTransparency( QgsRasterTransparency *t SIP_TRANSFER );
90  const QgsRasterTransparency *rasterTransparency() const { return mRasterTransparency; }
91 
92  void setAlphaBand( int band ) { mAlphaBand = band; }
93  int alphaBand() const { return mAlphaBand; }
94 
96  virtual void legendSymbologyItems( QList< QPair< QString, QColor > > &symbolItems SIP_OUT ) const { Q_UNUSED( symbolItems ); }
97 
99  void readXml( const QDomElement &rendererElem ) override;
100 
105  void copyCommonProperties( const QgsRasterRenderer *other, bool copyMinMaxOrigin = true );
106 
108  virtual QList<int> usesBands() const { return QList<int>(); }
109 
111  const QgsRasterMinMaxOrigin &minMaxOrigin() const { return mMinMaxOrigin; }
112 
114  void setMinMaxOrigin( const QgsRasterMinMaxOrigin &origin ) { mMinMaxOrigin = origin; }
115 
119  virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props = QgsStringMap() ) const;
120 
121  protected:
122 
124  void _writeXml( QDomDocument &doc, QDomElement &rasterRendererElem ) const;
125 
126  QString mType;
127 
129  double mOpacity = 1.0;
131  QgsRasterTransparency *mRasterTransparency = nullptr;
132 
136  int mAlphaBand = -1;
137 
140 
141  private:
142 #ifdef SIP_RUN
144  const QgsRasterRenderer &operator=( const QgsRasterRenderer & );
145 #endif
146 
147 };
148 
149 #endif // QGSRASTERRENDERER_H
virtual int bandCount() const =0
Gets number of bands.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
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
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1...
virtual QString type() const
DataType
Raster data types.
Definition: qgis.h:79
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.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:587
const QgsRasterTransparency * rasterTransparency() const
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.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:69
void setAlphaBand(int band)
Base class for processing filters like renderers, reprojector, resampler etc.
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
virtual bool setInput(QgsRasterInterface *input)
Set input.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
#define SIP_OUT
Definition: qgis_sip.h:51
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1...
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Gets symbology items if provided by renderer.
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.