Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoHandleEventAction.h
Go to the documentation of this file.
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-2020 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
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
131
133
134 public:
139 SoHandleEventAction(const SbViewportRegion &viewportRegion);
140
141 // Destructor
142#ifndef HIDDEN_FROM_DOC
143 virtual ~SoHandleEventAction();
144#endif // HIDDEN_FROM_DOC
145
149 void setViewportRegion(const SbViewportRegion &newRegion);
150
151
155 const SbViewportRegion &getViewportRegion() const { return vpRegion; }
156
158 virtual void clearApplyResult();
159
163 void setEvent(const SoEvent *ev) { event = ev; }
167 const SoEvent * getEvent() const { return event; }
168
172 void setHandled() { setTerminated(TRUE); }
176 SbBool isHandled() const { return hasTerminated(); }
177
182 void setGrabber(SoNode *node);
186 void releaseGrabber() { setGrabber(NULL); }
190 SoNode * getGrabber() const { return eventGrabber; }
191
196 void setPickRoot(SoNode *node);
201 SoNode * getPickRoot() const { return pickRoot; }
202
212 void setPickRadius(float radiusInPixels)
213 { pickAct->setRadius(radiusInPixels); }
214
219 float getPickRadius() const
220 { return pickAct->getRadius(); }
221
232
247
253
254 private:
262 void setPickedPoint( SoPickedPoint *point = NULL );
263
264 private:
265 static void initClass();
266 static void exitClass();
267
268 private:
269 // Initiates action on graph
270 virtual void beginTraversal(SoNode *node);
271
272 private:
273 const SoEvent *event; // Event being handled
274 SoNode *pickRoot; // Root node for initiating picking
275 SoPickedPoint *pickedPoint; // PickedPoint from last pick
276 SbBool pickValid; // Whether last pick is still valid
277 SbBool usedPickAll; // TRUE if last pick used pickAll=TRUE
278 SoRayPickAction *pickAct; // Pick action
279 SoNode *eventGrabber; // Event grabber - gets all events
280 SbViewportRegion vpRegion; // Current viewport region
281 SbBool pickedPtSet; // TRUE if picked pt was set by app
282
283};
284
285#endif /* _SO_HANDLE_EVENT_ACTION_ */
286
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
#define SO_ACTION_HEADER(className)
Definition SoSubAction.h:69
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