Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Gui::TrackballCameraManipulator Class Reference

A Trackball manipulator for Cameras. More...

#include <Gui/Viewer/TrackballCameraManipulator.hpp>

+ Inheritance diagram for Ra::Gui::TrackballCameraManipulator:
+ Collaboration diagram for Ra::Gui::TrackballCameraManipulator:

Public Types

using KeyMapping = KeyMappingManageable<TrackballCameraManipulator>
 

Public Slots

void setCameraPosition (const Core::Vector3 &position) override
 
void setCameraTarget (const Core::Vector3 &target) override
 
void fitScene (const Core::Aabb &aabb) override
 
void resetCamera () override
 
- Public Slots inherited from Ra::Gui::CameraManipulator
void mapCameraBehaviourToAabb (const Core::Aabb &aabb)
 Set the AABB to restrain the camera behavior against.
 
void unmapCameraBehaviourToAabb ()
 Free the camera from AABB restriction.
 
virtual void fitScene (const Core::Aabb &aabb)=0
 Setup the Camera according to the AABB of the scene to render.
 
virtual void setCameraPosition (const Core::Vector3 &position)=0
 Set the Camera position to position.
 
virtual void setCameraTarget (const Core::Vector3 &target)=0
 Set the Camera target to target.
 
virtual void resetCamera ()=0
 Reset the Camera settings to default values.
 
void setCameraSensitivity (Scalar sensitivity)
 
void setCameraFov (Scalar fov)
 
void setCameraFovInDegrees (Scalar fov)
 
void setCameraZNear (Scalar zNear)
 
void setCameraZFar (Scalar zFar)
 

Public Member Functions

 TrackballCameraManipulator ()
 Default constructor.
 
 TrackballCameraManipulator (const CameraManipulator &other)
 
virtual ~TrackballCameraManipulator ()
 Destructor.
 
bool handleMousePressEvent (QMouseEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key) override
 
bool handleMouseReleaseEvent (QMouseEvent *event) override
 
bool handleMouseMoveEvent (QMouseEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key) override
 
bool handleWheelEvent (QWheelEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key) override
 
bool handleKeyPressEvent (QKeyEvent *event, const KeyMappingManager::KeyMappingAction &action) override
 
void toggleRotateAround ()
 
void updateCamera () override
 
void setTrackballRadius (Scalar rad)
 
Scalar getTrackballRadius () const
 Return the distance from the camera to the target point.
 
const Core::Transform::ConstTranslationPart getTrackballCenter () const
 
KeyMappingManager::Context mappingContext () override
 
- Public Member Functions inherited from Ra::Gui::CameraManipulator
 CameraManipulator ()
 Initializes a manipulator for a given viewport size.
 
 CameraManipulator (const CameraManipulator &other)
 
virtual ~CameraManipulator ()
 
virtual bool handleKeyReleaseEvent (QKeyEvent *event, const KeyMappingManager::KeyMappingAction &action)
 
const Core::Asset::CameragetCamera () const
 Pointer access to the camera.
 
Core::Asset::CameragetCamera ()
 Pointer access to the camera.
 
void attachLight (Engine::Scene::Light *light)
 
bool hasLightAttached () const
 
Engine::Scene::LightgetLight ()
 pointer acces to the attached light if it exists, returns nullptr otherwise.
 

Protected Member Functions

virtual void handleCameraRotate (Scalar dx, Scalar dy)
 
virtual void handleCameraPan (Scalar dx, Scalar dy)
 
virtual void handleCameraZoom (Scalar dx, Scalar dy)
 
virtual void handleCameraZoom (Scalar z)
 
virtual void handleCameraMoveForward (Scalar dx, Scalar dy)
 
virtual void handleCameraMoveForward (Scalar z)
 
void updatePhiTheta ()
 Update the polar coordinates of the Camera w.r.t. the trackball center.
 
- Protected Member Functions inherited from Ra::Gui::CameraManipulator
std::pair< Scalar, Scalar > computeDeltaMouseMove (const QMouseEvent *mouseEvent)
 
- Protected Member Functions inherited from Ra::Gui::KeyMappingManageable< TrackballCameraManipulator >
TrackballCameraManipulatorself ()
 

Protected Attributes

Scalar m_phi { 0_ra }
 
Scalar m_theta { 0_ra }
 
Scalar m_phiDir { 1_ra }
 sign of m_theta at mousePressEvent, to guide the phi rotation direction.
 
Core::Transform m_referenceFrame
 initial frame of the camera, centered on target, to compute angles.
 
Scalar m_distFromCenter { 0_ra }
 The distance from the camera to the trackball center.
 
KeyMappingCallbackManager m_keyMappingCallbackManager
 
- Protected Attributes inherited from Ra::Gui::CameraManipulator
Scalar m_lastMouseX { 0_ra }
 x-position of the mouse on the screen at the manipulation start.
 
Scalar m_lastMouseY { 0_ra }
 y-position of the mouse on the screen at the manipulation start.
 
Scalar m_cameraSensitivity { 1_ra }
 the Camera sensitivity to manipulation.
 
Scalar m_quickCameraModifier { 1_ra }
 Additional factor for camera sensitivity.
 
Scalar m_wheelSpeedModifier { 0.02_ra }
 Speed modifier on mouse wheel events.
 
Core::Aabb m_targetedAabb
 Camera behavior restriction AABB.
 
Scalar m_targetedAabbVolume { 0_ra }
 Volume of the m_targetedAabb.
 
bool m_mapCameraBahaviourToAabb { false }
 whether the camera is restrained or not
 
Core::Vector3 m_target { 0_ra, 0_ra, 0_ra }
 
Core::Asset::Cameram_camera { nullptr }
 The Camera.
 
Engine::Scene::Lightm_light { nullptr }
 The light attached to the Camera.
 

Friends

class KeyMappingManageable< TrackballCameraManipulator >
 

Additional Inherited Members

- Static Public Member Functions inherited from Ra::Gui::KeyMappingManageable< TrackballCameraManipulator >
static KeyMappingManager::Context getContext ()
 
static void configureKeyMapping ()
 
- Static Protected Member Functions inherited from Ra::Gui::KeyMappingManageable< TrackballCameraManipulator >
static void setContext (const KeyMappingManager::Context &c)
 

Detailed Description

A Trackball manipulator for Cameras.

Definition at line 13 of file TrackballCameraManipulator.hpp.

Member Typedef Documentation

◆ KeyMapping

Constructor & Destructor Documentation

◆ TrackballCameraManipulator() [1/2]

Ra::Gui::TrackballCameraManipulator::TrackballCameraManipulator ( )

Default constructor.

Definition at line 72 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ TrackballCameraManipulator() [2/2]

Ra::Gui::TrackballCameraManipulator::TrackballCameraManipulator ( const CameraManipulator & other)
explicit

Copy constructor used when switching camera manipulator Requires that m_target is on the line of sight of the camera.

Definition at line 79 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ ~TrackballCameraManipulator()

Ra::Gui::TrackballCameraManipulator::~TrackballCameraManipulator ( )
virtual

Destructor.

Definition at line 92 of file TrackballCameraManipulator.cpp.

Member Function Documentation

◆ fitScene

void Ra::Gui::TrackballCameraManipulator::fitScene ( const Core::Aabb & aabb)
overrideslot

Definition at line 286 of file TrackballCameraManipulator.cpp.

◆ getTrackballCenter()

Core::Transform::ConstTranslationPart Ra::Gui::TrackballCameraManipulator::getTrackballCenter ( ) const

Return the trackball center.

Note
doesn't modify the camera.

Definition at line 137 of file TrackballCameraManipulator.cpp.

◆ getTrackballRadius()

Scalar Ra::Gui::TrackballCameraManipulator::getTrackballRadius ( ) const

Return the distance from the camera to the target point.

Definition at line 133 of file TrackballCameraManipulator.cpp.

◆ handleCameraMoveForward() [1/2]

void Ra::Gui::TrackballCameraManipulator::handleCameraMoveForward ( Scalar dx,
Scalar dy )
protectedvirtual

Definition at line 370 of file TrackballCameraManipulator.cpp.

◆ handleCameraMoveForward() [2/2]

void Ra::Gui::TrackballCameraManipulator::handleCameraMoveForward ( Scalar z)
protectedvirtual

Definition at line 374 of file TrackballCameraManipulator.cpp.

◆ handleCameraPan()

void Ra::Gui::TrackballCameraManipulator::handleCameraPan ( Scalar dx,
Scalar dy )
protectedvirtual

Definition at line 355 of file TrackballCameraManipulator.cpp.

◆ handleCameraRotate()

void Ra::Gui::TrackballCameraManipulator::handleCameraRotate ( Scalar dx,
Scalar dy )
protectedvirtual

Definition at line 314 of file TrackballCameraManipulator.cpp.

◆ handleCameraZoom() [1/2]

void Ra::Gui::TrackballCameraManipulator::handleCameraZoom ( Scalar dx,
Scalar dy )
protectedvirtual

Definition at line 386 of file TrackballCameraManipulator.cpp.

◆ handleCameraZoom() [2/2]

void Ra::Gui::TrackballCameraManipulator::handleCameraZoom ( Scalar z)
protectedvirtual

Definition at line 390 of file TrackballCameraManipulator.cpp.

◆ handleKeyPressEvent()

bool Ra::Gui::TrackballCameraManipulator::handleKeyPressEvent ( QKeyEvent * event,
const KeyMappingManager::KeyMappingAction & action )
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 249 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ handleMouseMoveEvent()

bool Ra::Gui::TrackballCameraManipulator::handleMouseMoveEvent ( QMouseEvent * event,
const Qt::MouseButtons & buttons,
const Qt::KeyboardModifiers & modifiers,
int key )
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 211 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ handleMousePressEvent()

bool Ra::Gui::TrackballCameraManipulator::handleMousePressEvent ( QMouseEvent * event,
const Qt::MouseButtons & buttons,
const Qt::KeyboardModifiers & modifiers,
int key )
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 197 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ handleMouseReleaseEvent()

bool Ra::Gui::TrackballCameraManipulator::handleMouseReleaseEvent ( QMouseEvent * event)
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 228 of file TrackballCameraManipulator.cpp.

◆ handleWheelEvent()

bool Ra::Gui::TrackballCameraManipulator::handleWheelEvent ( QWheelEvent * event,
const Qt::MouseButtons & buttons,
const Qt::KeyboardModifiers & modifiers,
int key )
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 233 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ mappingContext()

KeyMappingManager::Context Ra::Gui::TrackballCameraManipulator::mappingContext ( )
overridevirtual
Returns
the mapping context for keymapping, Index::Invalid() if no mapping is available

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 141 of file TrackballCameraManipulator.cpp.

◆ resetCamera

void Ra::Gui::TrackballCameraManipulator::resetCamera ( )
overrideslot
Todo
get rid of these light stuff

Definition at line 94 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ setCameraPosition

void Ra::Gui::TrackballCameraManipulator::setCameraPosition ( const Core::Vector3 & position)
overrideslot

Definition at line 255 of file TrackballCameraManipulator.cpp.

◆ setCameraTarget

void Ra::Gui::TrackballCameraManipulator::setCameraTarget ( const Core::Vector3 & target)
overrideslot

Definition at line 271 of file TrackballCameraManipulator.cpp.

◆ setTrackballRadius()

void Ra::Gui::TrackballCameraManipulator::setTrackballRadius ( Scalar rad)

Set the distance from the camera to the target point. update target m_referenceFrame.translation();

Note
doesn't modify the camera.

Definition at line 127 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ updateCamera()

void Ra::Gui::TrackballCameraManipulator::updateCamera ( )
overridevirtual

Reset manipulator internal data according to current active camera from manager. Call each time the active camera is changed to have coherent data.

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 111 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ updatePhiTheta()

void Ra::Gui::TrackballCameraManipulator::updatePhiTheta ( )
protected

Update the polar coordinates of the Camera w.r.t. the trackball center.

Definition at line 395 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ KeyMappingManageable< TrackballCameraManipulator >

Definition at line 13 of file TrackballCameraManipulator.hpp.

Member Data Documentation

◆ m_distFromCenter

Scalar Ra::Gui::TrackballCameraManipulator::m_distFromCenter { 0_ra }
protected

The distance from the camera to the trackball center.

Definition at line 104 of file TrackballCameraManipulator.hpp.

◆ m_keyMappingCallbackManager

KeyMappingCallbackManager Ra::Gui::TrackballCameraManipulator::m_keyMappingCallbackManager
protected

Definition at line 106 of file TrackballCameraManipulator.hpp.

◆ m_phi

Scalar Ra::Gui::TrackballCameraManipulator::m_phi { 0_ra }
protected

Spherical coordinates (ISO 80000-2:2019 convention) https://en.wikipedia.org/wiki/Spherical_coordinate_system phi is azimutal theta is polar, from y which is world "up" direction rest pose correspond to camera view direction at m_referenceFrame -z;

Definition at line 95 of file TrackballCameraManipulator.hpp.

◆ m_phiDir

Scalar Ra::Gui::TrackballCameraManipulator::m_phiDir { 1_ra }
protected

sign of m_theta at mousePressEvent, to guide the phi rotation direction.

Definition at line 98 of file TrackballCameraManipulator.hpp.

◆ m_referenceFrame

Core::Transform Ra::Gui::TrackballCameraManipulator::m_referenceFrame
protected

initial frame of the camera, centered on target, to compute angles.

Definition at line 101 of file TrackballCameraManipulator.hpp.

◆ m_theta

Scalar Ra::Gui::TrackballCameraManipulator::m_theta { 0_ra }
protected

Definition at line 96 of file TrackballCameraManipulator.hpp.


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