9.2. Overview

Although Inventor provides predefined highlight styles, at times you may want to highlight selected objects with a different style. You can provide your own highlight style in two ways: derive a new highlight class from SoGLRenderAction SoGLRenderAction SoGLRenderAction (described here), or make changes directly to the scene graph whenever the selection changes (using SoSelection SoSelection SoSelection callbacks, as described in Chapter 10 of The Inventor Mentor). If you're using manipulators, it's probably easiest to allow the manipulator to make changes to the scene graph through use of selection callbacks. In this case, the manipulator shows which objects are selected.

Creating a new highlight style by deriving a class from SoGLRenderAction SoGLRenderAction SoGLRenderAction is basically the same as deriving any new action class, as described in Chapter 4. You can use the action-class macros found in SoSubAction.h. The SO_ACTION_HEADER() macro declares type identifier and naming variables and methods that all node classes must support. The SO_ACTION_SOURCE() macro defines the static variables and methods declared in the SO_ACTION_HEADER() macro.

Creating a new highlight action class requires these steps:

  1. Select a name for the new highlight class. It will be derived from SoGLRenderAction SoGLRenderAction SoGLRenderAction or another highlight class.

  2. Define an initClass() method to initialize the type information. Use the SO_ACTION_INIT_CLASS() macro.

  3. Define a constructor. Use the SO_ACTION_CONSTRUCTOR() macro.

  4. Implement the virtual apply() method (see Section 9.3, “The apply() Method”).

  5. Implement other methods, if desired, to specify the appearance of the highlight. These optional methods include setColor(), setLinePattern() , and setLineWidth().