QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Qgs3DMapScene Class Reference

3 More...

#include <qgs3dmapscene.h>

Inheritance diagram for Qgs3DMapScene:
Inheritance graph
[legend]

Public Types

enum  SceneState { Ready , Updating }
 Enumeration of possible states of the 3D scene. More...
 

Public Slots

void updateTemporal ()
 Updates the temporale entities.
 

Signals

void fpsCountChanged (float fpsCount)
 Emitted when the FPS count changes.
 
void fpsCounterEnabledChanged (bool fpsCounterEnabled)
 Emitted when the FPS counter is activated or deactivated.
 
void gpuMemoryLimitReached ()
 Emitted when one of the entities reaches its GPU memory limit and it is not possible to lower the GPU memory use by unloading data that's not currently needed.
 
void sceneStateChanged ()
 Emitted when the scene's state has changed.
 
void terrainEntityChanged ()
 Emitted when the current terrain entity is replaced by a new one.
 
void terrainPendingJobsCountChanged ()
 Emitted when the number of terrain's pending jobs changes.
 
void totalPendingJobsCountChanged ()
 Emitted when the total number of pending jobs changes.
 
void viewed2DExtentFrom3DChanged (QVector< QgsPointXY > extent)
 Emitted when the viewed 2D extent seen by the 3D camera has changed.
 

Public Member Functions

 Qgs3DMapScene (Qgs3DMapSettings &map, QgsAbstract3DEngine *engine)
 Constructs a 3D scene based on map settings and Qt 3D renderer configuration.
 
QgsCameraControllercameraController () const
 Returns camera controller.
 
void disableClipping ()
 Disables OpenGL clipping.
 
QgsDoubleRange elevationRange () const
 Returns the scene's elevation range.
 
void enableClipping (const QList< QVector4D > &clipPlaneEquations)
 Enables OpenGL clipping based on the planes equations defined in clipPlaneEquations.
 
QgsAbstract3DEngineengine () const
 Returns the abstract 3D engine.
 
void exportScene (const Qgs3DMapExportSettings &exportSettings)
 Exports the scene according to the scene export settings.
 
Qgs3DAxisget3DAxis () const
 Returns the 3D axis object.
 
QVector< const QgsChunkNode * > getLayerActiveChunkNodes (QgsMapLayer *layer)
 Returns the active chunk nodes of layer.
 
bool hasSceneUpdatesEnabled () const
 Returns whether updates of the 3D scene's entities are allowed.
 
Qt3DCore::QEntity * layerEntity (QgsMapLayer *layer) const
 Returns the entity belonging to layer.
 
QList< QgsMapLayer * > layers () const
 Returns the layers that contain chunked entities.
 
Qgs3DMapSettingsmapSettings () const
 Returns the 3D map settings.
 
QgsRectangle sceneExtent () const
 Returns the scene extent in the map's CRS.
 
SceneState sceneState () const
 Returns the current state of the scene.
 
void setSceneUpdatesEnabled (bool enabled)
 Sets whether updates of the 3D scene's entities are allowed.
 
void setViewFrom2DExtent (const QgsRectangle &extent)
 Resets camera view to show the extent extent (top view)
 
QgsTerrainEntity * terrainEntity ()
 Returns terrain entity (may be temporarily nullptr)
 
int terrainPendingJobsCount () const
 Returns number of pending jobs of the terrain entity.
 
int totalPendingJobsCount () const
 Returns number of pending jobs for all chunked entities.
 
QVector< QgsPointXYviewFrustum2DExtent () const
 Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid.
 
void viewZoomFull ()
 Resets camera view to show the whole scene (top view)
 
float worldSpaceError (float epsilon, float distance) const
 Given screen error (in pixels) and distance from camera (in 3D world coordinates), this function estimates the error in world space.
 

Static Public Member Functions

static Q_DECL_DEPRECATED QMap< QString, Qgs3DMapScene * > openScenes ()
 Returns a map of 3D map scenes (by name) open in the QGIS application.
 

Static Public Attributes

static std::function< QMap< QString, Qgs3DMapScene * >() > sOpenScenesFunction = [] { return QMap< QString, Qgs3DMapScene * >(); }
 Static function for returning open 3D map scenes.
 

Detailed Description

3

Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children.

Definition at line 67 of file qgs3dmapscene.h.

Member Enumeration Documentation

◆ SceneState

Enumeration of possible states of the 3D scene.

Enumerator
Ready 

The scene is fully loaded/updated.

Updating 

The scene is still being loaded/updated.

Definition at line 115 of file qgs3dmapscene.h.

Constructor & Destructor Documentation

◆ Qgs3DMapScene()

