Debian Codegraph @

lib/database/src/so/nodes/SoTransformSeparator.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Classes:
46 | SoTransformSeparator
47 |
48 | Author(s) : Paul S. Strauss, Nick Thompson
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54
55 #include <Inventor/actions/SoCallbackAction.h>
56 #include <Inventor/actions/SoGLRenderAction.h>
57 #include <Inventor/actions/SoGetBoundingBoxAction.h>
58 #include <Inventor/actions/SoGetMatrixAction.h>
59 #include <Inventor/actions/SoPickAction.h>
60 #include <Inventor/actions/SoSearchAction.h>
61 #include <Inventor/elements/SoBBoxModelMatrixElement.h>
62 #include <Inventor/misc/SoChildList.h>
63 #include <Inventor/misc/SoState.h>
64 #include <Inventor/nodes/SoTransformSeparator.h>
65
66 SO_NODE_SOURCE(SoTransformSeparator);
67
68 ////////////////////////////////////////////////////////////////////////
69 //
70 // Description:
71 // Constructor
72 //
73 // Use: public
74
75 SoTransformSeparator::SoTransformSeparator()
76 //
77 ////////////////////////////////////////////////////////////////////////
78 {
79 SO_NODE_CONSTRUCTOR(SoTransformSeparator);
80 isBuiltIn = TRUE;
81 }
82
83 ////////////////////////////////////////////////////////////////////////
84 //
85 // Description:
86 // Constructor that takes approximate number of children.
87 //
88 // Use: public
89
90 SoTransformSeparator::SoTransformSeparator(int nChildren) : SoGroup(nChildren)
91 //
92 ////////////////////////////////////////////////////////////////////////
93 {
94 SO_NODE_CONSTRUCTOR(SoTransformSeparator);
95 isBuiltIn = TRUE;
96 }
97
98 ////////////////////////////////////////////////////////////////////////
99 //
100 // Description:
101 // Destructor
102 //
103 // Use: private
104
105 SoTransformSeparator::~SoTransformSeparator()
106 //
107 ////////////////////////////////////////////////////////////////////////
108 {
109 }
110
111 ////////////////////////////////////////////////////////////////////////
112 //
113 // Description:
114 // Typical action traversal. Assumes the model matrix element is
115 // enabled.
116 //
117 // Use: extender
118
119 void
120 SoTransformSeparator::doAction(SoAction *action)
121 //
122 ////////////////////////////////////////////////////////////////////////
123 {
124 SoState *state = action->getState();
125
126 // Remember the current matrix:
127 SbMatrix saveMat = SoModelMatrixElement::pushMatrix(state);
128
129 // Do regular group stuff
130 SoGroup::doAction(action);
131
132 // Set the matrix back to original value...
133 SoModelMatrixElement::popMatrix(state, saveMat);
134 }
135
136 ////////////////////////////////////////////////////////////////////////
137 //
138 // Description:
139 // Traversal for callback action.
140 //
141 // Use: extender
142
143 void
144 SoTransformSeparator::callback(SoCallbackAction *action)
145 //
146 ////////////////////////////////////////////////////////////////////////
147 {
148 SoTransformSeparator::doAction(action);
149 }
150
151 ////////////////////////////////////////////////////////////////////////
152 //
153 // Description:
154 // Traversal for GL rendering
155 //
156 // Use: extender
157
158 void
159 SoTransformSeparator::GLRender(SoGLRenderAction *action)
160 //
161 ////////////////////////////////////////////////////////////////////////
162 {
163 SoTransformSeparator::doAction(action);
164 }
165
166 ////////////////////////////////////////////////////////////////////////
167 //
168 // Description:
169 // Traversal for picking
170 //
171 // Use: extender
172
173 void
174 SoTransformSeparator::pick(SoPickAction *action)
175 //
176 ////////////////////////////////////////////////////////////////////////
177 {
178 SoTransformSeparator::doAction(action);
179 }
180
181 ////////////////////////////////////////////////////////////////////////
182 //
183 // Description:
184 // Traversal for get bounding box
185 //
186 // Use: extender
187
188 void
189 SoTransformSeparator::getBoundingBox(SoGetBoundingBoxAction *action)
190 //
191 ////////////////////////////////////////////////////////////////////////
192 {
193 SoState *state = action->getState();
194
195 // Remember the current matrices:
196 SbMatrix matrix, localmatrix;
197 SoBBoxModelMatrixElement::pushMatrix(state, matrix, localmatrix);
198
199 // Do regular group stuff
200 SoGroup::getBoundingBox(action);
201
202 // Set the matrices back to original value...
203 SoBBoxModelMatrixElement::popMatrix(state, matrix, localmatrix);
204 }
205
206 ////////////////////////////////////////////////////////////////////////
207 //
208 // Description:
209 // Implements getMatrix action.
210 //
211 // Use: extender
212
213 void
214 SoTransformSeparator::getMatrix(SoGetMatrixAction *action)
215 //
216 ////////////////////////////////////////////////////////////////////////
217 {
218 int numIndices;
219 const int *indices;
220
221 // Only need to compute matrix if transformSeparator is a node in middle of
222 // current path chain. We don't need to push or pop the state,
223 // since this shouldn't have any effect on other nodes being
224 // traversed.
225
226 if (action->getPathCode(numIndices, indices) == SoAction::IN_PATH)
227 children->traverse(action, 0, indices[numIndices - 1]);
228 }