QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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