Open Inventor Reference
|
Searches for nodes in a scene graph. More...
#include <Inventor/actions/SoSearchAction.h>
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. | |
SoNode * | getNode () 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 SbName & | getName () 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. | |
SoPath * | getPath () const |
Returns resulting path, or NULL if no path was found. | |
SoPathList & | getPaths () |
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. | |
SoNode * | getNodeAppliedTo () const |
These returns a pointer to the node, path, or path list the action is being applied to. | |
SoPath * | getPathAppliedTo () const |
const SoPathList * | getPathListAppliedTo () const |
A single path list may be split into several, one for each different head node. | |
const SoPathList * | getOriginalPathListAppliedTo () 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 SoPath * | getCurPath () |
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. | |
SoState * | getState () 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 SoNode * | getCurPathTail () |
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 SoLightweightPath & | getCurrentLightweightPath () 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 SoEnabledElementsList & | getEnabledElements () 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 | |
SoState * | state |
Traversal state. | |
SoActionMethodList * | traversalMethods |
The list of what to do when. | |
Static Protected Attributes inherited from SoAction | |
static SoEnabledElementsList * | enabledElements |
Holds list of enabled elements for the SoAction class. | |
static SoActionMethodList * | methods |
... and the methods | |
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.
Definition at line 86 of file SoSearchAction.h.
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.
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.
SoSearchAction::SoSearchAction | ( | ) |
|
virtual |
void SoSearchAction::addPath | ( | SoPath * | path | ) |
|
protectedvirtual |
Reimplemented from SoAction.
|
inline |
Definition at line 124 of file SoSearchAction.h.
|
inline |
Definition at line 147 of file SoSearchAction.h.
|
inline |
Definition at line 142 of file SoSearchAction.h.
|
inline |
Definition at line 127 of file SoSearchAction.h.
|
inline |
This should be used if the interest is FIRST or LAST.
Definition at line 162 of file SoSearchAction.h.
|
inline |
Definition at line 165 of file SoSearchAction.h.
|
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.
|
static |
|
inline |
Definition at line 170 of file SoSearchAction.h.
References SoAction::hasTerminated().
|
inline |
Definition at line 152 of file SoSearchAction.h.
void SoSearchAction::reset | ( | ) |
This can be used to apply the action again with a different set of search criteria.
|
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.
|
inline |
Definition at line 169 of file SoSearchAction.h.
References SoAction::setTerminated(), and TRUE.
|
inline |
Definition at line 149 of file SoSearchAction.h.
void SoSearchAction::setName | ( | const SbName & | n | ) |
void SoSearchAction::setNode | ( | SoNode * | n | ) |
|
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.
If derivedIsOk
is TRUE, a node that is of a type that is derived from t
will pass this search criterion.
|
static |
Definition at line 181 of file SoSearchAction.h.