18#include "qgsmeshterraingenerator.h"
35 std::unique_ptr<QgsMeshTerrainSettings> cloned = std::make_unique<QgsMeshTerrainSettings>();
36 cloned->mSymbol.reset( mSymbol->clone() );
37 cloned->mLayer = mLayer;
38 cloned->copyCommonProperties(
this );
39 return cloned.release();
44 return QStringLiteral(
"mesh" );
49 if ( element.hasAttribute( QStringLiteral(
"layer" ) ) )
51 mLayer =
QgsMapLayerRef( element.attribute( QStringLiteral(
"layer" ) ) );
52 mSymbol->readXml( element.firstChildElement(
"symbol" ), context );
57 const QDomElement elemTerrainGenerator = element.firstChildElement( QStringLiteral(
"generator" ) );
58 mLayer =
QgsMapLayerRef( elemTerrainGenerator.attribute( QStringLiteral(
"layer" ) ) );
59 mSymbol->readXml( elemTerrainGenerator.firstChildElement(
"symbol" ), context );
67 element.setAttribute( QStringLiteral(
"layer" ), mLayer.
layerId );
70 QDomElement elemSymbol = element.ownerDocument().createElement(
"symbol" );
71 mSymbol->writeXml( elemSymbol, context );
72 element.appendChild( elemSymbol );
86 if ( !otherMeshTerrain )
89 if ( *mSymbol != *otherMeshTerrain->mSymbol )
100 std::unique_ptr<QgsMeshTerrainGenerator> generator = std::make_unique<QgsMeshTerrainGenerator>();
101 generator->setLayer(
layer() );
102 std::unique_ptr<QgsMesh3DSymbol>
symbol( mSymbol->clone() );
104 generator->setSymbol(
symbol.release() );
106 generator->setExtent( context.
extent() );
117 return qobject_cast<QgsMeshLayer *>( mLayer.
layer.data() );
122 return mSymbol.get();
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.
double verticalScale() const
Returns the vertical scale (exaggeration) for terrain.
void readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common properties from the base class from the given DOM element.
void setVerticalScale(double verticalScale)
Sets mesh vertical scale.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
bool equals(const QgsAbstractTerrainSettings *other) const final
Returns true if this settings is exactly equal to another other settings.
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 setSymbol(QgsMesh3DSymbol *symbol)
Sets the symbol used to render the mesh as terrain.
QString type() const final
Returns the unique type name for the terrain generator.
void readXml(const QDomElement &element, const QgsReadWriteContext &context) final
Reads settings from a DOM element.
QgsMeshTerrainSettings * clone() const final
Returns a copy of the terrain settings.
QgsMeshLayer * layer() const
Returns the mesh layer with elevation model to be used for terrain generation.
QgsMesh3DSymbol * symbol() const
Returns the symbol used to render the mesh as terrain.
~QgsMeshTerrainSettings() override
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const final
Writes settings to a DOM element.
static QgsAbstractTerrainSettings * create()
Creates a new instance of a QgsMeshTerrainSettings object.
void setLayer(QgsMeshLayer *layer)
Sets the mesh layer with elevation model to be used for terrain generation.
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,...
The class is used as a container of context for various read/write operations on other objects.
_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.