Package com.openinventor.inventor.nodes
Class SoSwitch
- java.lang.Object
-
- All Implemented Interfaces:
SafeDisposable
- Direct Known Subclasses:
SoBlinker
,SoInteractiveSwitch
public class SoSwitch extends SoGroup
Group node that traverses one chosen child. This group node traverses exactly one, none or all 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, to switch between different properties, to switch between different geometry or to control the visibility of geometry.The
whichChild
field specifies the index of the child to traverse, where the first child has index 0. There are several special values that can be used:- SO_SWITCH_NONE (-1, the default) means do not traverse any children.
- SO_SWITCH_INHERIT (-2) allows the index to be inherited from a previously-encountered
SoSwitch
node or from certain other nodes (such asSoArray
orSoMultipleCopy
) that set the switch value. - SO_SWITCH_ALL (-3) traverses all children, making the switch behave exactly like a regular
SoGroup
.
There are several extended versions of this node with additional/different behavior:
SoInteractiveSwitch
: During a user interaction, for example moving the camera, traverses a different (or no) child specified by its whichInteractiveChild field.SoMultiSwitch
: Traverses any number of its children (specified in a list of indices).SoPathSwitch
: Only traverses its children if the current path (when it is traversed) matches or contains a path specified in its path field.SoMultiPathSwitch
: Only traverses its children if the current path matches or contains any of the paths specified in its paths field.
NOTES:
- The default value for
whichChild
is SO_SWITCH_NONE, meaning that nothing is displayed by default. In most cases you will want to set some other initial value in this field. - When the value of
whichChild
is SO_SWITCH_INHERIT, if the inherited value is larger than the number of children in the current node, the actual value used is "modulo" the number of children. - Some actions have an option that allows them to ignore the value of
whichChild
. For example, calling setSearchingAll(true) on anSoSearchAction
causes it to traverse all the children ofSoSwitch
nodes. SoSwitch
is commonly used to control the visibility of a geometry. For example an application might allow the user to create multiple slices through a volume (SoOrthoSlice
) or mesh (MoLogicalSlice) data set, but also allow the user to control the visibility of each slice separately. UsingSoSwitch
with SO_SWITCH_NONE is much more efficient than removing geometry from the scene graph because previously built caches are preserved. UsingSoSwitch
is also much more efficient than using draw style INVISIBLE (SoDrawStyle
) because the children are not traversed.- This node is an
SoGroup
, not anSoSeparator
, and therefore does not provide render caching. Generally if the children contain geometry, it is good practice to make each child anSoSeparator
to make render caching more effective.
File format/default:
Switch {
whichChild -1 Action behavior:
SoGLRenderAction
,SoCallbackAction
,SoGetBoundingBoxAction
,SoGetMatrixAction
,SoHandleEventAction
,SoRayPickAction
Traverses the chosen child or children. Sets:SoSwitchElement
SoSearchAction
If the action's Searching-All flag is set, always traverses all children. Otherwise, traverses just the chosen child or children.- See Also:
SoArray
,SoLevelOfDetail
,SoMultipleCopy
,SoPathSwitch
,SoMultiSwitch
,SoInteractiveSwitch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SoSwitch.WhichChild
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
Fields Modifier and Type Field Description static int
SO_SWITCH_ALL
static int
SO_SWITCH_INHERIT
static int
SO_SWITCH_NONE
SoSFInt32
whichChild
Index of the child to traverse, or one of SO_SWITCH_NONE, SO_SWITCH_INHERIT, or SO_SWITCH_ALL.-
Fields inherited from class com.openinventor.inventor.nodes.SoGroup
boundingBoxIgnoring
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Method Summary
-
Methods inherited from class com.openinventor.inventor.nodes.SoGroup
addChild, findChild, getChild, getNumChildren, insertChild, removeAllChildren, removeChild, removeChild, replaceChild, replaceChild
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Field Detail
-
whichChild
public final SoSFInt32 whichChild
Index of the child to traverse, or one of SO_SWITCH_NONE, SO_SWITCH_INHERIT, or SO_SWITCH_ALL.
-
SO_SWITCH_NONE
public static final int SO_SWITCH_NONE
- See Also:
- Constant Field Values
-
SO_SWITCH_INHERIT
public static final int SO_SWITCH_INHERIT
- See Also:
- Constant Field Values
-
SO_SWITCH_ALL
public static final int SO_SWITCH_ALL
- See Also:
- Constant Field Values
-
-