QGIS API Documentation 3.99.0-Master (8e76e220402)
Loading...
Searching...
No Matches
Qgs3DMapCanvas Class Reference

Convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS. More...

#include <qgs3dmapcanvas.h>

Inheritance diagram for Qgs3DMapCanvas:

Public Slots

void clearHighlights ()
 Removes all highlight entities.
void highlightFeature (const QgsFeature &feature, QgsMapLayer *layer)
 Add a highlight 3d entity for feature of layer.

Signals

void cameraNavigationSpeedChanged (double speed)
 Emitted when the camera navigation speed is changed.
void crossSectionEnabledChanged (bool enabled)
 Emitted when the cross section mode is enabled or disabled.
void fpsCountChanged (float fpsCount)
 Emitted when the FPS count changes (at most every frame).
void fpsCounterEnabledChanged (bool enabled)
 Emitted when the FPS counter is enabled or disabeld.
void mapSettingsChanged ()
 Emitted when the the map setting is changed.
void savedAsImage (const QString &fileName)
 Emitted when the 3D map canvas was successfully saved as image.
void viewed2DExtentFrom3DChanged (QVector< QgsPointXY > extent)
 Emitted when the viewed 2D extent seen by the 3D camera has changed.

Public Member Functions

 Qgs3DMapCanvas ()
 ~Qgs3DMapCanvas () override
Qt3DRender::QFrameGraphNode * activeFrameGraph () const
 Returns the node of the active frame graph.
Qt3DRender::QCamera * camera () const
 Returns the default camera of the 3D Window.
QgsCameraControllercameraController ()
 Returns access to the view's camera controller. Returns nullptr if the scene has not been initialized yet with setMapSettings().
QgsRayCastResult castRay (const QPoint &screenPoint, QgsRayCastContext context)
 Casts a ray towards the 3d scene and returns information about the intersected 3d entities.
QgsCrossSection crossSection () const
 Returns the current cross section definition for the 3D map canvas.
bool crossSectionEnabled () const
 Returns true if the cross section mode is enabled or the 3d scene has other clipping planes applied.
QgsWindow3DEngineengine () const
 Returns the 3D engine.
Qgs3DMapSettingsmapSettings ()
 Returns access to the 3D scene configuration.
Qgs3DMapToolmapTool () const
 Returns the active map tool that will receive events from the 3D canvas.
Qt3DRender::QRenderSettings * renderSettings () const
 Returns the render settings of the 3D Window.
void resetView ()
 Resets camera position to the default: looking down at the origin of world coordinates.
void saveAsImage (const QString &fileName, const QString &fileFormat)
 Saves the current scene as an image.
Qgs3DMapScenescene ()
 Returns access to the 3D scene (root 3D entity).
void setActiveFrameGraph (Qt3DRender::QFrameGraphNode *activeFrameGraph)
 Activates the specified activeFrameGraph.
void setCrossSection (const QgsCrossSection &crossSection)
 Sets the cross section definition for the 3D map canvas.
void setMapSettings (Qgs3DMapSettings *mapSettings)
 Configure map scene being displayed. Takes ownership.
void setMapTool (Qgs3DMapTool *tool)
 Sets the active map tool that will receive events from the 3D canvas.
void setRootEntity (Qt3DCore::QEntity *root)
 Sets the specified root entity of the scene.
void setTemporalController (QgsTemporalController *temporalController)
 Sets the temporal controller.
void setViewFrom2DExtent (const QgsRectangle &extent)
 Resets camera view to show the extent (top view).
void setViewFromTop (const QgsPointXY &center, float distance, float rotation=0)
 Sets camera position to look down at the given point (in map coordinates) in given distance from plane with zero elevation.
QVector< QgsPointXYviewFrustum2DExtent ()
 Calculates the 2D extent viewed by the 3D camera as the vertices of the viewed trapezoid.

Protected Member Functions

bool eventFilter (QObject *watched, QEvent *event) override
void resizeEvent (QResizeEvent *) override
 Resets the aspect ratio of the 3D window.
void showEvent (QShowEvent *e) override
 Manages the display events specified in e.

Detailed Description

Convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.

Note
This is a port of qtwindow3d which does not set the default surface when initialized.
The default surface must be set before the construction of the QApplication when using shared OpenGL context.
This is required in order to use QT3d and QtWebEngine at the same time.
Since
QGIS 3.36

Definition at line 88 of file qgs3dmapcanvas.h.

Constructor & Destructor Documentation

