Debian Codegraph @

lib/database/src/so/nodes/SoResetTransform.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 | SoResetTransform
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/SoGetMatrixAction.h>
58 #include <Inventor/actions/SoPickAction.h>
59 #include <Inventor/elements/SoGLModelMatrixElement.h>
60 #include <Inventor/nodes/SoResetTransform.h>
61
62 SO_NODE_SOURCE(SoResetTransform);
63
64 ////////////////////////////////////////////////////////////////////////
65 //
66 // Description:
67 // Constructor
68 //
69 // Use: public
70
71 SoResetTransform::SoResetTransform()
72 //
73 ////////////////////////////////////////////////////////////////////////
74 {
75 SO_NODE_CONSTRUCTOR(SoResetTransform);
76 SO_NODE_ADD_FIELD(whatToReset, (TRANSFORM));
77
78 // Set up static info for enumerated type field
79 SO_NODE_DEFINE_ENUM_VALUE(ResetType, TRANSFORM);
80 SO_NODE_DEFINE_ENUM_VALUE(ResetType, BBOX);
81
82 // Set up info in enumerated type field
83 SO_NODE_SET_SF_ENUM_TYPE(whatToReset, ResetType);
84
85 isBuiltIn = TRUE;
86 }
87
88 ////////////////////////////////////////////////////////////////////////
89 //
90 // Description:
91 // Destructor
92 //
93 // Use: private
94
95 SoResetTransform::~SoResetTransform()
96 //
97 ////////////////////////////////////////////////////////////////////////
98 {
99 }
100
101 ////////////////////////////////////////////////////////////////////////
102 //
103 // Description:
104 // Implements most actions.
105 //
106 // Use: extender
107
108 void
109 SoResetTransform::doAction(SoAction *action)
110 //
111 ////////////////////////////////////////////////////////////////////////
112 {
113 // If has effect on transform
114 if (! whatToReset.isIgnored() && (whatToReset.getValue() & TRANSFORM))
115 SoModelMatrixElement::makeIdentity(action->getState(), this);
116 }
117
118 ////////////////////////////////////////////////////////////////////////
119 //
120 // Description:
121 // Handles callback action
122 //
123 // Use: extender
124
125 void
126 SoResetTransform::callback(SoCallbackAction *action)
127 //
128 ////////////////////////////////////////////////////////////////////////
129 {
130 SoResetTransform::doAction(action);
131 }
132
133 ////////////////////////////////////////////////////////////////////////
134 //
135 // Description:
136 // Handles GL render action
137 //
138 // Use: extender
139
140 void
141 SoResetTransform::GLRender(SoGLRenderAction *action)
142 //
143 ////////////////////////////////////////////////////////////////////////
144 {
145 // If has effect on transform
146 if (! whatToReset.isIgnored() && (whatToReset.getValue() & TRANSFORM))
147 SoGLModelMatrixElement::makeIdentity(action->getState(), this);
148 }
149
150 ////////////////////////////////////////////////////////////////////////
151 //
152 // Description:
153 // Changes transformation used when computing bounding box. Also
154 // sets bounding box to empty if so specified.
155 //
156 // Use: extender
157
158 void
159 SoResetTransform::getBoundingBox(SoGetBoundingBoxAction *action)
160 //
161 ////////////////////////////////////////////////////////////////////////
162 {
163 // Do regular transform stuff
164 SoResetTransform::doAction(action);
165
166 // If supposed to reset bounding box to empty
167 if (whatToReset.getValue() & BBOX) {
168 action->getXfBoundingBox().makeEmpty();
169 action->resetCenter();
170 }
171 }
172
173 ////////////////////////////////////////////////////////////////////////
174 //
175 // Description:
176 // Returns transformation matrix.
177 //
178 // Use: extender
179
180 void
181 SoResetTransform::getMatrix(SoGetMatrixAction *action)
182 //
183 ////////////////////////////////////////////////////////////////////////
184 {
185 // If has effect on transform
186 if (! whatToReset.isIgnored() && (whatToReset.getValue() & TRANSFORM)) {
187
188 // Overwrite the current matrices with identity
189 action->getMatrix().makeIdentity();
190 action->getInverse().makeIdentity();
191 }
192 }
193
194 ////////////////////////////////////////////////////////////////////////
195 //
196 // Description:
197 // Handles pick action.
198 //
199 // Use: extender
200
201 void
202 SoResetTransform::pick(SoPickAction *action)
203 //
204 ////////////////////////////////////////////////////////////////////////
205 {
206 SoResetTransform::doAction(action);
207 }