SoEventCallback Class |
Node which invokes callbacks for events.
Namespace: OIV.Inventor.Nodes
The SoEventCallback type exposes the following members.
Name | Description | |
---|---|---|
SoEventCallback | Constructor creates an event callback node with no event interest and a NULL path. |
Name | Description | |
---|---|---|
AddEventCallback | Add an event delegate. | |
AffectsState | Returns true if a node has an effect on the state during traversal. | |
Callback | (Inherited from SoNode.) | |
Copy | Calls Copy(false). (Inherited from SoNode.) | |
Copy(Boolean) | Creates and returns an exact copy of the node. | |
CopyFieldValues(SoFieldContainer) | Calls CopyFieldValues(fc, false). (Inherited from SoFieldContainer.) | |
CopyFieldValues(SoFieldContainer, Boolean) | Copies the contents of fc's fields into this object's fields. | |
Dispose |
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.) | |
Distribute | (Inherited from SoNode.) | |
DoAction | (Inherited from SoNode.) | |
EnableNotify | Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false). | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
FieldsAreEqual | Returns true if this object's fields are exactly equal to fc's fields. | |
Get | Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
GetAction | Returns the OIV.Inventor.Actions.SoHandleEventAction currently traversing this node, or NULL if traversal is not taking place. | |
GetAllFields | Returns a list of fields, including the eventIn's and eventOut's. | |
GetAlternateRep | This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type). | |
GetBoundingBox | (Inherited from SoNode.) | |
GetEvent | Returns the event currently being handled, or NULL if traversal is not taking place. | |
GetEventIn | Returns a the eventIn with the given name. | |
GetEventOut | Returns the eventOut with the given name. | |
GetField | Returns a the field of this object whose name is fieldName. | |
GetFieldName | Returns the name of the given field in the fieldName argument. | |
GetFields | Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetMatrix | (Inherited from SoNode.) | |
GetName | Returns the name of an instance. | |
GetPath | Gets the path which must be picked in order for the callbacks to be invoked. | |
GetPickedPoint | Returns pick information during OIV.Inventor.Actions.SoHandleEventAction traversal, or NULL if traversal is not taking place. | |
GetPrimitiveCount | (Inherited from SoNode.) | |
GetRenderEngineMode | Returns the supported Render engine mode. | |
GetRenderUnitID | (Inherited from SoNode.) | |
GetStringName | (Inherited from SoBase.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GLRender | (Inherited from SoNode.) | |
GLRenderBelowPath | (Inherited from SoNode.) | |
GLRenderInPath | (Inherited from SoNode.) | |
GLRenderOffPath | (Inherited from SoNode.) | |
GrabEvents | Tells the event callback node to grab events. | |
GrabEventsCleanup | (Inherited from SoNode.) | |
GrabEventsSetup | (Inherited from SoNode.) | |
HandleEvent | (Overrides SoNodeHandleEvent(SoHandleEventAction).) | |
HasDefaultValues | Returns true if all of the object's fields have their default values. | |
IsBoundingBoxIgnoring | This method is used by getBoundingBox action traversal to know if the current node must be traversed or not, ie the bounding should be ignored. | |
IsHandled | Returns whether the event has been handled. | |
IsNotifyEnabled | Notification is the process of telling interested objects that this object has changed. | |
IsOverride | Returns the state of the override flag. | |
IsSynchronizable | Gets the ScaleViz synchronizable state of this object. | |
Pick | (Inherited from SoNode.) | |
RayPick | (Inherited from SoNode.) | |
ReleaseEvents | Tells the event callback node to release the grab of events. | |
RemoveEventCallback | Removes a previously specified event delegate. | |
Search | (Inherited from SoNode.) | |
Set | 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. | |
SetHandled | Tells the node the event was handled. | |
SetName | (Inherited from SoBase.) | |
SetOverride | Turns the override flag on or off. | |
SetPath | Sets the path which must be picked in order for the callbacks to be invoked. | |
SetSynchronizable | Sets this to be a ScaleViz synchronizable object. | |
SetToDefaults | Sets all fields in this object to their default values. | |
ToString |
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.) | |
Touch | Marks an instance as modified, simulating a change to it. | |
Write | (Inherited from SoNode.) |
Name | Description | |
---|---|---|
IsDisposable | ISafeDisposable interface implementation.
(Inherited from SoDisposable.) | |
UserData |
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.) |
OIV.Inventor.Nodes.SoEventCallback will invoke application supplied delegatesduring OIV.Inventor.Actions.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 delegateinvocation to occur. The application delegateis 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 delegatein an OIV.Inventor.Nodes.SoEventCallback node, all the delegateswill be invoked when an event occurs, even if one of the callbacks handles the event. However, if the event is handled (i.e. SetHandledis called) by any of the delegates, no subsequent node in the scene graph will see the event. Generally OIV.Inventor.Nodes.SoEventCallback nodes should be placed near the beginning of the scene graph, so the OIV.Inventor.Actions.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 OIV.Inventor.Nodes.SoEventCallback node is traversed, then none of the delegateswill be invoked.
Remember that when using the Open Inventor viewer classes, OIV.Inventor.Actions.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 delegate.
When invoked, this OIV.Inventor.Nodes.SoEventCallback node will be passed to the delegate. Using this object, you can get the event being handled (OIV.Inventor.Nodes.SoEventCallback.GetEvent()) and query what geometry is under the cursor (OIV.Inventor.Nodes.SoEventCallback.GetPickedPoint()). These are convenient wrappers around the corresponding methods in the OIV.Inventor.Actions.SoHandleEventAction (which you can get using OIV.Inventor.Nodes.SoEventCallback.GetAction()).
Picking: When OIV.Inventor.Nodes.SoEventCallback.GetPickedPoint() is called, the handle event action automatically applies an OIV.Inventor.Actions.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 OIV.Inventor.Actions.SoHandleEventAction (OIV.Inventor.Nodes.SoEventCallback.GetAction()), then calling the OIV.Inventor.Nodes.SoEventCallback.GetPickedPoint() method. The first time this method is called during a handle event traversal, the handle event action will automatically apply its internal OIV.Inventor.Actions.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, OIV.Inventor.Nodes.SoEventCallback.GetPickedPoint().getNormal() returns (0,0,0) and OIV.Inventor.Nodes.SoEventCallback.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 OIV.Inventor.Actions.SoHandleEventAction.GetPickRoot().
To use GPU picking on compatible shapes, it is mandatory to set the pick radius to 0, see OIV.Inventor.Actions.SoHandleEventAction.SetPickRadius(System.Single). Compatible shapes are described in the OIV.Inventor.Actions.SoRayPickAction section Picking Algorithms.
An event callback node that handles key and button events
SoEventCallback eventNode = new SoEventCallback(); eventNode.AddEventCallback( typeof(SoKeyboardEvent) , new SoEventCallback.EventCB(keyEventCB) ); eventNode.AddEventCallback( typeof(SoMouseButtonEvent), new SoEventCallback.EventCB(btnEventCB) ); . . .
private void keyEventCB( SoEventCallback node ) { SoKeyboardEvent evt = (SoKeyboardEvent)node.GetEvent(); if (evt.GetKey() == SoKeyboardEvent.Keys.UP_ARROW) { // Do something, then tell action to stop traversal node.SetHandled(); } else if (evt.GetKey() == SoKeyboardEvent.Keys.DOWN_ARROW) { // Do something, then tell action to stop traversal node.SetHandled(); } }
private void btnEventCB( SoEventCallback node ) { SoEvent evt = node.GetEvent(); // If button 1 was pressed if (SoMouseButtonEvent.IsButtonPressEvent( evt, SoMouseButtonEvent.Buttons.BUTTON1 )) { // Check if any geometry is under the cursor SoHandleEventAction action = node.GetAction(); SoPickedPoint pickedPt = action.GetPickedPoint(); if (pickedPt != null) { SoPath pickedPath = pickedPt.GetPath(); SoNode pickedNode = pickedPath.FullPath.GetTail(); } } }
EventCallback {