Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoCallback.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** Modified by : Nick Thompson (MMM yyyy)
26** Modified by : Gavin Bell (MMM yyyy)
27**=======================================================================*/
28/*=======================================================================
29 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
30 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
31 *** ***
32 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
33 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
34 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
35 *** ***
36 *** RESTRICTED RIGHTS LEGEND ***
37 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
38 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
39 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
40 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
41 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
42 *** ***
43 *** COPYRIGHT (C) 1996-2021 BY FEI S.A.S, ***
44 *** BORDEAUX, FRANCE ***
45 *** ALL RIGHTS RESERVED ***
46**=======================================================================*/
47/*=======================================================================
48** Modified by : VSG (MMM YYYY)
49**=======================================================================*/
50
51
52#ifndef _SO_CALLBACK_
53#define _SO_CALLBACK_
54
55#include <Inventor/SbLinear.h>
57
59//
60// Class: SoCallback
61//
62// The SoCallback node is a general mechanism that allows
63// applications to insert callback functions into a scene graph. The
64// callback function registered with the node is called each time
65// that node is traversed to perform any scene graph action. When the
66// callback function is called, it is passed a pointer to the action
67// being traversed and a user-data pointer that is registered with
68// the callback function. A NULL callback function pointer means that
69// no function will be called.
70//
72
76typedef void SoCallbackCB(void *userData, SoAction *action);
77
437class SoCallback : public SoNode {
438
440
441 public:
446
452 void setCallback(SoCallbackCB *func, void *localUserData = NULL)
453 { callbackFunc = func; callbackData = localUserData; }
454
455 private:
456
457 // Traversal methods for all the actions:
458 virtual void doAction(SoAction *action);
459 virtual void callback(SoCallbackAction *action);
460 virtual void GLRender(SoGLRenderAction *action);
461 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
462 virtual void getMatrix(SoGetMatrixAction *action);
463 virtual void handleEvent(SoHandleEventAction *action);
464 virtual void pick(SoPickAction *action);
465 virtual void search(SoSearchAction *action);
466 virtual void write(SoWriteAction *action);
467 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
468
469 private:
470
471 static void initClass();
472 static void exitClass();
473
474 // Convenient Constructor
475 SoCallback( SoCallbackCB* func, void* localUserData = nullptr );
476
477
478 //Gets pointer to callback function. By default, the function pointer in the node is nullptr and does nothing.
479 SoCallbackCB* getCallback() const;
480
481 // Copies the contents of the given node into this instance
482 virtual void copyContents(const SoFieldContainer *fromFC,
483 SbBool copyConnections);
484
485 private:
486
487 // destructor
488 virtual ~SoCallback();
489
490 // Function to call
491 SoCallbackCB *callbackFunc;
492
493 // User data to pass it
494 void *callbackData;
495};
496
497#endif /* _SO_CALLBACK_ */
498
void SoCallbackCB(void *userData, SoAction *action)
Callback functions registered with this node should be of this type.
Definition SoCallback.h:76
#define SO_NODE_HEADER(className)
Definition SoSubNode.h:151
Abstract base class for all actions.
Definition SoAction.h:132
Performs a generic traversal of a scene graph or path.
Provides custom behavior during actions.
Definition SoCallback.h:437
void setCallback(SoCallbackCB *func, void *localUserData=NULL)
Sets pointer to callback function and user data.
Definition SoCallback.h:452
SoCallback()
Creates a callback node with default settings.
Abstract base class for objects that contain fields.
Renders a scene graph using Open Inventor's Render Engine.
Computes bounding box of a scene.
Computes transformation matrix for a subgraph.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Counts number of...
Allows nodes in a graph to receive input events.
Abstract base class for all database nodes.
Definition SoNode.h:145
Abstract base class for picking objects in a scene.
Searches for nodes in a scene graph.
Writes a scene graph to a file.
int SbBool
Boolean type.
Definition SbBase.h:87