Debian Codegraph @

apps/demos/noodle/LineManip.c++

raw symbols SCIP
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 // A very specialized node; this manipulator completely takes care of
39 // editing a set of line segments. This is somewhat different from
40 // other manipulators, because you insert it in the scene graph and it
41 // edits itself (instead of pointing it at the thing you want it to
42 // edit).
43 //
44
45 #include <cstdio>
46 #include <assert.h>
47
48 #include <Inventor/SbColor.h>cxx . . $ `<file>/lib/database/include/Inventor/SbColor.h`/
49 #include <Inventor/SoPickedPoint.h>cxx . . $ `<file>/lib/database/include/Inventor/SoPickedPoint.h`/
50 #include <Inventor/actions/SoHandleEventAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoHandleEventAction.h`/
51 #include <Inventor/details/SoDetail.h>cxx . . $ `<file>/lib/database/include/Inventor/details/SoDetail.h`/
52 #include <Inventor/details/SoLineDetail.h>cxx . . $ `<file>/lib/database/include/Inventor/details/SoLineDetail.h`/
53 #include <Inventor/details/SoPointDetail.h>cxx . . $ `<file>/lib/database/include/Inventor/details/SoPointDetail.h`/
54 #include <Inventor/elements/SoViewVolumeElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoViewVolumeElement.h`/
55 #include <Inventor/elements/SoViewportRegionElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoViewportRegionElement.h`/
56 #include <Inventor/events/SoEvent.h>cxx . . $ `<file>/lib/database/include/Inventor/events/SoEvent.h`/
57 #include <Inventor/events/SoKeyboardEvent.h>cxx . . $ `<file>/lib/database/include/Inventor/events/SoKeyboardEvent.h`/
58 #include <Inventor/events/SoLocation2Event.h>cxx . . $ `<file>/lib/database/include/Inventor/events/SoLocation2Event.h`/
59 #include <Inventor/events/SoMouseButtonEvent.h>cxx . . $ `<file>/lib/database/include/Inventor/events/SoMouseButtonEvent.h`/
60 #include <Inventor/misc/SoState.h>cxx . . $ `<file>/lib/database/include/Inventor/misc/SoState.h`/
61 #include <Inventor/nodes/SoCoordinate3.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoCoordinate3.h`/
62 #include <Inventor/nodes/SoDrawStyle.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoDrawStyle.h`/
63 #include <Inventor/nodes/SoLightModel.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoLightModel.h`/
64 #include <Inventor/nodes/SoLineSet.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoLineSet.h`/
65 #include <Inventor/nodes/SoPointSet.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoPointSet.h`/
66 #include <Inventor/nodes/SoTransform.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoTransform.h`/
67 #include <Inventor/projectors/SbLineProjector.h>cxx . . $ `<file>/lib/database/include/Inventor/projectors/SbLineProjector.h`/
68 #include <Inventor/projectors/SbPlaneProjector.h>cxx . . $ `<file>/lib/database/include/Inventor/projectors/SbPlaneProjector.h`/
69 #include <Inventor/sensors/SoFieldSensor.h>cxx . . $ `<file>/lib/database/include/Inventor/sensors/SoFieldSensor.h`/
70
71 #include "LineManip.h"cxx . . $ `<file>/apps/demos/noodle/LineManip.h`/
72
73 SO_NODE_SOURCEcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:241:9`!(LineManip2);
74
75 //
76 // Constructor; sets up scene graph
77 //
78 LineManip2cxx . . $ LineManip2#::LineManip2cxx . . $ LineManip2#LineManip2(49f6e7a06ebc5aa8).()
79 {
80 SO_NODE_CONSTRUCTORcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:309:9`!(LineManip2);
81
82 coordcxx . . $ LineManip2#coord. = new SoCoordinate3cxx . . $ SoCoordinate3#();
83 addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(coordcxx . . $ LineManip2#coord.);
84 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..deleteValuescxx . . $ SoMField#deleteValues(3e454b8ccf442868).(0);
85
86 psetcxx . . $ LineManip2#pset. = new SoPointSetcxx . . $ SoPointSet#;
87 psetcxx . . $ LineManip2#pset.->numPointscxx . . $ SoPointSet#numPoints..setValuecxx . . $ SoSFInt32#setValue(d4f767463ce0a6b3).(0);
88 addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(psetcxx . . $ LineManip2#pset.);
89
90 drawStylecxx . . $ LineManip2#drawStyle. = new SoDrawStylecxx . . $ SoDrawStyle#;
91 drawStylecxx . . $ LineManip2#drawStyle.->stylecxx . . $ SoDrawStyle#style. =cxx . . $ SoSFEnum#`operator=`(7864480464b09eea). SoDrawStylecxx . . $ SoDrawStyle#::LINEScxx . . $ SoDrawStyle#LINES.;
92 addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(drawStylecxx . . $ LineManip2#drawStyle.);
93
94 lsetcxx . . $ LineManip2#lset. = new SoLineSetcxx . . $ SoLineSet#;
95 lsetcxx . . $ LineManip2#lset.->numVerticescxx . . $ SoLineSet#numVertices..setValuecxx . . $ SoMFInt32#setValue(d4f767463ce0a6b3).(0);
96 addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(lsetcxx . . $ LineManip2#lset.);
97
98 current_coordcxx . . $ LineManip2#current_coord. = -1;
99 planeProjcxx . . $ LineManip2#planeProj. = new SbPlaneProjectorcxx . . $ SbPlaneProjector#(FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!);
100 planeProjcxx . . $ LineManip2#planeProj.->setPlanecxx . . $ SbPlaneProjector#setPlane(b57880e1f0abeb65).( SbPlanecxx . . $ SbPlane#SbPlane(91fd4afec15735a5).( SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,1), 0 ) );
101 lineProjcxx . . $ LineManip2#lineProj. = new SbLineProjectorcxx . . $ SbLineProjector#();
102 lineProjcxx . . $ LineManip2#lineProj.->setLinecxx . . $ SbLineProjector#setLine(40219236977e8d5e).( SbLinecxx . . $ SbLine#SbLine(d696704770a33d8f).( SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,0),SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,1) ) );
103
104 hilightSizecxx . . $ LineManip2#hilightSize. = 0.05;
105
106 initHilightStuffcxx . . $ LineManip2#initHilightStuff(49f6e7a06ebc5aa8).();
107
108 myHandleEventActioncxx . . $ LineManip2#myHandleEventAction. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
109
110 // This sensor will insure that the pset and lset nodes will have
111 // the correct number of points.
112 coordFieldSensorcxx . . $ LineManip2#coordFieldSensor. = new SoFieldSensorcxx . . $ SoFieldSensor#(&LineManip2cxx . . $ LineManip2#::coordFieldSensorCBcxx . . $ LineManip2#coordFieldSensorCB(c8d298b3e215c027)., this);
113 coordFieldSensorcxx . . $ LineManip2#coordFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point. );
114 coordFieldSensorcxx . . $ LineManip2#coordFieldSensor.->setPrioritycxx . . $ SoDelayQueueSensor#setPriority(cb2f890c2fdad230).(0);
115 }
116
117 //
118 // Destructor. This will be called when this is unref'ed.
119 LineManip2cxx . . $ LineManip2#::~cxx . . $ LineManip2#`~LineManip2`(49f6e7a06ebc5aa8).LineManip2cxx . . $ LineManip2#()
120 {
121 //
122 // Don't need to delete children; they will have already been
123 // unref'ed and deleted (since this is derived from SoGroup).
124 //
125
126 delete planeProjcxx . . $ LineManip2#planeProj.;
127 delete lineProjcxx . . $ LineManip2#lineProj.;
128 delete coordFieldSensorcxx . . $ LineManip2#coordFieldSensor.;
129 }
130
131 //
132 // Magic stuff to register this node with the database
133 //
134 void
135 LineManip2cxx . . $ LineManip2#::initClasscxx . . $ LineManip2#initClass(49f6e7a06ebc5aa8).()
136 {
137 SO_NODE_INIT_CLASScxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:283:9`!(LineManip2, SoSeparator, "Separator");
138 }
139
140 //
141 // This tiny routine is how this Node gets used. After creating a
142 // LineManip2, call this routine and put a data sensor on the Coordinate3
143 // returned.
144 //
145 SoCoordinate3cxx . . $ SoCoordinate3# *
146 LineManip2cxx . . $ LineManip2#::getCoordinate3cxx . . $ LineManip2#getCoordinate3(761f332f3263f9af).()
147 {
148 return coordcxx . . $ LineManip2#coord.;
149 }
150
151 //
152 // This tiny routine is how this Node gets used. After creating a
153 // LineManip2, call this routine and put a data sensor on the Coordinate3
154 // returned.
155 //
156 void
157 LineManip2cxx . . $ LineManip2#::setCoordinate3cxx . . $ LineManip2#setCoordinate3(95029f1824630f9e).( SoCoordinate3cxx . . $ SoCoordinate3# *newNode )
158 {
159 if ( newNode == coordcxx . . $ LineManip2#coord.)
160 return;
161
162 if ( coordcxx . . $ LineManip2#coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ) {
163 removeChildcxx . . $ SoGroup#removeChild(da6c7544ccee32bd).( coordcxx . . $ LineManip2#coord. );
164 coordFieldSensorcxx . . $ LineManip2#coordFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).();
165 }
166 if ( newNode != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ) {
167 insertChildcxx . . $ SoGroup#insertChild(de18c6a3dadfdca6).(newNode,0);
168 coordFieldSensorcxx . . $ LineManip2#coordFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &newNode->pointcxx . . $ SoCoordinate3#point. );
169 }
170 coordcxx . . $ LineManip2#coord. = newNode;
171
172 coordFieldSensorCBcxx . . $ LineManip2#coordFieldSensorCB(c8d298b3e215c027).( this, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
173 }
174
175 //
176 // For setting the plane that the manip works in. You pass it a normal.
177 //
178 void
179 LineManip2cxx . . $ LineManip2#::setPlaneNormalcxx . . $ LineManip2#setPlaneNormal(65a601b9d70571d6).( const SbVec3fcxx . . $ SbVec3f# &newNormal )
180 {
181 SbVec3fcxx . . $ SbVec3f# zeroVeccxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,0);
182 planeNormalcxx . . $ LineManip2#planeNormal. =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). newNormal;
183 planeProjcxx . . $ LineManip2#planeProj.->setPlanecxx . . $ SbPlaneProjector#setPlane(b57880e1f0abeb65).( SbPlanecxx . . $ SbPlane#SbPlane(d696704770a33d8f).( planeNormalcxx . . $ LineManip2#planeNormal., zeroVec ) );
184 lineProjcxx . . $ LineManip2#lineProj.->setLinecxx . . $ SbLineProjector#setLine(40219236977e8d5e).( SbLinecxx . . $ SbLine#SbLine(d696704770a33d8f).( zeroVec, zeroVec +cxx . . $ operator+(af63bf8d0639b76b). planeNormalcxx . . $ LineManip2#planeNormal. ) );
185 hilightTransformcxx . . $ LineManip2#hilightTransform.->rotationcxx . . $ SoTransform#rotation..setValuecxx . . $ SoSFRotation#setValue(8b1048b3fc01a89c).( SbRotationcxx . . $ SbRotation#SbRotation(d696704770a33d8f).(SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,1), SbVec3fcxx . . $ SbVec3f#(planeNormalcxx . . $ LineManip2#planeNormal.)));
186 }
187
188 //
189 // Note:
190 // This node eats events. It uses the entire surface of the render
191 // area as its playground, sucking up mouse motion, left mouse and
192 // backspace/delete events, even if the mouse isn't on top of it.
193 //
194 void
195 LineManip2cxx . . $ LineManip2#::handleEventcxx . . $ LineManip2#handleEvent(89f4d17049d836a3).(SoHandleEventActioncxx . . $ SoHandleEventAction# *ha)
196 {
197 myHandleEventActioncxx . . $ LineManip2#myHandleEventAction. = ha;
198
199 const SoEventcxx . . $ SoEvent# *e = ha->getEventcxx . . $ SoHandleEventAction#getEvent(c30b8bbf6163e0e4).();
200
201 if (SO_MOUSE_PRESS_EVENTcxx . . $ `lib/database/include/Inventor/events/SoMouseButtonEvent.h:65:9`!(e, BUTTON1)) {
202 if (dragStartcxx . . $ LineManip2#dragStart(b126dc7c1de90089).())
203 ha->setHandledcxx . . $ SoHandleEventAction#setHandled(49f6e7a06ebc5aa8).();
204 }
205 else if (e->isOfTypecxx . . $ SoEvent#isOfType(1fd66475a268b64e).(SoLocation2Eventcxx . . $ SoLocation2Event#::getClassTypeIdcxx . . $ SoLocation2Event#getClassTypeId(c00c150378d2b968).())) {
206 // If not dragging, locate hilight
207 if (ha->getGrabbercxx . . $ SoHandleEventAction#getGrabber(b794963b450d51b3).() != this) {
208 if (locateHilightcxx . . $ LineManip2#locateHilight(b126dc7c1de90089).())
209 ha->setHandledcxx . . $ SoHandleEventAction#setHandled(49f6e7a06ebc5aa8).();
210 }
211 else { // Are dragging, move coordinate:
212 moveCoordcxx . . $ LineManip2#moveCoord(49f6e7a06ebc5aa8).();
213 ha->setHandledcxx . . $ SoHandleEventAction#setHandled(49f6e7a06ebc5aa8).();
214 }
215 }
216 else if (SO_MOUSE_RELEASE_EVENTcxx . . $ `lib/database/include/Inventor/events/SoMouseButtonEvent.h:68:9`!(e, BUTTON1) &&
217 ha->getGrabbercxx . . $ SoHandleEventAction#getGrabber(b794963b450d51b3).() == this) {
218 ha->releaseGrabbercxx . . $ SoHandleEventAction#releaseGrabber(49f6e7a06ebc5aa8).();
219 ha->setHandledcxx . . $ SoHandleEventAction#setHandled(49f6e7a06ebc5aa8).();
220 }
221 else if (SO_KEY_PRESS_EVENTcxx . . $ `lib/database/include/Inventor/events/SoKeyboardEvent.h:65:9`!(e, BACKSPACE) ||
222 SO_KEY_PRESS_EVENTcxx . . $ `lib/database/include/Inventor/events/SoKeyboardEvent.h:65:9`!(e, DELETE)) {
223 if (removecxx . . $ LineManip2#remove(b126dc7c1de90089).())
224 ha->setHandledcxx . . $ SoHandleEventAction#setHandled(49f6e7a06ebc5aa8).();
225 // If we are in mid-motion and we remove the point,
226 // we better stop grabber, cause we got nothin to grab anymore.
227 if (ha->getGrabbercxx . . $ SoHandleEventAction#getGrabber(b794963b450d51b3).() == this)
228 ha->releaseGrabbercxx . . $ SoHandleEventAction#releaseGrabber(49f6e7a06ebc5aa8).();
229 current_coordcxx . . $ LineManip2#current_coord. = -1;
230 }
231 }
232
233 static SbColorcxx . . $ SbColor# locateColorcxx . . $ locateColor.(0.5, 0.5, 0.5);
234 static SbColorcxx . . $ SbColor# pickColorcxx . . $ pickColor.(0.9, 0.9, 0.9);
235
236 //
237 // Figures out which part of the line manipulator is picked by the
238 // given detail. This will also set current_position and
239 // current_coord.
240 //
241 #ifdef __C_PLUS_PLUS_2
242 LineManipPart
243 #else
244 LineManip2cxx . . $ LineManip2#::Partcxx . . $ LineManip2#Part#
245 #endif
246 LineManip2cxx . . $ LineManip2#::whichPartcxx . . $ LineManip2#whichPart(97e0518b7d3357df).()
247 {
248 // Can't pick if we don't have an action, now can we?
249 if (myHandleEventActioncxx . . $ LineManip2#myHandleEventAction. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
250 return NOTHINGcxx . . $ LineManip2#NOTHING.;
251
252 // We're also out of luck if there's no coord node.
253 if (coordcxx . . $ LineManip2#coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
254 return NOTHINGcxx . . $ LineManip2#NOTHING.;
255
256 const SoPickedPointcxx . . $ SoPickedPoint# *picked_point = myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.->getPickedPointcxx . . $ SoHandleEventAction#getPickedPoint(76b3ff23e9b44274).();
257
258 projectMousecxx . . $ LineManip2#projectMouse(d027cd3ab60350a2).(current_positioncxx . . $ LineManip2#current_position.);
259
260 int numCoords = coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).();
261
262 if (numCoords == 0 || picked_point == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
263 //
264 // Endpoints
265 // Pick the endPoint that's closer to where the mouse is now.
266 if (numCoords == 0) {
267 current_coordcxx . . $ LineManip2#current_coord. = -1;
268 }
269 else {
270 SbVec3fcxx . . $ SbVec3f# v1cxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8)., v2cxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).;
271 v1 =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). current_positioncxx . . $ LineManip2#current_position. -cxx . . $ operator-(af63bf8d0639b76b). coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).0];
272 v2 =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). current_positioncxx . . $ LineManip2#current_position. -cxx . . $ operator-(af63bf8d0639b76b). coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).numCoords-1];
273 //
274 // Choose the endPoint closer to the current position.
275 //
276 if (v1.dotcxx . . $ SbVec3f#dot(adcfb95606509c95).(v1) < v2.dotcxx . . $ SbVec3f#dot(adcfb95606509c95).(v2)) {
277 current_coordcxx . . $ LineManip2#current_coord. = 0;
278 }
279 else {
280 current_coordcxx . . $ LineManip2#current_coord. = numCoords;
281 }
282 }
283 return ENDPOINTScxx . . $ LineManip2#ENDPOINTS.;
284 }
285
286 const SoPathcxx . . $ SoPath# *dpath = picked_point->getPathcxx . . $ SoPickedPoint#getPath(58db5280b30558ed).();
287 const SoDetailcxx . . $ SoDetail# *detail = picked_point->getDetailcxx . . $ SoPickedPoint#getDetail(57ca9d692aed245d).();
288
289 if (dpath->containsNodecxx . . $ SoPath#containsNode(25d228eba4c5059a).(psetcxx . . $ LineManip2#pset.)) {
290 current_coordcxx . . $ LineManip2#current_coord. =
291 ((SoPointDetailcxx . . $ SoPointDetail# *)detail)->getCoordinateIndexcxx . . $ SoPointDetail#getCoordinateIndex(455f465bc33b4cdf).();
292 return POINTScxx . . $ LineManip2#POINTS.;
293 }
294 if (dpath->containsNodecxx . . $ SoPath#containsNode(25d228eba4c5059a).(lsetcxx . . $ LineManip2#lset.)) {
295 current_coordcxx . . $ LineManip2#current_coord. =
296 ((SoLineDetailcxx . . $ SoLineDetail# *)detail)->getPartIndexcxx . . $ SoLineDetail#getPartIndex(455f465bc33b4cdf).();
297 return LINEScxx . . $ LineManip2#LINES.;
298 }
299 return NOTHINGcxx . . $ LineManip2#NOTHING.;
300 }
301
302 //
303 // Called when the mouse goes down to figure out what is being picked.
304 //
305 SbBoolcxx . . $ SbBool#
306 LineManip2cxx . . $ LineManip2#::dragStartcxx . . $ LineManip2#dragStart(b126dc7c1de90089).()
307 {
308 if ( coordcxx . . $ LineManip2#coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
309 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
310
311 SbBoolcxx . . $ SbBool# gotSomething = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
312
313 switch(whichPartcxx . . $ LineManip2#whichPart(97e0518b7d3357df).()) {
314 case POINTScxx . . $ LineManip2#POINTS.:
315 myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.->setGrabbercxx . . $ SoHandleEventAction#setGrabber(da6c7544ccee32bd).(this);
316 hilightVertexcxx . . $ LineManip2#hilightVertex(5a29e11d01c9d876).(coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).current_coordcxx . . $ LineManip2#current_coord.], pickColorcxx . . $ pickColor.);
317 break;
318
319 case LINEScxx . . $ LineManip2#LINES.:
320 // Create a new vertex
321 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..insertSpacecxx . . $ SoMField#insertSpace(3e454b8ccf442868).(current_coordcxx . . $ LineManip2#current_coord.+1, 1);
322 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..set1Valuecxx . . $ SoMFVec3f#set1Value(9c7ea36464c471ee).(current_coordcxx . . $ LineManip2#current_coord.+1, current_positioncxx . . $ LineManip2#current_position.);
323 myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.->setGrabbercxx . . $ SoHandleEventAction#setGrabber(da6c7544ccee32bd).(this);
324 ++current_coordcxx . . $ LineManip2#current_coord.;
325 hilightVertexcxx . . $ LineManip2#hilightVertex(5a29e11d01c9d876).(coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).current_coordcxx . . $ LineManip2#current_coord.], pickColorcxx . . $ pickColor.);
326 break;
327
328 case ENDPOINTScxx . . $ LineManip2#ENDPOINTS.:
329 // Create a new vertex
330 if (current_coordcxx . . $ LineManip2#current_coord. != -1) {
331 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..insertSpacecxx . . $ SoMField#insertSpace(3e454b8ccf442868).(current_coordcxx . . $ LineManip2#current_coord., 1);
332 }
333 else current_coordcxx . . $ LineManip2#current_coord. = 0;
334 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..set1Valuecxx . . $ SoMFVec3f#set1Value(9c7ea36464c471ee).(current_coordcxx . . $ LineManip2#current_coord., current_positioncxx . . $ LineManip2#current_position.);
335 myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.->setGrabbercxx . . $ SoHandleEventAction#setGrabber(da6c7544ccee32bd).(this);
336 hilightVertexcxx . . $ LineManip2#hilightVertex(5a29e11d01c9d876).(coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).current_coordcxx . . $ LineManip2#current_coord.], pickColorcxx . . $ pickColor.);
337 break;
338
339 case NOTHINGcxx . . $ LineManip2#NOTHING.:
340 current_coordcxx . . $ LineManip2#current_coord. = -1;
341 removeHilightscxx . . $ LineManip2#removeHilights(49f6e7a06ebc5aa8).();
342 gotSomething = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
343 break;
344 }
345
346 return gotSomething;
347 }
348
349 //
350 // Called by SoHandleEventAction when we grab events
351 // using myHandleEventAction->setGrabber( this );
352 //
353 // We will record the viewport and viewvolume.
354 // This is because once we've grabbed, we can't rely on the new handleEvent
355 // action to have correct view information.
356 // Why? Because grabbing bypasses traversal and sends the event directly
357 // to this node. The camera node has no chance to modify the state.
358 //
359
360 void
361 LineManip2cxx . . $ LineManip2#::grabEventsSetupcxx . . $ LineManip2#grabEventsSetup(49f6e7a06ebc5aa8).()
362 {
363 extractViewingParamscxx . . $ LineManip2#extractViewingParams(89f4d17049d836a3).(myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.);
364 savedRenderCachingValcxx . . $ LineManip2#savedRenderCachingVal.
365 = (SoSeparatorcxx . . $ SoSeparator#::CacheEnabledcxx . . $ SoSeparator#CacheEnabled#) renderCachingcxx . . $ SoSeparator#renderCaching..getValuecxx . . $ SoSFEnum#getValue(455f465bc33b4cdf).();
366 renderCachingcxx . . $ SoSeparator#renderCaching. =cxx . . $ SoSFEnum#`operator=`(7864480464b09eea). OFFcxx . . $ SoSeparator#OFF.;
367 }
368
369
370 void
371 LineManip2cxx . . $ LineManip2#::grabEventsCleanupcxx . . $ LineManip2#grabEventsCleanup(49f6e7a06ebc5aa8).()
372 {
373 removeHilightscxx . . $ LineManip2#removeHilights(49f6e7a06ebc5aa8).();
374 current_coordcxx . . $ LineManip2#current_coord. = -1;
375
376 renderCachingcxx . . $ SoSeparator#renderCaching. =cxx . . $ SoSFEnum#`operator=`(7864480464b09eea). savedRenderCachingValcxx . . $ LineManip2#savedRenderCachingVal.;
377 }
378
379 void
380 LineManip2cxx . . $ LineManip2#::extractViewingParamscxx . . $ LineManip2#extractViewingParams(89f4d17049d836a3).( SoHandleEventActioncxx . . $ SoHandleEventAction# *ha )
381 {
382 if (ha == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
383 // If the action is NULL, use default values for view info.
384 myViewVolumecxx . . $ LineManip2#myViewVolume..orthocxx . . $ SbViewVolume#ortho(ead52af07cf3d7c7).(-1,1,-1,1,1,10);
385 myVpRegioncxx . . $ LineManip2#myVpRegion. =cxx . . $ SbViewportRegion#`operator=`(6f57b312b6884eb0). SbViewportRegioncxx . . $ SbViewportRegion#SbViewportRegion(af780a7c10c7990f).(1,1);
386 }
387 else {
388 // Get the view info from the action.
389 SoStatecxx . . $ SoState# *state = ha->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).();
390 myViewVolumecxx . . $ LineManip2#myViewVolume. =cxx . . $ SbViewVolume#`operator=`(8d27664768fdc104). SoViewVolumeElementcxx . . $ SoViewVolumeElement#::getcxx . . $ SoViewVolumeElement#get(e937bd4440f2434a).( state );
391 myVpRegioncxx . . $ LineManip2#myVpRegion. =cxx . . $ SbViewportRegion#`operator=`(6f57b312b6884eb0). SoViewportRegionElementcxx . . $ SoViewportRegionElement#::getcxx . . $ SoViewportRegionElement#get(862cff51521dc30e).( state );
392 }
393 }
394
395 //
396 // Called when the backspace or delete keys is hit. Note that if the
397 // mouse is close to the middle of a line segment (so a pick would
398 // insert a point) nothing is done. This used to delete the entire
399 // line segment, but that was not intuitive. That might be a good
400 // interface for creating disconnected line segments, though...
401 //
402 SbBoolcxx . . $ SbBool#
403 LineManip2cxx . . $ LineManip2#::removecxx . . $ LineManip2#remove(b126dc7c1de90089).()
404 {
405 if (coordcxx . . $ LineManip2#coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
406 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
407
408 SbBoolcxx . . $ SbBool# removedSomething = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
409
410 if ( myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.->getGrabbercxx . . $ SoHandleEventAction#getGrabber(b794963b450d51b3).() == this ) {
411 // Remove whatever we're working on.
412 if (current_coordcxx . . $ LineManip2#current_coord. != -1)
413 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..deleteValuescxx . . $ SoMField#deleteValues(3e454b8ccf442868).(current_coordcxx . . $ LineManip2#current_coord., 1);
414 }
415 else {
416 // Remove whatever the cursor indicates should be gone.
417 switch (whichPartcxx . . $ LineManip2#whichPart(97e0518b7d3357df).()) {
418 case POINTScxx . . $ LineManip2#POINTS.:
419 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..deleteValuescxx . . $ SoMField#deleteValues(3e454b8ccf442868).(current_coordcxx . . $ LineManip2#current_coord., 1);
420 break;
421
422 case LINEScxx . . $ LineManip2#LINES.:
423 // Do nothing.
424 break;
425
426 case ENDPOINTScxx . . $ LineManip2#ENDPOINTS.:
427 if (current_coordcxx . . $ LineManip2#current_coord. != -1) {
428 if (current_coordcxx . . $ LineManip2#current_coord. != coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).())
429 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..deleteValuescxx . . $ SoMField#deleteValues(3e454b8ccf442868).(current_coordcxx . . $ LineManip2#current_coord., 1);
430 else
431 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..deleteValuescxx . . $ SoMField#deleteValues(3e454b8ccf442868).(current_coordcxx . . $ LineManip2#current_coord.-1, 1);
432 }
433 break;
434
435 case NOTHINGcxx . . $ LineManip2#NOTHING.:
436 removedSomething = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
437 break;
438 }
439 }
440
441 removeHilightscxx . . $ LineManip2#removeHilights(49f6e7a06ebc5aa8).();
442
443 return removedSomething;
444 }
445
446 //
447 // Called when the mouse is moving around, but the left mouse button
448 // is up.
449 //
450 SbBoolcxx . . $ SbBool#
451 LineManip2cxx . . $ LineManip2#::locateHilightcxx . . $ LineManip2#locateHilight(b126dc7c1de90089).()
452 {
453 if (coordcxx . . $ LineManip2#coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! )
454 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
455
456 SbBoolcxx . . $ SbBool# hilitSomething = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
457
458 switch (whichPartcxx . . $ LineManip2#whichPart(97e0518b7d3357df).()) {
459 case POINTScxx . . $ LineManip2#POINTS.:
460 hilightVertexcxx . . $ LineManip2#hilightVertex(5a29e11d01c9d876).(coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).current_coordcxx . . $ LineManip2#current_coord.], locateColorcxx . . $ locateColor.);
461 break;
462
463 case LINEScxx . . $ LineManip2#LINES.:
464 hilightLinecxx . . $ LineManip2#hilightLine(1a237de48800b59d).(current_coordcxx . . $ LineManip2#current_coord., current_positioncxx . . $ LineManip2#current_position., locateColorcxx . . $ locateColor.);
465 break;
466
467 case ENDPOINTScxx . . $ LineManip2#ENDPOINTS.:
468 if (current_coordcxx . . $ LineManip2#current_coord. == -1) {
469 // There are no coordinates at all. We can't perform a
470 // hilight.
471 hilitSomething = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
472 }
473 else if (current_coordcxx . . $ LineManip2#current_coord. == 0)
474 hilightLinecxx . . $ LineManip2#hilightLine(1a237de48800b59d).(-1, current_positioncxx . . $ LineManip2#current_position., locateColorcxx . . $ locateColor.);
475 else
476 hilightLinecxx . . $ LineManip2#hilightLine(1a237de48800b59d).(current_coordcxx . . $ LineManip2#current_coord.-1, current_positioncxx . . $ LineManip2#current_position., locateColorcxx . . $ locateColor.);
477 break;
478
479 case NOTHINGcxx . . $ LineManip2#NOTHING.:
480 hilitSomething = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
481 break;
482 }
483
484 return hilitSomething;
485 }
486
487 //
488 // Called to move the selected point when the mouse is moved and the
489 // left mouse button is pressed.
490 //
491 void
492 LineManip2cxx . . $ LineManip2#::moveCoordcxx . . $ LineManip2#moveCoord(49f6e7a06ebc5aa8).()
493 {
494 if (coordcxx . . $ LineManip2#coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
495 return;
496
497 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(current_coord > -1 && current_coord < coord->point.getNum());
498 updateProjectorscxx . . $ LineManip2#updateProjectors(65a601b9d70571d6).( coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).current_coordcxx . . $ LineManip2#current_coord.] );
499 SbVec3fcxx . . $ SbVec3f# tcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).;
500 projectMousecxx . . $ LineManip2#projectMouse(d027cd3ab60350a2).(t);
501 coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..set1Valuecxx . . $ SoMFVec3f#set1Value(9c7ea36464c471ee).(current_coordcxx . . $ LineManip2#current_coord., t);
502
503 hilightVertexcxx . . $ LineManip2#hilightVertex(5a29e11d01c9d876).(coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point.[cxx . . $ SoMFVec3f#`operator[]`(e550528ef0703ba8).current_coordcxx . . $ LineManip2#current_coord.], pickColorcxx . . $ pickColor.);
504 }
505
506 void
507 LineManip2cxx . . $ LineManip2#::updateProjectorscxx . . $ LineManip2#updateProjectors(65a601b9d70571d6).( const SbVec3fcxx . . $ SbVec3f# &curPt )
508 {
509 SbVec3fcxx . . $ SbVec3f# dir = lineProjcxx . . $ LineManip2#lineProj.->getLinecxx . . $ SbLineProjector#getLine(ea1b170d7c045246).().getDirectioncxx . . $ SbLine#getDirection(b5c384c15c94bb12).();
510 lineProjcxx . . $ LineManip2#lineProj.->setLinecxx . . $ SbLineProjector#setLine(40219236977e8d5e).( SbLinecxx . . $ SbLine#SbLine(d696704770a33d8f).( curPt, curPt +cxx . . $ operator+(af63bf8d0639b76b). dir ) );
511
512 dir =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). planeProjcxx . . $ LineManip2#planeProj.->getPlanecxx . . $ SbPlaneProjector#getPlane(e01acef9bccbd60e).().getNormalcxx . . $ SbPlane#getNormal(b5c384c15c94bb12).();
513 planeProjcxx . . $ LineManip2#planeProj.->setPlanecxx . . $ SbPlaneProjector#setPlane(b57880e1f0abeb65).( SbPlanecxx . . $ SbPlane#SbPlane(d696704770a33d8f).( dir, curPt ) );
514 }
515
516 //
517 // Does the grunt work of projecting the mouse onto the plane
518 // containing the line manipulator.
519 //
520 void
521 LineManip2cxx . . $ LineManip2#::projectMousecxx . . $ LineManip2#projectMouse(d027cd3ab60350a2).(SbVec3fcxx . . $ SbVec3f# &result)
522 {
523 const SoEventcxx . . $ SoEvent# *e = myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.->getEventcxx . . $ SoHandleEventAction#getEvent(c30b8bbf6163e0e4).();
524
525 // If we're grabbing, we've already got our view parameters.
526 // If not, then we'd better get them now.
527 // NOTE: If you're grabbing and you try to get view parameters, you'll
528 // get a bad answer. Grabbing causes you to skip over camera
529 // nodes directly to this one. So the state has no valid view info.
530 if ( myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.->getGrabbercxx . . $ SoHandleEventAction#getGrabber(b794963b450d51b3).() != this )
531 extractViewingParamscxx . . $ LineManip2#extractViewingParams(89f4d17049d836a3).(myHandleEventActioncxx . . $ LineManip2#myHandleEventAction.);
532
533 // If alt key is down, then we move in line perpendicular to plane
534 if ( e->wasAltDowncxx . . $ SoEvent#wasAltDown(455f465bc33b4cdf).() == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ) {
535 planeProjcxx . . $ LineManip2#planeProj.->setViewVolumecxx . . $ SbProjector#setViewVolume(187982bfa537c808).(myViewVolumecxx . . $ LineManip2#myViewVolume.);
536 result =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). planeProjcxx . . $ LineManip2#planeProj.->projectcxx . . $ SbPlaneProjector#project(52e93d88cc4c3965).(e->getNormalizedPositioncxx . . $ SoEvent#getNormalizedPosition(18356dd734a8b119).(myVpRegioncxx . . $ LineManip2#myVpRegion.));
537 }
538 else {
539 lineProjcxx . . $ LineManip2#lineProj.->setViewVolumecxx . . $ SbProjector#setViewVolume(187982bfa537c808).(myViewVolumecxx . . $ LineManip2#myViewVolume.);
540 result =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). lineProjcxx . . $ LineManip2#lineProj.->projectcxx . . $ SbLineProjector#project(52e93d88cc4c3965).(e->getNormalizedPositioncxx . . $ SoEvent#getNormalizedPosition(18356dd734a8b119).(myVpRegioncxx . . $ LineManip2#myVpRegion.));
541 }
542 }
543
544 // This sensor will insure that the pset and lset nodes will have
545 // the correct number of points.
546 void
547 LineManip2cxx . . $ LineManip2#::coordFieldSensorCBcxx . . $ LineManip2#coordFieldSensorCB(c8d298b3e215c027).( void *myPtr, SoSensorcxx . . $ SoSensor# *)
548 {
549 LineManip2cxx . . $ LineManip2# *myself = (LineManip2cxx . . $ LineManip2# *)myPtr;
550
551 int numPoints = 0;
552 if (myself->coordcxx . . $ LineManip2#coord.)
553 numPoints = myself->coordcxx . . $ LineManip2#coord.->pointcxx . . $ SoCoordinate3#point..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).();
554
555 if (myself->psetcxx . . $ LineManip2#pset.)
556 myself->psetcxx . . $ LineManip2#pset.->numPointscxx . . $ SoPointSet#numPoints..setValuecxx . . $ SoSFInt32#setValue(d4f767463ce0a6b3).(numPoints);
557 if (myself->lsetcxx . . $ LineManip2#lset.)
558 myself->lsetcxx . . $ LineManip2#lset.->numVerticescxx . . $ SoLineSet#numVertices..setValuecxx . . $ SoMFInt32#setValue(d4f767463ce0a6b3).(numPoints);
559 }