Unlike Open Inventor, which uses callbacks, DialogViz uses an “ auditor” mechanism (like Java does) to catch interaction with dialog components. An “auditor” is a class containing a set of methods corresponding to the basic components (button, slider, etc…). DialogViz provides a set of predefined “auditor” classes.
Here are the steps to build an “auditor”:
Imagine in your DialogViz application the user must activate an SoDialogPushButton to do a certain computation.
First create your auditor class derived from SoDialogPushButtonAuditor :
C++ :
Override the virtual method to make your code execute when the component is activated:
C++ :
You may not want to create a new auditor class for each component in your
interface. So as a solution, you can create an auditor class derived from the SoDialogAuditor
class and attach it to the SoTopLevelDialog, or any other node with a grouping behavior, such
as SoColumnDialog, etc. specified in More about DialogViz group nodes.
After creating your auditor class, you must attach it to the scene graph. All components in the dialog scene graph can be identified by a user-defined string registered in the auditorID field.
To attach your auditor to the scene graph, call the addAuditor() method of the component you want the auditor to be attached to.
In some cases, particularly when the dialog window is loaded from an Inventor file, you may not have a pointer to the component to which you want to attach the auditor. In this case, you must use the searchForAuditorID() method to retrieve the component address.
It is preferable for auditorID fields to
be different for each component in the dialog window because the searchForAuditorId() method
stops searching as soon as it finds the first requested component.
If several auditors have been attached to the same component, they all
will be called when the component is activated.
DialogViz classes are Open Inventor nodekits, so the methods for setting and querying fields are the usual setValues() and getValues(), and the connection mechanism is available. Using field connections to connect user interface components directly to nodes or engines in the scene graph is powerful and convenient (avoids the need for an auditor in some cases).
For example, to set and query the value field of an SoDialogIntegerSlider :
C++ :
You can easily connect an SoDialogIntegerSlider value field to the depth of an SoCube. In this case, interacting with your slider will directly affect your cube.
C++ :