SoSwitch(3)

πŸ“¦ version 2.5.0, in fedora 43, fedora 44

πŸ’– SoSwitch πŸ’–

okay bestie, sit down, hydrate, because we're talking about SoSwitch β€” that's SoSwitch(3) from the Library Functions Manual, and she is that girl. ✨


✨ NAME ✨

SoSwitch β€” the SoSwitch class is a group node which selects one child subgraph for traversal. fr fr, she picks ONE kid and sends them out on stage. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <Inventor/nodes/SoSwitch.h>

Inherits SoGroup.

Inherited by SoBlinker.

🌸 Public Member Functions 🌸

virtual SoType getTypeId (void) const
SoSwitch (void)
SoSwitch (int numchildren)
virtual SbBool affectsState (void) const
virtual void doAction (SoAction *action)
virtual void callback (SoCallbackAction *action)
virtual void GLRender (SoGLRenderAction *action)
virtual void pick (SoPickAction *action)
virtual void getBoundingBox (SoGetBoundingBoxAction *action)
virtual void handleEvent (SoHandleEventAction *action)
virtual void getMatrix (SoGetMatrixAction *action)
virtual void search (SoSearchAction *action)
virtual void write (SoWriteAction *action)
virtual void getPrimitiveCount (SoGetPrimitiveCountAction *action)
virtual void audioRender (SoAudioRenderAction *action)
virtual void notify (SoNotList *nl)

🧚 Public Member Functions inherited from SoGroup 🧚

SoGroup (void)
SoGroup (int nchildren)
virtual void addChild (SoNode *node)
virtual void insertChild (SoNode *child, int newchildindex)
virtual SoNode * getChild (int index) const
virtual int findChild (const SoNode *node) const
virtual int getNumChildren (void) const
virtual void removeChild (int childindex)
virtual void removeChild (SoNode *child)
virtual void removeAllChildren (void)
virtual void replaceChild (int index, SoNode *newchild)
virtual void replaceChild (SoNode *oldchild, SoNode *newchild)
virtual SoChildList * getChildren (void) const

πŸ’œ Public Member Functions inherited from SoNode πŸ’œ

void setOverride (const SbBool state)
SbBool isOverride (void) const
void setNodeType (const NodeType type)
NodeType getNodeType (void) const
virtual SoNode * copy (SbBool copyconnections=0) const
virtual void GLRenderBelowPath (SoGLRenderAction *action)
virtual void GLRenderInPath (SoGLRenderAction *action)
virtual void GLRenderOffPath (SoGLRenderAction *action)
virtual void rayPick (SoRayPickAction *action)
virtual void grabEventsSetup (void)
virtual void grabEventsCleanup (void)
virtual void startNotify (void)
uint32_t getNodeId (void) const
virtual void writeInstance (SoOutput *out)
virtual SoNode * addToCopyDict (void) const
virtual SoFieldContainer * copyThroughConnection (void) const

πŸŽ€ Public Member Functions inherited from SoFieldContainer πŸŽ€

void setToDefaults (void)
SbBool hasDefaultValues (void) const
SbBool fieldsAreEqual (const SoFieldContainer *container) const
void copyFieldValues (const SoFieldContainer *container, SbBool
    copyconnections=0)
SbBool set (const char *const fielddata)
void get (SbString &fielddata)
virtual int getFields (SoFieldList &l) const
virtual int getAllFields (SoFieldList &l) const
virtual SoField * getField (const SbName &name) const
virtual SoField * getEventIn (const SbName &name) const
virtual SoField * getEventOut (const SbName &name) const
SbBool getFieldName (const SoField *const field, SbName &name) const
SbBool enableNotify (const SbBool flag)
SbBool isNotifyEnabled (void) const
SbBool set (const char *fielddata, SoInput *in)
void get (SbString &fielddata, SoOutput *out)
virtual SbBool validateNewFieldValue (SoField *field, void *newval)
virtual void addWriteReference (SoOutput *out, SbBool isfromfield=0)
SbBool getIsBuiltIn (void) const
void setUserData (void *userdata) const
void * getUserData (void) const

