QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#include <QVector4D>
26
27#ifndef SIP_RUN
28namespace Qt3DRender
29{
30 class QRenderSettings;
31 class QCamera;
32} // namespace Qt3DRender
33
34namespace Qt3DLogic
35{
36 class QFrameAction;
37}
38
39namespace Qt3DExtras
40{
41 class QForwardRenderer;
42 class QSkyboxEntity;
43} // namespace Qt3DExtras
44#endif
45
46
47class Qgs3DAxis;
50class QgsMapLayer;
52class QgsTerrainEntity;
53class QgsChunkedEntity;
54class QgsSkyboxEntity;
58class QgsChunkNode;
59class QgsDoubleRange;
60class Qgs3DMapSceneEntity;
61
62
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
135 bool exportScene( const Qgs3DMapExportSettings &exportSettings );
136
142 QVector<const QgsChunkNode *> getLayerActiveChunkNodes( QgsMapLayer *layer ) SIP_SKIP;
143
149 QList<QgsMapLayer *> layers() const SIP_SKIP { return mLayerEntities.keys(); }
150
156 Qt3DCore::QEntity *layerEntity( QgsMapLayer *layer ) const SIP_SKIP { return mLayerEntities.value( layer ); }
157
163 QgsRectangle sceneExtent() const;
164
171 QgsDoubleRange elevationRange() const;
172
178 Qgs3DAxis *get3DAxis() const SIP_SKIP { return m3DAxis; }
179
185 QgsAbstract3DEngine *engine() const SIP_SKIP { return mEngine; }
186
192 Qgs3DMapSettings *mapSettings() const { return &mMap; }
193
201 bool hasSceneUpdatesEnabled() const { return mSceneUpdatesEnabled; }
202
210 void setSceneUpdatesEnabled( bool enabled ) { mSceneUpdatesEnabled = enabled; }
211
219 Q_DECL_DEPRECATED static QMap<QString, Qgs3DMapScene *> openScenes() SIP_DEPRECATED;
220
241 void enableClipping( const QList<QVector4D> &clipPlaneEquations );
242
249 void disableClipping();
250
251#ifndef SIP_RUN
253 static std::function<QMap<QString, Qgs3DMapScene *>()> sOpenScenesFunction;
254#endif
255
256 signals:
261
269
271 void fpsCountChanged( float fpsCount );
273 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
274
280 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
281
288
289 public slots:
291 void updateTemporal();
292
293 private slots:
294 void onCameraChanged();
295 void onFrameTriggered( float dt );
296 void createTerrain();
297 void onLayerRenderer3DChanged();
298 void onLayersChanged();
299 void createTerrainDeferred();
300 void onBackgroundColorChanged();
301 void updateLights();
302 void updateCameraLens();
303 void onSkyboxSettingsChanged();
304 void onShadowSettingsChanged();
305 void onAmbientOcclusionSettingsChanged();
306 void onEyeDomeShadingSettingsChanged();
307 void onDebugShadowMapSettingsChanged();
308 void onDebugDepthMapSettingsChanged();
309 void onCameraMovementSpeedChanged();
310 void onCameraNavigationModeChanged();
311 void onDebugOverlayEnabledChanged();
312 void onStopUpdatesChanged();
313 void on3DAxisSettingsChanged();
314
315 void onOriginChanged();
316
317 bool updateCameraNearFarPlanes();
318
319 private:
320#ifdef SIP_RUN
322 Qgs3DMapScene( const Qgs3DMapScene &other );
323#endif
324
325 void addLayerEntity( QgsMapLayer *layer );
326 void removeLayerEntity( QgsMapLayer *layer );
327 void addCameraViewCenterEntity( Qt3DRender::QCamera *camera );
328 void addCameraRotationCenterEntity( QgsCameraController *controller );
329 void setSceneState( SceneState state );
330 void updateSceneState();
331 void updateScene( bool forceUpdate = false );
332 void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
333 int maximumTextureSize() const;
334
335 void handleClippingOnEntity( QEntity *entity ) const;
336 void handleClippingOnAllEntities() const;
337
338 private:
339 Qgs3DMapSettings &mMap;
340 QgsAbstract3DEngine *mEngine = nullptr;
342 Qt3DLogic::QFrameAction *mFrameAction = nullptr;
343 QgsCameraController *mCameraController = nullptr;
344 QgsTerrainEntity *mTerrain = nullptr;
345 QList<Qgs3DMapSceneEntity *> mSceneEntities;
347 Qt3DCore::QEntity *mEntityCameraViewCenter = nullptr;
349 QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
350 bool mTerrainUpdateScheduled = false;
351 SceneState mSceneState = Ready;
353 QList<Qt3DCore::QEntity *> mLightEntities;
354 QList<QgsMapLayer *> mModelVectorLayers;
355 QgsSkyboxEntity *mSkybox = nullptr;
357 Qt3DCore::QEntity *mEntityRotationCenter = nullptr;
358
360 Qgs3DAxis *m3DAxis = nullptr;
361
362 bool mSceneUpdatesEnabled = true;
363
364 QList<QVector4D> mClipPlanesEquations;
365 int mMaxClipPlanes = 6;
366};
367#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.
bool hasSceneUpdatesEnabled() const
Returns whether updates of the 3D scene's entities are allowed.
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.
void setSceneUpdatesEnabled(bool enabled)
Sets whether updates of the 3D scene's entities are allowed.
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:76
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