Qgs3DMapScene::Qgs3DMapScene ( Qgs3DMapSettings map,
QgsAbstract3DEngine engine 
)

Constructs a 3D scene based on map settings and Qt 3D renderer configuration.

Definition at line 87 of file qgs3dmapscene.cpp.

Member Function Documentation

◆ cameraController()

QgsCameraController * Qgs3DMapScene::cameraController ( ) const
inline

Returns camera controller.

Definition at line 80 of file qgs3dmapscene.h.

◆ disableClipping()

void Qgs3DMapScene::disableClipping ( )

Disables OpenGL clipping.

See also
enableClipping()
Since
QGIS 3.40

Definition at line 1240 of file qgs3dmapscene.cpp.

◆ elevationRange()

QgsDoubleRange Qgs3DMapScene::elevationRange ( ) const

Returns the scene's elevation range.

Note
Only some layer types are considered by this method (eg terrain, point cloud and mesh layers)
Since
QGIS 3.30

Definition at line 1067 of file qgs3dmapscene.cpp.

◆ enableClipping()

void Qgs3DMapScene::enableClipping ( const QList< QVector4D > &  clipPlaneEquations)

Enables OpenGL clipping based on the planes equations defined in clipPlaneEquations.

The number of planes is equal to the size of clipPlaneEquations. A plane equation contains 4 elements. A simple way to define a clip plane equation is to define a normalized normal to the plane and its distance from the origin of the scene. In that case, the first 3 elements are the coordinates of the normal of the plane as (X, Y, Z). They need to be normalized. The last element is the distance of the plane from the origin of the scene. In mathematical terms, a 3d plane can be defined with the equation ax+by+cz+d=0 The normal is (a, b, c) with |a, b, c| = 1 The distance is -d.

By default, OpenGL supports up to 8 additional clipping planes. If clipPlaneEquations contains more than 8 planes, only the first 8 ones will be used. If clipPlaneEquations is empty, the clipping is disabled.

See also
disableClipping()
Since
QGIS 3.40

Definition at line 1224 of file qgs3dmapscene.cpp.

◆ engine()

QgsAbstract3DEngine * Qgs3DMapScene::engine ( ) const
inline

Returns the abstract 3D engine.

Since
QGIS 3.26

Definition at line 181 of file qgs3dmapscene.h.

◆ exportScene()

void Qgs3DMapScene::exportScene ( const Qgs3DMapExportSettings exportSettings)

Exports the scene according to the scene export settings.

Definition at line 999 of file qgs3dmapscene.cpp.

◆ fpsCountChanged

void Qgs3DMapScene::fpsCountChanged ( float  fpsCount)
signal

Emitted when the FPS count changes.

◆ fpsCounterEnabledChanged

void Qgs3DMapScene::fpsCounterEnabledChanged ( bool  fpsCounterEnabled)
signal

Emitted when the FPS counter is activated or deactivated.

◆ get3DAxis()

Qgs3DAxis * Qgs3DMapScene::get3DAxis ( ) const
inline

Returns the 3D axis object.

Since
QGIS 3.26

Definition at line 174 of file qgs3dmapscene.h.

◆ getLayerActiveChunkNodes()

QVector< const QgsChunkNode * > Qgs3DMapScene::getLayerActiveChunkNodes ( QgsMapLayer layer)

Returns the active chunk nodes of layer.

Since
QGIS 3.18

Definition at line 1049 of file qgs3dmapscene.cpp.

◆ gpuMemoryLimitReached

void Qgs3DMapScene::gpuMemoryLimitReached ( )
signal

Emitted when one of the entities reaches its GPU memory limit and it is not possible to lower the GPU memory use by unloading data that's not currently needed.

◆ hasSceneUpdatesEnabled()

bool Qgs3DMapScene::hasSceneUpdatesEnabled ( ) const
inline

Returns whether updates of the 3D scene's entities are allowed.

Normally, scene updates are enabled. But for debugging purposes, it may be useful to temporarily disable scene updates.

Since
QGIS 3.40

Definition at line 197 of file qgs3dmapscene.h.

◆ layerEntity()

Qt3DCore::QEntity * Qgs3DMapScene::layerEntity ( QgsMapLayer layer) const
inline

Returns the entity belonging to layer.

Since
QGIS 3.32

Definition at line 152 of file qgs3dmapscene.h.

◆ layers()

QList< QgsMapLayer * > Qgs3DMapScene::layers ( ) const
inline

Returns the layers that contain chunked entities.

Since
QGIS 3.32

Definition at line 145 of file qgs3dmapscene.h.

◆ mapSettings()

Qgs3DMapSettings * Qgs3DMapScene::mapSettings ( ) const
inline

