Class: QgsCameraController

Class Hierarchy

Inheritance diagram of qgis._3d.QgsCameraController

Base classes

QObject

Methods

cameraMovementSpeed

Returns the camera movement speed

cameraNavigationMode

Returns the navigation mode used by the camera controller.

cameraPose

Returns camera pose

depthBufferCaptured

Sets the depth buffer image used by the camera controller to calculate world position from a pixel's coordinates and depth

distance

Returns distance of the camera from the point it is looking at.

frameTriggered

Called internally from 3D scene when a new frame is generated.

globeMoveCenterPoint

Orbits camera around the globe by the specified amount given as the difference in latitude/longitude angles (in degrees)

globeUpdateHeadingAngle

Updates heading angle by the specified amount given as the angular difference in degrees

globeUpdatePitchAngle

Updates pitch angle by the specified amount given as the angular difference in degrees

globeZoom

Moves camera closer or further away from the globe.

hasInputHandlersEnabled

Returns whether the camera controller responds to mouse and keyboard events

keyboardEventFilter

If the event is relevant, handles the event and returns True, otherwise False.

lookingAtMapPoint

Returns the point in the map coordinates towards which the camera is looking

lookingAtPoint

Returns the point in the world coordinates towards which the camera is looking

moveView

Move the map by tx and ty

origin

Returns the origin of the scene in map coordinates

pitch

Returns pitch angle in degrees (0 = looking from the top, 90 = looking from the side).

readXml

Reads camera configuration from the given DOM element

resetGlobe

Resets view of the globe to look at a particular location given as latitude and longitude (in degrees) and distance from that point on ellipsoid

resetView