πŸ¦‹ Public Member Functions inherited from SoBase πŸ¦‹

void ref (void) const
void unref (void) const
void unrefNoDelete (void) const
int32_t getRefCount (void) const
void touch (void)
SbBool isOfType (SoType type) const
virtual SbName getName (void) const
virtual void setName (const SbName &newname)
void addAuditor (void *const auditor, const SoNotRec::Type type)
void removeAuditor (void *const auditor, const SoNotRec::Type type)
const SoAuditorList & getAuditors (void) const
SbBool shouldWrite (void)
void assertAlive (void) const

🌈 Static Public Member Functions 🌈

static SoType getClassTypeId (void)
static void initClass (void)

🌟 Static Public Member Functions inherited from SoGroup 🌟

static SoType getClassTypeId (void)
static void initClass (void)

⭐ Static Public Member Functions inherited from SoNode ⭐

static uint32_t getCompatibilityTypes (const SoType &nodetype)
static SoType getClassTypeId (void)
static SoNode * getByName (const SbName &name)
static int getByName (const SbName &name, SoNodeList &l)
static void initClass (void)
static void initClasses (void)
static uint32_t getNextNodeId (void)
static int getActionMethodIndex (const SoType type)
static void getBoundingBoxS (SoAction *action, SoNode *node)
static void GLRenderS (SoAction *action, SoNode *node)
static void callbackS (SoAction *action, SoNode *node)
static void getMatrixS (SoAction *action, SoNode *node)
static void handleEventS (SoAction *action, SoNode *node)
static void pickS (SoAction *action, SoNode *node)
static void rayPickS (SoAction *action, SoNode *node)
static void searchS (SoAction *action, SoNode *node)
static void writeS (SoAction *action, SoNode *node)
static void audioRenderS (SoAction *action, SoNode *node)
static void getPrimitiveCountS (SoAction *action, SoNode *node)

πŸ’« Static Public Member Functions inherited from SoFieldContainer πŸ’«

static void initClass (void)
static SoType getClassTypeId (void)
static void initCopyDict (void)
static void addCopy (const SoFieldContainer *orig, const
    SoFieldContainer *copy)
static SoFieldContainer * checkCopy (const SoFieldContainer *orig)
static SoFieldContainer * findCopy (const SoFieldContainer *orig, const
    SbBool copyconnections)
static void copyDone (void)

🫢 Static Public Member Functions inherited from SoBase 🫢

static void initClass (void)
static SoType getClassTypeId (void)
static void addName (SoBase *const base, const char *const name)
static void removeName (SoBase *const base, const char *const name)
static void incrementCurrentWriteCounter (void)
static void decrementCurrentWriteCounter (void)
static SoBase * getNamedBase (const SbName &name, SoType type)
static int getNamedBases (const SbName &name, SoBaseList &baselist,
    SoType type)
static SbBool read (SoInput *in, SoBase *&base, SoType expectedtype)
static void setInstancePrefix (const SbString &c)
static void setTraceRefs (SbBool trace)
static SbBool getTraceRefs (void)
static SbBool connectRoute (SoInput *in, const SbName &fromnodename,
    const SbName &fromfieldname, const SbName &tonodename, const SbName
    &tofieldname)
static SbBool readRoute (SoInput *in)

πŸ“ Public Attributes πŸ“

SoSFInt32 whichChild

πŸ‘‘ Protected Member Functions πŸ‘‘

virtual const SoFieldData * getFieldData (void) const
virtual ~SoSwitch ()
void traverseChildren (SoAction *action)

πŸ’… Protected Member Functions inherited from SoGroup πŸ’…

virtual ~SoGroup ()
virtual SbBool readInstance (SoInput *in, unsigned short flags)
virtual SbBool readChildren (SoInput *in)
virtual void copyContents (const SoFieldContainer *from, SbBool
    copyconnections)

