QGIS API Documentation 3.38.0-Grenoble (exported)
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;
57class QgsChunkNode;
58class QgsDoubleRange;
59class Qgs3DMapSceneEntity;
60
61
66#ifndef SIP_RUN
67class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
68{
69#else
70class _3D_EXPORT Qgs3DMapScene : public QObject
71{
72#endif
73
74 Q_OBJECT
75 public:
78
80 QgsCameraController *cameraController() const { return mCameraController; }
81
86 QgsTerrainEntity *terrainEntity() SIP_SKIP { return mTerrain; }
87
89 void viewZoomFull();
90
96 void setViewFrom2DExtent( const QgsRectangle &extent );
97
103 QVector<QgsPointXY> viewFrustum2DExtent() const;
104
106 int terrainPendingJobsCount() const;
107
112 int totalPendingJobsCount() const;
113
116 {
119 };
120
122 SceneState sceneState() const { return mSceneState; }
123
128 float worldSpaceError( float epsilon, float distance ) const;
129
131 void exportScene( const Qgs3DMapExportSettings &exportSettings );
132
138 QVector<const QgsChunkNode *> getLayerActiveChunkNodes( QgsMapLayer *layer ) SIP_SKIP;
139
145 QList<QgsMapLayer *> layers() const SIP_SKIP { return mLayerEntities.keys(); }
146
152 Qt3DCore::QEntity *layerEntity( QgsMapLayer *layer ) const SIP_SKIP { return mLayerEntities.value( layer ); }
153
159 QgsRectangle sceneExtent() const;
160
167 QgsDoubleRange elevationRange() const;
168
174 Qgs3DAxis *get3DAxis() const SIP_SKIP { return m3DAxis; }
175
181 QgsAbstract3DEngine *engine() const SIP_SKIP { return mEngine; }
182
188 Qgs3DMapSettings *mapSettings() const { return &mMap; }
189
197 Q_DECL_DEPRECATED static QMap< QString, Qgs3DMapScene * > openScenes() SIP_DEPRECATED;
198
199#ifndef SIP_RUN
201 static std::function< QMap< QString, Qgs3DMapScene * >() > sOpenScenesFunction;
202#endif
203
204 signals:
209
217
219 void fpsCountChanged( float fpsCount );
221 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
222
228 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
229
236
237 public slots:
239 void updateTemporal();
240
241 private slots:
242 void onCameraChanged();
243 void onFrameTriggered( float dt );
244 void createTerrain();
245 void onLayerRenderer3DChanged();
246 void onLayersChanged();
247 void createTerrainDeferred();
248 void onBackgroundColorChanged();
249 void updateLights();
250 void updateCameraLens();
251 void onSkyboxSettingsChanged();
252 void onShadowSettingsChanged();
253 void onAmbientOcclusionSettingsChanged();
254 void onEyeDomeShadingSettingsChanged();
255 void onDebugShadowMapSettingsChanged();
256 void onDebugDepthMapSettingsChanged();
257 void onCameraMovementSpeedChanged();
258 void onCameraNavigationModeChanged();
259 void onDebugOverlayEnabledChanged();
260
261 void on3DAxisSettingsChanged();
262
263 bool updateCameraNearFarPlanes();
264
265 private:
266#ifdef SIP_RUN
268 Qgs3DMapScene( const Qgs3DMapScene &other );
269#endif
270
271 void addLayerEntity( QgsMapLayer *layer );
272 void removeLayerEntity( QgsMapLayer *layer );
273 void addCameraViewCenterEntity( Qt3DRender::QCamera *camera );
274 void addCameraRotationCenterEntity( QgsCameraController *controller );
275 void setSceneState( SceneState state );
276 void updateSceneState();
277 void updateScene( bool forceUpdate = false );
278 void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
279 int maximumTextureSize() const;
280
281 private:
282 Qgs3DMapSettings &mMap;
283 QgsAbstract3DEngine *mEngine = nullptr;
285 Qt3DLogic::QFrameAction *mFrameAction = nullptr;
286 QgsCameraController *mCameraController = nullptr;
287 QgsTerrainEntity *mTerrain = nullptr;
288 QList<Qgs3DMapSceneEntity *> mSceneEntities;
290 Qt3DCore::QEntity *mEntityCameraViewCenter = nullptr;
292 QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
293 bool mTerrainUpdateScheduled = false;
294 SceneState mSceneState = Ready;
296 QList<Qt3DCore::QEntity *> mLightEntities;
297 QList<QgsMapLayer *> mModelVectorLayers;
298 QgsSkyboxEntity *mSkybox = nullptr;
300 Qt3DCore::QEntity *mEntityRotationCenter = nullptr;
301
303 Qgs3DAxis *m3DAxis = nullptr;
304
305};
306#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.
Qgs3DAxis * get3DAxis() const
Returns the 3D axis object.
void viewed2DExtentFrom3DChanged(QVector< QgsPointXY > extent)
Emitted when the viewed 2D extent seen by the 3D camera has changed.
void fpsCountChanged(float fpsCount)
Emitted when the FPS count changes.
Qgs3DMapSettings * mapSettings() const
Returns the 3D map settings.
QgsAbstract3DEngine * engine() const
Returns the abstract 3D engine.
void gpuMemoryLimitReached()
Emitted when one of the entities reaches its GPU memory limit and it is not possible to lower the GPU...
QgsCameraController * cameraController() const
Returns camera controller.
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.
QList< QgsMapLayer * > layers() const
Returns the layers that contain chunked entities.
void terrainEntityChanged()
Emitted when the current terrain entity is replaced by a new one.
Base class for all renderers that may to participate in 3D view.
QgsRange which stores a range of double values.
Definition qgsrange.h:231
Base class for all map layer types.
Definition qgsmaplayer.h:75
A rectangle specified with double values.
Base class for all skybox types.
Contains the configuration of a skybox entity.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126