SoSearchAction(3)
π SoSearchAction π
okay bestie, welcome to SoSearchAction(3) β that's section 3 of the Coin manual, and this page is long, so buckle up. This is part 1, and more parts are coming, so don't wander off. π
β¨ NAME β¨
SoSearchAction β the class that hands you the methods for searching through scene graphs. it's giving detective energy, fr fr. π
πΈ SYNOPSIS πΈ
#include <Inventor/actions/SoSearchAction.h>
Inherits SoAction.
π Public Types
enum LookFor { NODE = 1, TYPE = 2, NAME = 4 }
enum Interest { FIRST, LAST, ALL }
Public Types inherited from SoAction
enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 }
enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 }
π Public Member Functions
virtual SoType getTypeId (void) const
SoSearchAction (void)
virtual ~SoSearchAction (void)
void setNode (SoNode *const node)
SoNode * getNode (void) const
void setType (const SoType type, const SbBool chkderived=TRUE)
SoType getType (SbBool &chkderived) const
void setName (const SbName name)
SbName getName (void) const
void setFind (const int what)
int getFind (void) const
void setInterest (const Interest interest)
Interest getInterest (void) const
void setSearchingAll (const SbBool searchall)
SbBool isSearchingAll (void) const
SoPath * getPath (void) const
SoPathList & getPaths (void)
void reset (void)
void setFound (void)
SbBool isFound (void) const
void addPath (SoPath *const path)
Public Member Functions inherited from SoAction
virtual ~SoAction (void)
virtual SbBool isOfType (SoType type) const
virtual void apply (SoNode *root)
virtual void apply (SoPath *path)
virtual void apply (const SoPathList &pathlist, SbBool obeysrules=FALSE)
void apply (SoAction *beingApplied)
virtual void invalidateState (void)
AppliedCode getWhatAppliedTo (void) const
SoNode * getNodeAppliedTo (void) const
SoPath * getPathAppliedTo (void) const
const SoPathList * getPathListAppliedTo (void) const
const SoPathList * getOriginalPathListAppliedTo (void) const
SbBool isLastPathListAppliedTo (void) const
PathCode getPathCode (int &numindices, const int *&indices)
void traverse (SoNode *const node)
SbBool hasTerminated (void) const
const SoPath * getCurPath (void)
SoState * getState (void) const
PathCode getCurPathCode (void) const
virtual SoNode * getCurPathTail (void)
void usePathCode (int &numindices, const int *&indices)
void pushCurPath (const int childindex, SoNode *node=NULL)
void popCurPath (const PathCode prevpathcode)
void pushCurPath (void)
void popPushCurPath (const int childindex, SoNode *node=NULL)
void popCurPath (void)
void switchToPathTraversal (SoPath *path)
void switchToNodeTraversal (SoNode *node)
π Static Public Member Functions
static SoType getClassTypeId (void)
static void addMethod (const SoType type, SoActionMethod method)
static void enableElement (const SoType type, const int stackindex)
static void initClass (void)
Static Public Member Functions inherited from SoAction
static void initClass (void)
static void initClasses (void)
static SoType getClassTypeId (void)
static void nullAction (SoAction *action, SoNode *node)
π Static Public Attributes
static SbBool duringSearchAll = FALSE
π Protected Member Functions
virtual const SoEnabledElementsList & getEnabledElements (void) const
virtual void beginTraversal (SoNode *node)
Protected Member Functions inherited from SoAction
SoAction (void)
virtual void endTraversal (SoNode *node)
void setTerminated (const SbBool flag)
virtual SbBool shouldCompactPathList (void) const
π Static Protected Member Functions
static SoEnabledElementsList * getClassEnabledElements (void)
static SoActionMethodList * getClassActionMethods (void)
Static Protected Member Functions inherited from SoAction
static SoEnabledElementsList * getClassEnabledElements (void)
static SoActionMethodList * getClassActionMethods (void)
π Additional Inherited Members
Protected Attributes inherited from SoAction
SoState * state
SoActionMethodList * traversalMethods
π Detailed Description π
The SoSearchAction class provides methods for searching through scene graphs. that's the whole vibe, and honestly? iconic.
You can hunt for nodes by pointer, by type, and by name β or any combo of those criteria, because we love options. Types can be read as exact types, or the type can match nodes that are derived from it. And you can search every single node, or you can follow normal traversal rules while searching β which is especially important to note when it comes to switch nodes, bestie. don't sleep on that. π«Ά
When you use more than one of thesetNode(),setType()andsetName()calls, heads up: the action searches for node(s) with an "AND" combination of the given search criteria. all of them have to hit, no half-credit.
Now, the classic trap. One of the most common pitfalls when using SoSearchAction is calling isFound() after doing a search. It does not return what you'd expect it to return if you haven't read the documentation for that function. so go read it, okay? π i'm serious.
And another thing β please be careful with this one:
Be aware that if you do search operations on anSoSearchActioncreated on the stack, you can get some unfortunate side effects if you're not careful. SinceSoSearchActionkeeps a list of the path(s) found in the latest search, the nodes in these paths will be unref'ed when theSoSearchActionstack instance is destructed at the end of your function. If the root of your scene graph then has ref-count zero (it is often useful to do aunrefNoDelete()before returning a node from a function to leave the referencing to the caller), the root node will be destructed! π
so what do you do? A couple of options, and they both slay:
- It might be better to create a heap instance of the search action in those cases, since you'll then be able to destruct the search action before calling
unrefNoDelete(). - Another solution would be to call
reset()before callingunrefNoDelete()on your object, sincereset()truncates the path list.
Also, see the documentation of SoTexture2 for a full usage example of SoSearchAction. it's the reference example, iykyk. β¨
π§ Member Enumeration Documentation π§
π enum SoSearchAction::LookFor
Specify the search criterion. This can be a bitwise combination of the available values.
Enumerator:
NODEβ search for a node by pointer.TYPEβ search for a node by type.NAMEβ search for a node by name.
π enum SoSearchAction::Interest
Values used when specifying what node(s) we are interested in: the first one found, the last one, or all of them.
Enumerator:
FIRSTβ return the path to the first node found.LASTβ return the path to the last node found.ALLβ return paths to all nodes found.
π Constructor & Destructor Documentation π
π SoSearchAction::SoSearchAction (void )
Initializes internal settings with default values. And with the default settings, the SoSearchAction will ignore all nodes. yeah. by default it's not looking for anything β you gotta tell it what you want, main character. π
π SoSearchAction::~SoSearchAction (void ) [virtual]
Destructor. that's it, that's the whole thing.
and that's the end of part 1, bestie β there's more coming, so don't go anywhere π¦
SoType SoSearchAction::getTypeId(void) const [virtual]
okay so this one hands you the type id of any object that inherits from SoAction β it's how the library does runtime type checking and "downward" casting, bestie. β¨
Implements SoAction. π
SoType SoSearchAction::getClassTypeId(void) [static]
The static girlie that returns the SoType object linked to objects of this class. π
void SoSearchAction::addMethod(const SoType type, SoActionMethod method) [static]
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
like, not for you unless you're doing Very Serious Library Things, no cap. π
void SoSearchAction::enableElement(const SoType type, const int stackindex) [static]
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
same energy as above, it's giving internal-only. π
const SoEnabledElementsList & SoSearchAction::getEnabledElements(void) const [protected], [virtual]
Returns the list of enabled elements. π¦
Reimplemented from SoAction.
SoEnabledElementsList * SoSearchAction::getClassEnabledElements(void) [static], [protected]
Returns the list of enabled elements for this class.
so here's the lore: the enabledElements and methods variables are protected in the original OIV API. That'sβ¦ not such a good idea, since exposed static class member variables is a major grievance with regard to Win32 DLLs. π
This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
SoActionMethodList * SoSearchAction::getClassActionMethods(void) [static], [protected]
Returns the list of action methods for this class.
Same tea as the one right above: the enabledElements and methods variables are protected in the original OIV API, and that's not such a good idea, since exposed static class member variables is a major grievance with regard to Win32 DLLs. π
This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
void SoSearchAction::initClass(void) [static]
Initializes the runtime type system for this class, and sets up the enabled elements and action method list. the behind-the-scenes glow-up β¨
void SoSearchAction::setNode(SoNode *const nodeptr)
Sets the node pointer to search for. π
The action will be configured to set the search "interest" to LookFor NODE, so there is no need to call SoSearchAction::setFind(). it just handles it, periodt.
SoNode * SoSearchAction::getNode(void) const
Returns the node the SoSearchAction instance is configured to search for.
β οΈ Careful bestie: this method does not return what was found when you applied the action β it only returns what was specifically set by the user withsetNode(). What the action found is returned bygetPath()andgetPaths().
void SoSearchAction::setType(const SoType typearg, const SbBool chkderivedarg = TRUE)
Configures the SoSearchAction instance to search for nodes of the given type, and nodes of classes derived from the given type if chkderived is TRUE. πΈ
The action will be configured to set the search "interest" to LookFor TYPE, so there is no need to call SoSearchAction::setFind().
SoType SoSearchAction::getType(SbBool & chkderivedref) const
Returns the node type which is searched for, and whether derived classes of that type also return a match. π«Ά
void SoSearchAction::setName(const SbName namearg)
Configures the SoSearchAction instance to search for nodes with the given name.
The action will be configured to set the search "interest" to LookFor NAME, so there is no need to call SoSearchAction::setFind().
See also
SoNode::getByName()
SbName SoSearchAction::getName(void) const
Returns the name the SoSearchAction instance is configured to search for. π
void SoSearchAction::setFind(const int what)
Configures what to search for in the scene graph. what is a bitmask of LookFor flags. π―
Default find configuration is to ignore all nodes, but the setFind() configuration is updated automatically when any one of SoSearchAction::setNode(), SoSearchAction::setType() or SoSearchAction::setName() is called.
int SoSearchAction::getFind(void) const
Returns the search configuration of the action instance. lowkey the read-back of setFind(). β¨
void SoSearchAction::setInterest(const Interest interestarg)
Configures whether only the first, the last, or all the searching matches are of interest. Default configuration is FIRST. π
SoSearchAction::Interest SoSearchAction::getInterest(void) const
Returns whether only the first, the last, or all the searching matches will be saved. π
void SoSearchAction::setSearchingAll(const SbBool searchallarg)
Specifies whether normal graph traversal should be done (searchall is FALSE, which is the default setting), or if every single node should be searched (searchall is TRUE). π¦
If the searchall flag is TRUE, even nodes considered "hidden" by other actions are searched (like for instance the disabled children of SoSwitch nodes).
Heads up: SoBaseKit::setSearchingChildren() must be used to search for nodes under node kits.
SbBool SoSearchAction::isSearchingAll(void) const
Returns the traversal method configuration of the action. β
SoPath * SoSearchAction::getPath(void) const
Returns the path to the node of interest that matched the search criterions. If no match was found, NULL is returned.
Note: ifALLmatches are of interest, the result of a search action must be fetched throughSoSearchAction::getPaths().
There is one frequently asked question about the paths that are returned from either this method or the getPaths() method below: "why am I not getting the complete path as expected?" π
Well, then you probably have to cast the path to a SoFullPath, since certain nodes (nodekits, many VRML97 nodes) have hidden children. SoPath::getTail() will return the first node that has hidden children, or the tail if none of the nodes have hidden children. SoFullPath::getTail() will always return the actual tail. Just do like this:
SoFullPath * path = (SoFullPath *) searchaction->getPath();
SoVRMLCoordinate * vrmlcord = (SoVRMLCoordinate *) path->getTail();
slay, now you get the whole path. π
SoPathList & SoSearchAction::getPaths(void)
Returns a path list of all nodes that matched the search criterions. π
Note: if interest were onlyFIRSTorLAST,SoSearchAction::getPath()should be used instead of this method.
See also
getPath()
void SoSearchAction::reset(void)
Resets all the SoSearchAction internals back to their default values. fresh start energy β¨
void SoSearchAction::setFound(void)
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Marks the SoSearchAction instance as terminated. π
SbBool SoSearchAction::isFound(void) const
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Returns whether the search action was terminated.
Important: note that this value does not reflect whether the node(s) that was searched for was found or not. Use the result ofgetPath()/getPaths()if that is what you really are looking for. π
void SoSearchAction::addPath(SoPath *const pathptr)
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Sets the path, or adds the path to the path list, depending on the interest configuration.
β οΈ The path is not copied, so it cannot be modified after being added without side effects. no cap, that's a real one.
void SoSearchAction::beginTraversal(SoNode * node) [protected], [virtual]
This virtual method is called from SoAction::apply(), and is the entry point for the actual scene graph traversal. πͺβ¨
It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheriting SoAction.
Default method just callstraverse(), which any overridden implementation of the method must do too (or callSoAction::beginTraversal()) to trigger the scene graph traversal. don't skip this step bestie, nothing happens without it.
Reimplemented from SoAction.
π Member Data Documentation π
SbBool SoSearchAction::duringSearchAll = FALSE [static]
Obsoleted global flag, only present for compatibility reasons with old SGI / TGS Inventor application code. π΅
It's set to TRUE when an SoSearchAction traversal with SoSearchAction::isSearchingAll() equal to TRUE is started, and is reset to FALSE again after traversal has finished.
(The flag is used by SGI / TGS Inventor in SoSwitch::affectsState() to know when SoSwitch::whichChild should behave as SoSwitch::SO_SWITCH_ALL. We have a better solution for this problem in Coin.) π
πΈ Author πΈ
Generated automatically by Doxygen for Coin from the source code. it's giving β¨automaticβ¨, not a single human hand typed this, and honestly? iconic.
okay that's the whole page, bestie β this one's Coin version 4.0.10, dated Thu Jun 25 2026 00:00:00, and it lives at SoSearchAction(3). go forth and search, you absolute main character ππ
π¦ where this page comes from
- fedora 43: Coin4-devel 4.0.10-1.fc43 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 43: Coin4-devel 4.0.10-1.fc43 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 Β· BSD-3-Clause AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms