Open Inventor Release 2024.1.2
 
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
288class SoEventCallback : public SoNode {
289
290 SO_NODE_HEADER(SoEventCallback);
291
292 public:
298
305 void setPath(SoPath *path);
310 const SoPath * getPath() { return pathOfInterest; }
311
323 void addEventCallback(SoType eventType,
325 void *userData = NULL);
326
333 template<typename EventType>
334 void addEventCallback( SoEventCallbackCB* f, void* userData = nullptr )
335 {
336 addEventCallback( EventType::getClassTypeId(), f, userData );
337 }
338
344 void *userData = NULL);
345
352 template<typename EventType>
353 void removeEventCallback( SoEventCallbackCB* f, void* userData = nullptr )
354 {
355 removeEventCallback( EventType::getClassTypeId(), f, userData );
356 }
357
359 //
360 // These all provide information to callback functions. They
361 // return NULL when called from anywhere but a callback function.
362 //
363
368 SoHandleEventAction * getAction() const { return eventAction; }
369
374 const SoEvent * getEvent() const
375 { return (eventAction != NULL ? eventAction->getEvent() : NULL); }
376
393 { return (eventAction != NULL ? eventAction->getPickedPoint() : NULL);}
394
395 //
397
406 { if (eventAction != NULL) eventAction->setHandled(); }
407
413 { return (eventAction != NULL) ? eventAction->isHandled() : FALSE; }
414
421 { if (eventAction != NULL) eventAction->setGrabber(this); }
422
428 { if (eventAction != NULL) eventAction->releaseGrabber(); }
429
430 private:
431 // This will be called during handleEventAction traversal.
432 virtual void handleEvent(SoHandleEventAction *ha);
433
434 private:
435 static void initClass(); // initialize the class
436 static void exitClass();
437
438 private:
439 // Destructor - protected since ref/unref is what should destroy this
440 virtual ~SoEventCallback();
441
442 private:
443 // Only invoke callbacks if this path was picked.
444 // If path is NULL, always invoke callbacks.
445 SoPath *pathOfInterest;
446
447 // List of callback functions, event types, and user data.
448 SbPList * cblist;
449
450 // This is set for each SoHandleEventAction traversal of this node
451 // so that the apps callback routine can invoke methods on the action.
452 SoHandleEventAction *eventAction;
453};
454
455#endif /* _SO_EVENT_CALLBACK_ */
456
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