Node which invokes callbacks for events. More...
#include <Inventor/nodes/SoEventCallback.h>
Public Types | |
typedef void | SoEventCallbackCB(void *userData, SoEventCallback *node) |
Public Member Functions | |
virtual SoType | getTypeId () const |
Returns the type identifier for this specific instance. | |
SoEventCallback () | |
Constructor creates an event callback node with no event interest and a NULL path. | |
void | setPath (SoPath *path) |
Sets the path which must be picked in order for the callbacks to be invoked. | |
const SoPath * | getPath () |
Gets the path which must be picked in order for the callbacks to be invoked. | |
void | addEventCallback (SoType eventType, SoEventCallbackCB *f, void *userData=NULL) |
Add an event callback . | |
template<typename EventType > | |
void | addEventCallback (SoEventCallbackCB *f, void *userData=nullptr) |
Add an event callback . | |
void | removeEventCallback (SoType eventType, SoEventCallbackCB *f, void *userData=NULL) |
Removes a previously specified event callback . | |
template<typename EventType > | |
void | removeEventCallback (SoEventCallbackCB *f, void *userData=nullptr) |
Removes a previously specified event callback . | |
SoHandleEventAction * | getAction () const |
Returns the SoHandleEventAction currently traversing this node, or NULL if traversal is not taking place. | |
const SoEvent * | getEvent () const |
Returns the event currently being handled, or NULL if traversal is not taking place. | |
const SoPickedPoint * | getPickedPoint () const |
Returns pick information during SoHandleEventAction traversal, or NULL if traversal is not taking place. | |
void | setHandled () |
Tells the node the event was handled. | |
SbBool | isHandled () const |
Returns whether the event has been handled. | |
void | grabEvents () |
Tells the event callback node to grab events. | |
void | releaseEvents () |
Tells the event callback node to release the grab of events. | |
Public Member Functions inherited from SoNode | |
virtual void | setOverride (const SbBool state) |
Turns the override flag on or off. | |
virtual SbBool | isOverride () const |
Returns the state of the override flag. | |
virtual SoNode * | copy (SbBool copyConnections=FALSE) const |
Creates and returns an exact copy of the node. | |
virtual SbBool | affectsState () const |
Returns TRUE if a node has an effect on the state during traversal. | |
virtual void | touch () |
Marks an instance as modified, simulating a change to it. | |
Public Member Functions inherited from SoFieldContainer | |
void | setToDefaults () |
Sets all fields in this object to their default values. | |
SbBool | hasDefaultValues () const |
Returns TRUE if all of the object's fields have their default values. | |
SbBool | fieldsAreEqual (const SoFieldContainer *fc) const |
Returns TRUE if this object's fields are exactly equal to fc's fields. | |
void | copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE) |
Copies the contents of fc's fields into this object's fields. | |
SoNONUNICODE SbBool | set (const char *fieldDataString) |
Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
SbBool | set (const SbString &fieldDataString) |
Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
void | get (SbString &fieldDataString) |
Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
virtual int | getFields (SoFieldList &list) const |
Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
virtual int | getAllFields (SoFieldList &list) const |
Returns a list of fields, including the eventIn's and eventOut's. | |
virtual SoField * | getField (const SbName &fieldName) const |
Returns a the field of this object whose name is fieldName. | |
virtual SoField * | getEventIn (const SbName &fieldName) const |
Returns a the eventIn with the given name. | |
virtual SoField * | getEventOut (const SbName &fieldName) const |
Returns the eventOut with the given name. | |
SbBool | getFieldName (const SoField *field, SbName &fieldName) const |
Returns the name of the given field in the fieldName argument. | |
SbBool | enableNotify (SbBool flag) |
Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE). | |
SbBool | isNotifyEnabled () const |
Notification is the process of telling interested objects that this object has changed. | |
virtual void | setUserData (void *data) |
Sets application data. | |
void * | getUserData (void) const |
Gets user application data. | |
Public Member Functions inherited from SoBase | |
virtual SbName | getName () const |
Returns the name of an instance. | |
virtual void | setName (const SbName &name) |
Sets the name of an instance. | |
void | setSynchronizable (const bool b) |
Sets this to be a ScaleViz synchronizable object. | |
bool | isSynchronizable () const |
Gets the ScaleViz synchronizable state of this object. | |
Public Member Functions inherited from SoRefCounter | |
void | ref () const |
Adds a reference to an instance. | |
void | unref () const |
Removes a reference from an instance. | |
void | unrefNoDelete () const |
unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero. | |
int | getRefCount () const |
Returns current reference count. | |
void | lock () const |
lock this instance. | |
void | unlock () const |
unlock this instance. | |
Public Member Functions inherited from SoTypedObject | |
SbBool | isOfType (const SoType &type) const |
Returns TRUE if this object is of the type specified in type or is derived from that type. | |
template<typename TypedObjectClass > | |
SbBool | isOfType () const |
Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class. | |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
Static Public Member Functions inherited from SoNode | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
static SoNode * | getByName (const SbName &name) |
A node's name can be set using SoBase::setName(). | |
static int | getByName (const SbName &name, SoNodeList &list) |
A node's name can be set using SoBase::setName(). | |
Static Public Member Functions inherited from SoFieldContainer | |
static SoType | getClassTypeId () |
Returns the type of this class. | |
Static Public Member Functions inherited from SoBase | |
static SoType | getClassTypeId () |
Returns type identifier for this class. | |
Static Public Member Functions inherited from SoTypedObject | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
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.
The application method can conveniently find out what, if any, geometry is under the cursor by querying the SoHandleEventAction (getAction()), then calling the getPickedPoint() method. The first time this method is called during a handle event traversal, the handle event action will automatically apply its internal SoRayPickAction to the scene graph returned by getPickRoot(). The result is stored in case other nodes make the same query during the same traversal. The stored result can be cleared by calling clearApplyResult().
Some, but not all, options can be modified on the internal pick action (see for example setPickRadius()). Note that the internal pick action does not compute texture coordinates or normal vector for the picked point. Thus, getPickedPoint().getNormal() returns (0,0,0) and getPickedPoint().getTextureCoords() returns (0,0,0,0).
If your application needs to apply the pick action itself, for example to set different options, get the appropriate root node by calling SoHandleEventAction::getPickRoot().
Handler for key press events
Handler for mouse button events
SoInteraction, SoSelection, SoHandleEventAction, SoRayPickAction, SoDragger
Definition at line 284 of file SoEventCallback.h.
typedef void SoEventCallbackCB(void *userData, SoEventCallback *node) |
Definition at line 67 of file SoEventCallback.h.
SoEventCallback::SoEventCallback | ( | ) |
Constructor creates an event callback node with no event interest and a NULL path.
|
inline |
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.
Since Open Inventor 10.8
Definition at line 330 of file SoEventCallback.h.
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.
|
inline |
Returns the SoHandleEventAction currently traversing this node, or NULL if traversal is not taking place.
This should be called only from callback .
Definition at line 364 of file SoEventCallback.h.
|
static |
Returns the type identifier for this class.
|
inline |
Returns the event currently being handled, or NULL if traversal is not taking place.
This should be called only from callback .
Definition at line 370 of file SoEventCallback.h.
|
inline |
Gets the path which must be picked in order for the callbacks to be invoked.
Definition at line 306 of file SoEventCallback.h.
|
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.
Definition at line 388 of file SoEventCallback.h.
|
virtual |
Returns the type identifier for this specific instance.
Reimplemented from SoNode.
|
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.
Definition at line 416 of file SoEventCallback.h.
|
inline |
Returns whether the event has been handled.
This should be called only from callback .
Definition at line 408 of file SoEventCallback.h.
|
inline |
Tells the event callback node to release the grab of events.
Event grabbing is requested using grabEvents().
Definition at line 423 of file SoEventCallback.h.
|
inline |
Removes a previously specified event callback .
Since Open Inventor 10.8
Definition at line 349 of file SoEventCallback.h.
void SoEventCallback::removeEventCallback | ( | SoType | eventType, |
SoEventCallbackCB * | f, | ||
void * | userData = NULL |
||
) |
Removes a previously specified event callback .
|
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 .
Definition at line 401 of file SoEventCallback.h.
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.