Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoHandleEventAction Class Reference

Allows nodes in a graph to receive input events. More...

#include <Inventor/actions/SoHandleEventAction.h>

+ Inheritance diagram for SoHandleEventAction:

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoHandleEventAction (const SbViewportRegion &viewportRegion)
 Constructor takes viewport region to use; this is needed to perform a pick operation when requested.
 
void setViewportRegion (const SbViewportRegion &newRegion)
 Sets current viewport region to use for action.
 
const SbViewportRegiongetViewportRegion () const
 Returns current viewport region to use for action.
 
virtual void clearApplyResult ()
 When applied, an action may reference nodes or create objects (e.g.
 
void setEvent (const SoEvent *ev)
 Sets the event being handled.
 
const SoEventgetEvent () const
 Returns the event being handled.
 
void setHandled ()
 Sets whether any node has yet handled the event.
 
SbBool isHandled () const
 Returns whether any node has yet handled the event.
 
void setGrabber (SoNode *node)
 Initiates grabbing of future events.
 
void releaseGrabber ()
 Releases the grab.
 
SoNodegetGrabber () const
 Returns the node that is currently grabbing events, or NULL if there is none.
 
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.
 
SoNodegetPickRoot () const
 Returns the root node used for initiating a pick action for those nodes that want to know what is under the cursor.
 
void setPickRadius (float radiusInPixels)
 Sets the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.
 
float getPickRadius () const
 Returns the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.
 
void enableRadiusForTriangles (SbBool flag)
 Enable pick radius for triangle-based shapes.
 
const SoPickedPointgetPickedPoint ()
 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.
 
const SoPickedPointListgetPickedPointList ()
 Returns a list of objects intersected by a picking operation, sorted from nearest to farthest.
 
- 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 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 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

Allows nodes in a graph to receive input events.

This class is used to allow nodes in a scene graph to handle input events. It is usually invoked from a component derived from SoWinRenderArea when the component receives a window system event. 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.

A node can get the event currently being handled by calling getEvent().

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.

Picking

A node can conveniently find out what, if any, geometry is under the cursor by calling the getPickedPoint() method. Applications can do this in the callback function assigned to an SoEventCallback node. The first time this method is called during a handle event traversal, the handle event action will automatically apply its internal SoRayPickAction to the scene graph returned by getPickRoot(). The result is stored in case other nodes make the same query during the same traversal. The stored result can be cleared by calling clearApplyResult().

Some, but not all, options can be modified on the internal pick action (see for example setPickRadius()). Note that the internal pick action does not compute texture coordinates or normal vector for the picked point. Thus, getPickedPoint().getNormal() returns (0,0,0) and getPickedPoint().getTextureCoords() returns (0,0,0,0).

If a node needs to apply the pick action itself, for example to set different options, it can get the appropriate root node by calling getPickRoot().

To use GPU picking on compatible shapes, it is mandatory to set the pick radius to 0, see setPickRadius(float radiusInPixels). Compatible shapes are described in the SoRayPickAction section Picking Algorithms.

Sets: SoViewportRegionElement

SEE ALSO

SoEvent, SoEventCallback, SoPickedPoint, SoRayPickAction

Definition at line 130 of file SoHandleEventAction.h.

Constructor & Destructor Documentation

◆ SoHandleEventAction()

SoHandleEventAction::SoHandleEventAction ( const SbViewportRegion viewportRegion)

Constructor takes viewport region to use; this is needed to perform a pick operation when requested.

Member Function Documentation

◆ clearApplyResult()

virtual void SoHandleEventAction::clearApplyResult ( )
virtual

When applied, an action may reference nodes or create objects (e.g.

SoPath) that reference nodes. This is especially true for SoSearchAction and SoRayPickAction. These references will prevent the nodes from being destroyed and so may appear to be a "memory leak".

All references are cleared when the action is destroyed or re-applied. However it may be useful to clear them explicitly to remove references to nodes.

Reimplemented from SoAction.

◆ enableRadiusForTriangles()

void SoHandleEventAction::enableRadiusForTriangles ( SbBool  flag)

Enable pick radius for triangle-based shapes.

If TRUE, the radius of the ray specified by 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.

◆ getClassTypeId()

static SoType SoHandleEventAction::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getEvent()

const SoEvent * SoHandleEventAction::getEvent ( ) const
inline

Returns the event being handled.

Definition at line 167 of file SoHandleEventAction.h.

◆ getGrabber()

SoNode * SoHandleEventAction::getGrabber ( ) const
inline

Returns the node that is currently grabbing events, or NULL if there is none.

Definition at line 190 of file SoHandleEventAction.h.

◆ getPickedPoint()

const SoPickedPoint * SoHandleEventAction::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.

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).

◆ getPickedPointList()

const SoPickedPointList & SoHandleEventAction::getPickedPointList ( )

Returns a list of objects intersected by a picking operation, sorted from nearest to farthest.

◆ getPickRadius()

float SoHandleEventAction::getPickRadius ( ) const
inline

Returns the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.

Definition at line 219 of file SoHandleEventAction.h.

◆ getPickRoot()

SoNode * SoHandleEventAction::getPickRoot ( ) const
inline

Returns the root node used for initiating a pick action for those nodes that want to know what is under the cursor.

Definition at line 201 of file SoHandleEventAction.h.

◆ getTypeId()

virtual SoType SoHandleEventAction::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Implements SoTypedObject.

◆ getViewportRegion()

const SbViewportRegion & SoHandleEventAction::getViewportRegion ( ) const
inline

Returns current viewport region to use for action.

Definition at line 155 of file SoHandleEventAction.h.

◆ isHandled()

SbBool SoHandleEventAction::isHandled ( ) const
inline

Returns whether any node has yet handled the event.

Definition at line 176 of file SoHandleEventAction.h.

◆ releaseGrabber()

void SoHandleEventAction::releaseGrabber ( )
inline

Releases the grab.

Definition at line 186 of file SoHandleEventAction.h.

◆ setEvent()

void SoHandleEventAction::setEvent ( const SoEvent ev)
inline

Sets the event being handled.

Definition at line 163 of file SoHandleEventAction.h.

◆ setGrabber()

void SoHandleEventAction::setGrabber ( SoNode node)

Initiates grabbing of future events.

All events will be sent to the given node until the grab is released.

◆ setHandled()

void SoHandleEventAction::setHandled ( )
inline

Sets whether any node has yet handled the event.

Definition at line 172 of file SoHandleEventAction.h.

◆ setPickRadius()

void SoHandleEventAction::setPickRadius ( float  radiusInPixels)
inline

Sets the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.

Default is 5 pixels. Ray picking is performed when 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.

Definition at line 212 of file SoHandleEventAction.h.

◆ setPickRoot()

void SoHandleEventAction::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.

◆ setViewportRegion()

void SoHandleEventAction::setViewportRegion ( const SbViewportRegion newRegion)

Sets current viewport region to use for action.


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