16.11. Using List Parts

Some node-kit parts are actually lists of parts. These lists, of type SoNodeKitListPart SoNodeKitListPart SoNodeKitListPart , are a special type of group that restricts its children to certain classes of nodes. Examples are “childList” (found in SoSeparatorKit SoSeparatorKit SoSeparatorKit and SoSceneKit SoSceneKit SoSceneKit ) and “cameraList” and “lightList” (both found in SoSceneKit SoSceneKit SoSceneKit ). Whenever you add a child to a node-kit list, the group checks to see if that child is legitimate. If the child is not legitimate, it is not added (and if you are using the debugging library, an error is printed).

Use getPart() to obtain the requested list, then use any of the standard group methods for adding, removing, replacing, and inserting children in the parts list. (But remember that each of these methods is redefined to check the types of children before adding them.) For example:

SoPointLight *myLight = new SoPointLight;
ls = (SoNodeKitListPart *) k->getPart("lightList", TRUE);

SoPointLight myLight = new SoPointLight();
ls = (SoNodeKitListPart) k.GetPart("lightList", true);

SoPointLight myLight = new SoPointLight();
ls = (SoNodeKitListPart) k.getPart("lightList", true);