34 mTerrainProvider = std::make_unique< QgsFlatTerrainProvider >();
40 if ( mTerrainProvider )
41 mTerrainProvider->resolveReferences( project );
46 const QDomElement providerElement = element.firstChildElement( QStringLiteral(
"terrainProvider" ) );
47 if ( !providerElement.isNull() )
49 const QString type = providerElement.attribute( QStringLiteral(
"type" ) );
50 if ( type.compare( QLatin1String(
"flat" ) ) == 0 )
51 mTerrainProvider = std::make_unique< QgsFlatTerrainProvider >();
52 else if ( type.compare( QLatin1String(
"raster" ) ) == 0 )
53 mTerrainProvider = std::make_unique< QgsRasterDemTerrainProvider >();
54 else if ( type.compare( QLatin1String(
"mesh" ) ) == 0 )
55 mTerrainProvider = std::make_unique< QgsMeshTerrainProvider >();
57 mTerrainProvider = std::make_unique< QgsFlatTerrainProvider >();
59 mTerrainProvider->readXml( providerElement, context );
63 mTerrainProvider = std::make_unique< QgsFlatTerrainProvider >();
72 QDomElement element = document.createElement( QStringLiteral(
"ElevationProperties" ) );
74 if ( mTerrainProvider )
76 QDomElement providerElement = document.createElement( QStringLiteral(
"terrainProvider" ) );
77 providerElement.setAttribute( QStringLiteral(
"type" ), mTerrainProvider->type() );
78 providerElement.appendChild( mTerrainProvider->writeXml( document, context ) );
79 element.appendChild( providerElement );
86 return mTerrainProvider.get();
91 if ( mTerrainProvider.get() == provider )
94 mTerrainProvider.reset( provider );
Abstract base class for terrain providers.
A terrain provider where the terrain is a simple flat surface.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the property state from a DOM element.
void reset()
Resets the properties to a default state.
QgsProjectElevationProperties(QObject *parent=nullptr)
Constructor for QgsProjectElevationProperties with the specified parent object.
QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const
Returns a DOM element representing the properties.
~QgsProjectElevationProperties() override
QgsAbstractTerrainProvider * terrainProvider()
Returns the project's terrain provider.
void changed()
Emitted when the elevation properties change.
void resolveReferences(const QgsProject *project)
Resolves reference to layers from stored layer ID.
void setTerrainProvider(QgsAbstractTerrainProvider *provider)
Sets the project's terrain provider.
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.