Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoEventCallback.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 : David Mott (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-2023 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_EVENT_CALLBACK_
51#define _SO_EVENT_CALLBACK_
52
54#include <Inventor/SoPath.h>
57
58class SoEvent;
59class SoEventCallback;
60
61// callback function prototypes
65typedef void SoEventCallbackCB(void *userData, SoEventCallback *node);
66
68//
69// Class: SoEventCallback
70//
72
286class SoEventCallback : public SoNode {
287
289
290 public:
296
303 void setPath(SoPath *path);
308 const SoPath * getPath() { return pathOfInterest; }
309
321 void addEventCallback(SoType eventType,
323 void *userData = NULL);
324
331 template<typename EventType>
332 void addEventCallback( SoEventCallbackCB* f, void* userData = nullptr )
333 {
334 addEventCallback( EventType::getClassTypeId(), f, userData );
335 }
336
342 void *userData = NULL);
343
350 template<typename EventType>
351 void removeEventCallback( SoEventCallbackCB* f, void* userData = nullptr )
352 {
353 removeEventCallback( EventType::getClassTypeId(), f, userData );
354 }
355
357 //
358 // These all provide information to callback functions. They
359 // return NULL when called from anywhere but a callback function.
360 //
361
366 SoHandleEventAction * getAction() const { return eventAction; }
367
372 const SoEvent * getEvent() const
373 { return (eventAction != NULL ? eventAction->getEvent() : NULL); }
374
391 { return (eventAction != NULL ? eventAction->getPickedPoint() : NULL);}
392
393 //
395
404 { if (eventAction != NULL) eventAction->setHandled(); }
405
411 { return (eventAction != NULL) ? eventAction->isHandled() : FALSE; }
412
419 { if (eventAction != NULL) eventAction->setGrabber(this); }
420
426 { if (eventAction != NULL) eventAction->releaseGrabber(); }
427
428 private:
429 // This will be called during handleEventAction traversal.
430 virtual void handleEvent(SoHandleEventAction *ha);
431
432 private:
433 static void initClass(); // initialize the class
434 static void exitClass();
435
436 private:
437 // Destructor - protected since ref/unref is what should destroy this
438 virtual ~SoEventCallback();
439
440 private:
441 // Only invoke callbacks if this path was picked.
442 // If path is NULL, always invoke callbacks.
443 SoPath *pathOfInterest;
444
445 // List of callback functions, event types, and user data.
446 SbPList * cblist;
447
448 // This is set for each SoHandleEventAction traversal of this node
449 // so that the apps callback routine can invoke methods on the action.
450 SoHandleEventAction *eventAction;
451};
452
453#endif /* _SO_EVENT_CALLBACK_ */
454
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
void SoEventCallbackCB(void *userData, SoEventCallback *node)
#define SO_NODE_HEADER(className)
Definition SoSubNode.h:151
List of generic (void *) pointers.
Definition SbPList.h:77
Node which invokes callbacks for events.
void removeEventCallback(SoEventCallbackCB *f, void *userData=nullptr)
Removes a previously specified event callback .
SoHandleEventAction * getAction() const
Returns the SoHandleEventAction currently traversing this node, or NULL if traversal is not taking pl...
void removeEventCallback(SoType eventType, SoEventCallbackCB *f, void *userData=NULL)
Removes a previously specified event callback .
const SoEvent * getEvent() const
Returns the event currently being handled, or NULL if traversal is not taking place.
void releaseEvents()
Tells the event callback node to release the grab of events.
SoEventCallback()
Constructor creates an event callback node with no event interest and a NULL path.
const SoPath * getPath()
Gets the path which must be picked in order for the callbacks to be invoked.
void addEventCallback(SoEventCallbackCB *f, void *userData=nullptr)
Add an event callback .
void grabEvents()
Tells the event callback node to grab events.
SbBool isHandled() const
Returns whether the event has been handled.
void setHandled()
Tells the node the event was handled.
void addEventCallback(SoType eventType, SoEventCallbackCB *f, void *userData=NULL)
Add an event callback .
const SoPickedPoint * getPickedPoint() const
Returns pick information during SoHandleEventAction traversal, or NULL if traversal is not taking pla...
void setPath(SoPath *path)
Sets the path which must be picked in order for the callbacks to be invoked.
Base class for all events.
Definition SoEvent.h:116
Allows nodes in a graph to receive input events.
void setHandled()
Sets whether any node has yet handled the event.
void setGrabber(SoNode *node)
Initiates grabbing of future events.
SbBool isHandled() const
Returns whether any node has yet handled the event.
const SoEvent * getEvent() const
Returns 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
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Represents point on surface of picked object.
Stores runtime type information.
Definition SoType.h:98
int SbBool
Boolean type.
Definition SbBase.h:87