QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 QgsStringMap &props = QgsStringMap() ) 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
QgsHillshadeRenderer::setAzimuth
void setAzimuth(double azimuth)
Set the azimuth of the light source.
Definition: qgshillshaderenderer.h:107
QgsRasterRenderer::block
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.
QgsHillshadeRenderer::setAltitude
void setAltitude(double altitude)
Set the altitude of the light source.
Definition: qgshillshaderenderer.h:114
QgsHillshadeRenderer
A renderer for generating live hillshade models.
Definition: qgshillshaderenderer.h:36
QgsRasterInterface::writeXml
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Definition: qgsrasterinterface.h:461
qgsrasterrenderer.h
QgsRasterRenderer::toSld
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const
Used from subclasses to create SLD Rule elements following SLD v1.0 specs.
Definition: qgsrasterrenderer.cpp:175
QgsHillshadeRenderer::setMultiDirectional
void setMultiDirectional(bool isMultiDirectional)
Sets whether to render using a multi-directional hillshade algorithm.
Definition: qgshillshaderenderer.h:128
QgsRasterRenderer::usesBands
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
Definition: qgsrasterrenderer.h:132
QgsRectangle
Definition: qgsrectangle.h:41
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsHillshadeRenderer::azimuth
double azimuth() const
Returns the direction of the light over the raster between 0-360.
Definition: qgshillshaderenderer.h:82
QgsHillshadeRenderer::multiDirectional
bool multiDirectional() const
Returns true if the renderer is using multi-directional hillshading.
Definition: qgshillshaderenderer.h:100
QgsRasterRenderer
Definition: qgsrasterrenderer.h:38
qgis_sip.h
QgsHillshadeRenderer::altitude
double altitude() const
Returns the angle of the light source over the raster.
Definition: qgshillshaderenderer.h:88
QgsHillshadeRenderer::band
int band() const
Returns the band used by the renderer.
Definition: qgshillshaderenderer.h:70
QgsRasterRenderer::clone
QgsRasterRenderer * clone() const override=0
Clone itself, create deep copy.
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:714
QgsRasterInterface
Definition: qgsrasterinterface.h:116
QgsRasterBlockFeedback
Definition: qgsrasterinterface.h:40
QgsHillshadeRenderer::setZFactor
void setZFactor(double zfactor)
Set the Z scaling factor of the result image.
Definition: qgshillshaderenderer.h:121
QgsHillshadeRenderer::zFactor
double zFactor() const
Returns the Z scaling factor.
Definition: qgshillshaderenderer.h:94
QgsRasterBlock
Definition: qgsrasterblock.h:36