Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoNode.h
1 #ifndef COIN_SONODE_H
2 #define COIN_SONODE_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/fields/SoFieldContainer.h>
37 
38 class SoAction;
39 class SoCallbackAction;
40 class SoChildList;
41 class SoGLRenderAction;
43 class SoGetMatrixAction;
46 class SoNodeList;
47 class SoNotList;
48 class SoOutput;
49 class SoPickAction;
50 class SoRayPickAction;
51 class SoSearchAction;
52 class SoWriteAction;
54 class SbDict;
55 
56 class COIN_DLL_API SoNode : public SoFieldContainer {
58 
59 public:
60  // Probably not interesting for the application programmer..?
61 #ifndef DOXYGEN_SKIP_THIS
62  enum Stage { FIRST_INSTANCE, PROTO_INSTANCE, OTHER_INSTANCE };
63 #endif // !DOXYGEN_SKIP_THIS
64 
65  void setOverride(const SbBool state);
66  SbBool isOverride(void) const;
67 
68  enum NodeType {
69  INVENTOR = 0x0000,
70  VRML1 = 0x0001,
71  VRML2 = 0x0002,
72  INVENTOR_1 = 0x0004,
73  INVENTOR_2_0 = 0x0008,
74  INVENTOR_2_1 = 0x0010,
75  INVENTOR_2_5 = 0x0020,
76  INVENTOR_2_6 = 0x0040,
77  COIN_1_0 = 0x0080,
78  COIN_2_0 = 0x0100,
79  EXTENSION = 0x0200,
80  COIN_2_2 = 0x0400,
81  COIN_2_3 = 0x0800,
82  COIN_2_4 = 0x1000,
83  INVENTOR_5_0 = 0x2000,
84  COIN_2_5 = 0x4000,
85  COIN_3_0 = 0x8000,
86  INVENTOR_6_0 = 0x10000,
87  COIN_4_0 = 0x20000
88  };
89 
90  static uint32_t getCompatibilityTypes(const SoType & nodetype);
91  void setNodeType(const NodeType type);
92  NodeType getNodeType(void) const;
93 
94  virtual SoNode * copy(SbBool copyconnections = FALSE) const;
95  virtual SbBool affectsState(void) const;
96 
97  virtual void doAction(SoAction * action);
98  virtual void GLRender(SoGLRenderAction * action);
99  virtual void GLRenderBelowPath(SoGLRenderAction * action);
100  virtual void GLRenderInPath(SoGLRenderAction * action);
101  virtual void GLRenderOffPath(SoGLRenderAction * action);
102  virtual void callback(SoCallbackAction * action);
103  virtual void getBoundingBox(SoGetBoundingBoxAction * action);
104  virtual void getMatrix(SoGetMatrixAction * action);
105  virtual void handleEvent(SoHandleEventAction * action);
106  virtual void pick(SoPickAction * action);
107  virtual void rayPick(SoRayPickAction * action);
108  virtual void search(SoSearchAction * action);
109  virtual void write(SoWriteAction * action);
110  virtual void audioRender(SoAudioRenderAction * action);
111  virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
112 
113  virtual void grabEventsSetup(void);
114  virtual void grabEventsCleanup(void);
115 
116  virtual void startNotify(void);
117  virtual void notify(SoNotList * l);
118 
119  SbUniqueId getNodeId(void) const;
120  virtual SoChildList * getChildren(void) const;
121 
122  virtual void writeInstance(SoOutput * out);
123  virtual SoNode * addToCopyDict(void) const;
124  virtual void copyContents(const SoFieldContainer * from,
125  SbBool copyconnections);
126  virtual SoFieldContainer * copyThroughConnection(void) const;
127 
128 
129  static SoType getClassTypeId(void);
130  static SoNode * getByName(const SbName & name);
131  static int getByName(const SbName & name, SoNodeList & l);
132 
133  static void initClass(void);
134  static void initClasses(void);
135 
136  static SbUniqueId getNextNodeId(void);
137  static int getActionMethodIndex(const SoType type);
138 
139  static void getBoundingBoxS(SoAction * action, SoNode * node);
140  static void GLRenderS(SoAction * action, SoNode * node);
141  static void callbackS(SoAction * action, SoNode * node);
142  static void getMatrixS(SoAction * action, SoNode * node);
143  static void handleEventS(SoAction * action, SoNode * node);
144  static void pickS(SoAction * action, SoNode * node);
145  static void rayPickS(SoAction * action, SoNode * node);
146  static void searchS(SoAction * action, SoNode * node);
147  static void writeS(SoAction * action, SoNode * node);
148  static void audioRenderS(SoAction * action, SoNode * node);
149  static void getPrimitiveCountS(SoAction * action, SoNode * node);
150 
151 protected:
152  SoNode(void);
153  virtual ~SoNode();
154 
155  virtual SbBool readInstance(SoInput * in, unsigned short flags);
156 
157  static const SoFieldData ** getFieldDataPtr(void);
158 
159  // These are necessary to avoid problems with us not exporting the
160  // nextActionMethodIndex member into Win32 DLLs (we'll get
161  // unresolved symbol for extension node classes if the SoSubNode
162  // macros accesses the nextActionMethodIndex directly).
163  static void setNextActionMethodIndex(int index);
164  static int getNextActionMethodIndex(void);
165  static void incNextActionMethodIndex(void);
166 
167  static void setCompatibilityTypes(const SoType & nodetype, const uint32_t bitmask);
168 
169  SbUniqueId uniqueId;
170  static SbUniqueId nextUniqueId;
172 
173 private:
174  static SoType classTypeId;
175  uint32_t stateflags;
176  void clearStateFlags(const unsigned int bits);
177  void setStateFlags(const unsigned int bits);
178  SbBool getState(const unsigned int bits) const;
179  static void cleanupClass(void);
180 };
181 
182 #ifndef COIN_INTERNAL
183 // For SGI / TGS Open Inventor compile-time compatibility.
184 #include <Inventor/SoLists.h>
185 #endif // COIN_INTERNAL
186 
187 #endif // !COIN_SONODE_H
virtual void writeInstance(SoOutput *out)
Definition: SoFieldContainer.cpp:725
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:45
The SoRayPickAction class does ray intersection with scene graphs.
Definition: SoRayPickAction.h:50
The SoOutput class is an abstraction of an output stream.
Definition: SoOutput.h:51
The SoGetMatrixAction class is an action for accumulating the transformation matrix of a subgraph...
Definition: SoGetMatrixAction.h:46
The SoFieldContainer class is a base class for all classes that contain fields.
Definition: SoFieldContainer.h:43
The SoSearchAction class provides methods for searching through scene graphs.
Definition: SoSearchAction.h:44
virtual void copyContents(const SoFieldContainer *from, SbBool copyconnections)
Definition: SoFieldContainer.cpp:796
The SoPickAction class is the base class for picking actions.
Definition: SoPickAction.h:43
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
virtual SoFieldContainer * copyThroughConnection(void) const
Definition: SoFieldContainer.cpp:814
The SbDict class organizes a dictionary of keys and values.
Definition: SbDict.h:63
The SoChildList class is a container for node children.
Definition: SoChildList.h:42
static int nextActionMethodIndex
Definition: SoNode.h:171
The SoAudioRenderAction class renders the aural parts of the scene graph.
Definition: SoAudioRenderAction.h:42
virtual void notify(SoNotList *l)
Definition: SoFieldContainer.cpp:646
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:77
The SoHandleEventAction class distributes user events to the scene.
Definition: SoHandleEventAction.h:46
The SoGetPrimitiveCountAction class counts the primitives in a scene.
Definition: SoGetPrimitiveCountAction.h:44
The SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs.
Definition: SoGetBoundingBoxAction.h:45
virtual SbBool readInstance(SoInput *in, unsigned short flags)
Definition: SoFieldContainer.cpp:1041
virtual void startNotify(void)
Definition: SoBase.cpp:783
The SoCallbackAction class invokes callbacks at specific nodes.
Definition: SoCallbackAction.h:80
The SoNodeList class is a container for pointers to SoNode objects.
Definition: SoNodeList.h:40
The SoWriteAction class writes a scene graph to file.
Definition: SoWriteAction.h:42
The SoInput class is an abstraction of file import functionality.
Definition: SoInput.h:61
The SoFieldData class is a container for a prototype set of fields.
Definition: SoFieldData.h:48
SbUniqueId uniqueId
Definition: SoNode.h:169
static SbUniqueId nextUniqueId
Definition: SoNode.h:170
The SoNotList class is a list of SoNotRec notification records.
Definition: SoNotification.h:43
The SoType class is the basis for the run-time type system in Coin.
Definition: SoType.h:59
NodeType
Definition: SoNode.h:68
The SbName class stores strings by reference.
Definition: SbName.h:40
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition: SoGLRenderAction.h:50