Sensors are a special class of objects that can be attached to the database. They respond to database changes or to certain timer events by invoking a user-supplied callback function. Data sensors (derived from SoDataSensor( C++ | Java | .NET )) monitor part of the database and inform the application when that part changes. Timer sensors (such as SoAlarmSensor( C++ | Java | .NET ) and SoTimerSensor( C++ | Java | .NET )) notify the application when certain types of timer events occur. Note that timer “events” occur within Inventor and are not part of the event model described in Chapter 10, Handling Events and Selection. See Figure 14.1, “ Sensor Classes ” for a diagram of the portion of the class tree that includes sensors.
As the class tree in Figure 14.1, “ Sensor Classes ” suggests, sensors are placed in one of two queues:
When processing of either queue begins, all sensors in that queue are processed once, in order (see the section called “Using a Field Sensor”).
The following discussion of data and timer sensors uses a few new terms.
Triggering a sensor means calling its user-defined callback function and removing it from the queue.
Scheduling a sensor means adding it to a queue so that it can be triggered at some future time. If a sensor is already scheduled, scheduling it again has no effect. Unscheduling a sensor means removing it from the queue without processing it.
Notifying a data sensor means letting it know that the node (or field or path) to which it is attached has changed. A data sensor automatically schedules itself when it is notified of a change.