SoEventCallback Class Reference
[Nodes]

Node which invokes callbacks for events. More...

#include <Inventor/nodes/SoEventCallback.h>

Inheritance diagram for SoEventCallback:
SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.

Public Member Functions

virtual SoType getTypeId () const
 SoEventCallback ()
void setPath (SoPath *path)
const SoPathgetPath ()
void addEventCallback (SoType eventType, SoEventCallbackCB *f, void *userData=NULL)
void removeEventCallback (SoType eventType, SoEventCallbackCB *f, void *userData=NULL)
SoHandleEventActiongetAction () const
const SoEventgetEvent () const
const SoPickedPointgetPickedPoint () const
void setHandled ()
SbBool isHandled () const
void grabEvents ()
void releaseEvents ()

Static Public Member Functions

static SoType getClassTypeId ()

Detailed Description

Node which invokes callbacks for events.

SoEventCallback will invoke application supplied callbacks during SoHandleEventAction traversal. Methods allow the application to specify which Open Inventor events should trigger callbacks, and which path must be picked, if any, for the callback invocation to occur. The application callback is able to get information about the event and the pick detail, and may grab events, release events, and set whether the event was handled.

If you register more than one callback in an SoEventCallback node, all the callbacks will be invoked when an event occurs, even if one of the callbacks handles the event. However, if the event is handled (i.e. setHandled is called) by any of the callbacks , no subsequent node in the scene graph will see the event. Generally SoEventCallback nodes should be placed near the beginning of the scene graph, so the SoHandleEventAction does not need to traverse the rest of the scene graph if the event is handled. Note that events may be handled by other nodes in the scene graph, for example draggers and manipulators. If the event is handled before the SoEventCallback node is traversed, then none of the callbacks will be invoked.

Remember that when using the Open Inventor viewer classes, SoHandleEventAction traversal is only done when the viewer is in "selection" mode (the arrow cursor is displayed). Also note that some methods may only be called from the callback .

When invoked, this SoEventCallback node will be passed to the callback . Using this object, you can get the event being handled (getEvent()) and query what geometry is under the cursor (getPickedPoint()). These are convenient wrappers around the corresponding methods in the SoHandleEventAction (which you can get using getAction()).

Picking:
When getPickedPoint() is called, the handle event action automatically applies an SoRayPickAction to the scene graph using the cursor position in the event. The handle event action remembers the result in case another node needs pick information during the traversal. Often this is more convenient than creating and applying a pick action explicitly.

But note: The handle event action does not enable computation of normal vectors and texture coordinates in the pick action that it creates internally. If you need the normal vector at the point of intersection of the pick ray, then you must create your own pick action and apply it. In this case you can get the node to apply the pick action to by calling the handle event action's getPickRoot() method.

EXAMPLE

FILE FORMAT/DEFAULT

SEE ALSO

SoInteraction, SoSelection, SoHandleEventAction, SoRayPickAction, SoDragger

See related examples:

Spaceball, MedicalDentalCurveUnfolding, MedicalRuler, MedicalVolumePickingGpu, TutorialCombineColorMapping, TutorialPicking1, TutorialPicking2, TutorialPicking3, TutorialPicking4, TutorialPicking5, TutorialPicking6, TutorialPicking7, TutorialPicking8, TutorialPicking9, DemoAsyncGetDataBox


Constructor & Destructor Documentation

SoEventCallback::SoEventCallback (  ) 

Constructor creates an event callback node with no event interest and a NULL path.


Member Function Documentation

void SoEventCallback::addEventCallback ( SoType  eventType,
SoEventCallbackCB f,
void *  userData = NULL 
)

Add an event callback .

Specifies the callbacks to be invoked for different event types. When invoked, the callback will be passed the userData, along with a pointer to this SoEventCallback node. For example, passing the type of SoMouseButtonEvent means callbacks will be invoked only when a mouse button is pressed or released. Passing the type of SoEvent for the eventType will cause the callback to be invoked for every event which passes through this event callback node.

SoHandleEventAction* SoEventCallback::getAction (  )  const [inline]

Returns the SoHandleEventAction currently traversing this node, or NULL if traversal is not taking place.

This should be called only from callback .

static SoType SoEventCallback::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoNode.

const SoEvent* SoEventCallback::getEvent (  )  const [inline]

Returns the event currently being handled, or NULL if traversal is not taking place.

This should be called only from callback .

const SoPath* SoEventCallback::getPath (  )  [inline]

Gets the path which must be picked in order for the callbacks to be invoked.

const SoPickedPoint* SoEventCallback::getPickedPoint (  )  const [inline]

Returns pick information during SoHandleEventAction traversal, or NULL if traversal is not taking place.

This should be called only from callback .

When this method is called, an SoRayPickAction is automatically applied to the scene graph that the SoHandleEventAction is traversing, using the current event. However this is only done once for each SoHandleEventAction traversal and the result is cached for subsequent queries during the current traversal.

Note: The handle event action does not enable computation of normal vectors and texture coordinates in the pick action that it creates internally. If you need the normal vector at the point of intersection of the pick ray, then you must create your own pick action and apply it. In this case you can get the node to apply the pick action to by calling the handle event action's getPickRoot() method.

virtual SoType SoEventCallback::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoNode.

void SoEventCallback::grabEvents (  )  [inline]

Tells the event callback node to grab events.

While grabbing, the node will consume all events; however, each callback will only be invoked for events of interest.

SbBool SoEventCallback::isHandled (  )  const [inline]

Returns whether the event has been handled.

This should be called only from callback .

void SoEventCallback::releaseEvents (  )  [inline]

Tells the event callback node to release the grab of events.

Event grabbing is requested using grabEvents().

void SoEventCallback::removeEventCallback ( SoType  eventType,
SoEventCallbackCB f,
void *  userData = NULL 
)

Removes a previously specified event callback .

void SoEventCallback::setHandled (  )  [inline]

Tells the node the event was handled.

The callback is responsible for setting whether the event was handled or not. If there is more than one callback registered with an SoEventCallback node, all of them will be invoked, regardless of whether one has handled the event or not. This should be called only from callback .

void SoEventCallback::setPath ( SoPath path  ) 

Sets the path which must be picked in order for the callbacks to be invoked.

If the path is NULL, the callbacks will be invoked for every interesting event, as specified by addEventCallback(), regardless of what is picked. The setPath() method makes its own copy of the passed path.


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

Open Inventor by FEI reference manual, generated on 21 Nov 2018
Copyright © FEI S.A.S. All rights reserved.
http://www.openinventor.com/