Debian Codegraph @

lib/database/src/so/elements/SoPickRayElement.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 | SoPickRayElement
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/elements/SoPickRayElement.h>
55 #include <Inventor/errors/SoDebugError.h>
56
57 SO_ELEMENT_SOURCE(SoPickRayElement);
58
59 ////////////////////////////////////////////////////////////////////////
60 //
61 // Description:
62 // Destructor.
63 //
64 // Use: private
65
66 SoPickRayElement::~SoPickRayElement()
67 //
68 ////////////////////////////////////////////////////////////////////////
69 {
70 }
71
72 ////////////////////////////////////////////////////////////////////////
73 //
74 // Description:
75 // Initializes element.
76 //
77 // Use: public
78
79 void
80 SoPickRayElement::init(SoState *)
81 //
82 ////////////////////////////////////////////////////////////////////////
83 {
84 // Nothing to initialize. Just wait for a real picking ray to be set?
85 }
86
87 ////////////////////////////////////////////////////////////////////////
88 //
89 // Description:
90 // Overrides this method to always return FALSE. This element
91 // should never have anything to do with cache invalidation.
92 //
93 // Use: public
94
95 SbBool
96 SoPickRayElement::matches(const SoElement *) const
97 //
98 ////////////////////////////////////////////////////////////////////////
99 {
100 SoDebugError::post("SoPickRayElement::matches",
101 "This method should never be called!");
102
103 return FALSE;
104 }
105
106 ////////////////////////////////////////////////////////////////////////
107 //
108 // Description:
109 // Override method to return NULL; it should never be called.
110 //
111 // Use: protected
112
113 SoElement *
114 SoPickRayElement::copyMatchInfo() const
115 //
116 ////////////////////////////////////////////////////////////////////////
117 {
118 SoDebugError::post("SoPickRayElement::copyMatchInfo",
119 "This method should never be called!");
120
121 return NULL;
122 }
123
124 ////////////////////////////////////////////////////////////////////////
125 //
126 // Description:
127 // Sets the ray view volume in element accessed from state.
128 //
129 // Use: public, static
130
131 void
132 SoPickRayElement::set(SoState *state, const SbViewVolume &volume)
133 //
134 ////////////////////////////////////////////////////////////////////////
135 {
136 SoPickRayElement *elt;
137
138 // Get an instance we can change (pushing if necessary)
139 elt = (SoPickRayElement *) getElement(state, classStackIndex);
140
141 if (elt != NULL)
142 elt->volume = volume;
143 }
144
145 ////////////////////////////////////////////////////////////////////////
146 //
147 // Description:
148 // Returns the ray view volume from the state
149 //
150 // Use: public, static
151
152 const SbViewVolume &
153 SoPickRayElement::get(SoState *state)
154 //
155 ////////////////////////////////////////////////////////////////////////
156 {
157 const SoPickRayElement *elt;
158
159 elt = (const SoPickRayElement *) getConstElement(state, classStackIndex);
160
161 return elt->volume;
162 }
163
164 ////////////////////////////////////////////////////////////////////////
165 //
166 // Description:
167 // Prints contents of element for debugging.
168 //
169 // Use: public
170 //
171 ////////////////////////////////////////////////////////////////////////
172
173 #ifdef DEBUG
174 void
175 SoPickRayElement::print(FILE *fp) const
176 {
177 SoElement::print(fp);
178
179 fprintf(fp, "\tPicking Ray\n");
180
181 const SbVec3f &projPt = volume.getProjectionPoint();
182 const SbVec3f &projDir = volume.getProjectionDirection();
183
184 fprintf(fp, "\t\tStarting point = (%g, %g, %g)\n",
185 projPt[0], projPt[1], projPt[2]);
186
187 fprintf(fp, "\t\tDirection = (%g, %g, %g)\n",
188 projDir[0], projDir[1], projDir[2]);
189
190 fprintf(fp, "\t\tProjection is %s\n",
191 (volume.getProjectionType() == SbViewVolume::ORTHOGRAPHIC ?
192 "ORTHOGRAPHIC" : "PERSPECTIVE"));
193
194 fprintf(fp, "\t\tNear distance = %g\n", volume.getNearDist());
195 fprintf(fp, "\t\tFar distance = %g\n",
196 volume.getNearDist() + volume.getDepth());
197
198 fprintf(fp, "\t\tPick radius = %g\n", 0.5 * volume.getWidth());
199 }
200 #else /* DEBUG */
201 void
202 SoPickRayElement::print(FILE *) const
203 {
204 }
205 #endif /* DEBUG */