Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoDataSensor Class Referenceabstract

Abstract base class for sensors attached to parts of a scene. More...

#include <Inventor/sensors/SoDataSensor.h>

+ Inheritance diagram for SoDataSensor:

Public Types

enum  ChangeType {
  UNSPECIFIED ,
  GROUP_ADD_CHILD ,
  GROUP_INSERT_CHILD ,
  GROUP_REPLACE_CHILD ,
  GROUP_REMOVE_CHILD ,
  GROUP_REMOVE_ALL_CHILDREN ,
  FIELD_MULTIVALUE
}
 Change type. More...
 
- Public Types inherited from SoSensor
typedef void SoSensorCB(void *data, SoSensor *sensor)
 This typedef defines the calling sequence for all callbacks from sensors.
 

Public Member Functions

 SoDataSensor ()
 Constructor.
 
 SoDataSensor (SoSensorCB *func, void *data)
 Constructor that takes standard callback function and data.
 
void setDeleteCallback (SoSensorCB *f, void *data=NULL)
 Sets a callback that will be called when the object the sensor is sensing is deleted.
 
SoNodegetTriggerNode () const
 If this is a priority 0 data sensor, returns the node that was modified that caused this sensor to trigger.
 
SoFieldgetTriggerField () const
 If this is a priority 0 data sensor, returns the field that was modified that caused this sensor to trigger.
 
SoPathgetTriggerPath () const
 If this is a priority 0 data sensor, returns a path to the node that caused this sensor to trigger.
 
void setTriggerPathFlag (SbBool flag)
 Sets the flag that indicates whether the trigger path (see getTriggerPath()) is available to callback methods.
 
void setTriggerFastEditInfoFlag (SbBool flag)
 Sets the flag that indicates whether the trigger path fastEdit info (see getTriggerFastEditInfo()) is available to callback methods.
 
SbBool getTriggerPathFlag () const
 Queries the flag that indicates whether the trigger path (see getTriggerPath()) is available to callbacks .
 
SbBool getTriggerFastEditInfoFlag () const
 Queries the flag that indicates whether the trigger path fastEdit info (see getTriggerFastEditInfo()) is available to callbacks .
 
ChangeType getTriggerType () const
 If this is a priority 0 data sensor, returns the type of change that occurred.
 
SoNodegetTriggerChild () const
 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.
 
int getTriggerChildIndex () const
 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.
 
int getTriggerMFieldStartIndex () const
 If this is a priority 0 data sensor, and a change in the data values of a multiple field (e.g., SoMFVec3f) caused this sensor to be triggered, returns the first index of the range of the potentially changed values.
 
int getTriggerMFieldNumValues () const
 If this is a priority 0 data sensor, and a change in the data values of a multiple field (e.g., SoMFVec3f) caused this sensor to be triggered, returns the size of the range of the potentially changed values.
 
int getTriggerFastEditInfo () const
 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.
 
virtual void unschedule ()
 If this sensor is scheduled, removes it from the delay queue so that it will not be triggered.
 
- Public Member Functions inherited from SoDelayQueueSensor
 SoDelayQueueSensor ()
 Constructor.
 
 SoDelayQueueSensor (SoSensorCB *func, void *data)
 Constructor that takes standard callback and data.
 
void setPriority (uint32_t pri)
 Sets the priority of the sensor.
 
uint32_t getPriority () const
 Gets the priority of the sensor.
 
virtual void schedule ()
 If this sensor's priority is non-zero, adds this sensor to the list of delay queue sensors ready to be triggered.
 
virtual SbBool isIdleOnly () const
 
- Public Member Functions inherited from SoSensor
 SoSensor ()
 Constructor.
 
 SoSensor (SoSensorCB *f, void *d)
 Constructor that takes standard callback function and data.
 
void setFunction (SoSensorCB *f, void *userData)
 
void setFunction (SoSensorCB *f)
 Sets the callback function that is called when the sensor is triggered.
 
void setData (void *d)
 Sets the callback data passed to the callback function.
 
SoSensorCBgetFunction () const
 Returns the callback that will be called when the sensor is triggered.
 
void * getData () const
 Returns the user-supplied pointer that will be passed to the callback function.
 
virtual SbBool isScheduled () const
 Returns TRUE if this sensor has been scheduled and is waiting in a sensor queue to be triggered.
 

Additional Inherited Members

- Static Public Member Functions inherited from SoDelayQueueSensor
static uint32_t getDefaultPriority ()
 Returns the default delay queue sensor priority, which is 100.
 

Detailed Description

Abstract base class for sensors attached to parts of a scene.

Data sensors detect changes to scene graph objects (paths, nodes, or fields) and trigger their callback when the object changes. The Open Inventor viewer classes, for example, attach an 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 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 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 SoIdleSensor or SoAlarmSensor.

Data sensors provide a delete callback that is called just before the object the data sensor is attached to is destroyed. The callback should not attempt to modify the object in any way.

EXAMPLE

SEE ALSO

SoNodeSensor, SoPathSensor, SoFieldSensor, SoDelayQueueSensor

Definition at line 228 of file SoDataSensor.h.

Member Enumeration Documentation

◆ ChangeType

Change type.

Enumerator
UNSPECIFIED 

Unspecified.

GROUP_ADD_CHILD 

Group add child.

GROUP_INSERT_CHILD 

