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

The file SoSubElement.h contains the macros for defining new element classes. The SO_ELEMENT_HEADER() macro declares type identifier and naming variables and methods that all element classes must support. The SO_ELEMENT_SOURCE() macro defines the static variables and methods declared in the SO_ELEMENT_HEADER() macro. Other macros useful in creating new element classes are mentioned in the following sections.

Creating a new element requires these steps:

  1. Select a name for the new element class and determine what class it is derived from (see Deriving a Class from an Existing Element).
  2. Implement an initClass() method to initialize the type information (see The initClass() Method).
  3. Define an exitClass() method to clean up the type information. In the exitClass() routine of your class, use the macro SO_ELEMENT_EXIT_CLASS.
  4. Implement a destructor. Elements don't have constructors (see Destructor).
  5. Implement an init() method (see The init() Method).
  6. Implement set() and get() methods to modify and access current values (see The set() and get() Methods).
  7. Implement a print() method for debugging purposes (see The print() Method).
  8. Depending on what your class is derived from and the nature of your element, you may need to implement the following methods:

a. matches() and copyMatchInfo() (see Additional Methods).

b. push() and pop() (see Pushing and Popping Elements).

c. setElt() (see Additional Methods).