QGIS API Documentation  3.0.2-Girona (307d082)
qgspolygon3dsymbol.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgspolygon3dsymbol.cpp
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 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 
16 #include "qgspolygon3dsymbol.h"
17 
19 {
20  return new QgsPolygon3DSymbol( *this );
21 }
22 
23 void QgsPolygon3DSymbol::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
24 {
25  Q_UNUSED( context );
26 
27  QDomDocument doc = elem.ownerDocument();
28 
29  QDomElement elemDataProperties = doc.createElement( QStringLiteral( "data" ) );
30  elemDataProperties.setAttribute( QStringLiteral( "alt-clamping" ), Qgs3DUtils::altClampingToString( mAltClamping ) );
31  elemDataProperties.setAttribute( QStringLiteral( "alt-binding" ), Qgs3DUtils::altBindingToString( mAltBinding ) );
32  elemDataProperties.setAttribute( QStringLiteral( "height" ), mHeight );
33  elemDataProperties.setAttribute( QStringLiteral( "extrusion-height" ), mExtrusionHeight );
34  elemDataProperties.setAttribute( QStringLiteral( "culling-mode" ), Qgs3DUtils::cullingModeToString( mCullingMode ) );
35  elemDataProperties.setAttribute( QStringLiteral( "invert-normals" ), mInvertNormals ? "1" : "0" );
36  elem.appendChild( elemDataProperties );
37 
38  QDomElement elemMaterial = doc.createElement( QStringLiteral( "material" ) );
39  mMaterial.writeXml( elemMaterial );
40  elem.appendChild( elemMaterial );
41 
42  QDomElement elemDDP = doc.createElement( QStringLiteral( "data-defined-properties" ) );
44  elem.appendChild( elemDDP );
45 }
46 
47 void QgsPolygon3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
48 {
49  Q_UNUSED( context );
50 
51  QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral( "data" ) );
52  mAltClamping = Qgs3DUtils::altClampingFromString( elemDataProperties.attribute( QStringLiteral( "alt-clamping" ) ) );
53  mAltBinding = Qgs3DUtils::altBindingFromString( elemDataProperties.attribute( QStringLiteral( "alt-binding" ) ) );
54  mHeight = elemDataProperties.attribute( QStringLiteral( "height" ) ).toFloat();
55  mExtrusionHeight = elemDataProperties.attribute( QStringLiteral( "extrusion-height" ) ).toFloat();
56  mCullingMode = Qgs3DUtils::cullingModeFromString( elemDataProperties.attribute( QStringLiteral( "culling-mode" ) ) );
57  mInvertNormals = elemDataProperties.attribute( QStringLiteral( "invert-normals" ) ).toInt();
58 
59  QDomElement elemMaterial = elem.firstChildElement( QStringLiteral( "material" ) );
60  mMaterial.readXml( elemMaterial );
61 
62  QDomElement elemDDP = elem.firstChildElement( QStringLiteral( "data-defined-properties" ) );
63  if ( !elemDDP.isNull() )
65 }
static QString cullingModeToString(Qt3DRender::QCullFace::CullingMode mode)
Converts a value from CullingMode enum to a string.
Definition: qgs3dutils.cpp:85
The class is used as a container of context for various read/write operations on other objects...
static AltitudeBinding altBindingFromString(const QString &str)
Converts a string to a value from AltitudeBinding enum.
Definition: qgs3dutils.cpp:77
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes symbol configuration to the given DOM element.
QgsPropertyCollection mDataDefinedProperties
virtual bool readXml(const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
Reads property collection state from an XML element.
QgsPolygon3DSymbol()=default
Constructor for QgsPolygon3DSymbol.
static Qt3DRender::QCullFace::CullingMode cullingModeFromString(const QString &str)
Converts a string to a value from CullingMode enum.
Definition: qgs3dutils.cpp:97
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
void readXml(const QDomElement &elem)
Reads settings from a DOM element.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads symbol configuration from the given DOM element.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
static QString altBindingToString(AltitudeBinding altBind)
Converts a value from AltitudeBinding enum to a string.
Definition: qgs3dutils.cpp:66
void writeXml(QDomElement &elem) const
Writes settings to a DOM element.
static AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
Definition: qgs3dutils.cpp:55
QgsAbstract3DSymbol * clone() const override
Returns a new instance of the symbol with the same settings.
static QString altClampingToString(AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
Definition: qgs3dutils.cpp:43
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.