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

Static Public Member Functions

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

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

Protected Member Functions

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

Additional Inherited Members

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

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: