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

The file SoSubField.h contains the macros for defining new field classes. If you do create a field class, you will probably need to use only a few of these macros. The more commonly used ones are documented in this chapter.

Creating a new field requires these steps:

  1. Select a name for the new field class, determine whether it is derived from SoSField or SoMField (or a subclass), and determine the type of the field value (for example, float, SbVec3f).
  2. Define an initClass() method to initialize type information. This step is required for both single-value and multiple-value fields (see Initializing the Field Class).
  3. Define an exitClass() method to clean up the type information. In the exitClass() routine of your class, use the macro SO_SFIELD_EXIT_CLASS for single-value fields, and SO_MFIELD_EXIT_CLASS for multiple-value fields.
  4. Implement the reading and writing methods for the field.

a. For single-value fields, implement readValue() and writeValue() methods (see Creating a Single-Value Field).

b. For multiple-value fields, implement read1Value() and write1Value() methods. You may also want to implement a getNumValuesPerLine() method for a multiple-value field. This method is used by the ASCII file format and tells how many values fit on one line when the field is written out (see Creating a Multiple-Value Field).

  1. If it is useful, you can optionally define other methods for setting and accessing values in the field. For example, SoSFVec3f allows you to set the value from three floats or from an array of three floats, and so on.