Scroll to navigation

SoSwitch(3IV)() SoSwitch(3IV)()


SoSwitch — group node that traverse one chosen child


SoBase > SoFieldContainer > SoNode > SoGroup > SoSwitch


#include <Inventor/nodes/SoSwitch.h>

Fields from class SoSwitch:

SoSFInt32 whichChild

Methods from class SoSwitch:


SoSwitch(int nChildren)

static SoType getClassTypeId()

Methods from class SoGroup:

void addChild(SoNode *child)

void insertChild(SoNode *child, int newChildIndex)

SoNode * getChild(int index) const

int findChild(const SoNode *child) const

int getNumChildren() const

void removeChild(int index)

void removeChild(SoNode *child)

void removeAllChildren()

void replaceChild(int index, SoNode *newChild)

void replaceChild(SoNode *oldChild, SoNode *newChild)

Methods from class SoNode:

void setOverride(SbBool state)

SbBool isOverride() const

SoNode * copy(SbBool copyConnections = FALSE) const

virtual SbBool affectsState() const

static SoNode * getByName(const SbName &name)

static int getByName(const SbName &name, SoNodeList &list)

Methods from class SoFieldContainer:

void setToDefaults()

SbBool hasDefaultValues() const

SbBool fieldsAreEqual(const SoFieldContainer *fc) const

void copyFieldValues(const SoFieldContainer *fc, SbBool copyConnections = FALSE)

SbBool set(const char *fieldDataString)

void get(SbString &fieldDataString)

virtual int getFields(SoFieldList &resultList) const

virtual SoField * getField(const SbName &fieldName) const

SbBool getFieldName(const SoField *field, SbName &fieldName) const

SbBool isNotifyEnabled() const

SbBool enableNotify(SbBool flag)

Methods from class SoBase:

void ref()

void unref() const

void unrefNoDelete() const

void touch()

virtual SoType getTypeId() const

SbBool isOfType(SoType type) const

virtual void setName(const SbName &name)

virtual SbName getName() const


This group node usually traverses only one or none of its children. It implements an operation similar to the switch statement in C. One can use this node to switch on and off the effects of some properties or to switch between different properties.

The whichChild field specifies the index of the child to traverse, where the first child has index 0.

A value of SO_SWITCH_NONE (-1, the default) means do not traverse any children. A value of SO_SWITCH_INHERIT (-2) allows the index to be inherited from a previously-encountered SoSwitch node or from certain other nodes (such as SoArray or SoMultipleCopy) that set the switch value. A value of SO_SWITCH_ALL (-3) traverses all children, making the switch behave exactly like a regular SoGroup.


SoSFInt32 whichChild

Index of the child to traverse, or one of SO_SWITCH_NONE, SO_SWITCH_INHERIT, or SO_SWITCH_ALL.



Creates a switch node with default settings.

SoSwitch(int nChildren)

Constructor that takes approximate number of children.

static SoType getClassTypeId()

Returns type identifier for this class.


SoGLRenderAction, SoCallbackAction, SoGetBoundingBoxAction, SoGetMatrixAction, SoHandleEventAction, SoRayPickAction

Traverses the chosen child or children.


If the action's Searching-All flag is set, always traverses all children. Otherwise, traverses just the chosen child or children.


Switch {

whichChild -1


SoArray, SoLevelOfDetail, SoMultipleCopy, SoPathSwitch