File: noodle.c++

package info (click to toggle)
inventor 2.1.5-10-21
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 36,312 kB
  • sloc: ansic: 33,864; lisp: 7,361; cpp: 3,874; yacc: 369; sh: 359; perl: 234; awk: 141; makefile: 81; csh: 35; sed: 11
file content (684 lines) | stat: -rw-r--r-- 25,033 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
/*
 *
 *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  Further, this software is distributed without any warranty that it is
 *  free of the rightful claim of any third person regarding infringement
 *  or the like.  Any license provided herein, whether implied or
 *  otherwise, applies only to this software file.  Patent licenses, if
 *  any, provided herein do not apply to combinations of this program with
 *  other software, or any other product whatsoever.
 * 
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
 *  Mountain View, CA  94043, or:
 * 
 *  http://www.sgi.com 
 * 
 *  For further information regarding this notice, see: 
 * 
 *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
 *
 */
//
// Generalized Cylinder program
//

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <unistd.h>

#include <Inventor/SoPickedPoint.h>
#include <Inventor/Xt/SoXt.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#include <Inventor/Xt/viewers/SoXtPlaneViewer.h>
#include <Inventor/actions/SoBoxHighlightRenderAction.h>
#include <Inventor/actions/SoSearchAction.h>
#include <Inventor/actions/SoWriteAction.h>
#include <Inventor/nodes/SoNode.h>
#include <Inventor/nodes/SoSelection.h>
#include <Inventor/nodes/SoShapeHints.h>

#include <Xm/Xm.h>
#include <Xm/AtomMgr.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/LabelG.h>
#include <Xm/Protocols.h>
#include <Xm/PushBG.h>
#include <Xm/RowColumn.h>
#include <Xm/ScrollBar.h>
#include <Xm/Text.h>
#include <Xm/ToggleBG.h>
#include <Xm/ToggleB.h>

#include "LineManip.h"
#include "GeneralizedCylinder.h"
#include "NoodleSlider.h"
#include "Interface.h"
#include "WorldInfo.h"

////////////////////////////////////////////////////
// Print the usage message
//
static void
print_usage(const char *progname)
{
    fprintf(stderr, "Usage: %s [ -h][-bg r g b] [infiles]\n", progname);
    fprintf(stderr,
	    "\t-h           Help (Print this message)\n"
	    "\t-bg rgb      Background color triple for main renderArea\n"
	    "\tinfiles      Inventor Files to read into Scene\n"
	    );
    exit(0);
}

////////////////////////////////////////////////////
// Parse the command line arguments
//
static void
parse_args(int argc, char **argv, char *&in_filename, SbColor in_bgColor )
{
    int curArg = 1;
    SbBool moreOpts = TRUE;

    while ( moreOpts && curArg < argc ) {
	if ( !strcmp(argv[curArg], "-bg")) {
	    curArg++;
	    float r, g, b;
	    sscanf( argv[curArg++], "%f", &r );
	    sscanf( argv[curArg++], "%f", &g );
	    sscanf( argv[curArg++], "%f", &b );
	    in_bgColor.setValue( r, g, b );
	}
	else if ( !strcmp(argv[curArg], "-h")) {
	    print_usage(argv[0]);
	    exit(0);
	}
	else if ( !strncmp(argv[curArg], "-", 1)) {
	    print_usage(argv[0]);
	    exit(0);
	}
	else
	    moreOpts = FALSE;
    }

    // Remaining argument should be fileName.
    if (argc == curArg)
	in_filename = NULL;
    else
	in_filename = strdup( argv[curArg] );
}

//
// These are defined in profile.c++
//
extern void clearProfilePoints();
extern void clearCrossSectionPoints();
extern void clearSpinePoints();
extern void clearTwistPoints();
extern void makeReverseSection();
extern void makeCircularSection();
extern void makeCircularSpine();
extern void makeSemiCircularSpine();

Widget closeProfileButton;
Widget closeSectionButton;
Widget closeSpineButton;
Widget closeTwistButton;

SoXtPlaneViewer *profilePlaneViewer;
SoXtPlaneViewer *crossSectionPlaneViewer;
SoXtExaminerViewer *spinePlaneViewer;
SoXtPlaneViewer *twistPlaneViewer;
SoXtExaminerViewer *examViewer;


