QGIS API Documentation  3.0.2-Girona (307d082)
qgs3dmapscene.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgs3dmapscene.h
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 
16 #ifndef QGS3DMAPSCENE_H
17 #define QGS3DMAPSCENE_H
18 
19 #include "qgis_3d.h"
20 
21 #include <Qt3DCore/QEntity>
22 
23 namespace Qt3DRender
24 {
25  class QRenderSettings;
26  class QCamera;
27 }
28 
29 namespace Qt3DLogic
30 {
31  class QFrameAction;
32 }
33 
34 namespace Qt3DExtras
35 {
36  class QForwardRenderer;
37 }
38 
39 class QgsMapLayer;
41 class Qgs3DMapSettings;
42 class QgsTerrainEntity;
43 class QgsChunkedEntity;
44 
50 class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
51 {
52  Q_OBJECT
53  public:
55  Qgs3DMapScene( const Qgs3DMapSettings &map, Qt3DExtras::QForwardRenderer *defaultFrameGraph, Qt3DRender::QRenderSettings *renderSettings, Qt3DRender::QCamera *camera, const QRect &viewportRect, Qt3DCore::QNode *parent = nullptr );
56 
58  QgsCameraController *cameraController() { return mCameraController; }
60  QgsTerrainEntity *terrainEntity() { return mTerrain; }
61 
63  void viewZoomFull();
64 
66  int terrainPendingJobsCount() const;
67 
68  signals:
70  void terrainEntityChanged();
72  void terrainPendingJobsCountChanged();
73 
74  private slots:
75  void onCameraChanged();
76  void onFrameTriggered( float dt );
77  void createTerrain();
78  void onLayerRenderer3DChanged();
79  void onLayersChanged();
80  void createTerrainDeferred();
81  void onBackgroundColorChanged();
82 
83  private:
84  void addLayerEntity( QgsMapLayer *layer );
85  void removeLayerEntity( QgsMapLayer *layer );
86 
87  private:
88  const Qgs3DMapSettings &mMap;
90  Qt3DLogic::QFrameAction *mFrameAction = nullptr;
91  QgsCameraController *mCameraController = nullptr;
92  QgsTerrainEntity *mTerrain = nullptr;
94  Qt3DExtras::QForwardRenderer *mForwardRenderer = nullptr;
95  QList<QgsChunkedEntity *> mChunkEntities;
97  QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
98  bool mTerrainUpdateScheduled = false;
99 };
100 
101 #endif // QGS3DMAPSCENE_H
Base class for all map layer types.
Definition: qgsmaplayer.h:56
QgsTerrainEntity * terrainEntity()
Returns terrain entity.
Definition: qgs3dmapscene.h:60
3 Definition of the world
3 Object that controls camera movement based on user input
3 Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children...
Definition: qgs3dmapscene.h:50
QgsCameraController * cameraController()
Returns camera controller.
Definition: qgs3dmapscene.h:58