QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsabstractvectorlayer3drenderer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractvectorlayer3drenderer.cpp
3 --------------------------------------
4 Date : January 2020
5 Copyright : (C) 2020 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgsvectorlayer.h"
19
20
21
22void QgsVectorLayer3DTilingSettings::writeXml( QDomElement &elem ) const
23{
24 QDomDocument doc = elem.ownerDocument();
25
26 QDomElement elemTiling = doc.createElement( QStringLiteral( "vector-layer-3d-tiling" ) );
27 elemTiling.setAttribute( QStringLiteral( "zoom-levels-count" ), mZoomLevelsCount );
28 elemTiling.setAttribute( QStringLiteral( "show-bounding-boxes" ), mShowBoundingBoxes ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
29 elem.appendChild( elemTiling );
30}
31
32void QgsVectorLayer3DTilingSettings::readXml( const QDomElement &elem )
33{
34 const QDomElement elemTiling = elem.firstChildElement( QStringLiteral( "vector-layer-3d-tiling" ) );
35 if ( !elemTiling.isNull() )
36 {
37 mZoomLevelsCount = elemTiling.attribute( QStringLiteral( "zoom-levels-count" ) ).toInt();
38 mShowBoundingBoxes = elemTiling.attribute( QStringLiteral( "show-bounding-boxes" ) ).toInt();
39 }
40}
41
42
44
45
47
49{
50 mLayerRef = QgsMapLayerRef( layer );
51}
52
54{
55 return qobject_cast<QgsVectorLayer *>( mLayerRef.layer );
56}
57
59{
60 r->mLayerRef = mLayerRef;
61 r->mTilingSettings = mTilingSettings;
62}
63
65{
66 Q_UNUSED( context )
67 elem.setAttribute( QStringLiteral( "layer" ), mLayerRef.layerId );
68 mTilingSettings.writeXml( elem );
69}
70
72{
73 Q_UNUSED( context )
74 mLayerRef = QgsMapLayerRef( elem.attribute( QStringLiteral( "layer" ) ) );
75 mTilingSettings.readXml( elem );
76}
77
79{
80 mLayerRef.setLayer( project.mapLayer( mLayerRef.layerId ) );
81}
void writeXmlBaseProperties(QDomElement &elem, const QgsReadWriteContext &context) const
Writes common properties of this object to DOM element.
void readXmlBaseProperties(const QDomElement &elem, const QgsReadWriteContext &context)
Reads common properties of this object from DOM element.
void resolveReferences(const QgsProject &project) override
Resolves references to other objects - second phase of loading - after readXml()
void setLayer(QgsVectorLayer *layer)
Sets vector layer associated with the renderer.
void copyBaseProperties(QgsAbstractVectorLayer3DRenderer *r) const
Copies common properties of this object to another object.
QgsVectorLayer * layer() const
Returns vector layer associated with the renderer.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:107
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
The class is used as a container of context for various read/write operations on other objects.
void readXml(const QDomElement &elem)
Reads content of the object from XML.
void writeXml(QDomElement &elem) const
Writes content of the object to XML.
Represents a vector layer which manages a vector based data sets.
_LayerRef< QgsMapLayer > QgsMapLayerRef
QPointer< TYPE > layer
Weak pointer to map layer.
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString layerId
Original layer ID.