Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Initializing the Action Class

All action classes must have a static method to initialize the class (just like node classes). In this method, typically called initClass(), the type identifier information for the class is set up. This method must be called for all action classes to set up the method list correctly before an instance of the action can be created. The required work of this method is done by the SO_ACTION_INIT_CLASS() macro.

Enabling Elements in the State

Your action may also need to enable certain elements in the state. For example, the SoRayPickAction enables the SoPickRayElement in its initClass() routine:

enableElement( SoPickRayElement::getClassTypeId() );

Recall from Creating a Node that you can also enable elements in node class initialization methods using the SO_ENABLE() macro. All elements enabled by a parent action class are automatically enabled in a derived class.

Registering Static Methods

In addition, you need to explicitly register a static method for each supported node class with the method list for your new action. At a minimum, register a method for

SoNode, which can be inherited by other nodes. Use the SO_ACTION_ADD_METHOD() macro to register methods with the method list. For example:

SO_ACTION_ADD_METHOD( SoCube, cubeVolume );

See Implementing Static Methods for information on implementing new static methods.