35 std::unique_ptr< QgsLine3DSymbol > result = std::make_unique< QgsLine3DSymbol >();
36 result->mAltClamping = mAltClamping;
37 result->mAltBinding = mAltBinding;
38 result->mWidth = mWidth;
39 result->mHeight = mHeight;
40 result->mExtrusionHeight = mExtrusionHeight;
41 result->mRenderAsSimpleLines = mRenderAsSimpleLines;
42 result->mMaterial.reset( mMaterial->clone() );
43 copyBaseSettings( result.get() );
44 return result.release();
51 QDomDocument doc = elem.ownerDocument();
53 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
56 elemDataProperties.setAttribute( QStringLiteral(
"height" ), mHeight );
57 elemDataProperties.setAttribute( QStringLiteral(
"extrusion-height" ), mExtrusionHeight );
58 elemDataProperties.setAttribute( QStringLiteral(
"simple-lines" ), mRenderAsSimpleLines ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
59 elemDataProperties.setAttribute( QStringLiteral(
"width" ), mWidth );
60 elem.appendChild( elemDataProperties );
62 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterial->type() );
63 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
64 mMaterial->writeXml( elemMaterial, context );
65 elem.appendChild( elemMaterial );
72 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
75 mHeight = elemDataProperties.attribute( QStringLiteral(
"height" ) ).toFloat();
76 mExtrusionHeight = elemDataProperties.attribute( QStringLiteral(
"extrusion-height" ) ).toFloat();
77 mWidth = elemDataProperties.attribute( QStringLiteral(
"width" ) ).toFloat();
78 mRenderAsSimpleLines = elemDataProperties.attribute( QStringLiteral(
"simple-lines" ), QStringLiteral(
"0" ) ).toInt();
80 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
81 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
85 mMaterial->readXml( elemMaterial, context );
90 return mMaterial.get();
111 mAltBinding = props->
binding();
113 mHeight =
static_cast< float >( props->
zOffset() );
125 const QVector<Qgs3DExportObject *> objs = exporter->processLines( entity, objectNamePrefix );
126 exporter->mObjects << objs;
127 return objs.size() != 0;
131 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
132 for ( Qt3DRender::QGeometryRenderer *r : renderers )
134 Qgs3DExportObject *
object = exporter->processGeometryRenderer( r, objectNamePrefix );
135 if (
object ==
nullptr )
continue;
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 scene.
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.
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override
bool renderAsSimpleLines() const
Returns whether the renderer will render data with simple lines (otherwise it uses buffer)
QgsLine3DSymbol()
Constructor for QgsLine3DSymbol.
void setDefaultPropertiesFromLayer(const QgsVectorLayer *layer) override
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
void setMaterial(QgsAbstractMaterialSettings *material SIP_TRANSFER)
Sets the material settings used for shading of the symbol.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
QgsAbstractMaterialSettings * material() const
Returns material used for shading of the symbol.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
~QgsLine3DSymbol() override
bool exportGeometries(Qgs3DSceneExporter *exporter, Qt3DCore::QEntity *entity, const QString &objectNamePrefix) const override SIP_SKIP
Exports the geometries contained within the hierarchy of entity.
static QgsAbstract3DSymbol * create() SIP_FACTORY
Creates a new QgsLine3DSymbol.
double zOffset() const
Returns the z offset, which is a fixed offset amount which should be added to z values from the layer...
The class is used as a container of context for various read/write operations on other 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 data sets.