Group insert child.

GROUP_REPLACE_CHILD 

Group replace child.

GROUP_REMOVE_CHILD 

Group remove child.

GROUP_REMOVE_ALL_CHILDREN 

Group remove all children.

FIELD_MULTIVALUE 

Field multivalue.

Definition at line 232 of file SoDataSensor.h.

Constructor & Destructor Documentation

◆ SoDataSensor() [1/2]

SoDataSensor::SoDataSensor ( )

Constructor.

◆ SoDataSensor() [2/2]

SoDataSensor::SoDataSensor ( SoSensorCB func,
void *  data 
)

Constructor that takes standard callback function and data.

Member Function Documentation

◆ getTriggerChild()

SoNode * SoDataSensor::getTriggerChild ( ) const

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()

int SoDataSensor::getTriggerChildIndex ( ) const

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()

int SoDataSensor::getTriggerFastEditInfo ( ) const

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.

Since Open Inventor 9.2.3

◆ getTriggerFastEditInfoFlag()

SbBool SoDataSensor::getTriggerFastEditInfoFlag ( ) const
inline

Queries the flag that indicates whether the trigger path fastEdit info (see getTriggerFastEditInfo()) is available to callbacks .

Since Open Inventor 9.2.3

Definition at line 334 of file SoDataSensor.h.

◆ getTriggerField()

SoField * SoDataSensor::getTriggerField ( ) const

If this is a priority 0 data sensor, returns the field that was modified that caused this sensor to trigger.

Returns NULL if the sensor was not triggered because a field changed (for example, if schedule() is called on the sensor) or if this sensor is not a priority 0 sensor. Note that because one change to the scene graph may cause multiple nodes or fields to be modified (because of field-to-field connections), the field returned may not be the only one that changed.

◆ getTriggerMFieldNumValues()

int SoDataSensor::getTriggerMFieldNumValues ( ) const

If this is a priority 0 data sensor, and a change in the data values of a multiple field (e.g., SoMFVec3f) caused this sensor to be triggered, returns the size of the range of the potentially changed values.

Otherwise, returns -1

◆ getTriggerMFieldStartIndex()

int SoDataSensor::getTriggerMFieldStartIndex ( ) const

If this is a priority 0 data sensor, and a change in the data values of a multiple field (e.g., SoMFVec3f) caused this sensor to be triggered, returns the first index of the range of the potentially changed values.

Otherwise, returns -1

◆ getTriggerNode()

SoNode * SoDataSensor::getTriggerNode ( ) const

If this is a priority 0 data sensor, returns the node that was modified that caused this sensor to trigger.

Returns NULL if the sensor was not triggered because a node changed (for example, if schedule() is called on the sensor) or if this sensor is not a priority 0 sensor. Note that because one change to the scene graph may cause multiple nodes or fields to be modified (because of field-to-field connections), the node returned may not be the only one that changed.

◆ getTriggerPath()

SoPath * SoDataSensor::getTriggerPath ( ) const

If this is a priority 0 data sensor, returns a path to the node that caused this sensor to trigger.

Because recreating the path to the node that changed is relatively expensive, setTriggerPathFlag(TRUE) must be called before the sensor is scheduled. If it is not called, or if the sensor wasn't triggered because a node changed, this returns NULL. NULL is also returned if this is not a priority 0 sensor.

◆ getTriggerPathFlag()

SbBool SoDataSensor::getTriggerPathFlag ( ) const
inline

Queries the flag that indicates whether the trigger path (see getTriggerPath()) is available to callbacks .

Definition at line 326 of file SoDataSensor.h.

◆ getTriggerType()

ChangeType SoDataSensor::getTriggerType ( ) const

If this is a priority 0 data sensor, returns the type of change that occurred.

Returns UNSPECIFIED if the sensor was not triggered by a group children change or a multi-value field change or if this sensor is not a priority 0 sensor. A GROUP_* return value indicates that getTriggerChild and getTriggerChildIndex will return valid data. A FIELD_* return value indicates that the getTriggerMField* methods will return valid data.

◆ setDeleteCallback()

void SoDataSensor::setDeleteCallback ( SoSensorCB f,
void *  data = NULL 
)
inline

Sets a callback that will be called when the object the sensor is sensing is deleted.

Definition at line 268 of file SoDataSensor.h.

◆ setTriggerFastEditInfoFlag()

void SoDataSensor::setTriggerFastEditInfoFlag ( SbBool  flag)
inline

Sets the flag that indicates whether the trigger path fastEdit info (see getTriggerFastEditInfo()) is available to callback methods.

This is FALSE by default. Note that setting this to TRUE will add a little overhead when the sensor is notified. Since Open Inventor 9.2.3

Definition at line 319 of file SoDataSensor.h.

◆ setTriggerPathFlag()

void SoDataSensor::setTriggerPathFlag ( SbBool  flag)
inline

Sets the flag that indicates whether the trigger path (see getTriggerPath()) is available to callback methods.

This is FALSE by default. Note that setting this to TRUE will add a little overhead when the sensor is notified.

Definition at line 309 of file SoDataSensor.h.

◆ unschedule()

virtual void SoDataSensor::unschedule ( )
virtual

If this sensor is scheduled, removes it from the delay queue so that it will not be triggered.

Reimplemented from SoDelayQueueSensor.


The documentation for this class was generated from the following file: