Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoSearchAction Class Reference

The SoSearchAction class provides methods for searching through scene graphs. More...

#include <Inventor/actions/SoSearchAction.h>

Inheritance diagram for SoSearchAction::

SoAction List of all members.

Public Types

enum  LookFor { NODE = 1, TYPE = 2, NAME = 4 }
enum  Interest { FIRST, LAST, ALL }

Public Methods

 SoSearchAction (void)
virtual ~SoSearchAction ()
void setNode (SoNode *const node)
SoNodegetNode (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
SoPathgetPath (void) const
SoPathListgetPaths (void)
void reset (void)
void setFound (void)
SbBool isFound (void) const
void addPath (SoPath *const path)

Static Public Methods

void initClass (void)

Protected Methods

virtual void beginTraversal (SoNode *node)

Detailed Description

The SoSearchAction class provides methods for searching through scene graphs.

Nodes can be searched for by pointer, type, and name, or a combination of those criteria. Types can be interpreted as exact types, or the type can match nodes derived from it. Every single node can be searched, or normal traversal rules can be followed when searching (this is especially important to note with regard to switch nodes).

When using 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.

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.


Member Enumeration Documentation

enum SoSearchAction::LookFor
 

Specify the search criterion. This can be a bitwise combination of the available values.

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.


Constructor & Destructor Documentation

SoSearchAction::SoSearchAction void
 

Initializes internal settings with default values. With the default settings, the SoSearchAction will ignore all nodes.

SoSearchAction::~SoSearchAction [virtual]
 

Destructor.


Member Function Documentation

void SoSearchAction::initClass void [static]
 

Initializes the run-time type system for this class, and sets up the enabled elements and action method list.

Reimplemented from SoAction.

void SoSearchAction::setNode SoNode *const node
 

Sets the node pointer to search for.

The action is also automatically configured to set the search "interest" to LookFor NODE, so there is no need to call SoSearchAction::setFind() in anything but special cases. This is also the case for the setType() and setName() calls.

SoNode * SoSearchAction::getNode void const
 

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

void SoSearchAction::setType const SoType type,
const SbBool chkderived = 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.

SoType SoSearchAction::getType SbBool & chkderived 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 name
 

Configures the SoSearchAction instance to search for nodes with the given name.

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.

void SoSearchAction::setInterest const Interest interest
 

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 searchall
 

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

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

SoPathList & SoSearchAction::getPaths void
 

Returns a path list 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.

void SoSearchAction::reset void
 

Resets all the SoSearchAction internals back to their default values.

void SoSearchAction::setFound void
 

For internal use only.

SbBool SoSearchAction::isFound void const
 

For internal use only.

void SoSearchAction::addPath SoPath *const path
 

For internal use only.

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.

Reimplemented from SoAction.


The documentation for this class was generated from the following files:
Generated at Tue Mar 5 03:31:30 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001