Coin Logo http://www.sim.no/
http://www.coin3d.org/

SoAction.h
1 #ifndef COIN_SOACTION_H
2 #define COIN_SOACTION_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) by Kongsberg Oil & Gas Technologies.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Kongsberg Oil & Gas Technologies
18  * about acquiring a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/SbBasic.h>
28 #include <Inventor/SoType.h>
29 #include <Inventor/misc/SoTempPath.h>
30 #include <Inventor/tools/SbPimplPtr.h>
31 
32 // Include instead of using forward declarations to be compatible with
33 // Open Inventor (and besides, all the other action class definitions
34 // needs to know about these lists).
35 #include <Inventor/lists/SoActionMethodList.h>
36 #include <Inventor/lists/SoEnabledElementsList.h>
37 
38 // defined in Inventor/SbBasic.h
39 #ifdef COIN_UNDEF_IN_PATH_HACK
40 #include <sys/unistd.h>
41 #undef IN_PATH
42 // Avoid problem with HPUX 10.20 C library API headers, which defines IN_PATH
43 // in <sys/unistd.h>. That define destroys the SoAction::PathCode enum, and
44 // the preprocessor is so broken that we can't store/restore the define for
45 // the duration of this header file.
46 #endif // COIN_UNDEF_IN_PATH_HACK
47 
48 
53 #define SO_ENABLE(action, element) \
54  do { \
55  assert(!element::getClassTypeId().isBad()); \
56  action::enableElement(element::getClassTypeId(), \
57  element::getClassStackIndex()); \
58  } while (0)
59 
60 
62 class SoNode;
63 class SoPath;
64 class SoPathList;
65 class SoState;
66 class SoActionP;
67 
68 class COIN_DLL_API SoAction {
69 public:
70  static void initClass(void);
71  static void initClasses(void);
72 
73  enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 };
74  enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 };
75 
76  virtual ~SoAction(void);
77 
78  static SoType getClassTypeId(void);
79  virtual SoType getTypeId(void) const = 0;
80  virtual SbBool isOfType(SoType type) const;
81 
82  virtual void apply(SoNode * root);
83  virtual void apply(SoPath * path);
84  virtual void apply(const SoPathList & pathlist, SbBool obeysrules = FALSE);
85  void apply(SoAction * beingApplied);
86  virtual void invalidateState(void);
87 
88  static void nullAction(SoAction * action, SoNode * node);
89 
90  AppliedCode getWhatAppliedTo(void) const;
91  SoNode * getNodeAppliedTo(void) const;
92  SoPath * getPathAppliedTo(void) const;
93  const SoPathList * getPathListAppliedTo(void) const;
94  const SoPathList * getOriginalPathListAppliedTo(void) const;
95 
96  SbBool isLastPathListAppliedTo(void) const;
97 
98  PathCode getPathCode(int & numindices, const int * & indices);
99 
100  void traverse(SoNode * const node);
101  SbBool hasTerminated(void) const;
102 
103  const SoPath * getCurPath(void);
104  SoState * getState(void) const;
105 
106  PathCode getCurPathCode(void) const;
107  virtual SoNode * getCurPathTail(void);
108  void usePathCode(int & numindices, const int * & indices);
109 
110  void pushCurPath(const int childindex, SoNode * node = NULL);
111  void popCurPath(const PathCode prevpathcode);
112  void pushCurPath(void);
113 
114  void popPushCurPath(const int childindex, SoNode * node = NULL);
115  void popCurPath(void);
116 
117 public:
118  void switchToPathTraversal(SoPath * path);
119  void switchToNodeTraversal(SoNode * node);
120 
121 protected:
122  SoAction(void);
123 
124  virtual void beginTraversal(SoNode * node);
125  virtual void endTraversal(SoNode * node);
126  void setTerminated(const SbBool flag);
127 
128  virtual const SoEnabledElementsList & getEnabledElements(void) const;
129  virtual SbBool shouldCompactPathList(void) const;
130 
133 
134  /* These two methods are not available in the original OIV API. The
135  reason they have been added is explained in SoSubAction.h for the
136  SO_ACTION_HEADER macro. */
137  static SoEnabledElementsList * getClassEnabledElements(void);
138  static SoActionMethodList * getClassActionMethods(void);
139 
140 private:
141  static SoType classTypeId;
142  /* The enabledElements and methods variables are protected in the
143  original OIV API. This is not such a good idea, see the comments
144  in SoSubAction.h for SO_ACTION_HEADER. */
145 
146  static void atexit_cleanup(void);
147  static SoEnabledElementsList * enabledElements;
148  static SoActionMethodList * methods;
149  SoTempPath currentpath;
150  PathCode currentpathcode;
151 
152 private:
153  SbPimplPtr<SoActionP> pimpl;
154 
155  // NOT IMPLEMENTED:
156  SoAction(const SoAction & rhs);
157  SoAction & operator = (const SoAction & rhs);
158 }; // SoAction
159 
160 // inline methods
161 
162 inline SoAction::PathCode
164 {
165  return this->currentpathcode;
166 }
167 
168 #endif // !COIN_SOACTION_H
PathCode getCurPathCode(void) const
Definition: SoAction.h:163
The SoPathList class is a container for pointers to SoPath objects.As this class inherits SoBaseList...
Definition: SoPathList.h:31
The SoNode class is the base class for nodes used in scene graphs.Coin is a retained mode 3D visualiz...
Definition: SoNode.h:47
The SoState class manages the Coin scenegraph traversal state data.The SoState class is used by actio...
Definition: SoState.h:35
The SoPath class is a container class for traversal path descriptions.SoPath objects contain a list o...
Definition: SoPath.h:43
AppliedCode
Definition: SoAction.h:73
The SoAction class is the base class for all traversal actions.Applying actions is the basic mechanis...
Definition: SoAction.h:68
The SoTempPath class is used to store temporary paths.The path simply turns off auditing in the const...
Definition: SoTempPath.h:29
SoActionMethodList * traversalMethods
Definition: SoAction.h:132
The SoEnabledElementsList class is a container for type info for element types that are enabled in ac...
Definition: SoEnabledElementsList.h:29
PathCode
Definition: SoAction.h:74
SoState * state
Definition: SoAction.h:131
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:50
The SoActionMethodList class contains function pointers for action methods.An SoActionMethodList cont...
Definition: SoActionMethodList.h:35

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

Generated on Fri Sep 9 2016 for Coin by Doxygen 1.8.5.