◆ Qgs3DMapCanvas()

Qgs3DMapCanvas::Qgs3DMapCanvas ( )

Definition at line 43 of file qgs3dmapcanvas.cpp.

◆ ~Qgs3DMapCanvas()

Qgs3DMapCanvas::~Qgs3DMapCanvas ( )
override

Definition at line 78 of file qgs3dmapcanvas.cpp.

Member Function Documentation

◆ activeFrameGraph()

Qt3DRender::QFrameGraphNode * Qgs3DMapCanvas::activeFrameGraph ( ) const

Returns the node of the active frame graph.

Definition at line 108 of file qgs3dmapcanvas.cpp.

◆ camera()

Qt3DRender::QCamera * Qgs3DMapCanvas::camera ( ) const

Returns the default camera of the 3D Window.

Definition at line 113 of file qgs3dmapcanvas.cpp.

◆ cameraController()

QgsCameraController * Qgs3DMapCanvas::cameraController ( )

Returns access to the view's camera controller. Returns nullptr if the scene has not been initialized yet with setMapSettings().

Definition at line 183 of file qgs3dmapcanvas.cpp.

◆ cameraNavigationSpeedChanged

void Qgs3DMapCanvas::cameraNavigationSpeedChanged ( double speed)
signal

Emitted when the camera navigation speed is changed.

◆ castRay()

QgsRayCastResult Qgs3DMapCanvas::castRay ( const QPoint & screenPoint,
QgsRayCastContext context )

Casts a ray towards the 3d scene and returns information about the intersected 3d entities.

Parameters
screenPointThe ray starts from the current camera center and goes through this point (in pixel coordinates, originating at top left corner).
contextA context object defining parameters for the ray casting.
Since
QGIS 4.0

Definition at line 188 of file qgs3dmapcanvas.cpp.

◆ clearHighlights

void Qgs3DMapCanvas::clearHighlights ( )
slot

Removes all highlight entities.

Note
Not available in Python bindings.
Since
QGIS 4.0

Definition at line 410 of file qgs3dmapcanvas.cpp.

◆ crossSection()

QgsCrossSection Qgs3DMapCanvas::crossSection ( ) const
inline

Returns the current cross section definition for the 3D map canvas.

Since
QGIS 4.0

Definition at line 147 of file qgs3dmapcanvas.h.

◆ crossSectionEnabled()

bool Qgs3DMapCanvas::crossSectionEnabled ( ) const

Returns true if the cross section mode is enabled or the 3d scene has other clipping planes applied.

Since
QGIS 4.0

Definition at line 229 of file qgs3dmapcanvas.cpp.

◆ crossSectionEnabledChanged

void Qgs3DMapCanvas::crossSectionEnabledChanged ( bool enabled)
signal

Emitted when the cross section mode is enabled or disabled.

Since
QGIS 4.0

◆ engine()

QgsWindow3DEngine * Qgs3DMapCanvas::engine ( ) const
inline

Returns the 3D engine.

Definition at line 191 of file qgs3dmapcanvas.h.

◆ eventFilter()

bool Qgs3DMapCanvas::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected

Definition at line 313 of file qgs3dmapcanvas.cpp.

◆ fpsCountChanged

void Qgs3DMapCanvas::fpsCountChanged ( float fpsCount)
signal

Emitted when the FPS count changes (at most every frame).

◆ fpsCounterEnabledChanged

void Qgs3DMapCanvas::fpsCounterEnabledChanged ( bool enabled)
signal

Emitted when the FPS counter is enabled or disabeld.

◆ highlightFeature

void Qgs3DMapCanvas::highlightFeature ( const QgsFeature & feature,
QgsMapLayer * layer )
slot

Add a highlight 3d entity for feature of layer.

Note
Currently only supports vector layers with polygon features and point cloud layers with features generated by QgsIdentifyResultsDialog.
Not available in Python bindings.
Since
QGIS 4.0

Definition at line 405 of file qgs3dmapcanvas.cpp.

◆ mapSettings()

Qgs3DMapSettings * Qgs3DMapCanvas::mapSettings ( )
inline

Returns access to the 3D scene configuration.

Definition at line 96 of file qgs3dmapcanvas.h.

◆ mapSettingsChanged

void Qgs3DMapCanvas::mapSettingsChanged ( )
signal

Emitted when the the map setting is changed.

◆ mapTool()

Qgs3DMapTool * Qgs3DMapCanvas::mapTool ( ) const
inline

