QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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#include "qgsrectangle.h"
24#include "qgscameracontroller.h"
25
26#ifndef SIP_RUN
27namespace Qt3DRender
28{
29 class QRenderSettings;
30 class QCamera;
31}
32
33namespace Qt3DLogic
34{
35 class QFrameAction;
36}
37
38namespace Qt3DExtras
39{
40 class QForwardRenderer;
41 class QSkyboxEntity;
42}
43#endif
44
45
46class Qgs3DAxis;
49class QgsMapLayer;
51class QgsTerrainEntity;
52class QgsChunkedEntity;
53class QgsSkyboxEntity;
58class QgsChunkNode;
59class QgsDoubleRange;
60class Qgs3DMapSceneEntity;
61
62
69#ifndef SIP_RUN
70class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
71{
72#else
73class _3D_EXPORT Qgs3DMapScene : public QObject
74{
75#endif
76
77 Q_OBJECT
78 public:
81
83 QgsCameraController *cameraController() { return mCameraController; }
84
89 QgsTerrainEntity *terrainEntity() SIP_SKIP { return mTerrain; }
90
92 void viewZoomFull();
93
99 void setViewFrom2DExtent( const QgsRectangle &extent );
100
106 QVector<QgsPointXY> viewFrustum2DExtent();
107
109 int terrainPendingJobsCount() const;
110
115 int totalPendingJobsCount() const;
116
119 {
122 };
123
125 SceneState sceneState() const { return mSceneState; }
126
131 float worldSpaceError( float epsilon, float distance );
132
134 void exportScene( const Qgs3DMapExportSettings &exportSettings );
135
141 QVector<const QgsChunkNode *> getLayerActiveChunkNodes( QgsMapLayer *layer ) SIP_SKIP;
142
148 QList<QgsMapLayer *> layers() SIP_SKIP { return mLayerEntities.keys(); }
149
155 Qt3DCore::QEntity *layerEntity( QgsMapLayer *layer ) const SIP_SKIP { return mLayerEntities.value( layer ); }
156
162 QgsRectangle sceneExtent();
163
170 QgsDoubleRange elevationRange() const;
171
177 Qgs3DAxis *get3DAxis() SIP_SKIP { return m3DAxis; }
178
184 QgsAbstract3DEngine *engine() SIP_SKIP { return mEngine; }
185
191 Qgs3DMapSettings *mapSettings() const { return &mMap; }
192
200 static QMap< QString, Qgs3DMapScene * > openScenes();
201
202#ifndef SIP_RUN
204 static std::function< QMap< QString, Qgs3DMapScene * >() > sOpenScenesFunction;
205#endif
206
207 signals:
212
220
222 void fpsCountChanged( float fpsCount );
224 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
225
231 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
232
233 public slots:
235 void updateTemporal();
236
237 private slots:
238 void onCameraChanged();
239 void onFrameTriggered( float dt );
240 void createTerrain();
241 void onLayerRenderer3DChanged();
242 void onLayersChanged();
243 void createTerrainDeferred();
244 void onBackgroundColorChanged();
245 void updateLights();
246 void updateCameraLens();
247 void onSkyboxSettingsChanged();
248 void onShadowSettingsChanged();
249 void onAmbientOcclusionSettingsChanged();
250 void onEyeDomeShadingSettingsChanged();
251 void onDebugShadowMapSettingsChanged();
252 void onDebugDepthMapSettingsChanged();
253 void onCameraMovementSpeedChanged();
254 void onCameraNavigationModeChanged();
255 void onDebugOverlayEnabledChanged();
256
257 void on3DAxisSettingsChanged();
258
259 bool updateCameraNearFarPlanes();
260
261 private:
262#ifdef SIP_RUN
264 Qgs3DMapScene( const Qgs3DMapScene &other );
265#endif
266
267 void addLayerEntity( QgsMapLayer *layer );
268 void removeLayerEntity( QgsMapLayer *layer );
269 void addCameraViewCenterEntity( Qt3DRender::QCamera *camera );
270 void addCameraRotationCenterEntity( QgsCameraController *controller );
271 void setSceneState( SceneState state );
272 void updateSceneState();
273 void updateScene();
274 void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
275 int maximumTextureSize() const;
276
277 private:
278 Qgs3DMapSettings &mMap;
279 QgsAbstract3DEngine *mEngine = nullptr;
281 Qt3DLogic::QFrameAction *mFrameAction = nullptr;
282 QgsCameraController *mCameraController = nullptr;
283 QgsTerrainEntity *mTerrain = nullptr;
284 QList<Qgs3DMapSceneEntity *> mSceneEntities;
286 Qt3DCore::QEntity *mEntityCameraViewCenter = nullptr;
288 QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
289 bool mTerrainUpdateScheduled = false;
290 SceneState mSceneState = Ready;
292 QList<Qt3DCore::QEntity *> mLightEntities;
293 QList<QgsMapLayer *> mModelVectorLayers;
294 QgsSkyboxEntity *mSkybox = nullptr;
296 Qt3DCore::QEntity *mEntityRotationCenter = nullptr;
297
299 Qgs3DAxis *m3DAxis = nullptr;
300
301};
302#endif // QGS3DMAPSCENE_H
Manages the various settings the user can choose from when exporting a 3D scene 3.
void terrainPendingJobsCountChanged()
Emitted when the number of terrain's pending jobs changes.
void viewed2DExtentFrom3DChanged(QVector< QgsPointXY > extent)
Emitted when the viewed 2D extent seen by the 3D camera has changed.
QgsAbstract3DEngine * engine()
Returns the abstract 3D engine.
void fpsCountChanged(float fpsCount)
Emitted when the FPS count changes.
Qgs3DMapSettings * mapSettings() const
Returns the 3D map settings.
SceneState
Enumeration of possible states of the 3D scene.
@ Ready
The scene is fully loaded/updated.
@ Updating
The scene is still being loaded/updated.
QgsTerrainEntity * terrainEntity()
Returns terrain entity (may be temporarily nullptr)
Definition: qgs3dmapscene.h:89
void totalPendingJobsCountChanged()
Emitted when the total number of pending jobs changes.
Qt3DCore::QEntity * layerEntity(QgsMapLayer *layer) const
Returns the entity belonging to layer.
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is activated or deactivated.
void sceneStateChanged()
Emitted when the scene's state has changed.
SceneState sceneState() const
Returns the current state of the scene.
void terrainEntityChanged()
Emitted when the current terrain entity is replaced by a new one.
Qgs3DAxis * get3DAxis()
Returns the 3D axis object.
QList< QgsMapLayer * > layers()
Returns the layers that contain chunked entities.
QgsCameraController * cameraController()
Returns camera controller.
Definition: qgs3dmapscene.h:83
static std::function< QMap< QString, Qgs3DMapScene * >() > sOpenScenesFunction
Static function for returning open 3D map scenes.
Base class for all renderers that may to participate in 3D view.
QgsRange which stores a range of double values.
Definition: qgsrange.h:203
Base class for all map layer types.
Definition: qgsmaplayer.h:73
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Base class for all skybox types.
Contains the configuration of a skybox entity.
#define SIP_SKIP
Definition: qgis_sip.h:126