DART  6.10.1
dart::gui::osg::BodyNodeDnD Class Reference

#include <DragAndDrop.hpp>

Inheritance diagram for dart::gui::osg::BodyNodeDnD:
dart::gui::osg::DragAndDrop dart::common::Subject dart::common::Observer

Public Types

enum class  RotationOption : int { HOLD_MODKEY = 0 , ALWAYS_ON , ALWAYS_OFF }
 

Public Member Functions

 BodyNodeDnD (Viewer *viewer, dart::dynamics::BodyNode *bn, bool useExternalIK=true, bool useWholeBody=false)
 Constructor. More...
 
virtual ~BodyNodeDnD ()=default
 Virtual destructor. More...
 
dart::dynamics::BodyNodegetBodyNode () const
 Get the BodyNode associated with this DnD. More...
 
void update () override
 Called when mouse events are being handled. More...
 
void move () override
 Called to specify how the Entity should be moved. More...
 
void saveState () override
 Called when a point gets picked, and is used to save the current state of the Entity. More...
 
void release () override
 Called when the user lets go of the object that they are dragging and dropping. More...
 
void useExternalIK (bool external)
 Tell this DnD to use an external IK instead of the one embedded in the BodyNode. More...
 
bool isUsingExternalIK () const
 Returns true if it is using an external IK. More...
 
void useWholeBody (bool wholeBody)
 Tell this DnD to use the whole body. More...
 
bool isUsingWholeBody () const
 Returns true if this DnD is using the whole body. More...
 
void setPreserveOrientationModKey (::osgGA::GUIEventAdapter::ModKeyMask modkey)
 Set the key that will preserve the orientation of the body. More...
 
::osgGA::GUIEventAdapter::ModKeyMask getPreserveOrientationModKey () const
 Get the key that will preserve the orientation of the body. More...
 
void setJointRestrictionModKey (::osgGA::GUIEventAdapter::ModKeyMask modkey)
 Set the key that will restrict which joints are used by the DnD. More...
 
::osgGA::GUIEventAdapter::ModKeyMask getJointRestrictionModKey () const
 Get the key that will restrict which joints are used by the DnD. More...
 
dart::dynamics::EntitygetEntity () const
 Get the Entity that this DragAndDrop is associated with. More...
 
void setObstructable (bool _obstructable)
 If true is passed in, this object will only be drag and droppable if there are no other objects between its picked point and the camera. More...
 
bool isObstructable () const
 If this is true, then this object will only be drag and droppable if there are no other objects between its picked point and the camera. More...
 
virtual Eigen::Vector3d getConstrainedDx () const
 Default method for getting the translation requested by the user. More...
 
virtual Eigen::AngleAxisd getConstrainedRotation () const
 Default method for getting the rotation requested by the user. More...
 
void unconstrain ()
 Remove all constraints from the dragging and dropping. More...
 
void constrainToLine (const Eigen::Vector3d &slope)
 Constrain translation to only occur along the given slope, or constrain rotation to only occur about the given slope. More...
 
void constrainToPlane (const Eigen::Vector3d &normal)
 Constrain translation to only occur within the plane defined by the given normal, or constrain rotation to only occur about the given normal. More...
 
bool isMoving () const
 Returns the mAmMoving flag. More...
 
void setRotationOption (RotationOption option)
 Set the option for triggering rotations instead of translations. More...
 
RotationOption getRotationOption () const
 Get the current rotation option for this DnD. More...
 
void setRotationModKey (::osgGA::GUIEventAdapter::ModKeyMask rotationModKey)
 Set the modkey that will be used to toggle rotation for this DnD. More...
 
::osgGA::GUIEventAdapter::ModKeyMask getRotationModKey () const
 Get the modkey that will be used to toggle rotation for this DnD. More...
 

Protected Member Functions

void handleDestructionNotification (const dart::common::Subject *subscription) override
 Perform cleanup when the subject is destroyed. 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

dart::dynamics::WeakBodyNodePtr mBodyNode
 The BodyNode associated with this DnD. More...
 
dart::dynamics::InverseKinematicsPtr mIK
 The IK module being used by this DnD. More...
 
Eigen::Vector3d mSavedGlobalOffset
 The offset of the pick from the BodyNode origin, expressed in global coordinates. More...
 
