dart
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dart::gui::osg::DefaultEventHandler Class Reference
Inheritance diagram for dart::gui::osg::DefaultEventHandler:
Inheritance graph
[legend]
Collaboration diagram for dart::gui::osg::DefaultEventHandler:
Collaboration graph
[legend]

Public Member Functions

 DefaultEventHandler (Viewer *_viewer)
 Constructor takes in a pointer to a viewer.
 
virtual ~DefaultEventHandler ()
 Destructor.
 
MouseButtonEvent getButtonEvent (MouseButton button) const
 Returns the last event performed by a mouse button.
 
int getModKeyMask () const
 Returns the last modkey mask.
 
double getWindowCursorX () const
 Get the last x value of the cursor in Window coordinates.
 
double getWindowCursorY () const
 Get the last y value of the cursor in Window coordinates.
 
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 (_fromPosition). More...
 
void getNearAndFarPointUnderCursor (Eigen::Vector3d &near, Eigen::Vector3d &far, double distance=1.0) const
 Get two points that are under the current cursor position. More...
 
const std::vector< PickInfo > & getButtonPicks (MouseButton button, MouseButtonEvent event) const
 Get the most recent picks for the specified button and event type.
 
const std::vector< PickInfo > & getMovePicks () const
 Get the most recent picks for a mouse movement (click-and-drag actions do not qualify as movements)
 
void suppressButtonPicks (MouseButton button, MouseButtonEvent event)
 Suppress pick detection for the specified button event.
 
void suppressMovePicks ()
 Suppress pick detection for mouse movements.
 
void activateButtonPicks (MouseButton button, MouseButtonEvent event)
 Activate pick detection for the specified button event (on by default)
 
void activateMovePicks ()
 Activate pick detection for mouse movements (on by default)
 
void pick (std::vector< PickInfo > &infoVector, const ::osgGA::GUIEventAdapter &ea)
 Detect picks TODO(MXG): Consider putting this functionality in a more accessible place.
 
void addMouseEventHandler (MouseEventHandler *handler)
 Add a MouseEventHandler that will get invoked whenever a mouse event occurs. More...
 
const std::set< MouseEventHandler * > & getMouseEventHandlers () const
 Get the list of MouseEventHandlers that are currently held by this DefaultEventHandler.
 
bool handle (const ::osgGA::GUIEventAdapter &ea, ::osgGA::GUIActionAdapter &) override
 Handle incoming user input.
 
- Public Member Functions inherited from dart::common::Subject
virtual ~Subject ()
 Destructor will notify all Observers that it is destructing.
 
- Public Member Functions inherited from dart::common::Observer
virtual ~Observer ()
 Destructor will notify all Subjects that it is destructing.
 

Protected Member Functions

void triggerMouseEventHandlers ()
 Calls update on all MouseEventHandlers.
 
void eventPick (const ::osgGA::GUIEventAdapter &ea)
 Gather current picks and assign them to the latest event.
 
void clearButtonEvents ()
 Clear out the current button events.
 
void handleDestructionNotification (const dart::common::Subject *_subject) override
 Called by receiveDestructionNotification(). More...
 
- Protected Member Functions inherited from dart::common::Subject
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers.
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers.
 
- Protected Member Functions inherited from dart::common::Observer
void receiveDestructionNotification (const Subject *_subject)
 Called whenever a Subject is destroyed (or sends out a destruction notification). More...
 
void addSubject (const Subject *_subject)
 Add a Subject for this Observer.
 
void removeSubject (const Subject *_subject)
 Remove a Subject from this Observer.
 
void removeAllSubjects ()
 Remove all Subjects from this Observer.
 

Protected Attributes

ViewermViewer
 dart::gui::osg::Viewer that this event handler is tied to
 
std::set< MouseEventHandler * > mMouseEventHandlers
 Set of MouseEventHandlers that are tied to this DefaultEventHandler.
 
std::vector< PickInfomButtonPicks [NUM_MOUSE_BUTTONS][BUTTON_NOTHING]
 The objects that were under the cursor during the last button event.
 
bool mSuppressButtonPicks [NUM_MOUSE_BUTTONS][BUTTON_NOTHING]
 Suppress pick detection.
 
std::vector< PickInfomMovePicks
 The objects that were under the cursor during the last move.
 
bool mSuppressMovePicks
 Suppress pick detection for moves.
 
std::vector< PickInfomTempPicks
 Cache for pick data.
 
MouseButtonEvent mLastButtonEvent [NUM_MOUSE_BUTTONS]
 The last mouse event that was registered by the event handler.
 
Eigen::Vector2d mLastCursorPosition
 X/Y values of the cursor (in the window coordinates) during the last mouse event.
 
int mLastModKeyMask
 Storage for the last modkey mask.
 
- Protected Attributes inherited from dart::common::Subject
std::set< Observer * > mObservers
 List of current Observers.
 
- Protected Attributes inherited from dart::common::Observer
std::set< const Subject * > mSubjects
 List of current Subjects for this Observer.
 

Member Function Documentation

◆ addMouseEventHandler()

void dart::gui::osg::DefaultEventHandler::addMouseEventHandler ( MouseEventHandler handler)

Add a MouseEventHandler that will get invoked whenever a mouse event occurs.

You never need to worry about removing a MouseEventHandler from a DefaultEventHandler, because it will get removed automatically upon deletion

◆ getDeltaCursor()

Eigen::Vector3d dart::gui::osg::DefaultEventHandler::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 (_fromPosition).

For the unconstrained case, this change is projected onto a plane parallel to the camera's orientation.

If _constraint is set to LINE_CONSTRAINT, the change in cursor position will be constrained to a line that passes through _fromPosition with a slope of _constraintVector.

If _constraint is set to PLANE_CONSTRAINT, the change in cursor position will be constrained to a plane that passes through _fromPosition with a normal vector of _constraintVector.

◆ getNearAndFarPointUnderCursor()

void dart::gui::osg::DefaultEventHandler::getNearAndFarPointUnderCursor ( Eigen::Vector3d &  near,
Eigen::Vector3d &  far,
double  distance = 1.0 
) const

Get two points that are under the current cursor position.

The near point will be inside the plane of the camera. The far point will have the given distance from the plane of the camera (default is 1.0).

◆ handleDestructionNotification()

void dart::gui::osg::DefaultEventHandler::handleDestructionNotification ( const dart::common::Subject _subject)
overrideprotectedvirtual

Called by receiveDestructionNotification().

Override this function to customize your class's response to destruction notifications.

Reimplemented from dart::common::Observer.


The documentation for this class was generated from the following files: