7.4. Defining the Constructor

In the constructor for the node-kit class, you define the new parts for the node-kit catalog and create the node-kit parts list for each instance (as well as performing the standard node subclass construction). Some parts may be created in the constructor as well.

A series of macros is used to define a node-kit catalog. They are described in Section 7.6, “Defining a Node-Kit Part”. Initially, the catalog is the same as that of the parent class and is set up with the macro

SO_KIT_CONSTRUCTOR()

Next, you can modify the catalog by adding new parts. A new part is entered in the catalog using one of three macros:

SO_KIT_ADD_CATALOG_ENTRY()

SO_KIT_ADD_CATALOG_ABSTRACT_ENTRY()

SO_KIT_ADD_CATALOG_LIST_ENTRY()

Attributes of existing parts may be modified using these macros:

SO_KIT_ADD_LIST_ITEM_TYPE()

SO_KIT_CHANGE_ENTRY_TYPE()

SO_KIT_CHANGE_NULL_BY_DEFAULT()

The node-kit parts list is created by the macro SO_KIT_INIT_INSTANCE(). The parts list is a protected member containing pointers to all the existing parts in this instance of the node kit. This macro also creates any parts that are created by default, such as the “shape” part in the SoShapeKit SoShapeKit SoShapeKit (a cube) and the “light” part in the SoLightKit SoLightKit SoLightKit (a directional light).

The setUpConnections() method can be redefined by the class. If so, it is called at the end of the constructor. This method attaches or detaches sensors, callback functions, and field connections. It is called at the beginning and end of SoBaseKit::readInstance() and at the beginning and end of SoBaseKit::copy() . For each of these operations, it turns the sensors and field connections off, performs the operation, and then turns the sensors and field connections on again. See Chapter 8 for an example of using setUpConnections().