Click or drag to resize
SoEventCallback Class

Node which invokes callbacks for events.

Inheritance Hierarchy

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2023.1.3.0 (2023.1.3)
Syntax
public class SoEventCallback : SoNode

The SoEventCallback type exposes the following members.

Constructors
  NameDescription
Public methodSoEventCallback

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

Top
Methods
  NameDescription
Public methodAddEventCallback

Add an event delegate.

Public methodAffectsState

Returns true if a node has an effect on the state during traversal.

(Inherited from SoNode.)
Public methodCallback
(Inherited from SoNode.)
Public methodCopy
Calls Copy(false).
(Inherited from SoNode.)
Public methodCopy(Boolean)

Creates and returns an exact copy of the node.

(Inherited from SoNode.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodDistribute
(Inherited from SoNode.)
Public methodDoAction
(Inherited from SoNode.)
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAction

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

Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetAlternateRep

This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type).

(Inherited from SoNode.)
Public methodGetBoundingBox
(Inherited from SoNode.)
Public methodGetEvent

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

Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetMatrix
(Inherited from SoNode.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetPath

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

Public methodGetPickedPoint

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

Public methodGetPrimitiveCount
(Inherited from SoNode.)
Public methodGetRenderEngineMode

Returns the supported Render engine mode.

(Inherited from SoNode.)
Public methodGetRenderUnitID
(Inherited from SoNode.)
Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGLRender
(Inherited from SoNode.)
Public methodGLRenderBelowPath
(Inherited from SoNode.)
Public methodGLRenderInPath
(Inherited from SoNode.)
Public methodGLRenderOffPath
(Inherited from SoNode.)
Public methodGrabEvents

Tells the event callback node to grab events.

Public methodGrabEventsCleanup
(Inherited from SoNode.)
Public methodGrabEventsSetup
(Inherited from SoNode.)
Public methodHandleEvent
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodIsBoundingBoxIgnoring

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.

(Inherited from SoNode.)
Public methodIsHandled

Returns whether the event has been handled.

Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsOverride

Returns the state of the override flag.

(Inherited from SoNode.)
Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodPick
(Inherited from SoNode.)
Public methodRayPick
(Inherited from SoNode.)
Public methodReleaseEvents

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

Public methodRemoveEventCallback

Removes a previously specified event delegate.

Public methodSearch
(Inherited from SoNode.)
Public methodSet

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.

(Inherited from SoFieldContainer.)
Public methodSetHandled

Tells the node the event was handled.

Public methodSetName (Inherited from SoBase.)
Public methodSetOverride

Turns the override flag on or off.

(Inherited from SoNode.)
Public methodSetPath

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

Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoNode.)
Public methodWrite
(Inherited from SoNode.)
Top
Properties
  NameDescription
Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Top
Remarks

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.

EXAMPLE

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) );
. . .
Handler for key press events
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();
 }
}
Handler for mouse button events
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();
       }
   }
}

FILE FORMAT/DEFAULT

EventCallback { }

See Also