Debian Codegraph @

apps/demos/noodle/noodle.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 // Generalized Cylinder program
38 //
39
40 #include <cstdio>
41 #include <cmath>
42 #include <cstdlib>
43 #include <unistd.h>
44
45 #include <Inventor/SoPickedPoint.h>
46 #include <Inventor/Xt/SoXt.h>
47 #include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
48 #include <Inventor/Xt/viewers/SoXtPlaneViewer.h>
49 #include <Inventor/actions/SoBoxHighlightRenderAction.h>
50 #include <Inventor/actions/SoSearchAction.h>
51 #include <Inventor/actions/SoWriteAction.h>
52 #include <Inventor/nodes/SoNode.h>
53 #include <Inventor/nodes/SoSelection.h>
54 #include <Inventor/nodes/SoShapeHints.h>
55
56 #include <Xm/Xm.h>
57 #include <Xm/AtomMgr.h>
58 #include <Xm/Form.h>
59 #include <Xm/Frame.h>
60 #include <Xm/Label.h>
61 #include <Xm/LabelG.h>
62 #include <Xm/Protocols.h>
63 #include <Xm/PushBG.h>
64 #include <Xm/RowColumn.h>
65 #include <Xm/ScrollBar.h>
66 #include <Xm/Text.h>
67 #include <Xm/ToggleBG.h>
68 #include <Xm/ToggleB.h>
69
70 #include "LineManip.h"
71 #include "GeneralizedCylinder.h"
72 #include "NoodleSlider.h"
73 #include "Interface.h"
74 #include "WorldInfo.h"
75
76 ////////////////////////////////////////////////////
77 // Print the usage message
78 //
79 static void
80 print_usage(const char *progname)
81 {
82 fprintf(stderr, "Usage: %s [ -h][-bg r g b] [infiles]\n", progname);
83 fprintf(stderr,
84 "\t-h Help (Print this message)\n"
85 "\t-bg rgb Background color triple for main renderArea\n"
86 "\tinfiles Inventor Files to read into Scene\n"
87 );
88 exit(0);
89 }
90
91 ////////////////////////////////////////////////////
92 // Parse the command line arguments
93 //
94 static void
95 parse_args(int argc, char **argv, char *&in_filename, SbColor in_bgColor )
96 {
97 int curArg = 1;
98 SbBool moreOpts = TRUE;
99
100 while ( moreOpts && curArg < argc ) {
101 if ( !strcmp(argv[curArg], "-bg")) {
102 curArg++;
103 float r, g, b;
104 sscanf( argv[curArg++], "%f", &r );
105 sscanf( argv[curArg++], "%f", &g );
106 sscanf( argv[curArg++], "%f", &b );
107 in_bgColor.setValue( r, g, b );
108 }
109 else if ( !strcmp(argv[curArg], "-h")) {
110 print_usage(argv[0]);
111 exit(0);
112 }
113 else if ( !strncmp(argv[curArg], "-", 1)) {
114 print_usage(argv[0]);
115 exit(0);
116 }
117 else
118 moreOpts = FALSE;
119 }
120
121 // Remaining argument should be fileName.
122 if (argc == curArg)
123 in_filename = NULL;
124 else
125 in_filename = strdup( argv[curArg] );
126 }
127
128 //
129 // These are defined in profile.c++
130 //
131 extern void clearProfilePoints();
132 extern void clearCrossSectionPoints();
133 extern void clearSpinePoints();
134 extern void clearTwistPoints();
135 extern void makeReverseSection();
136 extern void makeCircularSection();
137 extern void makeCircularSpine();
138 extern void makeSemiCircularSpine();
139
140 Widget closeProfileButton;
141 Widget closeSectionButton;
142 Widget closeSpineButton;
143 Widget closeTwistButton;
144
145 SoXtPlaneViewer *profilePlaneViewer;
146 SoXtPlaneViewer *crossSectionPlaneViewer;
147 SoXtExaminerViewer *spinePlaneViewer;
148 SoXtPlaneViewer *twistPlaneViewer;
149 SoXtExaminerViewer *examViewer;
150
151
152 //
153 // Callback for the close buttons
154 //
155 void
156 closeProfileCallback(Widget w, XtPointer data, XtPointer)
157 {
158 SbBool test = XmToggleButtonGetState( w );
159 Interface *stuff = (Interface *) data;
160 GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
161 if ( s != NULL )
162 s->profileClosed = test;
163
164 }
165 void
166 closeSectionCallback(Widget w, XtPointer data, XtPointer)
167 {
168 SbBool test = XmToggleButtonGetState( w );
169 Interface *stuff = (Interface *) data;
170 GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
171 if ( s != NULL )
172 s->crossSectionClosed = test;
173
174 }
175 void
176 closeSpineCallback(Widget w, XtPointer data, XtPointer)
177 {
178 SbBool test = XmToggleButtonGetState( w );
179 Interface *stuff = (Interface *) data;
180 GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
181 if ( s != NULL )
182 s->spineClosed = test;
183
184 }
185 void
186 closeTwistCallback(Widget w, XtPointer data, XtPointer)
187 {
188 SbBool test = XmToggleButtonGetState( w );
189 Interface *stuff = (Interface *) data;
190 GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
191 if ( s != NULL )
192 s->twistClosed = test;
193
194 }
195
196 //
197 // Callback for the clear buttons
198 //
199 void
200 clearProfileCallback(Widget, XtPointer data, XtPointer)
201 {
202 clearProfilePoints();
203
204 // Also, set the curve to not be closed. It's really irritating
205 // to have to clear, then un-close the polygon. So do it automatically
206 // Note that, all we have to do is set the toggle. By passing the
207 // third argument as TRUE, the closeCallback gets called for us!
208 Widget closeToggle = (Widget) data;
209 XmToggleButtonSetState( closeToggle, FALSE, TRUE );
210 }
211
212 void
213 clearSectionCallback(Widget, XtPointer data, XtPointer)
214 {
215 clearCrossSectionPoints();
216
217 // Also, set the curve to not be closed. It's really irritating
218 // to have to clear, then un-close the polygon. So do it automatically
219 // Note that, all we have to do is set the toggle. By passing the
220 // third argument as TRUE, the closeCallback gets called for us!
221 Widget closeToggle = (Widget) data;
222 XmToggleButtonSetState( closeToggle, FALSE, TRUE );
223 }
224
225 void
226 clearSpineCallback(Widget, XtPointer data, XtPointer)
227 {
228 clearSpinePoints();
229
230 // Also, set the curve to not be closed. It's really irritating
231 // to have to clear, then un-close the polygon. So do it automatically
232 // Note that, all we have to do is set the toggle. By passing the
233 // third argument as TRUE, the closeCallback gets called for us!
234 Widget closeToggle = (Widget) data;
235 XmToggleButtonSetState( closeToggle, FALSE, TRUE );
236 }
237
238 void
239 reverseSectionCallback(Widget, XtPointer, XtPointer)
240 {
241 makeReverseSection();
242 }
243
244 void
245 circularSectionCallback(Widget, XtPointer, XtPointer)
246 {
247 makeCircularSection();
248 }
249
250 void
251 circularSpineCallback(Widget, XtPointer, XtPointer)
252 {
253 makeCircularSpine();
254 }
255
256 void
257 semiCircularSpineCallback(Widget, XtPointer, XtPointer)
258 {
259 makeSemiCircularSpine();
260 }
261
262 void
263 clearTwistCallback(Widget, XtPointer data, XtPointer)
264 {
265 clearTwistPoints();
266
267 // Also, set the curve to not be closed. It's really irritating
268 // to have to clear, then un-close the polygon. So do it automatically
269 // Note that, all we have to do is set the toggle. By passing the
270 // third argument as TRUE, the closeCallback gets called for us!
271 Widget closeToggle = (Widget) data;
272 XmToggleButtonSetState( closeToggle, FALSE, TRUE );
273 }
274
275 void
276 quitCallback(Widget, void *intrf, void * )
277 {
278 Interface *interface = (Interface *) intrf;
279 interface->fileQuitEvent();
280 }
281
282 int
283 main(int argc, char **argv)
284 {
285 // Parse command line arguments. This may fill in the
286 // background color and fileName if successful.
287 char *in_filename = NULL;
288 SbColor in_bgColor(0,0,0);
289 parse_args(argc, argv, in_filename, in_bgColor );
290
291 // Initialize Inventor
292 Widget mainWindow = SoXt::init(argv[0]);
293 if (mainWindow == NULL) exit(1);
294
295 // Give title to main window. Include version number and date.
296 XtVaSetValues(mainWindow,XtNtitle,"noodle - V1.0.2 - 9.19.94",NULL);
297
298 // Initialize special classes.
299 GeneralizedCylinder::initClass();
300 LineManip2::initClass();
301
302 // Create an interface.
303 Interface *interface = new Interface();
304
305 // Tell mainWindow to call the quit callback when user double clicks
306 // upper left button or selects quit from main window menu.
307 // First, tell it to do nothing automatically
308 XtVaSetValues(mainWindow,XmNdeleteResponse, XmDO_NOTHING, NULL);
309 Atom vmDeleteAtom = XmInternAtom(XtDisplay(mainWindow),
310 "WM_DELETE_WINDOW", False);
311 XmAddWMProtocolCallback(mainWindow, vmDeleteAtom,
312 (XtCallbackProc) quitCallback, (XtPointer) interface);
313
314 // Create a structure to hold our scene and pass it to the interface.
315 WorldInfo *worldInfo = new WorldInfo;
316 interface->setWorldInfo( worldInfo );
317
318 // Set the filename and background color for the interface.
319 worldInfo->setFileName( in_filename );
320 interface->setBackgroundColor( in_bgColor );
321
322 // Read the scene into worldInfo, if it received a filename
323 // during parse_args. This will also set the current noodle to
324 // be the first noodle in found in the scene.
325 interface->readScene(NULL, TRUE);
326
327 // If the scene was empty, add a noodle to it.
328 GeneralizedCylinder *curNoodle = worldInfo->getCurrentNoodle();
329 if ( !curNoodle )
330 curNoodle = worldInfo->addNewNoodle();
331
332 // Create the form that surrounds the five viewers and the pulldown
333 // menus.
334 Arg resources[20];
335 int n = 0;
336 XtSetArg(resources[n], "width", 1200); n++;
337 XtSetArg(resources[n], "height", 800); n++;
338 Widget form = XmCreateForm(mainWindow, "form", resources, n); n = 0;
339
340 // Build the interface (pulldowns). Get back the topmost widget it creates.
341 Widget menuWidget = interface->build( form );
342
343 #define STRING(a) XmStringCreate(a,XmSTRING_DEFAULT_CHARSET)
344
345 // And the five viewers (one to edit the cross section, one to
346 // edit the spine, one to edit the profile (scale of the cross section as
347 // it travels along the spine), one to edit the twist of the crsoss section,
348 // and one to view the shaded geometry)
349
350
351 //*************
352 // View of complete 3d model
353 //*************
354 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
355 XtSetArg(resources[n], XmNtopWidget, menuWidget); n++;
356 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_POSITION); n++;
357 XtSetArg(resources[n], XmNleftPosition, 33); n++;
358 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
359 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
360 XtSetArg(resources[n], XmNbottomPosition, 45); n++;
361 Widget frame2 = XmCreateFrame(form, "renderAreaFrame", resources,
362 n); n = 0;
363
364 // Create the examiner viewer...
365 examViewer = new SoXtExaminerViewer(frame2, "noodleMainWindow");
366 examViewer->setBackgroundColor( interface->getBackgroundColor() );
367
368 interface->setMainViewer( examViewer );
369
370 // Set it as part of the callback data.
371 // Scene graph
372 examViewer->setSceneGraph( worldInfo->getWorldRoot() );
373 // Selection
374 examViewer->redrawOnSelectionChange( worldInfo->getSelectorNode() );
375 // Highlighting
376 SoBoxHighlightRenderAction *hlRA = new SoBoxHighlightRenderAction;
377 hlRA->setVisible(TRUE);
378 examViewer->setGLRenderAction(hlRA);
379
380 // How it looks/works
381 examViewer->setBorder(FALSE);
382 examViewer->setAnimationEnabled(FALSE);
383 examViewer->show();
384 XtManageChild(frame2);
385
386 //*************
387 // PROFILE VIEW
388 //*************
389 // Form containing viewer and controls
390 n = 0;
391 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
392 XtSetArg(resources[n], XmNtopWidget, menuWidget); n++;
393 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
394 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_POSITION); n++;
395 XtSetArg(resources[n], XmNrightPosition, 33); n++;
396 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
397 XtSetArg(resources[n], XmNbottomPosition, 45); n++;
398 Widget form1 = XmCreateForm(form, "profileViewForm", resources,
399 n); n = 0;
400
401 // Row Column - goes along bottom edge of form, contains a button.
402 XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
403 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
404 XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
405 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
406 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
407 Widget rc1 = XmCreateRowColumn(form1, "profileStuff",
408 resources, n); n = 0;
409 // Close profile button
410 XtSetArg(resources[n], XmNlabelString, STRING("Close Profile")); ++n;
411 closeProfileButton = XmCreateToggleButtonGadget(rc1, "closeProfile",
412 resources, n); n = 0;
413 XmToggleButtonSetState( closeProfileButton,
414 curNoodle->profileClosed.getValue(), FALSE );
415 XtAddCallback(closeProfileButton, XmNvalueChangedCallback,
416 closeProfileCallback, (XtPointer)interface);
417 XtManageChild(closeProfileButton);
418 XtManageChild(rc1);
419
420 // Clear profile button
421 XtSetArg(resources[n], XmNlabelString, STRING("Clear Profile")); ++n;
422 Widget clearProfileButton = XmCreatePushButtonGadget(rc1, "clearProfile",
423 resources, n); n = 0;
424 XtAddCallback(clearProfileButton, XmNactivateCallback,
425 clearProfileCallback, (XtPointer)closeProfileButton);
426 XtManageChild(clearProfileButton);
427 XtManageChild(rc1);
428
429 // Frame = top Section of Form
430 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
431 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
432 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
433 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
434 XtSetArg(resources[n], XmNbottomWidget, rc1); n++;
435 Widget frame1 = XmCreateFrame(form1, "profileViewFrame", resources,
436 n); n = 0;
437 // Put viewer in frame
438 profilePlaneViewer = new SoXtPlaneViewer(frame1);
439 profilePlaneViewer->setBorder(FALSE);
440 profilePlaneViewer->setDecoration(FALSE);
441 profilePlaneViewer->setViewing(FALSE);
442 profilePlaneViewer->show();
443 interface->setProfileViewer( profilePlaneViewer );
444 interface->setProfileCloseButton( closeProfileButton );
445 XtManageChild(frame1);
446
447 XtManageChild(form1);
448
449 //*************
450 // CROSS SECTION VIEW
451 //*************
452 // Form containing viewer and controls
453 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_POSITION); n++;
454 XtSetArg(resources[n], XmNtopPosition, 45); n++;
455 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
456 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_POSITION); n++;
457 XtSetArg(resources[n], XmNrightPosition, 33); n++;
458 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
459 Widget form3 = XmCreateForm(form, "crossSectionViewForm", resources,
460 n); n = 0;
461
462 // Row Column - goes along bottom edge of form, contains a button.
463 XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
464 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
465 XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
466 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
467 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
468 Widget rc3 = XmCreateRowColumn(form3, "crossSectionStuff",
469 resources, n); n = 0;
470 // Close crossSection button
471 XtSetArg(resources[n], XmNlabelString, STRING("Close Section")); ++n;
472 closeSectionButton = XmCreateToggleButtonGadget(rc3, "closeSection",
473 resources, n); n = 0;
474 XmToggleButtonSetState( closeSectionButton,
475 curNoodle->crossSectionClosed.getValue(), FALSE );
476 XtAddCallback(closeSectionButton, XmNvalueChangedCallback,
477 closeSectionCallback, (XtPointer)interface);
478 XtManageChild(closeSectionButton);
479 XtManageChild(rc3);
480
481 // Clear crossSection button
482 XtSetArg(resources[n], XmNlabelString, STRING("Clear Section")); ++n;
483 Widget clearSectionButton = XmCreatePushButtonGadget(rc3, "clearSection",
484 resources, n); n = 0;
485 XtAddCallback(clearSectionButton, XmNactivateCallback,
486 clearSectionCallback, (XtPointer)closeSectionButton);
487 XtManageChild(clearSectionButton);
488 XtManageChild(rc3);
489
490 // circular section button
491 XtSetArg(resources[n], XmNlabelString, STRING("Circle")); ++n;
492 Widget circularSectionButton = XmCreatePushButtonGadget(rc3,"circle",
493 resources, n); n = 0;
494 XtAddCallback(circularSectionButton, XmNactivateCallback,
495 circularSectionCallback, (XtPointer)circularSectionButton);
496 XtManageChild(circularSectionButton);
497 XtManageChild(rc3);
498
499 // reverse section button
500 XtSetArg(resources[n], XmNlabelString, STRING("Reverse Order")); ++n;
501 Widget reverseSectionButton = XmCreatePushButtonGadget(rc3,"circle",
502 resources, n); n = 0;
503 XtAddCallback(reverseSectionButton, XmNactivateCallback,
504 reverseSectionCallback, (XtPointer)reverseSectionButton);
505 XtManageChild(reverseSectionButton);
506 XtManageChild(rc3);
507
508 // Frame = top Section of Form
509 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
510 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
511 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
512 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
513 XtSetArg(resources[n], XmNbottomWidget, rc3); n++;
514 Widget frame3 = XmCreateFrame(form3, "crossSectionViewFrame", resources,
515 n); n = 0;
516 // Put viewer in frame
517 crossSectionPlaneViewer = new SoXtPlaneViewer(frame3);
518 crossSectionPlaneViewer->setBorder(FALSE);
519 crossSectionPlaneViewer->setDecoration(FALSE);
520 crossSectionPlaneViewer->setViewing(FALSE);
521 crossSectionPlaneViewer->show();
522 interface->setSectionViewer( crossSectionPlaneViewer );
523 interface->setSectionCloseButton( closeSectionButton );
524 XtManageChild(frame3);
525
526 XtManageChild(form3);
527
528
529 //*************
530 // SPINE VIEW
531 //*************
532 // Form containing viewer and controls
533 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_POSITION); n++;
534 XtSetArg(resources[n], XmNtopPosition, 45); n++;
535 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_POSITION); n++;
536 XtSetArg(resources[n], XmNleftPosition, 33); n++;
537 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_POSITION); n++;
538 XtSetArg(resources[n], XmNrightPosition, 66); n++;
539 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
540 Widget form4 = XmCreateForm(form, "spineViewForm", resources,
541 n); n = 0;
542
543 // Row Column - goes along bottom edge of form, contains a button.
544 XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
545 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
546 XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
547 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
548 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
549 Widget rc4 = XmCreateRowColumn(form4, "spineStuff",
550 resources, n); n = 0;
551 // Close spine button
552 XtSetArg(resources[n], XmNlabelString, STRING("Close Spine")); ++n;
553 closeSpineButton = XmCreateToggleButtonGadget(rc4, "closeSpine",
554 resources, n); n = 0;
555 XmToggleButtonSetState( closeSpineButton,
556 curNoodle->spineClosed.getValue(), FALSE );
557 XtAddCallback(closeSpineButton, XmNvalueChangedCallback,
558 closeSpineCallback, (XtPointer)interface);
559 XtManageChild(closeSpineButton);
560 XtManageChild(rc4);
561
562 // Clear spine button
563 XtSetArg(resources[n], XmNlabelString, STRING("Clear Spine")); ++n;
564 Widget clearSpineButton = XmCreatePushButtonGadget(rc4, "clearSpine",
565 resources, n); n = 0;
566 XtAddCallback(clearSpineButton, XmNactivateCallback,
567 clearSpineCallback, (XtPointer)closeSpineButton);
568 XtManageChild(clearSpineButton);
569 XtManageChild(rc4);
570
571 // circular spine button
572 XtSetArg(resources[n], XmNlabelString, STRING("Circle")); ++n;
573 Widget circularSpineButton = XmCreatePushButtonGadget(rc4,"circle",
574 resources, n); n = 0;
575 XtAddCallback(circularSpineButton, XmNactivateCallback,
576 circularSpineCallback, (XtPointer)circularSpineButton);
577 XtManageChild(circularSpineButton);
578 XtManageChild(rc4);
579
580 // Semi-circular spine button
581 XtSetArg(resources[n], XmNlabelString, STRING("Semi-circle")); ++n;
582 Widget semiCircularSpineButton = XmCreatePushButtonGadget(rc4, "semiCircle",
583 resources, n); n = 0;
584 XtAddCallback(semiCircularSpineButton, XmNactivateCallback,
585 semiCircularSpineCallback, (XtPointer)semiCircularSpineButton);
586 XtManageChild(semiCircularSpineButton);
587 XtManageChild(rc4);
588
589 // Frame = top Section of Form
590 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
591 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
592 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
593 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
594 XtSetArg(resources[n], XmNbottomWidget, rc4); n++;
595 Widget frame4 = XmCreateFrame(form4, "spineViewFrame", resources,
596 n); n = 0;
597 // Put viewer in frame
598 spinePlaneViewer = new SoXtExaminerViewer(frame4);
599 spinePlaneViewer->setBorder(FALSE);
600 spinePlaneViewer->setDecoration(FALSE);
601 spinePlaneViewer->setViewing(FALSE);
602 spinePlaneViewer->show();
603 interface->setSpineViewer( spinePlaneViewer );
604 interface->setSpineCloseButton( closeSpineButton );
605 XtManageChild(frame4);
606
607 XtManageChild(form4);
608
609 //*************
610 // TWIST VIEW
611 //*************
612 // Form containing viewer and controls
613 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_POSITION); n++;
614 XtSetArg(resources[n], XmNtopPosition, 45); n++;
615 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_POSITION); n++;
616 XtSetArg(resources[n], XmNleftPosition, 66); n++;
617 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
618 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
619 Widget form5 = XmCreateForm(form, "twistViewForm", resources,
620 n); n = 0;
621
622 // Row Column - goes along bottom edge of form, contains a button.
623 XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
624 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
625 XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
626 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
627 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
628 Widget rc5 = XmCreateRowColumn(form5, "twistStuff",
629 resources, n); n = 0;
630 // Close twist button
631 XtSetArg(resources[n], XmNlabelString, STRING("Close Twist")); ++n;
632 closeTwistButton = XmCreateToggleButtonGadget(rc5, "closeTwist",
633 resources, n); n = 0;
634 XmToggleButtonSetState( closeTwistButton,
635 curNoodle->twistClosed.getValue(), FALSE );
636 XtAddCallback(closeTwistButton, XmNvalueChangedCallback,
637 closeTwistCallback, (XtPointer)interface);
638 XtManageChild(closeTwistButton);
639 XtManageChild(rc5);
640
641 // Clear Twist button
642 XtSetArg(resources[n], XmNlabelString, STRING("Clear Twist")); ++n;
643 Widget clearTwistButton = XmCreatePushButtonGadget(rc5, "clearTwist",
644 resources, n); n = 0;
645 XtAddCallback(clearTwistButton, XmNactivateCallback,
646 clearTwistCallback, (XtPointer)closeTwistButton);
647 XtManageChild(clearTwistButton);
648 XtManageChild(rc5);
649
650 // Frame = top Section of Form
651 XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
652 XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
653 XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
654 XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
655 XtSetArg(resources[n], XmNbottomWidget, rc5); n++;
656 Widget frame5 = XmCreateFrame(form5, "twistViewFrame", resources,
657 n); n = 0;
658 // Put viewer in frame
659 twistPlaneViewer = new SoXtPlaneViewer(frame5);
660 twistPlaneViewer->setBorder(FALSE);
661 twistPlaneViewer->setDecoration(FALSE);
662 twistPlaneViewer->setViewing(FALSE);
663 twistPlaneViewer->show();
664 interface->setTwistViewer( twistPlaneViewer );
665 interface->setTwistCloseButton( closeTwistButton );
666 XtManageChild(frame5);
667
668 XtManageChild(form5);
669
670 XtManageChild(form);
671
672 examViewer->viewAll();
673
674 // Tell the interface to display info about the current noodle
675 // This includes parameters in the pulldowns and also info in the
676 // graph viewers.
677 interface->setPrimarySelection( curNoodle );
678
679 SoXt::show(mainWindow);
680
681 SoXt::mainLoop();
682 return 0;
683 }
684