Debian Codegraph @

07p/plaut04/src/gmainxt.c++

raw
1 #include <sstream>
2
3 #include <X11/Intrinsic.h>
4
5 #include <Xm/Xm.h>
6 #include <Xm/CascadeB.h>
7 #include <Xm/CascadeBG.h>
8 #include <Xm/ComboBox.h>
9 #include <Xm/DrawingA.h>
10 #include <Xm/DrawnB.h>
11 #include <Xm/DialogS.h>
12 #include <Xm/Form.h>
13 #include <Xm/Frame.h>
14 #include <Xm/FileSB.h>
15 #include <Xm/PushB.h>
16 #include <Xm/Label.h>
17 #include <Xm/LabelG.h>
18 #include <Xm/List.h>
19 #include <Xm/MessageB.h>
20 #include <Xm/Notebook.h>
21 #include <Xm/PanedW.h>
22 #include <Xm/PushB.h>
23 #include <Xm/PushBG.h>
24 #include <Xm/RowColumn.h>
25 #include <Xm/Scale.h>
26 #include <Xm/Separator.h>
27 #include <Xm/SeparatoG.h>
28 #include <Xm/SpinB.h>
29 #include <Xm/SSpinB.h>
30 #include <Xm/TextF.h>
31 #include <Xm/ToggleB.h>
32 #include <Xm/ToggleBG.h>
33 #include <Xm/Text.h>
34
35 #include <Inventor/Xt/SoXt.h>
36 #include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
37 #include <Inventor/Xt/SoXtMaterialEditor.h>
38
39 #include "gplaut04.h"
40 #include "solution.h"
41 #include "bifurcation.h"
42
43 #define LBL_OFFSET 4
44
45 #ifdef LESSTIF_VERSION
46 #include <Xm/ComboBoxP.h>
47 #ifndef XmNwrap
48 #define XmNwrap ((char *)&_XmStrings[19401])
49 #endif
50 #undef XmFONTLIST_DEFAULT_TAG
51 #define XmFONTLIST_DEFAULT_TAG NULL
52 #endif
53
54 #ifdef USE_EXAM_VIEWER
55 static SoXtExaminerViewer *renderArea;
56 #else
57 static SoXtRenderArea *renderArea;
58 #endif
59
60 SbBool printToPostScript (SoNode *root, const char *filename,
61 SoXtExaminerViewer *viewer, int printerDPI);
62
63 struct ViewerAndScene
64 {
65 SoXtExaminerViewer *viewer;
66 char *filename;
67 SoNode *scene;
68 } ;
69
70 ViewerAndScene *vwrAndScene;
71
72 static const unsigned long systemLinePatternValue[] =
73 {
74 0xfffff, 0x7777, 0x3333, 0xfafa, 0xeaea, 0xffcc, 0xffdc,0xff9c,0
75 };
76
77 static const char *systemLinePatternLookAndFeel[] =
78 {
79 "SOLID LINE", "--------", ". . . . . ", "_ . _ . _ .",
80 "_ . . _ . .", "_ . . . _", "___ _ ___ _", "____ __ ____",
81 "NULL "
82 };
83
84 GC gc;
85 Colormap colormap;
86 XColor black, grey, red, white, green, blue, exact;
87
88 Widget topform;
89 Widget xAxisList, yAxisList, zAxisList, labelsList, colorMethodSeletionList;
90 Widget satAniSpeedSlider, orbitAniSpeedSlider, dimButton;
91
92 typedef struct EditMenuItems
93 {
94 Widget *items;
95 int which;
96 } EditMenuItems;
97
98 EditMenuItems *typeMenuItems, *styleMenuItems, *coordMenuItems;
99
100 EditMenuItems *coordSystemMenuItems;
101 Widget fileDialog = NULL;
102
103 XmStringTable xList = (XmStringTable) 0 ;
104 XmStringTable yList = (XmStringTable) 0 ;
105 XmStringTable zList = (XmStringTable) 0 ;
106 XmStringTable lblList = (XmStringTable) 0 ;
107 XmStringTable clrMethodList= (XmStringTable) 0 ;
108
109 static void xListCallBack(Widget combo, XtPointer client_data, XtPointer call_data);
110 static void yListCallBack(Widget combo, XtPointer client_data, XtPointer call_data);
111 static void zListCallBack(Widget combo, XtPointer client_data, XtPointer call_data);
112 static void lblListCallBack(Widget combo, XtPointer client_data, XtPointer call_data);
113 static void fileDialogCB(Widget, XtPointer client_data, XtPointer data);
114 static void hidenDialogShell (Widget widget, XtPointer client_data, XtPointer call_data);
115 static void applyPreferDialogChangeAndUpdateScene(Widget widget, XtPointer client_data, XtPointer call_data);
116 static void closePreferDialogAndUpdateScene(Widget widget, XtPointer client_data, XtPointer call_data);
117 static void closePreferDialogAndGiveUpChange(Widget widget, XtPointer client_data, XtPointer call_data);
118 static void savePreferAndUpdateScene(Widget widget, XtPointer client_data, XtPointer call_data);
119 static void getFileName(int fileMode);
120 static void showAboutDialog();
121 static void createPreferDialog();
122 extern SoSeparator * createBoundingBox();
123 static void showAboutCB(Widget, XtPointer, XtPointer);
124
125 ////////////////////////////////////////////////////////////////////////
126 //
127 // functions
128 //
129 ////////////////////////////////////////////////////////////////////////
130
131 ////////////////////////////////////////////////////////////////////////
132 //
133 static void
134 orbitSpeedCB(Widget, XtPointer userData, XtPointer callData)
135 //
136 ////////////////////////////////////////////////////////////////////////
137 {
138 XmScaleCallbackStruct *data = (XmScaleCallbackStruct *) callData;
139 orbitSpeed = data->value/50.0; ///50.0; ///75.0;
140 if(orbitSpeed == 0.0) orbitSpeed = 0.0001;
141 updateScene();
142 }
143
144
145 ////////////////////////////////////////////////////////////////////////
146 //
147 static void
148 satSpeedCB(Widget, XtPointer userData, XtPointer callData)
149 //
150 ////////////////////////////////////////////////////////////////////////
151 {
152 XmScaleCallbackStruct *data = (XmScaleCallbackStruct *) callData;
153 satSpeed = data->value/100.0;
154 updateScene();
155 }
156
157 ////////////////////////////////////////////////////////////////////////
158 //
159 static void
160 numPeriodAnimatedCB(Widget, XtPointer userData, XtPointer callData)
161 //
162 ////////////////////////////////////////////////////////////////////////
163 {
164 XmComboBoxCallbackStruct *cbs = (XmComboBoxCallbackStruct *)callData;
165 char *myChoice = (char *) XmStringUnparse (cbs->item_or_text, XmFONTLIST_DEFAULT_TAG,
166 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
167
168 if ( strcmp(myChoice, "inf") == 0 )
169 {
170 numPeriodAnimated = -1;
171 }
172 else
173 {
174 numPeriodAnimated = atof(myChoice);
175 }
176
177 //cout <<" Num Period Animated "<<myChoice<<" "<<numPeriodAnimated;
178
179 updateScene();
180 }
181
182
183 ////////////////////////////////////////////////////////////////////////
184 //
185 static void
186 colorMethodSelectionCB(Widget, XtPointer userData, XtPointer callData)
187 //
188 ////////////////////////////////////////////////////////////////////////
189 {
190 XmComboBoxCallbackStruct *cbs = (XmComboBoxCallbackStruct *)callData;
191 char *myChoice = (char *) XmStringUnparse (cbs->item_or_text, XmFONTLIST_DEFAULT_TAG,
192 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
193 int choice = (int) cbs->item_position;
194
195 coloringMethod = (strcasecmp(myChoice,"COMP")==0) ? CL_COMPONENT:
196 ((strcasecmp(myChoice,"TYPE")==0) ? CL_ORBIT_TYPE :
197 ((strcasecmp(myChoice,"CURV")==0) ? CL_CURVE_NUMBER:
198 ((strcasecmp(myChoice,"BRAN")==0) ? CL_BRANCH_NUMBER:
199 ((strcasecmp(myChoice,"PONT")==0) ? CL_POINT_NUMBER :
200 ((strcasecmp(myChoice,"LABL")==0) ? CL_LABELS:
201 ((strcasecmp(myChoice,"STAB")==0) ? CL_STABILITY : choice - specialColorItems))))));
202 coloringMethodType[whichType] = coloringMethod;
203
204 updateScene();
205 }
206
207
208 ////////////////////////////////////////////////////////////////////////
209 //
210 static void
211 lineWidthCB(Widget, XtPointer userData, XtPointer callData)
212 //
213 ////////////////////////////////////////////////////////////////////////
214 {
215 Widget spin = (Widget) userData;
216 unsigned char type;
217 int position;
218
219 XtVaGetValues (spin, XmNspinBoxChildType, &type, XmNposition, &position, NULL);
220 #ifdef LESSTIF_VERSION
221 if (position < 10) {
222 position = 10;
223 XtVaSetValues (spin, XmNposition, position, NULL);
224 }
225 #endif
226 lineWidthScaler = position/10.0;
227 updateScene();
228 }
229
230
231 ////////////////////////////////////////////////////////////////////////
232 //
233 // This is called by Xt when a menu item is picked from the File menu.
234 //
235 static void
236 fileMenuPick(Widget, void *userData, XtPointer *)
237 //
238 ////////////////////////////////////////////////////////////////////////
239 {
240 int which = (long) userData;
241
242 switch (which)
243 {
244 case SAVE_ITEM:
245 getFileName(SAVE_ITEM);
246 break;
247
248 case QUIT_ITEM:
249 postDeals();
250 exit(0);
251 break;
252 case PRINT_ITEM:
253 getFileName(PRINT_ITEM);
254 break;
255 case OPEN_ITEM:
256 getFileName(OPEN_ITEM);
257 break;
258 default:
259 printf("UNKNOWN file menu item!!!\n"); break;
260 }
261 }
262
263
264 ////////////////////////////////////////////////////////////////////////
265 //
266 // This is called by Xt when a menu item is picked from the Edit menu.
267 //
268 static void
269 editMenuPick( Widget w, void *userData, XmAnyCallbackStruct *cb)
270 //
271 ////////////////////////////////////////////////////////////////////////
272 {
273 int which = (long) userData;
274
275 Arg args[1];
276 EditMenuItems *menuItems;
277 XtSetArg(args[0], XmNuserData, &menuItems);
278 XtGetValues(w, args, 1);
279 menuItems->which = which;
280 whichCoordSystem = which;
281 whichCoordSystemOld = whichCoordSystem;
282
283 updateScene();
284 }
285
286
287 ////////////////////////////////////////////////////////////////////////
288 //
289 // This is called by Xt when a menu item is picked from the TYPE menu.
290 //
291 static void
292 typeMenuPick(Widget w, void *userData, XmAnyCallbackStruct *cb)
293 //
294 ////////////////////////////////////////////////////////////////////////
295 {
296 int which = (long) userData;
297
298 // get the user data for this menu item.
299 Arg args[1];
300 EditMenuItems *menuItems;
301 XtSetArg(args[0], XmNuserData, &menuItems);
302 XtGetValues(w, args, 1);
303
304 menuItems->which = which;
305 whichType = which;
306
307 if ( whichType != whichTypeOld )
308 {
309 graphWidgetToggleSet = 0;
310 if( whichType != BIFURCATION )
311 {
312 setShow3D = setShow3DSol;
313 for(int i=0; i<11; ++i)
314 {
315 optBif[i] = options[i];
316 options[i] = optSol[i];
317 graphWidgetToggleSet |= options[i] << i;
318 }
319 }
320 else
321 {
322 setShow3D = setShow3DBif;
323 for(int i=0; i<11; ++i)
324 {
325 optSol[i] = options[i];
326 options[i] = optBif[i];
327 graphWidgetToggleSet |= options[i] << i;
328 }
329 }
330 coloringMethodType[whichType] = coloringMethod;
331 }
332
333 whichTypeOld = whichType;
334
335 setListValue();
336 XmString xString;
337 if (setShow3D)
338 xString = XmStringCreateLocalized((char *)"3D");
339 else
340 xString = XmStringCreateLocalized((char *)"2D");
341 XtVaSetValues (dimButton, XmNlabelString, xString, NULL);
342 XmStringFree(xString);
343
344 XtVaSetValues(xAxisList, XmNselectedPosition, xCoordIndices[0], NULL);
345 XtVaSetValues(yAxisList, XmNselectedPosition, yCoordIndices[0], NULL);
346 XtVaSetValues(zAxisList, XmNselectedPosition, zCoordIndices[0], NULL);
347
348 updateScene();
349 }
350
351
352 ////////////////////////////////////////////////////////////////////////
353 //
354 // This is called by Xt when a menu item is picked from the Option menu.
355 //
356 static void
357 optMenuPick(Widget widget, void *userData, XmAnyCallbackStruct *cb)
358 //
359 ////////////////////////////////////////////////////////////////////////
360 {
361 XmToggleButtonCallbackStruct *toggle = (XmToggleButtonCallbackStruct *)cb;
362 int which = (long) userData;
363
364 if (toggle->set == XmSET)
365 {
366 graphWidgetToggleSet |= (1 << which);
367 options[which] = true;
368 }
369 else
370 {
371 options[which] = false;
372 graphWidgetToggleSet &= ~(1 << which);
373 }
374
375 if(options[OPT_SAT_ANI])
376 XtVaSetValues (satAniSpeedSlider, XmNeditable, TRUE, NULL);
377 else
378 XtVaSetValues (satAniSpeedSlider, XmNeditable, FALSE, NULL);
379
380 if(options[OPT_PERIOD_ANI])
381 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, TRUE, NULL);
382 else
383 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, FALSE, NULL);
384
385 if(useR3B && (graphWidgetToggleSet & (1<<OPT_NORMALIZE_DATA)))
386 {
387 options[OPT_PRIMARY] = false;
388 options[OPT_LIB_POINTS] = false;
389 options[OPT_REF_PLAN] = false;
390 graphWidgetToggleSet &= ~(1 << OPT_REF_PLAN);
391 graphWidgetToggleSet &= ~(1 << OPT_LIB_POINTS);
392 graphWidgetToggleSet &= ~(1 << OPT_PRIMARY);
393 }
394
395 updateScene();
396 }
397
398
399 ////////////////////////////////////////////////////////////////////////
400 //
401 static void lessTifFixupComboBox(Widget w, XmStringTable strList, int nItems,
402 int visible, int width, int columns)
403 //
404 ////////////////////////////////////////////////////////////////////////
405 {
406 #ifdef LESSTIF_VERSION
407 Widget list = CB_List(w);
408 XmListDeleteAllItems(list);
409 for (int i = 0; i < nItems; i++)
410 XmListAddItem(list,strList[i],0);
411 XtVaSetValues(w,
412 XmNvisibleItemCount, visible,
413 XmNwidth, width,
414 XmNcolumns, columns,
415 NULL);
416 XmComboBoxUpdate(w);
417 #endif
418 }
419
420
421 ///////////////////////////////////////////////////////////////////////////
422 //
423 void
424 setListValue()
425 //
426 ///////////////////////////////////////////////////////////////////////////
427 {
428 int nar;
429 int count = labels.size();
430 lblList = (XmStringTable) XtMalloc(count * sizeof (XmString *));
431 for (int i = 0; i < count; i++)
432 lblList[i] = XmStringCreateLocalized (const_cast<char *>(labels[i].c_str()));
433
434 if(whichType != BIFURCATION)
435 {
436 xCoordIndices = dai.solX;
437 yCoordIndices = dai.solY;
438 zCoordIndices = dai.solZ;
439 nar = mySolNode->nar();
440 }
441 else
442 {
443 xCoordIndices = dai.bifX;
444 yCoordIndices = dai.bifY;
445 zCoordIndices = dai.bifZ;
446 nar = myBifNode->nar();
447 }
448
449 XtVaSetValues(xAxisList, XmNitems, xList, XmNitemCount, nar, NULL);
450 XtVaSetValues(yAxisList, XmNitems, yList, XmNitemCount, nar, NULL);
451 XtVaSetValues(zAxisList, XmNitems, zList, XmNitemCount, nar, NULL);
452 lessTifFixupComboBox(xAxisList, xList, nar, 10, 60, 2);
453 lessTifFixupComboBox(yAxisList, yList, nar, 10, 60, 2);
454 lessTifFixupComboBox(zAxisList, zList, nar, 10, 60, 2);
455
456 coloringMethodList.clear();
457 coloringMethodList.push_back("BRAN");
458 coloringMethodList.push_back("STAB");
459 coloringMethodList.push_back("PONT");
460 coloringMethodList.push_back("CURV");
461
462 specialColorItems = 4;
463
464 if(whichType != BIFURCATION)
465 {
466 coloringMethodList.push_back("TYPE");
467 coloringMethodList.push_back("LABL");
468 coloringMethodList.push_back("COMP");
469 specialColorItems = 7;
470 }
471 for(int i=0; i<nar; ++i)
472 {
473 std::stringstream s;
474 s << i;
475 coloringMethodList.push_back(s.str());
476 }
477 if(whichType != BIFURCATION)
478 {
479 for(int i=0; i<mySolNode->npar(); ++i)
480 {
481 std::stringstream s;
482 s << "PAR(" << mySolNode->parID(i)+1 << ")";
483 coloringMethodList.push_back(s.str());
484 }
485
486 }
487
488 count = coloringMethodList.size();
489 for (int i = 0; i < count; ++i)
490 clrMethodList[i] = XmStringCreateLocalized (const_cast<char *>(coloringMethodList[i].c_str()));
491 XtVaSetValues(colorMethodSeletionList, XmNitems, clrMethodList,
492 XmNitemCount, count, NULL);
493 long nItems = labels.size();
494 XtVaSetValues(labelsList, XmNitems, lblList, XmNitemCount, nItems, NULL);
495 lessTifFixupComboBox(colorMethodSeletionList, clrMethodList,
496 count, 10, 80, 5);
497 lessTifFixupComboBox(labelsList, lblList, nItems, 10, 86, 6);
498
499 if(setShow3D)
500 XtSetSensitive (zAxisList, true);
501 else
502 {
503 zCoordIndices.clear();
504 zCoordIndices.push_back(-1);
505 XtSetSensitive (zAxisList, false);
506 }
507
508 }
509
510
511 ////////////////////////////////////////////////////////////////////////
512 //
513 // This is called by Xt when a menu item is picked from the STYLE menu.
514 //
515 static void
516 styleMenuPick(Widget w, void *userData, XmAnyCallbackStruct *cb)
517 //
518 ////////////////////////////////////////////////////////////////////////
519 {
520 int which = (long) userData;
521
522 // get the user data for this menu item.
523 Arg args[1];
524 EditMenuItems *menuItems;
525 XtSetArg(args[0], XmNuserData, &menuItems);
526 XtGetValues(w, args, 1);
527
528 menuItems->which = which;
529 whichStyle = which;
530 whichStyleOld = whichStyle;
531
532 updateScene();
533 }
534
535
536 ////////////////////////////////////////////////////////////////////////
537 //
538 // This is called by Xt when a menu item is picked from the STYLE menu.
539 //
540 static void
541 coordMenuPick(Widget w, void *userData, XmAnyCallbackStruct *cb)
542 //
543 ////////////////////////////////////////////////////////////////////////
544 {
545 int which = (long) userData;
546
547 // get the user data for this menu item.
548 Arg args[1];
549 EditMenuItems *menuItems;
550 XtSetArg(args[0], XmNuserData, &menuItems);
551 XtGetValues(w, args, 1);
552
553 menuItems->which = which;
554
555 if(which == DRAW_TICKER)
556 blDrawTicker = !blDrawTicker ;
557 else
558 {
559 whichCoord = which;
560 whichCoordOld = whichCoord;
561 }
562
563 updateScene();
564 }
565
566
567 ////////////////////////////////////////////////////////////////////////
568 //
569 // This is called by Xt just before the TYPE menu is displayed.
570 //
571 static void
572 typeMenuDisplay(Widget, void *userData, XtPointer)
573 //
574 ////////////////////////////////////////////////////////////////////////
575 {
576 EditMenuItems *menuItems = (EditMenuItems *) userData;
577
578 TOGGLE_OFF(menuItems->items[SOLUTION]);
579 TOGGLE_OFF(menuItems->items[BIFURCATION]);
580
581 TOGGLE_ON(menuItems->items[menuItems->which]);
582
583 XtSetSensitive (menuItems->items[SOLUTION], TRUE);
584 XtSetSensitive (menuItems->items[BIFURCATION], TRUE);
585
586 if(mySolNode->numOrbits() == 0)
587 XtSetSensitive (menuItems->items[SOLUTION], FALSE);
588
589 if(myBifNode->totalNumPoints() == 0)
590 XtSetSensitive (menuItems->items[BIFURCATION], FALSE);
591
592 }
593
594
595 ////////////////////////////////////////////////////////////////////////
596 //
597 // This is called by Xt just before the STYLE menu is displayed.
598 //
599 static void
600 styleMenuDisplay(Widget, void *userData, XtPointer)
601 //
602 ////////////////////////////////////////////////////////////////////////
603 {
604 EditMenuItems *menuItems = (EditMenuItems *) userData;
605 TOGGLE_OFF(menuItems->items[LINE]);
606 TOGGLE_OFF(menuItems->items[TUBE]);
607 TOGGLE_OFF(menuItems->items[SURFACE]);
608 TOGGLE_OFF(menuItems->items[MESH_POINTS]);
609 TOGGLE_OFF(menuItems->items[ALL_POINTS]);
610
611 if((useR3B && whichCoordSystem != ROTATING_F) || whichType == BIFURCATION)
612 {
613 XtSetSensitive (menuItems->items[SURFACE], false);
614 XtSetSensitive (menuItems->items[MESH_POINTS], false);
615 XtSetSensitive (menuItems->items[ALL_POINTS], false);
616 if(useR3B && (menuItems->which == SURFACE || menuItems->which == MESH_POINTS || menuItems->which == ALL_POINTS))
617 menuItems->which = LINE;
618 }
619 else
620 {
621 XtSetSensitive (menuItems->items[SURFACE], true);
622 XtSetSensitive (menuItems->items[MESH_POINTS], true);
623 XtSetSensitive (menuItems->items[ALL_POINTS], true);
624 }
625
626 TOGGLE_ON(menuItems->items[menuItems->which]);
627
628 }
629
630
631 ////////////////////////////////////////////////////////////////////////
632 //
633 // This is called by Xt just before the STYLE menu is displayed.
634 //
635 static void
636 coordMenuDisplay(Widget, void *userData, XtPointer)
637 //
638 ////////////////////////////////////////////////////////////////////////
639 {
640 EditMenuItems *menuItems = (EditMenuItems *) userData;
641
642 if(menuItems->which == DRAW_TICKER)
643 {
644 if(blDrawTicker)
645 XmToggleButtonSetState(menuItems->items[menuItems->which], TRUE, FALSE);
646 else
647 XmToggleButtonSetState(menuItems->items[menuItems->which], FALSE, FALSE);
648 }
649 else
650 {
651 TOGGLE_OFF(menuItems->items[NO_COORD]);
652 TOGGLE_OFF(menuItems->items[COORDORIGIN]);
653 TOGGLE_OFF(menuItems->items[LEFTBACK]);
654 TOGGLE_OFF(menuItems->items[LEFTAHEAD]);
655 TOGGLE_OFF(menuItems->items[COORD_AT_ORIGIN]);
656 TOGGLE_OFF(menuItems->items[DRAW_TICKER]);
657
658 TOGGLE_ON(menuItems->items[menuItems->which]);
659 if(blDrawTicker)
660 XmToggleButtonSetState(menuItems->items[DRAW_TICKER], TRUE, FALSE);
661 }
662 }
663
664
665 ////////////////////////////////////////////////////////////////////////
666 //
667 // This is called by Xt just before the Edit menu is displayed.
668 //
669 static void
670 centerMenuDisplay(Widget, void *userData, XtPointer)
671 //
672 ////////////////////////////////////////////////////////////////////////
673 {
674 EditMenuItems *menuItems = (EditMenuItems *) userData;
675
676 TOGGLE_OFF(menuItems->items[ROTATING_F]);
677 TOGGLE_OFF(menuItems->items[INERTIAL_B]);
678 TOGGLE_OFF(menuItems->items[INERTIAL_S]);
679 TOGGLE_OFF(menuItems->items[INERTIAL_E]);
680 TOGGLE_ON(menuItems->items[menuItems->which]);
681
682 if(whichType == SOLUTION)
683 {
684 XtSetSensitive (menuItems->items[ROTATING_F], true);
685 XtSetSensitive (menuItems->items[INERTIAL_B], true);
686 XtSetSensitive (menuItems->items[INERTIAL_E], true);
687 XtSetSensitive (menuItems->items[INERTIAL_S], true);
688 }
689 else
690 {
691 XtSetSensitive (menuItems->items[ROTATING_F], false);
692 XtSetSensitive (menuItems->items[INERTIAL_B], false);
693 XtSetSensitive (menuItems->items[INERTIAL_S], false);
694 XtSetSensitive (menuItems->items[INERTIAL_E], false);
695
696 }
697
698 }
699
700
701 ////////////////////////////////////////////////////////////////////////
702 //
703 // This is called by Xt just before the TYPE menu is displayed.
704 //
705 static void
706 optMenuDisplay(Widget, void *userData, XtPointer)
707 //
708 ////////////////////////////////////////////////////////////////////////
709 {
710 EditMenuItems *menuItems = (EditMenuItems *) userData;
711
712 for (unsigned int i = 0; i < XtNumber (graphWidgetItems); i++)
713 {
714 if (!useR3B && (i == OPT_PRIMARY || i == OPT_LIB_POINTS)) continue;
715 if (graphWidgetToggleSet & (1<<i))
716 {
717 XmToggleButtonSetState(menuItems->items[i], TRUE, FALSE);
718 }
719 else
720 {
721 XmToggleButtonSetState(menuItems->items[i], FALSE, FALSE);
722 }
723 }
724
725 if(useR3B)
726 {
727 if(!blMassDependantOption)
728 {
729 XtSetSensitive (menuItems->items[OPT_PRIMARY], false);
730 XtSetSensitive (menuItems->items[OPT_LIB_POINTS], false);
731 }
732 else
733 {
734 XtSetSensitive (menuItems->items[OPT_PRIMARY], true);
735 XtSetSensitive (menuItems->items[OPT_LIB_POINTS], true);
736 }
737
738 if(graphWidgetToggleSet & (1<<OPT_NORMALIZE_DATA))
739 {
740 XtSetSensitive (menuItems->items[OPT_PRIMARY], false);
741 XtSetSensitive (menuItems->items[OPT_LIB_POINTS], false);
742 XtSetSensitive (menuItems->items[OPT_REF_PLAN], false);
743 XmToggleButtonSetState(menuItems->items[OPT_PRIMARY], FALSE, FALSE);
744 XmToggleButtonSetState(menuItems->items[OPT_LIB_POINTS], FALSE, FALSE);
745 XmToggleButtonSetState(menuItems->items[OPT_REF_PLAN], FALSE, FALSE);
746 }
747 else
748 {
749 XtSetSensitive (menuItems->items[OPT_PRIMARY], true);
750 XtSetSensitive (menuItems->items[OPT_PRIMARY], true);
751 XtSetSensitive (menuItems->items[OPT_REF_PLAN], true);
752 }
753 }
754
755 if(whichType == BIFURCATION)
756 {
757 XtUnmanageChild(menuItems->items[OPT_PERIOD_ANI]);
758 XtUnmanageChild(menuItems->items[OPT_SAT_ANI]);
759 XtManageChild(menuItems->items[OPT_DRAW_LABELS]);
760 XtManageChild(menuItems->items[OPT_LABEL_NUMBERS]);
761 XtSetSensitive (menuItems->items[OPT_LABEL_NUMBERS],
762 (graphWidgetToggleSet & (1<<OPT_DRAW_LABELS)) != 0);
763 }
764 else
765 {
766 XtUnmanageChild(menuItems->items[OPT_DRAW_LABELS]);
767 XtUnmanageChild(menuItems->items[OPT_LABEL_NUMBERS]);
768 XtManageChild(menuItems->items[OPT_PERIOD_ANI]);
769 XtManageChild(menuItems->items[OPT_SAT_ANI]);
770 }
771 }
772
773
774 // A push item has no on/off state - it merely gets selected
775 #define PUSH_ITEM(ITEM,NAME,KONST,FUNC) \
776 ITEM = XtCreateManagedWidget(NAME, \
777 xmPushButtonGadgetClass, pulldown, args, n); \
778 XtAddCallback(ITEM, XmNactivateCallback,\
779 (XtCallbackProc) FUNC, \
780 (XtPointer) KONST)
781
782 // A toggle item has on/off state
783 #define TOGGLE_ITEM(ITEM,NAME,KONST,FUNC) \
784 ITEM = XtCreateManagedWidget(NAME, \
785 xmToggleButtonGadgetClass, pulldown, args, n); \
786 XtAddCallback(ITEM, XmNvalueChangedCallback,\
787 (XtCallbackProc) FUNC, \
788 (XtPointer) KONST)
789
790 // A separator draws a line between menu items
791 #define SEP_ITEM(NAME) \
792 (void) XtCreateManagedWidget("separator", \
793 xmSeparatorGadgetClass, pulldown, NULL, 0)
794
795 ////////////////////////////////////////////////////////////////////////
796 //
797 // This creates the File menu and all its items.
798 //
799 static Widget
800 buildFileMenu(Widget menubar)
801 //
802 ////////////////////////////////////////////////////////////////////////
803 {
804 Widget items[4];
805 Widget pulldown;
806 Arg args[8];
807 int n;
808
809 Arg popupargs[2];
810 int popupn = 0;
811
812 pulldown = XmCreatePulldownMenu(menubar, (char *)"fileMenu", popupargs, popupn);
813
814 // Accelerators are keyboard shortcuts for the menu items
815 const char *openAccel = "Ctrl<Key>o";
816 const char *saveAccel = "Ctrl<Key>s";
817 const char *quitAccel = "Ctrl<Key>q";
818 XmString openAccelText = XmStringCreate((char *)"Ctrl+o", (char *)XmSTRING_DEFAULT_CHARSET);
819 XmString saveAccelText = XmStringCreate((char *)"Ctrl+s", (char *)XmSTRING_DEFAULT_CHARSET);
820 XmString printAccelText = XmStringCreate((char *)"Ctrl+p", (char *)XmSTRING_DEFAULT_CHARSET);
821 XmString quitAccelText = XmStringCreate((char *)"Ctrl+q", (char *)XmSTRING_DEFAULT_CHARSET);
822 n = 0;
823 XtSetArg(args[n], XmNaccelerator, openAccel); n++;
824 XtSetArg(args[n], XmNacceleratorText, openAccelText); n++;
825 PUSH_ITEM(items[0], "Open...", OPEN_ITEM, fileMenuPick);
826
827 n = 0;
828 XtSetArg(args[n], XmNaccelerator, saveAccel); n++;
829 XtSetArg(args[n], XmNacceleratorText, saveAccelText); n++;
830 PUSH_ITEM(items[1], "Export...", SAVE_ITEM, fileMenuPick);
831
832 n = 0;
833 const char *printAccel = "Ctrl<Key>p";
834 XtSetArg(args[n], XmNaccelerator, printAccel); n++;
835 XtSetArg(args[n], XmNacceleratorText, printAccelText); n++;
836 PUSH_ITEM(items[2], "Print...", PRINT_ITEM, fileMenuPick);
837
838 SEP_ITEM("separator");
839
840 n = 0;
841 XtSetArg(args[n], XmNaccelerator, quitAccel); n++;
842 XtSetArg(args[n], XmNacceleratorText, quitAccelText); n++;
843 PUSH_ITEM(items[3], "Quit", QUIT_ITEM, fileMenuPick);
844 XtManageChildren(items, 4);
845
846 return pulldown;
847 }
848
849
850 ////////////////////////////////////////////////////////////////////////
851 //
852 // This creates the Help menu and all its items.
853 //
854 static Widget
855 buildHelpMenu(Widget menubar)
856 //
857 ////////////////////////////////////////////////////////////////////////
858 {
859 Widget items[2];
860 Widget pulldown;
861 Arg args[8];
862 int n;
863
864 // Tell motif to create the menu in the popup plane
865 Arg popupargs[2];
866 int popupn = 0;
867
868 pulldown = XmCreatePulldownMenu(menubar, (char *)"helpMenu", popupargs, popupn);
869
870 n = 0;
871 PUSH_ITEM(items[0], "About", ITEM_ONE, showAboutDialog);
872
873 SEP_ITEM("separator");
874
875 n = 0;
876 PUSH_ITEM(items[1], "HELP", ITEM_TWO, showHelpDialog);
877 XtManageChildren(items, 2);
878
879 return pulldown;
880 }
881
882
883 ////////////////////////////////////////////////////////////////////////
884 //
885 // This creates the TYPE menu and all its items.
886 //
887 static Widget
888 buildOptionMenu(Widget menubar)
889 //
890 ////////////////////////////////////////////////////////////////////////
891 {
892 Widget pulldown;
893 Arg args[13];
894 int n;
895
896 EditMenuItems *menuItems = new EditMenuItems;
897 menuItems->items = new Widget[XtNumber (graphWidgetItems)];
898
899 // Tell motif to create the menu in the popup plane
900 Arg popupargs[XtNumber (graphWidgetItems)];
901 int popupn = 0;
902
903 pulldown = XmCreatePulldownMenu(menubar, (char *)"optionMenu", popupargs, popupn);
904
905 XtAddCallback(pulldown, XmNmapCallback,
906 (XtCallbackProc) optMenuDisplay, (XtPointer) menuItems);
907
908 n = 0;
909 int mq = 0;
910 XtSetArg(args[n], XmNuserData, menuItems); n++;
911 if(!useR3B)
912 {
913 TOGGLE_ITEM(menuItems->items[OPT_PERIOD_ANI], "Hightlight Orbit", OPT_PERIOD_ANI, optMenuPick); ++mq;
914 TOGGLE_ITEM(menuItems->items[OPT_SAT_ANI], "Orbit Animation", OPT_SAT_ANI, optMenuPick); ++mq;
915 }
916 TOGGLE_ITEM(menuItems->items[OPT_REF_PLAN], "Draw Reference Plane", OPT_REF_PLAN, optMenuPick); ++mq;
917 TOGGLE_ITEM(menuItems->items[OPT_REF_SPHERE], "Draw Reference Sphere", OPT_REF_SPHERE,optMenuPick); ++mq;
918 if(useR3B)
919 {
920 TOGGLE_ITEM(menuItems->items[OPT_PRIMARY], "Draw Primaries", OPT_PRIMARY, optMenuPick); ++mq;
921 TOGGLE_ITEM(menuItems->items[OPT_LIB_POINTS], "Draw Libration Pts", OPT_LIB_POINTS, optMenuPick); ++mq;
922 SEP_ITEM("separator");
923 TOGGLE_ITEM(menuItems->items[OPT_PERIOD_ANI], "Orbit Animation", OPT_PERIOD_ANI, optMenuPick); ++mq;
924 TOGGLE_ITEM(menuItems->items[OPT_SAT_ANI], "Satellite Animation", OPT_SAT_ANI, optMenuPick); ++mq;
925 }
926 TOGGLE_ITEM(menuItems->items[OPT_DRAW_LABELS], "Draw Labels", OPT_DRAW_LABELS, optMenuPick); ++mq;
927 TOGGLE_ITEM(menuItems->items[OPT_LABEL_NUMBERS], "Show Label Numbers", OPT_LABEL_NUMBERS, optMenuPick); ++mq;
928 TOGGLE_ITEM(menuItems->items[OPT_BACKGROUND], "Draw Background", OPT_BACKGROUND, optMenuPick); ++mq;
929 TOGGLE_ITEM(menuItems->items[OPT_LEGEND], "Add Legend", OPT_LEGEND, optMenuPick); ++mq;
930 TOGGLE_ITEM(menuItems->items[OPT_NORMALIZE_DATA], "Normalize Data", OPT_NORMALIZE_DATA, optMenuPick); ++mq;
931 if (useR3B) {
932 XtManageChildren(menuItems->items, mq);
933 } else {
934 XtManageChildren(menuItems->items, OPT_REF_SPHERE+1);
935 XtManageChildren(&menuItems->items[OPT_PERIOD_ANI], mq-OPT_REF_SPHERE-1);
936 }
937 Widget pushitem;
938 SEP_ITEM("separator");
939 PUSH_ITEM(pushitem, "PREFERENCES", ITEM_ONE, createPreferDialog);
940 XtManageChild(pushitem);
941
942 return pulldown;
943 }
944
945
946 ////////////////////////////////////////////////////////////////////////
947 //
948 // This creates the Edit menu and all its items.
949 //
950 static Widget
951 buildCenterMenu(Widget menubar)
952 //
953 ////////////////////////////////////////////////////////////////////////
954 {
955 Widget pulldown;
956 Arg args[4];
957 int n;
958
959 coordSystemMenuItems = new EditMenuItems;
960 coordSystemMenuItems->items = new Widget[4];
961 coordSystemMenuItems->which = whichCoordSystem;
962
963 // Tell motif to create the menu in the popup plane
964 Arg popupargs[4];
965 int popupn = 0;
966
967 pulldown = XmCreatePulldownMenu(menubar, (char *)"editMenu", popupargs, popupn);
968
969 XtAddCallback(pulldown, XmNmapCallback,
970 (XtCallbackProc)centerMenuDisplay, (XtPointer) coordSystemMenuItems);
971
972 n = 0;
973 XtSetArg(args[n], XmNuserData, coordSystemMenuItems); n++;
974 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
975 TOGGLE_ITEM(coordSystemMenuItems->items[0],
976 "Rotating Frame", ROTATING_F, editMenuPick);
977 SEP_ITEM("separator");
978 TOGGLE_ITEM(coordSystemMenuItems->items[1],
979 "Bary Centered", INERTIAL_B, editMenuPick);
980 TOGGLE_ITEM(coordSystemMenuItems->items[2],
981 "Big Primary Centered", INERTIAL_S, editMenuPick);
982 TOGGLE_ITEM(coordSystemMenuItems->items[3],
983 "Small Primary Centered", INERTIAL_E, editMenuPick);
984
985 XtManageChildren(coordSystemMenuItems->items, 4);
986
987 return pulldown;
988 }
989
990
991 ////////////////////////////////////////////////////////////////////////
992 //
993 // This creates the STYLE menu and all its items.
994 //
995 static Widget
996 buildStyleMenu(Widget menubar)
997 //
998 ////////////////////////////////////////////////////////////////////////
999 {
1000 Widget pulldown;
1001 Arg args[5];
1002 int n;
1003
1004 styleMenuItems = new EditMenuItems;
1005 styleMenuItems->items = new Widget[5];
1006 styleMenuItems->which = whichStyle;
1007
1008 // Tell motif to create the menu in the popup plane
1009 Arg popupargs[5];
1010 int popupn = 0;
1011
1012 pulldown = XmCreatePulldownMenu(menubar, (char *)"styleMenu", popupargs, popupn);
1013
1014 XtAddCallback(pulldown, XmNmapCallback,
1015 (XtCallbackProc) styleMenuDisplay, (XtPointer) styleMenuItems);
1016
1017 n = 0;
1018 XtSetArg(args[n], XmNuserData, styleMenuItems); n++;
1019 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
1020 TOGGLE_ITEM(styleMenuItems->items[0], "Line", LINE, styleMenuPick);
1021 TOGGLE_ITEM(styleMenuItems->items[1], "Tube", TUBE, styleMenuPick);
1022 TOGGLE_ITEM(styleMenuItems->items[2], "Surface", SURFACE, styleMenuPick);
1023 TOGGLE_ITEM(styleMenuItems->items[3], "Mesh Points", MESH_POINTS, styleMenuPick);
1024 TOGGLE_ITEM(styleMenuItems->items[4], "All Points", ALL_POINTS, styleMenuPick);
1025
1026 XtManageChildren(styleMenuItems->items, 5);
1027
1028 return pulldown;
1029 }
1030
1031
1032 ////////////////////////////////////////////////////////////////////////
1033 //
1034 // This creates the Coordinates menu and all its items.
1035 //
1036 static Widget
1037 buildCoordMenu(Widget menubar)
1038 //
1039 ////////////////////////////////////////////////////////////////////////
1040 {
1041 Widget pulldown;
1042 Arg args[3];
1043 int n;
1044
1045 coordMenuItems = new EditMenuItems;
1046 coordMenuItems->items = new Widget[6];
1047 coordMenuItems->which = whichCoord;
1048
1049 Arg popupargs[3];
1050 int popupn = 0;
1051
1052 pulldown = XmCreatePulldownMenu(menubar, (char *)"coordMenu", popupargs, popupn);
1053
1054 XtAddCallback(pulldown, XmNmapCallback,
1055 (XtCallbackProc) coordMenuDisplay, (XtPointer) coordMenuItems);
1056
1057 n = 0;
1058 XtSetArg(args[n], XmNuserData, coordMenuItems); n++;
1059 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
1060 TOGGLE_ITEM(coordMenuItems->items[0], "NONE", NO_COORD, coordMenuPick);
1061 TOGGLE_ITEM(coordMenuItems->items[1], "Coord Center", COORDORIGIN, coordMenuPick);
1062 TOGGLE_ITEM(coordMenuItems->items[2], "Left and Back ", LEFTBACK, coordMenuPick);
1063 TOGGLE_ITEM(coordMenuItems->items[3], "Left and Ahead", LEFTAHEAD, coordMenuPick);
1064 TOGGLE_ITEM(coordMenuItems->items[4], "At Origin", COORD_AT_ORIGIN, coordMenuPick);
1065 SEP_ITEM("separator");
1066 TOGGLE_ITEM(coordMenuItems->items[5], "Draw Scale", DRAW_TICKER, coordMenuPick);
1067
1068 XtManageChildren(coordMenuItems->items, 6);
1069
1070 return pulldown;
1071 }
1072
1073
1074 ////////////////////////////////////////////////////////////////////////
1075 //
1076 // This creates the TYPE menu and all its items.
1077 //
1078 static Widget
1079 buildTypeMenu(Widget menubar)
1080 //
1081 ////////////////////////////////////////////////////////////////////////
1082 {
1083 Widget pulldown;
1084 Arg args[2];
1085 int n;
1086
1087 typeMenuItems = new EditMenuItems;
1088 typeMenuItems->items = new Widget[2];
1089 typeMenuItems->which = whichType;
1090
1091 // Tell motif to create the menu in the popup plane
1092 Arg popupargs[2];
1093 int popupn = 0;
1094
1095 pulldown = XmCreatePulldownMenu(menubar, (char *)"typeMenu", popupargs, popupn);
1096
1097 XtAddCallback(pulldown, XmNmapCallback,
1098 (XtCallbackProc) typeMenuDisplay, (XtPointer) typeMenuItems);
1099
1100 n = 0;
1101 XtSetArg(args[n], XmNuserData, typeMenuItems); n++;
1102 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
1103 TOGGLE_ITEM(typeMenuItems->items[0], "Solution", SOLUTION, typeMenuPick);
1104 TOGGLE_ITEM(typeMenuItems->items[1], "Bifurcation", BIFURCATION, typeMenuPick);
1105
1106 XtManageChildren(typeMenuItems->items, 2);
1107
1108 return pulldown;
1109 }
1110
1111
1112 ////////////////////////////////////////////////////////////////////////
1113 //
1114 // This creates the pulldown menu bar and its menus.
1115 //
1116 static Widget
1117 buildMenu(Widget parent)
1118 //
1119 ////////////////////////////////////////////////////////////////////////
1120 {
1121 Widget menuButtons[7];
1122 Widget pulldown2;
1123 Widget pulldown1, pulldown3, pulldown4, pulldown5, pulldown6, pulldown7;
1124 Arg args[8];
1125 int n, m;
1126
1127 // menu bar
1128 Widget menubar = XmCreateMenuBar(parent, (char *)"menuBar", NULL, 0);
1129 #ifndef LESSTIF_VERSION
1130 XtVaSetValues (menubar, XmNshadowThickness, 1, NULL);
1131 #endif
1132 pulldown1 = buildFileMenu(menubar);
1133 if(useR3B)
1134 pulldown2 = buildCenterMenu(menubar);
1135 pulldown3 = buildStyleMenu(menubar);
1136 pulldown4 = buildTypeMenu(menubar);
1137 pulldown7 = buildCoordMenu(menubar);
1138 pulldown5 = buildOptionMenu(menubar);
1139 pulldown6 = buildHelpMenu(menubar);
1140
1141 #ifdef USE_BK_COLOR
1142 // set the background color for the pull down menus.
1143 XtVaSetValues (pulldown1, XtVaTypedArg,
1144 XmNbackground, XmRString, "white", 6,
1145 NULL);
1146 XtVaSetValues (pulldown2, XtVaTypedArg,
1147 XmNbackground, XmRString, "white", 6,
1148 NULL);
1149 XtVaSetValues (pulldown3, XtVaTypedArg,
1150 XmNbackground, XmRString, "white", 6,
1151 NULL);
1152 XtVaSetValues (pulldown4, XtVaTypedArg,
1153 XmNbackground, XmRString, "white", 6,
1154 NULL);
1155 XtVaSetValues (pulldown5, XtVaTypedArg,
1156 XmNbackground, XmRString, "white", 6,
1157 NULL);
1158 XtVaSetValues (pulldown6, XtVaTypedArg,
1159 XmNbackground, XmRString, "white", 6,
1160 NULL);
1161 #endif
1162
1163 // the text in the menubar for these menus
1164 n = 0; m=0;
1165 XtSetArg(args[n], XmNsubMenuId, pulldown1); n++;
1166 menuButtons[m] = XtCreateManagedWidget("File",
1167 xmCascadeButtonGadgetClass,
1168 menubar, args, n);
1169 ++m;
1170
1171 n = 0;
1172 XtSetArg(args[n], XmNsubMenuId, pulldown4); n++;
1173 menuButtons[m] = XtCreateManagedWidget("Type",
1174 xmCascadeButtonGadgetClass,
1175 menubar, args, n);
1176 ++m;
1177
1178 n = 0;
1179 XtSetArg(args[n], XmNsubMenuId, pulldown3); n++;
1180 menuButtons[m] = XtCreateManagedWidget("Style",
1181 xmCascadeButtonGadgetClass,
1182 menubar, args, n);
1183 ++m;
1184
1185 n = 0;
1186 XtSetArg(args[n], XmNsubMenuId, pulldown7); n++;
1187 menuButtons[m] = XtCreateManagedWidget("Draw Coord",
1188 xmCascadeButtonGadgetClass,
1189 menubar, args, n);
1190 ++m;
1191
1192 if(useR3B)
1193 {
1194 n = 0;
1195 XtSetArg(args[n], XmNsubMenuId, pulldown2); n++;
1196 menuButtons[m] = XtCreateManagedWidget("Center",
1197 xmCascadeButtonGadgetClass,
1198 menubar, args, n);
1199 ++m;
1200 }
1201
1202 n = 0;
1203 XtSetArg(args[n], XmNsubMenuId, pulldown5); n++;
1204 menuButtons[m] = XtCreateManagedWidget("Options",
1205 xmCascadeButtonGadgetClass,
1206 menubar, args, n);
1207 ++m;
1208
1209 n = 0;
1210 XtSetArg(args[n], XmNsubMenuId, pulldown6); n++;
1211 XtSetArg(args[n], XmNmenuHelpWidget, pulldown6); n++;
1212 menuButtons[m] = XtCreateManagedWidget("Help",
1213 xmCascadeButtonGadgetClass,
1214 menubar, args, n);
1215 ++m;
1216
1217 // manage the menu buttons
1218 XtManageChildren(menuButtons, m);
1219
1220 return menubar;
1221 }
1222
1223
1224 ////////////////////////////////////////////////////////////////////////
1225 //
1226 static void
1227 dimensionToggledCB(Widget w, XtPointer client_data, XtPointer cbs)
1228 //
1229 ////////////////////////////////////////////////////////////////////////
1230 {
1231 static bool buttonState = setShow3D;
1232 buttonState = !buttonState;
1233 if(buttonState)
1234 {
1235 setShow3D = true;
1236 XtSetSensitive (zAxisList, true);
1237 setListValue();
1238 XmString xString = XmStringCreateLocalized((char *)"3D");
1239 XtVaSetValues (w, XmNlabelString, xString, NULL);
1240 XmStringFree(xString);
1241 }
1242 else
1243 {
1244 setShow3D = false;
1245 zCoordIndices.clear();
1246 zCoordIndices.push_back(-1);
1247 XtSetSensitive (zAxisList, false);
1248 XmString xString = XmStringCreateLocalized((char *)"2D");
1249 XtVaSetValues (w, XmNlabelString, xString, NULL);
1250 XmStringFree(xString);
1251 }
1252
1253 if(whichType != BIFURCATION)
1254 setShow3DSol = setShow3D;
1255 else
1256 setShow3DBif = setShow3D;
1257
1258 updateScene();
1259 }
1260
1261
1262 ////////////////////////////////////////////////////////////////////////
1263 //
1264 static void
1265 createBdBoxCB(Widget w, XtPointer client_data, XtPointer cbs)
1266 //
1267 ////////////////////////////////////////////////////////////////////////
1268 {
1269 static bool btnState = false;
1270 SoSeparator * scene = (SoSeparator *) client_data;
1271 btnState = !btnState;
1272 if(btnState)
1273 scene->addChild(createBoundingBox());
1274 else
1275 {
1276 SoSeparator * bdBox = (SoSeparator *)SoNode::getByName("bdBox");
1277 scene->removeChild(bdBox);
1278 }
1279 }
1280
1281
1282 ////////////////////////////////////////////////////////////////////////
1283 //
1284 // This creates the main window contents. In this case, we have a
1285 // menubar at the top of the window, and a render area filling out
1286 // the remainder. These widgets are layed out with a Motif form widget.
1287 //
1288 static void
1289 buildMainWindow(Widget parent, SoSeparator *root)
1290 //
1291 ////////////////////////////////////////////////////////////////////////
1292 {
1293 Arg args[15];
1294 int n,i;
1295
1296 SoSeparator *sceneGraph = new SoSeparator;
1297 sceneGraph->ref();
1298
1299 SoEventCallback *mouseEventCB = new SoEventCallback;
1300 sceneGraph->addChild(mouseEventCB);
1301 sceneGraph->addChild(root);
1302
1303 // build the toplevel widget
1304 topform = XtCreateWidget("topform", xmFormWidgetClass, parent,NULL, 0);
1305 // build menubar
1306 Widget menubar = buildMenu(topform);
1307 #ifdef USE_BK_COLOR
1308 XtVaSetValues (topform, XtVaTypedArg,
1309 XmNbackground, XmRString, "white", 6,
1310 NULL);
1311 XtVaSetValues (menubar, XtVaTypedArg,
1312 XmNbackground, XmRString, "white", 6,
1313 NULL);
1314 #endif
1315
1316 // build carrier for the x, y, z, and label lists.
1317 Widget listCarrier= XtCreateWidget("ListCarrier",
1318 xmFormWidgetClass, topform, NULL, 0);
1319 #ifdef USE_BK_COLOR
1320 XtVaSetValues (listCarrier, XtVaTypedArg,
1321 XmNbackground, XmRString, "white", 4,
1322 NULL);
1323 #endif
1324
1325 //build the xAxis drop down list
1326 int nItems = xAxis.size();
1327 xList = (XmStringTable) XtMalloc(nItems * sizeof (XmString *));
1328 for (i = 0; i < nItems; i++)
1329 xList[i] = XmStringCreateLocalized (const_cast<char *>(xAxis[i].c_str()));
1330
1331 xAxisList=XtVaCreateManagedWidget ("xAxis",
1332 xmComboBoxWidgetClass, listCarrier,
1333 XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX,
1334 XmNitemCount, nItems,
1335 XmNitems, xList,
1336 XmNselectedPosition, xCoordIndices[0],
1337 XmNcolumns, 2,
1338 XmNmarginHeight, 1,
1339 XmNpositionMode, XmZERO_BASED,
1340 NULL);
1341
1342 lessTifFixupComboBox(xAxisList, xList, nItems, 10, 60, 2);
1343
1344 // Add Callback function for the x-axis drop down list
1345 XtAddCallback (xAxisList, XmNselectionCallback,
1346 xListCallBack, NULL);
1347
1348 #ifdef USE_BK_COLOR
1349 XtVaSetValues (xAxisList, XtVaTypedArg,
1350 XmNbackground, XmRString, "white", 4,
1351 NULL);
1352 #endif
1353
1354 // build the yAxis drop down list
1355 nItems = yAxis.size();
1356 yList = (XmStringTable) XtMalloc(nItems * sizeof (XmString *));
1357 for (i = 0; i < nItems; i++)
1358 yList[i] = XmStringCreateLocalized(const_cast<char *>(yAxis[i].c_str()));
1359
1360 yAxisList=XtVaCreateManagedWidget ("yAxis",
1361 xmComboBoxWidgetClass, listCarrier,
1362 XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX,
1363 XmNitemCount, nItems,
1364 XmNitems, yList,
1365 XmNselectedPosition, yCoordIndices[0],
1366 XmNcolumns, 2,
1367 XmNmarginHeight, 1,
1368 XmNpositionMode, XmZERO_BASED,
1369 NULL);
1370
1371 lessTifFixupComboBox(yAxisList, yList, nItems, 10, 60, 2);
1372
1373 XtAddCallback (yAxisList, XmNselectionCallback,
1374 yListCallBack, NULL);
1375
1376 #ifdef USE_BK_COLOR
1377 XtVaSetValues (yAxisList, XtVaTypedArg,
1378 XmNbackground, XmRString, "white", 4,
1379 NULL);
1380 #endif
1381
1382 // build the zAxis drop down list
1383 nItems = zAxis.size();
1384 zList = (XmStringTable) XtMalloc(nItems * sizeof (XmString *));
1385 for (i = 0; i < nItems; i++)
1386 zList[i] = XmStringCreateLocalized(const_cast<char *>(zAxis[i].c_str()));
1387
1388 zAxisList=XtVaCreateManagedWidget ("zAxis",
1389 xmComboBoxWidgetClass, listCarrier,
1390 XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX,
1391 XmNitemCount, nItems,
1392 XmNitems, zList,
1393 XmNselectedPosition, zCoordIndices[0],
1394 XmNcolumns, 2,
1395 XmNmarginHeight, 1,
1396 XmNpositionMode, XmZERO_BASED,
1397 NULL);
1398
1399 lessTifFixupComboBox(zAxisList, zList, nItems, 10, 60, 2);
1400
1401 // Add Callback function for the z-axis drop down list
1402 XtAddCallback (zAxisList, XmNselectionCallback,
1403 zListCallBack, NULL);
1404
1405 #ifdef USE_BK_COLOR
1406 XtVaSetValues (zAxisList, XtVaTypedArg,
1407 XmNbackground, XmRString, "white", 6,
1408 NULL);
1409 #endif
1410
1411 // build the LABELs drop down list
1412 nItems = labels.size();
1413 lblList = (XmStringTable) XtMalloc(nItems * sizeof (XmString *));
1414 for (i = 0; i < nItems; i++)
1415 lblList[i] = XmStringCreateLocalized (const_cast<char *>(labels[i].c_str()));
1416
1417 labelsList=XtVaCreateManagedWidget ("Labels",
1418 xmComboBoxWidgetClass, listCarrier,
1419 XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX,
1420 XmNitemCount, nItems,
1421 XmNitems, lblList,
1422 XmNcolumns, 6,
1423 XmNmarginHeight, 1,
1424 XmNselectedPosition, lblChoice[0]+LBL_OFFSET, //lblIndices[0],
1425 XmNpositionMode, XmZERO_BASED,
1426 NULL);
1427
1428 lessTifFixupComboBox(labelsList, lblList, nItems, 10, 86, 6);
1429
1430 for (i = 0; i < nItems; i++)
1431 XmStringFree(lblList[i]);
1432
1433 // Add Callback function for the LABELs drop down list
1434 XtAddCallback (labelsList, XmNselectionCallback,
1435 lblListCallBack, NULL);
1436
1437 #ifdef USE_BK_COLOR
1438 XtVaSetValues (labelsList, XtVaTypedArg,
1439 XmNbackground, XmRString, "white", 6,
1440 NULL);
1441 XtVaSetValues (labelsList, XtVaTypedArg,
1442 XmNforeground, XmRString, "red", 4,
1443 NULL);
1444 #endif
1445
1446 // build the COLORING Method drop down list
1447 nItems = coloringMethodList.size();
1448 clrMethodList = (XmStringTable) XtMalloc(nItems * sizeof (XmString *));
1449
1450 for (i = 0; i < nItems; ++i)
1451 clrMethodList[i] = XmStringCreateLocalized(const_cast<char *>(coloringMethodList[i].c_str()));
1452
1453 colorMethodSeletionList=XtVaCreateManagedWidget ("coloringMethodlist",
1454 xmComboBoxWidgetClass, listCarrier,
1455 XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX,
1456 XmNitemCount, nItems,
1457 XmNitems, clrMethodList,
1458 XmNcolumns, 5,
1459 XmNmarginHeight, 1,
1460 XmNselectedPosition, (coloringMethod < 0 ?
1461 coloringMethod+CL_SP_ITEMS : coloringMethod+specialColorItems),
1462 XmNpositionMode, XmZERO_BASED,
1463 NULL);
1464
1465 lessTifFixupComboBox(colorMethodSeletionList, clrMethodList, nItems, 10, 80, 5);
1466
1467 XtAddCallback (colorMethodSeletionList, XmNselectionCallback,
1468 colorMethodSelectionCB, NULL);
1469
1470 // build the numPeriodAnimated drop down list
1471 nItems = 7;
1472 char (*numberPList)[5] = new char [nItems][5];
1473 XmStringTable numPList = (XmStringTable) XtMalloc(nItems * sizeof (XmString *));
1474
1475 int iam = 1;
1476 sprintf(numberPList[0], "%i", 0);
1477 for (i = 0; i < nItems-2; ++i)
1478 {
1479 sprintf(numberPList[i+1], "%i", iam);
1480 iam *= 2;
1481 }
1482 sprintf(numberPList[nItems-1], "%s", "inf");
1483
1484 for (i = 0; i < nItems; ++i)
1485 numPList[i] = XmStringCreateLocalized (numberPList[i]);
1486
1487 if (numPeriodAnimated > 0)
1488 i = ((int)(log(numPeriodAnimated)/log(2.0))) + 1;
1489 else if (numPeriodAnimated == 0)
1490 i = 0;
1491 else
1492 i = nItems - 1;
1493
1494 Widget numPeriodAnimatedList=XtVaCreateManagedWidget ("list",
1495 xmComboBoxWidgetClass, listCarrier,
1496 XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX,
1497 XmNitemCount, nItems,
1498 XmNitems, numPList,
1499 XmNcolumns, 3,
1500 XmNmarginHeight, 1,
1501 XmNselectedPosition, i,
1502 XmNpositionMode, XmZERO_BASED,
1503 NULL);
1504
1505 lessTifFixupComboBox(numPeriodAnimatedList, numPList, nItems, 10, 70, 3);
1506
1507 // Add Callback function for the numberPeriodAnimated drop down list
1508 XtAddCallback (numPeriodAnimatedList, XmNselectionCallback,
1509 numPeriodAnimatedCB, NULL);
1510
1511 for (i = 0; i < nItems; i++)
1512 XmStringFree(numPList[i]);
1513 XtFree((char *)numPList);
1514 // delete []numberPList;
1515 //----------------------------------------------------------------> Nov 06 End
1516
1517 // create labels for the x, y, z, and labels drop down lists
1518 Widget xLbl = XtVaCreateManagedWidget("X",xmLabelWidgetClass, listCarrier, NULL);
1519 Widget yLbl = XtVaCreateManagedWidget("Y",xmLabelWidgetClass, listCarrier, NULL);
1520 Widget zLbl = XtVaCreateManagedWidget("Z",xmLabelWidgetClass, listCarrier, NULL);
1521 Widget lLbl = XtVaCreateManagedWidget("Label",xmLabelWidgetClass, listCarrier, NULL);
1522 Widget colorLbl = XtVaCreateManagedWidget("Color",xmLabelWidgetClass, listCarrier, NULL);
1523 Widget numPeriodLbl = XtVaCreateManagedWidget("Period",xmLabelWidgetClass, listCarrier, NULL);
1524
1525 Widget orbitSldLbl = XtVaCreateManagedWidget("Orbit",xmLabelWidgetClass, listCarrier, NULL);
1526 Widget satSldLbl = XtVaCreateManagedWidget(useR3B ? "Sat " : "Anim",xmLabelWidgetClass, listCarrier, NULL);
1527 Widget spLbl = XtVaCreateManagedWidget(" Line ",xmLabelWidgetClass, listCarrier, NULL);
1528 Widget spLbl2 = XtVaCreateManagedWidget("Thickness",xmLabelWidgetClass, listCarrier, NULL);
1529
1530 #ifdef USE_BK_COLOR
1531 //set the background color for the labels
1532 XtVaSetValues (xLbl, XtVaTypedArg,
1533 XmNbackground, XmRString, "white", 6,
1534 NULL);
1535 XtVaSetValues (yLbl, XtVaTypedArg,
1536 XmNbackground, XmRString, "white", 6,
1537 NULL);
1538 XtVaSetValues (zLbl, XtVaTypedArg,
1539 XmNbackground, XmRString, "white", 6,
1540 NULL);
1541 XtVaSetValues (lLbl, XtVaTypedArg,
1542 XmNbackground, XmRString, "white", 6,
1543 NULL);
1544 #endif
1545
1546 // Create slider to control speed
1547 n = 0;
1548 XtSetArg(args[n], XmNminimum, MIN_SAT_SPEED); n++;
1549 XtSetArg(args[n], XmNmaximum, MAX_SAT_SPEED); n++;
1550 XtSetArg(args[n], XmNvalue, satSpeed*100);n++;//(MAX_SPEED-MIN_SPEED)/2.0); n++;
1551 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
1552 if(options[OPT_SAT_ANI])
1553 {
1554 XtSetArg(args[n], XmNeditable, TRUE); n++;
1555 }
1556 else
1557 {
1558 XtSetArg(args[n], XmNeditable, FALSE); n++;
1559 }
1560
1561
1562 satAniSpeedSlider =
1563 XtCreateWidget("Speed", xmScaleWidgetClass, listCarrier, args, n);
1564
1565 #ifdef USE_BK_COLOR
1566 XtVaSetValues (satAniSpeedSlider, XtVaTypedArg,
1567 XmNbackground, XmRString, "white", 6,
1568 NULL);
1569 #endif
1570
1571 // Callbacks for the slider
1572 XtAddCallback(satAniSpeedSlider, XmNvalueChangedCallback,
1573 satSpeedCB, NULL);
1574
1575 n = 0;
1576 XtSetArg(args[n], XmNminimum, MIN_ORBIT_SPEED); n++;
1577 XtSetArg(args[n], XmNmaximum, MAX_ORBIT_SPEED); n++;
1578 XtSetArg(args[n], XmNvalue, orbitSpeed*50);n++;
1579 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
1580 if(options[OPT_PERIOD_ANI])
1581 {
1582 XtSetArg(args[n], XmNeditable, TRUE); n++;
1583 }
1584 else
1585 {
1586 XtSetArg(args[n], XmNeditable, FALSE); n++;
1587 }
1588 orbitAniSpeedSlider =
1589 XtCreateWidget("Speed2", xmScaleWidgetClass, listCarrier, args, n);
1590
1591 #ifdef USE_BK_COLOR
1592 XtVaSetValues (orbitAniSpeedSlider, XtVaTypedArg,
1593 XmNbackground, XmRString, "white", 6,
1594 NULL);
1595 #endif
1596
1597 // Callbacks for the slider2
1598 XtAddCallback(orbitAniSpeedSlider, XmNvalueChangedCallback,
1599 orbitSpeedCB, NULL);
1600
1601 // create spinbox for the line width control.
1602 n = 0;
1603 XtSetArg (args[n], XmNarrowSize, 12); n++;
1604 XtSetArg (args[n], XmNspinBoxChildType, XmNUMERIC); n++;
1605 XtSetArg (args[n], XmNminimumValue, 10); n++;
1606 XtSetArg (args[n], XmNdecimalPoints, 1); n++;
1607 XtSetArg (args[n], XmNincrementValue, 1); n++;
1608 XtSetArg (args[n], XmNeditable, TRUE); n++;
1609 XtSetArg (args[n], XmNpositionType, XmPOSITION_VALUE); n++;
1610 XtSetArg (args[n], XmNposition, lineWidthScaler+10); n++;
1611 XtSetArg (args[n], XmNcolumns, 3); n++;
1612 XtSetArg (args[n], XmNwrap, FALSE); n++;
1613 #ifdef LESSTIF_VERSION
1614 XtSetArg (args[n], XmNmaximumValue, 110); n++;
1615 Widget spinBox = XmCreateSpinBox (listCarrier, (char *)"spinBox", args, 1);
1616 Widget tf = XmCreateTextField(spinBox, (char *)"tf", args+1, n-1);
1617 XtManageChild(tf);
1618 XtManageChild(spinBox);
1619 XtAddCallback(tf, XmNvalueChangedCallback,
1620 lineWidthCB, (XtPointer)tf);
1621 #else
1622 XtSetArg (args[n], XmNmaximumValue, 100); n++;
1623 Widget spinBox = XmCreateSimpleSpinBox (listCarrier, (char *)"spinBox", args, n);
1624
1625 // Callbacks for the spinebox
1626 XtAddCallback(spinBox, XmNvalueChangedCallback,
1627 lineWidthCB, (XtPointer)spinBox);
1628 #endif
1629
1630 // create RENDER AREA FOR THE graphics.
1631 #ifdef USE_EXAM_VIEWER
1632 renderArea = new SoXtExaminerViewer(topform);
1633 #else
1634 renderArea = new SoXtRenderArea(topform);
1635 #endif
1636
1637 renderArea->setSize(SbVec2s(winWidth, winHeight));
1638 renderArea->setBackgroundColor(envColors[0]);
1639 if(useR3B)
1640 renderArea->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
1641
1642 #ifdef USE_EXAM_VIEWER
1643 n = 0;
1644 Widget newButton = XmCreatePushButton(renderArea->getAppPushButtonParent(), (char *)"BOX", NULL, 0);
1645 XtAddCallback(newButton, XmNactivateCallback, createBdBoxCB, sceneGraph);
1646 renderArea->addAppPushButton(newButton);
1647
1648 char xString[5];
1649 if(setShow3D)
1650 {
1651 XtSetSensitive (zAxisList, true);
1652 strcpy(xString,"3D");
1653 }
1654 else
1655 {
1656 strcpy(xString,"2D");
1657 XtSetSensitive (zAxisList, false);
1658 }
1659
1660 dimButton = XmCreatePushButton(renderArea->getAppPushButtonParent(), xString, NULL, 0);
1661 XtAddCallback(dimButton, XmNactivateCallback, dimensionToggledCB, sceneGraph);
1662 renderArea->addAppPushButton(dimButton);
1663
1664 // used for printing scene to ps files
1665 vwrAndScene = new ViewerAndScene;
1666 vwrAndScene->scene = renderArea->getSceneGraph();
1667 vwrAndScene->viewer = renderArea;
1668 #endif
1669
1670 // layout
1671 //Positioning the x-label for the x-axis drop down list
1672 n = 0;
1673 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1674 XtSetArg(args[n], XmNtopOffset, 3 ); n++;
1675 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1676 XtSetArg(args[n], XmNbottomOffset, 3 ); n++;
1677 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1678 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1679 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
1680 XtSetValues(xLbl, args, n);
1681
1682 //Positioning the x-axis' drop down list
1683 n = 0;
1684 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM ); n++;
1685 XtSetArg(args[n], XmNtopOffset, 3 ); n++;
1686 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM ); n++;
1687 XtSetArg(args[n], XmNbottomOffset, 3 ); n++;
1688 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
1689 XtSetArg(args[n], XmNleftWidget, xLbl ); n++;
1690 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1691 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1692 XtSetValues(xAxisList, args, n);
1693
1694 //Positioning the y-label for the y-axis drop down list
1695 n = 0;
1696 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1697 XtSetArg(args[n], XmNtopWidget, xLbl ); n++;
1698 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1699 XtSetArg(args[n], XmNbottomWidget, xLbl ); n++;
1700 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1701 XtSetArg(args[n], XmNleftWidget, xAxisList ); n++;
1702 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1703 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1704 XtSetValues(yLbl, args, n);
1705
1706 //Positioning the y-axis' drop down list
1707 n = 0;
1708 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1709 XtSetArg(args[n], XmNtopWidget, xAxisList ); n++;
1710 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1711 XtSetArg(args[n], XmNbottomWidget, xAxisList ); n++;
1712 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1713 XtSetArg(args[n], XmNleftWidget, yLbl ); n++;
1714 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1715 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1716 XtSetValues(yAxisList, args, n);
1717
1718 //Positioning the z-label for the z-axis drop down list
1719 n = 0;
1720 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1721 XtSetArg(args[n], XmNtopWidget, xLbl ); n++;
1722 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1723 XtSetArg(args[n], XmNbottomWidget, xLbl ); n++;
1724 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1725 XtSetArg(args[n], XmNleftWidget, yAxisList ); n++;
1726 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1727 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1728 XtSetValues(zLbl, args, n);
1729
1730 //Positioning the z-axis' drop down list
1731 n = 0;
1732 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1733 XtSetArg(args[n], XmNtopWidget, xAxisList ); n++;
1734 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1735 XtSetArg(args[n], XmNbottomWidget, xAxisList ); n++;
1736 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1737 XtSetArg(args[n], XmNleftWidget, zLbl ); n++;
1738 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1739 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1740 XtSetValues(zAxisList, args, n);
1741
1742 //Positioning the LABELs' drop down list label
1743 n = 0;
1744 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1745 XtSetArg(args[n], XmNtopWidget, xLbl ); n++;
1746 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1747 XtSetArg(args[n], XmNbottomWidget, xLbl ); n++;
1748 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1749 XtSetArg(args[n], XmNleftWidget, zAxisList ); n++;
1750 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1751 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1752 XtSetValues(lLbl, args, n);
1753
1754 //Positioning the LABELs' drop down list
1755 n = 0;
1756 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1757 XtSetArg(args[n], XmNtopWidget, xAxisList ); n++;
1758 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1759 XtSetArg(args[n], XmNbottomWidget, xAxisList ); n++;
1760 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1761 XtSetArg(args[n], XmNleftWidget, lLbl ); n++;
1762 XtSetArg(args[n], XmNleftOffset, 0 ); n++;
1763 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1764 XtSetValues(labelsList, args, n);
1765
1766 //Positioning the label for the Coloring method list
1767 n = 0;
1768 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1769 XtSetArg(args[n], XmNtopWidget, xLbl ); n++;
1770 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1771 XtSetArg(args[n], XmNbottomWidget, xLbl ); n++;
1772 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1773 XtSetArg(args[n], XmNleftWidget, labelsList ); n++;
1774 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1775 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1776 XtSetValues(colorLbl, args, n);
1777
1778 // layout the coloring method selection on the listCarrier.
1779 n = 0;
1780 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1781 XtSetArg(args[n], XmNtopWidget, xAxisList ); n++;
1782 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1783 XtSetArg(args[n], XmNbottomWidget, xAxisList ); n++;
1784 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1785 XtSetArg(args[n], XmNleftWidget, colorLbl ); n++;
1786 XtSetArg(args[n], XmNleftOffset, 0 ); n++;
1787 XtSetValues(colorMethodSeletionList,args,n);
1788 XtManageChild(colorMethodSeletionList);
1789
1790 //Positioning the label for the number of period seleciton list
1791 n = 0;
1792 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1793 XtSetArg(args[n], XmNtopWidget, xLbl ); n++;
1794 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1795 XtSetArg(args[n], XmNbottomWidget, xLbl ); n++;
1796 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1797 XtSetArg(args[n], XmNleftWidget, colorMethodSeletionList ); n++;
1798 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1799 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1800 XtSetValues(numPeriodLbl, args, n);
1801
1802
1803 // layout the numPeriodAnimatedList on the listCarrier.
1804 n = 0;
1805 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1806 XtSetArg(args[n], XmNtopWidget, xAxisList ); n++;
1807 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1808 XtSetArg(args[n], XmNbottomWidget, xAxisList ); n++;
1809 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1810 //labelsList ); n++;
1811 XtSetArg(args[n], XmNleftWidget, numPeriodLbl ); n++;
1812 XtSetArg(args[n], XmNleftOffset, 0 ); n++;
1813 XtSetValues(numPeriodAnimatedList,args,n);
1814 XtManageChild(numPeriodAnimatedList);
1815
1816 // spinbox labels and spinboxes
1817 // layout the spinBox label on the listCarrier.
1818 n = 0;
1819 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM ); n++;
1820 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1821 // XtSetArg(args[n], XmNleftWidget, colorMethodSeletionList ); n++;
1822 XtSetArg(args[n], XmNleftWidget, numPeriodAnimatedList ); n++;
1823 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1824 XtSetValues(spLbl, args, n);
1825
1826 n = 0;
1827 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++;
1828 XtSetArg(args[n], XmNtopWidget, spLbl ); n++;
1829 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM ); n++;
1830 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1831 // XtSetArg(args[n], XmNleftWidget, colorMethodSeletionList ); n++;
1832 // XtSetArg(args[n], XmNleftWidget, labelsList); n++;
1833 XtSetArg(args[n], XmNleftWidget, numPeriodAnimatedList ); n++;
1834 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1835 XtSetValues(spLbl2, args, n);
1836
1837 // layout the spinBox on the listCarrier.
1838 n = 0;
1839 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1840 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM ); n++;
1841 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1842 XtSetArg(args[n], XmNleftWidget, spLbl ); n++;
1843 XtSetValues(spinBox, args, n);
1844 XtManageChild(spinBox);
1845
1846 //Positioning the label for the slider bars
1847 n = 0;
1848 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
1849 XtSetArg(args[n], XmNtopWidget, xAxisList ); n++;
1850 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1851 XtSetArg(args[n], XmNleftWidget, spinBox ); n++;
1852 XtSetArg(args[n], XmNleftOffset, 20 ); n++;
1853 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1854 XtSetValues(satSldLbl, args, n);
1855
1856 //Positioning the label for the slider bars
1857 n = 0;
1858 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET ); n++;
1859 XtSetArg(args[n], XmNbottomWidget, xAxisList ); n++;
1860 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1861 XtSetArg(args[n], XmNleftWidget, spinBox ); n++;
1862 XtSetArg(args[n], XmNleftOffset, 20 ); n++;
1863 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE ); n++;
1864 XtSetValues(orbitSldLbl, args, n);
1865
1866 // Layout the slider bar on the listCarrier
1867 n = 0;
1868 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM ); n++;
1869 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1870 XtSetArg(args[n], XmNleftWidget, satSldLbl ); n++;
1871 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1872 XtSetValues(satAniSpeedSlider, args, n);
1873 XtManageChild(satAniSpeedSlider);
1874
1875 n = 0;
1876 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++;
1877 XtSetArg(args[n], XmNtopWidget, satAniSpeedSlider ); n++;
1878 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM ); n++;
1879 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET ); n++;
1880 XtSetArg(args[n], XmNleftWidget, satSldLbl ); n++;
1881 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
1882 XtSetValues(orbitAniSpeedSlider, args, n);
1883 XtManageChild(orbitAniSpeedSlider);
1884
1885 // Positioning the menu bar.
1886 n = 0;
1887 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
1888 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1889 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1890 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
1891 XtSetValues(menubar, args, n);
1892
1893 // Positioning the listCarrier.
1894 n = 0;
1895 #ifdef LIST_UNDER_MENUBAR
1896 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1897 XtSetArg(args[n], XmNtopWidget, menubar ); n++;
1898 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
1899 #else
1900 XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
1901 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
1902 #endif
1903 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
1904 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
1905 XtSetValues(listCarrier, args, n);
1906
1907 // Positioning the Render Area
1908 n = 0;
1909 #ifdef LIST_UNDER_MENUBAR
1910 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1911 XtSetArg(args[n], XmNtopWidget, xAxisList ); n++;
1912 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM ); n++;
1913 #else
1914 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
1915 XtSetArg(args[n], XmNtopWidget, menubar ); n++;
1916 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
1917 XtSetArg(args[n], XmNbottomWidget, xAxisList ); n++;
1918 #endif
1919 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM ); n++;
1920 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM ); n++;
1921 XtSetValues(renderArea->getWidget(), args, n);
1922
1923 // manage the children
1924 XtManageChild(menubar);
1925 XtManageChild(listCarrier);
1926
1927 updateScene();
1928 // these two lines are the third method for showing in 2D/3D
1929 renderArea->setSceneGraph(sceneGraph);
1930 renderArea->show();
1931
1932 XtManageChild(topform);
1933
1934 #ifdef USE_BK_COLOR
1935 XtVaSetValues (mainWindow, XtVaTypedArg,
1936 XmNbackground, XmRString, "white", 6, NULL);
1937 #endif
1938
1939 mouseEventCB->addEventCallback(
1940 SoMouseButtonEvent::getClassTypeId(),
1941 myMousePressCB,
1942 renderArea->getSceneManager()->getSceneGraph());
1943 }
1944
1945
1946 ////////////////////////////////////////////////////////////////////////
1947 //
1948 // When the line color changed, this function will be raised.
1949 //
1950 static void
1951 lineColorValueChangedCB(Widget w, XtPointer client_data, XtPointer call_data)
1952 //
1953 ////////////////////////////////////////////////////////////////////////
1954 {
1955 XmSpinBoxCallbackStruct *sb = (XmSpinBoxCallbackStruct *) call_data;
1956 int value;
1957 int which;
1958 int lineNumber=0, columnNumber =0;
1959
1960 if (sb->reason == XmCR_OK)
1961 {
1962 XtVaGetValues (sb->widget, XmNuserData, &which, NULL);
1963 XtVaGetValues (sb->widget, XmNposition, &value, NULL);
1964 lineNumber = which / 3;
1965 columnNumber = which % 3;
1966 lineColorTemp[lineNumber][columnNumber] = value/10.0;
1967 }
1968 }
1969
1970
1971 ////////////////////////////////////////////////////////////////////////
1972 //
1973 // When the line pattern selection changed, this function will be raised.
1974 //
1975 static void
1976 linePatternValueChangedCB(Widget w, XtPointer client_data, XtPointer call_data)
1977 //
1978 ////////////////////////////////////////////////////////////////////////
1979 {
1980 XmSpinBoxCallbackStruct *sb = (XmSpinBoxCallbackStruct *) call_data;
1981 int position, which;
1982
1983 if (sb->reason == XmCR_OK)
1984 {
1985 XtVaGetValues (w, XmNposition, &position, NULL);
1986 XtVaGetValues (w, XmNuserData, &which, NULL);
1987 linePatternTemp[which] = systemLinePatternValue[position];
1988 }
1989 }
1990
1991
1992 ////////////////////////////////////////////////////////////////////////
1993 //
1994 // This creates the COLOR and LINE preference sheet stuff.
1995 //
1996 static Widget
1997 createLineColorAndPatternPrefSheetGuts(Widget parent, char *name, int id)
1998 //
1999 ////////////////////////////////////////////////////////////////////////
2000 {
2001 Widget widgetList[7];
2002 Arg args[15];
2003 int n;
2004
2005 Widget form = XtCreateWidget("", xmFormWidgetClass, parent, NULL, 0);
2006
2007 n=0;
2008 XtSetArg(args[n], XmNcolumns, 12); n++;
2009 widgetList[0] = XtCreateWidget(name,
2010 xmLabelGadgetClass, form, args, n);
2011 XtManageChild (widgetList[0]);
2012
2013 Widget spin = XmCreateSpinBox (form, (char *)"spin", NULL, 0);
2014 XtAddCallback (spin, XmNvalueChangedCallback, lineColorValueChangedCB, NULL);
2015
2016 // Create the red field
2017 n = 0;
2018 XtSetArg (args[n], XmNspinBoxChildType, XmNUMERIC) ; n++;
2019 XtSetArg (args[n], XmNcolumns, 3 ) ; n++;
2020 XtSetArg (args[n], XmNeditable, FALSE ) ; n++;
2021 XtSetArg (args[n], XmNminimumValue, 0 ) ; n++;
2022 XtSetArg (args[n], XmNmaximumValue, 10 ) ; n++;
2023 XtSetArg (args[n], XmNdecimalPoints, 1 ) ; n++;
2024 XtSetArg (args[n], XmNposition, lineColor[id][0]*10) ; n++;
2025 XtSetArg (args[n], XmNwrap, TRUE ) ; n++;
2026 XtSetArg (args[n], XmNuserData, id*3 ) ; n++;
2027
2028 widgetList[1]= XmCreateTextField (spin, (char *)"redText", args, n);
2029 XtManageChild (widgetList[1]);
2030
2031 // Create the green field
2032 n = 0;
2033 XtSetArg (args[n], XmNspinBoxChildType,XmNUMERIC); n++;
2034 XtSetArg (args[n], XmNcolumns, 3 ); n++;
2035 XtSetArg (args[n], XmNeditable, FALSE ); n++;
2036 XtSetArg (args[n], XmNminimumValue, 0 ); n++;
2037 XtSetArg (args[n], XmNmaximumValue, 10 ); n++;
2038 XtSetArg (args[n], XmNdecimalPoints, 1 ); n++;
2039 XtSetArg (args[n], XmNwrap, TRUE ); n++;
2040 XtSetArg (args[n], XmNposition, lineColor[id][1]*10); n++;
2041 XtSetArg (args[n], XmNuserData, id*3+1 ); n++;
2042
2043 widgetList[2]= XmCreateTextField (spin, (char *)"greenText", args, n);
2044 XtManageChild (widgetList[2]);
2045
2046 // Create the blue field
2047 n = 0;
2048 XtSetArg (args[n], XmNspinBoxChildType,XmNUMERIC); n++;
2049 XtSetArg (args[n], XmNcolumns, 3 ); n++;
2050 XtSetArg (args[n], XmNeditable, FALSE ); n++;
2051 XtSetArg (args[n], XmNminimumValue, 0 ); n++;
2052 XtSetArg (args[n], XmNmaximumValue, 10 ); n++;
2053 XtSetArg (args[n], XmNdecimalPoints, 1 ); n++;
2054 XtSetArg (args[n], XmNwrap, TRUE ); n++;
2055 XtSetArg (args[n], XmNposition, lineColor[id][2]*10); n++;
2056 XtSetArg (args[n], XmNuserData, id*3+2 ); n++;
2057
2058 widgetList[3]= XmCreateTextField (spin, (char *)"blueText", args, n);
2059 XtManageChild (widgetList[3]);
2060
2061 // create the line pattern
2062 int lengthOfSysPatternArray = XtNumber( systemLinePatternLookAndFeel );
2063 XmStringTable strList = (XmStringTable) XtMalloc (
2064 (unsigned) lengthOfSysPatternArray * sizeof (XmString *));
2065 for (int i = 0; i < lengthOfSysPatternArray; i++)
2066 strList[i] = XmStringCreateLocalized ((char *)systemLinePatternLookAndFeel[i]);
2067
2068 n = 0;
2069 XtSetArg (args[n], XmNspinBoxChildType, XmSTRING); n++;
2070 XtSetArg (args[n], XmNcolumns, 12 ) ; n++;
2071 XtSetArg (args[n], XmNeditable, FALSE); n++;
2072 XtSetArg (args[n], XmNnumValues, lengthOfSysPatternArray); n++;
2073 XtSetArg (args[n], XmNvalues, strList); n++;
2074 XtSetArg (args[n], XmNwrap, TRUE); n++;
2075 XtSetArg (args[n], XmNshadowThickness, 0); n++;
2076 XtSetArg (args[n], XmNuserData, id ); n++;
2077
2078 #ifdef LESSTIF_VERSION
2079 Widget lpSpinBox = XmCreateSpinBox (form, (char *)"lpSimple", args, 0);
2080 Widget tf = XmCreateTextField(lpSpinBox, (char *)"tf", args, n);
2081 XtManageChild(tf);
2082 XtAddCallback(tf, XmNvalueChangedCallback,
2083 linePatternValueChangedCB, (XtPointer)tf);
2084 #else
2085 Widget lpSpinBox = XmCreateSimpleSpinBox (form, (char *)"lpsimple", args, n);
2086 XtAddCallback (lpSpinBox, XmNvalueChangedCallback, linePatternValueChangedCB, NULL);
2087 #endif
2088
2089 for (int i = 0; i < lengthOfSysPatternArray; i++)
2090 XmStringFree (strList[i]);
2091 delete strList;
2092
2093 // layout
2094 n = 0;
2095 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2096 XtSetArg(args[n], XmNtopOffset, 8 ); n++;
2097 XtSetValues(widgetList[0], args, n);
2098
2099 n = 0;
2100 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
2101 XtSetArg(args[n], XmNleftWidget, widgetList[0] ); n++;
2102 XtSetArg(args[n], XmNleftOffset, 10 ); n++;
2103 XtSetValues(spin, args, n);
2104
2105 n = 0;
2106 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2107 XtSetArg(args[n], XmNrightOffset, 10 ); n++;
2108 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
2109 XtSetArg(args[n], XmNleftWidget, spin ); n++;
2110 XtSetArg(args[n], XmNleftOffset, 30 ); n++;
2111 XtSetValues(lpSpinBox, args, n);
2112
2113 XtManageChild (spin);
2114 XtManageChild (lpSpinBox);
2115 XtManageChild (form);
2116
2117 return form;
2118 }
2119
2120
2121 ////////////////////////////////////////////////////////////////////////
2122 //
2123 static Widget
2124 createColorAndLinePrefSheetHeader(Widget parent)
2125 //
2126 ////////////////////////////////////////////////////////////////////////
2127 {
2128 Widget widget;
2129 Arg args[6];
2130 int n;
2131
2132 // create a form to hold verything together
2133 Widget form = XtCreateWidget("", xmFormWidgetClass,
2134 parent, NULL, 0);
2135
2136 // create the first line
2137 n=0;
2138 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2139 XtSetArg(args[n], XmNtopOffset, 20 ); n++;
2140 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2141 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2142 XtSetArg(args[n], XmNbottomOffset, 10 ); n++;
2143 widget = XtCreateWidget("|PT TYPE| RED GREEN BLUE | LINE PATTERN |",
2144 xmLabelGadgetClass, form, args, n);
2145
2146 XtManageChild(widget);
2147
2148 return form;
2149 }
2150
2151
2152 ///////////////////////////////////////////////////////////////////////
2153 //
2154 // This simply creates the default parts of the pref dialog.
2155 //
2156 static void
2157 createLineAttrPrefSheetParts(Widget widgetList[], int &num, Widget form, const char** name)
2158 //
2159 ////////////////////////////////////////////////////////////////////////
2160 {
2161 for(int i=0; i<NUM_SP_POINTS; ++i)
2162 {
2163 linePatternTemp[i] = linePattern[i];
2164 linePatternOld[i] = linePattern[i];
2165 for(int j=0; j<3; ++j)
2166 {
2167 lineColorTemp[i][j] = lineColor[i][j];
2168 lineColorOld[i][j] = lineColor[i][j];
2169 }
2170 }
2171
2172 for(int i=0; i<NUM_SP_POINTS; ++i)
2173 widgetList[num++] = createLineColorAndPatternPrefSheetGuts(form, (char *)name[i], i);
2174 }
2175
2176
2177 ////////////////////////////////////////////////////////////////////////
2178 //
2179 // Given a widget list for the preference sheet and it's lenght
2180 // lay them out one after the other and manage them all. The dialog
2181 // is them mapped onto the screen.
2182 //
2183 static void
2184 layoutLineAttrPartsOnThePrefSheet(Widget widgetList[],
2185 int num, Widget form)
2186 //
2187 ////////////////////////////////////////////////////////////////////////
2188 {
2189 Arg args[12];
2190 int n;
2191
2192 // layout
2193 n = 0;
2194 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2195 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2196 XtSetArg(args[n], XmNtopOffset, 20 ); n++;
2197 XtSetValues(widgetList[0], args, n);
2198
2199 n = 0;
2200 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2201 XtSetArg(args[n], XmNtopOffset, 20 ); n++;
2202 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2203 XtSetValues(widgetList[1], args, n);
2204
2205 for (int i=2; i<num; i++)
2206 {
2207 n = 0;
2208 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2209 XtSetArg(args[n], XmNtopWidget, widgetList[i-2]); n++;
2210 if(i%2 == 0)
2211 {
2212 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2213 }
2214 else
2215 {
2216 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2217 }
2218 if (i == (num - 1) )
2219 {
2220 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2221 }
2222 XtSetValues(widgetList[i], args, n);
2223 }
2224
2225 XtManageChildren(widgetList, num);
2226 }
2227
2228
2229 ////////////////////////////////////////////////////////////////////////
2230 //
2231 static void
2232 createPreferShellAndPanedWindow(Widget &dialog_shell, Widget &panedWin)
2233 //
2234 ////////////////////////////////////////////////////////////////////////
2235 {
2236 Arg args[5];
2237 unsigned char modality = (unsigned char)XmDIALOG_PRIMARY_APPLICATION_MODAL;
2238
2239 int n=0;
2240 XtSetArg(args[n], XmNdialogStyle, modality); ++n;
2241 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); ++n;
2242 XtSetArg(args[n], XmNnoResize, TRUE); ++n;
2243 dialog_shell = XmCreateDialogShell(topform, (char *)"Preference Dialog", args, n);
2244
2245 n=0;
2246 XtSetArg(args[n], XmNsashWidth, 2); ++n;
2247 XtSetArg(args[n], XmNsashHeight, 2); ++n;
2248 XtSetArg(args[n], XmNmarginHeight, 12); ++n;
2249 XtSetArg(args[n], XmNmarginWidth, 12); ++n;
2250 panedWin = XmCreatePanedWindow(dialog_shell, (char *)"pane",args,n);
2251
2252 }
2253
2254
2255 ////////////////////////////////////////////////////////////////////////
2256 //
2257 static void
2258 createPreferActionFormControls(Widget &parent)
2259 //
2260 ////////////////////////////////////////////////////////////////////////
2261 {
2262 int n;
2263 Arg args[13];
2264
2265 Widget saveBtn, closeBtn, applyBtn, cancelBtn;
2266
2267 n=0;
2268 Widget form = XmCreateForm(parent, (char *)"control form", args, n);
2269
2270 n=0;
2271 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); ++n;
2272 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); ++n;
2273 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n;
2274 XtSetArg(args[n], XmNleftOffset, 100); ++n;
2275 saveBtn = XmCreatePushButton(form, (char *)" Save ", args, n);
2276 XtManageChild (saveBtn);
2277 XtAddCallback (saveBtn, XmNactivateCallback, savePreferAndUpdateScene, parent );
2278
2279 n=0;
2280 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); ++n;
2281 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); ++n;
2282 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); ++n;
2283 XtSetArg(args[n], XmNrightOffset, 50); ++n;
2284 cancelBtn = XmCreatePushButton(form, (char *)" Cancel ", args, n);
2285 XtManageChild (cancelBtn);
2286 XtAddCallback (cancelBtn, XmNactivateCallback, closePreferDialogAndGiveUpChange, parent);
2287
2288 n=0;
2289 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); ++n;
2290 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); ++n;
2291 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); ++n;
2292 XtSetArg(args[n], XmNleftWidget, saveBtn); ++n;
2293 XtSetArg(args[n], XmNleftOffset, 50); ++n;
2294 closeBtn = XmCreatePushButton(form, (char *)" Update ", args, n);
2295 XtManageChild (closeBtn);
2296 XtAddCallback (closeBtn, XmNactivateCallback, closePreferDialogAndUpdateScene, parent );
2297
2298 n=0;
2299 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); ++n;
2300 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); ++n;
2301 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); ++n;
2302 XtSetArg(args[n], XmNleftWidget, closeBtn); ++n;
2303 XtSetArg(args[n], XmNleftOffset, 50); ++n;
2304 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); ++n;
2305 XtSetArg(args[n], XmNrightWidget, cancelBtn); ++n;
2306 XtSetArg(args[n], XmNrightOffset, 50); ++n;
2307 applyBtn = XmCreatePushButton(form, (char *)" Apply ", args, n);
2308 XtManageChild (applyBtn);
2309 XtAddCallback (applyBtn, XmNactivateCallback, applyPreferDialogChangeAndUpdateScene, parent );
2310
2311 XtManageChild (form);
2312 }
2313
2314
2315 ////////////////////////////////////////////////////////////////////////
2316 //
2317 static Widget
2318 createPreferDefaultPageFrames(Widget parent, const char *frameName)
2319 //
2320 ////////////////////////////////////////////////////////////////////////
2321 {
2322 int n;
2323 Arg args[12];
2324 Widget frame, label;
2325
2326 // create frame for group color settings.
2327 n = 0;
2328 XtSetArg(args[n], XmNshadowType, XmSHADOW_ETCHED_IN); n++;
2329 frame = XmCreateFrame(parent, (char *)"frame", args, n);
2330
2331 n = 0;
2332 XtSetArg(args[n], XmNframeChildType, XmFRAME_TITLE_CHILD); n++;
2333 XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
2334 label = XmCreateLabelGadget (frame, (char *)frameName, args, n);
2335 XtManageChild (label);
2336 return frame;
2337 }
2338
2339
2340 ////////////////////////////////////////////////////////////////////////
2341 //
2342 static void
2343 graphCoordinateSystemToggledCB(Widget widget, XtPointer client_data, XtPointer call_data)
2344 //
2345 ////////////////////////////////////////////////////////////////////////
2346 {
2347 int which = (long) client_data;
2348 XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct *) call_data;
2349
2350 if (state->set == XmSET)
2351 whichCoordSystemTemp = which;
2352 else
2353 whichCoordSystemTemp = 0;
2354 }
2355
2356
2357 ////////////////////////////////////////////////////////////////////////
2358 //
2359 static void
2360 createGraphCoordinateSystemFrameGuts(Widget frame)
2361 //
2362 ////////////////////////////////////////////////////////////////////////
2363 {
2364 int n;
2365 Arg args[12];
2366 const char *coordSysItems[]=
2367 {
2368 "Rotating Frame", "Barycenter " ,
2369 "Large Primary Center", "Small Primary Center"
2370 };
2371
2372 // create default selections
2373 n = 0;
2374 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); ++n;
2375 XtSetArg (args[n], XmNnumColumns, 4); ++n;
2376 Widget toggleBox = XmCreateRadioBox(frame, (char *)"radio", args, n);
2377
2378 whichCoordSystemOld = whichCoordSystem;
2379 whichCoordSystemTemp = whichCoordSystem;
2380
2381 for (unsigned int i = 0; i < XtNumber (coordSysItems); i++)
2382 {
2383 n = 0;
2384 if ((unsigned long)whichCoordSystem == (unsigned long)i) XtSetArg(args[n++], XmNset, XmSET);
2385 Widget w = XmCreateToggleButtonGadget (toggleBox, (char *)coordSysItems[i], args, n);
2386 XtAddCallback (w, XmNvalueChangedCallback, graphCoordinateSystemToggledCB, (XtPointer) i);
2387 XtManageChild (w);
2388 }
2389
2390 XtManageChild (toggleBox);
2391 XtManageChild (frame);
2392 }
2393
2394 ////////////////////////////////////////////////////////////////////////
2395 //
2396 static void
2397 graphStyleWidgetToggledCB(Widget widget, XtPointer client_data, XtPointer call_data)
2398 //
2399 ////////////////////////////////////////////////////////////////////////
2400 {
2401 int which = (long) client_data;
2402 XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct *) call_data;
2403
2404 if (state->set == XmSET)
2405 whichStyleTemp = which;
2406 else
2407 whichStyleTemp = 0;
2408 }
2409
2410
2411 ////////////////////////////////////////////////////////////////////////
2412 //
2413 static void
2414 createGraphStyleFrameGuts(Widget frame)
2415 //
2416 ////////////////////////////////////////////////////////////////////////
2417 {
2418 int n;
2419 Arg args[12];
2420 const char * graphStyleItems[]=
2421 {
2422 "Line Style", "Tube Style" , "Surface Style"
2423 };
2424
2425 // create default selections
2426 n = 0;
2427 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); ++n;
2428 XtSetArg (args[n], XmNnumColumns, 4); ++n;
2429 Widget toggleBox = XmCreateRadioBox(frame, (char *)"togglebox", args, n);
2430 whichStyleOld = whichStyle;
2431 whichStyleTemp = whichStyle;
2432
2433 for (unsigned int i = 0; i < XtNumber (graphStyleItems); i++)
2434 {
2435 n = 0;
2436 if ((unsigned int)whichStyle == i) XtSetArg(args[n++], XmNset, XmSET);
2437 Widget w = XmCreateToggleButtonGadget (toggleBox, (char *)graphStyleItems[i], args, n);
2438 XtAddCallback (w, XmNvalueChangedCallback, graphStyleWidgetToggledCB, (XtPointer) i);
2439 XtManageChild (w);
2440 }
2441
2442 XtManageChild (toggleBox);
2443 XtManageChild (frame);
2444 }
2445
2446
2447 ////////////////////////////////////////////////////////////////////////
2448 //
2449 static void
2450 graphTypeWidgetToggledCB(Widget widget, XtPointer client_data, XtPointer call_data)
2451 //
2452 ////////////////////////////////////////////////////////////////////////
2453 {
2454 int which = (long) client_data;
2455 XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct *) call_data;
2456
2457 if (state->set == XmSET)
2458 whichTypeTemp = which;
2459 else
2460 whichTypeTemp = 0;
2461 }
2462
2463
2464 ////////////////////////////////////////////////////////////////////////
2465 //
2466 static void
2467 graphCoordWidgetToggledCB(Widget widget, XtPointer client_data, XtPointer call_data)
2468 //
2469 ////////////////////////////////////////////////////////////////////////
2470 {
2471 int which = (long) client_data;
2472 XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct *) call_data;
2473
2474 if (state->set == XmSET)
2475 whichCoordTemp = which;
2476 else
2477 whichCoordTemp = 0;
2478 }
2479
2480
2481 ////////////////////////////////////////////////////////////////////////
2482 //
2483 static void
2484 createGraphTypeFrameGuts(Widget frame)
2485 //
2486 ////////////////////////////////////////////////////////////////////////
2487 {
2488 int n;
2489 Arg args[12];
2490 const char * graphTypeItems[]={"Solution Diagram", "Bifurcation Diagram" };
2491
2492 // create default selections
2493 n = 0;
2494 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); ++n;
2495 XtSetArg (args[n], XmNnumColumns, 3); ++n;
2496 XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY_ROUND); ++n;
2497 XtSetArg (args[n], XmNindicatorOn, XmINDICATOR_CHECK); ++n;
2498 Widget toggleBox = XmCreateRadioBox(frame, (char *)"radiobox", args, n);
2499
2500 whichTypeOld = whichType;
2501 whichTypeTemp = whichType;
2502
2503 for (unsigned int i = 0; i < XtNumber (graphTypeItems); i++)
2504 {
2505 n = 0;
2506 if ((unsigned int)whichType == i) XtSetArg(args[n++], XmNset, XmSET);
2507 Widget w = XmCreateToggleButtonGadget (toggleBox, (char *)graphTypeItems[i], args, n);
2508 XtAddCallback (w, XmNvalueChangedCallback, graphTypeWidgetToggledCB, (XtPointer) i);
2509 XtManageChild (w);
2510 }
2511
2512 XtManageChild (toggleBox);
2513 XtManageChild (frame);
2514 }
2515
2516
2517 ////////////////////////////////////////////////////////////////////////
2518 //
2519 // callback for all ToggleButtons.
2520 //
2521 static void
2522 defaultGraphWidgetToggledCB( Widget widget, XtPointer client_data, XtPointer call_data)
2523 //
2524 ////////////////////////////////////////////////////////////////////////
2525 {
2526 int bit = (long) client_data;
2527 XmToggleButtonCallbackStruct *toggle_data = (XmToggleButtonCallbackStruct *) call_data;
2528
2529 if (toggle_data->set == XmSET)
2530 graphWidgetToggleSetTemp |= (1 << bit);
2531 else
2532 graphWidgetToggleSetTemp &= ~(1 << bit);
2533 }
2534
2535
2536 ////////////////////////////////////////////////////////////////////////
2537 //
2538 static void
2539 createOptionFrameGuts(Widget frame)
2540 //
2541 ////////////////////////////////////////////////////////////////////////
2542 {
2543 int n;
2544 Arg args[12];
2545
2546 // create default selections
2547 n = 0;
2548 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); ++n;
2549 XtSetArg (args[n], XmNnumColumns, 4); ++n;
2550 Widget toggleBox = XmCreateRowColumn (frame, (char *)"togglebox", args, n);
2551
2552 for (unsigned int i = 0; i < XtNumber (graphWidgetItems); i++)
2553 {
2554 if (!useR3B && (i == OPT_PRIMARY || i == OPT_LIB_POINTS)) continue;
2555 graphWidgetToggleSetOld = graphWidgetToggleSet;
2556 graphWidgetToggleSetTemp= graphWidgetToggleSet;
2557 n = 0;
2558 if (graphWidgetToggleSet & (1<<i)) XtSetArg(args[n++], XmNset, XmSET);
2559 Widget w = XmCreateToggleButtonGadget (toggleBox, (char *)graphWidgetItems[i], args, n);
2560 XtAddCallback (w, XmNvalueChangedCallback, defaultGraphWidgetToggledCB, (XtPointer) i);
2561 XtManageChild (w);
2562 }
2563
2564 XtManageChild (toggleBox);
2565 XtManageChild (frame);
2566 }
2567
2568 ////////////////////////////////////////////////////////////////////////
2569 //
2570 static void
2571 layoutPreferDefaultPageFrames(Widget widgetList[], int num)
2572 //
2573 ////////////////////////////////////////////////////////////////////////
2574 {
2575 Arg args[12];
2576 int n = 0;
2577
2578 // layout
2579 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2580 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2581
2582 for (int i=0; i<num; i++)
2583 {
2584 int m = n;
2585 if(i==0)
2586 {
2587 XtSetArg(args[m], XmNtopAttachment, XmATTACH_FORM); m++;
2588 XtSetArg(args[m], XmNtopOffset, 20 ); m++;
2589 }
2590 else
2591 {
2592 XtSetArg(args[m], XmNtopAttachment, XmATTACH_WIDGET); m++;
2593 XtSetArg(args[m], XmNtopWidget, widgetList[i-1]); m++;
2594 }
2595
2596 if (i == (num - 1) )
2597 {
2598 XtSetArg(args[m], XmNbottomAttachment, XmATTACH_FORM); m++;
2599 }
2600 XtSetValues(widgetList[i], args, m);
2601 }
2602
2603 XtManageChildren(widgetList, num);
2604 }
2605
2606
2607 ////////////////////////////////////////////////////////////////////////
2608 //
2609 static void
2610 createGraphCoordPartsFrameGuts(Widget frame)
2611 //
2612 ////////////////////////////////////////////////////////////////////////
2613 {
2614 int n;
2615 Arg args[12];
2616 const char *coordItems[]=
2617 {
2618 "No Coordinate", "At Origin" ,
2619 "At Left & Behind", "At Left & Ahead"
2620 };
2621
2622 // create default selections
2623 n = 0;
2624 XtSetArg (args[n], XmNpacking, XmPACK_COLUMN); ++n;
2625 XtSetArg (args[n], XmNnumColumns, 4); ++n;
2626 Widget toggleBox1 = XmCreateRadioBox(frame, (char *)"radio", args, n);
2627
2628 whichCoordOld = whichCoord;
2629 whichCoordTemp = whichCoord;
2630
2631 for (unsigned int i = 0; i < XtNumber (coordItems); i++)
2632 {
2633 n = 0;
2634 if ((unsigned long)whichCoord == (unsigned long)i) XtSetArg(args[n++], XmNset, XmSET);
2635 Widget w = XmCreateToggleButtonGadget (toggleBox1, (char *)coordItems[i], args, n);
2636 XtAddCallback (w, XmNvalueChangedCallback, graphCoordWidgetToggledCB, (XtPointer) i);
2637 XtManageChild (w);
2638 }
2639
2640 XtManageChild (toggleBox1);
2641 XtManageChild (frame);
2642 }
2643
2644
2645 ////////////////////////////////////////////////////////////////////////
2646 //
2647 static void
2648 createPreferDefaultPages(Widget parent)
2649 //
2650 ////////////////////////////////////////////////////////////////////////
2651 {
2652 Widget frameList[6];
2653 int num;
2654 const char * frmNames[]=
2655 {
2656 "Optional Widgets", "Graph Type", "Graph Style",
2657 "Coordinate System", "Coordinate Parts", "Others"
2658 };
2659
2660 unsigned j=0;
2661 for(unsigned int i=0; i<XtNumber(frmNames); ++i)
2662 {
2663 if(!useR3B && i==3)continue;
2664 frameList[j] = createPreferDefaultPageFrames(parent, frmNames[i]);
2665 j++;
2666 }
2667 num = 0;
2668 createOptionFrameGuts(frameList[num++]);
2669 createGraphTypeFrameGuts(frameList[num++]);
2670 createGraphStyleFrameGuts(frameList[num++]);
2671 if(useR3B)
2672 createGraphCoordinateSystemFrameGuts(frameList[num++]);
2673 createGraphCoordPartsFrameGuts(frameList[num++]);
2674 layoutPreferDefaultPageFrames(frameList, num);
2675 }
2676
2677
2678 ////////////////////////////////////////////////////////////////////////
2679 //
2680 static void
2681 createLineAttPages(Widget parent)
2682 //
2683 ////////////////////////////////////////////////////////////////////////
2684 {
2685 const char *names[] =
2686 {
2687 "DEFAULTS", "BP (ALG)", "LP (ALG)",
2688 "HB ", "UZ 4", "UZ -4",
2689 "LP (DIF)", "BP (DIF)", "PD ",
2690 "TR TORUS", "EP (NOR)", "MX (ABN)",
2691 "OTHERS "
2692 };
2693 const char *names2[] =
2694 {
2695 "Color 1", "Color 2", "Color 3",
2696 "Color 4", "Color 5", "Color 6",
2697 "Color 7", "Color 8", "Color 9",
2698 "Color 10", "Color 11", "Color 12",
2699 "Color 13"
2700 };
2701
2702 Widget widgetList[20];
2703
2704 int num = 0;
2705 widgetList[num++] = createColorAndLinePrefSheetHeader(parent);
2706 widgetList[num++] = createColorAndLinePrefSheetHeader(parent);
2707 if(coloringMethod == CL_BRANCH_NUMBER || coloringMethod == CL_CURVE_NUMBER)
2708 createLineAttrPrefSheetParts(widgetList, num, parent, names2);
2709 else
2710 createLineAttrPrefSheetParts(widgetList, num, parent, names);
2711
2712 layoutLineAttrPartsOnThePrefSheet(widgetList, num, parent);
2713 }
2714
2715
2716 ///////////////////////////////////////////////////////////////////////
2717 //
2718 static void
2719 createPreferNotebookPages(Widget notebook)
2720 //
2721 ////////////////////////////////////////////////////////////////////////
2722 {
2723 // create the preference sheet shell and form widget
2724 Widget pageForm[2], tab;
2725 int n=0;
2726 Arg args[14];
2727 const char *tabName[] = { "Menu Item Preferences", "Line Attributes" };
2728
2729 // create the first page.
2730 n = 0;
2731 XtSetArg(args[n], XmNmarginHeight, 15); ++n;
2732 XtSetArg(args[n], XmNmarginWidth, 15); ++n;
2733 pageForm[0] = XmCreateForm(notebook, (char *)"page", args, n);
2734
2735 n = 0;
2736 XtSetArg (args[n], XmNnotebookChildType, XmMINOR_TAB); n++;
2737 tab = XmCreatePushButton (notebook, (char *)tabName[0], args, n);
2738
2739 createPreferDefaultPages(pageForm[0]);
2740 XtManageChild (tab);
2741
2742 // create the second page.
2743 n = 0;
2744 XtSetArg(args[n], XmNmarginHeight, 15); ++n;
2745 XtSetArg(args[n], XmNmarginWidth, 15); ++n;
2746 pageForm[1] = XmCreateForm(notebook, (char *)"page", args, n);
2747
2748 n=0;
2749 XtSetArg (args[n], XmNnotebookChildType, XmMINOR_TAB); n++;
2750 tab = XmCreatePushButton (notebook, (char *)tabName[1], args, n);
2751 createLineAttPages(pageForm[1]);
2752 XtManageChild (tab);
2753
2754 XtManageChildren (pageForm, 2);
2755 }
2756
2757
2758 ////////////////////////////////////////////////////////////////////////
2759 //
2760 static void
2761 createPreferNotebookAndActionForm(Widget parentPane, Widget &notebook, Widget &actionForm)
2762 //
2763 ////////////////////////////////////////////////////////////////////////
2764 {
2765 int n;
2766 Arg args[15];
2767
2768 // create notebook to hold all the pages
2769 n = 0;
2770 XtSetArg(args[n], XmNmarginHeight, 15); ++n;
2771 XtSetArg(args[n], XmNmarginWidth, 10); ++n;
2772 XtSetArg (args[n], XmNunitType, Xm1000TH_INCHES); n++;
2773 XtSetArg (args[n], XmNwidth, 8900); n++;
2774 XtSetArg (args[n], XmNheight, 4800); n++;
2775 XtSetArg (args[n], XmNbackPagePlacement, XmTOP_RIGHT); n++;
2776 XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
2777 XtSetArg (args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
2778 notebook = XmCreateNotebook (parentPane, (char *)"Options", args, n);
2779
2780 n=0;
2781 XtSetArg (args[n], XmNpaneMinimum, 25); n++;
2782 XtSetArg (args[n], XmNpaneMaximum, 35); n++;
2783 XtSetArg (args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
2784
2785 actionForm = XmCreateForm(parentPane, (char *)"action form", args, n);
2786 }
2787
2788
2789 ////////////////////////////////////////////////////////////////////////
2790 //
2791 // This creates the preference sheet in a separate window. It
2792 // calls other routines to create the actual content of the sheet.
2793 //
2794 static void
2795 createPreferDialog()
2796 //
2797 ////////////////////////////////////////////////////////////////////////
2798 {
2799 static Widget shell;
2800
2801 // if(!shell)
2802 {
2803 Widget notebook, actionForm, panedWin;
2804 createPreferShellAndPanedWindow(shell, panedWin);
2805 createPreferNotebookAndActionForm(panedWin, notebook, actionForm);
2806 createPreferNotebookPages(notebook);
2807 createPreferActionFormControls(actionForm);
2808
2809 XtManageChild (notebook);
2810 XtManageChild (actionForm);
2811 XtManageChild (panedWin);
2812 }
2813 XtManageChild (shell);
2814 }
2815
2816
2817 ///////////////////////////////////////////////////////////////////
2818 // CANCEL CALL BACK
2819 //
2820 static void
2821 closePreferDialogAndGiveUpChange(Widget widget, XtPointer client_data, XtPointer call_data)
2822 //
2823 ////////////////////////////////////////////////////////////////////////
2824 {
2825 Widget form = (Widget) client_data;
2826 for(int i=0; i<NUM_SP_POINTS; ++i)
2827 {
2828 linePatternTemp[i] = linePatternOld[i];
2829 linePattern[i] = linePatternOld[i];
2830 for(int j=0; j<3; ++j)
2831 {
2832 lineColorTemp[i][j] = lineColorOld[i][j];
2833 lineColor[i][j] = lineColorOld[i][j];
2834 }
2835 }
2836
2837 whichType = whichTypeOld;
2838 whichTypeTemp = whichTypeOld;
2839 typeMenuItems->which = whichTypeOld;
2840
2841 whichStyle = whichStyleOld;
2842 whichStyleTemp = whichStyleOld;
2843 styleMenuItems->which = whichStyleOld;
2844
2845 if (useR3B)
2846 {
2847 whichCoordSystem = whichCoordSystemOld;
2848 whichCoordSystemTemp = whichCoordSystemOld;
2849 coordSystemMenuItems->which = whichCoordSystemOld;
2850 }
2851
2852 whichCoord = whichCoordOld;
2853 whichCoordTemp = whichCoordOld;
2854 coordMenuItems->which = whichCoordOld;
2855
2856 // cancel the selections and recover the original values.
2857 graphWidgetToggleSetTemp = graphWidgetToggleSetOld;
2858 graphWidgetToggleSet = graphWidgetToggleSetOld;
2859 for (unsigned int i = 0; i < XtNumber (graphWidgetItems); i++)
2860 {
2861 options[i] = (graphWidgetToggleSetOld & (1<<i)) ? true : false;
2862 }
2863
2864 if(options[OPT_SAT_ANI])
2865 XtVaSetValues (satAniSpeedSlider, XmNeditable, TRUE, NULL);
2866 else
2867 XtVaSetValues (satAniSpeedSlider, XmNeditable, FALSE, NULL);
2868
2869 if(options[OPT_PERIOD_ANI])
2870 {
2871 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, TRUE, NULL);
2872 }
2873 else
2874 {
2875 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, FALSE, NULL);
2876 }
2877
2878 XtDestroyWidget (XtParent(XtParent(form)));
2879 updateScene();
2880 }
2881
2882
2883 ///////////////////////////////////////////////////////////////////
2884 // OK & CLOSE CALL BACK
2885 //
2886 static void
2887 closePreferDialogAndUpdateScene(Widget widget, XtPointer client_data, XtPointer call_data)
2888 //
2889 ////////////////////////////////////////////////////////////////////////
2890 {
2891 Widget form = (Widget) client_data;
2892 for(int i=0; i<NUM_SP_POINTS; ++i)
2893 {
2894 linePattern[i] = linePatternTemp[i];
2895 linePatternOld[i] = linePatternTemp[i];
2896 for(int j=0; j<3; ++j)
2897 {
2898 lineColor[i][j] = lineColorTemp[i][j];
2899 lineColorOld[i][j] = lineColorTemp[i][j];
2900 }
2901 }
2902
2903 whichType = whichTypeTemp;
2904 whichTypeOld = whichTypeTemp;
2905 typeMenuItems->which = whichTypeTemp;
2906
2907 whichStyle = whichStyleTemp;
2908 whichStyleOld = whichStyleTemp;
2909 styleMenuItems->which = whichStyleTemp;
2910
2911 if (useR3B)
2912 {
2913 whichCoordSystem = whichCoordSystemTemp;
2914 whichCoordSystemOld = whichCoordSystemTemp;
2915 coordSystemMenuItems->which = whichCoordSystemTemp;
2916 }
2917
2918 whichCoord = whichCoordTemp;
2919 whichCoordOld = whichCoordTemp;
2920 coordMenuItems->which = whichCoordTemp;
2921
2922 graphWidgetToggleSet = graphWidgetToggleSetTemp;
2923 graphWidgetToggleSetOld = graphWidgetToggleSetTemp;
2924 for (unsigned int i = 0; i < XtNumber (graphWidgetItems); i++)
2925 {
2926 options[i] = (graphWidgetToggleSetTemp & (1<<i)) ? true : false;
2927 }
2928
2929 if(options[OPT_SAT_ANI])
2930 XtVaSetValues (satAniSpeedSlider, XmNeditable, TRUE, NULL);
2931 else
2932 XtVaSetValues (satAniSpeedSlider, XmNeditable, FALSE, NULL);
2933
2934 if(options[3])
2935 {
2936 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, TRUE, NULL);
2937 }
2938 else
2939 {
2940 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, FALSE, NULL);
2941 }
2942
2943 updateScene();
2944
2945 XtDestroyWidget (XtParent(XtParent(form)));
2946 }
2947
2948
2949 ///////////////////////////////////////////////////////////////////
2950 // OK & SAVE CALL BACK
2951 //
2952 static void
2953 savePreferAndUpdateScene(Widget widget, XtPointer client_data, XtPointer call_data)
2954 //
2955 ////////////////////////////////////////////////////////////////////////
2956 {
2957 Widget form = (Widget) client_data;
2958 for(int i=0; i<NUM_SP_POINTS; ++i)
2959 {
2960 linePattern[i] = linePatternTemp[i];
2961 linePatternOld[i] = linePatternTemp[i];
2962 for(int j=0; j<3; ++j)
2963 {
2964 lineColor[i][j] = lineColorTemp[i][j];
2965 lineColorOld[i][j] = lineColorTemp[i][j];
2966 }
2967 }
2968
2969 whichType = whichTypeTemp;
2970 whichTypeOld = whichTypeTemp;
2971 typeMenuItems->which = whichTypeTemp;
2972
2973 whichStyle = whichStyleTemp;
2974 whichStyleOld = whichStyleTemp;
2975 styleMenuItems->which = whichStyleTemp;
2976
2977 if (useR3B)
2978 {
2979 whichCoordSystem = whichCoordSystemTemp;
2980 whichCoordSystemOld = whichCoordSystemTemp;
2981 coordSystemMenuItems->which = whichCoordSystemTemp;
2982 }
2983 whichCoord = whichCoordTemp;
2984 whichCoordOld = whichCoordTemp;
2985 coordMenuItems->which = whichCoordTemp;
2986
2987 graphWidgetToggleSet = graphWidgetToggleSetTemp;
2988 graphWidgetToggleSetOld = graphWidgetToggleSetTemp;
2989 for (unsigned int i = 0; i < XtNumber (graphWidgetItems); i++)
2990 {
2991 options[i] = (graphWidgetToggleSetTemp & (1<<i)) ? true : false;
2992 }
2993
2994 if(options[OPT_SAT_ANI])
2995 XtVaSetValues (satAniSpeedSlider, XmNeditable, TRUE, NULL);
2996 else
2997 XtVaSetValues (satAniSpeedSlider, XmNeditable, FALSE, NULL);
2998
2999 if(options[3])
3000 {
3001 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, TRUE, NULL);
3002 }
3003 else
3004 {
3005 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, FALSE, NULL);
3006 }
3007
3008 updateScene();
3009
3010 writePreferValuesToFile();
3011 XtDestroyWidget (XtParent(XtParent(form)));
3012 }
3013
3014
3015 ///////////////////////////////////////////////////////////////////
3016 // APPLY CALL BACK
3017 //
3018 static void
3019 applyPreferDialogChangeAndUpdateScene(
3020 Widget widget, XtPointer client_data, XtPointer call_data)
3021 //
3022 ////////////////////////////////////////////////////////////////////////
3023 {
3024 for(int i=0; i<NUM_SP_POINTS; ++i)
3025 {
3026 linePattern[i]=linePatternTemp[i];
3027 for(int j=0; j<3; ++j)
3028 lineColor[i][j]=lineColorTemp[i][j];
3029 }
3030
3031 whichType = whichTypeTemp;
3032 typeMenuItems->which = whichTypeTemp;
3033
3034 whichStyle = whichStyleTemp;
3035 styleMenuItems->which = whichStyleTemp;
3036
3037 if (useR3B)
3038 {
3039 whichCoordSystem = whichCoordSystemTemp;
3040 coordSystemMenuItems->which = whichCoordSystemTemp;
3041 }
3042
3043 whichCoord = whichCoordTemp;
3044 coordMenuItems->which = whichCoordTemp;
3045
3046 graphWidgetToggleSet = graphWidgetToggleSetTemp;
3047 for (unsigned int i = 0; i < XtNumber (graphWidgetItems); i++)
3048 {
3049 options[i] = (graphWidgetToggleSetTemp & (1<<i)) ? true : false;
3050 }
3051
3052 if(options[OPT_SAT_ANI])
3053 XtVaSetValues (satAniSpeedSlider, XmNeditable, TRUE, NULL);
3054 else
3055 XtVaSetValues (satAniSpeedSlider, XmNeditable, FALSE, NULL);
3056
3057 if(options[OPT_PERIOD_ANI])
3058 {
3059 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, TRUE, NULL);
3060 }
3061 else
3062 {
3063 XtVaSetValues (orbitAniSpeedSlider, XmNeditable, FALSE, NULL);
3064 }
3065
3066 updateScene();
3067 }
3068
3069
3070 ////////////////////////////////////////////////////////////////////////
3071 //
3072 // This routine is called to get a file name using the
3073 // standard file dialog.
3074 //
3075 static void
3076 getFileName(int fileMode)
3077 //
3078 ////////////////////////////////////////////////////////////////////////
3079 {
3080 // use a motif file selection dialog
3081 if (fileDialog == NULL)
3082 {
3083 Arg args[5];
3084 int n = 0;
3085 XtSetArg(args[n], XmNautoUnmanage, TRUE); n++;
3086 if(topform== NULL)
3087 {
3088 printf("mainWindow is NULL!\n");
3089 return;
3090 }
3091 fileDialog = XmCreateFileSelectionDialog(
3092 XtParent(topform), (char *)"File Dialog", args, n);
3093 XtAddCallback(fileDialog, XmNokCallback,
3094 fileDialogCB, (XtPointer)fileMode);
3095 }
3096 XtManageChild(fileDialog);
3097 }
3098
3099
3100 ////////////////////////////////////////////////////////////////////////
3101 //
3102 // Motif file dialog callback.
3103 //
3104 static void
3105 fileDialogCB(Widget, XtPointer client_data, XtPointer call_data)
3106 //
3107 ////////////////////////////////////////////////////////////////////////
3108 {
3109 int fileMode = (long)client_data;
3110 char *filename;
3111 XmFileSelectionBoxCallbackStruct *data =
3112 (XmFileSelectionBoxCallbackStruct *)call_data;
3113 XmStringGetLtoR(data->value,
3114 (XmStringCharSet) XmSTRING_DEFAULT_CHARSET, &filename);
3115
3116 if(fileMode == SAVE_ITEM)
3117 writeToFile(filename);
3118 else if(fileMode == PRINT_ITEM)
3119 {
3120 printToPostScript(root,filename,renderArea,100);
3121 }
3122 else if(fileMode == OPEN_ITEM)
3123 {
3124 deleteScene();
3125 readFile(filename);
3126 }
3127
3128 XtFree(filename);
3129 }
3130
3131
3132 ////////////////////////////////////////////////////////////////////////
3133 //
3134 // Brings up the "ABOUT" dialog
3135 //
3136 static void
3137 showAboutDialog()
3138 //
3139 ////////////////////////////////////////////////////////////////////////
3140 {
3141 static Widget dialog = (Widget) 0 ;
3142 XmString t;
3143 unsigned char modality = (unsigned char)XmDIALOG_FULL_APPLICATION_MODAL;
3144 const char *str;
3145 if (useR3B)
3146 str = " AUTO r3bplaut04\n\n"
3147 " Zhang, Chenghai, Dr. Eusebius J. Doedel\n\n "
3148 " Computer Science Department\n"
3149 " Concordia University\n\n"
3150 " Montreal, Quebec\n"
3151 " CANADA\n\n"
3152 " June, 2004 \n";
3153 else
3154 str = " AUTO plaut04\n\n"
3155 " Zhang, Chenghai, Dr. Eusebius J. Doedel\n\n "
3156 " Computer Science Department\n"
3157 " Concordia University\n\n"
3158 " Montreal, Quebec\n"
3159 " CANADA\n\n"
3160 " August, 2004 \n";
3161
3162 if (!dialog)
3163 {
3164 Arg args[5];
3165 int n = 0;
3166 XmString ok = XmStringCreateLocalized ((char *)"OK");
3167 XtSetArg(args[n], XmNautoUnmanage, False); n++;
3168 XtSetArg(args[n], XmNcancelLabelString, ok); n++;
3169 dialog = XmCreateInformationDialog (topform, (char *)"About", args, n);
3170 Widget remove;
3171 remove = XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON);
3172 XtUnmanageChild(remove);
3173 XtAddCallback (dialog, XmNcancelCallback, showAboutCB, NULL);
3174 XtUnmanageChild (XtNameToWidget (dialog, "OK"));
3175 }
3176
3177
3178 t = XmStringCreateLocalized ((char *)str);
3179 XtVaSetValues (dialog, XmNmessageString, t, XmNdialogStyle, modality, NULL);
3180 XmStringFree (t);
3181 XtManageChild (dialog);
3182 }
3183
3184
3185 ////////////////////////////////////////////////////////////////////////
3186 //
3187 static void
3188 xListCallBack(Widget combo, XtPointer client_data, XtPointer call_data)
3189 //
3190 ////////////////////////////////////////////////////////////////////////
3191 {
3192 XmComboBoxCallbackStruct *cbs = (XmComboBoxCallbackStruct *)call_data;
3193 char *manyChoice = (char *) XmStringUnparse (cbs->item_or_text, XmFONTLIST_DEFAULT_TAG,
3194 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
3195
3196 if (cbs->reason == XmCR_SELECT && cbs->event != NULL)
3197 {
3198 char * tmp;
3199 tmp = strtok(manyChoice, ",");
3200 xCoordIndices.clear();
3201 do
3202 {
3203 xCoordIndices.push_back((strcasecmp(tmp,"t")==0) ? 0 : atoi(tmp));
3204 tmp = strtok(NULL,",");
3205 }while(tmp != NULL);
3206 if(whichType != BIFURCATION)
3207 {
3208 dai.solX = xCoordIndices;
3209 } else {
3210 dai.bifX = xCoordIndices;
3211 }
3212 updateScene();
3213 }
3214 }
3215
3216
3217 ////////////////////////////////////////////////////////////////////////
3218 //
3219 static void
3220 yListCallBack(Widget combo, XtPointer client_data, XtPointer call_data)
3221 //
3222 ////////////////////////////////////////////////////////////////////////
3223 {
3224 XmComboBoxCallbackStruct *cbs = (XmComboBoxCallbackStruct *)call_data;
3225 char *manyChoice = (char *) XmStringUnparse (cbs->item_or_text, XmFONTLIST_DEFAULT_TAG,
3226 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
3227
3228 if (cbs->reason == XmCR_SELECT && cbs->event != NULL)
3229 {
3230 char * tmp;
3231 tmp = strtok(manyChoice, ",");
3232 yCoordIndices.clear();
3233 do
3234 {
3235 yCoordIndices.push_back((strcasecmp(tmp,"t")==0) ? 0 : atoi(tmp));
3236 tmp = strtok(NULL,",");
3237 }while(tmp != NULL);
3238 if(whichType != BIFURCATION)
3239 {
3240 dai.solY = yCoordIndices;
3241 } else {
3242 dai.bifY = yCoordIndices;
3243 }
3244 updateScene();
3245 }
3246 }
3247
3248
3249 ////////////////////////////////////////////////////////////////////////
3250 //
3251 static void
3252 zListCallBack(Widget combo, XtPointer client_data, XtPointer call_data)
3253 //
3254 ////////////////////////////////////////////////////////////////////////
3255 {
3256 XmComboBoxCallbackStruct *cbs = (XmComboBoxCallbackStruct *)call_data;
3257 char *manyChoice = (char *) XmStringUnparse (cbs->item_or_text, XmFONTLIST_DEFAULT_TAG,
3258 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
3259
3260 if (cbs->reason == XmCR_SELECT && cbs->event != NULL)
3261 {
3262 char * tmp;
3263 tmp = strtok(manyChoice, ",");
3264 zCoordIndices.clear();
3265 do
3266 {
3267 zCoordIndices.push_back((strcasecmp(tmp,"t")==0) ? 0 : atoi(tmp));
3268 tmp = strtok(NULL,",");
3269 }while(tmp != NULL);
3270 if(whichType != BIFURCATION)
3271 {
3272 dai.solZ = zCoordIndices;
3273 } else {
3274 dai.bifZ = zCoordIndices;
3275 }
3276 updateScene();
3277 }
3278 }
3279
3280
3281 ////////////////////////////////////////////////////////////////////////
3282 //
3283 static void
3284 lblListCallBack(Widget combo, XtPointer client_data, XtPointer call_data)
3285 //
3286 ////////////////////////////////////////////////////////////////////////
3287 {
3288 XmComboBoxCallbackStruct *cbs = (XmComboBoxCallbackStruct *)call_data;
3289 int choice = (int) cbs->item_position - 1;
3290 int nItems = (whichType != BIFURCATION) ? mySolNode->totalLabels() : myBifNode->totalLabels();
3291 char *manyChoice = (char *) XmStringUnparse (cbs->item_or_text, XmFONTLIST_DEFAULT_TAG,
3292 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
3293
3294 char * tmp;
3295 static int half = 2;
3296 tmp = strtok(manyChoice, ",");
3297 choice -= SP_LBL_ITEMS;
3298 lblIndices.clear();
3299 if(choice <= MY_ALL || choice >= nItems)
3300 {
3301 do
3302 {
3303 lblIndices.push_back((strcasecmp(tmp,"all")==0) ? numLabels + MY_ALL :
3304 atoi(tmp)-myLabels[0]);
3305 tmp = strtok(NULL,",");
3306 }while(tmp != NULL);
3307 half = 2;
3308 }
3309 else if(choice == MY_HALF) // -3
3310 {
3311 for(int j = 0; j < numLabels - SP_LBL_ITEMS; j++)
3312 if(abs(clientData.labelIndex[j][2])!= 4 || (j+1)%half == 0)
3313 lblIndices.push_back(j);
3314 half *= 2;
3315 }
3316 else if(choice == MY_SPEC) // -2
3317 {
3318 for(int j = 0; j < numLabels - SP_LBL_ITEMS; j++)
3319 if(clientData.labelIndex[j][2] != TYPE_UZ && clientData.labelIndex[j][2] != TYPE_RG
3320 && clientData.labelIndex[j][2] != TYPE_EP_ODE && clientData.labelIndex[j][2] != TYPE_MX)
3321 lblIndices.push_back(j);
3322 half = 2;
3323 }
3324 else if(choice == MY_NONE) // -1
3325 {
3326 lblIndices.push_back(numLabels + MY_NONE);
3327 half = 2;
3328 }
3329 else
3330 {
3331 lblIndices.push_back(choice);
3332 half = 2;
3333 }
3334
3335 lblChoice.clear();
3336 if(choice < 0)
3337 lblChoice.push_back(choice);
3338 else for (std::vector<int>::size_type i = 0; i < lblIndices.size(); i++)
3339 lblChoice.push_back(lblIndices[i]);
3340
3341 updateScene();
3342 }
3343
3344
3345 ////////////////////////////////////////////////////////////////////////
3346 //
3347 static void
3348 showAboutCB(Widget dialog, XtPointer client_data, XtPointer call_data)
3349 //
3350 ////////////////////////////////////////////////////////////////////////
3351 {
3352 XtUnmanageChild (dialog);
3353 }
3354
3355
3356 ////////////////////////////////////////////////////////////////////////
3357 //
3358 static void
3359 hidenDialogShell (Widget widget, XtPointer client_data, XtPointer call_data)
3360 //
3361 ////////////////////////////////////////////////////////////////////////
3362 {
3363 XtUnmanageChild (XtParent(widget));
3364 }
3365
3366
3367 ////////////////////////////////////////////////////////////////////////
3368 //
3369 static void
3370 redrawFloqueMultipliers (Widget fmDrawingArea, XtPointer client_data, XtPointer call_data)
3371 //
3372 ////////////////////////////////////////////////////////////////////////
3373 {
3374 XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *) call_data;
3375 int numFM = (int)(long)client_data;
3376
3377 XAllocNamedColor(cbs->event->xexpose.display, colormap, "blue", &blue, &exact);
3378 XAllocNamedColor(cbs->event->xexpose.display, colormap, "green", &green, &exact);
3379 XAllocNamedColor(cbs->event->xexpose.display, colormap, "white", &white, &exact);
3380 XAllocNamedColor(cbs->event->xexpose.display, colormap, "red", &red, &exact);
3381 XAllocNamedColor(cbs->event->xexpose.display, colormap, "black", &black, &exact);
3382 XAllocNamedColor(cbs->event->xexpose.display, colormap, "grey", &grey, &exact);
3383
3384 static XTextItem myText[9] =
3385 {
3386 { (char *)"-inf", 4, 0, None }
3387 ,
3388 { (char *)"-100", 4, 0, None }
3389 ,
3390 { (char *)"-10", 3, 0, None },
3391 { (char *)"-1", 2, 0, None},
3392 { (char *)"0", 1, 0, None }
3393 ,
3394 { (char *)"1", 1, 0, None },
3395 { (char *)"10", 2, 0, None},
3396 { (char *)"100", 3, 0, None }
3397 ,
3398 { (char *)"+inf", 4, 0, None }
3399 };
3400
3401 XSetForeground(cbs->event->xexpose.display, gc, blue.pixel);
3402
3403 // draw Y
3404 XSetLineAttributes(cbs->event->xexpose.display, gc, 2, LineSolid, CapRound, JoinRound);
3405 XDrawLine(cbs->event->xexpose.display, cbs->window, gc, 200, 0, 200, 400);
3406
3407 // draw X
3408 XSetForeground(cbs->event->xexpose.display, gc, red.pixel);
3409 XSetLineAttributes(cbs->event->xexpose.display, gc, 2, LineSolid, CapRound, JoinRound);
3410 XDrawLine(cbs->event->xexpose.display, cbs->window, gc, 0, 200, 400, 200);
3411
3412 // draw grid
3413 XSetForeground(cbs->event->xexpose.display, gc, grey.pixel);
3414 XSetLineAttributes(cbs->event->xexpose.display, gc, 1, LineOnOffDash, CapButt, JoinRound);
3415 for(int i=0; i<9; ++i)
3416 XDrawLine(cbs->event->xexpose.display, cbs->window, gc, 0, 50*i, 400, 50*i);
3417 XSetLineAttributes(cbs->event->xexpose.display, gc, 1, LineOnOffDash, CapButt, JoinRound);
3418 for(int i=0; i<9; ++i)
3419 XDrawLine(cbs->event->xexpose.display, cbs->window, gc, i*50, 0, i*50, 400);
3420
3421 // draw text
3422 XSetForeground(cbs->event->xexpose.display, gc, black.pixel);
3423 for(int i = 0; i < 9; ++i)
3424 XDrawText(cbs->event->xexpose.display,cbs-> window, gc, i*50-3 , 215, &myText[i], 1);
3425 for(int i = 0; i < 9; ++i)
3426 XDrawText(cbs->event->xexpose.display,cbs-> window, gc, 210 , 410-i*50, &myText[i], 1);
3427
3428 XSetForeground(cbs->event->xexpose.display, gc, green.pixel);
3429
3430 // draw a unit circle.
3431 if (numFM > 0) {
3432 XSetLineAttributes(cbs->event->xexpose.display, gc, 1, LineSolid, CapRound, JoinRound);
3433 XDrawArc(cbs->event->xexpose.display, cbs->window, gc, 150, 150, 100, 100, 360*64, 360*64);
3434 }
3435
3436 XSetForeground(cbs->event->xexpose.display, gc, black.pixel);
3437
3438 int x, y;
3439
3440 XSetLineAttributes(cbs->event->xexpose.display, gc, 2, LineSolid, CapRound, JoinRound);
3441 for(int j = 0; j<abs(numFM); ++j)
3442 {
3443 float tmp = fmData[2*j];
3444 if(fabs(tmp) <= 1.1)
3445 x = (tmp>0.0) ? (int)(200+tmp*50) : (int)(200-fabs(tmp)*50);
3446 else
3447 x =(tmp>0.0) ? (int)(250+log10(tmp)*50) : (int)(150-log10(fabs(tmp))*50);
3448
3449 tmp = fmData[2*j+1];
3450 if(fabs(tmp) <= 1.1)
3451 y = (tmp>0.0) ? (int)(200+tmp*50) : (int)(200-fabs(tmp)*50);
3452 else
3453 y =(tmp>0.0) ? (int)(150-log10(tmp)*50): (int)(log10(fabs(tmp))*50+250);
3454
3455 if(x>390) x = 390; if(x<10) y = 10;
3456 if(y>390) y = 390; if(y<10) y = 10;
3457
3458 XDrawLine(cbs->event->xexpose.display, cbs->window, gc, x-3, y-3, x+3, y+3);
3459 XDrawLine(cbs->event->xexpose.display, cbs->window, gc, x-3, y+3, x+3, y-3);
3460
3461 }
3462 }
3463
3464
3465 ////////////////////////////////////////////////////////////////////////
3466 //
3467 void
3468 popupFloquetMultiplierDialog(float data[], int size, int numFM)
3469 //
3470 ////////////////////////////////////////////////////////////////////////
3471 {
3472
3473 static Widget dialog_shell = (Widget) 0 ;
3474 Widget pane = (Widget) 0 ;
3475 XmString str1;
3476 char *str, temp[200];
3477
3478 str = new char[size*50];
3479 str[0]='\0';
3480
3481 for(int i=0; i<size; ++i)
3482 {
3483 strcat(str," Col[");
3484 sprintf(temp,"%2d",i+1);
3485 strcat(str,temp);
3486 strcat(str," ] = ");
3487
3488 sprintf(temp,"%+E",data[i]);
3489 strcat(str,temp);
3490 if(size<20 || (size>=20 && (i+1)%2==0)) strcat(str,"\n");
3491 else strcat(str," | ");
3492 }
3493
3494 char *tmpstr;
3495 tmpstr = new char[500];
3496 tmpstr[0]='\0';
3497 if (numFM <= 0)
3498 strcat(tmpstr,"Eigenvalues:\n" );
3499 else
3500 strcat(tmpstr,"Floquet multipliers:\n" );
3501 for(int j=0; j<abs(numFM); ++j)
3502 {
3503 strcat(tmpstr," [");
3504 sprintf(temp,"%2d",j);
3505 strcat(tmpstr,temp);
3506 strcat(tmpstr,"] : ");
3507 sprintf(temp,"%E",fmData[j*2]);
3508 strcat(tmpstr,temp);
3509 if(fmData[j*2+1] != 0) {
3510 strcat(tmpstr,fmData[j*2+1] < 0 ? " - " : " + ");
3511 sprintf(temp,"%E",fabs(fmData[j*2+1]));
3512 strcat(tmpstr,temp);
3513 strcat(tmpstr,"i\n");
3514 }
3515 }
3516
3517 if (!pane)
3518 {
3519 Widget fmDrawingArea;
3520 Arg args[5];
3521 int n=0;
3522 XtSetArg(args[n], XmNdeleteResponse,XmDESTROY); ++n;
3523 dialog_shell = XmCreateDialogShell(topform, (char *)"Dialog", args, n);
3524
3525 n=0;
3526 XtSetArg(args[n], XmNsashWidth, 1); ++n;
3527 XtSetArg(args[n], XmNsashHeight, 2); ++n;
3528 pane = XmCreatePanedWindow(dialog_shell, (char *)"pane",args,n);
3529
3530 n = 0;
3531 XtSetArg (args[n], XmNunitType, Xm1000TH_INCHES); n++;
3532 XtSetArg (args[n], XmNwidth, 5500); n++;
3533 XtSetArg (args[n], XmNheight, 5500); n++;
3534 XtSetArg (args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3535 fmDrawingArea = XmCreateDrawingArea (pane, (char *)"fmDrawingArea", args, n);
3536
3537 XtAddCallback (fmDrawingArea, XmNexposeCallback, redrawFloqueMultipliers, (XtPointer)numFM);
3538
3539 XtVaSetValues (fmDrawingArea, XmNunitType, XmPIXELS, NULL);
3540
3541 XGCValues gcv;
3542 gcv.foreground = WhitePixelOfScreen (XtScreen (fmDrawingArea));
3543 gc = XCreateGC (XtDisplay (fmDrawingArea),
3544 RootWindowOfScreen (XtScreen (fmDrawingArea)), GCForeground, &gcv);
3545 colormap = DefaultColormapOfScreen(XtScreen(fmDrawingArea));
3546
3547 XSetForeground (XtDisplay (fmDrawingArea), gc,
3548 BlackPixelOfScreen (XtScreen (fmDrawingArea)));
3549
3550 Widget form = XmCreateForm(pane, (char *)"form", NULL,0);
3551 str1 = XmStringCreateLocalized(str);
3552
3553 n = 0;
3554 XtSetArg (args[n], XmNlabelString, str1); ++n;
3555 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
3556 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
3557 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
3558 Widget label3 = XmCreateLabelGadget (form, (char *)"label", args, n);
3559 XtManageChild (label3);
3560
3561 str1 = XmStringCreateLocalized(tmpstr);
3562 n = 0;
3563 XtSetArg (args[n], XmNlabelString, str1); ++n;
3564 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
3565 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
3566 XtSetArg(args[n], XmNleftWidget, label3); n++;
3567 XtSetArg(args[n], XmNleftOffset, 5 ); n++;
3568 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
3569 Widget label2 = XmCreateLabelGadget (form, (char *)"label", args, n);
3570 XtManageChild (label2);
3571
3572 XtManageChild (form);
3573
3574 Widget pushButton = XmCreatePushButtonGadget (pane, (char *)"OK", NULL, 0);
3575 XtAddCallback (pushButton, XmNactivateCallback, hidenDialogShell, dialog_shell);
3576
3577 XtManageChild (pushButton);
3578 XtManageChild (fmDrawingArea);
3579
3580 XmStringFree (str1);
3581 XtManageChild (pane);
3582 }
3583 XtManageChild (dialog_shell);
3584 delete [] str;
3585 delete [] tmpstr;
3586 }
3587
3588
3589 void soxtmain(int argc, char *argv[])
3590 {
3591 // Initialize Inventor and Xt.
3592 Widget mainWindow;
3593 mainWindow = SoXt::init(argv[0]);
3594
3595 if (mainWindow == NULL) return;
3596
3597 root = new SoSeparator;
3598 root->ref();
3599 buildMainWindow(mainWindow, root);
3600
3601 SoXt::show(mainWindow);
3602 SoXt::mainLoop();
3603 root->unref();
3604 }