Class: Qgs3DMapCanvas

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.

Note

The default surface must be set before the construction of the QApplication when using shared OpenGL context.

Note

This is required in order to use QT3d and QtWebEngine at the same time.

Added in version 3.36.

Class Hierarchy

Inheritance diagram of qgis._3d.Qgs3DMapCanvas

Base classes

QWindow

QObject

QSurface

Methods

cameraController

Returns access to the view's camera controller.

castRay

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

crossSectionEnabled

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

crossSectionEnabledChanged

Emitted when the cross section mode is enabled or disabled

disableCrossSection

disableCrossSection Disables the cross section mode and removes the scene's clipping planes

enableCrossSection

Enables cross section mode for the 3D map canvas.

mapSettings

Returns access to the 3D scene configuration

mapTool

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

scene

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

setMapTool

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

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of Qgs3DMapCanvas. See the FAQ for more details.

resizeEvent

Resets the aspect ratio of the 3D window.

showEvent

Manages the display events specified in e.

class qgis._3d.Qgs3DMapCanvas[source]

Bases: QWindow

cameraController(self) QgsCameraController | None[source]

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

Return type:

Optional[QgsCameraController]

castRay(self, screenPoint: QPoint, context: QgsRayCastContext) QgsRayCastResult[source]

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

Parameters:
  • screenPoint (QPoint) – The ray starts from the current camera center and goes through this point (in pixel coordinates, originating at top left corner).

  • context (QgsRayCastContext) – A context object defining parameters for the ray casting.

Added in version 4.0.

Return type:

QgsRayCastResult

crossSectionEnabled(self) bool[source]

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

Added in version 4.0.

Return type:

bool

crossSectionEnabledChanged(self, enabled: bool)[source]

Emitted when the cross section mode is enabled or disabled

Added in version 4.0.

Parameters:

enabled (bool)

disableCrossSection(self)[source]

disableCrossSection Disables the cross section mode and removes the scene’s clipping planes

Added in version 4.0.

enableCrossSection(self, startPoint: QgsPointXY, endPoint: QgsPointXY, tolerance: float, setSideView: bool = True)[source]

Enables cross section mode for the 3D map canvas. The 3D scene will be clipped by four clipping planes, defined by a cross section line segment from startPoint to endPoint and two parallel segments at distance tolerance to each side.

Parameters:
  • startPoint (QgsPointXY) – The start point of the cross section line in 3D map coordinates.

  • endPoint (QgsPointXY) – The end point of the cross section line in 3D map coordinates.

  • tolerance (float) – The distance in meters between the cross section line and the left and right clipping planes.

  • setSideView (bool = True) – When True, the camera will be moved to look at the scene from the right side of the cross section line.

Added in version 4.0.

mapSettings(self) Qgs3DMapSettings | None[source]

Returns access to the 3D scene configuration

Return type:

Optional[Qgs3DMapSettings]

mapTool(self) Qgs3DMapTool | None[source]

Returns the active map tool that will receive events from the 3D canvas. If the tool is None, events will be used for camera manipulation.

Added in version 4.0.

Return type:

Optional[Qgs3DMapTool]

virtual resizeEvent(self, a0: QResizeEvent | None)[source]

Resets the aspect ratio of the 3D window.

Parameters:

a0 (Optional[QResizeEvent])

scene(self) Qgs3DMapScene | None[source]

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

Return type:

Optional[Qgs3DMapScene]

setMapTool(self, tool: Qgs3DMapTool | None)[source]

Sets the active map tool that will receive events from the 3D canvas. Does not transfer ownership. If the tool is None, events will be used for camera manipulation.

Added in version 4.0.

Parameters:

tool (Optional[Qgs3DMapTool])

virtual showEvent(self, e: QShowEvent | None)[source]

Manages the display events specified in e.

Parameters:

e (Optional[QShowEvent])