34    renderEdl( elevation, image, context );
 
   36  if ( mRenderHillshading )
 
   37    renderHillshading( elevation, image, context );
 
 
   62  mRenderHillshading = active;
 
 
   67  return mRenderHillshading;
 
 
   72  return mHillshadingZFactor;
 
 
   77  mHillshadingZFactor = zFactor;
 
 
   82  return mHillshadingMultiDir;
 
 
   87  mHillshadingMultiDir = multiDirectional;
 
 
   92  return mLightAltitude;
 
 
  102  return mLightAzimuth;
 
 
  112  elem.setAttribute( QStringLiteral( 
"is-active" ), mIsActive ? 1 : 0 );
 
  114  elem.setAttribute( QStringLiteral( 
"combined-method" ), 
static_cast<int>( mCombinedElevationMethod ) );
 
  116  elem.setAttribute( QStringLiteral( 
"edl-is-active" ), mRenderEdl ? 1 : 0 );
 
  117  elem.setAttribute( QStringLiteral( 
"edl-strength" ),  
qgsDoubleToString( mEyeDomeLightingStrength ) );
 
  118  elem.setAttribute( QStringLiteral( 
"edl-distance" ),  
qgsDoubleToString( mEyeDomeLightingDistance ) );
 
  119  elem.setAttribute( QStringLiteral( 
"edl-distance-unit" ), 
static_cast<int>( mEyeDomeLightingDistanceUnit ) );
 
  121  elem.setAttribute( QStringLiteral( 
"hillshading-is-active" ), mRenderHillshading ? 1 : 0 );
 
  122  elem.setAttribute( QStringLiteral( 
"hillshading-z-factor" ), 
qgsDoubleToString( mHillshadingZFactor ) );
 
  123  elem.setAttribute( QStringLiteral( 
"hillshading-is-multidirectional" ), mHillshadingMultiDir ? 1 : 0 );
 
  125  elem.setAttribute( QStringLiteral( 
"light-altitude" ),  
qgsDoubleToString( mLightAltitude ) );
 
  126  elem.setAttribute( QStringLiteral( 
"light-azimuth" ),  
qgsDoubleToString( mLightAzimuth ) );
 
 
  131  if ( element.hasAttribute( QStringLiteral( 
"is-active" ) ) )
 
  132    mIsActive = element.attribute( QStringLiteral( 
"is-active" ) ).toInt() == 1;
 
  134  if ( element.hasAttribute( QStringLiteral( 
"combined-method" ) ) )
 
  137  if ( element.hasAttribute( QStringLiteral( 
"edl-is-active" ) ) )
 
  138    mRenderEdl = element.attribute( QStringLiteral( 
"edl-is-active" ) ).toInt() == 1;
 
  140  if ( element.hasAttribute( QStringLiteral( 
"edl-strength" ) ) )
 
  141    mEyeDomeLightingStrength = element.attribute( QStringLiteral( 
"edl-strength" ) ).toDouble();
 
  143  if ( element.hasAttribute( QStringLiteral( 
"edl-distance" ) ) )
 
  144    mEyeDomeLightingDistance = element.attribute( QStringLiteral( 
"edl-distance" ) ).toDouble();
 
  146  if ( element.hasAttribute( QStringLiteral( 
"edl-distance-unit" ) ) )
 
  147    mEyeDomeLightingDistanceUnit = 
static_cast<Qgis::RenderUnit>( element.attribute( QStringLiteral( 
"edl-distance-unit" ) ).toInt() );
 
  149  if ( element.hasAttribute( QStringLiteral( 
"hillshading-is-active" ) ) )
 
  150    mRenderHillshading = element.attribute( QStringLiteral( 
"hillshading-is-active" ) ).toInt() == 1;
 
  152  if ( element.hasAttribute( QStringLiteral( 
"hillshading-z-factor" ) ) )
 
  153    mHillshadingZFactor = element.attribute( QStringLiteral( 
"hillshading-z-factor" ) ).toDouble();
 
  155  if ( element.hasAttribute( QStringLiteral( 
"hillshading-is-multidirectional" ) ) )
 
  156    mHillshadingMultiDir = element.attribute( QStringLiteral( 
"hillshading-is-multidirectional" ) ).toInt() == 1;
 
  158  if ( element.hasAttribute( QStringLiteral( 
"light-altitude" ) ) )
 
  159    mLightAltitude = element.attribute( QStringLiteral( 
"light-altitude" ) ).toDouble();
 
  161  if ( element.hasAttribute( QStringLiteral( 
"light-azimuth" ) ) )
 
  162    mLightAzimuth = element.attribute( QStringLiteral( 
"light-azimuth" ) ).toDouble();
 
 
  167  return mCombinedElevationMethod;
 
 
  172  mCombinedElevationMethod = newCombinedElevationMethod;
 
 
  177  return mEyeDomeLightingDistanceUnit;
 
 
  182  mEyeDomeLightingDistanceUnit = newEyeDomeLightingDistanceUnit;
 
 
  187  return mEyeDomeLightingDistance;
 
 
  192  mEyeDomeLightingDistance = distance;
 
 
  197  return mEyeDomeLightingStrength;
 
 
  202  mEyeDomeLightingStrength = strength;
 
 
  207  double strength = mEyeDomeLightingStrength;
 
  208  double distanceDouble = context.
convertToPainterUnits( mEyeDomeLightingDistance, mEyeDomeLightingDistanceUnit );
 
  209  int distance = 
static_cast<int>( std::round( distanceDouble ) );
 
  224    effPixelSize = pixelSize;
 
  226  elevation.
applyHillshading( image, mHillshadingMultiDir, mLightAltitude, mLightAzimuth, mHillshadingZFactor, effPixelSize, effPixelSize );
 
DistanceUnit
Units of distance.
 
@ Unknown
Unknown distance unit.
 
ElevationMapCombineMethod
Methods used to select the elevation when two elevation maps are combined.
 
RenderUnit
Rendering size units.
 
Qgis::DistanceUnit lengthUnits() const
Returns the units of distance for length calculations made by this object.
 
Stores a digital elevation model in a raster image which may get updated as a part of the map layer r...
 
void applyEyeDomeLighting(QImage &image, int distance, float strength, float rendererScale) const
Applies eye dome lighting effect to the given image.
 
QImage rawElevationImage() const
Returns raw elevation image with elevations encoded as color values.
 
void applyHillshading(QImage &image, bool multiDirectional, double altitude, double azimuth, double zFactor, double cellSizeX, double cellSizeY) const
Applies hill shading effect to the given image.
 
Qgis::ElevationMapCombineMethod combinedElevationMethod() const
Returns the method used when conbining different elevation sources.
 
bool isActiveHillshading() const
Returns whether the hillshading is active.
 
void setCombinedElevationMethod(Qgis::ElevationMapCombineMethod method)
Sets the method used when conbining different elevation sources.
 
bool isActive() const
Returns whether this shading renderer is active.
 
void setActive(bool active)
Sets whether this shading renderer is active.
 
double hillshadingZFactor() const
Returns the z factor used by the hill shading method.
 
QgsElevationShadingRenderer()
 
double eyeDomeLightingStrength() const
Returns the strength of the eye dome lighting method.
 
void setLightAzimuth(double lightAzimuth)
Sets the azimuth of the light (degree) that can be used by some methods (e.g.
 
double lightAltitude() const
Returns the altitude of the light (degree) that can be used by some methods (e.g.
 
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes configuration on a DOM element.
 
void setHillshadingMultidirectional(bool multiDirectional)
Sets whether the hill shading method is multidirectional.
 
double eyeDomeLightingDistance() const
Returns the distance of the eye dome lighting method, that is the distance where the effect is apply ...
 
void setLightAltitude(double lightAltitude)
Sets the altitude of the light (degree) that can be used by some methods (e.g.
 
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads configuration from a DOM element.
 
void renderShading(const QgsElevationMap &elevation, QImage &image, const QgsRenderContext &context) const
Render shading on image condidering the elevation map elevation and the renderer context context If e...
 
void setEyeDomeLightingStrength(double strength)
Sets the strength of the eye dome lighting method.
 
void setEyeDomeLightingDistanceUnit(Qgis::RenderUnit unit)
Sets the unit of the distance of the eye dome lighting method set by setEyeDomeLightingDistance().
 
void setActiveHillshading(bool active)
Sets active the hillshading.
 
bool isHillshadingMultidirectional() const
Returns whether the hill shading method is multidirectional.
 
void setHillshadingZFactor(double zFactor)
Sets the z factor used by the hill shading method.
 
bool isActiveEyeDomeLighting() const
Returns whether eye-dome lighting shading method is active.
 
void setEyeDomeLightingDistance(double distance)
Sets the distance of the eye dome lighting method, that is the distance where the effect is apply fro...
 
void setActiveEyeDomeLighting(bool active)
Sets active the eye-dome lighting shading method.
 
double lightAzimuth() const
Returns the azimuth of the light (degree) that can be used by some methods (e.g.
 
Qgis::RenderUnit eyeDomeLightingDistanceUnit() const
Returns the unit of the distance of the eye dome lighting method returned by eyeDomeLightingDistance(...
 
double mapUnitsPerPixel() const
Returns the current map units per pixel.
 
A container for the context for various read/write operations on objects.
 
Contains information about the context of a rendering operation.
 
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
 
const QgsDistanceArea & distanceArea() const
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
 
double rendererScale() const
Returns the renderer map scale.
 
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
 
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
 
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.