34 auto result = std::make_unique<QgsLine3DSymbol>();
35 result->mAltClamping = mAltClamping;
36 result->mAltBinding = mAltBinding;
37 result->mWidth = mWidth;
38 result->mOffset = mOffset;
39 result->mExtrusionHeight = mExtrusionHeight;
40 result->mRenderAsSimpleLines = mRenderAsSimpleLines;
41 result->mMaterialSettings.reset( mMaterialSettings->clone() );
42 copyBaseSettings( result.get() );
43 return result.release();
50 QDomDocument doc = elem.ownerDocument();
52 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
55 elemDataProperties.setAttribute( QStringLiteral(
"offset" ), mOffset );
56 elemDataProperties.setAttribute( QStringLiteral(
"extrusion-height" ), mExtrusionHeight );
57 elemDataProperties.setAttribute( QStringLiteral(
"simple-lines" ), mRenderAsSimpleLines ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
58 elemDataProperties.setAttribute( QStringLiteral(
"width" ), mWidth );
59 elem.appendChild( elemDataProperties );
61 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterialSettings->type() );
62 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
63 mMaterialSettings->writeXml( elemMaterial, context );
64 elem.appendChild( elemMaterial );
71 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
74 mOffset = elemDataProperties.attribute( QStringLiteral(
"offset" ) ).toFloat();
75 mExtrusionHeight = elemDataProperties.attribute( QStringLiteral(
"extrusion-height" ) ).toFloat();
76 mWidth = elemDataProperties.attribute( QStringLiteral(
"width" ) ).toFloat();
77 mRenderAsSimpleLines = elemDataProperties.attribute( QStringLiteral(
"simple-lines" ), QStringLiteral(
"0" ) ).toInt();
79 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
80 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
82 if ( !mMaterialSettings )
84 mMaterialSettings->readXml( elemMaterial, context );
89 return mMaterialSettings.get();
110 mAltBinding = props->
binding();
112 mOffset =
static_cast<float>( props->
zOffset() );
124 const QVector<Qgs3DExportObject *> objs = exporter->processLines( entity, objectNamePrefix );
125 exporter->mObjects << objs;
126 return objs.size() != 0;
130 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
131 for ( Qt3DRender::QGeometryRenderer *r : renderers )
133 Qgs3DExportObject *
object = exporter->processGeometryRenderer( r, objectNamePrefix );
137 exporter->mObjects.push_back(
object );
139 return renderers.size() != 0;
Manages the data of each object of the scene (positions, normals, texture coordinates ....
void setupMaterial(QgsAbstractMaterialSettings *material)
Sets the material parameters (diffuse color, shininess...) from phong material.
Entity that handles the exporting of 3D scenes.
static Qgis::AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
static Qgis::AltitudeBinding altBindingFromString(const QString &str)
Converts a string to a value from AltitudeBinding enum.
static QString altClampingToString(Qgis::AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
static QString altBindingToString(Qgis::AltitudeBinding altBind)
Converts a value from AltitudeBinding enum to a string.
static QgsMaterialRegistry * materialRegistry()
Returns the material registry, used for managing 3D materials.
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Abstract base class for material settings.
bool renderAsSimpleLines() const
Returns whether the renderer will render data with simple lines (otherwise it uses buffer)
void setDefaultPropertiesFromLayer(const QgsVectorLayer *layer) override
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
~QgsLine3DSymbol() override
QList< Qgis::GeometryType > compatibleGeometryTypes() const override
bool exportGeometries(Qgs3DSceneExporter *exporter, Qt3DCore::QEntity *entity, const QString &objectNamePrefix) const override SIP_SKIP
Exports the geometries contained within the hierarchy of entity.
void setMaterialSettings(QgsAbstractMaterialSettings *materialSettings SIP_TRANSFER)
Sets the material settings used for shading of the symbol.
static QgsAbstract3DSymbol * create() SIP_FACTORY
Creates a new QgsLine3DSymbol.
QgsAbstractMaterialSettings * materialSettings() const
Returns material settings used for shading of the symbol.
double zOffset() const
Returns the z offset, which is a fixed offset amount which should be added to z values from the layer...
Basic shading material used for rendering based on the Phong shading model with three color component...
A container for the context for various read/write operations on objects.
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...
Qgis::AltitudeBinding binding() const
Returns the altitude binding method, which determines how altitude is bound to individual vertices in...
bool extrusionEnabled() const
Returns true if extrusion is enabled.
Represents a vector layer which manages a vector based dataset.