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) 1998-2007 by Systems in Motion. All rights reserved.
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 Systems in Motion about acquiring
18 * a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, 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
31// Include instead of using forward declarations to be compatible with
32// Open Inventor (and besides, all the other action class definitions
33// needs to know about these lists).
34#include <Inventor/lists/SoActionMethodList.h>
35#include <Inventor/lists/SoEnabledElementsList.h>
36
37// defined in Inventor/SbBasic.h
38#ifdef COIN_UNDEF_IN_PATH_HACK
39#include <sys/unistd.h>
40#undef IN_PATH
41// Avoid problem with HPUX 10.20 C library API headers, which defines IN_PATH
42// in <sys/unistd.h>. That define destroys the SoAction::PathCode enum, and
43// the preprocessor is so broken that we can't store/restore the define for
44// the duration of this header file.
45#endif
46
47
52#define SO_ENABLE(action, element) \
53 do { \
54 assert(!element::getClassTypeId().isBad()); \
55 action::enableElement(element::getClassTypeId(), \
56 element::getClassStackIndex()); \
57 } while (0)
58
59
61class SoNode;
62class SoPath;
63class SoPathList;
64class SoState;
65class SoActionP;
66
67class COIN_DLL_API SoAction {
68public:
69 enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 };
70 enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 };
71
72 virtual ~SoAction();
73
74 static void initClass(void);
75 static void initClasses(void);
76
77 static SoType getClassTypeId(void);
78 virtual SoType getTypeId(void) const = 0;
79 virtual SbBool isOfType(SoType type) const;
80
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
117public:
118 void switchToPathTraversal(SoPath * path);
119 void switchToNodeTraversal(SoNode * node);
120
121
122protected:
123 SoAction(void);
124
125 virtual void beginTraversal(SoNode * node);
126 virtual void endTraversal(SoNode * node);
127 void setTerminated(const SbBool flag);
128
129 virtual const SoEnabledElementsList & getEnabledElements(void) const;
130 virtual SbBool shouldCompactPathList(void) const;
131
134
135 /* These two methods are not available in the original OIV API. The
136 reason they have been added is explained in SoSubAction.h for the
137 SO_ACTION_HEADER macro. */
138 static SoEnabledElementsList * getClassEnabledElements(void);
139 static SoActionMethodList * getClassActionMethods(void);
140
141private:
142 static SoType classTypeId;
143 /* The enabledElements and methods variables are protected in the
144 original OIV API. This is not such a good idea, see the comments
145 in SoSubAction.h for SO_ACTION_HEADER. */
146
147 static void atexit_cleanup(void);
148 static SoEnabledElementsList * enabledElements;
149 static SoActionMethodList * methods;
150 SoTempPath currentpath;
151 PathCode currentpathcode;
152
153 SoActionP * pimpl;
154};
155
156// inline methods
157
160{
161 return this->currentpathcode;
162}
163
164inline void
166{
167 this->currentpath.pop();
168 this->currentpathcode = prevpathcode;
169}
170
171#endif // !COIN_SOACTION_H
The SoActionMethodList class contains function pointers for action methods.
Definition: SoActionMethodList.h:35
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:67
SoActionMethodList * traversalMethods
Definition: SoAction.h:133
PathCode
Definition: SoAction.h:70
AppliedCode
Definition: SoAction.h:69
virtual SoType getTypeId(void) const =0
SoState * state
Definition: SoAction.h:132
void popCurPath(void)
Definition: SoAction.cpp:1152
PathCode getCurPathCode(void) const
Definition: SoAction.h:159
The SoEnabledElementsList class is a container for type info for element types that are enabled in ac...
Definition: SoEnabledElementsList.h:29
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:47
The SoPathList class is a container for pointers to SoPath objects.
Definition: SoPathList.h:31
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:43
The SoState class manages the Coin scenegraph traversal state data.
Definition: SoState.h:35
The SoType class is the basis for the run-time type system in Coin.
Definition: SoType.h:50

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jan 18 2023 for Coin by Doxygen. 1.9.5