πŸŽ€ Protected Member Functions inherited from SoNode πŸŽ€

SoNode (void)
virtual ~SoNode ()

🧁 Protected Member Functions inherited from SoFieldContainer 🧁

SoFieldContainer (void)
~SoFieldContainer ()

🌸 Protected Member Functions inherited from SoBase 🌸

SoBase (void)
virtual ~SoBase ()
virtual void destroy (void)
SbBool hasMultipleWriteRefs (void) const
SbBool writeHeader (SoOutput *out, SbBool isgroup, SbBool isengine)
    const
void writeFooter (SoOutput *out) const
virtual const char * getFileFormatName (void) const

πŸ”₯ Static Protected Member Functions πŸ”₯

static const SoFieldData ** getFieldDataPtr (void)

✨ Static Protected Member Functions inherited from SoGroup ✨

static const SoFieldData ** getFieldDataPtr (void)

πŸ¦„ Static Protected Member Functions inherited from SoNode πŸ¦„

static const SoFieldData ** getFieldDataPtr (void)
static void setNextActionMethodIndex (int index)
static int getNextActionMethodIndex (void)
static void incNextActionMethodIndex (void)
static void setCompatibilityTypes (const SoType &nodetype, const
    uint32_t bitmask)

πŸ’– Static Protected Member Functions inherited from SoBase πŸ’–

static uint32_t getCurrentWriteCounter (void)
static void staticDataLock (void)
static void staticDataUnlock (void)

🌟 Friends 🌟

class SoSwitchP

🎁 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
    }

πŸ’œ 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 = 0
static int nextActionMethodIndex = 0

πŸ“– Detailed Description πŸ“–

The SoSwitch class is a group node which selects one child subgraph for traversal. like. she's a group node, but she plays favorites. and honestly? iconic behavior. πŸ’…

Which child to traverse is controlled by the application programmer by using the SoSwitch::whichChild field. In addition to picking out a single child for traversal, it is also possible to flip all children on or off for traversal. so yeah β€” one child, or literally all of them on/off like a light switch. the range is giving. πŸ¦‹

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. main character energy: she lets your app decide who gets to exist in the scene rn. ✨

FILE FORMAT/DEFAULTS:

Switch {
    whichChild -1
}
ok and lowkey important bestie β€” that default is -1. remember it. we'll be seeing her again. πŸ‘€

πŸŽ€ Constructor & Destructor Documentation πŸŽ€

πŸ’– SoSwitch::SoSwitch (void ) πŸ’–

Default constructor.

Referenced by getFieldData().

🌸 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. so like, it's a vibe check for the allocator, not a rule. no cap. 🫢

πŸ¦‹ SoSwitch::~SoSwitch () [protected], [virtual] πŸ¦‹

Destructor.


not me leaving you hanging β€” there's more of this page coming, so stay tuned bestie πŸ’–

✨ Member Function Documentation ✨

SoType SoSwitch::getTypeId(void) const β€” [virtual] πŸ’…

Okay bestie, this one hands you the type identification of any object that derives from SoBase. What's it for? Run-time type checking and "downward" casting, periodt. πŸ‘‘

Usage example, copy it exactly, no cap:

void foo(SoNode * node)
{
  if (node->getTypeId() == SoFile::getClassTypeId()) {
    SoFile * filenode = (SoFile *)node;  // safe downward cast, knows the type
  }
  else if (node->getTypeId().isOfType(SoGroup::getClassTypeId())) {
    SoGroup * group = (SoGroup *)node;  // safe downward cast, knows the type
  }
}

Now for the application programmers who wanna extend the library with new nodes, engines, nodekits, draggers or whatever β€” this method needs to be overridden in all subclasses. Not optional, bestie. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using 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. 🧚

Wanna know more about 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] πŸŽ€

