33 std::unique_ptr< QgsLine3DSymbol > result = std::make_unique< QgsLine3DSymbol >();
34 result->mAltClamping = mAltClamping;
35 result->mAltBinding = mAltBinding;
36 result->mWidth = mWidth;
37 result->mHeight = mHeight;
38 result->mExtrusionHeight = mExtrusionHeight;
39 result->mRenderAsSimpleLines = mRenderAsSimpleLines;
40 result->mMaterial.reset( mMaterial->clone() );
41 copyBaseSettings( result.get() );
42 return result.release();
49 QDomDocument doc = elem.ownerDocument();
51 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
54 elemDataProperties.setAttribute( QStringLiteral(
"height" ), mHeight );
55 elemDataProperties.setAttribute( QStringLiteral(
"extrusion-height" ), mExtrusionHeight );
56 elemDataProperties.setAttribute( QStringLiteral(
"simple-lines" ), mRenderAsSimpleLines ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
57 elemDataProperties.setAttribute( QStringLiteral(
"width" ), mWidth );
58 elem.appendChild( elemDataProperties );
60 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterial->type() );
61 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
62 mMaterial->writeXml( elemMaterial, context );
63 elem.appendChild( elemMaterial );
70 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
73 mHeight = elemDataProperties.attribute( QStringLiteral(
"height" ) ).toFloat();
74 mExtrusionHeight = elemDataProperties.attribute( QStringLiteral(
"extrusion-height" ) ).toFloat();
75 mWidth = elemDataProperties.attribute( QStringLiteral(
"width" ) ).toFloat();
76 mRenderAsSimpleLines = elemDataProperties.attribute( QStringLiteral(
"simple-lines" ), QStringLiteral(
"0" ) ).toInt();
78 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
79 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
83 mMaterial->readXml( elemMaterial, context );
88 return mMaterial.get();
113 const QVector<Qgs3DExportObject *> objs = exporter->processLines( entity, objectNamePrefix );
114 exporter->mObjects << objs;
115 return objs.size() != 0;
119 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
120 for ( Qt3DRender::QGeometryRenderer *r : renderers )
122 Qgs3DExportObject *
object = exporter->processGeometryRenderer( r, objectNamePrefix );
123 if (
object ==
nullptr )
continue;
125 exporter->mObjects.push_back(
object );
127 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 QString altBindingToString(Qgs3DTypes::AltitudeBinding altBind)
Converts a value from AltitudeBinding enum to a string.
static QString altClampingToString(Qgs3DTypes::AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
static Qgs3DTypes::AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
static Qgs3DTypes::AltitudeBinding altBindingFromString(const QString &str)
Converts a string to a value from AltitudeBinding enum.
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.
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.
The class is used as a container of context for various read/write operations on other objects.