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

As discussed in Key Concepts, the initClass() method sets up the type identifier and file format name information for the class. The initialization macro for nodes, SO_NODE_INIT_CLASS(), does most of the work for you. One additional task for you as the node writer is to enable each of the elements in the state for each action the node supports. The following subsections provide additional information about enabling elements in the state.

Enabling Elements in the State

In the initClass() method, use the SO_ENABLE() macro (defined in SoAction.h) to enable the elements required by your node in the state. To use a simple example,

SoDrawStyle enables these elements in the SoGLRenderAction :

SO_ENABLE( SoGLRenderAction, SoDrawStyleElement );
SO_ENABLE( SoGLRenderAction, SoLinePatternElement );
SO_ENABLE( SoGLRenderAction, SoLineWidthElement );
SO_ENABLE( SoGLRenderAction, SoPointSizeElement );

SoDrawStyle also implements the SoCallbackAction. It enables these elements in the SoCallbackAction :

SO_ENABLE( SoCallbackAction, SoDrawStyleElement );
SO_ENABLE( SoCallbackAction, SoLinePatternElement );
SO_ENABLE( SoCallbackAction, SoLineWidthElement );
SO_ENABLE( SoCallbackAction, SoPointSizeElement );

If you know that the element is already enabled by another node or action, you can skip this step. (See Table 1-1.)

Now that these elements have been enabled, their values can be set and inquired. (The debugging version of Inventor generates an error if you try to access or set an element that has not been enabled.)