QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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 "qgsfeatureid.h"
25#include "qgsray3d.h"
26#include "qgscameracontroller.h"
27
28namespace Qt3DRender
29{
30 class QRenderSettings;
31 class QCamera;
32 class QPickEvent;
33 class QObjectPicker;
34}
35
36namespace Qt3DLogic
37{
38 class QFrameAction;
39}
40
41namespace Qt3DExtras
42{
43 class QForwardRenderer;
44 class QSkyboxEntity;
45}
46
47class Qgs3DAxis;
50class QgsMapLayer;
53class QgsTerrainEntity;
54class QgsChunkedEntity;
55class QgsSkyboxEntity;
60class QgsChunkNode;
61
62#define SIP_NO_FILE
63
70class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
71{
72 Q_OBJECT
73 public:
76
78 QgsCameraController *cameraController() { return mCameraController; }
80 QgsTerrainEntity *terrainEntity() { return mTerrain; }
81
83 void viewZoomFull();
84
90 void setViewFrom2DExtent( const QgsRectangle &extent );
91
97 QVector<QgsPointXY> viewFrustum2DExtent();
98
100 int terrainPendingJobsCount() const;
101
106 int totalPendingJobsCount() const;
107
110 {
113 };
114
116 SceneState sceneState() const { return mSceneState; }
117
119 void registerPickHandler( Qgs3DMapScenePickHandler *pickHandler );
121 void unregisterPickHandler( Qgs3DMapScenePickHandler *pickHandler );
122
127 float worldSpaceError( float epsilon, float distance );
128
130 void exportScene( const Qgs3DMapExportSettings &exportSettings );
131
137 QVector<const QgsChunkNode *> getLayerActiveChunkNodes( QgsMapLayer *layer ) SIP_SKIP;
138
144 QgsRectangle sceneExtent();
145
151 Qgs3DAxis *get3DAxis() { return m3DAxis; }
152
158 QgsAbstract3DEngine *engine() { return mEngine; }
159
160 signals:
165
173
175 void fpsCountChanged( float fpsCount );
177 void fpsCounterEnabledChanged( bool fpsCounterEnabled );
178
184 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
185
186 public slots:
188 void updateTemporal();
189
190 private slots:
191 void onCameraChanged();
192 void onFrameTriggered( float dt );
193 void createTerrain();
194 void onLayerRenderer3DChanged();
195 void onLayersChanged();
196 void createTerrainDeferred();
197 void onBackgroundColorChanged();
198 void onLayerEntityPickedObject( Qt3DRender::QPickEvent *pickEvent, QgsFeatureId fid );
199 void updateLights();
200 void updateCameraLens();
201 void onRenderersChanged();
202 void onSkyboxSettingsChanged();
203 void onShadowSettingsChanged();
204 void onAmbientOcclusionSettingsChanged();
205 void onEyeDomeShadingSettingsChanged();
206 void onDebugShadowMapSettingsChanged();
207 void onDebugDepthMapSettingsChanged();
208 void onCameraMovementSpeedChanged();
209 void onCameraNavigationModeChanged();
210 void onDebugOverlayEnabledChanged();
211
212 void on3DAxisSettingsChanged();
213
214 bool updateCameraNearFarPlanes();
215
216 private:
217 void addLayerEntity( QgsMapLayer *layer );
218 void removeLayerEntity( QgsMapLayer *layer );
219 void addCameraViewCenterEntity( Qt3DRender::QCamera *camera );
220 void addCameraRotationCenterEntity( QgsCameraController *controller );
221 void setSceneState( SceneState state );
222 void updateSceneState();
223 void updateScene();
224 void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
225 int maximumTextureSize() const;
226
227 private:
228 Qgs3DMapSettings &mMap;
229 QgsAbstract3DEngine *mEngine = nullptr;
231 Qt3DLogic::QFrameAction *mFrameAction = nullptr;
232 QgsCameraController *mCameraController = nullptr;
233 QgsTerrainEntity *mTerrain = nullptr;
234 QList<QgsChunkedEntity *> mChunkEntities;
236 Qt3DCore::QEntity *mEntityCameraViewCenter = nullptr;
238 QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
239 QMap<const QgsAbstract3DRenderer *, Qt3DCore::QEntity *> mRenderersEntities;
240 bool mTerrainUpdateScheduled = false;
241 SceneState mSceneState = Ready;
243 QList<Qgs3DMapScenePickHandler *> mPickHandlers;
245 QList<Qt3DCore::QEntity *> mLightEntities;
246 QList<QgsMapLayer *> mModelVectorLayers;
247 QgsSkyboxEntity *mSkybox = nullptr;
249 Qt3DCore::QEntity *mEntityRotationCenter = nullptr;
250
252 Qgs3DAxis *m3DAxis = nullptr;
253
254};
255
256#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.
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:80
void totalPendingJobsCountChanged()
Emitted when the total number of pending jobs changes.
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.
QgsCameraController * cameraController()
Returns camera controller.
Definition: qgs3dmapscene.h:78
Base class for all renderers that may to participate in 3D view.
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
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28