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>
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;
87 KeySymbol turnLeftKey = KEY_a;
90 KeySymbol turnRightKey = KEY_d;
93 KeySymbol pitchUpKey = KEY_w;
96 KeySymbol pitchDownKey = KEY_s;
99 KeySymbol rollLeftKey = KEY_q;
102 KeySymbol rollRightKey = KEY_e;
105 KeySymbol moveForwardKey = KEY_o;
108 KeySymbol moveBackwardKey = KEY_i;
111 KeySymbol moveLeftKey = KEY_Left;
114 KeySymbol moveRightKey = KEY_Right;
117 KeySymbol moveUpKey = KEY_Up;
120 KeySymbol moveDownKey = KEY_Down;
123 ButtonMask rotateButtonMask = BUTTON_MASK_1;
126 ButtonMask panButtonMask = BUTTON_MASK_2;
129 ButtonMask zoomButtonMask = BUTTON_MASK_3;
132 ButtonMask touchMappedToButtonMask = BUTTON_MASK_1;
135 double zoomScale = 1.0;
138 bool supportsThrow =
true;
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(PointerEvent &event)
compute non dimensional window coordinate (-1,1) from event coords
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
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....
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
dvec3 tbc(PointerEvent &event)
compute trackball coordinate from event coords
WindowEvent is the base class for events related to a window.
Definition: WindowEvent.h:24
Definition: Trackball.h:78