Open Inventor Reference
SoSearchAction Class Reference

Searches for nodes in a scene graph. More...

#include <Inventor/actions/SoSearchAction.h>

Inheritance diagram for SoSearchAction:
SoAction

Public Types

enum  LookFor { NODE = 0x01 , TYPE = 0x02 , NAME = 0x04 }
 Enum that defines the search criterion: More...
 
enum  Interest { FIRST , LAST , ALL }
 Enum that defines which paths to return: More...
 
- Public Types inherited from SoAction
enum  AppliedCode { NODE , PATH , PATH_LIST }
 This enum is used to determine what the action is being applied to. More...
 
enum  PathCode { NO_PATH , IN_PATH , BELOW_PATH , OFF_PATH }
 This enum may be used during traversal of nodes to indicate where the node is with respect to the path being traversed. More...
 

Public Member Functions

 SoSearchAction ()
 Constructor.
 
virtual ~SoSearchAction ()
 Destructor.
 
void reset ()
 Resets options back to default values; clears list of returned paths.
 
void setFind (int what)
 Sets what to look for; what is a bitmask of LookFor enum values.
 
int getFind ()
 Returns what to look for.
 
SoNodegetNode () const
 Returns the node to search for.
 
void setNode (SoNode *n)
 Sets the node to search for.
 
SoType getType (bool &derivedIsOk) const
 Gets the node type to search for.
 
void setType (SoType t, bool derivedIsOk=TRUE)
 Sets the node type to search for.
 
const SbNamegetName () const
 Sets/returns the name of the node to search for.
 
void setName (const SbName &n)
 Sets/returns the name of the node to search for.
 
Interest getInterest () const
 Sets/returns which paths to return. Default is FIRST.
 
void setInterest (Interest i)
 Sets/returns which paths to return. Default is FIRST.
 
bool isSearchingAll () const
 
void setSearchingAll (bool flag)
 Sets/returns whether searching uses regular traversal or whether it traverses every single node.
 
SoPathgetPath () const
 Returns resulting path, or NULL if no path was found.
 
SoPathListgetPaths ()
 Returns resulting path list. This should be used if the interest is ALL.
 
void setFound ()
 Sets/returns whether action has found all desired nodes.
 
bool isFound () const
 
void addPath (SoPath *path)
 Sets found path or adds to list of found paths (depending on interest)
 
- Public Member Functions inherited from SoAction
virtual ~SoAction ()
 Destructor.
 
virtual SoType getTypeId () const =0
 Returns the type identifier for a specific instance.
 
bool isOfType (SoType type) const
 Returns TRUE if this instance is of the type specified in type or is derived from that type.
 
virtual void apply (SoNode *node)
 
virtual void apply (SoPath *path)
 
virtual void apply (const SoPathList &pathList, bool obeysRules=FALSE)
 Initiates an action on the graph defined either by a node, path, or list of paths.
 
virtual void invalidateState ()
 Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied.
 
AppliedCode getWhatAppliedTo () const
 Returns code indicating what action is being applied to.
 
SoNodegetNodeAppliedTo () const
 These returns a pointer to the node, path, or path list the action is being applied to.
 
SoPathgetPathAppliedTo () const
 
const SoPathListgetPathListAppliedTo () const
 A single path list may be split into several, one for each different head node.
 
const SoPathListgetOriginalPathListAppliedTo () const
 
bool isLastPathListAppliedTo () const
 
PathCode getPathCode (int &numIndices, const int *&indices)
 Returns path code based on where current node (the node at the end of the current path) lies with respect to the path(s) the action is being applied to.
 
void traverse (SoNode *node)
 Does traversal of a graph rooted by a node.
 
bool hasTerminated () const
 Returns TRUE if the traversal has reached a termination condition.
 
const SoPathgetCurPath ()
 Returns a pointer to the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed.
 
SoStategetState () const
 Get the state from the action.
 
PathCode getCurPathCode () const
 These methods maintain the current path accumulated so far during traversal.
 
void pushCurPath (int childIndex)
 
void popCurPath (PathCode prevPathCode)
 
virtual SoNodegetCurPathTail ()
 This is virtual, so that SoCallbackAction can use current node.
 
void usePathCode (int &numIndices, const int *&indices)
 called by inline getPathCode:
 
void pushCurPath ()
 Optimized versions of push/pop when we know path codes won't change:
 
void popPushCurPath (int childIndex)
 
void popCurPath ()
 
const SoLightweightPathgetCurrentLightweightPath () const
 Returns the current "light" path.
 
void setCurrentLightweightPath (const SoLightweightPath &path)
 Sets the current "light" path.
 

Static Public Member Functions

static void initClass ()
 
- Static Public Member Functions inherited from SoAction
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static void nullAction (SoAction *, SoNode *)
 Null action method that can be stored in lookup table when desired.
 
static void initClass ()
 
static void initClasses ()
 Initialize ALL Inventor action classes.
 

Static Public Attributes

static bool duringSearchAll
 This flag is used by the SoSwitch node, which must return a different result from its 'affectsState' method when called during a SearchAction that is searching all children.
 

Protected Member Functions

