Debian Codegraph @

libSoXt/src/motif/SoXtMltSldrs.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-93 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 | Subclasses of multiple sliders that act on specific fields of
47 | specific types of nodes.
48 |
49 | Author(s) : Paul Isaacs
50 |
51 ______________ S I L I C O N G R A P H I C S I N C . ____________
52 _______________________________________________________________________
53 */
54
55
56 #include <cmath>
57 #include <X11/StringDefs.h>
58
59 #include <Inventor/sensors/SoSensor.h>
60 #include <Inventor/nodes/SoLight.h>
61 #include <Inventor/nodes/SoMaterial.h>
62 #include <Inventor/nodes/SoOrthographicCamera.h>
63 #include <Inventor/nodes/SoPerspectiveCamera.h>
64 #include <Inventor/nodes/SoRotation.h>
65 #include <Inventor/nodes/SoScale.h>
66 #include <Inventor/nodes/SoTransform.h>
67 #include <Inventor/nodes/SoTranslation.h>
68 #include <SoXtMultiSliders.h>
69 #include <SoXtSliderTool.h>
70
71 #define TOL 0.0001
72 #define PI 3.141592653589793
73 #define DEGREES_TO_RADIANS PI / 180.0
74 #define RADIANS_TO_DEGREES 180.0 / PI
75
76 static void extract_xyz( SbMatrix inMat, float &x, float &y, float &z )
77 {
78 y = asin( inMat[2][0]);
79 if( fabs(inMat[0][0])<TOL && fabs(inMat[1][0])<TOL){
80 /* cos( y ) near 0 */
81 x = atan2(inMat[0][1], -1 * inMat[0][2]);
82 z = 0.;
83 }
84 else{
85 x = atan2( -1 * inMat[2][1],inMat[2][2]);
86 z = atan2( -1 * inMat[1][0],inMat[0][0]);
87 }
88 }
89
90 static void rot_xyz( float x, float y, float z, SbMatrix &out_mat )
91 {
92 float f_sin[3], f_cos[3];
93 f_sin[0] = sin( x ); f_sin[1] = sin( y );
94 f_sin[2] = sin( z );
95 f_cos[0] = cos( x ); f_cos[1] = cos( y );
96 f_cos[2] = cos( z );
97
98 out_mat[0][0] = f_cos[2] * f_cos[1];
99 out_mat[1][0] = -f_sin[2] * f_cos[1];
100 out_mat[2][0] = f_sin[1];
101 out_mat[3][0] = 0.0;
102
103 out_mat[0][1] = f_cos[2] * f_sin[1] * f_sin[0] + f_sin[2] * f_cos[0];
104 out_mat[1][1] = -f_sin[2] * f_sin[1] * f_sin[0] + f_cos[2] * f_cos[0];
105 out_mat[2][1] = -f_cos[1] * f_sin[0];
106 out_mat[3][1] = 0.0;
107
108 out_mat[0][2] = -f_cos[2] * f_sin[1] * f_cos[0] + f_sin[2] * f_sin[0];
109 out_mat[1][2] = f_sin[2] * f_sin[1] * f_cos[0] + f_cos[2] * f_sin[0];
110 out_mat[2][2] = f_cos[1] * f_cos[0];
111 out_mat[3][2] = 0.0;
112
113 out_mat[0][3] = 0.0;
114 out_mat[1][3] = 0.0;
115 out_mat[2][3] = 0.0;
116 out_mat[3][3] = 1.0;
117 }
118
119 /* Find a set of rotations equivalent to the 'new' ones */
120 /* that are closest in value to the 'old' ones */
121 /* (Useful in adjusting rotations extracted from matrices.) */
122 /* */
123 /* Assume that order of rotations is x then y then z. In this case,*/
124 /* rot( r0 ) x --> rot( r1 ) y --> rot( r2 ) z */
125 /* is the same as: */
126 /* rot( PI + r0 ) x --> rot( PI - r1 ) y --> rot( PI + r2 ) z */
127 /* */
128 static void match_xyz_rots( float oldx, float oldy, float oldz,
129 float &newx, float &newy, float &newz )
130 {
131
132 int i;
133 float R1[3],R2[3], Rold[3];
134 float sum1, sum2;
135
136 Rold[0] = oldx;
137 Rold[1] = oldy;
138 Rold[2] = oldz;
139
140 /* R1 and R2 are equivalent rots (see above) */
141 R1[0] = newx; R1[1] = newy; R1[2] = newz;
142 R2[0] = PI + newx; R2[1] = PI - newy; R2[2] = PI + newz;
143 /* map rots into interval nearest 'last frame' rots */
144 for( i=0; i<3; i++){
145 while( R1[i] < Rold[i] - PI )
146 R1[i] += 2. * PI;
147 while( R2[i] < Rold[i] - PI )
148 R2[i] += 2. * PI;
149 while( R1[i] >= Rold[i] + PI )
150 R1[i] -= 2. * PI;
151 while( R2[i] >= Rold[i] + PI )
152 R2[i] -= 2. * PI;
153 }
154 /* see whether R1 or R2 better matches 'last frame' rots */
155 sum1 = fabs(Rold[0]-R1[0]) + fabs(Rold[1]-R1[1]) + fabs(Rold[2]-R1[2]);
156 sum2 = fabs(Rold[0]-R2[0]) + fabs(Rold[1]-R2[1]) + fabs(Rold[2]-R2[2]);
157 if(sum1<sum2) {
158 newx = R1[0];
159 newy = R1[1];
160 newz = R1[2];
161 }
162 else {
163 newx = R2[0];
164 newy = R2[1];
165 newz = R2[2];
166 }
167 }
168
169 ///////////////////////////////////////////////////////////////////////////////
170 //
171 // Class: SoXtTransMultiSlider
172 //
173 ///////////////////////////////////////////////////////////////////////////////
174
175 SoXtTransMultiSlider::SoXtTransMultiSlider(
176 Widget parent,
177 const char *name,
178 SbBool buildInsideParent)
179 : SoXtMultiSlider(
180 parent,
181 name,
182 buildInsideParent,
183 FALSE) // tell parent not to build just yet
184 {
185 _numSubComponents = 3;
186 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
187
188 Widget form = buildForm(getParentWidget());
189
190 _subComponentArray[0] = new SoXtSliderTool(
191 form, NULL, TRUE,
192 SO_TRANSLATE_SLIDER_MINIMUM,
193 SO_TRANSLATE_SLIDER_MAXIMUM );
194 _subComponentArray[1] = new SoXtSliderTool(
195 form, NULL, TRUE,
196 SO_TRANSLATE_SLIDER_MINIMUM,
197 SO_TRANSLATE_SLIDER_MAXIMUM );
198 _subComponentArray[2] = new SoXtSliderTool(
199 form, NULL, TRUE,
200 SO_TRANSLATE_SLIDER_MINIMUM,
201 SO_TRANSLATE_SLIDER_MAXIMUM );
202
203 for( int i = 0; i < _numSubComponents; i++ )
204 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
205
206 SoXtMultiSlider::buildWidget(form);
207 setBaseWidget(form);
208 }
209
210 SoXtTransMultiSlider::~SoXtTransMultiSlider() {}
211
212 SbBool
213 SoXtTransMultiSlider::validNodeType(SoNode *node)
214 {
215 return ((node->isOfType(SoTransform::getClassTypeId())) ||
216 (node->isOfType(SoTranslation::getClassTypeId())));
217 }
218
219 void
220 SoXtTransMultiSlider::exportValuesToInventor()
221 {
222 float xX, xY, xZ;
223 SbVec3f val;
224
225 if ( _editNode ) {
226
227 // get values from x-windows sliders
228 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
229 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
230 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
231
232 // get values from inventor
233 val = ((SoTransform *)_editNode)->translation.getValue();
234
235 if ( val[0] != xX || val[1] != xY || val[2] != xZ ) { // COPY TO NODE
236 ((SoTransform *)_editNode)->translation.setValue( xX, xY, xZ );
237 }
238 }
239 }
240
241 void
242 SoXtTransMultiSlider::importValuesFromInventor()
243 {
244 SbVec3f val;
245
246 if ( _editNode ) {
247
248 // get values from inventor
249 val = ((SoTransform *)_editNode)->translation.getValue();
250
251 // set values if necessary
252 if ( val[0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
253 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( val[0] );
254 if ( val[1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
255 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( val[1] );
256 if ( val[2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
257 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( val[2] );
258 }
259 }
260
261
262 ///////////////////////////////////////////////////////////////////////////////
263 //
264 // Class: SoXtScaleMultiSlider
265 //
266 ///////////////////////////////////////////////////////////////////////////////
267 SoXtScaleMultiSlider::SoXtScaleMultiSlider(
268 Widget parent,
269 const char *name,
270 SbBool buildInsideParent)
271 : SoXtMultiSlider(
272 parent,
273 name,
274 buildInsideParent,
275 FALSE) // tell parent not to build just yet
276 {
277 _numSubComponents = 3;
278 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
279
280 Widget form = buildForm(getParentWidget());
281
282 _subComponentArray[0] = new SoXtSliderTool(
283 form, NULL, TRUE,
284 SO_SCALE_SLIDER_MINIMUM,
285 SO_SCALE_SLIDER_MAXIMUM );
286 _subComponentArray[1] = new SoXtSliderTool(
287 form, NULL, TRUE,
288 SO_SCALE_SLIDER_MINIMUM,
289 SO_SCALE_SLIDER_MAXIMUM );
290 _subComponentArray[2] = new SoXtSliderTool(
291 form, NULL, TRUE,
292 SO_SCALE_SLIDER_MINIMUM,
293 SO_SCALE_SLIDER_MAXIMUM );
294
295 for( int i = 0; i < _numSubComponents; i++ )
296 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
297
298 SoXtMultiSlider::buildWidget(form);
299 setBaseWidget(form);
300 }
301
302 SoXtScaleMultiSlider::~SoXtScaleMultiSlider() {}
303
304 SbBool
305 SoXtScaleMultiSlider::validNodeType(SoNode *node)
306 {
307 return ((node->isOfType(SoTransform::getClassTypeId())) ||
308 (node->isOfType(SoScale::getClassTypeId())));
309 }
310
311 void
312 SoXtScaleMultiSlider::exportValuesToInventor()
313 {
314 float xX, xY, xZ;
315 SbVec3f val;
316
317 if ( _editNode ) {
318
319 // get values from x-windows sliders
320 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
321 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
322 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
323
324 // get values from inventor
325 val = ((SoTransform *)_editNode)->scaleFactor.getValue();
326
327 if ( val[0] != xX || val[1] != xY || val[2] != xZ ) { // COPY INTO NODE
328 ((SoTransform *)_editNode)->scaleFactor.setValue( xX, xY, xZ );
329 }
330 }
331 }
332
333 void
334 SoXtScaleMultiSlider::importValuesFromInventor()
335 {
336 SbVec3f val;
337
338 if ( _editNode ) {
339
340 // get values from inventor
341 val = ((SoTransform *)_editNode)->scaleFactor.getValue();
342
343 // set values if necessary
344 if ( val[0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
345 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( val[0] );
346 if ( val[1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
347 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( val[1] );
348 if ( val[2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
349 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( val[2] );
350 }
351 }
352
353 ///////////////////////////////////////////////////////////////////////////////
354 //
355 // Class: SoXtRotateMultiSlider
356 //
357 ///////////////////////////////////////////////////////////////////////////////
358 SoXtRotateMultiSlider::SoXtRotateMultiSlider(
359 Widget parent,
360 const char *name,
361 SbBool buildInsideParent)
362 : SoXtMultiSlider(
363 parent,
364 name,
365 buildInsideParent,
366 FALSE) // tell parent not to build just yet
367 {
368 _numSubComponents = 3;
369 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
370
371 Widget form = buildForm(getParentWidget());
372
373 _subComponentArray[0] = new SoXtSliderTool(
374 form, NULL, TRUE,
375 SO_ROTATE_SLIDER_MINIMUM,
376 SO_ROTATE_SLIDER_MAXIMUM );
377 _subComponentArray[1] = new SoXtSliderTool(
378 form, NULL, TRUE,
379 SO_ROTATE_SLIDER_MINIMUM,
380 SO_ROTATE_SLIDER_MAXIMUM );
381 _subComponentArray[2] = new SoXtSliderTool(
382 form, NULL, TRUE,
383 SO_ROTATE_SLIDER_MINIMUM,
384 SO_ROTATE_SLIDER_MAXIMUM );
385
386 for( int i = 0; i < _numSubComponents; i++ )
387 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
388
389 SoXtMultiSlider::buildWidget(form);
390 setBaseWidget(form);
391 }
392
393 SoXtRotateMultiSlider::~SoXtRotateMultiSlider() {}
394
395 SbBool
396 SoXtRotateMultiSlider::validNodeType(SoNode *node)
397 {
398 return ((node->isOfType(SoTransform::getClassTypeId())) ||
399 (node->isOfType(SoRotation::getClassTypeId())));
400 }
401
402 void
403 SoXtRotateMultiSlider::exportValuesToInventor()
404 {
405 float xX, xY, xZ;
406 SbMatrix theMatrix;
407 SbRotation theRotation;
408
409 if ( _editNode ) {
410
411 // get values from x-windows sliders
412 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
413 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
414 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
415
416 // convert from degrees to radians
417 xX *= DEGREES_TO_RADIANS;
418 xY *= DEGREES_TO_RADIANS;
419 xZ *= DEGREES_TO_RADIANS;
420
421 // set values in inventor
422 rot_xyz( xX, xY, xZ, theMatrix );
423
424 theRotation.setValue( theMatrix );
425 ((SoTransform *)_editNode)->rotation.setValue( theRotation );
426 }
427 }
428
429 void
430 SoXtRotateMultiSlider::importValuesFromInventor()
431 {
432 SbMatrix theMatrix;
433 SbRotation theRotation;
434 float xX, xY, xZ, x, y, z;
435
436 if ( _editNode ) {
437
438 // get values from inventor
439 theRotation = ((SoTransform *)_editNode)->rotation.getValue();
440 theRotation.getValue( theMatrix );
441 extract_xyz( theMatrix, x, y, z );
442
443 // get values from sliders
444 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
445 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
446 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
447
448 // convert from degrees to radians
449 xX *= DEGREES_TO_RADIANS;
450 xY *= DEGREES_TO_RADIANS;
451 xZ *= DEGREES_TO_RADIANS;
452
453 // match inventor values as closely as possible to the ones being
454 // displayed
455 match_xyz_rots( xX, xY, xZ, x, y, z );
456
457 // convert from radians to degrees
458 x *= RADIANS_TO_DEGREES;
459 y *= RADIANS_TO_DEGREES;
460 z *= RADIANS_TO_DEGREES;
461
462 // set values if necessary
463 if ( x != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
464 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( x );
465 if ( y != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
466 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( y );
467 if ( z != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
468 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( z );
469 }
470 }
471
472 ///////////////////////////////////////////////////////////////////////////////
473 //
474 // Class: SoXtScaleOrientationMultiSlider
475 //
476 ///////////////////////////////////////////////////////////////////////////////
477 SoXtScaleOrientationMultiSlider::SoXtScaleOrientationMultiSlider(
478 Widget parent,
479 const char *name,
480 SbBool buildInsideParent)
481 : SoXtMultiSlider(
482 parent,
483 name,
484 buildInsideParent,
485 FALSE) // tell parent not to build just yet
486 {
487 _numSubComponents = 3;
488 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
489
490 Widget form = buildForm(getParentWidget());
491
492 _subComponentArray[0] = new SoXtSliderTool(
493 form, NULL, TRUE,
494 SO_ROTATE_SLIDER_MINIMUM,
495 SO_ROTATE_SLIDER_MAXIMUM );
496 _subComponentArray[1] = new SoXtSliderTool(
497 form, NULL, TRUE,
498 SO_ROTATE_SLIDER_MINIMUM,
499 SO_ROTATE_SLIDER_MAXIMUM );
500 _subComponentArray[2] = new SoXtSliderTool(
501 form, NULL, TRUE,
502 SO_ROTATE_SLIDER_MINIMUM,
503 SO_ROTATE_SLIDER_MAXIMUM );
504
505 for( int i = 0; i < _numSubComponents; i++ )
506 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
507
508 SoXtMultiSlider::buildWidget(form);
509 setBaseWidget(form);
510 }
511
512 SoXtScaleOrientationMultiSlider::~SoXtScaleOrientationMultiSlider() {}
513
514 SbBool
515 SoXtScaleOrientationMultiSlider::validNodeType(SoNode *node)
516 {
517 return ((node->isOfType(SoTransform::getClassTypeId())) ||
518 (node->isOfType(SoRotation::getClassTypeId())));
519 }
520
521 void
522 SoXtScaleOrientationMultiSlider::exportValuesToInventor()
523 {
524 float xX, xY, xZ;
525 SbMatrix theMatrix;
526 SbRotation theRotation;
527
528 if ( _editNode ) {
529
530 // get values from x-windows sliders
531 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
532 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
533 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
534
535 // convert from degrees to radians
536 xX *= DEGREES_TO_RADIANS;
537 xY *= DEGREES_TO_RADIANS;
538 xZ *= DEGREES_TO_RADIANS;
539
540 // set values in inventor
541 rot_xyz( xX, xY, xZ, theMatrix );
542
543 theRotation.setValue( theMatrix );
544 ((SoTransform *)_editNode)->scaleOrientation.setValue( theRotation );
545 }
546 }
547
548 void
549 SoXtScaleOrientationMultiSlider::importValuesFromInventor()
550 {
551 SbMatrix theMatrix;
552 SbRotation theRotation;
553 float xX, xY, xZ, x, y, z;
554
555 if ( _editNode ) {
556
557 // get values from inventor
558 theRotation = ((SoTransform *)_editNode)->scaleOrientation.getValue();
559 theRotation.getValue( theMatrix );
560 extract_xyz( theMatrix, x, y, z );
561
562 // get values from sliders
563 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
564 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
565 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
566
567 // convert from degrees to radians
568 xX *= DEGREES_TO_RADIANS;
569 xY *= DEGREES_TO_RADIANS;
570 xZ *= DEGREES_TO_RADIANS;
571
572 // match inventor values as closely as possible to the ones being
573 // displayed
574 match_xyz_rots( xX, xY, xZ, x, y, z );
575
576 // convert from radians to degrees
577 x *= RADIANS_TO_DEGREES;
578 y *= RADIANS_TO_DEGREES;
579 z *= RADIANS_TO_DEGREES;
580
581 // set values if necessary
582 if ( x != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
583 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( x );
584 if ( y != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
585 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( y );
586 if ( z != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
587 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( z );
588 }
589 }
590
591 ///////////////////////////////////////////////////////////////////////////////
592 //
593 // Class: SoXtCenterMultiSlider
594 //
595 ///////////////////////////////////////////////////////////////////////////////
596 SoXtCenterMultiSlider::SoXtCenterMultiSlider(
597 Widget parent,
598 const char *name,
599 SbBool buildInsideParent)
600 : SoXtMultiSlider(
601 parent,
602 name,
603 buildInsideParent,
604 FALSE) // tell parent not to build just yet
605 {
606 _numSubComponents = 3;
607 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
608
609 Widget form = buildForm(getParentWidget());
610
611 _subComponentArray[0] = new SoXtSliderTool(form);
612 _subComponentArray[1] = new SoXtSliderTool(form);
613 _subComponentArray[2] = new SoXtSliderTool(form);
614
615 for( int i = 0; i < _numSubComponents; i++ )
616 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
617
618 SoXtMultiSlider::buildWidget(form);
619 setBaseWidget(form);
620 }
621
622 SoXtCenterMultiSlider::~SoXtCenterMultiSlider() {}
623
624 SbBool
625 SoXtCenterMultiSlider::validNodeType(SoNode *node)
626 {
627 return (node->isOfType(SoTransform::getClassTypeId()));
628 }
629
630 void
631 SoXtCenterMultiSlider::exportValuesToInventor()
632 {
633 float xX, xY, xZ;
634 SbVec3f val;
635
636 if ( _editNode ) {
637
638 // get values from x-windows sliders
639 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
640 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
641 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
642
643 // get values from inventor
644 val = ((SoTransform *)_editNode)->center.getValue();
645
646 if ( val[0] != xX || val[1] != xY || val[2] != xZ ) { // COPY INTO NODE
647 ((SoTransform *)_editNode)->center.setValue( xX, xY, xZ );
648 }
649 }
650 }
651
652 void
653 SoXtCenterMultiSlider::importValuesFromInventor()
654 {
655 SbVec3f val;
656
657 if ( _editNode ) {
658
659 // get values from inventor
660 val = ((SoTransform *)_editNode)->center.getValue();
661
662 // set values if necessary
663 if ( val[0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
664 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( val[0] );
665 if ( val[1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
666 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( val[1] );
667 if ( val[2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
668 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( val[2] );
669 }
670 }
671
672 ///////////////////////////////////////////////////////////////////////////////
673 //
674 // Class: SoXtAmbientColorMultiSlider
675 //
676 ///////////////////////////////////////////////////////////////////////////////
677 SoXtAmbientColorMultiSlider::SoXtAmbientColorMultiSlider(
678 Widget parent,
679 const char *name,
680 SbBool buildInsideParent)
681 : SoXtMultiSlider(
682 parent,
683 name,
684 buildInsideParent,
685 FALSE) // tell parent not to build just yet
686 {
687 _numSubComponents = 3;
688 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
689
690 Widget form = buildForm(getParentWidget());
691
692 _subComponentArray[0] = new SoXtSliderTool(
693 form, NULL, TRUE,
694 SO_UNIT_SLIDER_MINIMUM,
695 SO_UNIT_SLIDER_MAXIMUM );
696 _subComponentArray[1] = new SoXtSliderTool(
697 form, NULL, TRUE,
698 SO_UNIT_SLIDER_MINIMUM,
699 SO_UNIT_SLIDER_MAXIMUM );
700 _subComponentArray[2] = new SoXtSliderTool(
701 form, NULL, TRUE,
702 SO_UNIT_SLIDER_MINIMUM,
703 SO_UNIT_SLIDER_MAXIMUM );
704
705 for( int i = 0; i < _numSubComponents; i++ )
706 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
707
708 SoXtMultiSlider::buildWidget(form);
709 setBaseWidget(form);
710 }
711
712 SoXtAmbientColorMultiSlider::~SoXtAmbientColorMultiSlider() {}
713
714 SbBool
715 SoXtAmbientColorMultiSlider::validNodeType(SoNode *node)
716 {
717 return (node->isOfType(SoMaterial::getClassTypeId()));
718 }
719
720 void
721 SoXtAmbientColorMultiSlider::exportValuesToInventor()
722 {
723 float xX, xY, xZ;
724 const SbVec3f *soColor;
725
726 if ( _editNode ) {
727
728 // get values from x-windows sliders
729 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
730 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
731 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
732
733 // get values from inventor
734 soColor = ((SoMaterial *)_editNode)->ambientColor.getValues( 0 );
735
736 // copy into node if necessary
737 if (soColor[0][0] != xX || soColor[0][1] != xY || soColor[0][2] != xZ) {
738 ((SoMaterial *)_editNode)->ambientColor.setValue( xX, xY, xZ );
739 ((SoMaterial *)_editNode)->ambientColor.setIgnored(FALSE);
740 }
741 }
742 }
743
744 void
745 SoXtAmbientColorMultiSlider::importValuesFromInventor()
746 {
747 const SbVec3f *soColor;
748
749 if ( _editNode ) {
750
751 // get values from inventor
752 soColor = ((SoMaterial *)_editNode)->ambientColor.getValues( 0 );
753
754 // set values if necessary
755 if ( soColor[0][0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
756 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soColor[0][0] );
757 if ( soColor[0][1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
758 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( soColor[0][1] );
759 if ( soColor[0][2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
760 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( soColor[0][2] );
761 }
762 }
763
764 ///////////////////////////////////////////////////////////////////////////////
765 //
766 // Class: SoXtDiffuseColorMultiSlider
767 //
768 ///////////////////////////////////////////////////////////////////////////////
769 SoXtDiffuseColorMultiSlider::SoXtDiffuseColorMultiSlider(
770 Widget parent,
771 const char *name,
772 SbBool buildInsideParent)
773 : SoXtMultiSlider(
774 parent,
775 name,
776 buildInsideParent,
777 FALSE) // tell parent not to build just yet
778 {
779 _numSubComponents = 3;
780 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
781
782 Widget form = buildForm(getParentWidget());
783
784 _subComponentArray[0] = new SoXtSliderTool(
785 form, NULL, TRUE,
786 SO_UNIT_SLIDER_MINIMUM,
787 SO_UNIT_SLIDER_MAXIMUM );
788 _subComponentArray[1] = new SoXtSliderTool(
789 form, NULL, TRUE,
790 SO_UNIT_SLIDER_MINIMUM,
791 SO_UNIT_SLIDER_MAXIMUM );
792 _subComponentArray[2] = new SoXtSliderTool(
793 form, NULL, TRUE,
794 SO_UNIT_SLIDER_MINIMUM,
795 SO_UNIT_SLIDER_MAXIMUM );
796
797 for( int i = 0; i < _numSubComponents; i++ )
798 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
799
800 SoXtMultiSlider::buildWidget(form);
801 setBaseWidget(form);
802 }
803
804 SoXtDiffuseColorMultiSlider::~SoXtDiffuseColorMultiSlider() {}
805
806 SbBool
807 SoXtDiffuseColorMultiSlider::validNodeType(SoNode *node)
808 {
809 return (node->isOfType(SoMaterial::getClassTypeId()));
810 }
811
812 void
813 SoXtDiffuseColorMultiSlider::exportValuesToInventor()
814 {
815 float xX, xY, xZ;
816 const SbVec3f *soColor;
817
818 if ( _editNode ) {
819
820 // get values from x-windows sliders
821 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
822 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
823 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
824
825 // get values from inventor
826 soColor = ((SoMaterial *)_editNode)->diffuseColor.getValues( 0 );
827
828 // copy into node if necessary
829 if (soColor[0][0] != xX || soColor[0][1] != xY || soColor[0][2] != xZ) {
830 ((SoMaterial *)_editNode)->diffuseColor.setValue( xX, xY, xZ );
831 ((SoMaterial *)_editNode)->diffuseColor.setIgnored(FALSE);
832 }
833 }
834 }
835
836 void
837 SoXtDiffuseColorMultiSlider::importValuesFromInventor()
838 {
839 const SbVec3f *soColor;
840
841 if ( _editNode ) {
842
843 // get values from inventor
844 soColor = ((SoMaterial *)_editNode)->diffuseColor.getValues( 0 );
845
846 // set values if necessary
847 if ( soColor[0][0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
848 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soColor[0][0] );
849 if ( soColor[0][1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
850 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( soColor[0][1] );
851 if ( soColor[0][2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
852 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( soColor[0][2] );
853 }
854 }
855
856 ///////////////////////////////////////////////////////////////////////////////
857 //
858 // Class: SoXtSpecularColorMultiSlider
859 //
860 ///////////////////////////////////////////////////////////////////////////////
861 SoXtSpecularColorMultiSlider::SoXtSpecularColorMultiSlider(
862 Widget parent,
863 const char *name,
864 SbBool buildInsideParent)
865 : SoXtMultiSlider(
866 parent,
867 name,
868 buildInsideParent,
869 FALSE) // tell parent not to build just yet
870 {
871 _numSubComponents = 3;
872 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
873
874 Widget form = buildForm(getParentWidget());
875
876 _subComponentArray[0] = new SoXtSliderTool(
877 form, NULL, TRUE,
878 SO_UNIT_SLIDER_MINIMUM,
879 SO_UNIT_SLIDER_MAXIMUM );
880 _subComponentArray[1] = new SoXtSliderTool(
881 form, NULL, TRUE,
882 SO_UNIT_SLIDER_MINIMUM,
883 SO_UNIT_SLIDER_MAXIMUM );
884 _subComponentArray[2] = new SoXtSliderTool(
885 form, NULL, TRUE,
886 SO_UNIT_SLIDER_MINIMUM,
887 SO_UNIT_SLIDER_MAXIMUM );
888
889 for( int i = 0; i < _numSubComponents; i++ )
890 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
891
892 SoXtMultiSlider::buildWidget(form);
893 setBaseWidget(form);
894 }
895
896 SoXtSpecularColorMultiSlider::~SoXtSpecularColorMultiSlider() {}
897
898 SbBool
899 SoXtSpecularColorMultiSlider::validNodeType(SoNode *node)
900 {
901 return (node->isOfType(SoMaterial::getClassTypeId()));
902 }
903
904 void
905 SoXtSpecularColorMultiSlider::exportValuesToInventor()
906 {
907 float xX, xY, xZ;
908 const SbVec3f *soColor;
909
910 if ( _editNode ) {
911
912 // get values from x-windows sliders
913 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
914 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
915 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
916
917 // get values from inventor
918 soColor = ((SoMaterial *)_editNode)->specularColor.getValues( 0 );
919
920 if (soColor[0][0] != xX || soColor[0][1] != xY || soColor[0][2] != xZ) {
921 ((SoMaterial *)_editNode)->specularColor.setValue( xX, xY, xZ );
922 ((SoMaterial *)_editNode)->specularColor.setIgnored(FALSE);
923 }
924 }
925 }
926
927 void
928 SoXtSpecularColorMultiSlider::importValuesFromInventor()
929 {
930 const SbVec3f *soColor;
931
932 if ( _editNode ) {
933
934 // get values from inventor
935 soColor = ((SoMaterial *)_editNode)->specularColor.getValues( 0 );
936
937 // set values if necessary
938 if ( soColor[0][0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
939 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soColor[0][0] );
940 if ( soColor[0][1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
941 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( soColor[0][1] );
942 if ( soColor[0][2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
943 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( soColor[0][2] );
944 }
945 }
946
947 ///////////////////////////////////////////////////////////////////////////////
948 //
949 // Class: SoXtEmissiveColorMultiSlider
950 //
951 ///////////////////////////////////////////////////////////////////////////////
952 SoXtEmissiveColorMultiSlider::SoXtEmissiveColorMultiSlider(
953 Widget parent,
954 const char *name,
955 SbBool buildInsideParent)
956 : SoXtMultiSlider(
957 parent,
958 name,
959 buildInsideParent,
960 FALSE) // tell parent not to build just yet
961 {
962 _numSubComponents = 3;
963 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
964
965 Widget form = buildForm(getParentWidget());
966
967 _subComponentArray[0] = new SoXtSliderTool(
968 form, NULL, TRUE,
969 SO_UNIT_SLIDER_MINIMUM,
970 SO_UNIT_SLIDER_MAXIMUM );
971 _subComponentArray[1] = new SoXtSliderTool(
972 form, NULL, TRUE,
973 SO_UNIT_SLIDER_MINIMUM,
974 SO_UNIT_SLIDER_MAXIMUM );
975 _subComponentArray[2] = new SoXtSliderTool(
976 form, NULL, TRUE,
977 SO_UNIT_SLIDER_MINIMUM,
978 SO_UNIT_SLIDER_MAXIMUM );
979
980 for( int i = 0; i < _numSubComponents; i++ )
981 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
982
983 SoXtMultiSlider::buildWidget(form);
984 setBaseWidget(form);
985 }
986
987 SoXtEmissiveColorMultiSlider::~SoXtEmissiveColorMultiSlider() {}
988
989 SbBool
990 SoXtEmissiveColorMultiSlider::validNodeType(SoNode *node)
991 {
992 return (node->isOfType(SoMaterial::getClassTypeId()));
993 }
994
995 void
996 SoXtEmissiveColorMultiSlider::exportValuesToInventor()
997 {
998 float xX, xY, xZ;
999 const SbVec3f *soColor;
1000
1001 if ( _editNode ) {
1002
1003 // get values from x-windows sliders
1004 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
1005 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
1006 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
1007
1008 // get values from inventor
1009 soColor = ((SoMaterial *)_editNode)->emissiveColor.getValues( 0 );
1010
1011 if (soColor[0][0] != xX || soColor[0][1] != xY || soColor[0][2] != xZ) {
1012 ((SoMaterial *)_editNode)->emissiveColor.setValue( xX, xY, xZ );
1013 ((SoMaterial *)_editNode)->emissiveColor.setIgnored(FALSE);
1014 }
1015 }
1016 }
1017
1018 void
1019 SoXtEmissiveColorMultiSlider::importValuesFromInventor()
1020 {
1021 const SbVec3f *soColor;
1022
1023 if ( _editNode ) {
1024
1025 // get values from inventor
1026 soColor = ((SoMaterial *)_editNode)->emissiveColor.getValues( 0 );
1027
1028 // set values if necessary
1029 if ( soColor[0][0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
1030 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soColor[0][0] );
1031 if ( soColor[0][1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
1032 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( soColor[0][1] );
1033 if ( soColor[0][2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
1034 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( soColor[0][2] );
1035 }
1036 }
1037
1038 ///////////////////////////////////////////////////////////////////////////////
1039 //
1040 // Class: SoXtShininessMultiSlider
1041 //
1042 ///////////////////////////////////////////////////////////////////////////////
1043 SoXtShininessMultiSlider::SoXtShininessMultiSlider(
1044 Widget parent,
1045 const char *name,
1046 SbBool buildInsideParent)
1047 : SoXtMultiSlider(
1048 parent,
1049 name,
1050 buildInsideParent,
1051 FALSE) // tell parent not to build just yet
1052 {
1053 _numSubComponents = 1;
1054 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
1055
1056 Widget form = buildForm(getParentWidget());
1057
1058 _subComponentArray[0] = new SoXtSliderTool(
1059 form, NULL, TRUE,
1060 SO_UNIT_SLIDER_MINIMUM,
1061 SO_UNIT_SLIDER_MAXIMUM );
1062
1063 for( int i = 0; i < _numSubComponents; i++ )
1064 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
1065
1066 SoXtMultiSlider::buildWidget(form);
1067 setBaseWidget(form);
1068 }
1069
1070 SoXtShininessMultiSlider::~SoXtShininessMultiSlider() {}
1071
1072 SbBool
1073 SoXtShininessMultiSlider::validNodeType(SoNode *node)
1074 {
1075 return (node->isOfType(SoMaterial::getClassTypeId()));
1076 }
1077
1078 void
1079 SoXtShininessMultiSlider::exportValuesToInventor()
1080 {
1081 float xVal;
1082 const float *soShininess;
1083
1084 if ( _editNode ) {
1085
1086 // get values from x-windows sliders
1087 xVal = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
1088
1089 // get values from inventor
1090 soShininess = ((SoMaterial *)_editNode)->shininess.getValues( 0 );
1091
1092 if (soShininess[0] != xVal ) {
1093 ((SoMaterial *)_editNode)->shininess.setValue( xVal );
1094 ((SoMaterial *)_editNode)->shininess.setIgnored(FALSE);
1095 }
1096 }
1097 }
1098
1099 void
1100 SoXtShininessMultiSlider::importValuesFromInventor()
1101 {
1102 const float *soShininess;
1103
1104 if ( _editNode ) {
1105
1106 // get values from inventor
1107 soShininess = ((SoMaterial *)_editNode)->shininess.getValues( 0 );
1108
1109 // set values if necessary
1110 if ( soShininess[0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
1111 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soShininess[0] );
1112 }
1113 }
1114
1115 ///////////////////////////////////////////////////////////////////////////////
1116 //
1117 // Class: SoXtTransparencyMultiSlider
1118 //
1119 ///////////////////////////////////////////////////////////////////////////////
1120 SoXtTransparencyMultiSlider::SoXtTransparencyMultiSlider(
1121 Widget parent,
1122 const char *name,
1123 SbBool buildInsideParent)
1124 : SoXtMultiSlider(
1125 parent,
1126 name,
1127 buildInsideParent,
1128 FALSE) // tell parent not to build just yet
1129 {
1130 _numSubComponents = 1;
1131 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
1132
1133 Widget form = buildForm(getParentWidget());
1134
1135 _subComponentArray[0] = new SoXtSliderTool(
1136 form, NULL, TRUE,
1137 SO_UNIT_SLIDER_MINIMUM,
1138 SO_UNIT_SLIDER_MAXIMUM );
1139
1140 for( int i = 0; i < _numSubComponents; i++ )
1141 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
1142
1143 SoXtMultiSlider::buildWidget(form);
1144 setBaseWidget(form);
1145 }
1146
1147 SoXtTransparencyMultiSlider::~SoXtTransparencyMultiSlider() {}
1148
1149 SbBool
1150 SoXtTransparencyMultiSlider::validNodeType(SoNode *node)
1151 {
1152 return (node->isOfType(SoMaterial::getClassTypeId()));
1153 }
1154
1155 void
1156 SoXtTransparencyMultiSlider::exportValuesToInventor()
1157 {
1158 float xVal;
1159 const float *soTransparency;
1160
1161 if ( _editNode ) {
1162
1163 // get values from x-windows sliders
1164 xVal = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
1165
1166 // get values from inventor
1167 soTransparency = ((SoMaterial *)_editNode)->transparency.getValues( 0 );
1168
1169 if (soTransparency[0] != xVal ) {
1170 ((SoMaterial *)_editNode)->transparency.setValue( xVal );
1171 ((SoMaterial *)_editNode)->transparency.setIgnored(FALSE);
1172 }
1173 }
1174 }
1175
1176 void
1177 SoXtTransparencyMultiSlider::importValuesFromInventor()
1178 {
1179 const float *soTransparency;
1180
1181 if ( _editNode ) {
1182
1183 // get values from inventor
1184 soTransparency = ((SoMaterial *)_editNode)->transparency.getValues( 0 );
1185
1186 // set values if necessary
1187 if ( soTransparency[0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
1188 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soTransparency[0] );
1189 }
1190 }
1191
1192
1193 ///////////////////////////////////////////////////////////////////////////////
1194 //
1195 // Class: SoXtLightIntensityMultiSlider
1196 //
1197 ///////////////////////////////////////////////////////////////////////////////
1198 SoXtLightIntensityMultiSlider::SoXtLightIntensityMultiSlider(
1199 Widget parent,
1200 const char *name,
1201 SbBool buildInsideParent)
1202 : SoXtMultiSlider(
1203 parent,
1204 name,
1205 buildInsideParent,
1206 FALSE) // tell parent not to build just yet
1207 {
1208 _numSubComponents = 1;
1209 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
1210
1211 Widget form = buildForm(getParentWidget());
1212
1213 _subComponentArray[0] = new SoXtSliderTool(
1214 form, NULL, TRUE,
1215 SO_UNIT_SLIDER_MINIMUM,
1216 SO_UNIT_SLIDER_MAXIMUM );
1217
1218 for( int i = 0; i < _numSubComponents; i++ )
1219 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
1220
1221 SoXtMultiSlider::buildWidget(form);
1222 setBaseWidget(form);
1223 }
1224
1225 SoXtLightIntensityMultiSlider::~SoXtLightIntensityMultiSlider() {}
1226
1227 SbBool
1228 SoXtLightIntensityMultiSlider::validNodeType(SoNode *node)
1229 {
1230 return (node->isOfType(SoLight::getClassTypeId()));
1231 }
1232
1233 void
1234 SoXtLightIntensityMultiSlider::exportValuesToInventor()
1235 {
1236 float xVal;
1237 float soIntensity;
1238
1239 if ( _editNode ) {
1240
1241 // get values from x-windows sliders
1242 xVal = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
1243
1244 // get values from inventor
1245 soIntensity = ((SoLight *)_editNode)->intensity.getValue();
1246
1247 if (soIntensity != xVal ) {
1248 ((SoLight *)_editNode)->intensity.setValue( xVal );
1249 }
1250 }
1251 }
1252
1253 void
1254 SoXtLightIntensityMultiSlider::importValuesFromInventor()
1255 {
1256 float soIntensity;
1257
1258 if ( _editNode ) {
1259
1260 // get values from inventor
1261 soIntensity = ((SoLight *)_editNode)->intensity.getValue();
1262
1263 // set values if necessary
1264 if ( soIntensity != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
1265 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soIntensity );
1266 }
1267 }
1268
1269 ///////////////////////////////////////////////////////////////////////////////
1270 //
1271 // Class: SoXtLightColorMultiSlider
1272 //
1273 ///////////////////////////////////////////////////////////////////////////////
1274 SoXtLightColorMultiSlider::SoXtLightColorMultiSlider(
1275 Widget parent,
1276 const char *name,
1277 SbBool buildInsideParent)
1278 : SoXtMultiSlider(
1279 parent,
1280 name,
1281 buildInsideParent,
1282 FALSE) // tell parent not to build just yet
1283 {
1284 _numSubComponents = 3;
1285 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
1286
1287 Widget form = buildForm(getParentWidget());
1288
1289 _subComponentArray[0] = new SoXtSliderTool(
1290 form, NULL, TRUE,
1291 SO_UNIT_SLIDER_MINIMUM,
1292 SO_UNIT_SLIDER_MAXIMUM );
1293 _subComponentArray[1] = new SoXtSliderTool(
1294 form, NULL, TRUE,
1295 SO_UNIT_SLIDER_MINIMUM,
1296 SO_UNIT_SLIDER_MAXIMUM );
1297 _subComponentArray[2] = new SoXtSliderTool(
1298 form, NULL, TRUE,
1299 SO_UNIT_SLIDER_MINIMUM,
1300 SO_UNIT_SLIDER_MAXIMUM );
1301
1302 for( int i = 0; i < _numSubComponents; i++ )
1303 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
1304
1305 SoXtMultiSlider::buildWidget(form);
1306 setBaseWidget(form);
1307 }
1308
1309 SoXtLightColorMultiSlider::~SoXtLightColorMultiSlider() {}
1310
1311 SbBool
1312 SoXtLightColorMultiSlider::validNodeType(SoNode *node)
1313 {
1314 return (node->isOfType(SoLight::getClassTypeId()));
1315 }
1316
1317 void
1318 SoXtLightColorMultiSlider::exportValuesToInventor()
1319 {
1320 float xX, xY, xZ;
1321 SbColor soColor;
1322
1323 if ( _editNode ) {
1324
1325 // get values from x-windows sliders
1326 xX = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue();
1327 xY = ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue();
1328 xZ = ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue();
1329
1330 // get values from inventor
1331 soColor = ((SoLight *)_editNode)->color.getValue();
1332
1333 // copy into node if necessary
1334 if (soColor[0] != xX || soColor[1] != xY || soColor[2] != xZ) {
1335 ((SoLight *)_editNode)->color.setValue( xX, xY, xZ );
1336 }
1337 }
1338 }
1339
1340 void
1341 SoXtLightColorMultiSlider::importValuesFromInventor()
1342 {
1343 SbColor soColor;
1344
1345 if ( _editNode ) {
1346
1347 // get values from inventor
1348 soColor = ((SoLight *)_editNode)->color.getValue();
1349
1350 // set values if necessary
1351 if ( soColor[0] != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
1352 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soColor[0] );
1353 if ( soColor[1] != ((SoXtSliderTool *) _subComponentArray[1])->getSliderValue())
1354 ((SoXtSliderTool *) _subComponentArray[1])->toolSetValue( soColor[1] );
1355 if ( soColor[2] != ((SoXtSliderTool *) _subComponentArray[2])->getSliderValue())
1356 ((SoXtSliderTool *) _subComponentArray[2])->toolSetValue( soColor[2] );
1357 }
1358 }
1359 ///////////////////////////////////////////////////////////////////////////////
1360 //
1361 // Class: SoXtFovMultiSlider
1362 //
1363 ///////////////////////////////////////////////////////////////////////////////
1364 SoXtFovMultiSlider::SoXtFovMultiSlider(
1365 Widget parent,
1366 const char *name,
1367 SbBool buildInsideParent)
1368 : SoXtMultiSlider(
1369 parent,
1370 name,
1371 buildInsideParent,
1372 FALSE) // tell parent not to build just yet
1373 {
1374 _numSubComponents = 1;
1375 _subComponentArray = new SoXtSliderSetBase* [_numSubComponents];
1376
1377 Widget form = buildForm(getParentWidget());
1378
1379 _subComponentArray[0] = new SoXtSliderTool(
1380 form, NULL, TRUE,
1381 SO_FOV_SLIDER_MINIMUM,
1382 SO_FOV_SLIDER_MAXIMUM );
1383
1384 for( int i = 0; i < _numSubComponents; i++ )
1385 ((SoXtSliderTool *)_subComponentArray[i])->setMultiSlider( this );
1386
1387 SoXtMultiSlider::buildWidget(form);
1388 setBaseWidget(form);
1389 }
1390
1391 SoXtFovMultiSlider::~SoXtFovMultiSlider() {}
1392
1393 SbBool
1394 SoXtFovMultiSlider::validNodeType(SoNode *node)
1395 {
1396 return (node->isOfType(SoCamera::getClassTypeId()));
1397 }
1398
1399 void
1400 SoXtFovMultiSlider::exportValuesToInventor()
1401 {
1402 float xFov;
1403 float soFov;
1404
1405 if ( _editNode ) {
1406
1407 // get value from x-windows sliders
1408 xFov = ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue() * DEGREES_TO_RADIANS;
1409
1410 // get values from inventor
1411 if ( _editNode->isOfType(SoPerspectiveCamera::getClassTypeId()) )
1412 soFov = ((SoPerspectiveCamera *)_editNode)->heightAngle.getValue();
1413 else
1414 soFov = ((SoOrthographicCamera *)_editNode)->height.getValue();
1415
1416 // copy into node if necessary
1417 if (soFov != xFov ) {
1418 if (_editNode->isOfType(SoPerspectiveCamera::getClassTypeId()))
1419 ((SoPerspectiveCamera *)_editNode)->heightAngle.setValue( xFov );
1420 else
1421 ((SoOrthographicCamera *)_editNode)->height.setValue( xFov );
1422
1423 }
1424 }
1425 }
1426
1427 void
1428 SoXtFovMultiSlider::importValuesFromInventor()
1429 {
1430 float soFov;
1431
1432 if ( _editNode ) {
1433
1434 // get values from inventor
1435 if (_editNode->isOfType(SoPerspectiveCamera::getClassTypeId()))
1436 soFov = ((SoPerspectiveCamera *)_editNode)->heightAngle.getValue() * RADIANS_TO_DEGREES;
1437 else
1438 soFov = ((SoOrthographicCamera *)_editNode)->height.getValue();
1439
1440 // set values if necessary
1441 if (soFov != ((SoXtSliderTool *) _subComponentArray[0])->getSliderValue())
1442 ((SoXtSliderTool *) _subComponentArray[0])->toolSetValue( soFov );
1443 }
1444 }