33 return QStringLiteral(
"dem" );
38 if ( element.hasAttribute( QStringLiteral(
"layer" ) ) )
40 mLayer =
QgsMapLayerRef( element.attribute( QStringLiteral(
"layer" ) ) );
41 mResolution = element.attribute( QStringLiteral(
"resolution" ) ).toInt();
42 mSkirtHeight = element.attribute( QStringLiteral(
"skirt-height" ) ).toDouble();
47 const QDomElement elemTerrainGenerator = element.firstChildElement( QStringLiteral(
"generator" ) );
48 mLayer =
QgsMapLayerRef( elemTerrainGenerator.attribute( QStringLiteral(
"layer" ) ) );
49 mResolution = elemTerrainGenerator.attribute( QStringLiteral(
"resolution" ) ).toInt();
50 mSkirtHeight = elemTerrainGenerator.attribute( QStringLiteral(
"skirt-height" ) ).toDouble();
58 element.setAttribute( QStringLiteral(
"layer" ), mLayer.
layerId );
59 element.setAttribute( QStringLiteral(
"resolution" ), mResolution );
60 element.setAttribute( QStringLiteral(
"skirt-height" ), mSkirtHeight );
78 return mResolution == otherTerrain->mResolution
85 std::unique_ptr<QgsDemTerrainGenerator> generator = std::make_unique<QgsDemTerrainGenerator>();
87 generator->setExtent( context.
extent() );
88 generator->setLayer(
layer() );
89 generator->setResolution( mResolution );
90 generator->setSkirtHeight(
static_cast<float>( mSkirtHeight ) );
101 return qobject_cast<QgsRasterLayer *>( mLayer.
layer.data() );
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system used in the 3D scene.
QgsRectangle extent() const
Returns the 3D scene's 2D extent in the 3D scene's CRS.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
void writeCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Writes common properties from the base class into an XML element.
bool equalsCommon(const QgsAbstractTerrainSettings *other) const
Returns true if common base class settings from other match this object.
void readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common properties from the base class from the given DOM element.
QgsDemTerrainSettings * clone() const final
Returns a copy of the terrain settings.
bool equals(const QgsAbstractTerrainSettings *other) const final
Returns true if this settings is exactly equal to another other settings.
QString type() const final
Returns the unique type name for the terrain generator.
static QgsAbstractTerrainSettings * create()
Creates a new instance of a QgsDemTerrainSettings object.
QgsRasterLayer * layer() const
Returns the raster layer with elevation model to be used for terrain generation.
void resolveReferences(const QgsProject *project) final
After reading settings from XML, resolves references to any layers in a project that have been read a...
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const final
Writes settings to a DOM element.
void setLayer(QgsRasterLayer *layer)
Sets the raster layer with elevation model to be used for terrain generation.
void readXml(const QDomElement &element, const QgsReadWriteContext &context) final
Reads settings from a DOM element.
std::unique_ptr< QgsTerrainGenerator > createTerrainGenerator(const Qgs3DRenderContext &context) const override
Creates a new instance of a terrain generator which matches the terrain settings.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Represents a raster layer.
The class is used as a container of context for various read/write operations on other objects.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
_LayerRef< QgsMapLayer > QgsMapLayerRef
QPointer< TYPE > layer
Weak pointer to map layer.
TYPE * resolve(const QgsProject *project)
Resolves the map layer by attempting to find a layer with matching ID within a project.
QString layerId
Original layer ID.