Coin Logo http://www.coin3d.org/
http://www.kongsberg.com/kogt/

SoAction.h
1 #ifndef COIN_SOACTION_H
2 #define COIN_SOACTION_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/SbBasic.h>
37 #include <Inventor/SoType.h>
38 #include <Inventor/misc/SoTempPath.h>
39 #include <Inventor/tools/SbPimplPtr.h>
40 
41 // Include instead of using forward declarations to be compatible with
42 // Open Inventor (and besides, all the other action class definitions
43 // needs to know about these lists).
45 #include <Inventor/lists/SoEnabledElementsList.h>
46 
47 // defined in Inventor/SbBasic.h
48 #ifdef COIN_UNDEF_IN_PATH_HACK
49 #include <sys/unistd.h>
50 #undef IN_PATH
51 // Avoid problem with HPUX 10.20 C library API headers, which defines IN_PATH
52 // in <sys/unistd.h>. That define destroys the SoAction::PathCode enum, and
53 // the preprocessor is so broken that we can't store/restore the define for
54 // the duration of this header file.
55 #endif // COIN_UNDEF_IN_PATH_HACK
56 
57 
62 #define SO_ENABLE(action, element) \
63  do { \
64  assert(!element::getClassTypeId().isBad()); \
65  action::enableElement(element::getClassTypeId(), \
66  element::getClassStackIndex()); \
67  } while (0)
68 
69 
71 class SoNode;
72 class SoPath;
73 class SoPathList;
74 class SoState;
75 class SoActionP;
76 
77 class COIN_DLL_API SoAction {
78 public:
79  static void initClass(void);
80  static void initClasses(void);
81 
82  enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 };
83  enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 };
84 
85  virtual ~SoAction(void);
86 
87  static SoType getClassTypeId(void);
88  virtual SoType getTypeId(void) const = 0;
89  virtual SbBool isOfType(SoType type) const;
90 
91  virtual void apply(SoNode * root);
92  virtual void apply(SoPath * path);
93  virtual void apply(const SoPathList & pathlist, SbBool obeysrules = FALSE);
94  void apply(SoAction * beingApplied);
95  virtual void invalidateState(void);
96 
97  static void nullAction(SoAction * action, SoNode * node);
98 
99  AppliedCode getWhatAppliedTo(void) const;
100  SoNode * getNodeAppliedTo(void) const;
101  SoPath * getPathAppliedTo(void) const;
102  const SoPathList * getPathListAppliedTo(void) const;
103  const SoPathList * getOriginalPathListAppliedTo(void) const;
104 
105  SbBool isLastPathListAppliedTo(void) const;
106 
107  PathCode getPathCode(int & numindices, const int * & indices);
108 
109  void traverse(SoNode * const node);
110  SbBool hasTerminated(void) const;
111 
112  const SoPath * getCurPath(void);
113  SoState * getState(void) const;
114 
115  PathCode getCurPathCode(void) const;
116  virtual SoNode * getCurPathTail(void);
117  void usePathCode(int & numindices, const int * & indices);
118 
119  void pushCurPath(const int childindex, SoNode * node = NULL);
120  void popCurPath(const PathCode prevpathcode);
121  void pushCurPath(void);
122 
123  void popPushCurPath(const int childindex, SoNode * node = NULL);
124  void popCurPath(void);
125 
126 public:
127  void switchToPathTraversal(SoPath * path);
128  void switchToNodeTraversal(SoNode * node);
129 
130 protected:
131  SoAction(void);
132 
133  virtual void beginTraversal(SoNode * node);
134  virtual void endTraversal(SoNode * node);
135  void setTerminated(const SbBool flag);
136 
137  virtual const SoEnabledElementsList & getEnabledElements(void) const;
138  virtual SbBool shouldCompactPathList(void) const;
139 
142 
143  /* These two methods are not available in the original OIV API. The
144  reason they have been added is explained in SoSubAction.h for the
145  SO_ACTION_HEADER macro. */
146  static SoEnabledElementsList * getClassEnabledElements(void);
147  static SoActionMethodList * getClassActionMethods(void);
148 
149 private:
150  static SoType classTypeId;
151  /* The enabledElements and methods variables are protected in the
152  original OIV API. This is not such a good idea, see the comments
153  in SoSubAction.h for SO_ACTION_HEADER. */
154 
155  static void atexit_cleanup(void);
156  static SoEnabledElementsList * enabledElements;
157  static SoActionMethodList * methods;
158  SoTempPath currentpath;
159  PathCode currentpathcode;
160 
161 private:
162  SbPimplPtr<SoActionP> pimpl;
163 
164  // NOT IMPLEMENTED:
165  SoAction(const SoAction & rhs);
166  SoAction & operator = (const SoAction & rhs);
167 }; // SoAction
168 
169 // inline methods
170 
171 inline SoAction::PathCode
173 {
174  return this->currentpathcode;
175 }
176 
177 #endif // !COIN_SOACTION_H
PathCode getCurPathCode(void) const
Definition: SoAction.h:172
The SoPathList class is a container for pointers to SoPath objects.As this class inherits SoBaseList...
Definition: SoPathList.h:40
The SoNode class is the base class for nodes used in scene graphs.Coin is a retained mode 3D visualiz...
Definition: SoNode.h:56
The SoState class manages the Coin scenegraph traversal state data.The SoState class is used by actio...
Definition: SoState.h:44
The SoPath class is a container class for traversal path descriptions.SoPath objects contain a list o...
Definition: SoPath.h:52
AppliedCode
Definition: SoAction.h:82
The SoAction class is the base class for all traversal actions.Applying actions is the basic mechanis...
Definition: SoAction.h:77
The SoTempPath class is used to store temporary paths.The path simply turns off auditing in the const...
Definition: SoTempPath.h:38
SoActionMethodList * traversalMethods
Definition: SoAction.h:141
The SoEnabledElementsList class is a container for type info for element types that are enabled in ac...
Definition: SoEnabledElementsList.h:38
PathCode
Definition: SoAction.h:83
SoState * state
Definition: SoAction.h:140
The SoType class is the basis for the run-time type system in Coin.Many of the classes in the Coin li...
Definition: SoType.h:59
The SoActionMethodList class contains function pointers for action methods.An SoActionMethodList cont...
Definition: SoActionMethodList.h:44

Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated for Coin by Doxygen