Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoEventCallback.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 : 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-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_EVENT_CALLBACK_
51#define _SO_EVENT_CALLBACK_
52
53#include <Inventor/misc/SoCallbackList.h>
54#include <Inventor/SoPath.h>
55#include <Inventor/nodes/SoNode.h>
56#include <Inventor/actions/SoHandleEventAction.h>
57
58class SoEvent;
59class SoEventCallback;
60
61// callback function prototypes
67typedef void SoEventCallbackCB(void *userData, SoEventCallback *node);
68
70//
71// Class: SoEventCallback
72//
74
284class SoEventCallback : public SoNode {
285
286 SO_NODE_HEADER(SoEventCallback);
287
288 public:
294
301 void setPath(SoPath *path);
306 const SoPath * getPath() { return pathOfInterest; }
307
319 void addEventCallback(SoType eventType,
321 void *userData = NULL);
322
329 template<typename EventType>
330 void addEventCallback( SoEventCallbackCB* f, void* userData = nullptr )
331 {
332 addEventCallback( EventType::getClassTypeId(), f, userData );
333 }
334
340 void *userData = NULL);
341
348 template<typename EventType>
349 void removeEventCallback( SoEventCallbackCB* f, void* userData = nullptr )
350 {
351 removeEventCallback( EventType::getClassTypeId(), f, userData );
352 }
353
355 //
356 // These all provide information to callback functions. They
357 // return NULL when called from anywhere but a callback function.
358 //
359
364 SoHandleEventAction * getAction() const { return eventAction; }
365
370 const SoEvent * getEvent() const
371 { return (eventAction != NULL ? eventAction->getEvent() : NULL); }
372
389 { return (eventAction != NULL ? eventAction->getPickedPoint() : NULL);}
390
391 //
393
402 { if (eventAction != NULL) eventAction->setHandled(); }
403
409 { return (eventAction != NULL) ? eventAction->isHandled() : FALSE; }
410
417 { if (eventAction != NULL) eventAction->setGrabber(this); }
418
424 { if (eventAction != NULL) eventAction->releaseGrabber(); }
425
426 private:
427 // This will be called during handleEventAction traversal.
428 virtual void handleEvent(SoHandleEventAction *ha);
429
430 private:
431 static void initClass(); // initialize the class
432 static void exitClass();
433
434 private:
435 // Destructor - protected since ref/unref is what should destroy this
436 virtual ~SoEventCallback();
437
438 private:
439 // Only invoke callbacks if this path was picked.
440 // If path is NULL, always invoke callbacks.
441 SoPath *pathOfInterest;
442
443 // List of callback functions, event types, and user data.
444 SbPList * cblist;
445
446 // This is set for each SoHandleEventAction traversal of this node
447 // so that the apps callback routine can invoke methods on the action.
448 SoHandleEventAction *eventAction;
449};
450
451#endif /* _SO_EVENT_CALLBACK_ */
452
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 SoEventCallbackCB(void *userData, SoEventCallback *node)
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