QGIS API Documentation 3.43.0-Master (3ee7834ace6)
Public Slots | Signals | Public Member Functions | Friends | List of all members
QgsCameraController Class Reference

3 More...

#include <qgscameracontroller.h>

Inheritance diagram for QgsCameraController:
Inheritance graph
[legend]

Public Slots

void depthBufferCaptured (const QImage &depthImage)
 Sets the depth buffer image used by the camera controller to calculate world position from a pixel's coordinates and depth.
 
void setCameraNavigationMode (Qgis::NavigationMode navigationMode)
 Sets the navigation mode used by the camera controller.
 

Signals

void cameraChanged ()
 Emitted when camera has been updated.
 
void cameraMovementSpeedChanged (double speed)
 Emitted whenever the camera movement speed is changed by the controller.
 
void cameraRotationCenterChanged (QVector3D position)
 Emitted when the camera rotation center changes.
 
void navigationModeChanged (Qgis::NavigationMode mode)
 Emitted when the navigation mode is changed using the hotkey ctrl + ~.
 
void requestDepthBufferCapture ()
 Emitted to ask for the depth buffer image.
 
void setCursorPosition (QPoint point)
 Emitted when the mouse cursor position should be moved to the specified point on the map viewport.
 

Public Member Functions

 QgsCameraController (Qgs3DMapScene *scene)
 Constructs the camera controller with optional parent node that will take ownership.
 
 ~QgsCameraController () override
 
Qt3DRender::QCamera * camera () const
 Returns camera that is being controlled.
 
double cameraMovementSpeed () const
 Returns the camera movement speed.
 
Qgis::NavigationMode cameraNavigationMode () const
 Returns the navigation mode used by the camera controller.
 
QgsCameraPose cameraPose () const
 Returns camera pose.
 
float distance () const
 Returns distance of the camera from the point it is looking at.
 
void frameTriggered (float dt)
 Called internally from 3D scene when a new frame is generated. Updates camera according to keyboard/mouse input.
 
void globeMoveCenterPoint (double latDiff, double lonDiff)
 Orbits camera around the globe by the specified amount given as the difference in latitude/longitude angles (in degrees)
 
void globeUpdateHeadingAngle (float angleDiff)
 Updates heading angle by the specified amount given as the angular difference in degrees.
 
void globeUpdatePitchAngle (float angleDiff)
 Updates pitch angle by the specified amount given as the angular difference in degrees.
 
void globeZoom (float factor)
 Moves camera closer or further away from the globe.
 
bool hasInputHandlersEnabled () const
 Returns whether the camera controller responds to mouse and keyboard events.
 
QgsVector3D lookingAtMapPoint () const
 Returns the point in the map coordinates towards which the camera is looking.
 
QgsVector3D lookingAtPoint () const
 Returns the point in the world coordinates towards which the camera is looking.
 
void moveView (float tx, float ty)
 Move the map by tx and ty.
 
float pitch () const
 Returns pitch angle in degrees (0 = looking from the top, 90 = looking from the side).
 
void readXml (const QDomElement &elem)
 Reads camera configuration from the given DOM element.
 
void resetGlobe (float distance, double lat=0, double lon=0)
 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.
 
