SoSwitch(3)
π SoSwitch(3) π
okay bestie, welcome to the Library Functions Manual page for SoSwitch β the Coin/Inventor node that's basically the group-chat admin of your scenegraph. she picks ONE child subgraph to walk, and she's iconic for it. let's get into it π
β¨ NAME β¨
SoSwitch β the group node which selects one child subgraph for traversal. one. just one. she's decisive. π
π¦ SYNOPSIS π¦
#include <Inventor/nodes/SoSwitch.h>
- Inherits
SoGroup. - Inherited by
SoBlinker.
so she's a SoGroup girlie, and SoBlinker inherits from her. family tree is giving royal lineage π
π Public Member Functions
virtual SoType getTypeId (void) constβ the type-id getter, virtual as always.SoSwitch (void)β default constructor, the classic.SoSwitch (int numchildren)β constructor that takes a child count.virtual SbBool affectsState (void) constβ does she touch state? find out.virtual void doAction (SoAction *action)β the action dispatcher.virtual void callback (SoCallbackAction *action)β forSoCallbackAction.virtual void GLRender (SoGLRenderAction *action)β forSoGLRenderAction.virtual void pick (SoPickAction *action)β forSoPickAction.virtual void getBoundingBox (SoGetBoundingBoxAction *action)β forSoGetBoundingBoxAction.virtual void handleEvent (SoHandleEventAction *action)β forSoHandleEventAction.virtual void getMatrix (SoGetMatrixAction *action)β forSoGetMatrixAction.virtual void search (SoSearchAction *action)β forSoSearchAction.virtual void write (SoWriteAction *action)β forSoWriteAction.virtual void getPrimitiveCount (SoGetPrimitiveCountAction *action)β forSoGetPrimitiveCountAction.virtual void audioRender (SoAudioRenderAction *action)β forSoAudioRenderAction.virtual void notify (SoNotList *nl)β the notification handler.
π« Public Member Functions inherited from SoGroup
SoGroup (void)β default constructor.SoGroup (int nchildren)β constructor with a child-count hint.virtual void addChild (SoNode *node)β add a child to the end.virtual void insertChild (SoNode *child, int newchildindex)β slot a child in at a specific index.virtual SoNode * getChild (int index) constβ grab the child at index.virtual int findChild (const SoNode *node) constβ where's this child at?virtual int getNumChildren (void) constβ how many children do we have.virtual void removeChild (int childindex)β bye bye child at childindex.virtual void removeChild (SoNode *child)β bye bye this specific child.virtual void removeAllChildren (void)β clear the whole roster.virtual void replaceChild (int index, SoNode *newchild)β swap out the child at index.virtual void replaceChild (SoNode *oldchild, SoNode *newchild)β swap oldchild for newchild.virtual SoChildList * getChildren (void) constβ hand over the whole child list.
π« Public Member Functions inherited from SoNode
void setOverride (const SbBool state)β set the override flag.SbBool isOverride (void) constβ is override on?void setNodeType (const NodeType type)β set the node type.NodeType getNodeType (void) constβ get the node type.virtual SoNode * copy (SbBool copyconnections=FALSE) constβ copy the node.virtual void GLRenderBelowPath (SoGLRenderAction *action)β render below path.virtual void GLRenderInPath (SoGLRenderAction *action)β render in path.virtual void GLRenderOffPath (SoGLRenderAction *action)β render off path.virtual void rayPick (SoRayPickAction *action)β ray pick handler.virtual void grabEventsSetup (void)β set up event grabbing.virtual void grabEventsCleanup (void)β tear down event grabbing.virtual void startNotify (void)β kick off notification.uint32_t getNodeId (void) constβ the node's id.virtual void writeInstance (SoOutput *out)β write the instance out.virtual SoNode * addToCopyDict (void) constβ add yourself to the copy dict.virtual SoFieldContainer * copyThroughConnection (void) constβ copy through a connection.
π« Public Member Functions inherited from SoFieldContainer
void setToDefaults (void)β reset all fields to defaults.SbBool hasDefaultValues (void) constβ everything still default?SbBool fieldsAreEqual (const SoFieldContainer *container) constβ compare fields with another container.void copyFieldValues (const SoFieldContainer *container, SbBool copyconnections=FALSE)β copy field values over.SbBool set (const char *const fielddata)β set fields from a string.void get (SbString &fielddata)β read fields out into a string.virtual int getFields (SoFieldList &l) constβ collect the fields.virtual int getAllFields (SoFieldList &l) constβ collect all the fields.virtual SoField * getField (const SbName &name) constβ look up a field by name.virtual SoField * getEventIn (const SbName &name) constβ look up an event in by name.virtual SoField * getEventOut (const SbName &name) constβ look up an event out by name.SbBool getFieldName (const SoField *const field, SbName &name) constβ reverse lookup, field to name.SbBool enableNotify (const SbBool flag)β turn notifications on/off.SbBool isNotifyEnabled (void) constβ are notifications on?SbBool set (const char *fielddata, SoInput *input)β set fields from a string with an input.void get (SbString &fielddata, SoOutput *out)β read fields out with an output.virtual SbBool validateNewFieldValue (SoField *field, void *newval)β validate a new field value.virtual void addWriteReference (SoOutput *out, SbBool isfromfield=FALSE)β add a write reference.SbBool getIsBuiltIn (void) constβ is this thing built-in?virtual void getFieldsMemorySize (size_t &managed, size_t &unmanaged) constβ memory size of fields.void setUserData (void *userdata) constβ stash your user data.void * getUserData (void) constβ get your user data back.
π« Public Member Functions inherited from SoBase
void ref (void) constβ bump the ref count.void unref (void) constβ drop the ref count.void unrefNoDelete (void) constβ unref, but don't delete.int32_t getRefCount (void) constβ what's the ref count rn.void touch (void)β touch it.SbBool isOfType (SoType type) constβ type check.virtual SbName getName (void) constβ get the name.virtual void setName (const SbName &newname)β set the name.void addAuditor (void *const auditor, const SoNotRec::Type type)β add an auditor.void removeAuditor (void *const auditor, const SoNotRec::Type type)β remove an auditor.const SoAuditorList & getAuditors (void) constβ get the auditor list.SbBool shouldWrite (void)β should this be written?void assertAlive (void) constβ assert that you're alive.
π Static Public Member Functions
static SoType getClassTypeId (void)β the class type id.static void initClass (void)β initialize the class.
π Static Public Member Functions inherited from SoGroup
static SoType getClassTypeId (void)β the class type id.static void initClass (void)β initialize the class.
π Static Public Member Functions inherited from SoNode
static uint32_t getCompatibilityTypes (const SoType &nodetype)β compatibility types for a node type.static SoType getClassTypeId (void)β the class type id.static SoNode * getByName (const SbName &name)β find a node by name.static int getByName (const SbName &name, SoNodeList &l)β find nodes by name into a list.static void initClass (void)β initialize the class.static void initClasses (void)β initialize the classes.static uint32_t getNextNodeId (void)β the next node id.static int getActionMethodIndex (const SoType type)β action method index for a type.static void getBoundingBoxS (SoAction *action, SoNode *node)β static bounding-box action.static void GLRenderS (SoAction *action, SoNode *node)β static GL render action.static void callbackS (SoAction *action, SoNode *node)β static callback action.static void getMatrixS (SoAction *action, SoNode *node)β static get-matrix action.static void handleEventS (SoAction *action, SoNode *node)β static handle-event action.static void pickS (SoAction *action, SoNode *node)β static pick action.static void rayPickS (SoAction *action, SoNode *node)β static ray-pick action.static void searchS (SoAction *action, SoNode *node)β static search action.static void writeS (SoAction *action, SoNode *node)β static write action.static void audioRenderS (SoAction *action, SoNode *node)β static audio render action.static void getPrimitiveCountS (SoAction *action, SoNode *node)β static primitive-count action.
π Static Public Member Functions inherited from SoFieldContainer
static void initClass (void)β initialize the class.static SoType getClassTypeId (void)β the class type id.static void cleanupClass (void)β clean up the class.static void initCopyDict (void)β initialize the copy dict.static void addCopy (const SoFieldContainer *orig, const SoFieldContainer *copy)β register a copy.static SoFieldContainer * checkCopy (const SoFieldContainer *orig)β check for a copy.static SoFieldContainer * findCopy (const SoFieldContainer *orig, const SbBool copyconnections)β find a copy.static void copyDone (void)β copying is done, bestie.
π Static Public Member Functions inherited from SoBase
static void initClass (void)β initialize the class.static SoType getClassTypeId (void)β the class type id.static void addName (SoBase *const base, const char *const name)β add a name.static void removeName (SoBase *const base, const char *const name)β remove a name.static void incrementCurrentWriteCounter (void)β bump the write counter.static void decrementCurrentWriteCounter (void)β drop the write counter.static SoBase * getNamedBase (const SbName &name, SoType type)β get a named base.static int getNamedBases (const SbName &name, SoBaseList &baselist, SoType type)β get named bases into a list.static SbBool read (SoInput *input, SoBase *&base, SoType expectedtype)β read a base in.static void setInstancePrefix (const SbString &c)β set the instance prefix.static void setTraceRefs (SbBool trace)β set reference tracing.static SbBool getTraceRefs (void)β get reference tracing.static SbBool connectRoute (SoInput *input, const SbName &fromnodename, const SbName &fromfieldname, const SbName &tonodename, const SbName &tofieldname)β connect a route.static SbBool readRoute (SoInput *input)β read a route.
π Public Attributes
SoSFInt32 whichChildβ THE field. this is the one that decides which child gets traversed. she's the main character here, no cap. π
π Protected Member Functions
virtual const SoFieldData * getFieldData (void) constβ get the field data.virtual ~SoSwitch ()β destructor, protected as ever.void traverseChildren (SoAction *action)β traverse the children.
π Protected Member Functions inherited from SoGroup
virtual ~SoGroup ()β destructor.virtual SbBool readInstance (SoInput *in, unsigned short flags)β read an instance.virtual SbBool readChildren (SoInput *in)β read the children.virtual void copyContents (const SoFieldContainer *from, SbBool copyconnections)β copy the contents.
π Protected Member Functions inherited from SoNode
SoNode (void)β constructor.virtual ~SoNode ()β destructor.
π Protected Member Functions inherited from SoFieldContainer
SoFieldContainer (void)β constructor.virtual ~SoFieldContainer ()β destructor.
π Protected Member Functions inherited from SoBase
SoBase (void)β constructor.virtual ~SoBase ()β destructor.virtual void destroy (void)β destroy it.SbBool hasMultipleWriteRefs (void) constβ multiple write refs?SbBool writeHeader (SoOutput *out, SbBool isgroup, SbBool isengine) constβ write the header.void writeFooter (SoOutput *out) constβ write the footer.virtual const char * getFileFormatName (void) constβ get the file format name.
π§ Static Protected Member Functions
static const SoFieldData ** getFieldDataPtr (void)β get the field data pointer.
π§ Static Protected Member Functions inherited from SoGroup
static const SoFieldData ** getFieldDataPtr (void)β get the field data pointer.
π§ Static Protected Member Functions inherited from SoNode
static const SoFieldData ** getFieldDataPtr (void)β get the field data pointer.static void setNextActionMethodIndex (int index)β set the next action method index.static int getNextActionMethodIndex (void)β get the next action method index.static void incNextActionMethodIndex (void)β increment the next action method index.static void setCompatibilityTypes (const SoType &nodetype, const uint32_t bitmask)β set compatibility types.
π§ Static Protected Member Functions inherited from SoBase
static uint32_t getCurrentWriteCounter (void)β get the current write counter.static void staticDataLock (void)β lock the static data.static void staticDataUnlock (void)β unlock the static data.
π Additional Inherited Members
Public Types inherited from SoNode
enum NodeType { INVENTOR = 0x0000, VRML1 = 0x0001, VRML2 = 0x0002,
INVENTOR_1 = 0x0004, INVENTOR_2_0 = 0x0008, INVENTOR_2_1 = 0x0010,
INVENTOR_2_5 = 0x0020, INVENTOR_2_6 = 0x0040, COIN_1_0 = 0x0080,
COIN_2_0 = 0x0100, EXTENSION = 0x0200, COIN_2_2 = 0x0400, COIN_2_3 =
0x0800, COIN_2_4 = 0x1000, INVENTOR_5_0 = 0x2000, COIN_2_5 = 0x4000,
COIN_3_0 = 0x8000, INVENTOR_6_0 = 0x10000 }
Protected Types inherited from SoBase
enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 }
Protected Attributes inherited from SoGroup
SoChildList * children
Protected Attributes inherited from SoNode
uint32_t uniqueId
Protected Attributes inherited from SoFieldContainer
SbBool isBuiltIn
Static Protected Attributes inherited from SoNode
static uint32_t nextUniqueId = 1static int nextActionMethodIndex = 0
π Detailed Description π
okay so here's the whole vibe: the SoSwitch class is a group node which selects one child subgraph for traversal. that's her whole thing. she's not doing the most, she's doing the right amount. β¨
Which child to traverse is controlled by the application programmer by using the SoSwitch::whichChild field. and bestie, it gets better β in addition to picking out a single child for traversal, it is also possible to flip all children on or off for traversal. so you can have everyone or no one. it's giving "everyone's invited / actually no one is coming" energy π
This node is very useful for conditionally turning on or off parts of the scenegraph based on the current application processing mode, visualizing mode, or whatever else the application can do. so like, whatever your app's whole deal is β she'll gatekeep the scenegraph accordingly. obsessed. π«Ά
FILE FORMAT/DEFAULTS:
Switch {
whichChild -1
}
π οΈ Constructor & Destructor Documentation π οΈ
SoSwitch::SoSwitch (void )
Default constructor. the classic, no args, just vibes. π
SoSwitch::SoSwitch (int numchildren)
Constructor.
The argument should be the approximate number of children which is expected to be inserted below this node. The number need not be exact, as it is only used as a hint for better memory resource allocation.
ngl bestie this is literally just a hint β she's not counting your children, she's just reserving a lil space for them. don't stress about getting it perfect. πΈ
SoSwitch::~SoSwitch () [protected], [virtual]
Destructor. protected and virtual, as the ancestors intended. π¦
π Member Function Documentation π
SoType SoSwitch::getTypeId (void ) const [virtual]
Okay bestie, this one is literally the β¨identity checkβ¨ of the whole type system. It hands you back the type identification of any object derived from a class that inherits SoBase. What's it for? Run-time type checking, and "downward" casting β you know, when you know a node is secretly a fancier type and you wanna peek inside. π
Usage example, take notes:
void foo(SoNode * node)
{
if (node->getTypeId() == SoFile::getClassTypeId()) {
SoFile * filenode = (SoFile *)node; // safe downward cast, knows the type
}
}
Now, for the application programmers out there who wanna extend the library with new nodes, engines, nodekits, draggers or whatever else you dream up: this method needs to be overridden in all subclasses. Like, no skipping it, fr fr. You normally do that as part of setting up the full type system for your extension classes, and the usual way is the pre-defined macros β available through for instance Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes), Inventor/engines/SoSubEngine.h (for engine classes), and so on. The macros do the heavy lifting, you just show up. π
Want more? For the full tea on writing Coin extensions, go read the class documentation of the toplevel superclasses for the various class groups.
- Reimplemented from
SoGroup. - Reimplemented in
SoBlinker.
const SoFieldData * SoSwitch::getFieldData (void ) const [protected], [virtual]
Returns a pointer to the class-wide field data storage object for this instance. And if there are, like, no fields at all? It returns NULL. Simple as that. π
- Reimplemented from
SoGroup. - Reimplemented in
SoBlinker.
SbBool SoSwitch::affectsState (void ) const [virtual]
Returns TRUE if the node could have any effect on the state during traversal. That's it, that's the vibe check.
But when it returns FALSE? Then no data in the traversal-state will change from the pre-traversal state to the post-traversal state. Iconic behaviour, honestly. For example, the SoSeparator node returns FALSE, because it pushes and pops the state before and after traversal of its children β in and out, clean, no mess. All SoShape nodes return FALSE too, since just pushing out geometry data to the rendering engine won't affect the actual rendering state. Sending the fit pics doesn't change who you are. β¨
The default method returns TRUE, on a "better safe than sorry" philosophy. Cautious queen behaviour. π
- Reimplemented from
SoNode.
void SoSwitch::doAction (SoAction * action) [virtual]
This function performs the typical operation of a node for any action. The general-purpose girly. π«
- Reimplemented from
SoGroup.
void SoSwitch::callback (SoCallbackAction * action) [virtual]
Action method for SoCallbackAction.
It just updates the state according to how the node behaves for the render action, so you, the application programmer, can use the SoCallbackAction for extracting information about the scene graph. Lowkey a spy mission, highkey useful. π΅οΈββοΈ
- Reimplemented from
SoGroup.
void SoSwitch::GLRender (SoGLRenderAction * action) [virtual]
Action method for the SoGLRenderAction.
This is called during rendering traversals. Any node that influences the rendering state in any way β or who just wants to throw geometry primitives at OpenGL β overrides this method. Main character energy only. π
- Reimplemented from
SoGroup.
void SoSwitch::pick (SoPickAction * action) [virtual]
Action method for SoPickAction.
Does common processing for SoPickAction action instances. Nothing dramatic, just doing its little tasks. π§
- Reimplemented from
SoGroup.
void SoSwitch::getBoundingBox (SoGetBoundingBoxAction * action) [virtual]
Action method for the SoGetBoundingBoxAction.
Calculates bounding box and center coordinates for the node, and modifies the values of the action so it encompasses the bounding box for this node β and shifts the center point for the scene more towards the one for this node. Basically it's out here claiming space. π
Nodes that influence how geometry nodes calculate their bounding box also override this method, to change the relevant state variables.
- Reimplemented from
SoGroup. - Reimplemented in
SoBlinker.
void SoSwitch::handleEvent (SoHandleEventAction * action) [virtual]
Action method for SoHandleEventAction.
It inspects the event data from action, and processes it if it's something this node should actually react to. Not everything is your business, bestie β know when to respond. π
Nodes that influence relevant state variables for how event handling is done also override this method.
- Reimplemented from
SoGroup.
void SoSwitch::getMatrix (SoGetMatrixAction * action) [virtual]
Action method for SoGetMatrixAction.
Updates action by accumulating with the transformation matrix of this node (if any). Only if any, though. No matrix, no accumulation. π
- Reimplemented from
SoGroup.
void SoSwitch::search (SoSearchAction * action) [virtual]
Action method for SoSearchAction.
It compares the search criteria from the action to see if this node is a match. Searching is done by matching up all criteria set up in the SoSearchAction β so if any of the requested criteria is a miss, the search is not deemed successful for the node. All or nothing, periodt. π€
See also
SoSearchAction- Reimplemented from
SoGroup.
void SoSwitch::write (SoWriteAction * action) [virtual]
Action method for SoWriteAction.
Writes out a node object, and any connected nodes, engines etc β if necessary. Only if necessary, mind you. Don't write things that don't need writing. βοΈ
- Reimplemented from
SoGroup. - Reimplemented in
SoBlinker.
void SoSwitch::getPrimitiveCount (SoGetPrimitiveCountAction * action) [virtual]
Action method for the SoGetPrimitiveCountAction.
It calculates the number of triangle, line segment and point primitives for the node, and adds these to the counters of the action. Counting all the little pieces, one by one. π’
Nodes that influence how geometry nodes calculate their primitive count also override this method, to change the relevant state variables.
- Reimplemented from
SoGroup.
void SoSwitch::audioRender (SoAudioRenderAction * action) [virtual]
Action method for SoAudioRenderAction.
Does common processing for SoAudioRenderAction action instances. Turn it up. π§
- Reimplemented from
SoGroup.
void SoSwitch::notify (SoNotList * l) [virtual]
Notifies all auditors for this instance when changes are made. Like a group chat blast β everyone who's watching gets the update. π£
- Reimplemented from
SoNode. - Reimplemented in
SoBlinker.
void SoSwitch::traverseChildren (SoAction * action) [protected]
Okay so, real talk: this function was part of the original SGI Inventor API, but it is not supported in Coin, as it looks like it should probably have been private in Inventor. So... yeah. It's giving "left in the API by accident". π Don't rely on it.
πΈ Member Data Documentation πΈ
SoSFInt32 SoSwitch::whichChild
Selects which child to traverse during rendering (and some other) actions. This is the field, the one that decides everything. π
The value should be either:
SO_SWITCH_NONEβ for traversing no children, like it was an emptySoGroupnodeSO_SWITCH_ALLβ for traversing like if we were anSoGroupnodeSO_SWITCH_INHERITβ for traversing the same child as the lastSoSwitchnode- or an index value for a child
Now, when you're using SO_SWITCH_INHERIT, it is important to understand how the SoSwitch-node is affected by other SoSwitch-nodes. Pay attention bestie, this one's tricky.
If you have several switches in the scenegraph, the last switch with its whichChild field set to anything but SO_SWITCH_INHERIT will be used. And here's the plot twist: the switch does not only inherit from its parent switch node, but also from its siblings, located anywhere before it in the scenegraph. Family drama. π
An example will help clarify this:
#Inventor V2.1 ascii
Separator {
Switch {
whichChild 0
Group {
Switch {
whichChild 1
BaseColor { rgb 1 0 0 } # red
BaseColor { rgb 1 1 0 } # yellow
}
Switch {
whichChild -2 # SO_SWITCH_INHERIT
BaseColor { rgb 0 1 0 } # green
BaseColor { rgb 0 0 1 } # blue
}
Cube { }
}
}
}
This results in a blue cube on the screen. The reason being that the value of the previous whichChild field was inherited by the final switch, making it select child 1 β the blue BaseColor. Inheritance ate, honestly. π
When constructing ascii Inventor files, the integer values for the keywords must be used instead of their names. They are-1forSO_SWITCH_NONE,-2forSO_SWITCH_INHERIT, and-3forSO_SWITCH_ALL. No names in ascii files, only numbers, fr fr.
Default value for the field is SO_SWITCH_NONE.
β¨ Author β¨
Generated automatically by Doxygen for Coin from the source code. (Not a human author β the robot did it. π€)
And that's a wrap on SoSwitch(3), bestie! π¦ Thanks for reading all the way to the bottom, you absolute legend. This page came from Coin, version 3.1.3, and the manual page itself is SoSwitch(3). Go forth and switch responsibly. πβ¨π
π¦ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms