33 #ifndef DART_GUI_OSG_DEFAULTEVENTHANDLER_HPP_
34 #define DART_GUI_OSG_DEFAULTEVENTHANDLER_HPP_
42 #include <osgGA/GUIEventHandler>
62 std::shared_ptr<dart::dynamics::Shape>
shape;
100 class MouseEventHandler;
138 const Eigen::Vector3d& _fromPosition,
140 const Eigen::Vector3d& _constraintVector
141 = Eigen::Vector3d::UnitZ())
const;
147 Eigen::Vector3d& near, Eigen::Vector3d& far,
double distance = 1.0)
const;
172 std::vector<PickInfo>& infoVector, const ::osgGA::GUIEventAdapter& ea);
186 const ::osgGA::GUIEventAdapter& ea, ::osgGA::GUIActionAdapter&)
override;
193 void eventPick(const ::osgGA::GUIEventAdapter& ea);
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_END
Definition: ClassWithVirtualBase.hpp:44
#define DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_BEGIN
Definition: ClassWithVirtualBase.hpp:43
The Observer class should be inherited by any class that wants to respond in a customized way to the ...
Definition: Observer.hpp:52
The Subject class is a base class for any object that wants to report when it gets destroyed.
Definition: Subject.hpp:58
Definition: ShapeFrame.hpp:192
Definition: DefaultEventHandler.hpp:106
std::vector< PickInfo > mMovePicks
The objects that were under the cursor during the last move.
Definition: DefaultEventHandler.hpp:214
int getModKeyMask() const
Returns the last modkey mask.
Definition: DefaultEventHandler.cpp:80
void clearButtonEvents()
Clear out the current button events.
Definition: DefaultEventHandler.cpp:429
double getWindowCursorX() const
Get the last x value of the cursor in Window coordinates.
Definition: DefaultEventHandler.cpp:86
void activateMovePicks()
Activate pick detection for mouse movements (on by default)
Definition: DefaultEventHandler.cpp:208
void pick(std::vector< PickInfo > &infoVector, const ::osgGA::GUIEventAdapter &ea)
Detect picks TODO(MXG): Consider putting this functionality in a more accessible place.
Definition: DefaultEventHandler.cpp:214
std::set< MouseEventHandler * > mMouseEventHandlers
Set of MouseEventHandlers that are tied to this DefaultEventHandler.
Definition: DefaultEventHandler.hpp:205
void triggerMouseEventHandlers()
Calls update on all MouseEventHandlers.
Definition: DefaultEventHandler.cpp:381
bool mSuppressMovePicks
Suppress pick detection for moves.
Definition: DefaultEventHandler.hpp:217
void suppressButtonPicks(MouseButton button, MouseButtonEvent event)
Suppress pick detection for the specified button event.
Definition: DefaultEventHandler.cpp:182
const std::vector< PickInfo > & getButtonPicks(MouseButton button, MouseButtonEvent event) const
Get the most recent picks for the specified button and event type.
Definition: DefaultEventHandler.cpp:166
bool handle(const ::osgGA::GUIEventAdapter &ea, ::osgGA::GUIActionAdapter &) override
Handle incoming user input.
Definition: DefaultEventHandler.cpp:307
DefaultEventHandler(Viewer *_viewer)
Constructor takes in a pointer to a viewer.
Definition: DefaultEventHandler.cpp:51
void suppressMovePicks()
Suppress pick detection for mouse movements.
Definition: DefaultEventHandler.cpp:192
std::vector< PickInfo > mTempPicks
Cache for pick data.
Definition: DefaultEventHandler.hpp:220
void activateButtonPicks(MouseButton button, MouseButtonEvent event)
Activate pick detection for the specified button event (on by default)
Definition: DefaultEventHandler.cpp:198
Eigen::Vector3d getDeltaCursor(const Eigen::Vector3d &_fromPosition, ConstraintType _constraint=UNCONSTRAINED, const Eigen::Vector3d &_constraintVector=Eigen::Vector3d::UnitZ()) const
Get the change change in the cursor position with respect to some previous location in the world (_fr...
Definition: DefaultEventHandler.cpp:98
MouseButtonEvent getButtonEvent(MouseButton button) const
Returns the last event performed by a mouse button.
Definition: DefaultEventHandler.cpp:74
Eigen::Vector2d mLastCursorPosition
X/Y values of the cursor (in the window coordinates) during the last mouse event.
Definition: DefaultEventHandler.hpp:227
void getNearAndFarPointUnderCursor(Eigen::Vector3d &near, Eigen::Vector3d &far, double distance=1.0) const
Get two points that are under the current cursor position.
Definition: DefaultEventHandler.cpp:148
void eventPick(const ::osgGA::GUIEventAdapter &ea)
Gather current picks and assign them to the latest event.
Definition: DefaultEventHandler.cpp:390
void handleDestructionNotification(const dart::common::Subject *_subject) override
Called by receiveDestructionNotification().
Definition: DefaultEventHandler.cpp:436
void addMouseEventHandler(MouseEventHandler *handler)
Add a MouseEventHandler that will get invoked whenever a mouse event occurs.
Definition: DefaultEventHandler.cpp:245
virtual ~DefaultEventHandler()
Destructor.
Definition: DefaultEventHandler.cpp:68
const std::vector< PickInfo > & getMovePicks() const
Get the most recent picks for a mouse movement (click-and-drag actions do not qualify as movements)
Definition: DefaultEventHandler.cpp:176
std::vector< PickInfo > mButtonPicks[NUM_MOUSE_BUTTONS][BUTTON_NOTHING]
The objects that were under the cursor during the last button event.
Definition: DefaultEventHandler.hpp:208
bool mSuppressButtonPicks[NUM_MOUSE_BUTTONS][BUTTON_NOTHING]
Suppress pick detection.
Definition: DefaultEventHandler.hpp:211
double getWindowCursorY() const
Get the last y value of the cursor in Window coordinates.
Definition: DefaultEventHandler.cpp:92
MouseButtonEvent mLastButtonEvent[NUM_MOUSE_BUTTONS]
The last mouse event that was registered by the event handler.
Definition: DefaultEventHandler.hpp:223
Viewer * mViewer
dart::gui::osg::Viewer that this event handler is tied to
Definition: DefaultEventHandler.hpp:202
const std::set< MouseEventHandler * > & getMouseEventHandlers() const
Get the list of MouseEventHandlers that are currently held by this DefaultEventHandler.
Definition: DefaultEventHandler.cpp:253
int mLastModKeyMask
Storage for the last modkey mask.
Definition: DefaultEventHandler.hpp:230
Definition: MouseEventHandler.hpp:51
Definition: Viewer.hpp:112
MouseButton
Definition: DefaultEventHandler.hpp:70
@ MIDDLE_MOUSE
Definition: DefaultEventHandler.hpp:74
@ RIGHT_MOUSE
Definition: DefaultEventHandler.hpp:73
@ NUM_MOUSE_BUTTONS
Definition: DefaultEventHandler.hpp:76
@ LEFT_MOUSE
Definition: DefaultEventHandler.hpp:72
ConstraintType
Definition: DefaultEventHandler.hpp:90
@ PLANE_CONSTRAINT
Definition: DefaultEventHandler.hpp:94
@ CUSTOM_CONSTRAINT
Definition: DefaultEventHandler.hpp:95
@ UNCONSTRAINED
Definition: DefaultEventHandler.hpp:92
@ LINE_CONSTRAINT
Definition: DefaultEventHandler.hpp:93
@ NUM_CONSTRAINT_TYPES
Definition: DefaultEventHandler.hpp:97
MouseButtonEvent
Definition: DefaultEventHandler.hpp:80
@ BUTTON_DRAG
Definition: DefaultEventHandler.hpp:83
@ BUTTON_RELEASE
Definition: DefaultEventHandler.hpp:84
@ BUTTON_PUSH
Definition: DefaultEventHandler.hpp:82
@ BUTTON_NOTHING
Definition: DefaultEventHandler.hpp:85
Definition: BulletCollisionDetector.cpp:65
Definition: DefaultEventHandler.hpp:60
dart::dynamics::ShapeFrame * frame
Definition: DefaultEventHandler.hpp:61
Eigen::Vector3d normal
Definition: DefaultEventHandler.hpp:64
std::shared_ptr< dart::dynamics::Shape > shape
Definition: DefaultEventHandler.hpp:62
Eigen::Vector3d position
Definition: DefaultEventHandler.hpp:63