void resetView (float distance)
 Move camera back to the initial position (looking down towards origin of world's coordinates)
 
void rotateAroundViewCenter (float deltaYaw)
 Rotate clockwise the view by deltaYaw around the view center (camera moves)
 
void rotateCamera (float diffPitch, float diffYaw)
 Rotates the camera on itself.
 
void rotateCameraAroundPivot (float newPitch, float newHeading, const QVector3D &pivotPoint)
 Rotates the camera around the pivot point (in world coordinates) to the given new pitch and heading angle.
 
void setCameraHeadingAngle (float angle)
 Set camera heading to angle (used for rotating the view)
 
void setCameraMovementSpeed (double movementSpeed)
 Sets the camera movement speed.
 
void setCameraPose (const QgsCameraPose &camPose, bool force=false)
 Sets camera pose.
 
void setInputHandlersEnabled (bool enable)
 Sets whether the camera controller responds to mouse and keyboard events.
 
void setLookingAtMapPoint (const QgsVector3D &point, float distance, float pitch, float yaw)
 Sets camera configuration like setLookingAtPoint(), but the point is given in map coordinates.
 
void setLookingAtPoint (const QgsVector3D &point, float distance, float pitch, float yaw)
 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.
 
void setOrigin (const QgsVector3D &origin)
 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.
 
void setVerticalAxisInversion (Qgis::VerticalAxisInversion inversion)
 Sets the vertical axis inversion behavior.
 
void setViewFromTop (float worldX, float worldY, float distance, float yaw=0)
 Sets camera to look down towards given point in world coordinate, in given distance from plane with zero elevation.
 
void tiltUpAroundViewCenter (float deltaPitch)
 Tilt up the view by deltaPitch around the view center (camera moves)
 
Qgis::VerticalAxisInversion verticalAxisInversion () const
 Returns the vertical axis inversion behavior.
 
void walkView (double tx, double ty, double tz)
 Walks into the map by tx, ty, and tz.
 
bool willHandleKeyEvent (QKeyEvent *event)
 Returns true if the camera controller will handle the specified key event, preventing it from being instead handled by parents of the 3D window before the controller ever receives it.
 
QDomElement writeXml (QDomDocument &doc) const
 Writes camera configuration to the given DOM element.
 
float yaw () const
 Returns yaw angle in degrees.
 
void zoom (float factor)
 Zoom the map by factor.
 
void zoomCameraAroundPivot (const QVector3D &oldCameraPosition, double zoomFactor, const QVector3D &pivotPoint)
 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.
 

Friends

class TestQgs3DCameraController
 
class TestQgs3DRendering
 

Detailed Description

3

Object that controls camera movement based on user input

Definition at line 57 of file qgscameracontroller.h.

Constructor & Destructor Documentation

◆ QgsCameraController()

QgsCameraController::QgsCameraController ( Qgs3DMapScene scene)

Constructs the camera controller with optional parent node that will take ownership.

Definition at line 33 of file qgscameracontroller.cpp.

◆ ~QgsCameraController()

QgsCameraController::~QgsCameraController ( )
overridedefault

Member Function Documentation

◆ camera()

Qt3DRender::QCamera * QgsCameraController::camera ( ) const
inline

Returns camera that is being controlled.

Note
Not available in Python bindings

Definition at line 76 of file qgscameracontroller.h.

◆ cameraChanged

void QgsCameraController::cameraChanged ( )
signal

Emitted when camera has been updated.

◆ cameraMovementSpeed()

double QgsCameraController::cameraMovementSpeed ( ) const
inline

Returns the camera movement speed.

Since
QGIS 3.18

Definition at line 89 of file qgscameracontroller.h.

◆ cameraMovementSpeedChanged

void QgsCameraController::cameraMovementSpeedChanged ( double  speed)
signal

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

◆ cameraNavigationMode()

Qgis::NavigationMode QgsCameraController::cameraNavigationMode ( ) const
inline

Returns the navigation mode used by the camera controller.

Since
QGIS 3.18

Definition at line 83 of file qgscameracontroller.h.

◆ cameraPose()

QgsCameraPose QgsCameraController::cameraPose ( ) const
inline

Returns camera pose.

Since
QGIS 3.4

Definition at line 151 of file qgscameracontroller.h.

◆ cameraRotationCenterChanged

void QgsCameraController::cameraRotationCenterChanged ( QVector3D  position)
signal

Emitted when the camera rotation center changes.

Since
QGIS 3.24

◆ depthBufferCaptured

void QgsCameraController::depthBufferCaptured ( const QImage &  depthImage)
slot

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

Since
QGIS 3.24

Definition at line 1285 of file qgscameracontroller.cpp.

◆ distance()

float QgsCameraController::distance ( ) const
inline

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

The value should not be smaller than 10.

Since
QGIS 3.4

Definition at line 158 of file qgscameracontroller.h.

◆ frameTriggered()

void QgsCameraController::frameTriggered ( float  dt)

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

Definition at line 168 of file qgscameracontroller.cpp.

◆ globeMoveCenterPoint()

void QgsCameraController::globeMoveCenterPoint ( double  latDiff,
double  lonDiff 
)

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
Since
QGIS 3.44

Definition at line 330 of file qgscameracontroller.cpp.

◆ globeUpdateHeadingAngle()

void QgsCameraController::globeUpdateHeadingAngle ( float  angleDiff)

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

Since
QGIS 3.44

Definition at line 350 of file qgscameracontroller.cpp.

◆ globeUpdatePitchAngle()

void QgsCameraController::globeUpdatePitchAngle ( float  angleDiff)

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

Since
QGIS 3.44

Definition at line 344 of file qgscameracontroller.cpp.

◆ globeZoom()

void QgsCameraController::globeZoom ( float  factor)

Moves camera closer or further away from the globe.

Use factor greater than one to zoom in, or less than one to zoom out.

Since
QGIS 3.44

Definition at line 338 of file qgscameracontroller.cpp.

◆ hasInputHandlersEnabled()

bool QgsCameraController::hasInputHandlersEnabled ( ) const
inline

Returns whether the camera controller responds to mouse and keyboard events.

Since
QGIS 3.44

Definition at line 244 of file qgscameracontroller.h.

◆ lookingAtMapPoint()

QgsVector3D QgsCameraController::lookingAtMapPoint ( ) const

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

Since
QGIS 3.44

Definition at line 217 of file qgscameracontroller.cpp.

◆ lookingAtPoint()

QgsVector3D QgsCameraController::lookingAtPoint ( ) const

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

Definition at line 202 of file qgscameracontroller.cpp.

◆ moveView()

void QgsCameraController::moveView ( float  tx,
float  ty 
)

Move the map by tx and ty.

Definition at line 1191 of file qgscameracontroller.cpp.

◆ navigationModeChanged

void QgsCameraController::navigationModeChanged ( Qgis::NavigationMode  mode)
signal

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

◆ pitch()

float QgsCameraController::pitch ( ) const
inline

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

The angle should range from 0 to 180.

Since
QGIS 3.4

Definition at line 165 of file qgscameracontroller.h.

◆ readXml()

void QgsCameraController::readXml ( const QDomElement &  elem)

Reads camera configuration from the given DOM element.

Definition at line 248 of file qgscameracontroller.cpp.

◆ requestDepthBufferCapture

void QgsCameraController::requestDepthBufferCapture ( )
signal

Emitted to ask for the depth buffer image.

Since
QGIS 3.24

◆ resetGlobe()

void QgsCameraController::resetGlobe ( float  distance,
double  lat = 0,
double  lon = 0 
)

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.

Since
QGIS 3.44

Definition at line 356 of file qgscameracontroller.cpp.

◆ resetView()

void QgsCameraController::resetView ( float  distance)

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

Definition at line 179 of file qgscameracontroller.cpp.

◆ rotateAroundViewCenter()

void QgsCameraController::rotateAroundViewCenter ( float  deltaYaw)

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

Definition at line 1176 of file qgscameracontroller.cpp.

◆ rotateCamera()

void QgsCameraController::rotateCamera ( float  diffPitch,
float  diffYaw 
)

Rotates the camera on itself.

Parameters
diffPitchthe pitch difference
diffYawthe yaw difference
Since
QGIS 3.30

Definition at line 103 of file qgscameracontroller.cpp.

◆ rotateCameraAroundPivot()

void QgsCameraController::rotateCameraAroundPivot ( float  newPitch,
float  newHeading,
const QVector3D &  pivotPoint 
)

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

Since
QGIS 3.42

Definition at line 131 of file qgscameracontroller.cpp.

◆ setCameraHeadingAngle()

void QgsCameraController::setCameraHeadingAngle ( float  angle)

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

Definition at line 1185 of file qgscameracontroller.cpp.

◆ setCameraMovementSpeed()

void QgsCameraController::setCameraMovementSpeed ( double  movementSpeed)

Sets the camera movement speed.

Since
QGIS 3.18

Definition at line 87 of file qgscameracontroller.cpp.

◆ setCameraNavigationMode

void QgsCameraController::setCameraNavigationMode ( Qgis::NavigationMode  navigationMode)
slot

Sets the navigation mode used by the camera controller.

Since
QGIS 3.18

Definition at line 77 of file qgscameracontroller.cpp.

◆ setCameraPose()

void QgsCameraController::setCameraPose ( const QgsCameraPose camPose,
bool  force = false 
)

Sets camera pose.

Since
QGIS 3.4

Definition at line 227 of file qgscameracontroller.cpp.

◆ setCursorPosition

void QgsCameraController::setCursorPosition ( QPoint  point)
signal

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

◆ setInputHandlersEnabled()

void QgsCameraController::setInputHandlersEnabled ( bool  enable)
inline

Sets whether the camera controller responds to mouse and keyboard events.

Since
QGIS 3.42

Definition at line 238 of file qgscameracontroller.h.

◆ setLookingAtMapPoint()

void QgsCameraController::setLookingAtMapPoint ( const QgsVector3D point,
float  distance,
float  pitch,
float  yaw 
)

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

Since
QGIS 3.44

Definition at line 222 of file qgscameracontroller.cpp.

◆ setLookingAtPoint()

void QgsCameraController::setLookingAtPoint ( const QgsVector3D point,
float  distance,
float  pitch,
float  yaw 
)

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.

Since
QGIS 3.4

Definition at line 207 of file qgscameracontroller.cpp.

◆ setOrigin()

void QgsCameraController::setOrigin ( const QgsVector3D origin)

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.

Since
QGIS 3.42

Definition at line 1348 of file qgscameracontroller.cpp.

◆ setVerticalAxisInversion()

void QgsCameraController::setVerticalAxisInversion ( Qgis::VerticalAxisInversion  inversion)

Sets the vertical axis inversion behavior.

Since
QGIS 3.18

Definition at line 98 of file qgscameracontroller.cpp.

◆ setViewFromTop()

void QgsCameraController::setViewFromTop ( float  worldX,
float  worldY,
float  distance,
float  yaw = 0 
)

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

Definition at line 186 of file qgscameracontroller.cpp.

◆ tiltUpAroundViewCenter()

void QgsCameraController::tiltUpAroundViewCenter ( float  deltaPitch)

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

Definition at line 1167 of file qgscameracontroller.cpp.

◆ verticalAxisInversion()

Qgis::VerticalAxisInversion QgsCameraController::verticalAxisInversion ( ) const
inline

Returns the vertical axis inversion behavior.

Since
QGIS 3.18

Definition at line 101 of file qgscameracontroller.h.

◆ walkView()

void QgsCameraController::walkView ( double  tx,
double  ty,
double  tz 
)

Walks into the map by tx, ty, and tz.

Since
QGIS 3.30

Definition at line 1000 of file qgscameracontroller.cpp.

◆ willHandleKeyEvent()

bool QgsCameraController::willHandleKeyEvent ( QKeyEvent *  event)

Returns true if the camera controller will handle the specified key event, preventing it from being instead handled by parents of the 3D window before the controller ever receives it.

Definition at line 1210 of file qgscameracontroller.cpp.

◆ writeXml()

QDomElement QgsCameraController::writeXml ( QDomDocument &  doc) const

Writes camera configuration to the given DOM element.

Definition at line 236 of file qgscameracontroller.cpp.

◆ yaw()

float QgsCameraController::yaw ( ) const
inline

Returns yaw angle in degrees.

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

Since
QGIS 3.4

Definition at line 172 of file qgscameracontroller.h.

◆ zoom()

void QgsCameraController::zoom ( float  factor)

Zoom the map by factor.

Definition at line 678 of file qgscameracontroller.cpp.

◆ zoomCameraAroundPivot()

void QgsCameraController::zoomCameraAroundPivot ( const QVector3D &  oldCameraPosition,
double  zoomFactor,
const QVector3D &  pivotPoint 
)

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.

Since
QGIS 3.42

Definition at line 152 of file qgscameracontroller.cpp.

Friends And Related Symbol Documentation

◆ TestQgs3DCameraController

friend class TestQgs3DCameraController
friend

Definition at line 462 of file qgscameracontroller.h.

◆ TestQgs3DRendering

friend class TestQgs3DRendering
friend

Definition at line 461 of file qgscameracontroller.h.


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