//
// Callback for the close buttons
//
void
closeProfileCallback(Widget w, XtPointer data, XtPointer)
{
    SbBool test = XmToggleButtonGetState( w );
    Interface  *stuff = (Interface *) data;
    GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
    if ( s != NULL )
	s->profileClosed = test;

}
void
closeSectionCallback(Widget w, XtPointer data, XtPointer)
{
    SbBool test = XmToggleButtonGetState( w );
    Interface  *stuff = (Interface *) data;
    GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
    if ( s != NULL )
	s->crossSectionClosed = test;

}
void
closeSpineCallback(Widget w, XtPointer data, XtPointer)
{
    SbBool test = XmToggleButtonGetState( w );
    Interface  *stuff = (Interface *) data;
    GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
    if ( s != NULL )
	s->spineClosed = test;

}
void
closeTwistCallback(Widget w, XtPointer data, XtPointer)
{
    SbBool test = XmToggleButtonGetState( w );
    Interface  *stuff = (Interface *) data;
    GeneralizedCylinder *s = stuff->getWorldInfo()->getCurrentNoodle();
    if ( s != NULL )
	s->twistClosed = test;

}

//
// Callback for the clear buttons
//
void
clearProfileCallback(Widget, XtPointer data, XtPointer)
{
    clearProfilePoints();

    // Also, set the curve to not be closed. It's really irritating
    // to have to clear, then un-close the polygon. So do it automatically
    // Note that, all we have to do is set the toggle. By passing the
    // third argument as TRUE, the closeCallback gets called for us!
    Widget closeToggle = (Widget) data;
    XmToggleButtonSetState( closeToggle, FALSE, TRUE );
}

void
clearSectionCallback(Widget, XtPointer  data, XtPointer)
{
    clearCrossSectionPoints();

    // Also, set the curve to not be closed. It's really irritating
    // to have to clear, then un-close the polygon. So do it automatically
    // Note that, all we have to do is set the toggle. By passing the
    // third argument as TRUE, the closeCallback gets called for us!
    Widget closeToggle = (Widget) data;
    XmToggleButtonSetState( closeToggle, FALSE, TRUE );
}

void
clearSpineCallback(Widget, XtPointer  data, XtPointer)
{
    clearSpinePoints();

    // Also, set the curve to not be closed. It's really irritating
    // to have to clear, then un-close the polygon. So do it automatically
    // Note that, all we have to do is set the toggle. By passing the
    // third argument as TRUE, the closeCallback gets called for us!
    Widget closeToggle = (Widget) data;
    XmToggleButtonSetState( closeToggle, FALSE, TRUE );
}

void
reverseSectionCallback(Widget, XtPointer, XtPointer)
{
    makeReverseSection();
}

void
circularSectionCallback(Widget, XtPointer, XtPointer)
{
    makeCircularSection();
}

void
circularSpineCallback(Widget, XtPointer, XtPointer)
{
    makeCircularSpine();
}

void
semiCircularSpineCallback(Widget, XtPointer, XtPointer)
{
    makeSemiCircularSpine();
}

void
clearTwistCallback(Widget, XtPointer  data, XtPointer)
{
    clearTwistPoints();

    // Also, set the curve to not be closed. It's really irritating
    // to have to clear, then un-close the polygon. So do it automatically
    // Note that, all we have to do is set the toggle. By passing the
    // third argument as TRUE, the closeCallback gets called for us!
    Widget closeToggle = (Widget) data;
    XmToggleButtonSetState( closeToggle, FALSE, TRUE );
}

void
quitCallback(Widget, void *intrf, void * )
{
    Interface *interface = (Interface *) intrf;
    interface->fileQuitEvent();
}

