15#include <vsg/app/Camera.h>
16#include <vsg/app/EllipsoidModel.h>
17#include <vsg/maths/transform.h>
18#include <vsg/ui/Keyboard.h>
19#include <vsg/ui/PointerEvent.h>
20#include <vsg/ui/ScrollWheelEvent.h>
21#include <vsg/ui/TouchEvent.h>
27 class VSG_DECLSPEC Trackball :
public Inherit<Visitor, Trackball>
44 void apply(
MoveEvent& moveEvent)
override;
51 virtual void rotate(
double angle,
const dvec3& axis);
52 virtual void zoom(
double ratio);
53 virtual void pan(
const dvec2& delta);
55 std::pair<int32_t, int32_t> cameraRenderAreaCoordinates(
const PointerEvent& pointerEvent)
const;
56 bool withinRenderArea(
const PointerEvent& pointerEvent)
const;
71 void addKeyViewpoint(KeySymbol key,
double latitude,
double longitude,
double altitude,
double duration = 1.0);
80 double duration = 0.0;
145 bool _hasKeyboardFocus =
false;
146 bool _hasPointerFocus =
false;
147 bool _lastPointerEventWithinRenderArea =
false;
156 UpdateMode _updateMode = INACTIVE;
157 double _zoomPreviousRatio = 0.0;
159 double _rotateAngle = 0.0;
162 time_point _previousTime;
164 double _previousDelta = 0.0;
165 double _prevZoomTouchDistance = 0.0;
166 bool _thrown =
false;
168 time_point _startTime;
171 std::map<uint32_t, ref_ptr<TouchEvent>> _previousTouches;
175 double _animationDuration = 0.0;
FocusInEvent represents a window acquiring focus event.
Definition WindowEvent.h:98
FocusOutEvent represents a window losing focus event.
Definition WindowEvent.h:109
Definition ApplicationEvent.h:37
KeyPressEvent represents a key press event.
Definition KeyEvent.h:309
KeyReleaseEvent represents a key release event.
Definition KeyEvent.h:320
MoveEvent represents a pointer move event.
Definition PointerEvent.h:89
PointerEvent is a base class for mouse pointer events.
Definition PointerEvent.h:34
TouchDownEvent represents a touch down event.
Definition TouchEvent.h:45
TouchMoveEvent represents a touch move event.
Definition TouchEvent.h:67
TouchUpEvent represents a touch up event.
Definition TouchEvent.h:56
Trackball is an event handler that provides mouse and touch controlled 3d trackball camera view manip...
Definition Trackball.h:28
dvec2 ndc(const PointerEvent &event)
compute non dimensional window coordinate (-1,1) from event coords
ButtonMask touchMappedToButtonMask
Button mask value used used for touch events.
Definition Trackball.h:132
bool supportsThrow
Toggle on/off whether the view should continue moving when the mouse buttons are released while the m...
Definition Trackball.h:138
KeySymbol moveForwardKey
Key that moves the view forward.
Definition Trackball.h:105
void addWindow(ref_ptr< Window > window, const ivec2 &offset={})
add a Window to respond events for, with mouse coordinate offset to treat all associated windows
void addKeyViewpoint(KeySymbol key, ref_ptr< LookAt > lookAt, double duration=1.0)
add Key to Viewpoint binding using a LookAt to define the viewpoint
std::map< KeySymbol, Viewpoint > keyViewpointMap
container that maps key symbol bindings with the Viewpoint that should move the LookAt to when presse...
Definition Trackball.h:84
KeySymbol rollRightKey
Key that rolls the view clockwise/right.
Definition Trackball.h:102
ButtonMask rotateButtonMask
Button mask value used to enable panning of the view, defaults to left mouse button.
Definition Trackball.h:123
KeySymbol moveLeftKey
Key that moves the view left.
Definition Trackball.h:111
double zoomScale
Scale for controlling how rapidly the view zooms in/out. Positive value zooms in when mouse moves dow...
Definition Trackball.h:135
void addKeyViewpoint(KeySymbol key, double latitude, double longitude, double altitude, double duration=1.0)
add Key to Viewpoint binding using a latitude, longitude and altitude to define the viewpoint....
KeySymbol pitchUpKey
Key that pitches up the view around the eye point.
Definition Trackball.h:93
void setViewpoint(ref_ptr< LookAt > lookAt, double duration=1.0)
std::map< observer_ptr< Window >, ivec2 > windowOffsets
list of windows that this Trackball should respond to events from, and the points xy offsets to apply
Definition Trackball.h:62
KeySymbol moveBackwardKey
Key that moves the view backwards.
Definition Trackball.h:108
ButtonMask zoomButtonMask
Button mask value used to enable zooming of the view, defaults to right mouse button.
Definition Trackball.h:129
KeySymbol rollLeftKey
Key that rools the view anti-clockwise/left.
Definition Trackball.h:99
KeySymbol turnRightKey
Key that turns the view right around the eye points.
Definition Trackball.h:90
KeySymbol moveUpKey
Key that moves the view upward.
Definition Trackball.h:117
ButtonMask panButtonMask
Button mask value used to enable panning of the view, defaults to middle mouse button.
Definition Trackball.h:126
KeySymbol moveRightKey
Key that moves the view right.
Definition Trackball.h:114
KeySymbol moveDownKey
Key that moves the view downward.
Definition Trackball.h:120
dvec3 tbc(const PointerEvent &event)
compute trackball coordinate from event coords
KeySymbol pitchDownKey
Key that pitches down the view around the eye point.
Definition Trackball.h:96
KeySymbol turnLeftKey
Key that turns the view left around the eye points.
Definition Trackball.h:87
WindowEvent is the base class for events related to a window.
Definition WindowEvent.h:24
Definition Trackball.h:78