29 QDomDocument doc = elem.ownerDocument();
31 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
33 elem.appendChild( elemDataProperties );
35 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
37 elem.appendChild( elemMaterial );
39 elem.setAttribute( QStringLiteral(
"shape" ),
shapeToString( mShape ) );
41 QVariantMap shapePropertiesCopy( mShapeProperties );
42 shapePropertiesCopy[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
writePath( shapePropertiesCopy[QStringLiteral(
"model" )].toString() ) );
44 QDomElement elemShapeProperties = doc.createElement( QStringLiteral(
"shape-properties" ) );
46 elem.appendChild( elemShapeProperties );
48 QDomElement elemTransform = doc.createElement( QStringLiteral(
"transform" ) );
50 elem.appendChild( elemTransform );
55 QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
58 QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
59 mMaterial.
readXml( elemMaterial );
61 mShape =
shapeFromString( elem.attribute( QStringLiteral(
"shape" ) ) );
63 QDomElement elemShapeProperties = elem.firstChildElement( QStringLiteral(
"shape-properties" ) );
65 mShapeProperties[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
readPath( mShapeProperties[QStringLiteral(
"model" )].toString() ) );
67 QDomElement elemTransform = elem.firstChildElement( QStringLiteral(
"transform" ) );
73 if ( shape == QStringLiteral(
"sphere" ) )
75 else if ( shape == QStringLiteral(
"cone" ) )
77 else if ( shape == QStringLiteral(
"cube" ) )
79 else if ( shape == QStringLiteral(
"torus" ) )
81 else if ( shape == QStringLiteral(
"plane" ) )
83 else if ( shape == QStringLiteral(
"extruded-text" ) )
85 else if ( shape == QStringLiteral(
"model" ) )
95 case Cylinder:
return QStringLiteral(
"cylinder" );
96 case Sphere:
return QStringLiteral(
"sphere" );
97 case Cone:
return QStringLiteral(
"cone" );
98 case Cube:
return QStringLiteral(
"cube" );
99 case Torus:
return QStringLiteral(
"torus" );
100 case Plane:
return QStringLiteral(
"plane" );
101 case ExtrudedText:
return QStringLiteral(
"extruded-text" );
102 case Model:
return QStringLiteral(
"model" );
103 default: Q_ASSERT(
false );
return QString();
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.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
static Qgs3DTypes::AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
QgsPoint3DSymbol()=default
Constructor for QgsPoint3DSymbol.
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.
void writeXml(QDomElement &elem) const
Writes settings to a DOM element.
Shape shape() const
Returns 3D shape for points.
void readXml(const QDomElement &elem)
Reads settings from a DOM element.
QgsAbstract3DSymbol * clone() const override
Returns a new instance of the symbol with the same settings.
Shape
3D shape types supported by the symbol
static Shape shapeFromString(const QString &shape)
Returns shape enum value from a string.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes symbol configuration to the given DOM element.
static QMatrix4x4 stringToMatrix4x4(const QString &str)
Convert a string to a 4x4 transform matrix.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
static QString shapeToString(Shape shape)
Returns string from a shape enum value.
static QString matrix4x4toString(const QMatrix4x4 &m)
Converts a 4x4 transform matrix to a string.
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads symbol configuration from the given DOM element.