37 , mShape( other.
shape() )
47 QDomDocument doc = elem.ownerDocument();
49 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
51 elem.appendChild( elemDataProperties );
53 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
55 elem.appendChild( elemMaterial );
57 elem.setAttribute( QStringLiteral(
"shape" ),
shapeToString( mShape ) );
59 QVariantMap shapePropertiesCopy( mShapeProperties );
60 shapePropertiesCopy[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
writePath( shapePropertiesCopy[QStringLiteral(
"model" )].toString() ) );
62 QDomElement elemShapeProperties = doc.createElement( QStringLiteral(
"shape-properties" ) );
64 elem.appendChild( elemShapeProperties );
66 QDomElement elemTransform = doc.createElement( QStringLiteral(
"transform" ) );
68 elem.appendChild( elemTransform );
74 elem.appendChild( symbolElem );
80 QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
83 QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
84 mMaterial.
readXml( elemMaterial );
86 mShape =
shapeFromString( elem.attribute( QStringLiteral(
"shape" ) ) );
88 QDomElement elemShapeProperties = elem.firstChildElement( QStringLiteral(
"shape-properties" ) );
90 mShapeProperties[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
readPath( mShapeProperties[QStringLiteral(
"model" )].toString() ) );
92 QDomElement elemTransform = elem.firstChildElement( QStringLiteral(
"transform" ) );
95 QDomElement symbolElem = elem.firstChildElement( QStringLiteral(
"symbol" ) );
97 setBillboardSymbol( QgsSymbolLayerUtils::loadSymbol< QgsMarkerSymbol >( symbolElem, context ) );
102 if ( shape == QStringLiteral(
"sphere" ) )
104 else if ( shape == QStringLiteral(
"cone" ) )
106 else if ( shape == QStringLiteral(
"cube" ) )
108 else if ( shape == QStringLiteral(
"torus" ) )
110 else if ( shape == QStringLiteral(
"plane" ) )
112 else if ( shape == QStringLiteral(
"extruded-text" ) )
114 else if ( shape == QStringLiteral(
"model" ) )
116 else if ( shape == QStringLiteral(
"billboard" ) )
126 case Cylinder:
return QStringLiteral(
"cylinder" );
127 case Sphere:
return QStringLiteral(
"sphere" );
128 case Cone:
return QStringLiteral(
"cone" );
129 case Cube:
return QStringLiteral(
"cube" );
130 case Torus:
return QStringLiteral(
"torus" );
131 case Plane:
return QStringLiteral(
"plane" );
132 case ExtrudedText:
return QStringLiteral(
"extruded-text" );
133 case Model:
return QStringLiteral(
"model" );
134 case Billboard:
return QStringLiteral(
"billboard" );
135 default: Q_ASSERT(
false );
return QString();
144 QMatrix4x4 billboardTransformMatrix;
145 billboardTransformMatrix.translate( QVector3D( 0, md[13], 0 ) );
147 return billboardTransformMatrix;
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 readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Qgs3DTypes::AltitudeClamping altitudeClamping() const
Returns method that determines altitude (whether to clamp to feature to terrain)
Shape shape() const
Returns 3D shape for points.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides...
static Qgs3DTypes::AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
QVariantMap shapeProperties() const
Returns a key-value dictionary of point shape properties.
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
QMatrix4x4 transform() const
Returns transform for individual objects represented by the symbol.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
3 3D symbol that draws point geometries as 3D objects using one of the predefined shapes...
QgsPhongMaterialSettings material() const
Returns material used for shading of the symbol.
void readXml(const QDomElement &elem)
Reads settings from a DOM element.
QMatrix4x4 billboardTransform() const
Returns transform for billboards.
QgsMarkerSymbol * billboardSymbol() const
Returns a symbol for billboard.
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.
void setBillboardSymbol(QgsMarkerSymbol *symbol)
Set symbol for billboard and the ownership is transferred.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
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.
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 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.
QgsPoint3DSymbol()
Constructor for QgsPoint3DSymbol with default QgsMarkerSymbol as the billboardSymbol.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads symbol configuration from the given DOM element.