Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoHandleEventAction.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_HANDLE_EVENT_ACTION_
51#define _SO_HANDLE_EVENT_ACTION_
52
53#include <Inventor/SbViewportRegion.h>
54#include <Inventor/actions/SoSubAction.h>
55#include <Inventor/actions/SoRayPickAction.h>
56
57class SoEvent;
58class SoPickedPoint;
59
61//
62// Class: SoHandleEventAction
63//
64// Event handling action. This traverses a graph looking for a node
65// or nodes interested in a particular event.
66//
68
127
128 SO_ACTION_HEADER(SoHandleEventAction);
129
130 public:
135 SoHandleEventAction(const SbViewportRegion &viewportRegion);
136
137 // Destructor
138#ifndef HIDDEN_FROM_DOC
139 virtual ~SoHandleEventAction();
140#endif // HIDDEN_FROM_DOC
141
145 void setViewportRegion(const SbViewportRegion &newRegion);
146
147
151 const SbViewportRegion &getViewportRegion() const { return vpRegion; }
152
154 virtual void clearApplyResult();
155
159 void setEvent(const SoEvent *ev) { event = ev; }
163 const SoEvent * getEvent() const { return event; }
164
168 void setHandled() { setTerminated(TRUE); }
172 SbBool isHandled() const { return hasTerminated(); }
173
178 void setGrabber(SoNode *node);
182 void releaseGrabber() { setGrabber(NULL); }
186 SoNode * getGrabber() const { return eventGrabber; }
187
192 void setPickRoot(SoNode *node);
197 SoNode * getPickRoot() const { return pickRoot; }
198
208 void setPickRadius(float radiusInPixels)
209 { pickAct->setRadius(radiusInPixels); }
210
215 float getPickRadius() const
216 { return pickAct->getRadius(); }
217
228
243
249
250 private:
258 void setPickedPoint( SoPickedPoint *point = NULL );
259
260 private:
261 static void initClass();
262 static void exitClass();
263
264 private:
265 // Initiates action on graph
266 virtual void beginTraversal(SoNode *node);
267
268 private:
269 const SoEvent *event; // Event being handled
270 SoNode *pickRoot; // Root node for initiating picking
271 SoPickedPoint *pickedPoint; // PickedPoint from last pick
272 SbBool pickValid; // Whether last pick is still valid
273 SbBool usedPickAll; // TRUE if last pick used pickAll=TRUE
274 SoRayPickAction *pickAct; // Pick action
275 SoNode *eventGrabber; // Event grabber - gets all events
276 SbViewportRegion vpRegion; // Current viewport region
277 SbBool pickedPtSet; // TRUE if picked pt was set by app
278
279};
280
281#endif /* _SO_HANDLE_EVENT_ACTION_ */
282
Class for representing a viewport.
Abstract base class for all actions.
Definition SoAction.h:132
SbBool hasTerminated() const
Returns TRUE if the traversal has reached a termination condition.
Definition SoAction.h:430
Base class for all events.
Definition SoEvent.h:116
Allows nodes in a graph to receive input events.
const SbViewportRegion & getViewportRegion() const
Returns current viewport region to use for action.
float getPickRadius() const
Returns the radius (in pixels) around the viewport-space point through which the ray passes when doin...
void setHandled()
Sets whether any node has yet handled the event.
void setGrabber(SoNode *node)
Initiates grabbing of future events.
SoNode * getPickRoot() const
Returns the root node used for initiating a pick action for those nodes that want to know what is und...
SoNode * getGrabber() const
Returns the node that is currently grabbing events, or NULL if there is none.
void enableRadiusForTriangles(SbBool flag)
Enable pick radius for triangle-based shapes.
const SoPickedPointList & getPickedPointList()
Returns a list of objects intersected by a picking operation, sorted from nearest to farthest.
void setPickRadius(float radiusInPixels)
Sets the radius (in pixels) around the viewport-space point through which the ray passes when doing r...
SbBool isHandled() const
Returns whether any node has yet handled the event.
const SoEvent * getEvent() const
Returns the event being handled.
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.
virtual void clearApplyResult()
When applied, an action may reference nodes or create objects (e.g.
void setPickRoot(SoNode *node)
Sets the root node used for initiating a pick action for those nodes that want to know what is under ...
void setEvent(const SoEvent *ev)
Sets the event being handled.
const SoPickedPoint * getPickedPoint()
Returns the frontmost object hit (as an SoPickedPoint) by performing a pick based on the mouse locati...
void releaseGrabber()
Releases the grab.
Abstract base class for all database nodes.
Definition SoNode.h:145
Represents point on surface of picked object.
Maintains a list of pointers to SoPickedPoint instances.
Intersects objects with a ray cast into scene.
void setRadius(float radius)
Sets the radius around the point.
float getRadius() const
Gets the radius (in pixels) around the point.
int SbBool
Boolean type.
Definition SbBase.h:87