Hands back a pointer to the class-wide field data storage object for this instance. And if there are no fields at all? It returns NULL. Simple as that. ✨

  • Reimplemented from SoGroup.
  • Reimplemented in SoBlinker.
  • References SoSwitch().
  • Referenced by write().

SbBool SoSwitch::affectsState(void) const β€” [virtual] πŸ¦‹

Returns TRUE if the node could have any effect on the state during traversal. πŸ’«

If it returns FALSE, no data in the traversal-state will change from the pre-traversal state to the post-traversal state. Take the SoSeparator node β€” it returns FALSE, because it pushes and pops the state before and after traversal of its children. And all SoShape nodes also return FALSE, since just pushing out geometry data to the rendering engine won't affect the actual rendering state. Iconic behavior, honestly.

The default method returns TRUE, on a "better safe than sorry" philosophy. Very mindful, very demure.

  • Reimplemented from SoNode.
  • References affectsState(), SoGroup::getChild(), and SoGroup::getNumChildren().
  • Referenced by affectsState().

void SoSwitch::doAction(SoAction * action) β€” [virtual] πŸ”₯

This function performs the typical operation of a node for any action. The main character of the whole method lineup, fr fr.

  • Reimplemented from SoGroup.
  • References SoGroup::children, SoGroup::getBoundingBox(), SoGroup::getChildren(), SoGroup::getNumChildren(), SoAction::getPathCode(), SoAction::getState(), SbString::getString(), SoAction::isOfType(), SoDebugError::post(), and whichChild.
  • Referenced by audioRender(), callback(), getBoundingBox(), getMatrix(), getPrimitiveCount(), GLRender(), handleEvent(), pick(), and search().

void SoSwitch::callback(SoCallbackAction * action) β€” [virtual] 🌸

Action method for SoCallbackAction. πŸ’–

It simply updates the state according to how the node behaves for the render action, so the application programmer can use the SoCallbackAction for extracting information about the scene graph. So helpful of it.

  • Reimplemented from SoGroup.
  • References doAction().

void SoSwitch::GLRender(SoGLRenderAction * action) β€” [virtual] 🌈

Action method for the SoGLRenderAction.

This gets called during rendering traversals. Any node influencing the rendering state in any way, or who wants to throw geometry primitives at OpenGL, overrides this method. Slinging primitives at OpenGL is such a mood. πŸ”₯

  • Reimplemented from SoGroup.
  • References doAction().

void SoSwitch::pick(SoPickAction * action) β€” [virtual] πŸ“

Action method for SoPickAction.

Does common processing for SoPickAction action instances. Common queen behavior. πŸ‘‘

  • Reimplemented from SoGroup.
  • References doAction().

void SoSwitch::getBoundingBox(SoGetBoundingBoxAction * action) β€” [virtual] πŸŽ€

Action method for the SoGetBoundingBoxAction.

It calculates the bounding box and center coordinates for the node, and modifies the values of the action to encompass the bounding box for this node and to shift the center point for the scene more towards the one for this node. Moving the center point around like it owns the place. ✨

Nodes influencing how geometry nodes calculate their bounding box also override this method to change the relevant state variables.

  • Reimplemented from SoGroup.
  • Reimplemented in SoBlinker.
  • References doAction().

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 react to. If it's not giving, it's not reacting. πŸ’…

Nodes influencing relevant state variables for how event handling is done also override this method.

  • Reimplemented from SoGroup.
  • References doAction().

void SoSwitch::getMatrix(SoGetMatrixAction * action) β€” [virtual] πŸ¦‹

Action method for SoGetMatrixAction.

Updates action by accumulating with the transformation matrix of this node β€” if there is any. No matrix, no drama.

  • Reimplemented from SoGroup.
  • References doAction(), and SoAction::getCurPathCode().

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 β€” and if any of the requested criteria is a miss, the search is not deemed successful for the node. One miss and it's over, bestie. πŸ’€

See also

  • SoSearchAction
  • Reimplemented from SoGroup.
  • References SoGroup::children, doAction(), SoSearchAction::isFound(), SoSearchAction::isSearchingAll(), and SoNode::search().

