QGIS API Documentation 3.35.0-Master (f6e073f0eed)
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"
26
27#ifndef SIP_RUN
28namespace Qt3DRender
29{
30 class QRenderSettings;
31 class QCamera;
32}
33
34namespace Qt3DLogic
35{
36 class QFrameAction;
37}
38
39namespace Qt3DExtras
40{
41 class QForwardRenderer;
42 class QSkyboxEntity;
43}
44#endif
45
46
47class Qgs3DAxis;
50class QgsMapLayer;
52class QgsTerrainEntity;
53class QgsChunkedEntity;
54class QgsSkyboxEntity;
58class QgsChunkNode;
59class QgsDoubleRange;
60
61
67#ifndef SIP_RUN
68class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
69{
70#else
71class _3D_EXPORT Qgs3DMapScene : public QObject
72{
73#endif
74
75 Q_OBJECT
76 public:
79
81 QgsCameraController *cameraController() const { return mCameraController; }
82
87 QgsTerrainEntity *terrainEntity() SIP_SKIP { return mTerrain; }
88
90 void viewZoomFull();
91
97 void setViewFrom2DExtent( const QgsRectangle &extent );
98
104 QVector<QgsPointXY> viewFrustum2DExtent() const;
105
107 int terrainPendingJobsCount() const;
108
113 int totalPendingJobsCount() const;
114
117 {
120 };
121
123 SceneState sceneState() const { return mSceneState; }
124
129 float worldSpaceError( float epsilon, float distance ) const;
130
132 void exportScene( const Qgs3DMapExportSettings &exportSettings );
133
139 QVector<const QgsChunkNode *> getLayerActiveChunkNodes( QgsMapLayer *layer ) SIP_SKIP;
140
146 QList<QgsMapLayer *> layers() const SIP_SKIP { return mLayerEntities.keys(); }
147
153 Qt3DCore::QEntity *layerEntity( QgsMapLayer *layer ) const SIP_SKIP { return mLayerEntities.value( layer ); }
154
160 QgsRectangle sceneExtent() const;
161
168 QgsDoubleRange elevationRange() const;
169
175 Qgs3DAxis *get3DAxis() const SIP_SKIP { return m3DAxis; }
176
182 QgsAbstract3DEngine *engine() const SIP_SKIP { return mEngine; }
183
189 Qgs3DMapSettings *mapSettings() const { return &mMap; }
190
198 Q_DECL_DEPRECATED static QMap< QString, Qgs3DMapScene * > openScenes() SIP_DEPRECATED;
199
200#ifndef SIP_RUN
202 static std::function< QMap< QString, Qgs3DMapScene * >() > sOpenScenesFunction;
203#endif
204
205 signals:
210
218
220 void fpsCountChanged( float fpsCount );
222 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
223
229 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
230
237
238 public slots:
240 void updateTemporal();
241
242 private slots:
243 void onCameraChanged();
244 void onFrameTriggered( float dt );
245 void createTerrain();
246 void onLayerRenderer3DChanged();
247 void onLayersChanged();
248 void createTerrainDeferred();
249 void onBackgroundColorChanged();
250 void updateLights();
251 void updateCameraLens();
252 void onSkyboxSettingsChanged();
253 void onShadowSettingsChanged();
254 void onAmbientOcclusionSettingsChanged();
255 void onEyeDomeShadingSettingsChanged();
256 void onDebugShadowMapSettingsChanged();
257 void onDebugDepthMapSettingsChanged();
258 void onCameraMovementSpeedChanged();
259 void onCameraNavigationModeChanged();
260 void onDebugOverlayEnabledChanged();
261
262 void on3DAxisSettingsChanged();
263
264 bool updateCameraNearFarPlanes();
265
266 private:
267#ifdef SIP_RUN
269 Qgs3DMapScene( const Qgs3DMapScene &other );
270#endif
271
272 void addLayerEntity( QgsMapLayer *layer );
273 void removeLayerEntity( QgsMapLayer *layer );
274 void addCameraViewCenterEntity( Qt3DRender::QCamera *camera );
275 void addCameraRotationCenterEntity( QgsCameraController *controller );
276 void setSceneState( SceneState state );
277 void updateSceneState();
278 void updateScene( bool forceUpdate = false );
279 void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
280 int maximumTextureSize() const;
281 Qgs3DMapSceneEntity::SceneContext buildSceneContext( ) const;
282
283 private:
284 Qgs3DMapSettings &mMap;
285 QgsAbstract3DEngine *mEngine = nullptr;
287 Qt3DLogic::QFrameAction *mFrameAction = nullptr;
288 QgsCameraController *mCameraController = nullptr;
289 QgsTerrainEntity *mTerrain = nullptr;
290 QList<Qgs3DMapSceneEntity *> mSceneEntities;
292 Qt3DCore::QEntity *mEntityCameraViewCenter = nullptr;
294 QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
295 bool mTerrainUpdateScheduled = false;
296 SceneState mSceneState = Ready;
298 QList<Qt3DCore::QEntity *> mLightEntities;
299 QList<QgsMapLayer *> mModelVectorLayers;
300 QgsSkyboxEntity *mSkybox = nullptr;
302 Qt3DCore::QEntity *mEntityRotationCenter = nullptr;
303
305 Qgs3DAxis *m3DAxis = nullptr;
306
307};
308#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:201
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