SOSEARCHACTION(3iv)

SoSearchAction πŸ’…βœ¨

okay bestie, gather round, because we're talking about SoSearchAction(3IV) β€” the lil action class that goes snooping around your scene graph looking for nodes. yes she's nosy. yes she's iconic. let's get into it πŸ•΅οΈβ™€οΈπŸ’–


🌸 NAME 🌸

SoSearchAction β€” searches for nodes in a scene graph πŸ”


πŸ¦‹ INHERITS FROM πŸ¦‹

SoAction > SoSearchAction


✨ SYNOPSIS ✨

#include <Inventor/actions/SoSearchAction.h>

the enum situation, bestie:

enum LookFor {
     SoSearchAction::NODE  Search for a particular node (by pointer)
     SoSearchAction::TYPE  Search for a particular type of node
     SoSearchAction::NAME  Search for a node with a particular name
}

enum Interest {
     SoSearchAction::FIRST  Return only the first path found
     SoSearchAction::LAST   Return only the last path found
     SoSearchAction::ALL    Return all paths found
}

and the methods she got from her own class, SoSearchAction:

                    SoSearchAction()
void                setNode(SoNode *n)
SoNode *            getNode() const
void                setType(SoType t, SbBool derivedIsOk = TRUE)
SoType              getType(SbBool &derivedIsOk) const
void                setName(const SbName &n)
const SbName &      getName() const
void                setFind(int what)
int                 getFind()
void                setInterest(Interest interest)
Interest            getInterest() const
void                setSearchingAll(SbBool flag)
SbBool              isSearchingAll() const
SoPath *            getPath() const
SoPathList &        getPaths()
void                reset()

plus everything she inherited from SoAction:

virtual void        apply(SoNode *node)
virtual void        apply(SoPath *path)
virtual void        apply(const SoPathList &pathList, SbBool obeysRules =
                         FALSE)
static SoType       getClassTypeId()
virtual SoType      getTypeId()
virtual SbBool      isOfType(SoType type)
virtual void        invalidateState()

πŸ’– DESCRIPTION πŸ’–

so, what's the vibe? this class is your scene-graph detective πŸ•΅οΈβ™€οΈ. you use it to search scene graphs for specific nodes, nodes of a specific type, nodes with a specific name, or any combination of these. she can hunt down just the first or the last node that matches your criteria, or all the nodes that match. and then β€” the payoff β€” the action hands you back the paths to each node it found. paths to your faves. we love a queen who delivers πŸ‘‘

⚠️ real talk: by default, nodekits do not search their children when a search action is applied. the man page for SoBaseKit discusses the methods SoBaseKit::isSearchingChildren() and SoBaseKit::setSearchingChildren(), which let you query and control this behavior. so if your search is coming up empty, that might be why, bestie 😭

πŸŽ€ METHODS πŸŽ€

SoSearchAction()

Constructor. that's it, that's the whole thing. she's born πŸ’«


void setNode(SoNode *n) / SoNode * getNode() const

Sets/returns the node to search for. 🎯


void setType(SoType t, SbBool derivedIsOk = TRUE) / SoType getType(SbBool &derivedIsOk) const

Sets/returns the node type to search for. and here's the tea β˜•: if derivedIsOk is TRUE, a node that is of a type that is derived from t will pass this search criterion. so she's flexible, not picky. as she should be πŸ’…


void setName(const SbName &n) / const SbName & getName() const

Sets/returns the name of the node to search for. name-drop and she'll find it 🏷️


void setFind(int what) / int getFind()

Sets/returns what to look for; what is a bitmask of LookFor enum values. default is no flags at all. and here's the fun part β€” setting a node, type, and/or name to search for activates the relevant flag, so you may never need to call this method directly. she does it for you, no cap 🫢


void setInterest(Interest interest) / Interest getInterest() const

Sets/returns which paths to return. default is FIRST. first come, first served, main character energy πŸ‘‘


void setSearchingAll(SbBool flag) / SbBool isSearchingAll() const

Sets/returns whether searching uses regular traversal or whether it traverses every single node. for example, if this flag is FALSE, an SoSwitch node will traverse only the child or children it would normally traverse for an action. if the flag is TRUE, the switch would always traverse all of its children. the default is FALSE. πŸ”€


SoPath * getPath() const

Returns resulting path, or NULL if no path was found. 😭 should be used if the interest is FIRST or LAST. remember that, bestie, don't use her for ALL, it's giving wrong tool for the job.


SoPathList & getPaths()

Returns resulting path list. should be used if the interest is ALL. now this is the one for collecting everything 🌈


void reset()

Resets options back to default values; clears list of returned paths. this can be used to apply the action again with a different set of search criteria. she's got a reset button and honestly? we all need one 🧚


πŸ‘€ SEE ALSO πŸ‘€

  • SoPath
  • SoBaseKit

πŸ’Œ and that's the whole page, babe. this was SoSearchAction(3IV), manual page SoSearchAction(3IV)() β€” version and date baked right into that footer, cute. go search some scene graphs. slay. periodt. πŸ’…πŸ’–βœ¨