37
37
PointEntity::PointEntity ( const Map3D &map, QgsVectorLayer *layer, const QgsPoint3DSymbol &symbol, Qt3DCore::QNode *parent )
38
38
: Qt3DCore::QEntity( parent )
39
39
{
40
- if ( symbol.shapeProperties [" shape" ].toString () == " model" )
40
+ if ( symbol.shapeProperties () [" shape" ].toString () == " model" )
41
41
{
42
42
Model3DPointEntityFactory::addEntitiesForSelectedPoints ( map, layer, symbol, this );
43
43
Model3DPointEntityFactory::addEntitiesForNotSelectedPoints ( map, layer, symbol, this );
@@ -80,12 +80,12 @@ Qt3DRender::QMaterial *InstancedPointEntityFactory::material( const QgsPoint3DSy
80
80
Qt3DRender::QParameter *specularParameter = new Qt3DRender::QParameter ( QStringLiteral ( " ks" ), QColor::fromRgbF ( 0 .01f , 0 .01f , 0 .01f , 1 .0f ) );
81
81
Qt3DRender::QParameter *shininessParameter = new Qt3DRender::QParameter ( QStringLiteral ( " shininess" ), 150 .0f );
82
82
83
- diffuseParameter->setValue ( symbol.material .diffuse () );
84
- ambientParameter->setValue ( symbol.material .ambient () );
85
- specularParameter->setValue ( symbol.material .specular () );
86
- shininessParameter->setValue ( symbol.material .shininess () );
83
+ diffuseParameter->setValue ( symbol.material () .diffuse () );
84
+ ambientParameter->setValue ( symbol.material () .ambient () );
85
+ specularParameter->setValue ( symbol.material () .specular () );
86
+ shininessParameter->setValue ( symbol.material () .shininess () );
87
87
88
- QMatrix4x4 transformMatrix = symbol.transform ;
88
+ QMatrix4x4 transformMatrix = symbol.transform () ;
89
89
QMatrix3x3 normalMatrix = transformMatrix.normalMatrix (); // transponed inverse of 3x3 sub-matrix
90
90
91
91
// QMatrix3x3 is not supported for passing to shaders, so we pass QMatrix4x4
@@ -198,19 +198,20 @@ Qt3DRender::QGeometryRenderer *InstancedPointEntityNode::renderer( const QgsPoin
198
198
instanceDataAttribute->setByteStride ( 3 * sizeof ( float ) );
199
199
200
200
Qt3DRender::QGeometry *geometry = nullptr ;
201
- QString shape = symbol.shapeProperties [" shape" ].toString ();
201
+ QVariantMap shapeProperties = symbol.shapeProperties ();
202
+ QString shape = shapeProperties[" shape" ].toString ();
202
203
if ( shape == " sphere" )
203
204
{
204
- float radius = symbol. shapeProperties [" radius" ].toFloat ();
205
+ float radius = shapeProperties[" radius" ].toFloat ();
205
206
Qt3DExtras::QSphereGeometry *g = new Qt3DExtras::QSphereGeometry;
206
207
g->setRadius ( radius ? radius : 10 );
207
208
geometry = g;
208
209
}
209
210
else if ( shape == " cone" )
210
211
{
211
- float length = symbol. shapeProperties [" length" ].toFloat ();
212
- float bottomRadius = symbol. shapeProperties [" bottomRadius" ].toFloat ();
213
- float topRadius = symbol. shapeProperties [" topRadius" ].toFloat ();
212
+ float length = shapeProperties[" length" ].toFloat ();
213
+ float bottomRadius = shapeProperties[" bottomRadius" ].toFloat ();
214
+ float topRadius = shapeProperties[" topRadius" ].toFloat ();
214
215
Qt3DExtras::QConeGeometry *g = new Qt3DExtras::QConeGeometry;
215
216
g->setLength ( length ? length : 10 );
216
217
g->setBottomRadius ( bottomRadius );
@@ -221,7 +222,7 @@ Qt3DRender::QGeometryRenderer *InstancedPointEntityNode::renderer( const QgsPoin
221
222
}
222
223
else if ( shape == " cube" )
223
224
{
224
- float size = symbol. shapeProperties [" size" ].toFloat ();
225
+ float size = shapeProperties[" size" ].toFloat ();
225
226
Qt3DExtras::QCuboidGeometry *g = new Qt3DExtras::QCuboidGeometry;
226
227
g->setXExtent ( size ? size : 10 );
227
228
g->setYExtent ( size ? size : 10 );
@@ -230,16 +231,16 @@ Qt3DRender::QGeometryRenderer *InstancedPointEntityNode::renderer( const QgsPoin
230
231
}
231
232
else if ( shape == " torus" )
232
233
{
233
- float radius = symbol. shapeProperties [" radius" ].toFloat ();
234
- float minorRadius = symbol. shapeProperties [" minorRadius" ].toFloat ();
234
+ float radius = shapeProperties[" radius" ].toFloat ();
235
+ float minorRadius = shapeProperties[" minorRadius" ].toFloat ();
235
236
Qt3DExtras::QTorusGeometry *g = new Qt3DExtras::QTorusGeometry;
236
237
g->setRadius ( radius ? radius : 10 );
237
238
g->setMinorRadius ( minorRadius ? minorRadius : 5 );
238
239
geometry = g;
239
240
}
240
241
else if ( shape == " plane" )
241
242
{
242
- float size = symbol. shapeProperties [" size" ].toFloat ();
243
+ float size = shapeProperties[" size" ].toFloat ();
243
244
Qt3DExtras::QPlaneGeometry *g = new Qt3DExtras::QPlaneGeometry;
244
245
g->setWidth ( size ? size : 10 );
245
246
g->setHeight ( size ? size : 10 );
@@ -248,8 +249,8 @@ Qt3DRender::QGeometryRenderer *InstancedPointEntityNode::renderer( const QgsPoin
248
249
#if QT_VERSION >= 0x050900
249
250
else if ( shape == " extrudedText" )
250
251
{
251
- float depth = symbol. shapeProperties [" depth" ].toFloat ();
252
- QString text = symbol. shapeProperties [" text" ].toString ();
252
+ float depth = shapeProperties[" depth" ].toFloat ();
253
+ QString text = shapeProperties[" text" ].toString ();
253
254
Qt3DExtras::QExtrudedTextGeometry *g = new Qt3DExtras::QExtrudedTextGeometry;
254
255
g->setDepth ( depth ? depth : 1 );
255
256
g->setText ( text );
@@ -258,8 +259,8 @@ Qt3DRender::QGeometryRenderer *InstancedPointEntityNode::renderer( const QgsPoin
258
259
#endif
259
260
else // shape == "cylinder" or anything else
260
261
{
261
- float radius = symbol. shapeProperties [" radius" ].toFloat ();
262
- float length = symbol. shapeProperties [" length" ].toFloat ();
262
+ float radius = shapeProperties[" radius" ].toFloat ();
263
+ float length = shapeProperties[" length" ].toFloat ();
263
264
Qt3DExtras::QCylinderGeometry *g = new Qt3DExtras::QCylinderGeometry;
264
265
// g->setRings(2); // how many vertices vertically
265
266
// g->setSlices(8); // how many vertices on circumference
@@ -284,10 +285,10 @@ static Qt3DExtras::QPhongMaterial *phongMaterial( const QgsPoint3DSymbol &symbol
284
285
{
285
286
Qt3DExtras::QPhongMaterial *phong = new Qt3DExtras::QPhongMaterial;
286
287
287
- phong->setAmbient ( symbol.material .ambient () );
288
- phong->setDiffuse ( symbol.material .diffuse () );
289
- phong->setSpecular ( symbol.material .specular () );
290
- phong->setShininess ( symbol.material .shininess () );
288
+ phong->setAmbient ( symbol.material () .ambient () );
289
+ phong->setDiffuse ( symbol.material () .diffuse () );
290
+ phong->setSpecular ( symbol.material () .specular () );
291
+ phong->setShininess ( symbol.material () .shininess () );
291
292
292
293
return phong;
293
294
}
@@ -312,7 +313,7 @@ void Model3DPointEntityFactory::addEntitiesForNotSelectedPoints( const Map3D &ma
312
313
notSelected.subtract ( layer->selectedFeatureIds () );
313
314
req.setFilterFids ( notSelected );
314
315
315
- if ( symbol.shapeProperties [" overwriteMaterial" ].toBool () )
316
+ if ( symbol.shapeProperties () [" overwriteMaterial" ].toBool () )
316
317
{
317
318
addMeshEntities ( map, layer, req, symbol, parent, false );
318
319
}
@@ -330,7 +331,7 @@ void Model3DPointEntityFactory::addSceneEntities( const Map3D &map, QgsVectorLay
330
331
// build the entity
331
332
Qt3DCore::QEntity *entity = new Qt3DCore::QEntity;
332
333
333
- QUrl url = QUrl::fromLocalFile ( symbol.shapeProperties [" model" ].toString () );
334
+ QUrl url = QUrl::fromLocalFile ( symbol.shapeProperties () [" model" ].toString () );
334
335
Qt3DRender::QSceneLoader *modelLoader = new Qt3DRender::QSceneLoader;
335
336
modelLoader->setSource ( url );
336
337
@@ -358,7 +359,7 @@ void Model3DPointEntityFactory::addMeshEntities( const Map3D &map, QgsVectorLaye
358
359
// build the entity
359
360
Qt3DCore::QEntity *entity = new Qt3DCore::QEntity;
360
361
361
- QUrl url = QUrl::fromLocalFile ( symbol.shapeProperties [" model" ].toString () );
362
+ QUrl url = QUrl::fromLocalFile ( symbol.shapeProperties () [" model" ].toString () );
362
363
Qt3DRender::QMesh *mesh = new Qt3DRender::QMesh;
363
364
mesh->setSource ( url );
364
365
@@ -372,7 +373,7 @@ void Model3DPointEntityFactory::addMeshEntities( const Map3D &map, QgsVectorLaye
372
373
Qt3DCore::QTransform *Model3DPointEntityFactory::transform ( const QVector3D &position, const QgsPoint3DSymbol &symbol )
373
374
{
374
375
Qt3DCore::QTransform *tr = new Qt3DCore::QTransform;
375
- tr->setMatrix ( symbol.transform );
376
+ tr->setMatrix ( symbol.transform () );
376
377
tr->setTranslation ( position + tr->translation () );
377
378
return tr;
378
379
}
0 commit comments