33using namespace Qt::StringLiterals;
54 , mShape( other.
shape() )
66 QDomDocument doc = elem.ownerDocument();
68 QDomElement elemDataProperties = doc.createElement( u
"data"_s );
70 elem.appendChild( elemDataProperties );
72 elem.setAttribute( u
"material_type"_s, mMaterialSettings->type() );
73 QDomElement elemMaterial = doc.createElement( u
"material"_s );
74 mMaterialSettings->writeXml( elemMaterial, context );
75 elem.appendChild( elemMaterial );
79 QVariantMap shapePropertiesCopy( mShapeProperties );
80 shapePropertiesCopy[u
"model"_s] = QVariant( context.
pathResolver().
writePath( shapePropertiesCopy[u
"model"_s].toString() ) );
82 QDomElement elemShapeProperties = doc.createElement( u
"shape-properties"_s );
84 elem.appendChild( elemShapeProperties );
86 QDomElement elemTransform = doc.createElement( u
"transform"_s );
88 elem.appendChild( elemTransform );
90 QDomElement elemDDP = doc.createElement( u
"data-defined-properties"_s );
92 elem.appendChild( elemDDP );
98 elem.appendChild( symbolElem );
104 const QDomElement elemDataProperties = elem.firstChildElement( u
"data"_s );
107 const QDomElement elemMaterial = elem.firstChildElement( u
"material"_s );
108 const QString materialType = elem.attribute( u
"material_type"_s, u
"metalrough"_s );
110 if ( !mMaterialSettings )
112 mMaterialSettings->readXml( elemMaterial, context );
116 const QDomElement elemShapeProperties = elem.firstChildElement( u
"shape-properties"_s );
118 mShapeProperties[u
"model"_s] = QVariant( context.
pathResolver().
readPath( mShapeProperties[u
"model"_s].toString() ) );
120 const QDomElement elemTransform = elem.firstChildElement( u
"transform"_s );
123 const QDomElement elemDDP = elem.firstChildElement( u
"data-defined-properties"_s );
124 if ( !elemDDP.isNull() )
127 const QDomElement symbolElem = elem.firstChildElement( u
"symbol"_s );
142 mTransform.data()[13] =
static_cast<float>( props->
zOffset() );
148 if (
shape ==
"sphere"_L1 )
150 else if (
shape ==
"cone"_L1 )
152 else if (
shape ==
"cube"_L1 )
154 else if (
shape ==
"torus"_L1 )
156 else if (
shape ==
"plane"_L1 )
158 else if (
shape ==
"extruded-text"_L1 )
160 else if (
shape ==
"model"_L1 )
162 else if (
shape ==
"billboard"_L1 )
173 return u
"cylinder"_s;
185 return u
"extruded-text"_s;
189 return u
"billboard"_s;
202 if ( property ==
"length"_L1 )
204 const float length = mShapeProperties.value( property ).toFloat();
209 else if ( property ==
"radius"_L1 )
211 const float radius = mShapeProperties.value( property ).toFloat();
220 if ( property ==
"radius"_L1 )
222 const float radius = mShapeProperties.value( property ).toFloat();
227 else if ( property ==
"rings"_L1 )
229 constexpr int DEFAULT_RINGS = 16;
230 const int rings = mShapeProperties.value( property, DEFAULT_RINGS ).toInt();
232 return DEFAULT_RINGS;
235 else if ( property ==
"slices"_L1 )
237 constexpr int DEFAULT_SLICES = 16;
238 const int slices = mShapeProperties.value( property, DEFAULT_SLICES ).toInt();
240 return DEFAULT_SLICES;
247 if ( property ==
"length"_L1 )
249 const float length = mShapeProperties.value( property ).toFloat();
258 if ( property ==
"size"_L1 )
260 const float size = mShapeProperties.value( property ).toFloat();
269 if ( property ==
"radius"_L1 )
271 const float radius = mShapeProperties.value( property ).toFloat();
276 else if ( property ==
"minorRadius"_L1 )
278 const float minorRadius = mShapeProperties.value( property ).toFloat();
279 if ( minorRadius == 0 )
287 if ( property ==
"size"_L1 )
289 const float size = mShapeProperties.value( property ).toFloat();
298 if ( property ==
"depth"_L1 )
300 const float depth = mShapeProperties.value( property ).toFloat();
311 if ( property ==
"upAxis"_L1 )
313 return mShapeProperties.value( u
"upAxis"_s, u
"z"_s ).toString();
315 if ( property ==
"forwardAxis"_L1 )
317 return mShapeProperties.value( u
"forwardAxis"_s, u
"y"_s ).toString();
325 return mShapeProperties.value( property );
330 return mTransform.data()[14];
335 return mMaterialSettings.get();
350 Qt3DRender::QSceneLoader *sceneLoader = entity->findChild<Qt3DRender::QSceneLoader *>();
353 const QVector<Qgs3DExportObject *> objects = exporter->processSceneLoaderGeometries( sceneLoader, objectNamePrefix );
359 exporter->mObjects << objects;
363 const QList<Qt3DRender::QMesh *> meshes = entity->findChildren<Qt3DRender::QMesh *>();
364 for ( Qt3DRender::QMesh *mesh : meshes )
366 Qgs3DExportObject *
object = exporter->processGeometryRenderer( mesh, objectNamePrefix );
371 exporter->mObjects << object;
381 exporter->mObjects << obj;
387 const QVector<Qgs3DExportObject *> objects = exporter->processInstancedPointGeometry( entity, objectNamePrefix );
391 exporter->mObjects << obj;
400 return mBillboardSymbol.get();
405 mBillboardSymbol.reset( symbol );
Point3DShape
3D point shape types.
@ ExtrudedText
Extruded text.
Manages the data of each object of the scene (positions, normals, texture coordinates ....
void setSmoothEdges(bool smoothEdges)
Sets whether triangles edges will look smooth.
Entity that handles the exporting of 3D scenes.
bool smoothEdges() const
Returns whether the triangles will look smooth.
static Qgis::AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
static QString matrix4x4toString(const QMatrix4x4 &m)
Converts a 4x4 transform matrix to a string.
static QString altClampingToString(Qgis::AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
static QMatrix4x4 stringToMatrix4x4(const QString &str)
Convert a string to a 4x4 transform matrix.
static QgsMaterialRegistry * materialRegistry()
Returns the material registry, used for managing 3D materials.
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
QgsPropertyCollection mDataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
Abstract base class for material settings.
double zOffset() const
Returns the z offset, which is a fixed offset amount which should be added to z values from the layer...
A marker symbol type, for rendering Point and MultiPoint geometries.
std::unique_ptr< QgsAbstractMaterialSettings > createMaterialSettings(const QString &type) const
Creates a new instance of the material settings of the specified type.
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 QString shapeToString(Qgis::Point3DShape shape)
Returns string from a shape enum value.
~QgsPoint3DSymbol() override
void setDefaultPropertiesFromLayer(const QgsVectorLayer *layer) override
Sets default properties for the symbol based on a layer's configuration.
static QgsAbstract3DSymbol * create()
Creates a new QgsPoint3DSymbol.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes symbol configuration to the given DOM element.
QgsPoint3DSymbol()
Constructor for QgsPoint3DSymbol with default QgsMarkerSymbol as the billboardSymbol.
QMatrix4x4 transform() const
Returns transform for individual objects represented by the symbol.
void setMaterialSettings(QgsAbstractMaterialSettings *materialSettings) override
Sets the material settings used for shading of the symbol.
QgsMarkerSymbol * billboardSymbol() const
Returns a symbol for billboard.
Qgis::Point3DShape shape() const
Returns 3D shape for points.
float billboardHeight() const
Returns how much the billboard should be elevated upwards.
QList< Qgis::GeometryType > compatibleGeometryTypes() const override
Returns the list of the vector layer geometry types which are compatible with this symbol.
bool exportGeometries(Qgs3DSceneExporter *exporter, Qt3DCore::QEntity *entity, const QString &objectNamePrefix) const override
Exports the geometries contained within the hierarchy of entity.
void setBillboardSymbol(QgsMarkerSymbol *symbol)
Set symbol for billboard and the ownership is transferred.
QgsAbstractMaterialSettings * materialSettings() const override
Returns material settings used for shading of the symbol.
QVariantMap shapeProperties() const
Returns a key-value dictionary of point shape properties.
Qgis::AltitudeClamping altitudeClamping() const
Returns method that determines altitude (whether to clamp to feature to terrain).
QgsAbstract3DSymbol * clone() const override
Returns a new instance of the symbol with the same settings.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads symbol configuration from the given DOM element.
QVariant shapeProperty(const QString &property) const
Returns the value for a specific shape property.
static Qgis::Point3DShape shapeFromString(const QString &shape)
Returns shape enum value from a string.
A container for the context for various read/write operations on objects.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
static std::unique_ptr< QgsSymbol > loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Vector layer specific subclass of QgsMapLayerElevationProperties.
double extrusionHeight() const
Returns the feature extrusion height.
Qgis::AltitudeClamping clamping() const
Returns the altitude clamping method, which dictates how feature heights are interpreted with respect...
bool extrusionEnabled() const
Returns true if extrusion is enabled.
Represents a vector layer which manages a vector based dataset.
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.