Class SoSearchPathAction
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.actions.SoAction
-
- com.openinventor.inventor.actions.SoSearchAction
-
- com.openinventor.inventor.actions.SoSearchPathAction
-
public class SoSearchPathAction extends SoSearchAction
Searches for a node in a scene graph using a sequence of search criteria. This class extendsSoSearchAction
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
orSoSearchAction
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 methodsSoBaseKit.isSearchingChildren()
andSoBaseKit.setSearchingChildren()
, which allow you to query and control this behavior.- See Also:
SoPath
,SoSearchAction
,SoSearchStepAction
,SoBaseKit
-
-
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 Constructor Description SoSearchPathAction()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
boolean
getDerivedIsOK()
Gets flag to allow search on a type to match derived types.int
getNumItemsFound()
Get the number of search items that were successfully found.java.lang.String
getSearchString()
Gets the search path string.byte
getSeparatorChar()
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(java.lang.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
-
-
-
-
Method Detail
-
setSearchString
public void setSearchString(java.lang.String searchString)
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
public java.lang.String 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
public static void enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
-
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.
-
-