Returns the 3D map settings.

Since
QGIS 3.30

Definition at line 188 of file qgs3dmapscene.h.

◆ openScenes()

QMap< QString, Qgs3DMapScene * > Qgs3DMapScene::openScenes ( )
static

Returns a map of 3D map scenes (by name) open in the QGIS application.

Note
Only available from the QGIS desktop application.
Deprecated:
QGIS 3.36. Use QgisAppInterface::mapCanvases3D() instead.
Since
QGIS 3.30

Definition at line 1131 of file qgs3dmapscene.cpp.

◆ sceneExtent()

QgsRectangle Qgs3DMapScene::sceneExtent ( ) const

Returns the scene extent in the map's CRS.

Since
QGIS 3.20

Definition at line 1062 of file qgs3dmapscene.cpp.

◆ sceneState()

SceneState Qgs3DMapScene::sceneState ( ) const
inline

Returns the current state of the scene.

Definition at line 122 of file qgs3dmapscene.h.

◆ sceneStateChanged

void Qgs3DMapScene::sceneStateChanged ( )
signal

Emitted when the scene's state has changed.

◆ setSceneUpdatesEnabled()

void Qgs3DMapScene::setSceneUpdatesEnabled ( bool  enabled)
inline

Sets whether updates of the 3D scene's entities are allowed.

Normally, scene updates are enabled. But for debugging purposes, it may be useful to temporarily disable scene updates.

Since
QGIS 3.40

Definition at line 206 of file qgs3dmapscene.h.

◆ setViewFrom2DExtent()

void Qgs3DMapScene::setViewFrom2DExtent ( const QgsRectangle extent)

Resets camera view to show the extent extent (top view)

Since
QGIS 3.26

Definition at line 218 of file qgs3dmapscene.cpp.

◆ terrainEntity()

QgsTerrainEntity * Qgs3DMapScene::terrainEntity ( )
inline

Returns terrain entity (may be temporarily nullptr)

Note
Not available in Python bindings

Definition at line 86 of file qgs3dmapscene.h.

◆ terrainEntityChanged

void Qgs3DMapScene::terrainEntityChanged ( )
signal

Emitted when the current terrain entity is replaced by a new one.

◆ terrainPendingJobsCount()

int Qgs3DMapScene::terrainPendingJobsCount ( ) const

Returns number of pending jobs of the terrain entity.

Definition at line 271 of file qgs3dmapscene.cpp.

◆ terrainPendingJobsCountChanged

void Qgs3DMapScene::terrainPendingJobsCountChanged ( )
signal

Emitted when the number of terrain's pending jobs changes.

◆ totalPendingJobsCount()

int Qgs3DMapScene::totalPendingJobsCount ( ) const

Returns number of pending jobs for all chunked entities.

Since
QGIS 3.12

Definition at line 276 of file qgs3dmapscene.cpp.

◆ totalPendingJobsCountChanged

void Qgs3DMapScene::totalPendingJobsCountChanged ( )
signal

Emitted when the total number of pending jobs changes.

Since
QGIS 3.12

◆ updateTemporal

void Qgs3DMapScene::updateTemporal ( )
slot

Updates the temporale entities.

Definition at line 583 of file qgs3dmapscene.cpp.

◆ viewed2DExtentFrom3DChanged

void Qgs3DMapScene::viewed2DExtentFrom3DChanged ( QVector< QgsPointXY extent)
signal

Emitted when the viewed 2D extent seen by the 3D camera has changed.

Since
QGIS 3.26

◆ viewFrustum2DExtent()

QVector< QgsPointXY > Qgs3DMapScene::viewFrustum2DExtent ( ) const

Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid.

Since
QGIS 3.26

Definition at line 241 of file qgs3dmapscene.cpp.

◆ viewZoomFull()

void Qgs3DMapScene::viewZoomFull ( )

Resets camera view to show the whole scene (top view)

Definition at line 207 of file qgs3dmapscene.cpp.

◆ worldSpaceError()

float Qgs3DMapScene::worldSpaceError ( float  epsilon,
float  distance 
) const

Given screen error (in pixels) and distance from camera (in 3D world coordinates), this function estimates the error in world space.

Takes into account camera's field of view and the screen (3D view) size.

Definition at line 284 of file qgs3dmapscene.cpp.

Member Data Documentation

◆ sOpenScenesFunction

std::function< QMap< QString, Qgs3DMapScene * >() > Qgs3DMapScene::sOpenScenesFunction = [] { return QMap< QString, Qgs3DMapScene * >(); }
static

Static function for returning open 3D map scenes.

Definition at line 85 of file qgs3dmapscene.h.


The documentation for this class was generated from the following files: