Skip to content

Commit 992d1e2

Browse files
authoredNov 10, 2017
Merge pull request #5587 from nyalldawson/3d
Fix 3d renderer does not work with multi-point layers
2 parents fb205b1 + c13dadf commit 992d1e2

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed
 

‎src/3d/qgs3dutils.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,15 @@ QList<QVector3D> Qgs3DUtils::positions( const Qgs3DMapSettings &map, QgsVectorLa
172172
continue;
173173

174174
const QgsAbstractGeometry *g = f.geometry().constGet();
175-
if ( const QgsPoint *pt = qgsgeometry_cast< const QgsPoint *>( g ) )
175+
for ( auto it = g->vertices_begin(); it != g->vertices_end(); ++it )
176176
{
177+
QgsPoint pt = *it;
177178
float geomZ = 0;
178-
if ( pt->is3D() )
179+
if ( pt.is3D() )
179180
{
180-
geomZ = pt->z();
181+
geomZ = pt.z();
181182
}
182-
float terrainZ = map.terrainGenerator()->heightAt( pt->x(), pt->y(), map ) * map.terrainVerticalScale();
183+
float terrainZ = map.terrainGenerator()->heightAt( pt.x(), pt.y(), map ) * map.terrainVerticalScale();
183184
float h;
184185
switch ( altClamp )
185186
{
@@ -193,11 +194,9 @@ QList<QVector3D> Qgs3DUtils::positions( const Qgs3DMapSettings &map, QgsVectorLa
193194
h = terrainZ + geomZ;
194195
break;
195196
}
196-
positions.append( QVector3D( pt->x() - map.originX(), h, -( pt->y() - map.originY() ) ) );
197+
positions.append( QVector3D( pt.x() - map.originX(), h, -( pt.y() - map.originY() ) ) );
197198
//qDebug() << positions.last();
198199
}
199-
else
200-
qDebug() << "not a point";
201200
}
202201

203202
return positions;

‎src/3d/qgs3dutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class _3D_EXPORT Qgs3DUtils
7575
static QMatrix4x4 stringToMatrix4x4( const QString &str );
7676

7777
/**
78-
* Calculates (x,y,z) position of point in the Point vector layers
78+
* Calculates (x,y,z) positions of a (multi)point in the Point vector layers
7979
*/
8080
static QList<QVector3D> positions( const Qgs3DMapSettings &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, AltitudeClamping altClamp );
8181

‎src/app/3d/qgsline3dsymbolwidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ QgsLine3DSymbolWidget::QgsLine3DSymbolWidget( QWidget *parent )
2323
{
2424
setupUi( this );
2525

26+
spinHeight->setClearValue( 0.0 );
27+
spinWidth->setClearValue( 0.0 );
28+
spinExtrusion->setClearValue( 0.0 );
29+
2630
setSymbol( QgsLine3DSymbol() );
2731

2832
connect( spinWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLine3DSymbolWidget::changed );

‎src/app/3d/qgspoint3dsymbolwidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ QgsPoint3DSymbolWidget::QgsPoint3DSymbolWidget( QWidget *parent )
2525
{
2626
setupUi( this );
2727

28+
spinTX->setClearValue( 0.0 );
29+
spinTY->setClearValue( 0.0 );
30+
spinTZ->setClearValue( 0.0 );
31+
spinSX->setClearValue( 1.0 );
32+
spinSY->setClearValue( 1.0 );
33+
spinSZ->setClearValue( 1.0 );
34+
spinRX->setClearValue( 0.0 );
35+
spinRY->setClearValue( 0.0 );
36+
spinRZ->setClearValue( 0.0 );
37+
2838
cboShape->addItem( tr( "Sphere" ), QgsPoint3DSymbol::Sphere );
2939
cboShape->addItem( tr( "Cylinder" ), QgsPoint3DSymbol::Cylinder );
3040
cboShape->addItem( tr( "Cube" ), QgsPoint3DSymbol::Cube );

‎src/app/3d/qgspolygon3dsymbolwidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ QgsPolygon3DSymbolWidget::QgsPolygon3DSymbolWidget( QWidget *parent )
2222
: QWidget( parent )
2323
{
2424
setupUi( this );
25+
spinHeight->setClearValue( 0.0 );
26+
spinExtrusion->setClearValue( 0.0 );
2527

2628
setSymbol( QgsPolygon3DSymbol(), nullptr );
2729

0 commit comments

Comments
 (0)
Please sign in to comment.