Returns the active map tool that will receive events from the 3D canvas.

If the tool is nullptr, events will be used for camera manipulation.

Since
QGIS 4.0

Definition at line 116 of file qgs3dmapcanvas.h.

◆ renderSettings()

Qt3DRender::QRenderSettings * Qgs3DMapCanvas::renderSettings ( ) const

Returns the render settings of the 3D Window.

Definition at line 118 of file qgs3dmapcanvas.cpp.

◆ resetView()

void Qgs3DMapCanvas::resetView ( )

Resets camera position to the default: looking down at the origin of world coordinates.

Definition at line 234 of file qgs3dmapcanvas.cpp.

◆ resizeEvent()

void Qgs3DMapCanvas::resizeEvent ( QResizeEvent * )
overrideprotected

Resets the aspect ratio of the 3D window.

Definition at line 136 of file qgs3dmapcanvas.cpp.

◆ saveAsImage()

void Qgs3DMapCanvas::saveAsImage ( const QString & fileName,
const QString & fileFormat )

Saves the current scene as an image.

Definition at line 252 of file qgs3dmapcanvas.cpp.

◆ savedAsImage

void Qgs3DMapCanvas::savedAsImage ( const QString & fileName)
signal

Emitted when the 3D map canvas was successfully saved as image.

◆ scene()

Qgs3DMapScene * Qgs3DMapCanvas::scene ( )
inline

Returns access to the 3D scene (root 3D entity).

Definition at line 99 of file qgs3dmapcanvas.h.

◆ setActiveFrameGraph()

void Qgs3DMapCanvas::setActiveFrameGraph ( Qt3DRender::QFrameGraphNode * activeFrameGraph)

Activates the specified activeFrameGraph.

Definition at line 103 of file qgs3dmapcanvas.cpp.

◆ setCrossSection()

void Qgs3DMapCanvas::setCrossSection ( const QgsCrossSection & crossSection)

Sets the cross section definition for the 3D map canvas.

The 3D scene will be clipped by four clipping planes, defined by a cross section line segment and two parallel segments at cross section half width to each side. Passing an invalid cross section will disable the clipping.

Parameters
crossSectionThe cross section definition
Since
QGIS 4.0

Definition at line 197 of file qgs3dmapcanvas.cpp.

◆ setMapSettings()

void Qgs3DMapCanvas::setMapSettings ( Qgs3DMapSettings * mapSettings)

Configure map scene being displayed. Takes ownership.

Definition at line 143 of file qgs3dmapcanvas.cpp.

◆ setMapTool()

void Qgs3DMapCanvas::setMapTool ( Qgs3DMapTool * tool)

Sets the active map tool that will receive events from the 3D canvas.

Does not transfer ownership. If the tool is nullptr, events will be used for camera manipulation.

Since
QGIS 4.0

Definition at line 286 of file qgs3dmapcanvas.cpp.

◆ setRootEntity()

void Qgs3DMapCanvas::setRootEntity ( Qt3DCore::QEntity * root)

Sets the specified root entity of the scene.

Definition at line 91 of file qgs3dmapcanvas.cpp.

◆ setTemporalController()

void Qgs3DMapCanvas::setTemporalController ( QgsTemporalController * temporalController)

Sets the temporal controller.

Definition at line 369 of file qgs3dmapcanvas.cpp.

◆ setViewFrom2DExtent()

void Qgs3DMapCanvas::setViewFrom2DExtent ( const QgsRectangle & extent)

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

Definition at line 392 of file qgs3dmapcanvas.cpp.

◆ setViewFromTop()

void Qgs3DMapCanvas::setViewFromTop ( const QgsPointXY & center,
float distance,
float rotation = 0 )

Sets camera position to look down at the given point (in map coordinates) in given distance from plane with zero elevation.

Definition at line 242 of file qgs3dmapcanvas.cpp.

◆ showEvent()

void Qgs3DMapCanvas::showEvent ( QShowEvent * e)
overrideprotected

Manages the display events specified in e.

Definition at line 123 of file qgs3dmapcanvas.cpp.

◆ viewed2DExtentFrom3DChanged

void Qgs3DMapCanvas::viewed2DExtentFrom3DChanged ( QVector< QgsPointXY > extent)
signal

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

◆ viewFrustum2DExtent()

QVector< QgsPointXY > Qgs3DMapCanvas::viewFrustum2DExtent ( )

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

Definition at line 400 of file qgs3dmapcanvas.cpp.


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