QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
56 bool prepare( const Qgs3DRenderContext &context, QSet<QString> &attributeNames, const QgsBox3D &chunkExtent ) override;
57 void processFeature( const QgsFeature &f, const Qgs3DRenderContext &context ) override;
58 void finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context ) override;
59
60 private:
62 struct PolygonData
63 {
64 std::unique_ptr<QgsTessellator> tessellator;
65 QVector<QgsFeatureId> triangleIndexFids;
66 QVector<uint> triangleIndexStartingIndices;
67 QByteArray materialDataDefined;
68 };
69
70 void processPolygon( const QgsPolygon *poly, QgsFeatureId fid, float offset, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out );
71 void processMaterialDatadefined( uint verticesCount, const QgsExpressionContext &context, PolygonData &out );
72 void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PolygonData &out, bool selected );
73 QgsMaterial *material( const QgsPolygon3DSymbol *symbol, bool isSelected, const Qgs3DRenderContext &context ) const;
74
75 // input specific for this class
76 std::unique_ptr<QgsPolygon3DSymbol> mSymbol;
77 // inputs - generic
78 QgsFeatureIds mSelectedIds;
79 // outputs
80 PolygonData outNormal;
81 PolygonData outSelected;
82
83 QgsLineVertexData outEdges;
84
86 bool mWasClippedToExtent = false;
87};
88
89
90bool QgsPolygon3DSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet<QString> &attributeNames, const QgsBox3D &chunkExtent )
91{
92 mChunkOrigin = chunkExtent.center();
93 mChunkOrigin.setZ( 0. ); // set the chunk origin to the bottom of the box, as the tessellator currently always considers origin z to be zero
94 mChunkExtent = chunkExtent;
95
96 outEdges.withAdjacency = true;
97 outEdges.init( mSymbol->altitudeClamping(), mSymbol->altitudeBinding(), 0, context, mChunkOrigin );
98
99 const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast<const QgsPhongTexturedMaterialSettings *>( mSymbol->materialSettings() );
100
101 auto tessellator = std::make_unique<QgsTessellator>();
102 tessellator->setOrigin( mChunkOrigin );
103 tessellator->setAddNormals( true );
104 tessellator->setInvertNormals( mSymbol->invertNormals() );
105 tessellator->setBackFacesEnabled( mSymbol->addBackFaces() );
106 tessellator->setOutputZUp( true );
107 tessellator->setExtrusionFaces( mSymbol->extrusionFaces() );
108 tessellator->setTextureRotation( texturedMaterialSettings ? static_cast<float>( texturedMaterialSettings->textureRotation() ) : 0.f );
109 tessellator->setAddTextureUVs( texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() );
110 tessellator->setOutputZUp( true );
111
112 outNormal.tessellator = std::move( tessellator );
113
114 tessellator = std::make_unique<QgsTessellator>();
115 tessellator->setOrigin( mChunkOrigin );
116 tessellator->setAddNormals( true );
117 tessellator->setInvertNormals( mSymbol->invertNormals() );
118 tessellator->setBackFacesEnabled( mSymbol->addBackFaces() );
119 tessellator->setOutputZUp( true );
120 tessellator->setExtrusionFaces( mSymbol->extrusionFaces() );
121 tessellator->setTextureRotation( texturedMaterialSettings ? static_cast<float>( texturedMaterialSettings->textureRotation() ) : 0.f );
122 tessellator->setAddTextureUVs( texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() );
123 tessellator->setOutputZUp( true );
124
125 outSelected.tessellator = std::move( tessellator );
126
127 QSet<QString> attrs = mSymbol->dataDefinedProperties().referencedFields( context.expressionContext() );
128 attributeNames.unite( attrs );
129 attrs = mSymbol->materialSettings()->dataDefinedProperties().referencedFields( context.expressionContext() );
130 attributeNames.unite( attrs );
131 return true;
132}
133
134void QgsPolygon3DSymbolHandler::processPolygon( const QgsPolygon *poly, QgsFeatureId fid, float offset, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out )
135{
136 std::unique_ptr<QgsPolygon> polyClone( poly->clone() );
137
138 if ( mSymbol->edgesEnabled() )
139 {
140 // add edges before the polygon gets the Z values modified because addLineString() does its own altitude handling
141 const QgsAbstractGeometry *exteriorRing = static_cast<const QgsLineString *>( polyClone->exteriorRing() );
142
143 // This geometry will take ownership of the cleaned exteriorRing abstract geom.
144 // We need this to live for as long as exteriorRing is used.
145 QgsGeometry cleanedExteriorRingGeometry;
146
147 if ( mWasClippedToExtent )
148 {
149 // if the polygon was clipped to the chunk extent, then we need to remove any part of the exterior ring that
150 // overlaps the chunk extent line, otherwise the chunk extents will appear as edges. Any interior rings
151 // that were intersected by the extent will now be part of the exterior ring of the clipped geometry.
152 const QVector< QgsPointXY > extentPoints {
153 { mChunkExtent.xMinimum(), mChunkExtent.yMinimum() },
154 { mChunkExtent.xMaximum(), mChunkExtent.yMinimum() },
155 { mChunkExtent.xMaximum(), mChunkExtent.yMaximum() },
156 { mChunkExtent.xMinimum(), mChunkExtent.yMaximum() },
157 { mChunkExtent.xMinimum(), mChunkExtent.yMinimum() }
158 };
159 auto extentLinestring = std::make_unique<QgsLineString>( extentPoints );
160
161 const QgsGeometry exteriorRingGeometry( exteriorRing->clone() );
162 // it should be safe to perform the diff without any tolerance, the extent line string is a simple rectangle (chunk perimeter)
163 cleanedExteriorRingGeometry = exteriorRingGeometry.difference( QgsGeometry( extentLinestring.release() ) );
164 // make sure the diff didn't produce some degenerate geometry
165 ( void ) cleanedExteriorRingGeometry.convertGeometryCollectionToSubclass( Qgis::GeometryType::Line );
166 exteriorRing = cleanedExteriorRingGeometry.constGet()->simplifiedTypeRef();
167 }
168
169 if ( const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( exteriorRing ) )
170 {
171 outEdges.addLineString( *line, offset );
172 }
173 // if geometry was clipped to the chunk extents, we might now have a multilinestring
174 else if ( const QgsMultiLineString *mline = qgsgeometry_cast<const QgsMultiLineString *>( exteriorRing ) )
175 {
176 for ( int i = 0; i < mline->numGeometries(); ++i )
177 {
178 const QgsLineString *line = mline->lineStringN( i );
179 outEdges.addLineString( *line, offset );
180 }
181 }
182
183 // if geometry was clipped to the chunk extents and the chunk extents intersected an interior ring, then
184 // that ring is now part of the exterior ring. Hence we don't need to treat interior rings any differently
185 for ( int i = 0; i < polyClone->numInteriorRings(); ++i )
186 outEdges.addLineString( *static_cast<const QgsLineString *>( polyClone->interiorRing( i ) ), offset );
187
188 if ( extrusionHeight != 0.f )
189 {
190 // add roof and wall edges
191
192 if ( const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( exteriorRing ) )
193 {
194 outEdges.addLineString( *line, extrusionHeight + offset );
195 outEdges.addVerticalLines( *line, extrusionHeight, offset );
196 }
197 // if geometry was clipped to the chunk extents, we might now have a multilinestring
198 else if ( const QgsMultiLineString *mline = qgsgeometry_cast<const QgsMultiLineString *>( exteriorRing ) )
199 {
200 for ( int i = 0; i < mline->numGeometries(); ++i )
201 {
202 const QgsLineString *line = mline->lineStringN( i );
203 outEdges.addLineString( *line, extrusionHeight + offset );
204 outEdges.addVerticalLines( *line, extrusionHeight, offset );
205 }
206 }
207
208 // if geometry was clipped to the chunk extents and the chunk extents intersected an interior ring, then
209 // that ring is now part of the exterior ring. Hence we don't need to treat interior rings any differently
210 for ( int i = 0; i < polyClone->numInteriorRings(); ++i )
211 {
212 const QgsLineString *interior = static_cast<const QgsLineString *>( polyClone->interiorRing( i ) );
213 outEdges.addLineString( *interior, extrusionHeight + offset );
214 outEdges.addVerticalLines( *interior, extrusionHeight, offset );
215 }
216 }
217 }
218
219 Qgs3DUtils::clampAltitudes( polyClone.get(), mSymbol->altitudeClamping(), mSymbol->altitudeBinding(), offset, context );
220
221 Q_ASSERT( out.tessellator->dataVerticesCount() % 3 == 0 );
222 const uint startingTriangleIndex = static_cast<uint>( out.tessellator->dataVerticesCount() / 3 );
223 out.triangleIndexStartingIndices.append( startingTriangleIndex );
224 out.triangleIndexFids.append( fid );
225
226 const size_t oldVertexCount = out.tessellator->uniqueVertexCount();
227 out.tessellator->addPolygon( *polyClone, extrusionHeight );
228 if ( !out.tessellator->error().isEmpty() )
229 {
230 QgsMessageLog::logMessage( out.tessellator->error(), QObject::tr( "3D" ) );
231 }
232
233 if ( mSymbol->materialSettings()->dataDefinedProperties().hasActiveProperties() )
234 {
235 const uint newUniqueVertices = out.tessellator->uniqueVertexCount() - oldVertexCount;
236 processMaterialDatadefined( newUniqueVertices, context.expressionContext(), out );
237 }
238}
239
240void QgsPolygon3DSymbolHandler::processMaterialDatadefined( uint verticesCount, const QgsExpressionContext &context, QgsPolygon3DSymbolHandler::PolygonData &out )
241{
242 const QByteArray bytes = mSymbol->materialSettings()->dataDefinedVertexColorsAsByte( context );
243 out.materialDataDefined.append( bytes.repeated( verticesCount ) );
244}
245
246void QgsPolygon3DSymbolHandler::processFeature( const QgsFeature &f, const Qgs3DRenderContext &context )
247{
248 if ( f.geometry().isNull() )
249 return;
250
251 PolygonData &out = mSelectedIds.contains( f.id() ) ? outSelected : outNormal;
252
253 QgsGeometry geom = f.geometry();
254 mWasClippedToExtent = clipGeometryIfTooLarge( geom );
255
256 if ( geom.isEmpty() )
257 return;
258
260
261 // segmentize curved geometries if necessary
263 {
264 geom = QgsGeometry( g->segmentize() );
265 g = geom.constGet()->simplifiedTypeRef();
266 }
267
268 const QgsPropertyCollection &ddp = mSymbol->dataDefinedProperties();
269 const bool hasDDHeight = ddp.isActive( QgsAbstract3DSymbol::Property::Height );
270 const bool hasDDExtrusion = ddp.isActive( QgsAbstract3DSymbol::Property::ExtrusionHeight );
271
272 float offset = mSymbol->offset();
273 float extrusionHeight = mSymbol->extrusionHeight();
274 if ( hasDDHeight )
275 offset = static_cast<float>( ddp.valueAsDouble( QgsAbstract3DSymbol::Property::Height, context.expressionContext(), offset ) );
276 if ( hasDDExtrusion )
277 extrusionHeight = ddp.valueAsDouble( QgsAbstract3DSymbol::Property::ExtrusionHeight, context.expressionContext(), extrusionHeight );
278
279 if ( const QgsPolygon *poly = qgsgeometry_cast<const QgsPolygon *>( g ) )
280 {
281 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
282 }
283 else if ( const QgsMultiPolygon *mpoly = qgsgeometry_cast<const QgsMultiPolygon *>( g ) )
284 {
285 for ( int i = 0; i < mpoly->numGeometries(); ++i )
286 {
287 const QgsPolygon *poly = mpoly->polygonN( i );
288 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
289 }
290 }
292 {
293 for ( int i = 0; i < gc->numGeometries(); ++i )
294 {
295 const QgsAbstractGeometry *g2 = gc->geometryN( i );
297 {
298 const QgsPolygon *poly = static_cast<const QgsPolygon *>( g2 );
299 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
300 }
301 }
302 }
303 else if ( const QgsPolyhedralSurface *polySurface = qgsgeometry_cast<const QgsPolyhedralSurface *>( g ) )
304 {
305 for ( int i = 0; i < polySurface->numPatches(); ++i )
306 {
307 const QgsPolygon *poly = polySurface->patchN( i );
308 processPolygon( poly, f.id(), offset, extrusionHeight, context, out );
309 }
310 }
311 else
312 qWarning() << "not a polygon";
313
314 mFeatureCount++;
315}
316
317void QgsPolygon3DSymbolHandler::finalize( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context )
318{
319 // create entity for selected and not selected
320 makeEntity( parent, context, outNormal, false );
321 makeEntity( parent, context, outSelected, true );
322
323 mZMin = std::min( outNormal.tessellator->zMinimum(), outSelected.tessellator->zMinimum() );
324 mZMax = std::max( outNormal.tessellator->zMaximum(), outSelected.tessellator->zMaximum() );
325
326 // add entity for edges, but not when doing highlighting
327 if ( mSymbol->edgesEnabled() && !outEdges.indexes.isEmpty() && !mHighlightingEnabled )
328 {
329 QgsLineMaterial *mat = new QgsLineMaterial;
330 mat->setLineColor( mSymbol->edgeColor() );
331 mat->setLineWidth( mSymbol->edgeWidth() );
332
333 Qt3DCore::QEntity *entity = new Qt3DCore::QEntity;
334 entity->setObjectName( parent->objectName() + "_EDGES" );
335
336 // geometry renderer
337 Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer;
338 renderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::LineStripAdjacency );
339 renderer->setGeometry( outEdges.createGeometry( entity ) );
340 renderer->setVertexCount( outEdges.indexes.count() );
341 renderer->setPrimitiveRestartEnabled( true );
342 renderer->setRestartIndexValue( 0 );
343
344 // add transform (our geometry has coordinates relative to mChunkOrigin)
345 QgsGeoTransform *tr = new QgsGeoTransform;
346 tr->setGeoTranslation( mChunkOrigin );
347
348 // make entity
349 entity->addComponent( renderer );
350 entity->addComponent( mat );
351 entity->addComponent( tr );
352 entity->setParent( parent );
353 }
354}
355
356
357void QgsPolygon3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PolygonData &polyData, bool selected )
358{
359 if ( polyData.tessellator->dataVerticesCount() == 0 )
360 return; // nothing to show - no need to create the entity
361
362 QgsMaterial *mat = material( mSymbol.get(), selected, context );
363
364 // extract vertex buffer data from tessellator
365 const QByteArray vertexBuffer = polyData.tessellator->vertexBuffer();
366 const QByteArray indexBuffer = polyData.tessellator->indexBuffer();
367 const int vertexCount = polyData.tessellator->uniqueVertexCount();
368 const size_t indexCount = polyData.tessellator->dataVerticesCount();
369
370 const QgsPhongTexturedMaterialSettings *texturedMaterialSettings = dynamic_cast<const QgsPhongTexturedMaterialSettings *>( mSymbol->materialSettings() );
371
373 = new QgsTessellatedPolygonGeometry( true, mSymbol->invertNormals(), mSymbol->addBackFaces(), texturedMaterialSettings && texturedMaterialSettings->requiresTextureCoordinates() );
374
375 geometry->setVertexBufferData( vertexBuffer, vertexCount, polyData.triangleIndexFids, polyData.triangleIndexStartingIndices );
376 geometry->setIndexBufferData( indexBuffer, indexCount );
377
378 if ( mSymbol->materialSettings()->dataDefinedProperties().hasActiveProperties() )
379 mSymbol->materialSettings()->applyDataDefinedToGeometry( geometry, vertexCount, polyData.materialDataDefined );
380 Qt3DRender::QGeometryRenderer *renderer = new Qt3DRender::QGeometryRenderer;
381 renderer->setGeometry( geometry );
382
383 // add transform (our geometry has coordinates relative to mChunkOrigin)
384 QgsGeoTransform *tr = new QgsGeoTransform;
385 tr->setGeoTranslation( mChunkOrigin );
386
387 // make entity
388 Qt3DCore::QEntity *entity = new Qt3DCore::QEntity;
389 entity->setObjectName( parent->objectName() + "_CHUNK_MESH" );
390 entity->addComponent( renderer );
391 entity->addComponent( mat );
392 entity->addComponent( tr );
393 entity->setParent( parent );
394
395 if ( !selected )
396 renderer->setProperty( Qgs3DTypes::PROP_NAME_3D_RENDERER_FLAG, Qgs3DTypes::Main3DRenderer ); // temporary measure to distinguish between "selected" and "main"
397
398 // cppcheck wrongly believes entity will leak
399 // cppcheck-suppress memleak
400}
401
402// front/back side culling
403static void applyCullingMode( Qgs3DTypes::CullingMode cullingMode, QgsMaterial *material )
404{
405 const auto techniques = material->effect()->techniques();
406 for ( auto tit = techniques.constBegin(); tit != techniques.constEnd(); ++tit )
407 {
408 auto renderPasses = ( *tit )->renderPasses();
409 for ( auto rpit = renderPasses.begin(); rpit != renderPasses.end(); ++rpit )
410 {
411 Qt3DRender::QCullFace *cullFace = new Qt3DRender::QCullFace;
412 cullFace->setMode( Qgs3DUtils::qt3DcullingMode( cullingMode ) );
413 ( *rpit )->addRenderState( cullFace );
414 }
415 }
416}
417
418QgsMaterial *QgsPolygon3DSymbolHandler::material( const QgsPolygon3DSymbol *symbol, bool isSelected, const Qgs3DRenderContext &context ) const
419{
420 QgsMaterialContext materialContext;
421 materialContext.setIsSelected( isSelected );
422 materialContext.setSelectionColor( context.selectionColor() );
423 materialContext.setIsHighlighted( mHighlightingEnabled );
424
425 const bool dataDefined = mSymbol->materialSettings()->dataDefinedProperties().hasActiveProperties();
426 QgsMaterial *material
428 applyCullingMode( symbol->cullingMode(), material );
429 return material;
430}
431
432
433// --------------
434
435
436namespace Qgs3DSymbolImpl
437{
438
439
440 QgsFeature3DHandler *handlerForPolygon3DSymbol( QgsVectorLayer *layer, const QgsAbstract3DSymbol *symbol )
441 {
442 const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast<const QgsPolygon3DSymbol *>( symbol );
443 if ( !polygonSymbol )
444 return nullptr;
445
446 return new QgsPolygon3DSymbolHandler( polygonSymbol, layer->selectedFeatureIds() );
447 }
448} // namespace Qgs3DSymbolImpl
449
@ Line
Lines.
Definition qgis.h:381
@ Polygon
Polygon.
Definition qgis.h:298
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:80
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