18#include <Qt3DCore/QEntity> 
   38  std::unique_ptr< QgsPolygon3DSymbol > result = std::make_unique< QgsPolygon3DSymbol >();
 
   39  result->mAltClamping = mAltClamping;
 
   40  result->mAltBinding = mAltBinding;
 
   41  result->mHeight = mHeight;
 
   42  result->mExtrusionHeight = mExtrusionHeight;
 
   43  result->mMaterialSettings.reset( mMaterialSettings->clone() );
 
   44  result->mCullingMode = mCullingMode;
 
   45  result->mInvertNormals = mInvertNormals;
 
   46  result->mAddBackFaces = mAddBackFaces;
 
   47  result->mRenderedFacade = mRenderedFacade;
 
   48  result->mEdgesEnabled = mEdgesEnabled;
 
   49  result->mEdgeWidth = mEdgeWidth;
 
   50  result->mEdgeColor = mEdgeColor;
 
   51  copyBaseSettings( result.get() );
 
   52  return result.release();
 
   59  QDomDocument doc = elem.ownerDocument();
 
   61  QDomElement elemDataProperties = doc.createElement( QStringLiteral( 
"data" ) );
 
   64  elemDataProperties.setAttribute( QStringLiteral( 
"height" ), mHeight );
 
   65  elemDataProperties.setAttribute( QStringLiteral( 
"extrusion-height" ), mExtrusionHeight );
 
   67  elemDataProperties.setAttribute( QStringLiteral( 
"invert-normals" ), mInvertNormals ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) );
 
   68  elemDataProperties.setAttribute( QStringLiteral( 
"add-back-faces" ), mAddBackFaces ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) );
 
   69  elemDataProperties.setAttribute( QStringLiteral( 
"rendered-facade" ), mRenderedFacade );
 
   70  elem.appendChild( elemDataProperties );
 
   72  elem.setAttribute( QStringLiteral( 
"material_type" ), mMaterialSettings->type() );
 
   73  QDomElement elemMaterial = doc.createElement( QStringLiteral( 
"material" ) );
 
   74  mMaterialSettings->writeXml( elemMaterial, context );
 
   75  elem.appendChild( elemMaterial );
 
   77  QDomElement elemDDP = doc.createElement( QStringLiteral( 
"data-defined-properties" ) );
 
   78  mDataDefinedProperties.writeXml( elemDDP, propertyDefinitions() );
 
   79  elem.appendChild( elemDDP );
 
   81  QDomElement elemEdges = doc.createElement( QStringLiteral( 
"edges" ) );
 
   82  elemEdges.setAttribute( QStringLiteral( 
"enabled" ), mEdgesEnabled ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) );
 
   83  elemEdges.setAttribute( QStringLiteral( 
"width" ), mEdgeWidth );
 
   85  elem.appendChild( elemEdges );
 
   92  const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral( 
"data" ) );
 
   95  mHeight = elemDataProperties.attribute( QStringLiteral( 
"height" ) ).toFloat();
 
   96  mExtrusionHeight = elemDataProperties.attribute( QStringLiteral( 
"extrusion-height" ) ).toFloat();
 
   98  mInvertNormals = elemDataProperties.attribute( QStringLiteral( 
"invert-normals" ) ).toInt();
 
   99  mAddBackFaces = elemDataProperties.attribute( QStringLiteral( 
"add-back-faces" ) ).toInt();
 
  100  mRenderedFacade = elemDataProperties.attribute( QStringLiteral( 
"rendered-facade" ), 
"3" ).toInt();
 
  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  const QDomElement elemDDP = elem.firstChildElement( QStringLiteral( 
"data-defined-properties" ) );
 
  110  if ( !elemDDP.isNull() )
 
  111    mDataDefinedProperties.readXml( elemDDP, propertyDefinitions() );
 
  113  const QDomElement elemEdges = elem.firstChildElement( QStringLiteral( 
"edges" ) );
 
  114  if ( !elemEdges.isNull() )
 
  116    mEdgesEnabled = elemEdges.attribute( QStringLiteral( 
"enabled" ) ).toInt();
 
  117    mEdgeWidth = elemEdges.attribute( QStringLiteral( 
"width" ) ).toFloat();
 
  124  return QList< Qgis::GeometryType >() << Qgis::GeometryType::Polygon;
 
  132  mAltBinding = props->
binding();
 
  140    mDataDefinedProperties.setProperty( PropertyExtrusionHeight, 
QgsProperty() );
 
  148    mDataDefinedProperties.setProperty( PropertyHeight, 
QgsProperty() );
 
  150  mHeight = 
static_cast< float >( props->
zOffset() );
 
  160  return mMaterialSettings.get();
 
  173  const QList<Qt3DCore::QEntity *> entities = entity->findChildren<Qt3DCore::QEntity *>( QString(), Qt::FindDirectChildrenOnly );
 
  174  if ( entities.isEmpty() )
 
  176    const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
 
  177    for ( Qt3DRender::QGeometryRenderer *renderer : renderers )
 
  179      Qgs3DExportObject *
object = exporter->processGeometryRenderer( renderer, objectNamePrefix );
 
  180      if ( 
object == 
nullptr ) 
continue;
 
  181      exporter->processEntityMaterial( entity, 
object );
 
  182      exporter->mObjects.push_back( 
object );
 
  184    return renderers.size() != 0;
 
  190    for ( Qt3DCore::QEntity *e : entities )
 
  192      if ( e->objectName().isEmpty() )
 
  193        prefix = objectNamePrefix;
 
  195        prefix = e->objectName() + 
"_";
 
Manages the data of each object of the scene (positions, normals, texture coordinates ....
 
Entity that handles the exporting of 3D scene.
 
static Qgs3DTypes::CullingMode cullingModeFromString(const QString &str)
Converts a string to a value from CullingMode enum.
 
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 cullingModeToString(Qgs3DTypes::CullingMode mode)
Converts a value from CullingMode enum to a string.
 
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.
 
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the object's property collection, used for data defined overrides.
 
@ ExtrusionHeight
Z offset.
 
double zOffset() const
Returns the z offset, which is a fixed offset amount which should be added to z values from the layer...
 
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
 
static QgsAbstract3DSymbol * create() SIP_FACTORY
Creates a new QgsPolygon3DSymbol.
 
QgsAbstractMaterialSettings * materialSettings() const
Returns material settings used for shading of the symbol.
 
QgsPolygon3DSymbol()
Constructor for QgsPolygon3DSymbol.
 
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
 
void setMaterialSettings(QgsAbstractMaterialSettings *materialSettings SIP_TRANSFER)
Sets the material settings used for shading of the symbol.
 
~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 setDefaultPropertiesFromLayer(const QgsVectorLayer *layer) override
 
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
 
QList< Qgis::GeometryType > compatibleGeometryTypes() const override
 
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
 
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
 
A store for object properties.
 
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)
 
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.