Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoCallback.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 : 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-2024 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>
56#include <Inventor/nodes/SoNode.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
80typedef void SoCallbackCB(void *userData, SoAction *action);
81
441class SoCallback : public SoNode {
442
443 SO_NODE_HEADER(SoCallback);
444
445 public:
450
456 void setCallback(SoCallbackCB *func, void *localUserData = NULL)
457 { callbackFunc = func; callbackData = localUserData; }
458
459 private:
460
461 // Traversal methods for all the actions:
462 virtual void doAction(SoAction *action);
463 virtual void callback(SoCallbackAction *action);
464 virtual void GLRender(SoGLRenderAction *action);
465 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
466 virtual void getMatrix(SoGetMatrixAction *action);
467 virtual void handleEvent(SoHandleEventAction *action);
468 virtual void pick(SoPickAction *action);
469 virtual void search(SoSearchAction *action);
470 virtual void write(SoWriteAction *action);
471 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
472
473 private:
474
475 static void initClass();
476 static void exitClass();
477
478 // Convenient Constructor
479 SoCallback( SoCallbackCB* func, void* localUserData = nullptr );
480
481
482 //Gets pointer to callback function. By default, the function pointer in the node is nullptr and does nothing.
483 SoCallbackCB* getCallback() const;
484
485 // Copies the contents of the given node into this instance
486 virtual void copyContents(const SoFieldContainer *fromFC,
487 SbBool copyConnections);
488
489 private:
490
491 // destructor
492 virtual ~SoCallback();
493
494 // Function to call
495 SoCallbackCB *callbackFunc;
496
497 // User data to pass it
498 void *callbackData;
499};
500
501#endif /* _SO_CALLBACK_ */
502
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:441
void setCallback(SoCallbackCB *func, void *localUserData=NULL)
Sets pointer to callback function and user data.
Definition SoCallback.h:456
void SoCallbackCB(void *userData, SoAction *action)
Callback functions registered with this node should be of this type.
Definition SoCallback.h:80
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