Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Overview

The file SoSubAction.h contains the macros for defining new action classes. The SO_ACTION_HEADER() macro declares type identifier and naming variables and methods that all action classes must support. The SO_ACTION_SOURCE() macro defines the static variables and methods declared in the SO_ACTION_HEADER() macro.

Creating a new action requires these steps:

  1. Select a name for the new action class and determine what class it is derived from.
  2. Define an initClass() method to initialize the runtime type information for the class (see Initializing the Action Class).

a. Enable elements in the state that are used by nodes when the action is applied to them (see the section called “Enabling Elements in the State”).

b. Register a static method for each node class that supports this action (see the section called “Registering Static Methods”).

c. Define an exitClass() method to clean up the type information. In the exitClass() routine of your class, use the macro SO_ACTION_EXIT_CLASS.

  1. Write the constructor for the action (see Defining the Constructor).
  2. Write the destructor for the action (see Defining the Destructor).
  3. If necessary, override the beginTraversal() method to implement a different traversal behavior or to perform special initialization before traversal. The apply() methods all call beginTraversal() (see Traversal Behavior).
  4. Implement the methods that you registered in step 2b of this list (see Implementing Static Methods).

An easy way to create a new action is to derive it from the callback action. The callback action provides generic traversal of the scene graph and enables all standard elements. Note that deriving a new action class requires more work than simply registering callback functions with the callback action. In many cases, this latter approach will suffice.