16#ifndef QGS3DMAPSCENE_H
17#define QGS3DMAPSCENE_H
25#include <Qt3DCore/QEntity>
30 class QRenderSettings;
41 class QForwardRenderer;
52class QgsTerrainEntity;
54class QgsChunkedEntity;
61class Qgs3DMapSceneEntity;
137 double worldSpaceError(
double epsilon,
double distance )
const;
179 QgsDoubleRange elevationRange(
bool ignoreTerrain =
false )
const;
254 Q_DECL_DEPRECATED
static QMap<QString, Qgs3DMapScene *> openScenes()
SIP_DEPRECATED;
276 void enableClipping( const QList<QVector4D> &clipPlaneEquations );
284 void disableClipping();
292 void addSceneEntity( Qgs3DMapSceneEntity *entity )
SIP_SKIP;
299 void removeSceneEntity( Qgs3DMapSceneEntity *entity )
SIP_SKIP;
311 static std::function<QMap<QString, Qgs3DMapScene *>()> sOpenScenesFunction;
350 void onCameraChanged();
351 void onViewed2DExtentFrom3DChanged();
352 void onFrameTriggered(
float dt );
353 void createTerrain();
354 void onLayerRenderer3DChanged();
355 void onLayersChanged();
356 void createTerrainDeferred();
357 void onBackgroundColorChanged();
359 void updateCameraLens();
360 void onBackgroundSettingsChanged();
361 void onShadowSettingsChanged();
362 void onAmbientOcclusionSettingsChanged();
363 void onBloomSettingsChanged();
364 void onColorGradingSettingsChanged();
365 void onEyeDomeShadingSettingsChanged();
366 void onMsaaEnabledChanged();
367 void onDebugDepthMapSettingsChanged();
368 void onCameraMovementSpeedChanged();
369 void onCameraNavigationModeChanged();
370 void onDebugOverlayEnabledChanged();
371 void onStopUpdatesChanged();
372 void on3DAxisSettingsChanged();
373 void onShowMapOverlayChanged();
375 void onOriginChanged();
377 bool updateCameraNearFarPlanes();
379 void applyPendingOverlayUpdate();
389 void addCameraViewCenterEntity( Qt3DRender::QCamera *camera );
392 void updateSceneState();
394 bool updateScene(
bool forceUpdate =
false );
395 void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
396 int maximumTextureSize()
const;
398 void handleClippingOnEntity( QEntity *entity )
const;
399 void handleClippingOnAllEntities()
const;
401 void schedule2DMapOverlayUpdate();
402 void update2DMapOverlay(
const QVector<QgsPointXY> &extent2DAsPoints );
408 Qt3DLogic::QFrameAction *mFrameAction =
nullptr;
410 QgsTerrainEntity *mTerrain =
nullptr;
411 QgsGlobeEntity *mGlobe =
nullptr;
412 QList<Qgs3DMapSceneEntity *> mSceneEntities;
414 Qt3DCore::QEntity *mEntityCameraViewCenter =
nullptr;
416 QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
417 bool mTerrainUpdateScheduled =
false;
420 QList<Qt3DCore::QEntity *> mLightEntities;
421 QList<QgsMapLayer *> mModelVectorLayers;
422 Qt3DCore::QEntity *mBackgroundEntity =
nullptr;
425 Qt3DCore::QEntity *mEntityRotationCenter =
nullptr;
430 bool mSceneUpdatesEnabled =
true;
431 bool mSceneOriginShiftEnabled =
true;
433 QList<QVector4D> mClipPlanesEquations;
434 int mMaxClipPlanes = 6;
438 QTimer *mOverlayUpdateTimer =
nullptr;
441 double mLastCenterDepth = 0.5;
442 QTimer *mDepthBufferRefreshTimer =
nullptr;
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
Display 3D ortho axis in the main 3D view.
Manages the various settings the user can choose from when exporting a 3D scene.
void viewed2DExtentFrom3DChanged(QVector< QgsPointXY > extent)
Emitted when the viewed 2D extent seen by the 3D camera has changed.
QList< QVector4D > clipPlaneEquations() const
Returns list of clipping planes if clipping is enabled, otherwise an empty list.
void fpsCountChanged(float fpsCount)
Emitted when the FPS count changes.
friend class TestQgs3DRendering
void setViewFrom2DExtent(const QgsRectangle &extent)
Resets camera view to show the extent extent (top view).
QgsTerrainEntity * terrainEntity() SIP_SKIP
Returns terrain entity (may be nullptr if using globe scene, terrain rendering is disabled or when te...
Qgs3DMapSettings * mapSettings() const
Returns the 3D map settings.
Qgs3DAxis * get3DAxis() const SIP_SKIP
Returns the 3D axis object.
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.
int totalPendingJobsCount() const
Returns number of pending jobs for all chunked entities.
bool hasSceneOriginShiftEnabled() const
Returns whether the 3D scene is allowed to automatically move the scene's origin.
bool hasSceneUpdatesEnabled() const
Returns whether updates of the 3D scene's entities are allowed.
QList< QgsMapLayer * > layers() const SIP_SKIP
Returns the layers that contain chunked entities.
void updateTemporal()
Updates the temporale entities.
void totalPendingJobsCountChanged()
Emitted when the total number of pending jobs changes.
Qgs3DMapScene(Qgs3DMapSettings &map, QgsAbstract3DEngine *engine) SIP_SKIP
Constructs a 3D scene based on map settings and Qt 3D renderer configuration.
void fpsCounterEnabledChanged(bool fpsCounterEnabled)
Emitted when the FPS counter is activated or deactivated.
void sceneStateChanged()
Emitted when the scene's state has changed.
QgsAbstract3DEngine * engine() const SIP_SKIP
Returns the abstract 3D engine.
SceneState sceneState() const
Returns the current state of the scene.
QVector< QgsPointXY > viewFrustum2DExtent() const
Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid.
void terrainEntityChanged()
Emitted when the current terrain entity is replaced by a new one.
Qt3DCore::QEntity * layerEntity(QgsMapLayer *layer) const SIP_SKIP
Returns the entity belonging to layer.
void setSceneUpdatesEnabled(bool enabled)
Sets whether updates of the 3D scene's entities are allowed.
void setSceneOriginShiftEnabled(bool enabled)
Returns whether the 3D scene is allowed to automatically move the scene's origin.
QgsGlobeEntity * globeEntity() SIP_SKIP
Returns globe entity (may be nullptr if not using globe scene, terrain rendering is disabled or when ...
Base class for 3D engine implementation.
Base class for all renderers that participate in 3D views.
Object that controls camera movement based on user input.
QgsRange which stores a range of double values.
An environment light entity.
A background entity that renders a two-color gradient behind all 3D scene geometry.
Base class for all map layer types.
A rectangle specified with double values.
Base class for all skybox types.
Contains the configuration of a skybox entity.