cee::vis::CameraInputHandler Class Referenceabstract

Class for manipulating a camera from input events (typically mouse interaction). More...

Public Types

enum  NavigationType {
  NONE, PAN, WALK, ZOOM,
  ROTATE, ROLL
}
 Navigation types. More...
 

Public Member Functions

 CameraInputHandler ()
 Constructs a camera manipulation handler connected to the given camera. More...
 
virtual void mousePressEvent (MouseButton buttonPressed, const MouseEvent &mouseEvent)
 Processes the mouse press event. More...
 
virtual bool mouseMoveEvent (const MouseEvent &mouseEvent)
 Processes the mouse move event. Returns true if a redraw of the screen is needed. More...
 
virtual void mouseReleaseEvent (MouseButton buttonReleased, const MouseEvent &mouseEvent)
 Processes the mouse press event. More...
 
virtual void wheelEvent (const WheelEvent &theWheelEvent)
 Processes the mouse wheel event. More...
 
virtual void wheelEvent (const WheelEvent &theWheelEvent, const cee::Vec3d &position)
 Processes the mouse wheel event. More...
 
Vec3d rotationPoint () const
 Returns the current rotation point. More...
 
virtual void setRotationPoint (const Vec3d &rotationPoint)
 Sets the navigation rotation point to rotationPoint. More...
 
double rotationSensitivity () const
 Returns the current rotation sensitivity. More...
 
void setRotationSensitivity (double sensitivity)
 Sets the current rotation sensitivity. More...
 
double rollSensitivity () const
 Returns the current roll sensitivity. More...
 
void setRollSensitivity (double sensitivity)
 Sets the current roll sensitivity. More...
 
double walkSensitivity () const
 Returns the current walk sensitivity. More...
 
void setWalkSensitivity (double sensitivity)
 Sets the current walk sensitivity. More...
 
NavigationType activeNavigation () const
 Returns the active navigation type. More...
 
void startNavigation (NavigationType navigationType, int x, int y)
 Starts navigation with the given type and x,y position. More...
 
bool updateNavigation (int x, int y)
 Updates the current navigation based on the x,y coordinate. More...
 
void endNavigation ()
 Ends the current navigation. More...
 
virtual NavigationType navigationTypeFromInputState (MouseButtons mouseButtons, KeyboardModifiers keyboardModifiers) const =0
 Returns the navigation type based on the state of the input event. Must be implemented in all derived classes. More...
 
virtual bool reverseZoom () const
 Returns true in derived classes to reverse the zoom direction. More...
 
- Public Member Functions inherited from cee::RefCountedObject
void addRef () const
 Increments the reference count for this object. More...
 
void release () const
 Decrements the reference count for this object. More...
 
int refCount () const
 Returns the reference count for this object. More...
 
void setRefCountZero () const
 Sets the ref count to zero, but DOES NOT delete the object. More...
 

Protected Member Functions

virtual NavigationType wheelNavigationType () const
 Returns the navigation type to use for the mouse wheel. Base class returns NONE. More...
 
Cameracamera ()
 Returns the host camera. More...
 
void setMinimumWalkTargetDistance (double distance)
 Sets the minimum distance for the walk calculation with respect to the rotation point. More...
 
Inheritance diagram for cee::vis::CameraInputHandler:
cee::RefCountedObject cee::vis::CameraInputHandlerWalk cee::vis::CameraInputHandlerZoom

Detailed Description

Class for manipulating a camera from input events (typically mouse interaction).

CameraInputHandler is the base class for camera manipulation classes. Ceetron Desktop Components has two built in classes:

The easiest way to add a custom navigation scheme is to derive from this class and override the navigationTypeFromInputState() method.

In more advanced cases the user can also override the mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent() and wheelEvent() methods and create a fully custom user experience.

See also
CameraInputHandlerZoom
CameraInputHandlerWalk

Member Enumeration Documentation

Navigation types.

Enumerator
NONE 

No navigation.

PAN 

Pan. Move the model in the screen plane.

WALK 

Walk. Move the camera position (eye) forward or backward in the view direction.

ZOOM 

Adjust the Field of view (perspective projection) or frustum height (orthographic projection) to resize the model.

ROTATE 

Rotate the model around the current rotation point.

ROLL 

Roll. Rotate the model around view direction.

Constructor & Destructor Documentation

cee::vis::CameraInputHandler::CameraInputHandler ( )

Constructs a camera manipulation handler connected to the given camera.

Member Function Documentation

CameraInputHandler::NavigationType cee::vis::CameraInputHandler::activeNavigation ( ) const

Returns the active navigation type.

