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.
Your action may also need to enable certain elements in the state. For example, the SoRayPickAction SoRayPickAction SoRayPickAction enables the SoPickRayElement SoPickRayElement SoPickRayElement in its initClass() routine:
enableElement(SoPickRayElement::getClassTypeId());
Recall from Chapter 2 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.
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 SoNode 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 Section 4.6, “Implementing Static Methods” for information on implementing new static methods.