28 QDomDocument doc = elem.ownerDocument();
30 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
32 elem.appendChild( elemDataProperties );
34 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
36 elem.appendChild( elemMaterial );
38 elem.setAttribute( QStringLiteral(
"shape" ),
shapeToString( mShape ) );
40 QVariantMap shapePropertiesCopy( mShapeProperties );
41 shapePropertiesCopy[
"model"] = QVariant( context.
pathResolver().
writePath( shapePropertiesCopy[
"model"].toString() ) );
43 QDomElement elemShapeProperties = doc.createElement( QStringLiteral(
"shape-properties" ) );
45 elem.appendChild( elemShapeProperties );
47 QDomElement elemTransform = doc.createElement( QStringLiteral(
"transform" ) );
49 elem.appendChild( elemTransform );
54 QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
57 QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
58 mMaterial.
readXml( elemMaterial );
60 mShape =
shapeFromString( elem.attribute( QStringLiteral(
"shape" ) ) );
62 QDomElement elemShapeProperties = elem.firstChildElement( QStringLiteral(
"shape-properties" ) );
64 mShapeProperties[
"model"] = QVariant( context.
pathResolver().
readPath( mShapeProperties[
"model"].toString() ) );
66 QDomElement elemTransform = elem.firstChildElement( QStringLiteral(
"transform" ) );
72 if ( shape == QStringLiteral(
"sphere" ) )
74 else if ( shape == QStringLiteral(
"cone" ) )
76 else if ( shape == QStringLiteral(
"cube" ) )
78 else if ( shape == QStringLiteral(
"torus" ) )
80 else if ( shape == QStringLiteral(
"plane" ) )
82 else if ( shape == QStringLiteral(
"extruded-text" ) )
84 else if ( shape == QStringLiteral(
"model" ) )
94 case Cylinder:
return QStringLiteral(
"cylinder" );
95 case Sphere:
return QStringLiteral(
"sphere" );
96 case Cone:
return QStringLiteral(
"cone" );
97 case Cube:
return QStringLiteral(
"cube" );
98 case Torus:
return QStringLiteral(
"torus" );
99 case Plane:
return QStringLiteral(
"plane" );
100 case ExtrudedText:
return QStringLiteral(
"extruded-text" );
101 case Model:
return QStringLiteral(
"model" );
102 default: Q_ASSERT(
false );
return QString();
The class is used as a container of context for various read/write operations on other objects...
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Shape shape() const
Returns 3D shape for points.
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 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
Writes settings to a DOM element.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes symbol configuration to the given DOM element.
static AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
static QMatrix4x4 stringToMatrix4x4(const QString &str)
Convert a string to a 4x4 transform matrix.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
static QString shapeToString(Shape shape)
Returns string from a shape enum value.
static QString altClampingToString(AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
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.