Eigen::Vector3d mSavedLocalOffset
 The offset of the pick from the BodyNode origin, expressed in local coordinates. More...
 
Eigen::AngleAxisd mSavedRotation
 The rotation of the BodyNode. More...
 
bool mUseExternalIK
 Whether to use an external IK. More...
 
bool mUseWholeBody
 Whether to use the whole body. More...
 
::osgGA::GUIEventAdapter::ModKeyMask mPreserveOrientationModKey
 Key for preserving orientation. More...
 
::osgGA::GUIEventAdapter::ModKeyMask mJointRestrictionModKey
 Key for restricting joint usage. More...
 
std::size_t mAdditionalBodyNodes
 Currently unused, but this will change in the future. More...
 
ViewermViewer
 Pointer to the DnD's Viewer. More...
 
dart::dynamics::EntitymEntity
 Pointer to the DnD's Entity. More...
 
Eigen::Vector3d mPickedPosition
 The location in the world that was picked by the user. More...
 
Eigen::Vector3d mVector
 Reference vector for constraint (slope for line constraint, or normal for plane constraint) More...
 
Eigen::Vector3d mPivot
 Point in space about which rotations should happen. More...
 
ConstraintType mConstraintType
 Constraint type for this DnD. More...
 
bool mAmObstructable
 Whether other objects can block this one from being picked. More...
 
bool mAmMoving
 Whether this DnD is currently moving. More...
 
RotationOption mRotationOption
 Option for rotation settings. More...
 
::osgGA::GUIEventAdapter::ModKeyMask mRotationModKey
 Modkey for rotation. More...
 
std::set< Observer * > mObservers
 List of current Observers. More...
 
std::set< const Subject * > mSubjects
 List of current Subjects for this Observer. More...
 

Member Enumeration Documentation

◆ RotationOption

enum dart::gui::osg::DragAndDrop::RotationOption : int
stronginherited
Enumerator
HOLD_MODKEY 
ALWAYS_ON 
ALWAYS_OFF 

Constructor & Destructor Documentation

◆ BodyNodeDnD()

dart::gui::osg::BodyNodeDnD::BodyNodeDnD ( Viewer viewer,
dart::dynamics::BodyNode bn,
bool  useExternalIK = true,
bool  useWholeBody = false 
)

Constructor.

◆ ~BodyNodeDnD()

virtual dart::gui::osg::BodyNodeDnD::~BodyNodeDnD ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ addObserver()

void dart::common::Subject::addObserver ( Observer _observer) const
protectedinherited

Add an Observer to the list of Observers.

◆ addSubject()

void dart::common::Observer::addSubject ( const Subject _subject)
protectedinherited

Add a Subject for this Observer.

◆ constrainToLine()

void dart::gui::osg::DragAndDrop::constrainToLine ( const Eigen::Vector3d &  slope)
inherited

Constrain translation to only occur along the given slope, or constrain rotation to only occur about the given slope.

For rotation, this function is equivalent to constrainToPlane

◆ constrainToPlane()

void dart::gui::osg::DragAndDrop::constrainToPlane ( const Eigen::Vector3d &  normal)
inherited

Constrain translation to only occur within the plane defined by the given normal, or constrain rotation to only occur about the given normal.

For rotation, this function is equivalent to constrainToLine

◆ getBodyNode()

dart::dynamics::BodyNode * dart::gui::osg::BodyNodeDnD::getBodyNode ( ) const

Get the BodyNode associated with this DnD.

◆ getConstrainedDx()

Eigen::Vector3d dart::gui::osg::DragAndDrop::getConstrainedDx ( ) const
virtualinherited

Default method for getting the translation requested by the user.

◆ getConstrainedRotation()

Eigen::AngleAxisd dart::gui::osg::DragAndDrop::getConstrainedRotation ( ) const
virtualinherited

Default method for getting the rotation requested by the user.

◆ getEntity()

dart::dynamics::Entity * dart::gui::osg::DragAndDrop::getEntity ( ) const
inherited

Get the Entity that this DragAndDrop is associated with.

◆ getJointRestrictionModKey()

osgGA::GUIEventAdapter::ModKeyMask dart::gui::osg::BodyNodeDnD::getJointRestrictionModKey ( ) const

Get the key that will restrict which joints are used by the DnD.

◆ getPreserveOrientationModKey()

osgGA::GUIEventAdapter::ModKeyMask dart::gui::osg::BodyNodeDnD::getPreserveOrientationModKey ( ) const

Get the key that will preserve the orientation of the body.

◆ getRotationModKey()

osgGA::GUIEventAdapter::ModKeyMask dart::gui::osg::DragAndDrop::getRotationModKey ( ) const
inherited

Get the modkey that will be used to toggle rotation for this DnD.

◆ getRotationOption()

DragAndDrop::RotationOption dart::gui::osg::DragAndDrop::getRotationOption ( ) const
inherited

Get the current rotation option for this DnD.

◆ handleDestructionNotification()

void dart::gui::osg::DragAndDrop::handleDestructionNotification ( const dart::common::Subject subscription)
overrideprotectedvirtualinherited

Perform cleanup when the subject is destroyed.

Reimplemented from dart::common::Observer.

Reimplemented in dart::gui::osg::SimpleFrameShapeDnD.

◆ isMoving()

bool dart::gui::osg::DragAndDrop::isMoving ( ) const
inherited

Returns the mAmMoving flag.

◆ isObstructable()

bool dart::gui::osg::DragAndDrop::isObstructable ( ) const
inherited

If this is true, then this object will only be drag and droppable if there are no other objects between its picked point and the camera.

Default is true.

◆ isUsingExternalIK()

bool dart::gui::osg::BodyNodeDnD::isUsingExternalIK ( ) const

Returns true if it is using an external IK.

◆ isUsingWholeBody()

bool dart::gui::osg::BodyNodeDnD::isUsingWholeBody ( ) const

Returns true if this DnD is using the whole body.

◆ move()

void dart::gui::osg::BodyNodeDnD::move ( )
overridevirtual

Called to specify how the Entity should be moved.

Implements dart::gui::osg::DragAndDrop.

◆ receiveDestructionNotification()

void dart::common::Observer::receiveDestructionNotification ( const Subject _subject)
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.

◆ release()

void dart::gui::osg::BodyNodeDnD::release ( )
overridevirtual

Called when the user lets go of the object that they are dragging and dropping.

This function does nothing by default, but you can override it.

Reimplemented from dart::gui::osg::DragAndDrop.

◆ removeAllSubjects()

void dart::common::Observer::removeAllSubjects ( )
protectedinherited

Remove all Subjects from this Observer.

◆ removeObserver()

void dart::common::Subject::removeObserver ( Observer _observer) const
protectedinherited

Remove an Observer from the list of Observers.

◆ removeSubject()

void dart::common::Observer::removeSubject ( const Subject _subject)
protectedinherited

Remove a Subject from this Observer.

◆ saveState()

void dart::gui::osg::BodyNodeDnD::saveState ( )
overridevirtual

Called when a point gets picked, and is used to save the current state of the Entity.

Implements dart::gui::osg::DragAndDrop.

◆ sendDestructionNotification()

void dart::common::Subject::sendDestructionNotification ( ) const
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.

◆ setJointRestrictionModKey()

void dart::gui::osg::BodyNodeDnD::setJointRestrictionModKey ( ::osgGA::GUIEventAdapter::ModKeyMask  modkey)

Set the key that will restrict which joints are used by the DnD.

◆ setObstructable()

void dart::gui::osg::DragAndDrop::setObstructable ( bool  _obstructable)
inherited

If true is passed in, this object will only be drag and droppable if there are no other objects between its picked point and the camera.

◆ setPreserveOrientationModKey()

void dart::gui::osg::BodyNodeDnD::setPreserveOrientationModKey ( ::osgGA::GUIEventAdapter::ModKeyMask  modkey)

Set the key that will preserve the orientation of the body.

◆ setRotationModKey()

void dart::gui::osg::DragAndDrop::setRotationModKey ( ::osgGA::GUIEventAdapter::ModKeyMask  rotationModKey)
inherited

Set the modkey that will be used to toggle rotation for this DnD.

◆ setRotationOption()

void dart::gui::osg::DragAndDrop::setRotationOption ( RotationOption  option)
inherited

Set the option for triggering rotations instead of translations.

◆ unconstrain()

void dart::gui::osg::DragAndDrop::unconstrain ( )
inherited

Remove all constraints from the dragging and dropping.

◆ update()

void dart::gui::osg::BodyNodeDnD::update ( )
overridevirtual

