Debian Codegraph @

lib/database/src/so/nodes/SoShapeHints.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 | SoShapeHints
47 |
48 | Author(s) : Paul S. Strauss
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54 #include <Inventor/actions/SoCallbackAction.h>
55 #include <Inventor/actions/SoGLRenderAction.h>
56 #include <Inventor/actions/SoGetBoundingBoxAction.h>
57 #include <Inventor/actions/SoPickAction.h>
58 #include <Inventor/elements/SoGLShapeHintsElement.h>
59 #include <Inventor/elements/SoCreaseAngleElement.h>
60 #include <Inventor/elements/SoOverrideElement.h>
61 #include <Inventor/nodes/SoShapeHints.h>
62
63 SO_NODE_SOURCE(SoShapeHints);
64
65 ////////////////////////////////////////////////////////////////////////
66 //
67 // Description:
68 // Constructor
69 //
70 // Use: public
71
72 SoShapeHints::SoShapeHints()
73 //
74 ////////////////////////////////////////////////////////////////////////
75 {
76 SO_NODE_CONSTRUCTOR(SoShapeHints);
77
78 SO_NODE_ADD_FIELD(vertexOrdering,
79 (SoShapeHintsElement::getDefaultVertexOrdering()));
80 SO_NODE_ADD_FIELD(shapeType,
81 (SoShapeHintsElement::getDefaultShapeType()));
82 SO_NODE_ADD_FIELD(faceType,
83 (SoShapeHintsElement::getDefaultFaceType()));
84 SO_NODE_ADD_FIELD(creaseAngle,
85 (SoCreaseAngleElement::getDefault()));
86
87 //
88 // Set up static info for enumerated type fields
89 //
90
91 SO_NODE_DEFINE_ENUM_VALUE(VertexOrdering, UNKNOWN_ORDERING);
92 SO_NODE_DEFINE_ENUM_VALUE(VertexOrdering, CLOCKWISE);
93 SO_NODE_DEFINE_ENUM_VALUE(VertexOrdering, COUNTERCLOCKWISE);
94
95 SO_NODE_DEFINE_ENUM_VALUE(ShapeType, UNKNOWN_SHAPE_TYPE);
96 SO_NODE_DEFINE_ENUM_VALUE(ShapeType, SOLID);
97
98 SO_NODE_DEFINE_ENUM_VALUE(FaceType, UNKNOWN_FACE_TYPE);
99 SO_NODE_DEFINE_ENUM_VALUE(FaceType, CONVEX);
100
101 SO_NODE_SET_SF_ENUM_TYPE(vertexOrdering, VertexOrdering);
102 SO_NODE_SET_SF_ENUM_TYPE(shapeType, ShapeType);
103 SO_NODE_SET_SF_ENUM_TYPE(faceType, FaceType);
104
105 isBuiltIn = TRUE;
106 }
107
108 ////////////////////////////////////////////////////////////////////////
109 //
110 // Description:
111 // Destructor
112 //
113 // Use: private
114
115 SoShapeHints::~SoShapeHints()
116 //
117 ////////////////////////////////////////////////////////////////////////
118 {
119 }
120
121 ////////////////////////////////////////////////////////////////////////
122 //
123 // Description:
124 // Updates state for actions
125 //
126 // Use: extender
127
128 void
129 SoShapeHints::doAction(SoAction *action)
130 //
131 ////////////////////////////////////////////////////////////////////////
132 {
133 SoState *state = action->getState();
134
135 if (! creaseAngle.isIgnored()
136 && ! SoOverrideElement::getCreaseAngleOverride(state)) {
137 if (isOverride()) {
138 SoOverrideElement::setCreaseAngleOverride(state, this, TRUE);
139 }
140 SoCreaseAngleElement::set(state, creaseAngle.getValue());
141 }
142 }
143
144 ////////////////////////////////////////////////////////////////////////
145 //
146 // Description:
147 // Updates state for actions that also set shape hints element.
148 //
149 // Use: private
150
151 void
152 SoShapeHints::doAction2(SoAction *action)
153 //
154 ////////////////////////////////////////////////////////////////////////
155 {
156 SoShapeHints::doAction(action);
157 SoState *state = action->getState();
158
159 if (SoOverrideElement::getShapeHintsOverride(state)) {
160 return;
161 }
162
163 if (isOverride()) {
164 SoOverrideElement::setShapeHintsOverride(state, this, TRUE);
165 }
166
167 //
168 // Determine which hints to set. If any are ignored, leave them AS_IS
169 //
170
171 SoShapeHintsElement::VertexOrdering order;
172 SoShapeHintsElement::ShapeType shape;
173 SoShapeHintsElement::FaceType face;
174
175 order = (vertexOrdering.isIgnored() ?
176 SoShapeHintsElement::ORDERING_AS_IS :
177 (SoShapeHintsElement::VertexOrdering)vertexOrdering.getValue());
178
179 shape = (shapeType.isIgnored() ?
180 SoShapeHintsElement::SHAPE_TYPE_AS_IS :
181 (SoShapeHintsElement::ShapeType) shapeType.getValue());
182
183 face = (faceType.isIgnored() ?
184 SoShapeHintsElement::FACE_TYPE_AS_IS :
185 (SoShapeHintsElement::FaceType) faceType.getValue());
186
187 SoShapeHintsElement::set(state, order, shape, face);
188 }
189
190 ////////////////////////////////////////////////////////////////////////
191 //
192 // Description:
193 // Handles callback action
194 //
195 // Use: extender
196
197 void
198 SoShapeHints::callback(SoCallbackAction *action)
199 //
200 ////////////////////////////////////////////////////////////////////////
201 {
202 SoShapeHints::doAction2(action);
203 }
204
205 ////////////////////////////////////////////////////////////////////////
206 //
207 // Description:
208 // Handles GL render action
209 //
210 // Use: extender
211
212 void
213 SoShapeHints::GLRender(SoGLRenderAction *action)
214 //
215 ////////////////////////////////////////////////////////////////////////
216 {
217 SoShapeHints::doAction2(action);
218 }
219
220 ////////////////////////////////////////////////////////////////////////
221 //
222 // Description:
223 // Handles pick action
224 //
225 // Use: extender
226
227 void
228 SoShapeHints::pick(SoPickAction *action)
229 //
230 ////////////////////////////////////////////////////////////////////////
231 {
232 SoShapeHints::doAction2(action);
233 }
234
235 ////////////////////////////////////////////////////////////////////////
236 //
237 // Description:
238 // Handles get bounding box action
239 //
240 // Use: extender
241
242 void
243 SoShapeHints::getBoundingBox(SoGetBoundingBoxAction *action)
244 //
245 ////////////////////////////////////////////////////////////////////////
246 {
247 SoShapeHints::doAction(action);
248 }