47 mTransform.rotate( QQuaternion::fromAxisAndAngle( QVector3D( 1, 0, 0 ), 90 ) );
51 : mAltClamping( other.altitudeClamping() )
52 , mMaterialSettings( other.materialSettings() ? other.materialSettings()->clone() : nullptr )
53 , mShape( other.shape() )
54 , mShapeProperties( other.shapeProperties() )
55 , mTransform( other.transform() )
56 , mBillboardSymbol( other.billboardSymbol() ? other.billboardSymbol()->clone() : nullptr )
65 QDomDocument doc = elem.ownerDocument();
67 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
69 elem.appendChild( elemDataProperties );
71 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterialSettings->type() );
72 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
73 mMaterialSettings->writeXml( elemMaterial, context );
74 elem.appendChild( elemMaterial );
76 elem.setAttribute( QStringLiteral(
"shape" ),
shapeToString( mShape ) );
78 QVariantMap shapePropertiesCopy( mShapeProperties );
79 shapePropertiesCopy[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
writePath( shapePropertiesCopy[QStringLiteral(
"model" )].toString() ) );
81 QDomElement elemShapeProperties = doc.createElement( QStringLiteral(
"shape-properties" ) );
83 elem.appendChild( elemShapeProperties );
85 QDomElement elemTransform = doc.createElement( QStringLiteral(
"transform" ) );
87 elem.appendChild( elemTransform );
93 elem.appendChild( symbolElem );
99 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
102 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
103 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
105 if ( !mMaterialSettings )
107 mMaterialSettings->readXml( elemMaterial, context );
109 mShape =
shapeFromString( elem.attribute( QStringLiteral(
"shape" ) ) );
111 const QDomElement elemShapeProperties = elem.firstChildElement( QStringLiteral(
"shape-properties" ) );
113 mShapeProperties[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
readPath( mShapeProperties[QStringLiteral(
"model" )].toString() ) );
115 const QDomElement elemTransform = elem.firstChildElement( QStringLiteral(
"transform" ) );
118 const QDomElement symbolElem = elem.firstChildElement( QStringLiteral(
"symbol" ) );
120 setBillboardSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( symbolElem, context ) );
133 mTransform.data()[13] =
static_cast<float>( props->
zOffset() );
139 if (
shape == QStringLiteral(
"sphere" ) )
141 else if (
shape == QLatin1String(
"cone" ) )
143 else if (
shape == QLatin1String(
"cube" ) )
145 else if (
shape == QLatin1String(
"torus" ) )
147 else if (
shape == QLatin1String(
"plane" ) )
149 else if (
shape == QLatin1String(
"extruded-text" ) )
151 else if (
shape == QLatin1String(
"model" ) )
153 else if (
shape == QLatin1String(
"billboard" ) )
164 return QStringLiteral(
"cylinder" );
166 return QStringLiteral(
"sphere" );
168 return QStringLiteral(
"cone" );
170 return QStringLiteral(
"cube" );
172 return QStringLiteral(
"torus" );
174 return QStringLiteral(
"plane" );
176 return QStringLiteral(
"extruded-text" );
178 return QStringLiteral(
"model" );
180 return QStringLiteral(
"billboard" );
193 if ( property == QLatin1String(
"length" ) )
195 const float length = mShapeProperties.value( property ).toFloat();
200 else if ( property == QLatin1String(
"radius" ) )
202 const float radius = mShapeProperties.value( property ).toFloat();
211 if ( property == QLatin1String(
"radius" ) )
213 const float radius = mShapeProperties.value( property ).toFloat();
222 if ( property == QLatin1String(
"length" ) )
224 const float length = mShapeProperties.value( property ).toFloat();
233 if ( property == QLatin1String(
"size" ) )
235 const float size = mShapeProperties.value( property ).toFloat();
244 if ( property == QLatin1String(
"radius" ) )
246 const float radius = mShapeProperties.value( property ).toFloat();
251 else if ( property == QLatin1String(
"minorRadius" ) )
253 const float minorRadius = mShapeProperties.value( property ).toFloat();
254 if ( minorRadius == 0 )
262 if ( property == QLatin1String(
"size" ) )
264 const float size = mShapeProperties.value( property ).toFloat();
273 if ( property == QLatin1String(
"depth" ) )
275 const float depth = mShapeProperties.value( property ).toFloat();
287 return mShapeProperties.value( property );
292 return mTransform.data()[14];
297 return mMaterialSettings.get();
312 Qt3DRender::QSceneLoader *sceneLoader = entity->findChild<Qt3DRender::QSceneLoader *>();
315 const QVector<Qgs3DExportObject *> objects = exporter->processSceneLoaderGeometries( sceneLoader, objectNamePrefix );
321 exporter->mObjects << objects;
325 const QList<Qt3DRender::QMesh *> meshes = entity->findChildren<Qt3DRender::QMesh *>();
326 for ( Qt3DRender::QMesh *mesh : meshes )
328 Qgs3DExportObject *
object = exporter->processGeometryRenderer( mesh, objectNamePrefix );
333 exporter->mObjects << object;
343 exporter->mObjects << obj;
349 const QVector<Qgs3DExportObject *> objects = exporter->processInstancedPointGeometry( entity, objectNamePrefix );
353 exporter->mObjects << obj;
362 return mBillboardSymbol.get();
367 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 scene.
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.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
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.
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.
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.
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.
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.
The class is used as a container of context for various read/write operations on other objects.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
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 data sets.
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.