QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
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
239
240 public slots:
242 void updateTemporal();
243
244 private slots:
245 void onCameraChanged();
246 void onFrameTriggered( float dt );
247 void createTerrain();
248 void onLayerRenderer3DChanged();
249 void onLayersChanged();
250 void createTerrainDeferred();
251 void onBackgroundColorChanged();
252 void updateLights();
253 void updateCameraLens();
254 void onSkyboxSettingsChanged();
255 void onShadowSettingsChanged();
256 void onAmbientOcclusionSettingsChanged();
257 void onEyeDomeShadingSettingsChanged();
258 void onDebugShadowMapSettingsChanged();
259 void onDebugDepthMapSettingsChanged();
260 void onCameraMovementSpeedChanged();
261 void onCameraNavigationModeChanged();
262 void onDebugOverlayEnabledChanged();
263
264 void on3DAxisSettingsChanged();
265
266 bool updateCameraNearFarPlanes();
267
268 private:
269#ifdef SIP_RUN
271 Qgs3DMapScene( const Qgs3DMapScene &other );
272#endif
273
274 void addLayerEntity( QgsMapLayer *layer );
275 void removeLayerEntity( QgsMapLayer *layer );
276 void addCameraViewCenterEntity( Qt3DRender::QCamera *camera );
277 void addCameraRotationCenterEntity( QgsCameraController *controller );
278 void setSceneState( SceneState state );
279 void updateSceneState();
280 void updateScene();
281 void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
282 int maximumTextureSize() const;
283
284 private:
285 Qgs3DMapSettings &mMap;
286 QgsAbstract3DEngine *mEngine = nullptr;
288 Qt3DLogic::QFrameAction *mFrameAction = nullptr;
289 QgsCameraController *mCameraController = nullptr;
290 QgsTerrainEntity *mTerrain = nullptr;
291 QList<Qgs3DMapSceneEntity *> mSceneEntities;
293 Qt3DCore::QEntity *mEntityCameraViewCenter = nullptr;
295 QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
296 bool mTerrainUpdateScheduled = false;
297 SceneState mSceneState = Ready;
299 QList<Qt3DCore::QEntity *> mLightEntities;
300 QList<QgsMapLayer *> mModelVectorLayers;
301 QgsSkyboxEntity *mSkybox = nullptr;
303 Qt3DCore::QEntity *mEntityRotationCenter = nullptr;
304
306 Qgs3DAxis *m3DAxis = nullptr;
307
308};
309#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.
void gpuMemoryLimitReached()
Emitted when one of the entities reaches its GPU memory limit and it is not possible to lower the GPU...
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)
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.
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:74
A rectangle specified with double values.
Base class for all skybox types.
Contains the configuration of a skybox entity.
#define SIP_SKIP
Definition qgis_sip.h:126