QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 "qgsrasterrenderer.h"
23 
24 class QgsRasterBlock;
25 class QgsRectangle;
26 class QgsRasterInterface;
27 
28 
34 class CORE_EXPORT QgsHillshadeRenderer : public QgsRasterRenderer
35 {
36  public:
44  QgsHillshadeRenderer( QgsRasterInterface* input, int band, double lightAzimuth, double lightAltitude );
45 
46  QgsHillshadeRenderer * clone() const override;
47 
54  static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input );
55 
56  void writeXML( QDomDocument& doc, QDomElement& parentElem ) const override;
57 
58  QgsRasterBlock *block( int bandNo, QgsRectangle const & extent, int width, int height ) override;
59  QgsRasterBlock *block2( int bandNo, QgsRectangle const & extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override;
60 
61  QList<int> usesBands() const override;
62 
65  int band() const { return mBand; }
66 
70  void setBand( int bandNo );
71 
76  double azimuth() const { return mLightAzimuth; }
77 
81  double altitude() const { return mLightAngle; }
82 
86  double zFactor() const { return mZFactor; }
87 
91  bool multiDirectional() const { return mMultiDirectional; }
92 
98  void setAzimuth( double azimuth ) { mLightAzimuth = azimuth; }
99 
105  void setAltitude( double altitude ) { mLightAngle = altitude; }
106 
112  void setZFactor( double zfactor ) { mZFactor = zfactor; }
113 
118  void setMultiDirectional( bool isMultiDirectional ) { mMultiDirectional = isMultiDirectional; }
119 
120  private:
121  int mBand;
122  double mZFactor;
123  double mLightAngle;
124  double mLightAzimuth;
125  bool mMultiDirectional;
126 
128  double calcFirstDerX( double x11, double x21, double x31, double x12, double x22, double x32, double x13, double x23, double x33 , double cellsize );
129 
131  double calcFirstDerY( double x11, double x21, double x31, double x12, double x22, double x32, double x13, double x23, double x33 , double cellsize );
132 };
133 
134 #endif // QGSHILLSHADERENDERER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:35
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.
virtual QgsRasterBlock * block2(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)
Read block of data using given extent and size.
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.
virtual void writeXML(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
A renderer for generating live hillshade models.
void setAzimuth(double azimuth)
Set the azimuth of the light source.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)=0
Read block of data using given extent and size.
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.
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.