QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
35 mAltClamping( other.altitudeClamping() )
36 , mMaterial( other.material() )
37 , mShape( other.shape() )
38 , mShapeProperties( other.shapeProperties() )
39 , mTransform( other.transform() )
40 , mBillboardSymbol( other.billboardSymbol() ? other.billboardSymbol()->clone() : nullptr )
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();
141 QMatrix4x4 billboardTransformMatrix;
142 billboardTransformMatrix.translate( QVector3D( 0, mTransform.data()[13], 0 ) );
144 return billboardTransformMatrix;
QMatrix4x4 billboardTransform() const
Returns transform for billboards.
static Shape shapeFromString(const QString &shape)
Returns shape enum value from a string.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Shape
3D shape types supported by the symbol
void setBillboardSymbol(QgsMarkerSymbol *symbol)
Set symbol for billboard and the ownership is transferred.
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.
static QString shapeToString(Shape shape)
Returns string from a shape enum value.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
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.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
static QString matrix4x4toString(const QMatrix4x4 &m)
Converts a 4x4 transform matrix to a string.
static QString altClampingToString(Qgs3DTypes::AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
void readXml(const QDomElement &elem)
Reads settings from a DOM element.
Shape shape() const
Returns 3D shape for points.
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.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
@ ExtrudedText
Supported in Qt 5.9+.
void writeXml(QDomElement &elem) const
Writes settings to a DOM element.
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
QgsMarkerSymbol * billboardSymbol() const
Returns a symbol for billboard.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
QgsAbstract3DSymbol * clone() const override
Returns a new instance of the symbol with the same settings.