23 #include <Qt3DCore/QTransform> 24 #include <Qt3DRender/QEffect> 25 #include <Qt3DRender/QTechnique> 26 #include <Qt3DRender/QCullFace> 54 addEntityForSelectedPolygons( map, layer, symbol );
55 addEntityForNotSelectedPolygons( map, layer, symbol );
61 Qt3DExtras::QPhongMaterial *mat =
material( symbol );
68 Qt3DCore::QTransform *tform =
new Qt3DCore::QTransform;
69 tform->setTranslation( QVector3D( 0, 0, 0 ) );
78 QgsPolygon3DSymbolEntityNode *entity =
new QgsPolygon3DSymbolEntityNode( map, layer, symbol, req );
79 entity->addComponent( mat );
80 entity->addComponent( tform );
81 entity->setParent(
this );
87 Qt3DExtras::QPhongMaterial *mat =
material( symbol );
90 Qt3DCore::QTransform *tform =
new Qt3DCore::QTransform;
91 tform->setTranslation( QVector3D( 0, 0, 0 ) );
103 QgsPolygon3DSymbolEntityNode *entity =
new QgsPolygon3DSymbolEntityNode( map, layer, symbol, req );
104 entity->addComponent( mat );
105 entity->addComponent( tform );
106 entity->setParent(
this );
110 Qt3DExtras::QPhongMaterial *QgsPolygon3DSymbolEntity::material(
const QgsPolygon3DSymbol &symbol )
const 112 Qt3DExtras::QPhongMaterial *
material =
new Qt3DExtras::QPhongMaterial;
115 auto techniques = material->effect()->techniques();
116 for (
auto tit = techniques.constBegin(); tit != techniques.constEnd(); ++tit )
118 auto renderPasses = ( *tit )->renderPasses();
119 for (
auto rpit = renderPasses.begin(); rpit != renderPasses.end(); ++rpit )
121 Qt3DRender::QCullFace *cullFace =
new Qt3DRender::QCullFace;
123 ( *rpit )->addRenderState( cullFace );
137 addComponent( renderer( map, symbol, layer, req ) );
143 QList<QgsPolygon *> polygons;
144 QList<float> extrusionHeightPerPolygon;
173 if ( hasDDExtrusion )
176 if (
const QgsPolygon *poly = qgsgeometry_cast< const QgsPolygon *>( g ) )
180 polygons.append( polyClone );
181 if ( hasDDExtrusion )
182 extrusionHeightPerPolygon.append( extrusionHeight );
184 else if (
const QgsMultiPolygon *mpoly = qgsgeometry_cast< const QgsMultiPolygon *>( g ) )
186 for (
int i = 0; i < mpoly->numGeometries(); ++i )
192 polygons.append( polyClone );
193 if ( hasDDExtrusion )
194 extrusionHeightPerPolygon.append( extrusionHeight );
198 qDebug() <<
"not a polygon";
203 mGeometry->setPolygons( polygons, origin, symbol.
extrusionHeight(), extrusionHeightPerPolygon );
205 Qt3DRender::QGeometryRenderer *renderer =
new Qt3DRender::QGeometryRenderer;
206 renderer->setGeometry( mGeometry );
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
float height() const
Returns height (altitude) of the symbol (in map units)
Wrapper for iterator of features from vector data provider or vector layer.
float shininess() const
Returns shininess of the surface.
QColor selectionColor() const
Returns color used for selected features.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
void setInvertNormals(bool invert)
Sets whether the normals of triangles will be inverted (useful for fixing clockwise / counter-clockwi...
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double...
static void clampAltitudes(QgsLineString *lineString, AltitudeClamping altClamp, AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map)
Clamps altitude of vertices of a linestring according to the settings.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QSet< QgsFeatureId > QgsFeatureIds
QColor specular() const
Returns specular color component.
A class to represent a 2D point.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
3 3D symbol that draws polygon geometries as planar polygons, optionally extruded (with added walls)...
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides...
Extrusion height (zero means no extrusion)
A geometry is the spatial representation of a feature.
AltitudeClamping altitudeClamping() const
Returns method that determines altitude (whether to clamp to feature to terrain)
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsPhongMaterialSettings material() const
Returns material used for shading of the symbol.
double y() const
Returns Y coordinate.
3 Definition of the world
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0)
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
const QgsFeatureIds & selectedFeatureIds() const
Return reference to identifiers of selected features.
QgsFields fields() const override
Returns the list of fields of this layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
3 Class derived from Qt3DRender::QGeometry that represents polygons tessellated into 3D geometry...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Qt3DRender::QCullFace::CullingMode cullingMode() const
Returns front/back culling mode.
Abstract base class for all geometries.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
bool invertNormals() const
Returns whether the normals of triangles will be inverted (useful for fixing clockwise / counter-cloc...
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
AltitudeBinding altitudeBinding() const
Returns method that determines how altitude is bound to individual vertices.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const override
Returns the set of any fields referenced by the active properties from the collection.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Set feature IDs that should be fetched.
Multi polygon geometry collection.
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
QColor ambient() const
Returns ambient color component.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
QColor diffuse() const
Returns diffuse color component.
QgsAbstract3DSymbol * clone() const override
Returns a new instance of the symbol with the same settings.
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.
virtual QgsFeatureIds allFeatureIds() const
Returns a list of all feature IDs for features present in the source.
static Type flatType(Type type)
Returns the flat type for a WKB type.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
void setAmbient(const QColor &ambient)
Sets ambient color component.
double x() const
Returns X coordinate.
float extrusionHeight() const
Returns extrusion height (in map units)