14.1. Introduction to Sensors

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.

Sensor Classes

Figure 14.1.  Sensor Classes


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.