18 #include <Qt3DCore/QEntity>
36 std::unique_ptr< QgsPolygon3DSymbol > result = std::make_unique< QgsPolygon3DSymbol >();
37 result->mAltClamping = mAltClamping;
38 result->mAltBinding = mAltBinding;
39 result->mHeight = mHeight;
40 result->mExtrusionHeight = mExtrusionHeight;
41 result->mMaterial.reset( mMaterial->clone() );
42 result->mCullingMode = mCullingMode;
43 result->mInvertNormals = mInvertNormals;
44 result->mAddBackFaces = mAddBackFaces;
45 result->mRenderedFacade = mRenderedFacade;
46 result->mEdgesEnabled = mEdgesEnabled;
47 result->mEdgeWidth = mEdgeWidth;
48 result->mEdgeColor = mEdgeColor;
49 copyBaseSettings( result.get() );
50 return result.release();
57 QDomDocument doc = elem.ownerDocument();
59 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
62 elemDataProperties.setAttribute( QStringLiteral(
"height" ), mHeight );
63 elemDataProperties.setAttribute( QStringLiteral(
"extrusion-height" ), mExtrusionHeight );
65 elemDataProperties.setAttribute( QStringLiteral(
"invert-normals" ), mInvertNormals ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
66 elemDataProperties.setAttribute( QStringLiteral(
"add-back-faces" ), mAddBackFaces ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
67 elemDataProperties.setAttribute( QStringLiteral(
"rendered-facade" ), mRenderedFacade );
68 elem.appendChild( elemDataProperties );
70 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterial->type() );
71 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
72 mMaterial->writeXml( elemMaterial, context );
73 elem.appendChild( elemMaterial );
75 QDomElement elemDDP = doc.createElement( QStringLiteral(
"data-defined-properties" ) );
76 mDataDefinedProperties.writeXml( elemDDP, propertyDefinitions() );
77 elem.appendChild( elemDDP );
79 QDomElement elemEdges = doc.createElement( QStringLiteral(
"edges" ) );
80 elemEdges.setAttribute( QStringLiteral(
"enabled" ), mEdgesEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
81 elemEdges.setAttribute( QStringLiteral(
"width" ), mEdgeWidth );
83 elem.appendChild( elemEdges );
90 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
93 mHeight = elemDataProperties.attribute( QStringLiteral(
"height" ) ).toFloat();
94 mExtrusionHeight = elemDataProperties.attribute( QStringLiteral(
"extrusion-height" ) ).toFloat();
96 mInvertNormals = elemDataProperties.attribute( QStringLiteral(
"invert-normals" ) ).toInt();
97 mAddBackFaces = elemDataProperties.attribute( QStringLiteral(
"add-back-faces" ) ).toInt();
98 mRenderedFacade = elemDataProperties.attribute( QStringLiteral(
"rendered-facade" ),
"3" ).toInt();
100 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
101 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
105 mMaterial->readXml( elemMaterial, context );
107 const QDomElement elemDDP = elem.firstChildElement( QStringLiteral(
"data-defined-properties" ) );
108 if ( !elemDDP.isNull() )
109 mDataDefinedProperties.readXml( elemDDP, propertyDefinitions() );
111 const QDomElement elemEdges = elem.firstChildElement( QStringLiteral(
"edges" ) );
112 if ( !elemEdges.isNull() )
114 mEdgesEnabled = elemEdges.attribute( QStringLiteral(
"enabled" ) ).toInt();
115 mEdgeWidth = elemEdges.attribute( QStringLiteral(
"width" ) ).toFloat();
132 return mMaterial.get();
145 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
146 for ( Qt3DRender::QGeometryRenderer *r : renderers )
148 Qgs3DExportObject *
object = exporter->processGeometryRenderer( r, objectNamePrefix );
149 if (
object ==
nullptr )
continue;
150 exporter->processEntityMaterial( entity,
object );
151 exporter->mObjects.push_back(
object );
153 return renderers.size() != 0;
Manages the data of each object of the scene (positions, normals, texture coordinates ....
Entity that handles the exporting of 3D scene.
static QString altBindingToString(Qgs3DTypes::AltitudeBinding altBind)
Converts a value from AltitudeBinding enum to a string.
static Qgs3DTypes::CullingMode cullingModeFromString(const QString &str)
Converts a string to a value from CullingMode enum.
static QString altClampingToString(Qgs3DTypes::AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
static QString cullingModeToString(Qgs3DTypes::CullingMode mode)
Converts a value from CullingMode 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.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
static QgsAbstract3DSymbol * create() SIP_FACTORY
Creates a new QgsPolygon3DSymbol.
QgsPolygon3DSymbol()
Constructor for QgsPolygon3DSymbol.
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
~QgsPolygon3DSymbol() 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 setMaterial(QgsAbstractMaterialSettings *material SIP_TRANSFER)
Sets the material settings used for shading of the symbol.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
QgsAbstractMaterialSettings * material() const
Returns material used for shading of the symbol.
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override
The class is used as a container of context for various read/write operations on other objects.
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)