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;
42 class SoGetBoundingBoxAction;
43 class SoGetMatrixAction;
44 class SoGetPrimitiveCountAction;
45 class SoHandleEventAction;
46 class SoNodeList;
47 class SoNotList;
48 class SoOutput;
49 class SoPickAction;
50 class SoRayPickAction;
51 class SoSearchAction;
52 class SoWriteAction;
53 class SoAudioRenderAction;
54 class SbDict;
55 
56 class COIN_DLL_API SoNode : public SoFieldContainer {
57   typedef SoFieldContainer inherited;
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;
171   static int nextActionMethodIndex;
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
188