virtual void beginTraversal (SoNode *node)
 Initiates action on graph.
 
- Protected Member Functions inherited from SoAction
 SoAction ()
 Constructor.
 
virtual const SoEnabledElementsListgetEnabledElements () const
 Returns the list of enabled elements for a given action subclass.
 
virtual void beginTraversal (SoNode *node)
 Begins traversal of an action at the given node.
 
void setTerminated (bool flag)
 Allows subclass instance to indicate that traversal has reached a termination condition.
 
virtual bool shouldCompactPathLists () const
 This method is used when applying an action to an SoPathList.
 

Additional Inherited Members

- Protected Attributes inherited from SoAction
SoStatestate
 Traversal state.
 
SoActionMethodListtraversalMethods
 The list of what to do when.
 
- Static Protected Attributes inherited from SoAction
static SoEnabledElementsListenabledElements
 Holds list of enabled elements for the SoAction class.
 
static SoActionMethodListmethods
 ... and the methods
 

Detailed Description

This class is used to search scene graphs for specific nodes, nodes of a specific type, nodes with a specific name, or any combination of these. It can search for just the first or last node satisfying the criteria or for all such nodes. The actions return paths to each node found.

Note that 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 allow you to query and control this behavior.

See Also
SoPath, SoBaseKit

Definition at line 86 of file SoSearchAction.h.

Member Enumeration Documentation

◆ Interest

Enumerator
FIRST 

Return only the first path found.

LAST 

Return only the last path found.

ALL 

Return all paths found.

Definition at line 100 of file SoSearchAction.h.

◆ LookFor

Enumerator
NODE 

Looking for a particular node.

TYPE 

Looking for a particualr type of node.

NAME 

Looking for a node with a particular name.

Definition at line 93 of file SoSearchAction.h.

Constructor & Destructor Documentation

◆ SoSearchAction()

SoSearchAction::SoSearchAction ( )

◆ ~SoSearchAction()

virtual SoSearchAction::~SoSearchAction ( )
virtual

Member Function Documentation

◆ addPath()

void SoSearchAction::addPath ( SoPath path)

◆ beginTraversal()

virtual void SoSearchAction::beginTraversal ( SoNode node)
protectedvirtual

Reimplemented from SoAction.

◆ getFind()

int SoSearchAction::getFind ( )
inline
See also
setFind

Definition at line 124 of file SoSearchAction.h.

◆ getInterest()

Interest SoSearchAction::getInterest ( ) const
inline

Definition at line 147 of file SoSearchAction.h.

◆ getName()

const SbName & SoSearchAction::getName ( ) const
inline

Definition at line 142 of file SoSearchAction.h.

◆ getNode()

SoNode * SoSearchAction::getNode ( ) const
inline

Definition at line 127 of file SoSearchAction.h.

◆ getPath()

SoPath * SoSearchAction::getPath ( ) const
inline

This should be used if the interest is FIRST or LAST.

Definition at line 162 of file SoSearchAction.h.

◆ getPaths()

SoPathList & SoSearchAction::getPaths ( )
inline

Definition at line 165 of file SoSearchAction.h.

◆ getType()

SoType SoSearchAction::getType ( bool &  derivedIsOk) const
inline

If derivedIsOk is TRUE, a node that is of a type that is derived from t will pass this search criterion.

Definition at line 134 of file SoSearchAction.h.

◆ initClass()

static void SoSearchAction::initClass ( )
static

◆ isFound()

bool SoSearchAction::isFound ( ) const
inline

Definition at line 170 of file SoSearchAction.h.

References SoAction::hasTerminated().

◆ isSearchingAll()

bool SoSearchAction::isSearchingAll ( ) const
inline
See also
setSearchingAll

Definition at line 152 of file SoSearchAction.h.

◆ reset()

void SoSearchAction::reset ( )

This can be used to apply the action again with a different set of search criteria.

◆ setFind()

void SoSearchAction::setFind ( int  what)
inline

Default is no flags at all. Note that setting a node, type, and/or name to search for activates the relevant flag, so you may never need to call this method directly.

Definition at line 121 of file SoSearchAction.h.

◆ setFound()

void SoSearchAction::setFound ( )
inline

Definition at line 169 of file SoSearchAction.h.

References SoAction::setTerminated(), and TRUE.

◆ setInterest()

void SoSearchAction::setInterest ( Interest  i)
inline

Definition at line 149 of file SoSearchAction.h.

◆ setName()

void SoSearchAction::setName ( const SbName n)

◆ setNode()

void SoSearchAction::setNode ( SoNode n)

◆ setSearchingAll()

void SoSearchAction::setSearchingAll ( bool  flag)
inline

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.

Definition at line 158 of file SoSearchAction.h.

◆ setType()

void SoSearchAction::setType ( SoType  t,
bool  derivedIsOk = TRUE 
)

If derivedIsOk is TRUE, a node that is of a type that is derived from t will pass this search criterion.

Member Data Documentation

◆ duringSearchAll

bool SoSearchAction::duringSearchAll
static

Definition at line 181 of file SoSearchAction.h.


The documentation for this class was generated from the following file: