Class SoSearchPathAction
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 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.
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.openinventor.inventor.actions.SoSearchAction
SoSearchAction.Interests, SoSearchAction.LookFors
Nested classes/interfaces inherited from class com.openinventor.inventor.actions.SoAction
SoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndices
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
Field Summary
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
enableElement
(Class<? extends Inventor> t, int stkIndex) boolean
Gets flag to allow search on a type to match derived types.int
Get the number of search items that were successfully found.Gets the search path string.byte
Gets separator char for search string.void
setDerivedIsOK
(boolean derivedIsOK) Sets flag to allow search on a type to match derived types.void
setFound()
void
setSearchString
(String searchString) Sets the search path string.void
setSeparatorChar
(byte sepChar) Sets separator char for search string.Methods inherited from class com.openinventor.inventor.actions.SoSearchAction
addPath, getFind, getInterest, getName, getNode, getNodeClass, getPath, getPaths, isFound, isSearchingAll, isSearchingExtendedClass, reset, setFind, setInterest, setName, setNode, setNodeClass, setNodeClass, setSearchingAll
Methods inherited from class com.openinventor.inventor.actions.SoAction
apply, apply, clearApplyResult, forwardTraversal, forwardTraversal, getContinueActionInBranchFlag, getCurPath, getDistribMode, getNodeAppliedTo, getOriginalPathListAppliedTo, getPathAppliedTo, getPathCode, getPathListAppliedTo, getPipeId, getSceneManager, getState, getWhatAppliedTo, hasTerminated, invalidateState, isBeingApplied, isLastPathListAppliedTo, isUsingAlternateRep, nullAction, postDelayedTraversal, preDelayedTraversal, resetContinueActionInBranchFlag, setPipeId, setSceneManager, setUpState, stopActionInBranch, traverse, useAlternateRep
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
Constructor Details
-
SoSearchPathAction
public SoSearchPathAction()Constructor. The default action searches for first node of or derived from given type, using regular traversal rules.
-
-
Method Details
-
setSearchString
Sets the search path string. -
getNumItemsFound
public int getNumItemsFound()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. -
getSearchString
Gets the search path string. -
setFound
public void setFound()- Overrides:
setFound
in classSoSearchAction
-
getDerivedIsOK
public boolean getDerivedIsOK()Gets flag to allow search on a type to match derived types. -
enableElement
-
setSeparatorChar
public void setSeparatorChar(byte sepChar) Sets separator char for search string. The default is '/'. -
getSeparatorChar
public byte getSeparatorChar()Gets separator char for search string. -
setDerivedIsOK
public void setDerivedIsOK(boolean derivedIsOK) Sets flag to allow search on a type to match derived types.
-