QGIS API Documentation  3.2.0-Bonn (bc43194)
qgshillshaderenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshillshaderenderer.cpp
3  ---------------------------------
4  begin : May 2016
5  copyright : (C) 2016 by Nathan Woodrow
6  email : woodrow dot nathan at gmail dot com
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 QGSHILLSHADERENDERER_H
19 #define QGSHILLSHADERENDERER_H
20 
21 
22 #include "qgis_core.h"
23 #include "qgis.h"
24 #include "qgsrasterrenderer.h"
25 
26 class QgsRasterBlock;
27 class QgsRectangle;
28 class QgsRasterInterface;
29 
30 
36 class CORE_EXPORT QgsHillshadeRenderer : public QgsRasterRenderer
37 {
38  public:
39 
47  QgsHillshadeRenderer( QgsRasterInterface *input, int band, double lightAzimuth, double lightAltitude );
48 
49  QgsHillshadeRenderer *clone() const override SIP_FACTORY;
50 
57  static QgsRasterRenderer *create( const QDomElement &elem, QgsRasterInterface *input ) SIP_FACTORY;
58 
59  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const override;
60 
61  QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback = nullptr ) override;
62 
63  QList<int> usesBands() const override;
64 
68  int band() const { return mBand; }
69 
74  void setBand( int bandNo );
75 
80  double azimuth() const { return mLightAzimuth; }
81 
86  double altitude() const { return mLightAngle; }
87 
92  double zFactor() const { return mZFactor; }
93 
98  bool multiDirectional() const { return mMultiDirectional; }
99 
105  void setAzimuth( double azimuth ) { mLightAzimuth = azimuth; }
106 
112  void setAltitude( double altitude ) { mLightAngle = altitude; }
113 
119  void setZFactor( double zfactor ) { mZFactor = zfactor; }
120 
126  void setMultiDirectional( bool isMultiDirectional ) { mMultiDirectional = isMultiDirectional; }
127 
128  private:
129  int mBand;
130  double mZFactor;
131  double mLightAngle;
132  double mLightAzimuth;
133  bool mMultiDirectional;
134 
136  double calcFirstDerX( double x11, double x21, double x31, double x12, double x22, double x32, double x13, double x23, double x33, double cellsize );
137 
139  double calcFirstDerY( double x11, double x21, double x31, double x12, double x22, double x32, double x13, double x23, double x33, double cellsize );
140 };
141 
142 #endif // QGSHILLSHADERENDERER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:40
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override=0
Read block of data using given extent and size.
void setAltitude(double altitude)
Set the altitude of the light source.
void setMultiDirectional(bool isMultiDirectional)
Sets whether to render using a multi-directional hillshade algorithm.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
void setZFactor(double zfactor)
Set the Z scaling factor of the result image.
int band() const
Returns the band used by the renderer.
Raster data container.
bool multiDirectional() const
Returns true if the renderer is using multi-directional hillshading.
A renderer for generating live hillshade models.
void setAzimuth(double azimuth)
Set the azimuth of the light source.
#define SIP_FACTORY
Definition: qgis_sip.h:69
Base class for processing filters like renderers, reprojector, resampler etc.
double altitude() const
Returns the angle of the light source over the raster.
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
double zFactor() const
Returns the Z scaling factor.
double azimuth() const
Returns the direction of the light over the raster between 0-360.
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.