Searches for a node in a scene graph using a sequence of search criteria. More...
#include <Inventor/actions/SoSearchPathAction.h>
Public Member Functions | |
virtual SoType | getTypeId () const |
SoSearchPathAction () | |
virtual | ~SoSearchPathAction () |
void | reset () |
void | setSearchString (const char *searchString) |
const SbString & | getSearchString () const |
void | setSeparatorChar (const char sepChar) |
char | getSeparatorChar () const |
void | setDerivedIsOK (const SbBool derivedIsOK) |
SbBool | getDerivedIsOK () const |
int | getNumItemsFound () const |
Static Public Member Functions | |
static SoType | getClassTypeId () |
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
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:
SoSearchPathAction spa; spa.setSearchString( "Wheel1" );
is equivalent to:
SoSearchAction sa; sa.setName( "Wheel1" ); // By default, interest is FIRST
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.
SoPath, SoSearchAction, SoSearchStepAction, SoBaseKit
SoSearchPathAction::SoSearchPathAction | ( | ) |
Constructor.
The default action searches for first node of or derived from given type, using regular traversal rules.
virtual SoSearchPathAction::~SoSearchPathAction | ( | ) | [virtual] |
Destructor.
static SoType SoSearchPathAction::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoSearchAction.
SbBool SoSearchPathAction::getDerivedIsOK | ( | ) | const [inline] |
Gets flag to allow search on a type to match derived types.
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.
const SbString& SoSearchPathAction::getSearchString | ( | ) | const [inline] |
Gets the search path string.
char SoSearchPathAction::getSeparatorChar | ( | ) | const [inline] |
Gets separator char for search string.
virtual SoType SoSearchPathAction::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoSearchAction.
void SoSearchPathAction::reset | ( | ) | [virtual] |
Reset options back to default values, clears returned path.
Reimplemented from SoSearchAction.
void SoSearchPathAction::setDerivedIsOK | ( | const SbBool | derivedIsOK | ) | [inline] |
Sets flag to allow search on a type to match derived types.
void SoSearchPathAction::setSearchString | ( | const char * | searchString | ) |
Sets the search path string.
void SoSearchPathAction::setSeparatorChar | ( | const char | sepChar | ) | [inline] |
Sets separator char for search string.
The default is '/'.