7.7. Changing a Defined Part

Three macros assist you in changing parts that have already been defined in the node kit (either in this class or in a parent class):

SO_KIT_CHANGE_ENTRY_TYPE()

changes the type or default type of a part inherited from the parent class

SO_KIT_ADD_LIST_ITEM_TYPE()

adds a type to the list of accepted child types (for list types only)

SO_KIT_CHANGE_NULL_BY_DEFAULT()

changes whether a part is NULL by default. If TRUE, the part is NULL by default. If FALSE, the part is always created during the SO_KIT_INIT_INSTANCE() macro for the node kit that uses this catalog.

Changing the Type of a Part

If you wish to change the type or defaultType of a part that is inherited from the parent class, use the following macro. If you change the type, the new type must be a subclass of the inherited type. This is useful if the part has an abstract type in the parent class, but you wish to narrow this parameter in the child class. If you change the defaultType, any subclass of type is allowable. The syntax of this macro is

SO_KIT_CHANGE_ENTRY_TYPE( name, newClassName, newDefaultClassName )

In this chapter, PyramidKit changes the type of the “shape” part from SoShape SoShape SoShape to Pyramid, and it changes the defaultType from SoCube SoCube SoCube to Pyramid:

SO_KIT_CHANGE_ENTRY_TYPE(shape, Pyramid, Pyramid);

Adding a Type to a List Entry

When you want a list part to accept more than one type of node as a child, use this macro to add to the listItemTypes:

SO_KIT_ADD_LIST_ITEM_TYPE( name, newClass)

For example, if you wanted “childList” to also accept SoCube SoCube SoCube nodes, you'd add:

SO_KIT_ADD_LIST_ITEM_TYPE(childList, SoCube);