QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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_sip.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 SIP_FACTORY;
62 
63  QList<int> usesBands() const override;
64 
65  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props = QVariantMap() ) const override;
66 
70  int band() const { return mBand; }
71 
76  void setBand( int bandNo );
77 
82  double azimuth() const { return mLightAzimuth; }
83 
88  double altitude() const { return mLightAngle; }
89 
94  double zFactor() const { return mZFactor; }
95 
100  bool multiDirectional() const { return mMultiDirectional; }
101 
107  void setAzimuth( double azimuth ) { mLightAzimuth = azimuth; }
108 
114  void setAltitude( double altitude ) { mLightAngle = altitude; }
115 
121  void setZFactor( double zfactor ) { mZFactor = zfactor; }
122 
128  void setMultiDirectional( bool isMultiDirectional ) { mMultiDirectional = isMultiDirectional; }
129 
130  private:
131  int mBand;
132  double mZFactor;
133  double mLightAngle;
134  double mLightAzimuth;
135  bool mMultiDirectional;
136 
138  double calcFirstDerX( double x11, double x21, double x31, double x12, double x22, double x32, double x13, double x23, double x33, double cellsize );
139 
141  double calcFirstDerY( double x11, double x21, double x31, double x12, double x22, double x32, double x13, double x23, double x33, double cellsize );
142 };
143 
144 #endif // QGSHILLSHADERENDERER_H
A renderer for generating live hillshade models.
bool multiDirectional() const
Returns true if the renderer is using multi-directional hillshading.
void setZFactor(double zfactor)
Set the Z scaling factor of the result image.
double azimuth() const
Returns the direction of the light over the raster between 0-360.
int band() const
Returns the band used by the renderer.
void setAltitude(double altitude)
Set the altitude of the light source.
void setAzimuth(double azimuth)
Set the azimuth of the light source.
void setMultiDirectional(bool isMultiDirectional)
Sets whether to render using a multi-directional hillshade algorithm.
double altitude() const
Returns the angle of the light source over the raster.
double zFactor() const
Returns the Z scaling factor.
Feedback object tailored for raster block reading.
Raster data container.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Raster renderer pipe that applies colors to a raster.
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.
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
Used from subclasses to create SLD Rule elements following SLD v1.0 specs.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define SIP_FACTORY
Definition: qgis_sip.h:76