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... | |
![]() | |
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... | |
Camera * | camera () |
Returns the host camera. More... | |
void | setMinimumWalkTargetDistance (double distance) |
Sets the minimum distance for the walk calculation with respect to the rotation point. More... | |
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.
Navigation types.
cee::vis::CameraInputHandler::CameraInputHandler | ( | ) |
Constructs a camera manipulation handler connected to the given camera.
CameraInputHandler::NavigationType cee::vis::CameraInputHandler::activeNavigation | ( | ) | const |
Returns the active navigation type.
|
protected |
Returns the host camera.
void cee::vis::CameraInputHandler::endNavigation | ( | ) |
Ends the current navigation.
|
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.
|
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 |
Processes the mouse press event.
This is typically called from the viewer (platform dependent class derived from cee::vis::Viewer) based on mouse input.
|
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.
|
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.
|
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.
|
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.
bool cee::vis::CameraInputHandler::updateNavigation | ( | int | x, |
int | y | ||
) |
Updates the current navigation based on the x,y coordinate.
double cee::vis::CameraInputHandler::walkSensitivity | ( | ) | const |
Returns the current walk sensitivity.
|
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.
|
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.
|
protectedvirtual |
Returns the navigation type to use for the mouse wheel. Base class returns NONE.
Reimplemented in cee::vis::CameraInputHandlerWalk, and cee::vis::CameraInputHandlerZoom.