Move camera back to the initial position (looking down towards origin of world's coordinates)

rotateAroundViewCenter

Rotate clockwise the view by deltaYaw around the view center (camera moves)

rotateCamera

Rotates the camera on itself.

rotateCameraAroundPivot

Rotates the camera around the pivot point (in world coordinates) to the given new pitch and heading angle.

rotateCameraToBottom

rotateCameraToEast

rotateCameraToHome

rotateCameraToNorth

rotateCameraToSouth

rotateCameraToTop

rotateCameraToWest

setCameraHeadingAngle

Set camera heading to angle (used for rotating the view)

setCameraMovementSpeed

Sets the camera movement speed

setCameraNavigationMode

Sets the navigation mode used by the camera controller.

setCameraPose

Sets camera pose

setInputHandlersEnabled

Sets whether the camera controller responds to mouse and keyboard events

setLookingAtMapPoint

Sets camera configuration like setLookingAtPoint(), but the point is given in map coordinates

setLookingAtPoint

Sets the complete camera configuration: the point towards it is looking (in 3D world coordinates), the distance of the camera from the point, pitch angle in degrees (0 = looking from the top, 90 = looking from the side) and yaw angle in degrees.

setOrigin

Reacts to the shift of origin of the scene, updating camera pose and any other member variables so that the origin stays at the same position relative to other entities.

setVerticalAxisInversion

Sets the vertical axis inversion behavior.

setViewFromTop

Sets camera to look down towards given point in world coordinate, in given distance from plane with zero elevation

tiltUpAroundViewCenter

Tilt up the view by deltaPitch around the view center (camera moves)

verticalAxisInversion

Returns the vertical axis inversion behavior.

walkView

Walks into the map by tx, ty, and tz

writeXml

Writes camera configuration to the given DOM element

yaw

Returns yaw angle in degrees.

zoom

Zoom the map by factor

zoomCameraAroundPivot

Zooms camera by given zoom factor (>1 one means zoom in) while keeping the pivot point (given in world coordinates) at the same screen coordinates after the zoom.

Signals

cameraChanged

Emitted when camera has been updated

cameraMovementSpeedChanged

Emitted whenever the camera movement speed is changed by the controller.

cameraRotationCenterChanged

Emitted when the camera rotation center changes

navigationModeChanged

Emitted when the navigation mode is changed using the hotkey ctrl + ~

requestDepthBufferCapture

Emitted to ask for the depth buffer image

setCursorPosition

Emitted when the mouse cursor position should be moved to the specified point on the map viewport.

class qgis._3d.QgsCameraController[source]

Bases: QObject

signal cameraChanged[source]

Emitted when camera has been updated

cameraMovementSpeed(self) float[source]

Returns the camera movement speed

Added in version 3.18.

Return type:

float

signal cameraMovementSpeedChanged(speed: float)[source]

Emitted whenever the camera movement speed is changed by the controller.

Parameters:

speed (float)

cameraNavigationMode(self) Qgis.NavigationMode[source]

Returns the navigation mode used by the camera controller.

Added in version 3.18.

Return type:

Qgis.NavigationMode

cameraPose(self) QgsCameraPose[source]

Returns camera pose

Added in version 3.4.

Return type:

QgsCameraPose

signal cameraRotationCenterChanged(position: QVector3D)[source]

Emitted when the camera rotation center changes

Added in version 3.24.

Parameters:

position (QVector3D)

depthBufferCaptured(self, depthImage: QImage)[source]

Sets the depth buffer image used by the camera controller to calculate world position from a pixel’s coordinates and depth

Added in version 3.24.

Parameters:

depthImage (QImage)

distance(self) float[source]

Returns distance of the camera from the point it is looking at. The value should not be smaller than 10.

Added in version 3.4.

Return type:

float

frameTriggered(self, dt: float)[source]

Called internally from 3D scene when a new frame is generated. Updates camera according to keyboard/mouse input

Parameters:

dt (float)

globeMoveCenterPoint(self, latDiff: float, lonDiff: float)[source]

Orbits camera around the globe by the specified amount given as the difference in latitude/longitude angles (in degrees)

Note

the final latitude gets clamped to 0-90 degrees, while the longitude does not get clamped

Added in version 3.44.

Parameters:
  • latDiff (float)

  • lonDiff (float)

globeUpdateHeadingAngle(self, angleDiff: float)[source]

Updates heading angle by the specified amount given as the angular difference in degrees

Added in version 3.44.

Parameters:

angleDiff (float)

globeUpdatePitchAngle(self, angleDiff: float)[source]

Updates pitch angle by the specified amount given as the angular difference in degrees

Added in version 3.44.

Parameters:

angleDiff (float)

globeZoom(self, factor: float)[source]

Moves camera closer or further away from the globe. Use factor greater than one to zoom in, or less than one to zoom out.

Added in version 3.44.

Parameters:

factor (float)

hasInputHandlersEnabled(self) bool[source]

Returns whether the camera controller responds to mouse and keyboard events

Added in version 3.44.

Return type:

bool

keyboardEventFilter(self, event: QKeyEvent | None) bool[source]

If the event is relevant, handles the event and returns True, otherwise False.

Added in version 3.44.

Parameters:

event (Optional[QKeyEvent])

Return type:

bool

lookingAtMapPoint(self) QgsVector3D[source]

Returns the point in the map coordinates towards which the camera is looking

Added in version 3.44.

Return type:

QgsVector3D

lookingAtPoint(self) QgsVector3D[source]

Returns the point in the world coordinates towards which the camera is looking

Return type:

QgsVector3D

moveView(self, tx: float, ty: float)[source]

Move the map by tx and ty

Parameters:
  • tx (float)

  • ty (float)

signal navigationModeChanged(mode: Qgis.NavigationMode)[source]

Emitted when the navigation mode is changed using the hotkey ctrl + ~

Parameters:

mode (Qgis.NavigationMode)

origin(self) QgsVector3D[source]

Returns the origin of the scene in map coordinates

Added in version 3.44.

Return type:

QgsVector3D

pitch(self) float[source]

Returns pitch angle in degrees (0 = looking from the top, 90 = looking from the side). The angle should range from 0 to 180.

Added in version 3.4.

Return type:

float

readXml(self, elem: QDomElement, savedOrigin: QgsVector3D)[source]

Reads camera configuration from the given DOM element

Parameters:
signal requestDepthBufferCapture[source]

Emitted to ask for the depth buffer image

Added in version 3.24.

resetGlobe(self, distance: float, lat: float = 0, lon: float = 0)[source]

Resets view of the globe to look at a particular location given as latitude and longitude (in degrees) and distance from that point on ellipsoid

Added in version 3.44.

Parameters:
  • distance (float)

  • lat (float = 0)

  • lon (float = 0)

resetView(self, distance: float)[source]

Move camera back to the initial position (looking down towards origin of world’s coordinates)

Parameters:

distance (float)

rotateAroundViewCenter(self, deltaYaw: float)[source]

Rotate clockwise the view by deltaYaw around the view center (camera moves)

Parameters:

deltaYaw (float)

rotateCamera(self, diffPitch: float, diffYaw: float)[source]

Rotates the camera on itself.

Parameters:
  • diffPitch (float) – the pitch difference

  • diffYaw (float) – the yaw difference

Added in version 3.30.

rotateCameraAroundPivot(self, newPitch: float, newHeading: float, pivotPoint: QVector3D)[source]

Rotates the camera around the pivot point (in world coordinates) to the given new pitch and heading angle.

Added in version 3.42.

Parameters:
  • newPitch (float)

  • newHeading (float)

  • pivotPoint (QVector3D)

rotateCameraToBottom(self)[source]

Added in version 3.44.

rotateCameraToEast(self)[source]

Added in version 3.44.

rotateCameraToHome(self)[source]

Added in version 3.44.

rotateCameraToNorth(self)[source]

Added in version 3.44.

rotateCameraToSouth(self)[source]

Added in version 3.44.

rotateCameraToTop(self)[source]

Added in version 3.44.

rotateCameraToWest(self)[source]

Added in version 3.44.

setCameraHeadingAngle(self, angle: float)[source]

Set camera heading to angle (used for rotating the view)

Parameters:

angle (float)

setCameraMovementSpeed(self, movementSpeed: float)[source]

Sets the camera movement speed

Added in version 3.18.

Parameters:

movementSpeed (float)

setCameraNavigationMode(self, navigationMode: Qgis.NavigationMode)[source]

Sets the navigation mode used by the camera controller.

Added in version 3.18.

Parameters:

navigationMode (Qgis.NavigationMode)

setCameraPose(self, camPose: QgsCameraPose, force: bool = False)[source]

Sets camera pose

Added in version 3.4.

Parameters:
signal setCursorPosition(point: QPoint)[source]

Emitted when the mouse cursor position should be moved to the specified point on the map viewport.

Parameters:

point (QPoint)

setInputHandlersEnabled(self, enable: bool)[source]

Sets whether the camera controller responds to mouse and keyboard events

Added in version 3.42.

Parameters:

enable (bool)

setLookingAtMapPoint(self, point: QgsVector3D, distance: float, pitch: float, yaw: float)[source]

Sets camera configuration like setLookingAtPoint(), but the point is given in map coordinates

Added in version 3.44.

Parameters:
  • point (QgsVector3D)

  • distance (float)

  • pitch (float)

  • yaw (float)

setLookingAtPoint(self, point: QgsVector3D, distance: float, pitch: float, yaw: float)[source]

Sets the complete camera configuration: the point towards it is looking (in 3D world coordinates), the distance of the camera from the point, pitch angle in degrees (0 = looking from the top, 90 = looking from the side) and yaw angle in degrees.

Added in version 3.4.

Parameters:
  • point (QgsVector3D)

  • distance (float)

  • pitch (float)

  • yaw (float)

setOrigin(self, origin: QgsVector3D)[source]

Reacts to the shift of origin of the scene, updating camera pose and any other member variables so that the origin stays at the same position relative to other entities.

Added in version 3.42.

Parameters:

origin (QgsVector3D)

setVerticalAxisInversion(self, inversion: Qgis.VerticalAxisInversion)[source]

Sets the vertical axis inversion behavior.

Added in version 3.18.

Parameters:

inversion (Qgis.VerticalAxisInversion)

setViewFromTop(self, worldX: float, worldY: float, distance: float, yaw: float = 0)[source]

Sets camera to look down towards given point in world coordinate, in given distance from plane with zero elevation

Parameters:
  • worldX (float)

  • worldY (float)

  • distance (float)

  • yaw (float = 0)

tiltUpAroundViewCenter(self, deltaPitch: float)[source]

Tilt up the view by deltaPitch around the view center (camera moves)

Parameters:

deltaPitch (float)

verticalAxisInversion(self) Qgis.VerticalAxisInversion[source]

Returns the vertical axis inversion behavior.

Added in version 3.18.

Return type:

Qgis.VerticalAxisInversion

walkView(self, tx: float, ty: float, tz: float)[source]

Walks into the map by tx, ty, and tz

Added in version 3.30.

Parameters:
  • tx (float)

  • ty (float)

  • tz (float)

writeXml(self, doc: QDomDocument) QDomElement[source]

Writes camera configuration to the given DOM element

Parameters:

doc (QDomDocument)

Return type:

QDomElement

yaw(self) float[source]

Returns yaw angle in degrees. Yaw value of zero means the camera is pointing towards north. The angle should range from 0 to 360.

Added in version 3.4.

Return type:

float

zoom(self, factor: float)[source]

Zoom the map by factor

Parameters:

factor (float)

zoomCameraAroundPivot(self, oldCameraPosition: QVector3D, zoomFactor: float, pivotPoint: QVector3D)[source]

Zooms camera by given zoom factor (>1 one means zoom in) while keeping the pivot point (given in world coordinates) at the same screen coordinates after the zoom.

Added in version 3.42.

Parameters:
  • oldCameraPosition (QVector3D)

  • zoomFactor (float)

  • pivotPoint (QVector3D)