29.3. Interacting with Your Application

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”:

  1. Make your own “auditor” class derived from an existing predefined DialogViz Interface class.

  2. Override the necessary virtual methods such as dialogPushButton(), dialogCheckBox(), menuRadioButtons(), …

  3. Attach the “auditor” to the dialog scene graph.

Building Your Auditor Class

Imagine in your DialogViz application the user must activate an SoDialogPushButton to do a certain computation.

First create your auditor class derived from SoDialogPushButtonAuditor :

class myAuditor : public SoDialogPushButtonAuditor
  virtual void dialogPushButton(SoDialogPushButton *button);

Override the virtual method to make your code execute when the component is activated:

void myAuditor::dialogPushButton(SoDialogPushButton *button)
// write your code ...

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 the section called “More about DialogViz group nodes”.

Attaching an Auditor to the Scene Graph

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.

Connecting Fields

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 :

// set new value to 10

// get slider value
int myValue = mySlider->value.getValue();

You can easily connect an SoDialogIntegerSlider value field to the depth of an SoCube SoCube SoCube . In this case, interacting with your slider will directly affect your cube.