QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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#include <QString>
21
22using namespace Qt::StringLiterals;
23
24void QgsVectorLayer3DTilingSettings::writeXml( QDomElement &elem ) const
25{
26 QDomDocument doc = elem.ownerDocument();
27
28 QDomElement elemTiling = doc.createElement( u"vector-layer-3d-tiling"_s );
29 elemTiling.setAttribute( u"zoom-levels-count"_s, mZoomLevelsCount );
30 elemTiling.setAttribute( u"show-bounding-boxes"_s, mShowBoundingBoxes ? u"1"_s : u"0"_s );
31 elemTiling.setAttribute( u"max-chunk-features"_s, mMaxChunkFeatures );
32 elem.appendChild( elemTiling );
33}
34
35void QgsVectorLayer3DTilingSettings::readXml( const QDomElement &elem )
36{
37 const QDomElement elemTiling = elem.firstChildElement( u"vector-layer-3d-tiling"_s );
38 if ( !elemTiling.isNull() )
39 {
40 mZoomLevelsCount = elemTiling.attribute( u"zoom-levels-count"_s ).toInt();
41 mShowBoundingBoxes = elemTiling.attribute( u"show-bounding-boxes"_s ).toInt();
42 mMaxChunkFeatures = elemTiling.attribute( u"max-chunk-features"_s, QString::number( mMaxChunkFeatures ) ).toInt();
43 }
44}
45
46
48
49
51
56
58{
59 return qobject_cast<QgsVectorLayer *>( mLayerRef.layer );
60}
61
63{
64 r->mLayerRef = mLayerRef;
65 r->mTilingSettings = mTilingSettings;
66}
67
69{
70 Q_UNUSED( context )
71 elem.setAttribute( u"layer"_s, mLayerRef.layerId );
72 mTilingSettings.writeXml( elem );
73}
74
76{
77 Q_UNUSED( context )
78 mLayerRef = QgsMapLayerRef( elem.attribute( u"layer"_s ) );
79 mTilingSettings.readXml( elem );
80}
81
83{
84 mLayerRef.setLayer( project.mapLayer( mLayerRef.layerId ) );
85}
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:112
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
A container for the context for various read/write operations on 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 dataset.
_LayerRef< QgsMapLayer > QgsMapLayerRef