SoSearchAction(3)

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

okay bestie, sit down, hydrate, and let's talk about SoSearchAction(3) πŸ’– this is the Library Functions Manual page for it and honestly? it's giving ✨ scene-graph detective energy ✨.


🌸 NAME 🌸

SoSearchAction β€” the SoSearchAction class provides methods for searching through scene graphs. she's a searcher, she's a finder, she's literally just here to look through your scene graph for you πŸ•΅οΈβ€β™€οΈπŸ¦‹


✨ 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.

so like. you can search for nodes by pointer, by type, and by name, or literally any combination of those three criteria bestie, she's flexible πŸ’… Types can be read as exact types, OR the type can match nodes that are derived from it. And you can either search every single node, or follow normal traversal rules while searching β€” and this is especially important to note with regard to switch nodes, ok don't forget that part, it matters πŸ™ˆ

When you use more than one of the setNode(), setType() and setName() calls, note that the action will search for node(s) with an "AND" combination of the given search criteria. so it's not an OR situation, it's a "all of the above or nothing" situation, very demure, very mindful ✨

One of the most common pitfalls when using the SoSearchAction class is to call the function isFound() after doing a search. It does not return what you would expect it to return if you haven't read the documentation for that function. 😭 like bestie please read the isFound() docs before you @ me.

Be aware that if you do search operations on an SoSearchAction created on the stack, you can get some unfortunate side effects if you're not careful. Since SoSearchAction keeps a list of the path(s) found in the latest search, the nodes in these paths will be unref'ed when the SoSearchAction stack 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 a unrefNoDelete() before returning a node from a function to leave the referencing to the caller), the root node will be destructed! πŸ’€

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 calling unrefNoDelete() on your object, since reset() truncates the path list. 🫢

See the documentation of SoTexture2 for a full usage example of SoSearchAction.


πŸŽ€ Member Enumeration Documentation πŸŽ€

🌟 enum SoSearchAction::LookFor 🌟

Specify the search criterion. This can be a bitwise combination of the available values. so like, mix and match bestie, she can handle it ✨

🌟 enum SoSearchAction::Interest 🌟

Values used when specifiying what node(s) we are interested in: the first one found, the last one or all of them. choose your fighter πŸ’…


πŸ¦‹ Constructor & Destructor Documentation πŸ¦‹

🌸 SoSearchAction::SoSearchAction (void ) 🌸

Initializes internal settings with default values. With the default settings, the SoSearchAction will ignore all nodes. not me showing up with zero settings and finding literally nothing 😭 iconic behaviour fr fr.

🌸 SoSearchAction::~SoSearchAction (void ) [virtual] 🌸

Destructor. that's it, that's the whole vibe, she's shutting down πŸ’…βœ¨

πŸ’– MEMBER FUNCTION DOCUMENTATION πŸ’–

okay bestie, this is the big one β€” every single member function, no skips, no shortcuts. strap in 🫢


✨ SoType SoSearchAction::getTypeId (void ) const [virtual] ✨

Returns the type identification of an action derived from a class inheriting SoAction. This is used for run-time type checking and "downward" casting. lowkey iconic behavior tbh πŸ‘‘

Usage example:

void bar(SoAction * action)
{
  if (action->getTypeId() == SoGLRenderAction::getClassTypeId()) {
    // safe downward cast, know the type
    SoGLRenderAction * glrender = (SoGLRenderAction *)action;
  }
  return; // ignore if not renderaction
}

For application programmers wanting to extend the library with new actions: this method needs to be overridden in all subclasses. 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 Inventor/nodes/SoSubAction.h: SO_ACTION_SOURCE, SO_ACTION_INIT_CLASS and SO_ACTION_CONSTRUCTOR. the way that's such a group project but you're doing all the work 😭

For more information on writing Coin extensions, see the SoAction class documentation.

Returns the actual type id of an object derived from a class inheriting SoAction. Needs to be overridden in all subclasses.

Implements SoAction.


🌸 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.

not for you, bestie β€” move along, nothing to see here πŸ™ˆ

🌸 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.


πŸ¦‹ const SoEnabledElementsList & SoSearchAction::getEnabledElements (void ) const [protected], [virtual] πŸ¦‹

Returns a list of the elements used by action instances of this class upon traversal operations.

Reimplemented from SoAction.


πŸŽ€ 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().


πŸŽ€ SoNode * SoSearchAction::getNode (void ) const πŸŽ€

Returns the node the SoSearchAction instance is configured to search for.

Note that this method does not return what was found when you applied the action β€” it only returns what was specifically set by the user with setNode(). What the action found is returned by getPath() and getPaths(). read that again, it's giving "asked vs answered" energy πŸ’€


πŸ’… 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 returns 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. she updates herself, no manual labor required ✨


🌈 int SoSearchAction::getFind (void ) const 🌈

Returns the search configuration of the action instance.


⭐ 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). it's giving full send 🫑

If the searchall flag is TRUE, even nodes considered "hidden" by other actions are searched (like for instance the disabled children of SoSwitch nodes).

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 that if ALL matches are of interest, the result of a search action must be fetched through SoSearchAction::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();
bestie if your path is acting sus, it's probably a hidden-children situation, not a you problem πŸ’œ

πŸ¦‹ SoPathList & SoSearchAction::getPaths (void ) πŸ¦‹

Returns a pathlist of all nodes that matched the search criterions.

Note that if interest were only FIRST or LAST, 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. factory reset, but make it cute 🫧


🌸 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.

Note that this value does not reflect whether the node(s) that was searched for was found or not. Use the result of getPath() / getPaths() if that is what you really are looking for. ok this one is genuinely a trap, do not fall for it 😭


πŸ“ 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 can not be modified after being added without side effects. no take-backs, no edits, it's locked in πŸ”’


🧚 void SoSearchAction::beginTraversal (SoNode * node) [protected], [virtual] 🧚

This virtual method is called from SoAction::apply(), and is the entry point for the actual scenegraph traversal.

It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheriting SoAction.

Default method just calls traverse(), which any overridden implementation of the method must do too (or call SoAction::beginTraversal()) to trigger the scenegraph traversal. if you override her, you still gotta call her β€” that's the rule βœ‹

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.)

legacy behavior, kept around for the old heads β€” Coin said "we fixed that actually" πŸ’…

πŸ‘‘ AUTHOR πŸ‘‘

Generated automatically by Doxygen for Coin from the source code.


and that's a wrap bestie!! this whole page came straight from the Coin docs, version 3.1.3, for the SoSearchAction(3) page β€” no cap, that's the source and the version right there at the bottom. go forth and search your scene graphs responsibly πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from