Camera * cee::vis::CameraInputHandler::camera ( )
protected

Returns the host camera.

void cee::vis::CameraInputHandler::endNavigation ( )

Ends the current navigation.

Note
This method is only used for more advanced navigation customization.
bool cee::vis::CameraInputHandler::mouseMoveEvent ( const MouseEvent mouseEvent)
virtual

Processes the mouse move event. Returns true if a redraw of the screen is needed.

This is typically called from the viewer (platform dependent class derived from cee::vis::Viewer) based on mouse input.

void cee::vis::CameraInputHandler::mousePressEvent ( MouseButton  buttonPressed,
const MouseEvent mouseEvent 
)
virtual

Processes the mouse press event.

This is typically called from the viewer (platform dependent class derived from cee::vis::Viewer) based on mouse input.

void cee::vis::CameraInputHandler::mouseReleaseEvent ( MouseButton  buttonReleased,
const MouseEvent mouseEvent 
)
virtual

Processes the mouse press event.

This is typically called from the viewer (platform dependent class derived from cee::vis::Viewer) based on mouse input.

virtual NavigationType cee::vis::CameraInputHandler::navigationTypeFromInputState ( MouseButtons  mouseButtons,
KeyboardModifiers  keyboardModifiers 
) const
pure virtual

Returns the navigation type based on the state of the input event. Must be implemented in all derived classes.

Implemented in cee::vis::CameraInputHandlerWalk, and cee::vis::CameraInputHandlerZoom.

bool cee::vis::CameraInputHandler::reverseZoom ( ) const
virtual

Returns true in derived classes to reverse the zoom direction.

double cee::vis::CameraInputHandler::rollSensitivity ( ) const

Returns the current roll sensitivity.

Vec3d cee::vis::CameraInputHandler::rotationPoint ( ) const

Returns the current rotation point.

double cee::vis::CameraInputHandler::rotationSensitivity ( ) const

Returns the current rotation sensitivity.

void cee::vis::CameraInputHandler::setMinimumWalkTargetDistance ( double  distance)
protected

Sets the minimum distance for the walk calculation with respect to the rotation point.

The walk navigation features a dynamic walk speed to make it possible to navigate large models The walk speed is reduced when we get closer to the rotation point, and this method specifies the minimum distance to use in the calculations.

This is useful if the navigation slows down too much when getting close to the rotation point.

void cee::vis::CameraInputHandler::setRollSensitivity ( double  sensitivity)

Sets the current roll sensitivity.

void cee::vis::CameraInputHandler::setRotationPoint ( const Vec3d rotationPoint)
virtual

Sets the navigation rotation point to rotationPoint.

Reimplemented in cee::vis::CameraInputHandlerZoom.

void cee::vis::CameraInputHandler::setRotationSensitivity ( double  sensitivity)

Sets the current rotation sensitivity.

void cee::vis::CameraInputHandler::setWalkSensitivity ( double  sensitivity)

Sets the current walk sensitivity.

void cee::vis::CameraInputHandler::startNavigation ( NavigationType  navigationType,
int  x,
int  y 
)

Starts navigation with the given type and x,y position.

Note
This method is only used for more advanced navigation customization.
bool cee::vis::CameraInputHandler::updateNavigation ( int  x,
int  y 
)

Updates the current navigation based on the x,y coordinate.

Note
This method is only used for more advanced navigation customization.
double cee::vis::CameraInputHandler::walkSensitivity ( ) const

Returns the current walk sensitivity.

void cee::vis::CameraInputHandler::wheelEvent ( const WheelEvent theWheelEvent)
virtual

Processes the mouse wheel event.

This is typically called from the viewer (platform dependent class derived from cee::vis::Viewer) based on mouse input.

Reimplemented in cee::vis::CameraInputHandlerWalk, and cee::vis::CameraInputHandlerZoom.

void cee::vis::CameraInputHandler::wheelEvent ( const WheelEvent theWheelEvent,
const cee::Vec3d position 
)
virtual

Processes the mouse wheel event.

This is typically called from the viewer (platform dependent class derived from cee::vis::Viewer) based on mouse input.

Also offers a position position which are typically used to implement zoom to cursor. position is not handled on this base class. See derived classes.

Reimplemented in cee::vis::CameraInputHandlerWalk, and cee::vis::CameraInputHandlerZoom.

CameraInputHandler::NavigationType cee::vis::CameraInputHandler::wheelNavigationType ( ) const
protectedvirtual

Returns the navigation type to use for the mouse wheel. Base class returns NONE.

Reimplemented in cee::vis::CameraInputHandlerWalk, and cee::vis::CameraInputHandlerZoom.