int
main(int argc, char **argv)
{
    // Parse command line arguments. This may fill in the 
    // background color and fileName if successful.
	char    *in_filename = NULL;
	SbColor in_bgColor(0,0,0);
	parse_args(argc, argv, in_filename, in_bgColor );

    // Initialize Inventor
	Widget mainWindow = SoXt::init(argv[0]);
	if (mainWindow == NULL) exit(1);

    // Give title to main window. Include version number and date.
        XtVaSetValues(mainWindow,XtNtitle,"noodle - V1.0.2 - 9.19.94",NULL);

    // Initialize special classes.
	GeneralizedCylinder::initClass();
	LineManip2::initClass();

    // Create an interface.  
	Interface *interface = new Interface();

    // Tell mainWindow to call the quit callback when user double clicks
    // upper left button or selects quit from main window menu.
	// First, tell it to do nothing automatically
        XtVaSetValues(mainWindow,XmNdeleteResponse, XmDO_NOTHING, NULL);
	Atom vmDeleteAtom = XmInternAtom(XtDisplay(mainWindow),
		"WM_DELETE_WINDOW", False);
	XmAddWMProtocolCallback(mainWindow, vmDeleteAtom,
		(XtCallbackProc) quitCallback, (XtPointer) interface);

    // Create a structure to hold our scene and pass it to the interface.
	WorldInfo *worldInfo = new WorldInfo;
	interface->setWorldInfo( worldInfo );

    // Set the filename and background color for the interface.
        worldInfo->setFileName( in_filename );
	interface->setBackgroundColor( in_bgColor );

    // Read the scene into worldInfo, if it received a filename
    // during parse_args. This will also set the current noodle to 
    // be the first noodle in found in the scene.
	interface->readScene(NULL, TRUE);

    // If the scene was empty, add a noodle to it.
	GeneralizedCylinder *curNoodle = worldInfo->getCurrentNoodle();
	if ( !curNoodle )
	    curNoodle = worldInfo->addNewNoodle();

    // Create the form that surrounds the five viewers and the pulldown
    // menus.
	Arg resources[20];
	int n = 0;
	XtSetArg(resources[n], "width", 1200); n++;
	XtSetArg(resources[n], "height", 800); n++;
	Widget form = XmCreateForm(mainWindow, "form", resources, n); n = 0;

    // Build the interface (pulldowns). Get back the topmost widget it creates.
	Widget menuWidget = interface->build( form );

#define STRING(a) XmStringCreate(a,XmSTRING_DEFAULT_CHARSET)
    
    // And the five viewers (one to edit the cross section, one to
    // edit the spine, one to edit the profile (scale of the cross section as
    // it travels along the spine), one to edit the twist of the crsoss section,
    // and one to view the shaded geometry)
    

    //*************
    // View of complete 3d model
    //*************
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(resources[n], XmNtopWidget, menuWidget); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNleftPosition, 33); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNbottomPosition, 45); n++;
    Widget frame2 = XmCreateFrame(form, "renderAreaFrame", resources,
				  n); n = 0;

    // Create the examiner viewer...
    examViewer = new SoXtExaminerViewer(frame2, "noodleMainWindow");
    examViewer->setBackgroundColor( interface->getBackgroundColor() );

    interface->setMainViewer( examViewer );

    // Set it as part of the callback data.
    // Scene graph
	examViewer->setSceneGraph( worldInfo->getWorldRoot() );
    // Selection
	examViewer->redrawOnSelectionChange( worldInfo->getSelectorNode() );
    // Highlighting
	SoBoxHighlightRenderAction *hlRA = new SoBoxHighlightRenderAction;
	hlRA->setVisible(TRUE);
	examViewer->setGLRenderAction(hlRA);

    // How it looks/works
	examViewer->setBorder(FALSE);
	examViewer->setAnimationEnabled(FALSE);
	examViewer->show();
    XtManageChild(frame2);
    
    //*************
    // PROFILE VIEW
    //*************
    // Form containing viewer and controls
    n = 0;
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(resources[n], XmNtopWidget, menuWidget); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNrightPosition, 33); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNbottomPosition, 45); n++;
    Widget form1 = XmCreateForm(form, "profileViewForm", resources,
				  n); n = 0;

    // Row Column - goes along bottom edge of form, contains a button.
    XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    Widget rc1 = XmCreateRowColumn(form1, "profileStuff",
				  resources, n); n = 0;
    // Close profile button
    XtSetArg(resources[n], XmNlabelString, STRING("Close Profile")); ++n;
    closeProfileButton = XmCreateToggleButtonGadget(rc1, "closeProfile",
						 resources, n); n = 0;
    XmToggleButtonSetState( closeProfileButton, 
				curNoodle->profileClosed.getValue(), FALSE );
    XtAddCallback(closeProfileButton, XmNvalueChangedCallback,
		  closeProfileCallback, (XtPointer)interface);
    XtManageChild(closeProfileButton);
    XtManageChild(rc1);

    // Clear profile button
    XtSetArg(resources[n], XmNlabelString, STRING("Clear Profile")); ++n;
    Widget clearProfileButton = XmCreatePushButtonGadget(rc1, "clearProfile",
						 resources, n); n = 0;
    XtAddCallback(clearProfileButton, XmNactivateCallback,
		  clearProfileCallback, (XtPointer)closeProfileButton);
    XtManageChild(clearProfileButton);
    XtManageChild(rc1);

    // Frame = top Section of Form
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(resources[n], XmNbottomWidget, rc1); n++;
    Widget frame1 = XmCreateFrame(form1, "profileViewFrame", resources,
				  n); n = 0;
    // Put viewer in frame
    profilePlaneViewer = new SoXtPlaneViewer(frame1);
    profilePlaneViewer->setBorder(FALSE);
    profilePlaneViewer->setDecoration(FALSE);
    profilePlaneViewer->setViewing(FALSE);
    profilePlaneViewer->show();
    interface->setProfileViewer( profilePlaneViewer );
    interface->setProfileCloseButton( closeProfileButton );
    XtManageChild(frame1);

    XtManageChild(form1);

    //*************
    // CROSS SECTION VIEW
    //*************
    // Form containing viewer and controls
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNtopPosition, 45); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNrightPosition, 33); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    Widget form3 = XmCreateForm(form, "crossSectionViewForm", resources,
				  n); n = 0;

    // Row Column - goes along bottom edge of form, contains a button.
    XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    Widget rc3 = XmCreateRowColumn(form3, "crossSectionStuff",
				  resources, n); n = 0;
    // Close crossSection button
    XtSetArg(resources[n], XmNlabelString, STRING("Close Section")); ++n;
    closeSectionButton = XmCreateToggleButtonGadget(rc3, "closeSection",
						 resources, n); n = 0;
    XmToggleButtonSetState( closeSectionButton, 
			    curNoodle->crossSectionClosed.getValue(), FALSE );
    XtAddCallback(closeSectionButton, XmNvalueChangedCallback,
		  closeSectionCallback, (XtPointer)interface);
    XtManageChild(closeSectionButton);
    XtManageChild(rc3);

    // Clear crossSection button
    XtSetArg(resources[n], XmNlabelString, STRING("Clear Section")); ++n;
    Widget clearSectionButton = XmCreatePushButtonGadget(rc3, "clearSection",
						 resources, n); n = 0;
    XtAddCallback(clearSectionButton, XmNactivateCallback,
		  clearSectionCallback, (XtPointer)closeSectionButton);
    XtManageChild(clearSectionButton);
    XtManageChild(rc3);

    // circular section button
    XtSetArg(resources[n], XmNlabelString, STRING("Circle")); ++n;
    Widget circularSectionButton = XmCreatePushButtonGadget(rc3,"circle",
						 resources, n); n = 0;
    XtAddCallback(circularSectionButton, XmNactivateCallback,
		  circularSectionCallback, (XtPointer)circularSectionButton);
    XtManageChild(circularSectionButton);
    XtManageChild(rc3);

    // reverse section button
    XtSetArg(resources[n], XmNlabelString, STRING("Reverse Order")); ++n;
    Widget reverseSectionButton = XmCreatePushButtonGadget(rc3,"circle",
						 resources, n); n = 0;
    XtAddCallback(reverseSectionButton, XmNactivateCallback,
		  reverseSectionCallback, (XtPointer)reverseSectionButton);
    XtManageChild(reverseSectionButton);
    XtManageChild(rc3);

    // Frame = top Section of Form
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(resources[n], XmNbottomWidget, rc3); n++;
    Widget frame3 = XmCreateFrame(form3, "crossSectionViewFrame", resources,
				  n); n = 0;
    // Put viewer in frame
    crossSectionPlaneViewer = new SoXtPlaneViewer(frame3);
    crossSectionPlaneViewer->setBorder(FALSE);
    crossSectionPlaneViewer->setDecoration(FALSE);
    crossSectionPlaneViewer->setViewing(FALSE);
    crossSectionPlaneViewer->show();
    interface->setSectionViewer( crossSectionPlaneViewer );
    interface->setSectionCloseButton( closeSectionButton );
    XtManageChild(frame3);

    XtManageChild(form3);


    //*************
    // SPINE VIEW
    //*************
    // Form containing viewer and controls
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNtopPosition, 45); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNleftPosition, 33); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNrightPosition, 66); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    Widget form4 = XmCreateForm(form, "spineViewForm", resources,
				  n); n = 0;

    // Row Column - goes along bottom edge of form, contains a button.
    XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    Widget rc4 = XmCreateRowColumn(form4, "spineStuff",
				  resources, n); n = 0;
    // Close spine button
    XtSetArg(resources[n], XmNlabelString, STRING("Close Spine")); ++n;
    closeSpineButton = XmCreateToggleButtonGadget(rc4, "closeSpine",
						 resources, n); n = 0;
    XmToggleButtonSetState( closeSpineButton, 
				curNoodle->spineClosed.getValue(), FALSE );
    XtAddCallback(closeSpineButton, XmNvalueChangedCallback,
		  closeSpineCallback, (XtPointer)interface);
    XtManageChild(closeSpineButton);
    XtManageChild(rc4);

    // Clear spine button
    XtSetArg(resources[n], XmNlabelString, STRING("Clear Spine")); ++n;
    Widget clearSpineButton = XmCreatePushButtonGadget(rc4, "clearSpine",
						 resources, n); n = 0;
    XtAddCallback(clearSpineButton, XmNactivateCallback,
		  clearSpineCallback, (XtPointer)closeSpineButton);
    XtManageChild(clearSpineButton);
    XtManageChild(rc4);

    // circular spine button
    XtSetArg(resources[n], XmNlabelString, STRING("Circle")); ++n;
    Widget circularSpineButton = XmCreatePushButtonGadget(rc4,"circle",
						 resources, n); n = 0;
    XtAddCallback(circularSpineButton, XmNactivateCallback,
		  circularSpineCallback, (XtPointer)circularSpineButton);
    XtManageChild(circularSpineButton);
    XtManageChild(rc4);

    // Semi-circular spine button
    XtSetArg(resources[n], XmNlabelString, STRING("Semi-circle")); ++n;
    Widget semiCircularSpineButton = XmCreatePushButtonGadget(rc4, "semiCircle",
						 resources, n); n = 0;
    XtAddCallback(semiCircularSpineButton, XmNactivateCallback,
		 semiCircularSpineCallback, (XtPointer)semiCircularSpineButton);
    XtManageChild(semiCircularSpineButton);
    XtManageChild(rc4);

    // Frame = top Section of Form
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(resources[n], XmNbottomWidget, rc4); n++;
    Widget frame4 = XmCreateFrame(form4, "spineViewFrame", resources,
				  n); n = 0;
    // Put viewer in frame
    spinePlaneViewer = new SoXtExaminerViewer(frame4);
    spinePlaneViewer->setBorder(FALSE);
    spinePlaneViewer->setDecoration(FALSE);
    spinePlaneViewer->setViewing(FALSE);
    spinePlaneViewer->show();
    interface->setSpineViewer( spinePlaneViewer );
    interface->setSpineCloseButton( closeSpineButton );
    XtManageChild(frame4);

    XtManageChild(form4);

    //*************
    // TWIST VIEW
    //*************
    // Form containing viewer and controls
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNtopPosition, 45); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_POSITION); n++;
    XtSetArg(resources[n], XmNleftPosition, 66); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    Widget form5 = XmCreateForm(form, "twistViewForm", resources,
				  n); n = 0;

    // Row Column - goes along bottom edge of form, contains a button.
    XtSetArg(resources[n], XmNorientation, XmHORIZONTAL); ++n;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNadjustLast, FALSE); ++n;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    Widget rc5 = XmCreateRowColumn(form5, "twistStuff",
				  resources, n); n = 0;
    // Close twist button
    XtSetArg(resources[n], XmNlabelString, STRING("Close Twist")); ++n;
    closeTwistButton = XmCreateToggleButtonGadget(rc5, "closeTwist",
						 resources, n); n = 0;
    XmToggleButtonSetState( closeTwistButton, 
				curNoodle->twistClosed.getValue(), FALSE );
    XtAddCallback(closeTwistButton, XmNvalueChangedCallback,
		  closeTwistCallback, (XtPointer)interface);
    XtManageChild(closeTwistButton);
    XtManageChild(rc5);

    // Clear Twist button
    XtSetArg(resources[n], XmNlabelString, STRING("Clear Twist")); ++n;
    Widget clearTwistButton = XmCreatePushButtonGadget(rc5, "clearTwist",
						 resources, n); n = 0;
    XtAddCallback(clearTwistButton, XmNactivateCallback,
		  clearTwistCallback, (XtPointer)closeTwistButton);
    XtManageChild(clearTwistButton);
    XtManageChild(rc5);

    // Frame = top Section of Form
    XtSetArg(resources[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(resources[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(resources[n], XmNbottomWidget, rc5); n++;
    Widget frame5 = XmCreateFrame(form5, "twistViewFrame", resources,
				  n); n = 0;
    // Put viewer in frame
    twistPlaneViewer = new SoXtPlaneViewer(frame5);
    twistPlaneViewer->setBorder(FALSE);
    twistPlaneViewer->setDecoration(FALSE);
    twistPlaneViewer->setViewing(FALSE);
    twistPlaneViewer->show();
    interface->setTwistViewer( twistPlaneViewer );
    interface->setTwistCloseButton( closeTwistButton );
    XtManageChild(frame5);

    XtManageChild(form5);

    XtManageChild(form);

    examViewer->viewAll();

    // Tell the interface to display info about the current noodle
    // This includes parameters in the pulldowns and also info in the
    // graph viewers.
	interface->setPrimarySelection( curNoodle );
    
    SoXt::show(mainWindow);

    SoXt::mainLoop();
    return 0;
}