Skip to content

Commit 7389588

Browse files
committed
More class documentation
1 parent d91ebe2 commit 7389588

15 files changed

+168
-89
lines changed

python/core/3d/qgsabstract3drenderer.sip

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
/************************************************************************
22
* This file has been generated automatically from *
33
* *
4-
* src/core/./3d/qgsabstract3drenderer.h *
4+
* src/core/3d/qgsabstract3drenderer.h *
55
* *
66
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
77
************************************************************************/
88

99

1010

1111

12-
namespace Qt3DCore
13-
{
14-
}
1512

1613
class QgsAbstract3DRenderer
1714
{
@@ -62,7 +59,7 @@ Resolves references to other objects - second phase of loading - after readXml()
6259
/************************************************************************
6360
* This file has been generated automatically from *
6461
* *
65-
* src/core/./3d/qgsabstract3drenderer.h *
62+
* src/core/3d/qgsabstract3drenderer.h *
6663
* *
6764
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
6865
************************************************************************/

src/3d/qgs3dmapsettings.h

+50-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ class QgsProject;
2222

2323
class QDomElement;
2424

25-
//! Definition of the world
25+
/** \ingroup 3d
26+
* Definition of the world
27+
*
28+
* \since QGIS 3.0
29+
*/
2630
class _3D_EXPORT Qgs3DMapSettings : public QObject
2731
{
2832
Q_OBJECT
@@ -31,42 +35,71 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject
3135
Qgs3DMapSettings( const Qgs3DMapSettings &other );
3236
~Qgs3DMapSettings();
3337

38+
//! Reads configuration from a DOM element previously written by writeXml()
3439
void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
35-
40+
//! Writes configuration to a DOM element, to be used later with readXml()
3641
QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
37-
42+
//! Resolves references to other objects (map layers) after the call to readXml()
3843
void resolveReferences( const QgsProject &project );
3944

4045
double originX, originY, originZ; //!< Coordinates in map CRS at which our 3D world has origin (0,0,0)
4146
QgsCoordinateReferenceSystem crs; //!< Destination coordinate system of the world (TODO: not needed? can be
4247

48+
//! Sets background color of the 3D map view
4349
void setBackgroundColor( const QColor &color );
50+
//! Returns background color of the 3D map view
4451
QColor backgroundColor() const;
4552

53+
//! Sets color used for selected features
4654
void setSelectionColor( const QColor &color );
55+
//! Returns color used for selected features
4756
QColor selectionColor() const;
4857

4958
//
5059
// terrain related config
5160
//
5261

62+
//! Sets vertical scale (exaggeration) of terrain
63+
//! (1 = true scale, > 1 = hills get more pronounced)
5364
void setTerrainVerticalScale( double zScale );
65+
//! Returns vertical scale (exaggeration) of terrain
5466
double terrainVerticalScale() const;
5567

68+
//! Sets the list of map layers to be rendered as a texture of the terrain
5669
void setLayers( const QList<QgsMapLayer *> &layers );
70+
//! Returns the list of map layers to be rendered as a texture of the terrain
5771
QList<QgsMapLayer *> layers() const;
5872

73+
//! Sets resolution (in pixels) of the texture of a terrain tile
74+
//! \sa mapTileResolution()
5975
void setMapTileResolution( int res );
76+
//! Returns resolution (in pixels) of the texture of a terrain tile. This parameter influences
77+
//! how many zoom levels for terrain tiles there will be (together with maxTerrainGroundError())
6078
int mapTileResolution() const;
6179

80+
//! Sets maximum allowed screen error of terrain tiles in pixels.
81+
//! \sa maxTerrainScreenError()
6282
void setMaxTerrainScreenError( float error );
83+
//! Returns maximum allowed screen error of terrain tiles in pixels. This parameter decides
84+
//! how aggressively less detailed terrain tiles are swapped to more detailed ones as camera gets closer.
85+
//! Each tile has its error defined in world units - this error gets projected to screen pixels
86+
//! according to camera view and if the tile's error is greater than the allowed error, it will
87+
//! be swapped by more detailed tiles with lower error.
6388
float maxTerrainScreenError() const;
6489

90+
//! Returns maximum ground error of terrain tiles in world units.
91+
//! \sa maxTerrainGroundError()
6592
void setMaxTerrainGroundError( float error );
93+
//! Returns maximum ground error of terrain tiles in world units. This parameter influences
94+
//! how many zoom levels there will be (together with mapTileResolution()).
95+
//! This value tells that when the given ground error is reached (e.g. 10 meters), it makes no sense
96+
//! to further split terrain tiles into finer ones because they will not add extra details anymore.
6697
float maxTerrainGroundError() const;
6798

99+
//! Sets terrain generator. It takes care of producing terrain tiles from the input data.
68100
//! Takes ownership of the generator
69101
void setTerrainGenerator( TerrainGenerator *gen );
102+
//! Returns terrain generator. It takes care of producing terrain tiles from the input data.
70103
TerrainGenerator *terrainGenerator() const { return mTerrainGenerator.get(); }
71104

72105
//
@@ -79,21 +112,35 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject
79112
QString skyboxFileBase;
80113
QString skyboxFileExtension;
81114

115+
//! Sets whether to display bounding boxes of terrain tiles (for debugging)
82116
void setShowTerrainBoundingBoxes( bool enabled );
117+
//! Returns whether to display bounding boxes of terrain tiles (for debugging)
83118
bool showTerrainBoundingBoxes() const { return mShowTerrainBoundingBoxes; }
119+
//! Sets whether to display extra tile info on top of terrain tiles (for debugging)
84120
void setShowTerrainTilesInfo( bool enabled );
121+
//! Returns whether to display extra tile info on top of terrain tiles (for debugging)
85122
bool showTerrainTilesInfo() const { return mShowTerrainTileInfo; }
86123

87124
signals:
125+
//! Emitted when the background color has changed
88126
void backgroundColorChanged();
127+
//! Emitted when the selection color has changed
89128
void selectionColorChanged();
129+
//! Emitted when the list of map layers for terrain texture has changed
90130
void layersChanged();
131+
//! Emitted when the terrain generator has changed
91132
void terrainGeneratorChanged();
133+
//! Emitted when the vertical scale of the terrain has changed
92134
void terrainVerticalScaleChanged();
135+
//! Emitted when the map tile resoulution has changed
93136
void mapTileResolutionChanged();
137+
//! Emitted when the maximum terrain screen error has changed
94138
void maxTerrainScreenErrorChanged();
139+
//! Emitted when the maximum terrain ground error has changed
95140
void maxTerrainGroundErrorChanged();
141+
//! Emitted when the flag whether terrain's bounding boxes are shown has changed
96142
void showTerrainBoundingBoxesChanged();
143+
//! Emitted when the flag whether terrain's tile info is shown has changed
97144
void showTerrainTilesInfoChanged();
98145

99146
private:

src/3d/qgstessellatedpolygongeometry.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ QgsTessellatedPolygonGeometry::QgsTessellatedPolygonGeometry( QNode *parent )
2020
m_vertexBuffer = new Qt3DRender::QBuffer( Qt3DRender::QBuffer::VertexBuffer, this );
2121

2222
QgsTessellator tmpTess( 0, 0, m_withNormals );
23-
const int stride = tmpTess.stride;
23+
const int stride = tmpTess.stride();
2424

2525
m_positionAttribute = new Qt3DRender::QAttribute( this );
2626
m_positionAttribute->setName( Qt3DRender::QAttribute::defaultPositionAttributeName() );
@@ -73,8 +73,8 @@ void QgsTessellatedPolygonGeometry::setPolygons( const QList<QgsPolygonV2 *> &po
7373
++i;
7474
}
7575

76-
QByteArray data( ( const char * )tesselator.data.constData(), tesselator.data.count() * sizeof( float ) );
77-
int nVerts = data.count() / tesselator.stride;
76+
QByteArray data( ( const char * )tesselator.data().constData(), tesselator.data().count() * sizeof( float ) );
77+
int nVerts = data.count() / tesselator.stride();
7878

7979
m_vertexBuffer->setData( data );
8080
m_positionAttribute->setCount( nVerts );

src/3d/qgstessellatedpolygongeometry.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@ namespace Qt3DRender
1010
class QBuffer;
1111
}
1212

13-
//! Class that represents polygons tessellated into 3D geometry
13+
/** \ingroup 3d
14+
* Class derived from Qt3DRender::QGeometry that represents polygons tessellated into 3D geometry.
15+
*
16+
* Takes a list of polygons as input, internally it does tessellation and writes output to the internal
17+
* vertex buffer. Optionally it can add "walls" if the extrusion height is non-zero.
18+
*
19+
* \since QGIS 3.0
20+
*/
1421
class QgsTessellatedPolygonGeometry : public Qt3DRender::QGeometry
1522
{
1623
public:
24+
//! Constructor
1725
QgsTessellatedPolygonGeometry( QNode *parent = nullptr );
1826
~QgsTessellatedPolygonGeometry();
1927

20-
// takes ownership of passed polygon geometries
28+
//! Initializes vertex buffer from given polygons. Takes ownership of passed polygon geometries
2129
void setPolygons( const QList<QgsPolygonV2 *> &polygons, const QgsPointXY &origin, float extrusionHeight );
2230

2331
private:

src/3d/qgstessellator.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ static void make_quad( float x0, float y0, float x1, float y1, float zLow, float
4444

4545

4646
QgsTessellator::QgsTessellator( double originX, double originY, bool addNormals )
47-
: originX( originX )
48-
, originY( originY )
49-
, addNormals( addNormals )
47+
: mOriginX( originX )
48+
, mOriginY( originY )
49+
, mAddNormals( addNormals )
5050
{
51-
stride = 3 * sizeof( float );
51+
mStride = 3 * sizeof( float );
5252
if ( addNormals )
53-
stride += 3 * sizeof( float );
53+
mStride += 3 * sizeof( float );
5454
}
5555

5656

@@ -112,7 +112,7 @@ void QgsTessellator::addPolygon( const QgsPolygonV2 &polygon, float extrusionHei
112112
exterior->pointAt( i, pt, vt );
113113
if ( i == 0 || pt != ptPrev )
114114
{
115-
p2t::Point *pt2 = new p2t::Point( pt.x() - originX, pt.y() - originY );
115+
p2t::Point *pt2 = new p2t::Point( pt.x() - mOriginX, pt.y() - mOriginY );
116116
polyline.push_back( pt2 );
117117
float zPt = qIsNaN( pt.z() ) ? 0 : pt.z();
118118
z[pt2] = zPt;
@@ -134,7 +134,7 @@ void QgsTessellator::addPolygon( const QgsPolygonV2 &polygon, float extrusionHei
134134
hole->pointAt( j, pt, vt );
135135
if ( j == 0 || pt != ptPrev )
136136
{
137-
p2t::Point *pt2 = new p2t::Point( pt.x() - originX, pt.y() - originY );
137+
p2t::Point *pt2 = new p2t::Point( pt.x() - mOriginX, pt.y() - mOriginY );
138138
holePolyline.push_back( pt2 );
139139
float zPt = qIsNaN( pt.z() ) ? 0 : pt.z();
140140
z[pt2] = zPt;
@@ -158,9 +158,9 @@ void QgsTessellator::addPolygon( const QgsPolygonV2 &polygon, float extrusionHei
158158
{
159159
p2t::Point *p = t->GetPoint( j );
160160
float zPt = z[p];
161-
data << p->x << extrusionHeight + zPt << -p->y;
162-
if ( addNormals )
163-
data << 0.f << 1.f << 0.f;
161+
mData << p->x << extrusionHeight + zPt << -p->y;
162+
if ( mAddNormals )
163+
mData << 0.f << 1.f << 0.f;
164164
}
165165
}
166166

@@ -171,9 +171,9 @@ void QgsTessellator::addPolygon( const QgsPolygonV2 &polygon, float extrusionHei
171171
// add walls if extrusion is enabled
172172
if ( extrusionHeight != 0 )
173173
{
174-
_makeWalls( *exterior, false, extrusionHeight, data, addNormals, originX, originY );
174+
_makeWalls( *exterior, false, extrusionHeight, mData, mAddNormals, mOriginX, mOriginY );
175175

176176
for ( int i = 0; i < polygon.numInteriorRings(); ++i )
177-
_makeWalls( *polygon.interiorRing( i ), true, extrusionHeight, data, addNormals, originX, originY );
177+
_makeWalls( *polygon.interiorRing( i ), true, extrusionHeight, mData, mAddNormals, mOriginX, mOriginY );
178178
}
179179
}

src/3d/qgstessellator.h

+23-12
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,36 @@ class QgsPolygonV2;
55

66
#include <QVector>
77

8+
9+
/** \ingroup 3d
10+
* Class that takes care of tessellation of polygons into triangles.
11+
*
12+
* It is expected that client code will create the tessellator object, then repeatedly call
13+
* addPolygon() method that will generate triangles, and finally call data() to get final vertex data.
14+
*
15+
* Optionally provides extrusion by adding triangles that serve as walls when extrusion height is non-zero.
16+
*
17+
* \since QGIS 3.0
18+
*/
819
class QgsTessellator
920
{
1021
public:
22+
//! Creates tessellator with a specified origin point of the world (in map coordinates)
1123
QgsTessellator( double originX, double originY, bool addNormals );
1224

25+
//! Tessellates a triangle and adds its vertex entries to the output data array
1326
void addPolygon( const QgsPolygonV2 &polygon, float extrusionHeight );
1427

15-
// input:
16-
// - origin X/Y
17-
// - whether to add walls
18-
// - stream of geometries
19-
// output:
20-
// - vertex buffer data (+ index buffer data ?)
21-
22-
double originX, originY;
23-
bool addNormals;
24-
//QByteArray data;
25-
QVector<float> data;
26-
int stride; //!< Size of one vertex entry in bytes
28+
//! Returns array of triangle vertex data
29+
QVector<float> data() const { return mData; }
30+
//! Returns size of one vertex entry in bytes
31+
int stride() const { return mStride; }
32+
33+
private:
34+
double mOriginX, mOriginY;
35+
bool mAddNormals;
36+
QVector<float> mData;
37+
int mStride;
2738
};
2839

2940
#endif // QGSTESSELLATOR_H

src/3d/terrain/demterraintilegeometry.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using namespace Qt3DRender;
1010

1111

12-
QByteArray createPlaneVertexData( int res, const QByteArray &heights )
12+
static QByteArray createPlaneVertexData( int res, const QByteArray &heights )
1313
{
1414
Q_ASSERT( res >= 2 );
1515
Q_ASSERT( heights.count() == res * res * ( int )sizeof( float ) );
@@ -67,7 +67,7 @@ QByteArray createPlaneVertexData( int res, const QByteArray &heights )
6767
}
6868

6969

70-
QByteArray createPlaneIndexData( int res )
70+
static QByteArray createPlaneIndexData( int res )
7171
{
7272
QSize resolution( res, res );
7373
// Create the index data. 2 triangles per rectangular face
@@ -101,7 +101,10 @@ QByteArray createPlaneIndexData( int res )
101101
return indexBytes;
102102
}
103103

104+
///@cond PRIVATE
104105

106+
107+
//! Generates vertex buffer for DEM terrain tiles
105108
class PlaneVertexBufferFunctor : public QBufferDataGenerator
106109
{
107110
public:
@@ -133,6 +136,8 @@ class PlaneVertexBufferFunctor : public QBufferDataGenerator
133136
QByteArray m_heightMap;
134137
};
135138

139+
140+
//! Generates index buffer for DEM terrain tiles
136141
class PlaneIndexBufferFunctor : public QBufferDataGenerator
137142
{
138143
public:
@@ -161,6 +166,7 @@ class PlaneIndexBufferFunctor : public QBufferDataGenerator
161166
int m_resolution;
162167
};
163168

169+
/// @endcond
164170

165171

166172

src/3d/terrain/flatterraingenerator.h

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#include "chunkloader.h"
1111

1212

13+
/** \ingroup 3d
14+
* Terrain generator that creates a simple square flat area.
15+
*
16+
* \since QGIS 3.0
17+
*/
1318
class _3D_EXPORT FlatTerrainGenerator : public TerrainGenerator
1419
{
1520
public:
@@ -24,9 +29,12 @@ class _3D_EXPORT FlatTerrainGenerator : public TerrainGenerator
2429
virtual void writeXml( QDomElement &elem ) const override;
2530
virtual void readXml( const QDomElement &elem ) override;
2631

32+
//! Sets extent of the terrain
2733
void setExtent( const QgsRectangle &extent );
2834

35+
//! Sets CRS of the terrain
2936
void setCrs( const QgsCoordinateReferenceSystem &crs );
37+
//! Returns CRS of the terrain
3038
QgsCoordinateReferenceSystem crs() const { return mCrs; }
3139

3240
private:

0 commit comments

Comments
 (0)