/
qgs3dmapscene.h
76 lines (63 loc) · 2.07 KB
/
qgs3dmapscene.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef QGS3DMAPSCENE_H
#define QGS3DMAPSCENE_H
#include "qgis_3d.h"
#include <Qt3DCore/QEntity>
namespace Qt3DRender
{
class QRenderSettings;
class QCamera;
}
namespace Qt3DLogic
{
class QFrameAction;
}
namespace Qt3DExtras
{
class QForwardRenderer;
}
class QgsMapLayer;
class QgsCameraController;
class Qgs3DMapSettings;
class Terrain;
class ChunkedEntity;
/** \ingroup 3d
* Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children.
* \since QGIS 3.0
*/
class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
{
Q_OBJECT
public:
//! Constructs a 3D scene based on map settings and Qt 3D renderer configuration
Qgs3DMapScene( const Qgs3DMapSettings &map, Qt3DExtras::QForwardRenderer *defaultFrameGraph, Qt3DRender::QRenderSettings *renderSettings, Qt3DRender::QCamera *camera, const QRect &viewportRect, Qt3DCore::QNode *parent = nullptr );
//! Returns camera controller
QgsCameraController *cameraController() { return mCameraController; }
//! Returns terrain entity
Terrain *terrain() { return mTerrain; }
//! Resets camera view to show the whole scene (top view)
void viewZoomFull();
private slots:
void onCameraChanged();
void onFrameTriggered( float dt );
void createTerrain();
void onLayerRenderer3DChanged();
void onLayersChanged();
void createTerrainDeferred();
void onBackgroundColorChanged();
private:
void addLayerEntity( QgsMapLayer *layer );
void removeLayerEntity( QgsMapLayer *layer );
private:
const Qgs3DMapSettings &mMap;
//! Provides a way to have a synchronous function executed each frame
Qt3DLogic::QFrameAction *mFrameAction;
QgsCameraController *mCameraController;
Terrain *mTerrain;
//! Forward renderer provided by 3D window
Qt3DExtras::QForwardRenderer *mForwardRenderer;
QList<ChunkedEntity *> chunkEntities;
//! Keeps track of entities that belong to a particular layer
QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
bool mTerrainUpdateScheduled = false;
};
#endif // QGS3DMAPSCENE_H