QGIS API Documentation  master-59fd5e0
src/core/raster/qgsrasterrenderer.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgsrasterrenderer.h
00003                          -------------------
00004     begin                : December 2011
00005     copyright            : (C) 2011 by Marco Hugentobler
00006     email                : marco at sourcepole dot ch
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QGSRASTERRENDERER_H
00019 #define QGSRASTERRENDERER_H
00020 
00021 #include <QPair>
00022 
00023 #include "qgsrasterdataprovider.h"
00024 #include "qgsrasterinterface.h"
00025 
00026 class QDomElement;
00027 
00028 class QPainter;
00029 class QgsRasterTransparency;
00030 
00034 class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface
00035 {
00036   public:
00037     // Origin of min / max values
00038     enum MinMaxOrigin
00039     {
00040       MinMaxUnknown         = 0,
00041       MinMaxUser            = 1, // entered by user
00042       // method
00043       MinMaxMinMax          = 1 << 1,
00044       MinMaxCumulativeCut   = 1 << 2,
00045       MinMaxStdDev          = 1 << 3,
00046       // Extent
00047       MinMaxFullExtent      = 1 << 4,
00048       MinMaxSubExtent       = 1 << 5,
00049       // Precision
00050       MinMaxEstimated       = 1 << 6,
00051       MinMaxExact           = 1 << 7
00052     };
00053 
00054     static const QRgb NODATA_COLOR;
00055 
00056     QgsRasterRenderer( QgsRasterInterface* input = 0, const QString& type = "" );
00057     virtual ~QgsRasterRenderer();
00058 
00059     QgsRasterInterface * clone() const = 0;
00060 
00061     virtual int bandCount() const;
00062 
00063     virtual QGis::DataType dataType( int bandNo ) const;
00064 
00065     virtual QString type() const { return mType; }
00066 
00067     virtual bool setInput( QgsRasterInterface* input );
00068 
00069     virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) = 0;
00070 
00071     bool usesTransparency() const;
00072 
00073     void setOpacity( double opacity ) { mOpacity = opacity; }
00074     double opacity() const { return mOpacity; }
00075 
00076     void setRasterTransparency( QgsRasterTransparency* t );
00077     const QgsRasterTransparency* rasterTransparency() const { return mRasterTransparency; }
00078 
00079     void setAlphaBand( int band ) { mAlphaBand = band; }
00080     int alphaBand() const { return mAlphaBand; }
00081 
00083     virtual void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const { Q_UNUSED( symbolItems ); }
00084 
00086     void readXML( const QDomElement& rendererElem );
00087 
00089     virtual QList<int> usesBands() const { return QList<int>(); }
00090 
00091     static QString minMaxOriginName( int theOrigin );
00092     static QString minMaxOriginLabel( int theOrigin );
00093     static int minMaxOriginFromName( QString theName );
00094 
00095   protected:
00096 
00098     void _writeXML( QDomDocument& doc, QDomElement& rasterRendererElem ) const;
00099 
00100     QString mType;
00101 
00103     double mOpacity;
00105     QgsRasterTransparency* mRasterTransparency;
00108     int mAlphaBand;
00109 };
00110 
00111 #endif // QGSRASTERRENDERER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines