RobWorkProject  23.9.11-
Public Types | Public Member Functions | Protected Member Functions | List of all members
ArcBallController Class Reference

Use the ArcBallController method to control the camera view point in a scene. More...

#include <ArcBallController.hpp>

Inherits CameraController.

Public Types

typedef rw::core::Ptr< ArcBallControllerPtr
 Smart pointer type for ArcBallController.
 
- Public Types inherited from CameraController
typedef rw::core::Ptr< CameraControllerPtr
 smart pointer type of this class
 

Public Member Functions

 ArcBallController (double NewWidth, double NewHeight)
 constructor
 
 ArcBallController (double NewWidth, double NewHeight, rw::graphics::SceneCamera::Ptr cam)
 constructor
 
virtual ~ArcBallController ()
 destructor
 
void click (float x, float y)
 register a mouse click event. The coordinates must be inside the specified bounds. More...
 
rw::math::Quaternion< double > drag (float x, float y)
 Calculates the rotation of the object/scene based on the mouse being dragged to the position (x,y). More...
 
void draw ()
 draw the camera control. More...
 
void setBounds (double NewWidth, double NewHeight)
 set the bounds that define the area where the 2d point is valid. The bound is defined in a plane with [0,width] and [0,height]. Where (0,0) is the upper left corner of the plane. More...
 
virtual void handleEvent (QEvent *event)
 event handler, typically mouse and keyboard More...
 
virtual rw::math::Transform3D getTransform () const
 get the current world to camera transformation More...
 
void setTransform (const rw::math::Transform3D<> &t3d)
 set world to camera transformation More...
 
void setCenter (const rw::math::Vector3D<> &center, const rw::math::Vector2D<> &screenCenter)
 update the center of rotation and screen center More...
 
rw::math::Vector3D getCenter ()
 get the current pivot point in world coordinates More...
 
void zoom (double amount)
 Zoom by amount specified by amount. More...
 
void autoZoom (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< const rw::kinematics::State > state, double fovy, double aspectRatio)
 Zooms the camera to fit all devices into the camera view. More...
 
void setZoomTarget (rw::math::Vector3D< double > target, bool enable=true)
 set the 3D coordinate that should be zoomed towards. More...
 
void setPanTarget (rw::math::Vector3D< double > target, bool enable=true)
 set the 3D coordinate that should be moved. More...
 
rw::math::Vector3D getPanTarget ()
 get the 3D coordinate that should be moved. More...
 
void setDrawable (rw::graphics::DrawableNode::Ptr obj)
 add a drawable to the camera controller More...
 
void zoomScale (double scale=1)
 
- Public Member Functions inherited from CameraController
virtual ~CameraController ()
 destructor
 

Protected Member Functions

rw::math::Vector3D mapToSphere (double x, double y) const
 maps a 2d position (x,y) into a position on a 3D sphere which is centered around _centerPt. More...
 
rw::math::Vector3D unproject (int x, int y, double z)
 project a image position into 3D space using pinhole model More...
 
void pan (int x, int y)
 move the camera in 2D relative to the scene More...
 

Detailed Description

Use the ArcBallController method to control the camera view point in a scene.

The ArcBallController method defines a way to map a 2d position into a 3d position on some sphere. This means that the rotation is defined by dragging a point on a sphere around its center.

Member Function Documentation

◆ autoZoom()

void autoZoom ( rw::core::Ptr< rw::models::WorkCell workcell,
rw::core::Ptr< const rw::kinematics::State state,
double  fovy,
double  aspectRatio 
)
virtual

Zooms the camera to fit all devices into the camera view.

Useful when working with robots smaller or larger than standard. Calling this method moves the camera along its Z-axis.

Parameters
workcell[in] The autozoom functions fits all frames of workcell in the viewport
state[in] state with the current positions of the frames. If NULL, the default workcell state is used.
fovy[in] the field of view in the vertical direction (in radians).
aspectRatio[in] the aspect ratio of (width divided by height).

Implements CameraController.

◆ click()

void click ( float  x,
float  y 
)

register a mouse click event. The coordinates must be inside the specified bounds.

Parameters
x[in] x-coodinate
y[in] y-coodinate

◆ drag()

rw::math::Quaternion<double> drag ( float  x,
float  y 
)

Calculates the rotation of the object/scene based on the mouse being dragged to the position (x,y).

Parameters
x[in] the x-coordinate of the current mouse position
y[in] the y-coordinate of the current mouse position
Returns
the rotation that should be applied to the object/scene

◆ draw()

void draw ( )
virtual

draw the camera control.

Implements CameraController.

◆ getCenter()

rw::math::Vector3D getCenter ( )
inlinevirtual

get the current pivot point in world coordinates

Returns
current pivot point

Implements CameraController.

◆ getPanTarget()

rw::math::Vector3D getPanTarget ( )
virtual

get the 3D coordinate that should be moved.

Returns
the target position to move.

Reimplemented from CameraController.

◆ getTransform()

virtual rw::math::Transform3D getTransform ( ) const
virtual

get the current world to camera transformation

Returns
world to camera transformation

Implements CameraController.

◆ handleEvent()

virtual void handleEvent ( QEvent *  event)
virtual

event handler, typically mouse and keyboard

Parameters
event[in] the specific event

Implements CameraController.

◆ mapToSphere()

rw::math::Vector3D mapToSphere ( double  x,
double  y 
) const
protected

maps a 2d position (x,y) into a position on a 3D sphere which is centered around _centerPt.

Parameters
x[in]
y[in]

◆ pan()

void pan ( int  x,
int  y 
)
protected

move the camera in 2D relative to the scene

Parameters
x[in] current mouse position in x-axis
y[in] current mouse position in y-axis

◆ setBounds()

void setBounds ( double  NewWidth,
double  NewHeight 
)
virtual

set the bounds that define the area where the 2d point is valid. The bound is defined in a plane with [0,width] and [0,height]. Where (0,0) is the upper left corner of the plane.

Parameters
NewWidth[in] width
NewHeight[in] height

Implements CameraController.

◆ setCenter()

void setCenter ( const rw::math::Vector3D<> &  center,
const rw::math::Vector2D<> &  screenCenter 
)
virtual

update the center of rotation and screen center

Parameters
center[in] center of rotation in world coordinates
screenCenter[in] center of rotation in screen coordinates

Implements CameraController.

◆ setDrawable()

void setDrawable ( rw::graphics::DrawableNode::Ptr  obj)
inlinevirtual

add a drawable to the camera controller

Parameters
obj[in] a drawable to be controled by the camera controller

Reimplemented from CameraController.

◆ setPanTarget()

void setPanTarget ( rw::math::Vector3D< double >  target,
bool  enable = true 
)
virtual

set the 3D coordinate that should be moved.

Parameters
target[in] the target position to move.
enable[in] enable or disable pan with pantarget.

Reimplemented from CameraController.

◆ setTransform()

void setTransform ( const rw::math::Transform3D<> &  t3d)
virtual

set world to camera transformation

Parameters
t3d[in] world to camera transformation

Implements CameraController.

◆ setZoomTarget()

void setZoomTarget ( rw::math::Vector3D< double >  target,
bool  enable = true 
)
virtual

set the 3D coordinate that should be zoomed towards.

Parameters
target[in] the target position to zoom towards.
enable[in] enable or disable zoom with zoomtarget.

Reimplemented from CameraController.

◆ unproject()

rw::math::Vector3D unproject ( int  x,
int  y,
double  z 
)
protected

project a image position into 3D space using pinhole model

Parameters
x[in] the x coordinate in the image
y[in] the y coordinate in the image
z[in] the z coordinate of the world
Returns
the projected 3D position

◆ zoom()

void zoom ( double  amount)
virtual

Zoom by amount specified by amount.

Calling this method moves the camera along its Z-axis.

Parameters
amount[in] Meters to zoom the camera

Implements CameraController.


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