QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
qgspolygon3dsymbol_p.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgspolygon3dsymbol_p.cpp
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgs3drendercontext.h"
19#include "qgs3dutils.h"
21#include "qgsgeotransform.h"
22#include "qgslinematerial_p.h"
23#include "qgslinestring.h"
24#include "qgslinevertexdata_p.h"
25#include "qgsmessagelog.h"
26#include "qgsmultilinestring.h"
27#include "qgsmultipolygon.h"
29#include "qgspolygon.h"
30#include "qgspolygon3dsymbol.h"
33#include "qgstessellator.h"
34#include "qgsvectorlayer.h"
35
36#include <Qt3DExtras/QDiffuseMapMaterial>
37#include <Qt3DExtras/QPhongMaterial>
38#include <Qt3DRender/QAbstractTextureImage>
39#include <Qt3DRender/QCullFace>
40#include <Qt3DRender/QEffect>
41#include <Qt3DRender/QGeometryRenderer>
42#include <Qt3DRender/QTechnique>
43#include <Qt3DRender/QTexture>
44
46
47
48class QgsPolygon3DSymbolHandler : public QgsFeature3DHandler
49{
50 public:
51 QgsPolygon3DSymbolHandler( const QgsPolygon3DSymbol *symbol, const QgsFeatureIds &selectedIds )
52 : mSymbol( static_cast<QgsPolygon3DSymbol *>( symbol->clone() ) )
53 , mSelectedIds( selectedIds ) {}
54
55 bool prepare( const Qgs3DRenderContext &context, QSet<QString> &attributeNames, const QgsBox3D &chunkExtent ) override;
56 void processFeature( const QgsFeature &f, const Qgs3DRenderContext &context ) override;
57 void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override;
58
59 private:
61 struct PolygonData
62 {
63 std::unique_ptr<QgsTessellator> tessellator;
64 QVector<QgsFeatureId> triangleIndexFids;
65 QVector<uint> triangleIndexStartingIndices;
66 QByteArray materialDataDefined;
67 };
68
69 void processPolygon( const QgsPolygon *poly, QgsFeatureId fid, float offset, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out );
70 void processMaterialDatadefined( uint verticesCount, const QgsExpressionContext &context, PolygonData &out );
71 void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PolygonData &out, bool selected );
72 QgsMaterial *material( const QgsPolygon3DSymbol *symbol, bool isSelected, const Qgs3DRenderContext &context ) const;
73
74 // input specific for this class
75 std::unique_ptr<QgsPolygon3DSymbol> mSymbol;
76 // inputs - generic
77 QgsFeatureIds mSelectedIds;
78 // outputs
79 PolygonData outNormal;
80 PolygonData outSelected;
81
82 QgsLineVertexData outEdges;
83
85 bool mWasClippedToExtent = false;
86};
87
88
89bool QgsPolygon3DSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet<QString> &attributeNames, const QgsBox3D &chunkExtent )
90{
91 mChunkOrigin = chunkExtent.center();
92 mChunkOrigin.setZ( 0. ); // set the chunk origin to the bottom of the box, as the tessellator currently always considers origin z to be zero
93 mChunkExtent = chunkExtent;
94
95 outEdges.withAdjacency = true;
96 outEdges.init( mSymbol->altitudeClamping(), mSymbol->altitudeBinding(), 0, context, mChunkOrigin );
97
98 const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast<const QgsPhongTexturedMaterialSettings *>( mSymbol->materialSettings() );
99
100 auto tessellator = std::make_unique<QgsTessellator>();
101 tessellator->setOrigin( mChunkOrigin );
102 tessellator->setAddNormals( true );
103 tessellator->setInvertNormals( mSymbol->invertNormals() );
104 tessellator->setBackFacesEnabled( mSymbol->addBackFaces() );
105 tessellator->setOutputZUp( true );
106 tessellator->setExtrusionFaces( mSymbol->extrusionFaces() );
107 tessellator->setTextureRotation( texturedMaterialSettings ? static_cast<float>( texturedMaterialSettings->textureRotation() ) : 0.f );
108 tessellator->setAddTextureUVs( texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() );
109 tessellator->setOutputZUp( true );
110
111 outNormal.tessellator = std::move( tessellator );
112
113 tessellator = std::make_unique<QgsTessellator>();
114 tessellator->setOrigin( mChunkOrigin );
115 tessellator->setAddNormals( true );
116 tessellator->setInvertNormals( mSymbol->invertNormals() );
117 tessellator->setBackFacesEnabled( mSymbol->addBackFaces() );
118 tessellator->setOutputZUp( true );
119 tessellator->setExtrusionFaces( mSymbol->extrusionFaces() );
120 tessellator->setTextureRotation( texturedMaterialSettings ? static_cast<float>( texturedMaterialSettings->textureRotation() ) : 0.f );
121 tessellator->setAddTextureUVs( texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() );
122 tessellator->setOutputZUp( true );
123
124 outSelected.tessellator = std::move( tessellator );
125
126 QSet<QString> attrs = mSymbol->dataDefinedProperties().referencedFields( context.expressionContext() );
127 attributeNames.unite( attrs );
128 attrs = mSymbol->materialSettings()->dataDefinedProperties().referencedFields( context.expressionContext() );
129 attributeNames.unite( attrs );
130 return true;
131}
132
133void QgsPolygon3DSymbolHandler::processPolygon( const QgsPolygon *poly, QgsFeatureId fid, float offset, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out )
134{
135 std::unique_ptr<QgsPolygon> polyClone( poly->clone() );
136
137 if ( mSymbol->edgesEnabled() )
138 {
139 // add edges before the polygon gets the Z values modified because addLineString() does its own altitude handling
140 const QgsAbstractGeometry *exteriorRing = static_cast<const QgsLineString *>( polyClone->exteriorRing() );
141
142 // This geometry will take ownership of the cleaned exteriorRing abstract geom.
143 // We need this to live for as long as exteriorRing is used.
144 QgsGeometry cleanedExteriorRingGeometry;
145
146 if ( mWasClippedToExtent )
147 {
148 // if the polygon was clipped to the chunk extent, then we need to remove any part of the exterior ring that
149 // overlaps the chunk extent line, otherwise the chunk extents will appear as edges. Any interior rings
150 // that were intersected by the extent will now be part of the exterior ring of the clipped geometry.
151 const QVector< QgsPointXY > extentPoints {
152 { mChunkExtent.xMinimum(), mChunkExtent.yMinimum() },
153 { mChunkExtent.xMaximum(), mChunkExtent.yMinimum() },
154 { mChunkExtent.xMaximum(), mChunkExtent.yMaximum() },
155 { mChunkExtent.xMinimum(), mChunkExtent.yMaximum() },
156 { mChunkExtent.xMinimum(), mChunkExtent.yMinimum() }
157 };
158 auto extentLinestring = std::make_unique<QgsLineString>( extentPoints );
159
160 const QgsGeometry exteriorRingGeometry( exteriorRing->clone() );
161 // it should be safe to perform the diff without any tolerance, the extent line string is a simple rectangle (chunk perimeter)
162 cleanedExteriorRingGeometry = exteriorRingGeometry.difference( QgsGeometry( extentLinestring.release() ) );
163 // make sure the diff didn't produce some degenerate geometry
164 ( void ) cleanedExteriorRingGeometry.convertGeometryCollectionToSubclass( Qgis::GeometryType::Line );
165 exteriorRing = cleanedExteriorRingGeometry.constGet()->simplifiedTypeRef();
166 }
167
168 if ( const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( exteriorRing ) )
169 {
170 outEdges.addLineString( *line, offset );
171 }
172 // if geometry was clipped to the chunk extents, we might now have a multilinestring
173 else if ( const QgsMultiLineString *mline = qgsgeometry_cast<const QgsMultiLineString *>( exteriorRing ) )
174 {
175 for ( int i = 0; i < mline->numGeometries(); ++i )
176 {
177 const QgsLineString *line = mline->lineStringN( i );
178 outEdges.addLineString( *line, offset );
179 }
180 }
181
182 // if geometry was clipped to the chunk extents and the chunk extents intersected an interior ring, then
183 // that ring is now part of the exterior ring. Hence we don't need to treat interior rings any differently
184 for ( int i = 0; i < polyClone->numInteriorRings(); ++i )
185 outEdges.addLineString( *static_cast<const QgsLineString *>( polyClone->interiorRing( i ) ), offset );
186
187 if ( extrusionHeight != 0.f )
188 {
189 // add roof and wall edges
190
191 if ( const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( exteriorRing ) )
192 {
193 outEdges.addLineString( *line, extrusionHeight + offset );
194 outEdges.addVerticalLines( *line, extrusionHeight, offset );
195 }
196 // if geometry was clipped to the chunk extents, we might now have a multilinestring
197 else if ( const QgsMultiLineString *mline = qgsgeometry_cast<const QgsMultiLineString *>( exteriorRing ) )
198 {
199 for ( int i = 0; i < mline->numGeometries(); ++i )
200 {
201 const QgsLineString *line = mline->lineStringN( i );
202 outEdges.addLineString( *line, extrusionHeight + offset );
203 outEdges.addVerticalLines( *line, extrusionHeight, offset );
204 }
205 }
206
207 // if geometry was clipped to the chunk extents and the chunk extents intersected an interior ring, then
208 // that ring is now part of the exterior ring. Hence we don't need to treat interior rings any differently
209 for ( int i = 0; i < polyClone->numInteriorRings(); ++i )
210 {
211 const QgsLineString *interior = static_cast<const QgsLineString *>( polyClone->interiorRing( i ) );
212 outEdges.addLineString( *interior, extrusionHeight + offset );
213 outEdges.addVerticalLines( *interior, extrusionHeight, offset );
214 }
215 }
216 }
217
218 Qgs3DUtils::clampAltitudes( polyClone.get(), mSymbol->altitudeClamping(), mSymbol->altitudeBinding(), offset, context );
219
220 Q_ASSERT( out.tessellator->dataVerticesCount() % 3 == 0 );
221 const uint startingTriangleIndex = static_cast<uint>( out.tessellator->dataVerticesCount() / 3 );
222 out.triangleIndexStartingIndices.append( startingTriangleIndex );
223 out.triangleIndexFids.append( fid );
224
225 const size_t oldVertexCount = out.tessellator->uniqueVertexCount();
226 out.tessellator->addPolygon( *polyClone, extrusionHeight );
227 if ( !out.tessellator->error().isEmpty() )
228 {
229 QgsMessageLog::logMessage( out.tessellator->error(), QObject::tr( "3D" ) );
230 }
231
232 if ( mSymbol->materialSettings()->dataDefinedProperties().hasActiveProperties() )
233 {
234 const uint newUniqueVertices = out.tessellator->uniqueVertexCount() - oldVertexCount;
235 processMaterialDatadefined( newUniqueVertices, context.expressionContext(), out );
236 }
237}
238
239void QgsPolygon3DSymbolHandler::processMaterialDatadefined( uint verticesCount, const QgsExpressionContext &context, QgsPolygon3DSymbolHandler::PolygonData &out )
240{
241 const QByteArray bytes = mSymbol->materialSettings()->dataDefinedVertexColorsAsByte( context );
242 out.materialDataDefined.append( bytes.repeated( verticesCount ) );
243}
244
245void QgsPolygon3DSymbolHandler::processFeature( const QgsFeature &f, const Qgs3DRenderContext &context )
246{
247 if ( f.geometry().isNull() )
248 return;
249
250 PolygonData &out = mSelectedIds.contains( f.id() ) ? outSelected : outNormal;
251
252 QgsGeometry geom = f.geometry();
253 mWasClippedToExtent = clipGeometryIfTooLarge( geom );
254
255 if ( geom.isEmpty() )
256 return;
257
259
260 // segmentize curved geometries if necessary
262 {
263 geom = QgsGeometry( g->segmentize() );
264 g = geom.constGet()->simplifiedTypeRef();
265 }
266
267 const QgsPropertyCollection &ddp = mSymbol->dataDefinedProperties();
268 const bool hasDDHeight = ddp.isActive( QgsAbstract3DSymbol::Property::Height );
269 const bool hasDDExtrusion = ddp.isActive( QgsAbstract3DSymbol::Property::ExtrusionHeight );
270
271 float offset = mSymbol->offset();
272 float extrusionHeight = mSymbol->extrusionHeight();
273 if ( hasDDHeight )
274 offset = static_cast<float>( ddp.valueAsDouble( QgsAbstract3DSymbol::Property::Height, context.expressionContext(), offset ) );
275 if ( hasDDExtrusion )
276 extrusionHeight = ddp.valueAsDouble( QgsAbstract3DSymbol::Property::ExtrusionHeight, context.expressionContext(), extrusionHeight );
277
278 if ( const QgsPolygon *poly = qgsgeometry_cast<const QgsPolygon *>( g ) )
279 {
280 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
281 }
282 else if ( const QgsMultiPolygon *mpoly = qgsgeometry_cast<const QgsMultiPolygon *>( g ) )
283 {
284 for ( int i = 0; i < mpoly->numGeometries(); ++i )
285 {
286 const QgsPolygon *poly = mpoly->polygonN( i );
287 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
288 }
289 }
291 {
292 for ( int i = 0; i < gc->numGeometries(); ++i )
293 {
294 const QgsAbstractGeometry *g2 = gc->geometryN( i );
296 {
297 const QgsPolygon *poly = static_cast<const QgsPolygon *>( g2 );
298 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
299 }
300 }
301 }
302 else if ( const QgsPolyhedralSurface *polySurface = qgsgeometry_cast<const QgsPolyhedralSurface *>( g ) )
303 {
304 for ( int i = 0; i < polySurface->numPatches(); ++i )
305 {
306 const QgsPolygon *poly = polySurface->patchN( i );
307 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
308 }
309 }
310 else
311 qWarning() << "not a polygon";
312
313 mFeatureCount++;
314}
315
316void QgsPolygon3DSymbolHandler::finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context )
317{
318 // create entity for selected and not selected
319 makeEntity( parent, context, outNormal, false );
320 makeEntity( parent, context, outSelected, true );
321
322 mZMin = std::min( outNormal.tessellator->zMinimum(), outSelected.tessellator->zMinimum() );
323 mZMax = std::max( outNormal.tessellator->zMaximum(), outSelected.tessellator->zMaximum() );
324
325 // add entity for edges, but not when doing highlighting
326 if ( mSymbol->edgesEnabled() && !outEdges.indexes.isEmpty() && !mHighlightingEnabled )
327 {
328 QgsLineMaterial *mat = new QgsLineMaterial;
329 mat->setLineColor( mSymbol->edgeColor() );
330 mat->setLineWidth( mSymbol->edgeWidth() );
331
332 Qt3DCore::QEntity *entity = new Qt3DCore::QEntity;
333 entity->setObjectName( parent->objectName() + "_EDGES" );
334
335 // geometry renderer
336 Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer;
337 renderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::LineStripAdjacency );
338 renderer->setGeometry( outEdges.createGeometry( entity ) );
339 renderer->setVertexCount( outEdges.indexes.count() );
340 renderer->setPrimitiveRestartEnabled( true );
341 renderer->setRestartIndexValue( 0 );
342
343 // add transform (our geometry has coordinates relative to mChunkOrigin)
344 QgsGeoTransform *tr = new QgsGeoTransform;
345 tr->setGeoTranslation( mChunkOrigin );
346
347 // make entity
348 entity->addComponent( renderer );
349 entity->addComponent( mat );
350 entity->addComponent( tr );
351 entity->setParent( parent );
352 }
353}
354
355
356void QgsPolygon3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PolygonData &polyData, bool selected )
357{
358 if ( polyData.tessellator->dataVerticesCount() == 0 )
359 return; // nothing to show - no need to create the entity
360
361 QgsMaterial *mat = material( mSymbol.get(), selected, context );
362
363 // extract vertex buffer data from tessellator
364 const QByteArray vertexBuffer = polyData.tessellator->vertexBuffer();
365 const QByteArray indexBuffer = polyData.tessellator->indexBuffer();
366 const int vertexCount = polyData.tessellator->uniqueVertexCount();
367 const size_t indexCount = polyData.tessellator->dataVerticesCount();
368
369 const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast<const QgsPhongTexturedMaterialSettings *>( mSymbol->materialSettings() );
370
371 QgsTessellatedPolygonGeometry *geometry = new QgsTessellatedPolygonGeometry( true, mSymbol->invertNormals(), mSymbol->addBackFaces(), texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() );
372
373 geometry->setVertexBufferData( vertexBuffer, vertexCount, polyData.triangleIndexFids, polyData.triangleIndexStartingIndices );
374 geometry->setIndexBufferData( indexBuffer, indexCount );
375
376 if ( mSymbol->materialSettings()->dataDefinedProperties().hasActiveProperties() )
377 mSymbol->materialSettings()->applyDataDefinedToGeometry( geometry, vertexCount, polyData.materialDataDefined );
378 Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer;
379 renderer->setGeometry( geometry );
380
381 // add transform (our geometry has coordinates relative to mChunkOrigin)
382 QgsGeoTransform *tr = new QgsGeoTransform;
383 tr->setGeoTranslation( mChunkOrigin );
384
385 // make entity
386 Qt3DCore::QEntity *entity = new Qt3DCore::QEntity;
387 entity->setObjectName( parent->objectName() + "_CHUNK_MESH" );
388 entity->addComponent( renderer );
389 entity->addComponent( mat );
390 entity->addComponent( tr );
391 entity->setParent( parent );
392
393 if ( !selected )
394 renderer->setProperty( Qgs3DTypes::PROP_NAME_3D_RENDERER_FLAG, Qgs3DTypes::Main3DRenderer ); // temporary measure to distinguish between "selected" and "main"
395
396 // cppcheck wrongly believes entity will leak
397 // cppcheck-suppress memleak
398}
399
400// front/back side culling
401static void applyCullingMode( Qgs3DTypes::CullingMode cullingMode, QgsMaterial *material )
402{
403 const auto techniques = material->effect()->techniques();
404 for ( auto tit = techniques.constBegin(); tit != techniques.constEnd(); ++tit )
405 {
406 auto renderPasses = ( *tit )->renderPasses();
407 for ( auto rpit = renderPasses.begin(); rpit != renderPasses.end(); ++rpit )
408 {
409 Qt3DRender::QCullFace *cullFace = new Qt3DRender::QCullFace;
410 cullFace->setMode( Qgs3DUtils::qt3DcullingMode( cullingMode ) );
411 ( *rpit )->addRenderState( cullFace );
412 }
413 }
414}
415
416QgsMaterial *QgsPolygon3DSymbolHandler::material( const QgsPolygon3DSymbol *symbol, bool isSelected, const Qgs3DRenderContext &context ) const
417{
418 QgsMaterialContext materialContext;
419 materialContext.setIsSelected( isSelected );
420 materialContext.setSelectionColor( context.selectionColor() );
421 materialContext.setIsHighlighted( mHighlightingEnabled );
422
423 const bool dataDefined = mSymbol->materialSettings()->dataDefinedProperties().hasActiveProperties();
425 applyCullingMode( symbol->cullingMode(), material );
426 return material;
427}
428
429
430// --------------
431
432
433namespace Qgs3DSymbolImpl
434{
435
436
437 QgsFeature3DHandler *handlerForPolygon3DSymbol( QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol )
438 {
439 const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast<const QgsPolygon3DSymbol *>( symbol );
440 if ( !polygonSymbol )
441 return nullptr;
442
443 return new QgsPolygon3DSymbolHandler( polygonSymbol, layer->selectedFeatureIds() );
444 }
445} // namespace Qgs3DSymbolImpl
446
@ Line
Lines.
Definition qgis.h:378
@ Polygon
Polygon.
Definition qgis.h:295
Rendering context for preparation of 3D entities.
QColor selectionColor() const
Returns color used for selected features.
QgsExpressionContext & expressionContext()
Gets the expression context.
@ Main3DRenderer
Renderer for normal entities.
Definition qgs3dtypes.h:48
static const char * PROP_NAME_3D_RENDERER_FLAG
Qt property name to hold the 3D geometry renderer flag.
Definition qgs3dtypes.h:43
CullingMode
Triangle culling mode.
Definition qgs3dtypes.h:35
static Qt3DRender::QCullFace::CullingMode qt3DcullingMode(Qgs3DTypes::CullingMode mode)
Converts Qgs3DTypes::CullingMode mode into its Qt3D equivalent.
static void clampAltitudes(QgsLineString *lineString, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, const QgsPoint &centroid, float offset, const Qgs3DRenderContext &context)
Clamps altitude of vertices of a linestring according to the settings.
@ ExtrusionHeight
Extrusion height (zero means no extrusion).
Abstract base class for all geometries.
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
virtual QgsMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QgsMaterial object representing the material settings.
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.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
QgsVector3D center() const
Returns the center of the box as a vector.
Definition qgsbox3d.cpp:124
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
QgsFeatureId id
Definition qgsfeature.h:68
QgsGeometry geometry
Definition qgsfeature.h:71
A geometry is the spatial representation of a feature.
QgsGeometry difference(const QgsGeometry &geometry, const QgsGeometryParameters &parameters=QgsGeometryParameters()) const
Returns a geometry representing the points making up this geometry that do not make up other.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
bool convertGeometryCollectionToSubclass(Qgis::GeometryType geomType)
Converts geometry collection to a the desired geometry type subclass (multi-point,...
Line string geometry type, with support for z-dimension and m-values.
Context settings for a material.
void setIsSelected(bool isSelected)
Sets whether the material should represent a selected state.
void setSelectionColor(const QColor &color)
Sets the color for representing materials in a selected state.
void setIsHighlighted(bool isHighlighted)
Sets whether the material should represent a highlighted state.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:40
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
Multi line string geometry collection.
Multi polygon geometry collection.
A Phong shading model with diffuse texture map.
bool requiresTextureCoordinates() const
Returns true if the material requires texture coordinates to be generated during triangulation....
double textureRotation() const
Returns the texture rotation, in degrees.
3D symbol that draws polygon geometries as planar polygons, optionally extruded (with added walls).
QgsAbstractMaterialSettings * materialSettings() const
Returns material settings used for shading of the symbol.
Qgs3DTypes::CullingMode cullingMode() const
Returns front/back culling mode.
Polygon geometry type.
Definition qgspolygon.h:37
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
Polyhedral surface geometry type.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
Qt3DRender::QGeometry subclass that represents polygons tessellated into 3D geometry.
void setVertexBufferData(const QByteArray &vertexBufferData, int vertexCount, const QVector< QgsFeatureId > &triangleIndexFids, const QVector< uint > &triangleIndexStartingIndices)
Initializes vertex buffer (and other members) from data that were already tessellated.
void setIndexBufferData(const QByteArray &indexBufferData, size_t indexCount)
Sets index buffer data.
void setZ(double z)
Sets Z coordinate.
Definition qgsvector3d.h:72
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
static Q_INVOKABLE bool isCurvedType(Qgis::WkbType type)
Returns true if the WKB type is a curved type or can contain curved geometries.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
@ Triangles
Triangle based rendering (default).
@ TrianglesDataDefined
Triangle based rendering with possibility of datadefined color.
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features