QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  public:
37  // Origin of min / max values
39  {
40  MinMaxUnknown = 0,
41  MinMaxUser = 1, // entered by user
42  // method
43  MinMaxMinMax = 1 << 1,
44  MinMaxCumulativeCut = 1 << 2,
45  MinMaxStdDev = 1 << 3,
46  // Extent
47  MinMaxFullExtent = 1 << 4,
48  MinMaxSubExtent = 1 << 5,
49  // Precision
50  MinMaxEstimated = 1 << 6,
51  MinMaxExact = 1 << 7
52  };
53 
54  static const QRgb NODATA_COLOR;
55 
56  QgsRasterRenderer( QgsRasterInterface* input = 0, const QString& type = "" );
57  virtual ~QgsRasterRenderer();
58 
59  QgsRasterInterface * clone() const = 0;
60 
61  virtual int bandCount() const;
62 
63  virtual QGis::DataType dataType( int bandNo ) const;
64 
65  virtual QString type() const { return mType; }
66 
67  virtual bool setInput( QgsRasterInterface* input );
68 
69  virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) = 0;
70 
71  bool usesTransparency() const;
72 
73  void setOpacity( double opacity ) { mOpacity = opacity; }
74  double opacity() const { return mOpacity; }
75 
76  void setRasterTransparency( QgsRasterTransparency* t );
77  const QgsRasterTransparency* rasterTransparency() const { return mRasterTransparency; }
78 
79  void setAlphaBand( int band ) { mAlphaBand = band; }
80  int alphaBand() const { return mAlphaBand; }
81 
83  virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }
84 
86  void readXML( const QDomElement& rendererElem );
87 
89  virtual QList<int> usesBands() const { return QList<int>(); }
90 
91  static QString minMaxOriginName( int theOrigin );
92  static QString minMaxOriginLabel( int theOrigin );
93  static int minMaxOriginFromName( QString theName );
94 
95  protected:
96 
98  void _writeXML( QDomDocument& doc, QDomElement& rasterRendererElem ) const;
99 
100  QString mType;
101 
103  double mOpacity;
109 };
110 
111 #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
DataType
Raster data types.
Definition: qgis.h:204
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
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.