32using namespace Qt::StringLiterals;
53 , mShape( other.
shape() )
65 QDomDocument doc = elem.ownerDocument();
67 QDomElement elemDataProperties = doc.createElement( u
"data"_s );
69 elem.appendChild( elemDataProperties );
71 elem.setAttribute( u
"material_type"_s, mMaterialSettings->type() );
72 QDomElement elemMaterial = doc.createElement( u
"material"_s );
73 mMaterialSettings->writeXml( elemMaterial, context );
74 elem.appendChild( elemMaterial );
78 QVariantMap shapePropertiesCopy( mShapeProperties );
79 shapePropertiesCopy[u
"model"_s] = QVariant( context.
pathResolver().
writePath( shapePropertiesCopy[u
"model"_s].toString() ) );
81 QDomElement elemShapeProperties = doc.createElement( u
"shape-properties"_s );
83 elem.appendChild( elemShapeProperties );
85 QDomElement elemTransform = doc.createElement( u
"transform"_s );
87 elem.appendChild( elemTransform );
89 QDomElement elemDDP = doc.createElement( u
"data-defined-properties"_s );
91 elem.appendChild( elemDDP );
97 elem.appendChild( symbolElem );
103 const QDomElement elemDataProperties = elem.firstChildElement( u
"data"_s );
106 const QDomElement elemMaterial = elem.firstChildElement( u
"material"_s );
107 const QString materialType = elem.attribute( u
"material_type"_s, u
"phong"_s );
109 if ( !mMaterialSettings )
111 mMaterialSettings->readXml( elemMaterial, context );
115 const QDomElement elemShapeProperties = elem.firstChildElement( u
"shape-properties"_s );
117 mShapeProperties[u
"model"_s] = QVariant( context.
pathResolver().
readPath( mShapeProperties[u
"model"_s].toString() ) );
119 const QDomElement elemTransform = elem.firstChildElement( u
"transform"_s );
122 const QDomElement elemDDP = elem.firstChildElement( u
"data-defined-properties"_s );
123 if ( !elemDDP.isNull() )
126 const QDomElement symbolElem = elem.firstChildElement( u
"symbol"_s );
141 mTransform.data()[13] =
static_cast<float>( props->
zOffset() );
147 if (
shape ==
"sphere"_L1 )
149 else if (
shape ==
"cone"_L1 )
151 else if (
shape ==
"cube"_L1 )
153 else if (
shape ==
"torus"_L1 )
155 else if (
shape ==
"plane"_L1 )
157 else if (
shape ==
"extruded-text"_L1 )
159 else if (
shape ==
"model"_L1 )
161 else if (
shape ==
"billboard"_L1 )
172 return u
"cylinder"_s;
184 return u
"extruded-text"_s;
188 return u
"billboard"_s;
201 if ( property ==
"length"_L1 )
203 const float length = mShapeProperties.value( property ).toFloat();
208 else if ( property ==
"radius"_L1 )
210 const float radius = mShapeProperties.value( property ).toFloat();
219 if ( property ==
"radius"_L1 )
221 const float radius = mShapeProperties.value( property ).toFloat();
230 if ( property ==
"length"_L1 )
232 const float length = mShapeProperties.value( property ).toFloat();
241 if ( property ==
"size"_L1 )
243 const float size = mShapeProperties.value( property ).toFloat();
252 if ( property ==
"radius"_L1 )
254 const float radius = mShapeProperties.value( property ).toFloat();
259 else if ( property ==
"minorRadius"_L1 )
261 const float minorRadius = mShapeProperties.value( property ).toFloat();
262 if ( minorRadius == 0 )
270 if ( property ==
"size"_L1 )
272 const float size = mShapeProperties.value( property ).toFloat();
281 if ( property ==
"depth"_L1 )
283 const float depth = mShapeProperties.value( property ).toFloat();
294 if ( property ==
"upAxis"_L1 )
296 return mShapeProperties.value( u
"upAxis"_s, u
"z"_s ).toString();
298 if ( property ==
"forwardAxis"_L1 )
300 return mShapeProperties.value( u
"forwardAxis"_s, u
"y"_s ).toString();
308 return mShapeProperties.value( property );
313 return mTransform.data()[14];
318 return mMaterialSettings.get();
333 Qt3DRender::QSceneLoader *sceneLoader = entity->findChild<Qt3DRender::QSceneLoader *>();
336 const QVector<Qgs3DExportObject *> objects = exporter->processSceneLoaderGeometries( sceneLoader, objectNamePrefix );
342 exporter->mObjects << objects;
346 const QList<Qt3DRender::QMesh *> meshes = entity->findChildren<Qt3DRender::QMesh *>();
347 for ( Qt3DRender::QMesh *mesh : meshes )
349 Qgs3DExportObject *
object = exporter->processGeometryRenderer( mesh, objectNamePrefix );
354 exporter->mObjects << object;
364 exporter->mObjects << obj;
370 const QVector<Qgs3DExportObject *> objects = exporter->processInstancedPointGeometry( entity, objectNamePrefix );
374 exporter->mObjects << obj;
383 return mBillboardSymbol.get();
388 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.
Basic shading material used for rendering based on the Phong shading model with three color component...
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.
QgsAbstractMaterialSettings * materialSettings() const
Returns material settings used for shading of the symbol.
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.
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.
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 setMaterialSettings(QgsAbstractMaterialSettings *materialSettings)
Sets the material settings used for shading of the symbol.
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.