Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoSearchPathAction Class Reference

VSG extension Searches for a node in a scene graph using a sequence of search criteria. More...

#include <Inventor/actions/SoSearchPathAction.h>

+ Inheritance diagram for SoSearchPathAction:

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoSearchPathAction ()
 Constructor.
 
virtual ~SoSearchPathAction ()
 Destructor.
 
void reset ()
 Reset options back to default values, clears returned path.
 
void setSearchString (const char *searchString)
 Sets the search path string.
 
const SbStringgetSearchString () const
 Gets the search path string.
 
void setSeparatorChar (const char sepChar)
 Sets separator char for search string.
 
char getSeparatorChar () const
 Gets separator char for search string.
 
void setDerivedIsOK (const SbBool derivedIsOK)
 Sets flag to allow search on a type to match derived types.
 
SbBool getDerivedIsOK () const
 Gets flag to allow search on a type to match derived types.
 
int getNumItemsFound () const
 Get the number of search items that were successfully found.
 
- Public Member Functions inherited from SoSearchAction
 SoSearchAction ()
 Constructor.
 
virtual void clearApplyResult ()
 When applied, an action may reference nodes or create objects (e.g.
 
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 (SbBool &derivedIsOk) const
 Returns the node type to search for.
 
void setType (SoType t, SbBool derivedIsOk=TRUE)
 Sets the node type to search for.
 
const SbNamegetName () const
 Returns the name of the node to search for.
 
void setName (const SbName &n)
 Sets the name of the node to search for.
 
Interest getInterest () const
 Returns which paths to return.
 
void setInterest (Interest i)
 Sets which paths to return.
 
SbBool isSearchingAll () const
 Returns FALSE if searching uses regular traversal, TRUE if it traverses every single node.
 
void setSearchingAll (SbBool flag)
 Sets 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.
 
- Public Member Functions inherited from SoAction
virtual ~SoAction ()
 Destructor.
 
virtual void apply (SoNode *node)
 Initiates an action on the graph defined by a node.
 
virtual void apply (SoPath *path)
 Initiates an action on the graph defined by a path.
 
virtual void apply (const SoPathList &pathList, SbBool obeysRules=FALSE)
 Initiates an action on the graph defined by a 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.
 
void stopActionInBranch ()
 This function stops the action in the current Scene Graph branch.
 
SbBool getContinueActionInBranchFlag () const
 This function indicates if the action must stop in the current branch.
 
void resetContinueActionInBranchFlag ()
 This function resets the continue action flag.
 
void useAlternateRep (const SbBool enable)
 Tell the action to use alternate representations during traversal when available.
 
SbBool isUsingAlternateRep () const
 Returns TRUE if current action is using alternate representations.
 
void setSceneManager (SoSceneManager *mgr)
 Set the scene manager associated with this action (if any ).
 
SoSceneManagergetSceneManager () const
 Return the SoSceneManager associated with this action.
 
virtual void forwardTraversal (SoNode *node)
 Traverse a node that is not part of the current scenegraph.
 
virtual void forwardTraversal (SoPath *path)
 Traverse a path that is not part of the current scenegraph.
 
DistribMode getDistribMode () const
 Returns the distribution mode of this action across a cluster (ScaleViz-Cluster only).
 
AppliedCode getWhatAppliedTo () const
 Returns code indicating what action is being applied to.
 
SoNodegetNodeAppliedTo () const
 Returns the node the action is being applied to.
 
SoPathgetPathAppliedTo () const
 Returns the path the action is being applied to.
 
const SoPathListgetPathListAppliedTo () const
 Returns the path list the action is being applied to.
 
const SoPathListgetOriginalPathListAppliedTo () const
 Returns the original path list the action is being applied to.
 
SbBool isLastPathListAppliedTo () const
 Returns TRUE if the current list is the last one from the original.
 
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.
 
PathCode getPathCodeMI (int &numIndices, const int *&indices, const int *&instanceIndices)
 Extender API: available to programmers who wish to extend the toolkit
 
void traverse (SoNode *node)
 Does traversal of a graph rooted by a node.
 
SbBool hasTerminated () const
 Returns TRUE if the traversal has reached a termination condition.
 
const SoPathgetCurPath ()
 Returns 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
 Gets the state from the action.
 
virtual void setUpState ()
 Creates state if it is NULL or it is no longer valid because new elements have been enabled since it was created.
 
void setPipeId (int id)
 Sets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.
 
int getPipeId () const
 Gets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.
 
bool isBeingApplied ()
 Returns TRUE if this action is currently being applied.
 
virtual bool preDelayedTraversal ()
 Method called by SoMultiPassManager before delayed pass traversals.
 
virtual void postDelayedTraversal ()
 Method called by SoMultiPassManager after delayed pass traversals.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoSearchAction
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- 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 Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Additional Inherited Members

- Public Types inherited from SoSearchAction
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  DistribMode {
  LOCAL_ONLY ,
  CLUSTER_ONLY ,
  ALL
}
 This is used to define the way an action is distributed across a cluster. More...
 
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...
 

Detailed Description

VSG extension Searches for a node in a scene graph using a sequence of search criteria.

This class extends SoSearchAction to search for a sequence of items defined in a string, e.g., "Wheel1/Hub/Bearing". Each item can be a

  • Node name, or


  • Node address (hex value starting with zero, e.g., "0x100fa30"), or
  • Node type (type name in angle brackets, e.g., "<Cone>").

When the action finds a node that satisfies the current search item, it effectively restarts the search from that node, using the next search item. This means that the search for each item (after the first) is confined to the subgraph under the node that satisfied the previous search item. In most cases each item (except possibly the last one) will be a grouping node, but this is not enforced by the action.

Finding nodes by name is a useful technique for modifying a scene graph, but using SoNode::getByName or SoSearchAction requires assigning a unique name to every (interesting) node. Often the same subgraph will be used multiple times and it would be convenient to assign each instance of the subgraph a unique name, but reuse the same names for the nodes inside the subgraph. SoSearchPathAction allows this kind of hierarchical naming.

Given a scene graph with hierarchical names, for example:

  DEF Wheel1 Separator {
      DEF Hub Separator {
          DEF Bolt Separator {
              Cylinder { height 3 }
          }
      }
  }
  DEF Wheel2 Separator {
      DEF Hub Separator {
          DEF Bolt Separator {
              Cylinder { height 13 }
          }
      }
  }

"Wheel1/Hub/Bolt" would find "Bolt" in the first wheel. Intermediate names may be omitted if the search string is still unambiguous. For example "Wheel1/Bolt" would find the same node in this simple case. "Wheel2/Hub/Bolt/<Cylinder>" would return a path including the leaf SoCylinder node in the second wheel.

In the simplest case:

spa.setSearchString( "Wheel1" );
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Searches for a n...
void setSearchString(const char *searchString)
Sets the search path string.

is equivalent to:

sa.setName( "Wheel1" ); // By default, interest is FIRST
Searches for nodes in a scene graph.
void setName(const SbName &n)
Sets the name of the node to search for.

Most of the methods inherited from SoSearchAction are ignored and do not return useful information (set/getNode, set/getName, etc.). Relevant inherited methods are set/isSearchingAll, getPath, and reset.

Note that by default nodekits do not search their children when a search action is applied. The reference page for SoBaseKit discusses the methods SoBaseKit::isSearchingChildren() and SoBaseKit::setSearchingChildren(), which allow you to query and control this behavior.

SEE ALSO

SoPath, SoSearchAction, SoSearchStepAction, SoBaseKit

Definition at line 116 of file SoSearchPathAction.h.

Constructor & Destructor Documentation

◆ SoSearchPathAction()

SoSearchPathAction::SoSearchPathAction ( )

Constructor.

The default action searches for first node of or derived from given type, using regular traversal rules.

◆ ~SoSearchPathAction()

virtual SoSearchPathAction::~SoSearchPathAction ( )
virtual

Destructor.

Member Function Documentation

◆ getClassTypeId()

static SoType SoSearchPathAction::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getDerivedIsOK()

SbBool SoSearchPathAction::getDerivedIsOK ( ) const
inline

Gets flag to allow search on a type to match derived types.

Definition at line 167 of file SoSearchPathAction.h.

◆ getNumItemsFound()

int SoSearchPathAction::getNumItemsFound ( ) const
inline

Get the number of search items that were successfully found.

If the complete search succeeded and a path was returned, then this will be the total number of search items (not in general the same as the number of nodes in the returned path!). If the search failed, this indicates which search item was the problem.

Definition at line 176 of file SoSearchPathAction.h.

◆ getSearchString()

const SbString & SoSearchPathAction::getSearchString ( ) const
inline

Gets the search path string.

Definition at line 145 of file SoSearchPathAction.h.

◆ getSeparatorChar()

char SoSearchPathAction::getSeparatorChar ( ) const
inline

Gets separator char for search string.

Definition at line 156 of file SoSearchPathAction.h.

◆ getTypeId()

virtual SoType SoSearchPathAction::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoSearchAction.

◆ reset()

void SoSearchPathAction::reset ( )
virtual

Reset options back to default values, clears returned path.

Reimplemented from SoSearchAction.

◆ setDerivedIsOK()

void SoSearchPathAction::setDerivedIsOK ( const SbBool  derivedIsOK)
inline

Sets flag to allow search on a type to match derived types.

Definition at line 162 of file SoSearchPathAction.h.

◆ setSearchString()

void SoSearchPathAction::setSearchString ( const char *  searchString)

Sets the search path string.

◆ setSeparatorChar()

void SoSearchPathAction::setSeparatorChar ( const char  sepChar)
inline

Sets separator char for search string.

The default is '/'.

Definition at line 151 of file SoSearchPathAction.h.


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