DART
6.10.1
|
#include <DefaultEventHandler.hpp>
Public Member Functions | |
DefaultEventHandler (Viewer *_viewer) | |
Constructor takes in a pointer to a viewer. More... | |
virtual | ~DefaultEventHandler () |
Destructor. More... | |
MouseButtonEvent | getButtonEvent (MouseButton button) const |
Returns the last event performed by a mouse button. More... | |
int | getModKeyMask () const |
Returns the last modkey mask. More... | |
double | getWindowCursorX () const |
Get the last x value of the cursor in Window coordinates. More... | |
double | getWindowCursorY () const |
Get the last y value of the cursor in Window coordinates. More... | |
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. More... | |
const std::vector< PickInfo > & | getMovePicks () const |
Get the most recent picks for a mouse movement (click-and-drag actions do not qualify as movements) More... | |
void | suppressButtonPicks (MouseButton button, MouseButtonEvent event) |
Suppress pick detection for the specified button event. More... | |
void | suppressMovePicks () |
Suppress pick detection for mouse movements. More... | |
void | activateButtonPicks (MouseButton button, MouseButtonEvent event) |
Activate pick detection for the specified button event (on by default) More... | |
void | activateMovePicks () |
Activate pick detection for mouse movements (on by default) More... | |
void | pick (std::vector< PickInfo > &infoVector, const ::osgGA::GUIEventAdapter &ea) |
Detect picks TODO(MXG): Consider putting this functionality in a more accessible place. More... | |
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. More... | |
bool | handle (const ::osgGA::GUIEventAdapter &ea, ::osgGA::GUIActionAdapter &) override |
Handle incoming user input. More... | |
Protected Member Functions | |
void | triggerMouseEventHandlers () |
Calls update on all MouseEventHandlers. More... | |
void | eventPick (const ::osgGA::GUIEventAdapter &ea) |
Gather current picks and assign them to the latest event. More... | |
void | clearButtonEvents () |
Clear out the current button events. More... | |
void | handleDestructionNotification (const dart::common::Subject *_subject) override |
Called by receiveDestructionNotification(). More... | |
void | sendDestructionNotification () const |
Send a destruction notification to all Observers. More... | |
void | addObserver (Observer *_observer) const |
Add an Observer to the list of Observers. More... | |
void | removeObserver (Observer *_observer) const |
Remove an Observer from the list of Observers. More... | |
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. More... | |
void | removeSubject (const Subject *_subject) |
Remove a Subject from this Observer. More... | |
void | removeAllSubjects () |
Remove all Subjects from this Observer. More... | |
Protected Attributes | |
Viewer * | mViewer |
dart::gui::osg::Viewer that this event handler is tied to More... | |
std::set< MouseEventHandler * > | mMouseEventHandlers |
Set of MouseEventHandlers that are tied to this DefaultEventHandler. More... | |
std::vector< PickInfo > | mButtonPicks [NUM_MOUSE_BUTTONS][BUTTON_NOTHING] |
The objects that were under the cursor during the last button event. More... | |
bool | mSuppressButtonPicks [NUM_MOUSE_BUTTONS][BUTTON_NOTHING] |
Suppress pick detection. More... | |
std::vector< PickInfo > | mMovePicks |
The objects that were under the cursor during the last move. More... | |
bool | mSuppressMovePicks |
Suppress pick detection for moves. More... | |
std::vector< PickInfo > | mTempPicks |
Cache for pick data. More... | |
MouseButtonEvent | mLastButtonEvent [NUM_MOUSE_BUTTONS] |
The last mouse event that was registered by the event handler. More... | |
Eigen::Vector2d | mLastCursorPosition |
X/Y values of the cursor (in the window coordinates) during the last mouse event. More... | |
int | mLastModKeyMask |
Storage for the last modkey mask. More... | |
std::set< Observer * > | mObservers |
List of current Observers. More... | |
std::set< const Subject * > | mSubjects |
List of current Subjects for this Observer. More... | |
|
explicit |
Constructor takes in a pointer to a viewer.
|
virtual |
Destructor.
void dart::gui::osg::DefaultEventHandler::activateButtonPicks | ( | MouseButton | button, |
MouseButtonEvent | event | ||
) |
Activate pick detection for the specified button event (on by default)
void dart::gui::osg::DefaultEventHandler::activateMovePicks | ( | ) |
Activate pick detection for mouse movements (on by default)
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
|
protectedinherited |
Add an Observer to the list of Observers.
|
protectedinherited |
Add a Subject for this Observer.
|
protected |
Clear out the current button events.
|
protected |
Gather current picks and assign them to the latest event.
MouseButtonEvent dart::gui::osg::DefaultEventHandler::getButtonEvent | ( | MouseButton | button | ) | const |
Returns the last event performed by a mouse button.
const std::vector< PickInfo > & dart::gui::osg::DefaultEventHandler::getButtonPicks | ( | MouseButton | button, |
MouseButtonEvent | event | ||
) | const |
Get the most recent picks for the specified button and event type.
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.
int dart::gui::osg::DefaultEventHandler::getModKeyMask | ( | ) | const |
Returns the last modkey mask.
const std::set< MouseEventHandler * > & dart::gui::osg::DefaultEventHandler::getMouseEventHandlers | ( | ) | const |
Get the list of MouseEventHandlers that are currently held by this DefaultEventHandler.
const std::vector< PickInfo > & dart::gui::osg::DefaultEventHandler::getMovePicks | ( | ) | const |
Get the most recent picks for a mouse movement (click-and-drag actions do not qualify as movements)
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).
double dart::gui::osg::DefaultEventHandler::getWindowCursorX | ( | ) | const |
Get the last x value of the cursor in Window coordinates.
double dart::gui::osg::DefaultEventHandler::getWindowCursorY | ( | ) | const |
Get the last y value of the cursor in Window coordinates.
|
override |
Handle incoming user input.
|
overrideprotectedvirtual |
Called by receiveDestructionNotification().
Override this function to customize your class's response to destruction notifications.
Reimplemented from dart::common::Observer.
void dart::gui::osg::DefaultEventHandler::pick | ( | std::vector< PickInfo > & | infoVector, |
const ::osgGA::GUIEventAdapter & | ea | ||
) |
Detect picks TODO(MXG): Consider putting this functionality in a more accessible place.
|
protectedinherited |
Called whenever a Subject is destroyed (or sends out a destruction notification).
Override handleDestructionNotification() in order to customize your class's response to destruction notifications.
|
protectedinherited |
Remove all Subjects from this Observer.
|
protectedinherited |
Remove an Observer from the list of Observers.
|
protectedinherited |
Remove a Subject from this Observer.
|
protectedinherited |
Send a destruction notification to all Observers.
This will cause all Observers to behave as if this Subject has been permanently deleted, so it should only be called when that behavior is desired.
void dart::gui::osg::DefaultEventHandler::suppressButtonPicks | ( | MouseButton | button, |
MouseButtonEvent | event | ||
) |
Suppress pick detection for the specified button event.
void dart::gui::osg::DefaultEventHandler::suppressMovePicks | ( | ) |
Suppress pick detection for mouse movements.
|
protected |
Calls update on all MouseEventHandlers.
|
protected |
The objects that were under the cursor during the last button event.
|
protected |
The last mouse event that was registered by the event handler.
|
protected |
X/Y values of the cursor (in the window coordinates) during the last mouse event.
|
protected |
Storage for the last modkey mask.
|
protected |
Set of MouseEventHandlers that are tied to this DefaultEventHandler.
|
protected |
The objects that were under the cursor during the last move.
|
mutableprotectedinherited |
List of current Observers.
|
protectedinherited |
List of current Subjects for this Observer.
|
protected |
Suppress pick detection.
|
protected |
Suppress pick detection for moves.
|
protected |
Cache for pick data.
|
protected |
dart::gui::osg::Viewer that this event handler is tied to