void SoSwitch::write(SoWriteAction * action) β€” [virtual] πŸ“

Action method for SoWriteAction.

Writes out a node object, and any connected nodes, engines etc, if necessary. Putting it all on paper, literally. ✍️

  • Reimplemented from SoGroup.
  • Reimplemented in SoBlinker.
  • References SoFieldContainer::addWriteReference(), SoGroup::getChildren(), getFieldData(), SoGroup::getNumChildren(), SoWriteAction::getOutput(), SoOutput::getStage(), SoBase::hasMultipleWriteRefs(), SoOutput::isBinary(), SoChildList::traverse(), SoFieldData::write(), SoOutput::write(), SoBase::writeFooter(), and SoBase::writeHeader().
  • Referenced by SoBlinker::write().

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 the girlies one by one. πŸŽ€

Nodes influencing how geometry nodes calculate their primitive count also override this method to change the relevant state variables.

  • Reimplemented from SoGroup.
  • References doAction().

void SoSwitch::audioRender(SoAudioRenderAction * action) β€” [virtual] πŸ”Š

Action method for SoAudioRenderAction.

Does common processing for SoAudioRenderAction action instances. Turn the volume up, it's giving soundtrack. 🎢

  • Reimplemented from SoGroup.
  • References doAction().

void SoSwitch::notify(SoNotList * l) β€” [virtual] πŸ“£

Notifies all auditors for this instance when changes are made. Spreading the news, no gatekeeping.

  • Reimplemented from SoNode.
  • Reimplemented in SoBlinker.
  • References SoGroup::findChild(), SoNotRec::getBase(), SoNotList::getLastRec(), SoFieldContainer::notify(), SoNode::SoNode(), and whichChild.
  • Referenced by SoBlinker::notify().

void SoSwitch::traverseChildren(SoAction * action) β€” [protected] 🚫

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 legacy, it's giving deprecated energy. Don't build your whole personality on it. πŸ™ˆ


✨ Member Data Documentation ✨

SoSFInt32 SoSwitch::whichChild πŸ‘‘

Selects which child to traverse during rendering (and some other) actions.

The value should be either:

  • SO_SWITCH_NONE β€” for traversing no children, like it was an empty SoGroup node
  • SO_SWITCH_ALL β€” for traversing like if we were an SoGroup node
  • SO_SWITCH_INHERIT β€” for traversing the same child as the last SoSwitch node
  • or an index value for a child

When using SO_SWITCH_INHERIT, it's important to understand how the SoSwitch-node is affected by other SoSwitch-nodes. 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 listen β€” the switch does not only inherit from its parent switch node, but also from its siblings, located anywhere before it in the scenegraph. An example will help clarify this, bestie:

#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. Slay. πŸ’™

When constructing ascii Inventor files, the integer values for the keywords must be used instead of their names. They are -1 for SO_SWITCH_NONE, -2 for SO_SWITCH_INHERIT, and -3 for SO_SWITCH_ALL. Don't try to be cute and write the names, it won't work.

Default value for the field is SO_SWITCH_NONE.

  • Referenced by doAction(), SoBlinker::getBoundingBox(), SoSceneKit::getCameraNumber(), SoBlinker::notify(), notify(), SoInteractionKit::setAnySurrogatePath(), SoSceneKit::setCameraNumber(), SoTrackballDragger::setDefaultOnNonWritingFields(), SoInteractionKit::setSwitchValue(), and SoBlinker::SoBlinker().

✨ Author ✨

Generated automatically by Doxygen for Coin from the source code. Not a human, just a very efficient little bot doing its thing. πŸ€–βœ¨


And that's the whole page, bestie!! 🫢 This was Coin, Version 2.5.0, and the page is SoSwitch(3) β€” go forth and switch responsibly, mwah πŸ’…πŸ’–πŸŽ€

πŸ“¦ where this page comes from