SoDataSensor Class |
Abstract base class for sensors attached to parts of a scene.
Namespace: OIV.Inventor.Sensors
The SoDataSensor type exposes the following members.
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetPriority | Gets the priority of the sensor. | |
GetTriggerChild | If this is a priority 0 data sensor, and a change to a group node's children caused this sensor to be triggered (getTriggerType returns GROUP_ADD_CHILD, GROUP_INSERT_CHILD, or GROUP_REPLACE_CHILD), returns the node that was added to the group, and NULL in all other cases. | |
GetTriggerChildIndex | If this is a priority 0 data sensor, and a change to a group node's children caused this sensor to be triggered (getTriggerType returns GROUP_ADD_CHILD, GROUP_INSERT_CHILD, or GROUP_REPLACE_CHILD), returns the index of the node that was added or removed, and -1 in all other cases. | |
GetTriggerFastEditInfo | Returns true if the triggered changes come from a field or node that was below a Separator with a fastEditPolicy field with a value different than OFF. | |
GetTriggerFastEditInfoFlag | Queries the flag that indicates whether the trigger path fastEdit info (see OIV.Inventor.Sensors.SoDataSensor.GetTriggerFastEditInfo()) is available to delegates. | |
GetTriggerField | If this is a priority 0 data sensor, returns the field that was modified that caused this sensor to trigger. | |
GetTriggerMFieldNumValues | If this is a priority 0 data sensor, and a change in the data values of a multiple field (e.g., OIV.Inventor.Fields.SoMFVec3f) caused this sensor to be triggered, returns the size of the range of the potentially changed values. | |
GetTriggerMFieldStartIndex | If this is a priority 0 data sensor, and a change in the data values of a multiple field (e.g., OIV.Inventor.Fields.SoMFVec3f) caused this sensor to be triggered, returns the first index of the range of the potentially changed values. | |
GetTriggerNode | If this is a priority 0 data sensor, returns the node that was modified that caused this sensor to trigger. | |
GetTriggerPath | If this is a priority 0 data sensor, returns a path to the node that caused this sensor to trigger. | |
GetTriggerPathFlag | Queries the flag that indicates whether the trigger path (see OIV.Inventor.Sensors.SoDataSensor.GetTriggerPath()) is available to delegates. | |
GetTriggerType | If this is a priority 0 data sensor, returns the type of change that occurred. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsIdleOnly | (Inherited from SoDelayQueueSensor.) | |
IsScheduled | Returns true if this sensor has been scheduled and is waiting in a sensor queue to be triggered. | |
Schedule | (Inherited from SoSensor.) | |
SetPriority | Sets the priority of the sensor. | |
SetTriggerFastEditInfoFlag | Sets the flag that indicates whether the trigger path fastEdit info (see OIV.Inventor.Sensors.SoDataSensor.GetTriggerFastEditInfo()) is available to delegatemethods. | |
SetTriggerPathFlag | Sets the flag that indicates whether the trigger path (see OIV.Inventor.Sensors.SoDataSensor.GetTriggerPath()) is available to delegatemethods. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Unschedule | (Inherited from SoSensor.) |
Name | Description | |
---|---|---|
Action | (Inherited from SoSensor.) | |
DeleteCallback | Sets a callback that will be called when the object the sensor is sensing is deleted. |
Data sensors detect changes to scene graph objects (paths, nodes, or fields) and trigger their delegatewhen the object changes. The Open Inventor viewer classes, for example, attach an OIV.Inventor.Sensors.SoNodeSensor to the root of the application's scene graph in order to know when any part of the scene graph has been modified and a redraw is needed.
Data sensors provide methods that can be called in the delegateto determine exactly which node or field caused the sensor to be triggered. However these methods only return valid information if the sensor priority was explicitly set to zero (default is 100). Depending on the type of attached object, there are multiple possible triggers and only some of the get trigger info methods will return useful information.
Priority zero data sensors are triggered immediately after the change. Normal priority sensors are not triggered until the next time the "delay queue" is processed. Normally this happens when the viewer / renderArea is not rendering and there are no input events to be processed.
A data sensor will be triggered if its Schedule()method is called. But the trigger node, trigger field, etc. queries will return null. Generally this method is only useful for "at some future time" sensors like OIV.Inventor.Sensors.SoIdleSensor or OIV.Inventor.Sensors.SoAlarmSensor.
Data sensors provide a delete delegatethat is called just before the object the data sensor is attached to is destroyed. The delegateshould not attempt to modify the object in any way.
Create a node sensor to detect when the camera has been modified.
SoCamera camera = viewer.GetCamera(); SoNodeSensor nodeSensor = new SoNodeSensor(); nodeSensor.Action = nodeChangedCB; nodeSensor.DeleteCallback = nodeDestroyedCB; nodeSensor.SetPriority( 0 ); nodeSensor.Attach( camera );
Delegatecalled when the object is modified.
public void nodeChangedCB( SoSensor sensor ) { SoNodeSensor nodeSensor = (SoNodeSensor)sensor; SoNode node = nodeSensor.GetAttachedNode(); Console.WriteLine("Node Changed: {0}", node.GetType().Name); if (nodeSensor.GetPriority() == 0) { SoField field = nodeSensor.GetTriggerField(); String fieldName; node.GetFieldName( field, out fieldName ); Console.WriteLine( " Field: {0}", fieldName ); } } public void nodeDestroyedCB(SoSensor sensor) { SoNodeSensor nodeSensor = (SoNodeSensor)sensor; SoNode node = nodeSensor.GetAttachedNode(); Console.WriteLine("Node Destroyed: {0}", node.GetType().Name); }