public class SoHandleEventAction extends SoAction
SoSceneManager
automatically creates a handle event action and provides a convenience method processEvent() to pass events to its managed scene graph. The Open Inventor viewer classes use this method to pass events to the scene graph in selection mode.
Manipulator, dragger and selection nodes respond to and process events. Most group nodes just pass the event to their children, while most other nodes simply ignore the action entirely. The SoEventCallback
node invokes a callback / delegate method when traversed by a handle event action processing a specific type of event. This is the primary mechanism for handling event input in Open Inventor. Once a node has indicated to the action that it has handled the event, traversal stops.
A node that handles an event can also grab future events. Once it has done so, all events will be sent directly to that node, with no traversal taking place, until the node releases the grab. Draggers use this mechanism to ensure that they see the "finish" (e.g. mouse button up) event for their interaction.
A node can get the event currently being handled by calling getEvent()
. A node can also find out what, if any, geometry is under the cursor by calling the getPickedPoint()
method. The handle event action will automatically apply an SoRayPickAction
to the scene graph and remember the result in case other nodes make the same query during the traversal. If a node needs to apply the pick action itself, it can get the appropriate root node by calling getPickRoot()
.
NOTE: The SoRayPickAction
applied by the handle event action does not compute texture coordinates and normal vector for the picked point. Thus, getPickedPoint()
.getNormal() returns (0,0,0) and getPickedPoint()
.getTextureCoords() returns (0,0,0,0).
Sets: SoViewportRegionElement
See also:
SoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndices
Inventor.ConstructorCommand
ALL, BELOW_PATH, CLUSTER_ONLY, IN_PATH, LOCAL_ONLY, NO_PATH, NODE, OFF_PATH, PATH, PATH_LIST
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoHandleEventAction(SbViewportRegion viewportRegion)
Constructor takes viewport region to use; this is needed to perform a pick operation when requested.
|
Modifier and Type | Method and Description |
---|---|
static void |
enableElement(java.lang.Class<? extends Inventor> t,
int stkIndex) |
void |
enableRadiusForTriangles(boolean flag)
Enable pick radius for triangle-based shapes.
|
SoEvent |
getEvent()
Returns the event being handled.
|
SoNode |
getGrabber()
Returns the node that is currently grabbing events, or NULL if there is none.
|
SoPickedPoint |
getPickedPoint()
Returns the frontmost object hit (as an
SoPickedPoint ) by performing a pick based on the mouse location specified in the event for which the action is being applied. |
java.util.Vector<SoPickedPoint> |
getPickedPointList()
Returns a list of objects intersected by a picking operation, sorted from nearest to farthest.
|
float |
getPickRadius()
Returns the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.
|
SoNode |
getPickRoot()
Returns the root node used for initiating a pick action for those nodes that want to know what is under the cursor.
|
SbViewportRegion |
getViewportRegion()
Returns current viewport region to use for action.
|
boolean |
isHandled()
Returns whether any node has yet handled the event.
|
void |
releaseGrabber()
Releases the grab.
|
void |
setEvent(SoEvent ev)
Sets the event being handled.
|
void |
setGrabber(SoNode node)
Initiates grabbing of future events.
|
void |
setHandled()
Sets whether any node has yet handled the event.
|
void |
setPickedPoint()
Calls setPickedPoint((com.openinventor.inventor.SoPickedPoint)null).
|
void |
setPickedPoint(SoPickedPoint point)
Set the
SoPickedPoint object that will be returned by getPickedPoint. |
void |
setPickRadius(float radiusInPixels)
Sets the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.
|
void |
setPickRoot(SoNode node)
Sets the root node used for initiating a pick action for those nodes that want to know what is under the cursor.
|
void |
setViewportRegion(SbViewportRegion newRegion)
Sets current viewport region to use for action.
|
apply, apply, clearApplyResult, forwardTraversal, getContinueActionInBranchFlag, getCurPath, getNodeAppliedTo, getOriginalPathListAppliedTo, getPathAppliedTo, getPathCode, getPathListAppliedTo, getPipeId, getSceneManager, getState, getWhatAppliedTo, hasTerminated, invalidateState, isBeingApplied, isLastPathListAppliedTo, isUsingAlternateRep, nullAction, postDelayedTraversal, preDelayedTraversal, resetContinueActionInBranchFlag, setPipeId, setSceneManager, setUpState, stopActionInBranch, traverse, useAlternateRep
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
public SoHandleEventAction(SbViewportRegion viewportRegion)
public void setPickedPoint()
public static void enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
public SoNode getGrabber()
public void setPickedPoint(SoPickedPoint point)
SoPickedPoint
object that will be returned by getPickedPoint.
Useful in some special cases where a pick operation has already been done and the picked point is known. Avoids doing the pick operation again. In other words, events will be processed as if the specified point had been picked. Reset the picked point by calling with NULL.public void setViewportRegion(SbViewportRegion newRegion)
public SbViewportRegion getViewportRegion()
public SoNode getPickRoot()
public boolean isHandled()
public void setPickRadius(float radiusInPixels)
getPickedPoint()
is called.
Note: By default the pick radius set here is only used when testing the ray against lines and points. To enable pick radius for triangle based geometry use the enableRadiusForTriangles()
method.
public void releaseGrabber()
public void setPickRoot(SoNode node)
public void setGrabber(SoNode node)
public void setHandled()
public void setEvent(SoEvent ev)
public SoPickedPoint getPickedPoint()
SoPickedPoint
) by performing a pick based on the mouse location specified in the event for which the action is being applied.
The first time this is called for a particular event, an SoRayPickAction
is applied to find this object; subsequent calls for the same event return the same information. The storage for the picked point remains valid as long as the action is not re-applied or deleted.
Note: The applied SoRayPickAction
does not compute texture coordinates and normal vector for the picked point. Thus, getPickedPoint()
.getNormal() returns (0,0,0) and getPickedPoint()
.getTextureCoords() returns (0,0,0,0).
public java.util.Vector<SoPickedPoint> getPickedPointList()
public float getPickRadius()
public SoEvent getEvent()
public void enableRadiusForTriangles(boolean flag)
setPickRadius()
is taken in account when checking for a ray intersection with triangle-based shapes (e.g. SoIndexedFaceSet
). Otherwise, the pick radius for these shapes is 1 pixel regardless of the specified pick radius. Default is false for performance.Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com