Class SoNodeSensor


  • public class SoNodeSensor
    extends SoDataSensor
    Sensor class that can be attached to Open Inventor nodes. Node sensors detect changes to nodes, calling a callback whenever any field of the node or, if the node is a group node, any children of the node change. The Open Inventor viewer classes, for example, attach a node sensor 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.

    Node sensors provide methods that can be called in the callback to 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 node, there are multiple possible triggers and only some of the get trigger info methods will return useful information.

    Priority zero 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.

    The node 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 SoIdleSensor or SoAlarmSensor.

    Node sensors provide a "final" task that is called when the object the data sensor is attached to is finalized. This task should not attempt to modify the object in any way. (see setFinalTask(Runnable)) that is called just before the object the data sensor is attached to is deleted. The callback should not attempt to modify the object in any way.

    See SoDataSensor for general information and code example.

    See Also:
    SoFieldSensor, SoPathSensor, SoDataSensor
    • Constructor Detail

      • SoNodeSensor

        public SoNodeSensor​(java.lang.Runnable task)
        Builds a new node sensor with the task to be executed when the sensor is triggered.
      • SoNodeSensor

        public SoNodeSensor()
        Default constructor.
    • Method Detail

      • detach

        public void detach()
        Unschedules this sensor (if it is scheduled) and makes it ignore changes to the scene graph.
      • getAttachedNode

        public SoNode getAttachedNode()
        Returns the node that this sensor is sensing, or NULL if it is not attached to any node.
      • attach

        public void attach​(SoNode node)
        Makes this sensor detect changes to the given node.