Called when mouse events are being handled.

Reimplemented from dart::gui::osg::DragAndDrop.

◆ useExternalIK()

void dart::gui::osg::BodyNodeDnD::useExternalIK ( bool  external)

Tell this DnD to use an external IK instead of the one embedded in the BodyNode.

Using the one embedded in the BodyNode allows it to automatically be used in a WholeBodyIK, but using an external IK allows it to be automatically solved without instructing a WholeBodyIK to solve.

◆ useWholeBody()

void dart::gui::osg::BodyNodeDnD::useWholeBody ( bool  wholeBody)

Tell this DnD to use the whole body.

Member Data Documentation

◆ mAdditionalBodyNodes

std::size_t dart::gui::osg::BodyNodeDnD::mAdditionalBodyNodes
protected

Currently unused, but this will change in the future.

◆ mAmMoving

bool dart::gui::osg::DragAndDrop::mAmMoving
protectedinherited

Whether this DnD is currently moving.

◆ mAmObstructable

bool dart::gui::osg::DragAndDrop::mAmObstructable
protectedinherited

Whether other objects can block this one from being picked.

◆ mBodyNode

dart::dynamics::WeakBodyNodePtr dart::gui::osg::BodyNodeDnD::mBodyNode
protected

The BodyNode associated with this DnD.

◆ mConstraintType

ConstraintType dart::gui::osg::DragAndDrop::mConstraintType
protectedinherited

Constraint type for this DnD.

◆ mEntity

dart::dynamics::Entity* dart::gui::osg::DragAndDrop::mEntity
protectedinherited

Pointer to the DnD's Entity.

◆ mIK

dart::dynamics::InverseKinematicsPtr dart::gui::osg::BodyNodeDnD::mIK
protected

The IK module being used by this DnD.

◆ mJointRestrictionModKey

::osgGA::GUIEventAdapter::ModKeyMask dart::gui::osg::BodyNodeDnD::mJointRestrictionModKey
protected

Key for restricting joint usage.

◆ mObservers

std::set<Observer*> dart::common::Subject::mObservers
mutableprotectedinherited

List of current Observers.

◆ mPickedPosition

Eigen::Vector3d dart::gui::osg::DragAndDrop::mPickedPosition
protectedinherited

The location in the world that was picked by the user.

◆ mPivot

Eigen::Vector3d dart::gui::osg::DragAndDrop::mPivot
protectedinherited

Point in space about which rotations should happen.

◆ mPreserveOrientationModKey

::osgGA::GUIEventAdapter::ModKeyMask dart::gui::osg::BodyNodeDnD::mPreserveOrientationModKey
protected

Key for preserving orientation.

◆ mRotationModKey

::osgGA::GUIEventAdapter::ModKeyMask dart::gui::osg::DragAndDrop::mRotationModKey
protectedinherited

Modkey for rotation.

◆ mRotationOption

RotationOption dart::gui::osg::DragAndDrop::mRotationOption
protectedinherited

Option for rotation settings.

◆ mSavedGlobalOffset

Eigen::Vector3d dart::gui::osg::BodyNodeDnD::mSavedGlobalOffset
protected

The offset of the pick from the BodyNode origin, expressed in global coordinates.

◆ mSavedLocalOffset

Eigen::Vector3d dart::gui::osg::BodyNodeDnD::mSavedLocalOffset
protected

The offset of the pick from the BodyNode origin, expressed in local coordinates.

◆ mSavedRotation

Eigen::AngleAxisd dart::gui::osg::BodyNodeDnD::mSavedRotation
protected

The rotation of the BodyNode.

◆ mSubjects

std::set<const Subject*> dart::common::Observer::mSubjects
protectedinherited

List of current Subjects for this Observer.

◆ mUseExternalIK

bool dart::gui::osg::BodyNodeDnD::mUseExternalIK
protected

Whether to use an external IK.

◆ mUseWholeBody

bool dart::gui::osg::BodyNodeDnD::mUseWholeBody
protected

Whether to use the whole body.

◆ mVector

Eigen::Vector3d dart::gui::osg::DragAndDrop::mVector
protectedinherited

Reference vector for constraint (slope for line constraint, or normal for plane constraint)

◆ mViewer

Viewer* dart::gui::osg::DragAndDrop::mViewer
protectedinherited

Pointer to the DnD's Viewer.