QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
22 void 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 
32 void 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 }
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsMapLayerRef
_LayerRef< QgsMapLayer > QgsMapLayerRef
Definition: qgsmaplayerref.h:295
QgsProject::mapLayer
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Definition: qgsproject.cpp:3680
QgsAbstractVectorLayer3DRenderer
Base class for 3D renderers that are based on vector layers.
Definition: qgsabstractvectorlayer3drenderer.h:77
QgsAbstractVectorLayer3DRenderer::copyBaseProperties
void copyBaseProperties(QgsAbstractVectorLayer3DRenderer *r) const
Copies common properties of this object to another object.
Definition: qgsabstractvectorlayer3drenderer.cpp:58
_LayerRef::layer
QPointer< TYPE > layer
Weak pointer to map layer.
Definition: qgsmaplayerref.h:114
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:103
QgsAbstractVectorLayer3DRenderer::QgsAbstractVectorLayer3DRenderer
QgsAbstractVectorLayer3DRenderer()
QgsAbstractVectorLayer3DRenderer::readXmlBaseProperties
void readXmlBaseProperties(const QDomElement &elem, const QgsReadWriteContext &context)
Reads common properties of this object from DOM element.
Definition: qgsabstractvectorlayer3drenderer.cpp:71
_LayerRef::layerId
QString layerId
Original layer ID.
Definition: qgsmaplayerref.h:117
_LayerRef::setLayer
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
Definition: qgsmaplayerref.h:78
QgsAbstractVectorLayer3DRenderer::layer
QgsVectorLayer * layer() const
Returns vector layer associated with the renderer.
Definition: qgsabstractvectorlayer3drenderer.cpp:53
qgsabstractvectorlayer3drenderer.h
QgsVectorLayer3DTilingSettings::readXml
void readXml(const QDomElement &elem)
Reads content of the object from XML.
Definition: qgsabstractvectorlayer3drenderer.cpp:32
QgsVectorLayer3DTilingSettings::writeXml
void writeXml(QDomElement &elem) const
Writes content of the object to XML.
Definition: qgsabstractvectorlayer3drenderer.cpp:22
QgsAbstractVectorLayer3DRenderer::setLayer
void setLayer(QgsVectorLayer *layer)
Sets vector layer associated with the renderer.
Definition: qgsabstractvectorlayer3drenderer.cpp:48
QgsAbstractVectorLayer3DRenderer::writeXmlBaseProperties
void writeXmlBaseProperties(QDomElement &elem, const QgsReadWriteContext &context) const
Writes common properties of this object to DOM element.
Definition: qgsabstractvectorlayer3drenderer.cpp:64
qgsvectorlayer.h
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsAbstractVectorLayer3DRenderer::resolveReferences
void resolveReferences(const QgsProject &project) override
Resolves references to other objects - second phase of loading - after readXml()
Definition: qgsabstractvectorlayer3drenderer.cpp:78