QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsline3dsymbol.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsline3dsymbol.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 "qgsline3dsymbol.h"
17 
18 #include "qgs3dutils.h"
19 
21 {
22  return new QgsLine3DSymbol( *this );
23 }
24 
25 void QgsLine3DSymbol::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
26 {
27  Q_UNUSED( context )
28 
29  QDomDocument doc = elem.ownerDocument();
30 
31  QDomElement elemDataProperties = doc.createElement( QStringLiteral( "data" ) );
32  elemDataProperties.setAttribute( QStringLiteral( "alt-clamping" ), Qgs3DUtils::altClampingToString( mAltClamping ) );
33  elemDataProperties.setAttribute( QStringLiteral( "alt-binding" ), Qgs3DUtils::altBindingToString( mAltBinding ) );
34  elemDataProperties.setAttribute( QStringLiteral( "height" ), mHeight );
35  elemDataProperties.setAttribute( QStringLiteral( "extrusion-height" ), mExtrusionHeight );
36  elemDataProperties.setAttribute( QStringLiteral( "simple-lines" ), mRenderAsSimpleLines ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
37  elemDataProperties.setAttribute( QStringLiteral( "width" ), mWidth );
38  elem.appendChild( elemDataProperties );
39 
40  QDomElement elemMaterial = doc.createElement( QStringLiteral( "material" ) );
41  mMaterial.writeXml( elemMaterial );
42  elem.appendChild( elemMaterial );
43 }
44 
45 void QgsLine3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
46 {
47  Q_UNUSED( context )
48 
49  QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral( "data" ) );
50  mAltClamping = Qgs3DUtils::altClampingFromString( elemDataProperties.attribute( QStringLiteral( "alt-clamping" ) ) );
51  mAltBinding = Qgs3DUtils::altBindingFromString( elemDataProperties.attribute( QStringLiteral( "alt-binding" ) ) );
52  mHeight = elemDataProperties.attribute( QStringLiteral( "height" ) ).toFloat();
53  mExtrusionHeight = elemDataProperties.attribute( QStringLiteral( "extrusion-height" ) ).toFloat();
54  mWidth = elemDataProperties.attribute( QStringLiteral( "width" ) ).toFloat();
55  mRenderAsSimpleLines = elemDataProperties.attribute( QStringLiteral( "simple-lines" ), QStringLiteral( "0" ) ).toInt();
56 
57  QDomElement elemMaterial = elem.firstChildElement( QStringLiteral( "material" ) );
58  mMaterial.readXml( elemMaterial );
59 }
The class is used as a container of context for various read/write operations on other objects...
static QString altClampingToString(Qgs3DTypes::AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
Definition: qgs3dutils.cpp:184
QgsLine3DSymbol()=default
Constructor for QgsLine3DSymbol.
static Qgs3DTypes::AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
Definition: qgs3dutils.cpp:196
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
QgsAbstract3DSymbol * clone() const override
Returns a new instance of the symbol with the same settings.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes symbol configuration to the given DOM element.
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.
void writeXml(QDomElement &elem) const
Writes settings to a DOM element.
static Qgs3DTypes::AltitudeBinding altBindingFromString(const QString &str)
Converts a string to a value from AltitudeBinding enum.
Definition: qgs3dutils.cpp:218
static QString altBindingToString(Qgs3DTypes::AltitudeBinding altBind)
Converts a value from AltitudeBinding enum to a string.
Definition: qgs3dutils.cpp:207