Debian Codegraph @

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

raw
1 #define LENGTH(arr) ((sizeof(arr) / sizeof(arr[0])))
2
3 #include <sstream>
4
5 #if defined(__APPLE__) && defined(__MACH__)
6 #include <sys/utsname.h>
7 #endif
8
9 #include <Inventor/Qt/SoQt.h>
10 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
11
12 #include <qapplication.h>
13 #include <qpainter.h>
14 #include <qmenubar.h>
15 #include <qfiledialog.h>
16 #include <qcombobox.h>
17 #include <qlabel.h>
18 #include <qmessagebox.h>
19 #include <qtabwidget.h>
20 #include <qradiobutton.h>
21 #include <qcheckbox.h>
22 #include <qlayout.h>
23 #include <qpushbutton.h>
24 #include <qslider.h>
25 #include <qspinbox.h>
26 #include <qtoolbar.h>
27 #include <qbuttongroup.h>
28 #if QT_VERSION < 0x40000
29 #define toLocal8Bit local8Bit
30 #define addButton insert
31 #define addItem insertItem
32 #define setObjectName setName
33 #define setMinimum setMinValue
34 #define setMaximum setMaxValue
35 #define setSingleStep setLineStep
36 #define KEYSEQUENCE_OPEN Qt::CTRL+Qt::Key_O
37 #define KEYSEQUENCE_SAVE Qt::CTRL+Qt::Key_S
38 #define KEYSEQUENCE_PRINT Qt::CTRL+Qt::Key_P
39 #define KEYSEQUENCE_QUIT Qt::CTRL+Qt::Key_Q
40 #else
41 #define setCaption setWindowTitle
42 #define insertItem(a,b,c,d,e) addAction(a,b,c,d)
43 #define insertSeparator addSeparator
44 #define setCurrentItem setCurrentIndex
45 #define currentItem currentIndex
46 #define QPopupMenu QMenu
47 #define setItemChecked(i,x) actions()[i]->setChecked(x)
48 #define setItemEnabled(i,x) actions()[i]->setEnabled(x)
49 #define setItemVisible(i,x) actions()[i]->setVisible(x)
50 #define getSaveFileName(dir,filter,parent,name,caption) getSaveFileName(parent,caption,dir,filter)
51 #define getOpenFileName(dir,filter,parent) getOpenFileName(parent,QString::null,dir,filter)
52 #define KEYSEQUENCE_OPEN QKeySequence::Open
53 #define KEYSEQUENCE_SAVE QKeySequence::Save
54 #define KEYSEQUENCE_PRINT QKeySequence::Print
55 #define KEYSEQUENCE_QUIT QKeySequence::Quit
56 #endif
57
58 #include "gplaut04.h"
59 #include "solution.h"
60 #include "bifurcation.h"
61 #include "gmainqt.h"
62
63 #define LBL_OFFSET 4
64
65 static QSlider *satAniSpeedSlider, *orbitAniSpeedSlider;
66 static EditMenuItems *typeMenuItems, *styleMenuItems, *coordMenuItems;
67 static EditMenuItems *coordSystemMenuItems;
68
69 extern SbBool printToPostScript (SoNode *root, const char *filename,
70 SoQtExaminerViewer *viewer, int printerDPI);
71 extern SoSeparator * createBoundingBox();
72
73 static MainWindow *mainWindow;
74
75 ////////////////////////////////////////////////////////////////////////
76 //
77 // functions
78 //
79 ////////////////////////////////////////////////////////////////////////
80
81 DecSpinBox::DecSpinBox(int minValue, int maxValue, int step, QWidget * parent,
82 const char *name)
83 : QSpinBox(parent)
84 {
85 setMinimum(minValue);
86 setMaximum(maxValue);
87 setSingleStep(step);
88 setObjectName(name);
89 }
90
91 #if QT_VERSION >= 0x40000
92 QString
93 DecSpinBox::textFromValue( int value ) const {
94 return QString("%1.%2").arg(value/10).arg(abs(value%10));
95 }
96
97 int
98 DecSpinBox::valueFromText( QString text ) const {
99 return int(text.toFloat()*10);
100 }
101 #else
102 QString
103 DecSpinBox::mapValueToText( int value ) {
104 return QString("%1.%2").arg(value/10).arg(abs(value%10));
105 }
106
107 int
108 DecSpinBox::mapTextToValue( bool* ok ) {
109 return int(text().toFloat()*10);
110 }
111 #endif
112
113 ////////////////////////////////////////////////////////////////////////
114 //
115 void
116 MainWindow::orbitSpeedCB(int value)
117 //
118 ////////////////////////////////////////////////////////////////////////
119 {
120 orbitSpeed = value/50.0; ///50.0; ///75.0;
121 if(orbitSpeed == 0.0) orbitSpeed = 0.0001;
122 updateScene();
123 }
124
125
126 ////////////////////////////////////////////////////////////////////////
127 //
128 void
129 MainWindow::satSpeedCB(int value)
130 //
131 ////////////////////////////////////////////////////////////////////////
132 {
133 satSpeed = value/100.0;
134 updateScene();
135 }
136
137
138 ////////////////////////////////////////////////////////////////////////
139 //
140 void
141 MainWindow::numPeriodAnimatedCB(const QString &myChoice)
142 //
143 ////////////////////////////////////////////////////////////////////////
144 {
145 if ( myChoice == "inf" )
146 {
147 numPeriodAnimated = -1;
148 }
149 else
150 {
151 numPeriodAnimated = myChoice.toFloat();
152 }
153
154 //cout <<" Num Period Animated "<<myChoice<<" "<<numPeriodAnimated;
155
156 updateScene();
157 }
158
159
160 ////////////////////////////////////////////////////////////////////////
161 //
162 void
163 MainWindow::colorMethodSelectionCB(const QString &myChoic)
164 //
165 ////////////////////////////////////////////////////////////////////////
166 {
167 int choice = colorMethodSeletionList->currentItem();
168 const char *myChoice = myChoic.toLocal8Bit();
169
170 coloringMethod = (strcasecmp(myChoice,"COMP")==0) ? CL_COMPONENT:
171 ((strcasecmp(myChoice,"TYPE")==0) ? CL_ORBIT_TYPE :
172 ((strcasecmp(myChoice,"CURV")==0) ? CL_CURVE_NUMBER:
173 ((strcasecmp(myChoice,"BRAN")==0) ? CL_BRANCH_NUMBER:
174 ((strcasecmp(myChoice,"PONT")==0) ? CL_POINT_NUMBER :
175 ((strcasecmp(myChoice,"LABL")==0) ? CL_LABELS:
176 ((strcasecmp(myChoice,"STAB")==0) ? CL_STABILITY : choice - specialColorItems))))));
177 coloringMethodType[whichType] = coloringMethod;
178
179 updateScene();
180 }
181
182
183 ////////////////////////////////////////////////////////////////////////
184 //
185 void
186 MainWindow::lineWidthCB(int position)
187 //
188 ////////////////////////////////////////////////////////////////////////
189 {
190 lineWidthScaler = position/10.0;
191 updateScene();
192 }
193
194 ////////////////////////////////////////////////////////////////////////
195 //
196 // These are called by Qt when a menu item is picked from the File menu.
197 //
198
199 // Common quit function
200 void
201 MainWindow::quit()
202 {
203 postDeals();
204 delete renderArea;
205 qApp->exit(0);
206 }
207
208 void
209 MainWindow::open()
210 //
211 ////////////////////////////////////////////////////////////////////////
212 {
213 getFileName(OPEN_ITEM);
214 }
215
216 void
217 MainWindow::save()
218 //
219 ////////////////////////////////////////////////////////////////////////
220 {
221 getFileName(SAVE_ITEM);
222 }
223
224 void
225 MainWindow::print()
226 //
227 ////////////////////////////////////////////////////////////////////////
228 {
229 getFileName(PRINT_ITEM);
230 }
231
232 ////////////////////////////////////////////////////////////////////////
233 //
234 // This is called by Qt when a menu item is picked from the Edit menu.
235 //
236 void
237 MainWindow::editMenuPick(int which)
238 //
239 ////////////////////////////////////////////////////////////////////////
240 {
241 EditMenuItems *menuItems;
242 menuItems = coordSystemMenuItems;
243 menuItems->which = which;
244 whichCoordSystem = which;
245 whichCoordSystemOld = whichCoordSystem;
246
247 updateScene();
248 }
249
250 void
251 MainWindow::editMenuRotating()
252 //
253 ////////////////////////////////////////////////////////////////////////
254 {
255 editMenuPick(ROTATING_F);
256 }
257
258 void
259 MainWindow::editMenuBary()
260 //
261 ////////////////////////////////////////////////////////////////////////
262 {
263 editMenuPick(INERTIAL_B);
264 }
265
266 void
267 MainWindow::editMenuBig()
268 //
269 ////////////////////////////////////////////////////////////////////////
270 {
271 editMenuPick(INERTIAL_S);
272 }
273
274 void
275 MainWindow::editMenuSmall()
276 //
277 ////////////////////////////////////////////////////////////////////////
278 {
279 editMenuPick(INERTIAL_E);
280 }
281
282
283 ////////////////////////////////////////////////////////////////////////
284 //
285 // This is called by Qt when a menu item is picked from the TYPE menu.
286 //
287 void
288 MainWindow::typeMenuPick(int which)
289 //
290 ////////////////////////////////////////////////////////////////////////
291 {
292 // get the user data for this menu item.
293 EditMenuItems *menuItems;
294
295 menuItems = typeMenuItems;
296 menuItems->which = which;
297 whichType = which;
298
299 if ( whichType != whichTypeOld )
300 {
301 graphWidgetToggleSet = 0;
302 if( whichType != BIFURCATION )
303 {
304 setShow3D = setShow3DSol;
305 for(int i=0; i<11; ++i)
306 {
307 optBif[i] = options[i];
308 options[i] = optSol[i];
309 graphWidgetToggleSet |= options[i] << i;
310 }
311 }
312 else
313 {
314 setShow3D = setShow3DBif;
315 for(int i=0; i<11; ++i)
316 {
317 optSol[i] = options[i];
318 options[i] = optBif[i];
319 graphWidgetToggleSet |= options[i] << i;
320 }
321 }
322 coloringMethod = coloringMethodType[whichType];
323 }
324
325 whichTypeOld = whichType;
326
327 setListValue();
328
329 updateScene();
330 }
331
332 void
333 MainWindow::typeMenuSolution()
334 //
335 ////////////////////////////////////////////////////////////////////////
336 {
337 typeMenuPick(SOLUTION);
338 }
339
340 void
341 MainWindow::typeMenuBifurcation()
342 //
343 ////////////////////////////////////////////////////////////////////////
344 {
345 typeMenuPick(BIFURCATION);
346 }
347
348 ////////////////////////////////////////////////////////////////////////
349 //
350 // This is called by Qt when a menu item is picked from the Option menu.
351 //
352 void
353 MainWindow::optMenuPick(int which)
354 //
355 ////////////////////////////////////////////////////////////////////////
356 {
357 options[which] = !options[which];
358 if (options[which])
359 graphWidgetToggleSet |= (1 << which);
360 else
361 graphWidgetToggleSet &= ~(1 << which);
362
363 satAniSpeedSlider->setEnabled(options[OPT_SAT_ANI]);
364 orbitAniSpeedSlider->setEnabled(options[OPT_PERIOD_ANI]);
365
366 if(useR3B && graphWidgetToggleSet & (1<<OPT_NORMALIZE_DATA))
367 {
368 options[OPT_PRIMARY] = false;
369 options[OPT_LIB_POINTS] = false;
370 options[OPT_REF_PLAN] = false;
371 graphWidgetToggleSet &= ~(1 << OPT_REF_PLAN);
372 graphWidgetToggleSet &= ~(1 << OPT_LIB_POINTS);
373 graphWidgetToggleSet &= ~(1 << OPT_PRIMARY);
374 }
375
376 updateScene();
377 }
378
379 void
380 MainWindow::optMenuPeriod()
381 //
382 ////////////////////////////////////////////////////////////////////////
383 {
384 optMenuPick(OPT_PERIOD_ANI);
385 }
386
387 void
388 MainWindow::optMenuSat()
389 //
390 ////////////////////////////////////////////////////////////////////////
391 {
392 optMenuPick(OPT_SAT_ANI);
393 }
394
395 void
396 MainWindow::optMenuPlane()
397 //
398 ////////////////////////////////////////////////////////////////////////
399 {
400 optMenuPick(OPT_REF_PLAN);
401 }
402
403 void
404 MainWindow::optMenuSphere()
405 //
406 ////////////////////////////////////////////////////////////////////////
407 {
408 optMenuPick(OPT_REF_SPHERE);
409 }
410
411 void
412 MainWindow::optMenuPrimaries()
413 //
414 ////////////////////////////////////////////////////////////////////////
415 {
416 optMenuPick(OPT_PRIMARY);
417 }
418
419 void
420 MainWindow::optMenuLibration()
421 //
422 ////////////////////////////////////////////////////////////////////////
423 {
424 optMenuPick(OPT_LIB_POINTS);
425 }
426
427 void
428 MainWindow::optMenuLabels()
429 //
430 ////////////////////////////////////////////////////////////////////////
431 {
432 optMenuPick(OPT_DRAW_LABELS);
433 }
434
435 void
436 MainWindow::optMenuNumbers()
437 //
438 ////////////////////////////////////////////////////////////////////////
439 {
440 optMenuPick(OPT_LABEL_NUMBERS);
441 }
442
443 void
444 MainWindow::optMenuBackground()
445 //
446 ////////////////////////////////////////////////////////////////////////
447 {
448 optMenuPick(OPT_BACKGROUND);
449 }
450
451 void
452 MainWindow::optMenuLegend()
453 //
454 ////////////////////////////////////////////////////////////////////////
455 {
456 optMenuPick(OPT_LEGEND);
457 }
458
459 void
460 MainWindow::optMenuNormalize()
461 //
462 ////////////////////////////////////////////////////////////////////////
463 {
464 optMenuPick(OPT_NORMALIZE_DATA);
465 }
466
467 ///////////////////////////////////////////////////////////////////////////
468 //
469 void
470 setListValue()
471 //
472 ///////////////////////////////////////////////////////////////////////////
473 {
474 mainWindow->setListValue();
475 }
476
477 ///////////////////////////////////////////////////////////////////////////
478 //
479 void
480 MainWindow::setListValue()
481 //
482 ///////////////////////////////////////////////////////////////////////////
483 {
484 int nar;
485 if(whichType != BIFURCATION)
486 {
487 xCoordIndices = dai.solX;
488 yCoordIndices = dai.solY;
489 zCoordIndices = dai.solZ;
490 nar = mySolNode->nar();
491 }
492 else
493 {
494 xCoordIndices = dai.bifX;
495 yCoordIndices = dai.bifY;
496 zCoordIndices = dai.bifZ;
497 nar = myBifNode->nar();
498 }
499
500 xAxisList->clear();
501 yAxisList->clear();
502 zAxisList->clear();
503 for (std::vector<std::string>::size_type i = 0; i < xAxis.size(); i++) {
504 xAxisList->addItem(xAxis[i].c_str());
505 yAxisList->addItem(yAxis[i].c_str());
506 zAxisList->addItem(zAxis[i].c_str());
507 }
508
509 coloringMethodList.clear();
510 coloringMethodList.push_back("BRAN");
511 coloringMethodList.push_back("STAB");
512 coloringMethodList.push_back("PONT");
513 coloringMethodList.push_back("CURV");
514
515 specialColorItems = 4;
516
517 if(whichType != BIFURCATION)
518 {
519 coloringMethodList.push_back("TYPE");
520 coloringMethodList.push_back("LABL");
521 coloringMethodList.push_back("COMP");
522 specialColorItems = 7;
523 }
524 for(int i=0; i<nar; ++i)
525 {
526 std::stringstream s;
527 s << i;
528 coloringMethodList.push_back(s.str());
529 }
530 if(whichType != BIFURCATION)
531 {
532 for(int i=0; i<mySolNode->npar(); ++i)
533 {
534 std::stringstream s;
535 s << "PAR(" << mySolNode->parID(i)+1 << ")";
536 coloringMethodList.push_back(s.str());
537 }
538
539 }
540 colorMethodSeletionList->clear();
541 for (std::vector<std::string>::size_type i = 0; i < coloringMethodList.size(); i++)
542 colorMethodSeletionList->addItem(coloringMethodList[i].c_str());
543 labelsList->clear();
544 for (std::vector<std::string>::size_type i = 0; i < labels.size(); i++)
545 labelsList->addItem(labels[i].c_str());
546 xAxisList->setCurrentItem(xCoordIndices[0]);
547 yAxisList->setCurrentItem(yCoordIndices[0]);
548 zAxisList->setCurrentItem(zCoordIndices[0]);
549 labelsList->setCurrentItem(lblChoice[0]+LBL_OFFSET); //lblIndices[0]
550 colorMethodSeletionList->setCurrentItem(coloringMethod < 0 ?
551 coloringMethod+CL_SP_ITEMS : coloringMethod+specialColorItems);
552 dimButton->setText(setShow3D ? "3D" : "2D");
553
554 if(setShow3D)
555 zAxisList->setEnabled(true);
556 else
557 {
558 zCoordIndices.clear();
559 zCoordIndices.push_back(-1);
560 zAxisList->setEnabled(false);
561 }
562 }
563
564
565 ////////////////////////////////////////////////////////////////////////
566 //
567 // This is called by Qt when a menu item is picked from the STYLE menu.
568 //
569 void
570 MainWindow::styleMenuPick(int which)
571 //
572 ////////////////////////////////////////////////////////////////////////
573 {
574 EditMenuItems *menuItems;
575
576 menuItems = styleMenuItems;
577 menuItems->which = which;
578 whichStyle = which;
579 whichStyleOld = whichStyle;
580
581 updateScene();
582 }
583
584 void
585 MainWindow::styleMenuLine()
586 {
587 styleMenuPick(LINE);
588 }
589
590 void
591 MainWindow::styleMenuTube()
592 {
593 styleMenuPick(TUBE);
594 }
595
596 void
597 MainWindow::styleMenuSurface()
598 {
599 styleMenuPick(SURFACE);
600 }
601
602 void
603 MainWindow::styleMenuMesh()
604 {
605 styleMenuPick(MESH_POINTS);
606 }
607
608 void
609 MainWindow::styleMenuAll()
610 {
611 styleMenuPick(ALL_POINTS);
612 }
613
614 ////////////////////////////////////////////////////////////////////////
615 //
616 // This is called by Qt when a menu item is picked from the STYLE menu.
617 //
618 void
619 MainWindow::coordMenuPick(int which)
620 //
621 ////////////////////////////////////////////////////////////////////////
622 {
623 EditMenuItems *menuItems;
624
625 menuItems = coordMenuItems;
626 menuItems->which = which;
627
628 if(which == DRAW_TICKER)
629 blDrawTicker = !blDrawTicker ;
630 else
631 {
632 whichCoord = which;
633 whichCoordOld = whichCoord;
634 }
635
636 updateScene();
637 }
638
639 void
640 MainWindow::coordMenuNone()
641 {
642 coordMenuPick(NO_COORD);
643 }
644
645 void
646 MainWindow::coordMenuCenter()
647 {
648 coordMenuPick(COORDORIGIN);
649 }
650
651 void
652 MainWindow::coordMenuLB()
653 {
654 coordMenuPick(LEFTBACK);
655 }
656
657 void
658 MainWindow::coordMenuLA()
659 {
660 coordMenuPick(LEFTAHEAD);
661 }
662
663 void
664 MainWindow::coordMenuOrigin()
665 {
666 coordMenuPick(COORD_AT_ORIGIN);
667 }
668
669 void
670 MainWindow::coordMenuScale()
671 {
672 coordMenuPick(DRAW_TICKER);
673 }
674
675 ////////////////////////////////////////////////////////////////////////
676 //
677 // This is called by Qt just before the TYPE menu is displayed.
678 //
679 void MainWindow::typeMenuDisplay()
680 //
681 ////////////////////////////////////////////////////////////////////////
682 {
683 EditMenuItems *menuItems = typeMenuItems;
684
685 menuItems->items->setItemChecked(BIFURCATION, false);
686 menuItems->items->setItemChecked(SOLUTION, false);
687
688 menuItems->items->setItemChecked(whichType, true);
689
690 menuItems->items->setItemEnabled(BIFURCATION, true);
691 menuItems->items->setItemEnabled(SOLUTION, true);
692
693 if(mySolNode->numOrbits() == 0)
694 menuItems->items->setItemEnabled(SOLUTION, false);
695
696 if(myBifNode->totalNumPoints() == 0)
697 menuItems->items->setItemEnabled(BIFURCATION, false);
698 }
699
700
701 ////////////////////////////////////////////////////////////////////////
702 //
703 // This is called by Qt just before the STYLE menu is displayed.
704 //
705 void
706 MainWindow::styleMenuDisplay()
707 //
708 ////////////////////////////////////////////////////////////////////////
709 {
710 EditMenuItems *menuItems = styleMenuItems;
711 menuItems->items->setItemChecked(LINE, false);
712 menuItems->items->setItemChecked(TUBE, false);
713 menuItems->items->setItemChecked(SURFACE, false);
714 menuItems->items->setItemChecked(MESH_POINTS, false);
715 menuItems->items->setItemChecked(ALL_POINTS, false);
716
717 if((useR3B && whichCoordSystem != ROTATING_F) || whichType == BIFURCATION)
718 {
719 menuItems->items->setItemEnabled(SURFACE, false);
720 menuItems->items->setItemEnabled(MESH_POINTS, false);
721 menuItems->items->setItemEnabled(ALL_POINTS, false);
722 if(useR3B && (menuItems->which == SURFACE || menuItems->which == MESH_POINTS || menuItems->which == ALL_POINTS))
723 menuItems->which = LINE;
724 }
725 else
726 {
727 menuItems->items->setItemEnabled(SURFACE, true);
728 menuItems->items->setItemEnabled(MESH_POINTS, true);
729 menuItems->items->setItemEnabled(ALL_POINTS, true);
730 }
731
732 menuItems->items->setItemChecked(menuItems->which, true);
733 }
734
735
736 ////////////////////////////////////////////////////////////////////////
737 //
738 // This is called by Qt just before the STYLE menu is displayed.
739 //
740 void
741 MainWindow::coordMenuDisplay()
742 //
743 ////////////////////////////////////////////////////////////////////////
744 {
745 EditMenuItems *menuItems = coordMenuItems;
746
747 if(menuItems->which == DRAW_TICKER)
748 {
749 #if QT_VERSION < 0x40000
750 menuItems->items->setItemChecked(DRAW_TICKER, blDrawTicker);
751 #else
752 menuItems->items->setItemChecked(DRAW_TICKER+1, blDrawTicker);
753 #endif
754 }
755 else
756 {
757 menuItems->items->setItemChecked(NO_COORD, false);
758 menuItems->items->setItemChecked(COORDORIGIN, false);
759 menuItems->items->setItemChecked(LEFTBACK, false);
760 menuItems->items->setItemChecked(LEFTAHEAD, false);
761 menuItems->items->setItemChecked(COORD_AT_ORIGIN, false);
762 #if QT_VERSION < 0x40000
763 menuItems->items->setItemChecked(DRAW_TICKER, blDrawTicker);
764 #else
765 menuItems->items->setItemChecked(DRAW_TICKER+1, blDrawTicker);
766 #endif
767 menuItems->items->setItemChecked(menuItems->which, true);
768 }
769 }
770
771
772 ////////////////////////////////////////////////////////////////////////
773 //
774 // This is called by Qt just before the Edit menu is displayed.
775 //
776 void
777 MainWindow::centerMenuDisplay()
778 //
779 ////////////////////////////////////////////////////////////////////////
780 {
781 EditMenuItems *menuItems = coordSystemMenuItems;
782
783 menuItems->items->setItemChecked(ROTATING_F, false);
784 menuItems->items->setItemChecked(INERTIAL_B, false);
785 menuItems->items->setItemChecked(INERTIAL_S, false);
786 menuItems->items->setItemChecked(INERTIAL_E, false);
787 menuItems->items->setItemChecked(menuItems->which, true);
788
789 bool enable = whichType == SOLUTION;
790 menuItems->items->setItemEnabled(ROTATING_F, enable);
791 menuItems->items->setItemEnabled(INERTIAL_B, enable);
792 menuItems->items->setItemEnabled(INERTIAL_E, enable);
793 menuItems->items->setItemEnabled(INERTIAL_S, enable);
794 }
795
796
797 ////////////////////////////////////////////////////////////////////////
798 //
799 // This is called by Qt just before the TYPE menu is displayed.
800 //
801
802 #if QT_VERSION >= 0x40000
803 #undef setItemChecked
804 #undef setItemEnabled
805 #undef setItemVisible
806 #define setItemChecked(i,x) actions()[optItem(i)]->setChecked(x)
807 #define setItemEnabled(i,x) actions()[optItem(i)]->setEnabled(x)
808 #define setItemVisible(i,x) actions()[optItem(i)]->setVisible(x)
809 #endif
810
811 unsigned
812 MainWindow::optItem(unsigned i)
813 {
814 unsigned j = i;
815 if (useR3B) {
816 if (i > OPT_LIB_POINTS) j = i+1;
817 }
818 else {
819 if (i <= OPT_REF_SPHERE) j += 2; // 0,1=>2,3
820 else if (i <= OPT_SAT_ANI) j -= 4; // 4,5=>0,1
821 else j -= 2; // 6..=>4..
822 }
823 return j;
824 }
825
826 void
827 MainWindow::optMenuDisplay()
828 //
829 ////////////////////////////////////////////////////////////////////////
830 {
831 EditMenuItems *menuItems = optMenuItems;
832
833 for (unsigned i = 0; i < LENGTH (graphWidgetItems); i++)
834 {
835 if (!useR3B && (i == OPT_PRIMARY || i == OPT_LIB_POINTS)) continue;
836 menuItems->items->setItemChecked(i, (graphWidgetToggleSet & (1<<i)) != 0);
837 }
838
839 if (useR3B) {
840 menuItems->items->setItemEnabled(OPT_PRIMARY, blMassDependantOption);
841 menuItems->items->setItemEnabled(OPT_LIB_POINTS, blMassDependantOption);
842
843 if(graphWidgetToggleSet & (1<<OPT_NORMALIZE_DATA))
844 {
845 menuItems->items->setItemEnabled(OPT_PRIMARY, false);
846 menuItems->items->setItemEnabled(OPT_LIB_POINTS, false);
847 menuItems->items->setItemEnabled(OPT_REF_PLAN, false);
848 menuItems->items->setItemChecked(OPT_PRIMARY, false);
849 menuItems->items->setItemChecked(OPT_LIB_POINTS, false);
850 menuItems->items->setItemChecked(OPT_REF_PLAN, false);
851 }
852 else
853 {
854 menuItems->items->setItemEnabled(OPT_PRIMARY, true);
855 menuItems->items->setItemEnabled(OPT_LIB_POINTS, true);
856 menuItems->items->setItemEnabled(OPT_REF_PLAN, true);
857 }
858 }
859
860 menuItems->items->setItemVisible(OPT_PERIOD_ANI, whichType == SOLUTION);
861 menuItems->items->setItemVisible(OPT_SAT_ANI, whichType == SOLUTION);
862 menuItems->items->setItemVisible(OPT_DRAW_LABELS, whichType != SOLUTION);
863 menuItems->items->setItemVisible(OPT_LABEL_NUMBERS, whichType != SOLUTION);
864 if(whichType == BIFURCATION)
865 {
866 menuItems->items->setItemEnabled(OPT_LABEL_NUMBERS,
867 (graphWidgetToggleSet & (1<<OPT_DRAW_LABELS)) != 0);
868 }
869 }
870
871
872 ////////////////////////////////////////////////////////////////////////
873 //
874 // This creates the File menu and all its items.
875 //
876 QPopupMenu *
877 MainWindow::buildFileMenu()
878 //
879 ////////////////////////////////////////////////////////////////////////
880 {
881 QPopupMenu *pulldown;
882
883 #if QT_VERSION < 0x40000
884 pulldown = new QPopupMenu(this);
885 #else
886 pulldown = menuBar()->addMenu(tr("&File"));
887 #endif
888
889 pulldown->insertItem("&Open...", this, SLOT(open()),
890 KEYSEQUENCE_OPEN, -1);
891 pulldown->insertItem("&Export...", this, SLOT(save()),
892 KEYSEQUENCE_SAVE, -1);
893 pulldown->insertItem("&Print...", this, SLOT(print()),
894 KEYSEQUENCE_PRINT, -1);
895 pulldown->insertSeparator();
896 pulldown->insertItem("&Quit", this, SLOT(quit()),
897 KEYSEQUENCE_QUIT, -1);
898 return pulldown;
899 }
900
901
902 ////////////////////////////////////////////////////////////////////////
903 //
904 // This creates the Help menu and all its items.
905 //
906 QPopupMenu *
907 MainWindow::buildHelpMenu()
908 //
909 ////////////////////////////////////////////////////////////////////////
910 {
911 QPopupMenu *pulldown;
912 #if QT_VERSION < 0x40000
913 pulldown = new QPopupMenu(this);
914 #else
915 pulldown = menuBar()->addMenu(tr("&Help"));
916 #endif
917 pulldown->insertItem("&About", this, SLOT(showAboutDialog()), 0, -1);
918 pulldown->insertSeparator();
919 pulldown->insertItem("&HELP", this, SLOT(showHelp()), 0, -1);
920 return pulldown;
921 }
922
923
924 ////////////////////////////////////////////////////////////////////////
925 //
926 // This creates the Option menu and all its items.
927 //
928 QPopupMenu *
929 MainWindow::buildOptionMenu()
930 //
931 ////////////////////////////////////////////////////////////////////////
932 {
933 QPopupMenu *pulldown;
934 #if QT_VERSION < 0x40000
935 pulldown = new QPopupMenu(this);
936 pulldown->setCheckable(true);
937 #else
938 pulldown = menuBar()->addMenu(tr("&Options"));
939 #endif
940
941 connect(pulldown, SIGNAL(aboutToShow()), this, SLOT(optMenuDisplay()));
942
943 EditMenuItems *menuItems = new EditMenuItems;
944 menuItems->items = pulldown;
945 optMenuItems = menuItems;
946 if (!useR3B)
947 {
948 pulldown->insertItem("&Highlight Orbit", this, SLOT(optMenuPeriod()),
949 0, OPT_PERIOD_ANI);
950 pulldown->insertItem("&Orbit Animation", this, SLOT(optMenuSat()),
951 0, OPT_SAT_ANI);
952 }
953 pulldown->insertItem("Draw &Reference Plane", this, SLOT(optMenuPlane()),
954 0, OPT_REF_PLAN);
955 pulldown->insertItem("Draw R&eference Sphere", this, SLOT(optMenuSphere()),
956 0, OPT_REF_SPHERE);
957 if (useR3B)
958 {
959 pulldown->insertItem("Draw &Primaries", this, SLOT(optMenuPrimaries()),
960 0, OPT_PRIMARY);
961 pulldown->insertItem("Draw &Libration Pts", this, SLOT(optMenuLibration()),
962 0, OPT_LIB_POINTS);
963 pulldown->insertSeparator();
964 pulldown->insertItem("&Orbit Animation", this, SLOT(optMenuPeriod()),
965 0, OPT_PERIOD_ANI);
966 pulldown->insertItem("&Satellite Animation", this, SLOT(optMenuSat()),
967 0, OPT_SAT_ANI);
968 }
969 pulldown->insertItem("&Draw Labels", this, SLOT(optMenuLabels()),
970 0, OPT_DRAW_LABELS);
971 pulldown->insertItem("Sho&w Label Numbers", this, SLOT(optMenuNumbers()),
972 0, OPT_LABEL_NUMBERS);
973 pulldown->insertItem("Draw &Background", this, SLOT(optMenuBackground()),
974 0, OPT_BACKGROUND);
975 pulldown->insertItem("&Add Legend", this, SLOT(optMenuLegend()),
976 0, OPT_LEGEND);
977 pulldown->insertItem("&Normalize Data", this, SLOT(optMenuNormalize()),
978 0, OPT_NORMALIZE_DATA);
979 pulldown->insertSeparator();
980 preferDialog = NULL;
981 pulldown->insertItem("&PREFERENCES", this, SLOT(createPreferDialog()), 0, -1);
982
983 #if QT_VERSION >= 0x40000
984 for (int j = 0; j < pulldown->actions().size() - 2; ++j)
985 pulldown->actions()[j]->setCheckable(true);
986 #endif
987 return pulldown;
988 }
989
990
991 ////////////////////////////////////////////////////////////////////////
992 //
993 // This creates the Edit menu and all its items.
994 //
995 QPopupMenu *
996 MainWindow::buildCenterMenu()
997 //
998 ////////////////////////////////////////////////////////////////////////
999 {
1000 QPopupMenu *pulldown;
1001 #if QT_VERSION < 0x40000
1002 pulldown = new QPopupMenu(this);
1003 pulldown->setCheckable(true);
1004 #else
1005 pulldown = menuBar()->addMenu(tr("&Center"));
1006 #endif
1007
1008 connect(pulldown, SIGNAL(aboutToShow()), this, SLOT(centerMenuDisplay()));
1009
1010 coordSystemMenuItems = new EditMenuItems;
1011 coordSystemMenuItems->items = pulldown;
1012 coordSystemMenuItems->which = whichCoordSystem;
1013
1014 pulldown->insertItem("&Rotating Frame", this,
1015 SLOT(editMenuRotating()), 0, ROTATING_F);
1016 pulldown->insertSeparator();
1017 pulldown->insertItem("Bary &Centered", this,
1018 SLOT(editMenuCentered()), 0, INERTIAL_B);
1019 pulldown->insertItem("&Big Primary Centered", this,
1020 SLOT(editMenuBig()), 0, INERTIAL_S);
1021 pulldown->insertItem("&Small Primary Centered", this,
1022 SLOT(editMenuSmall()), 0, INERTIAL_E);
1023 #if QT_VERSION >= 0x40000
1024 for (int i = ROTATING_F; i <= INERTIAL_E; i++)
1025 pulldown->actions()[i]->setCheckable(true);
1026 #endif
1027 return pulldown;
1028 }
1029
1030
1031 ////////////////////////////////////////////////////////////////////////
1032 //
1033 // This creates the STYLE menu and all its items.
1034 //
1035 QPopupMenu *
1036 MainWindow::buildStyleMenu()
1037 //
1038 ////////////////////////////////////////////////////////////////////////
1039 {
1040 QPopupMenu *pulldown;
1041 #if QT_VERSION < 0x40000
1042 pulldown = new QPopupMenu(this);
1043 #else
1044 pulldown = menuBar()->addMenu(tr("&Style"));
1045 #endif
1046
1047 styleMenuItems = new EditMenuItems;
1048 styleMenuItems->items = pulldown;
1049 styleMenuItems->which = whichStyle;
1050 connect(pulldown, SIGNAL(aboutToShow()), this, SLOT(styleMenuDisplay()));
1051
1052 #if QT_VERSION < 0x40000
1053 pulldown->setCheckable(true);
1054 #endif
1055 pulldown->insertItem("&Line", this, SLOT(styleMenuLine()), 0, LINE);
1056 pulldown->insertItem("&Tube", this, SLOT(styleMenuTube()), 0, TUBE);
1057 pulldown->insertItem("&Surface", this, SLOT(styleMenuSurface()),
1058 0, SURFACE);
1059 pulldown->insertItem("&Mesh Points", this, SLOT(styleMenuMesh()),
1060 0, MESH_POINTS);
1061 pulldown->insertItem("&All Points", this, SLOT(styleMenuAll()),
1062 0, ALL_POINTS);
1063 #if QT_VERSION >= 0x40000
1064 for (int i = LINE; i <= ALL_POINTS; i++)
1065 pulldown->actions()[i]->setCheckable(true);
1066 #endif
1067 return pulldown;
1068 }
1069
1070
1071 ////////////////////////////////////////////////////////////////////////
1072 //
1073 // This creates the Coordinates menu and all its items.
1074 //
1075 QPopupMenu *
1076 MainWindow::buildCoordMenu()
1077 //
1078 ////////////////////////////////////////////////////////////////////////
1079 {
1080 QPopupMenu *pulldown;
1081
1082 #if QT_VERSION < 0x40000
1083 pulldown = new QPopupMenu(this);
1084 #else
1085 pulldown = menuBar()->addMenu(tr("&Draw Coord"));
1086 #endif
1087 coordMenuItems = new EditMenuItems;
1088 coordMenuItems->items = pulldown;
1089 coordMenuItems->which = whichCoord;
1090
1091 connect(pulldown, SIGNAL(aboutToShow()), this, SLOT(coordMenuDisplay()));
1092
1093 #if QT_VERSION < 0x40000
1094 pulldown->setCheckable(true);
1095 #endif
1096 pulldown->insertItem("&NONE", this, SLOT(coordMenuNone()), 0, NO_COORD);
1097 pulldown->insertItem("&Coord Center", this, SLOT(coordMenuCenter()),
1098 0, COORDORIGIN);
1099 pulldown->insertItem("Left and &Back", this, SLOT(coordMenuLB()),
1100 0, LEFTBACK);
1101 pulldown->insertItem("Left and &Ahead", this, SLOT(coordMenuLA()),
1102 0, LEFTAHEAD);
1103 pulldown->insertItem("At &Origin", this, SLOT(coordMenuOrigin()),
1104 0, COORD_AT_ORIGIN);
1105 pulldown->insertSeparator();
1106 pulldown->insertItem("&Draw Scale", this, SLOT(coordMenuScale()),
1107 0, DRAW_TICKER);
1108 #if QT_VERSION >= 0x40000
1109 for (int i = COORDORIGIN; i <= COORD_AT_ORIGIN; i++)
1110 pulldown->actions()[i]->setCheckable(true);
1111 pulldown->actions()[DRAW_TICKER+1]->setCheckable(true);
1112 #endif
1113 return pulldown;
1114 }
1115
1116
1117 ////////////////////////////////////////////////////////////////////////
1118 //
1119 // This creates the TYPE menu and all its items.
1120 //
1121 QPopupMenu *
1122 MainWindow::buildTypeMenu()
1123 //
1124 ////////////////////////////////////////////////////////////////////////
1125 {
1126 QPopupMenu *pulldown;
1127
1128 #if QT_VERSION < 0x40000
1129 pulldown = new QPopupMenu(this);
1130 #else
1131 pulldown = menuBar()->addMenu(tr("&Type"));
1132 #endif
1133 typeMenuItems = new EditMenuItems;
1134 typeMenuItems->items = pulldown;
1135 typeMenuItems->which = whichType;
1136
1137 #if QT_VERSION < 0x40000
1138 pulldown->setCheckable(true);
1139 #endif
1140
1141 connect(pulldown, SIGNAL(aboutToShow()), this, SLOT(typeMenuDisplay()));
1142
1143 pulldown->insertItem("&Solution", this, SLOT(typeMenuSolution()),
1144 0, SOLUTION);
1145 pulldown->insertItem("&Bifurcation", this, SLOT(typeMenuBifurcation()),
1146 0, BIFURCATION);
1147
1148 #if QT_VERSION >= 0x40000
1149 pulldown->actions()[SOLUTION]->setCheckable(true);
1150 pulldown->actions()[BIFURCATION]->setCheckable(true);
1151 #endif
1152 return pulldown;
1153 }
1154
1155
1156 ////////////////////////////////////////////////////////////////////////
1157 //
1158 // This creates the pulldown menu bar and its menus.
1159 //
1160 void
1161 MainWindow::buildMenu()
1162 //
1163 ////////////////////////////////////////////////////////////////////////
1164 {
1165 QPopupMenu *pulldown2 = NULL;
1166 QPopupMenu *pulldown1, *pulldown3, *pulldown4, *pulldown5, *pulldown6, *pulldown7;
1167 // menu bar
1168 pulldown1 = buildFileMenu();
1169 if(useR3B)
1170 pulldown2 = buildCenterMenu();
1171 pulldown3 = buildStyleMenu();
1172 pulldown4 = buildTypeMenu();
1173 pulldown7 = buildCoordMenu();
1174 pulldown5 = buildOptionMenu();
1175 pulldown6 = buildHelpMenu();
1176
1177 #ifdef USE_BK_COLOR
1178 // set the background color for the pull down menus.
1179 pulldown1->setPaletteBackgroundColor("white");
1180 if (useR3B) pulldown2->setPaletteBackgroundColor("white");
1181 pulldown3->setPaletteBackgroundColor("white");
1182 pulldown4->setPaletteBackgroundColor("white");
1183 pulldown5->setPaletteBackgroundColor("white");
1184 pulldown6->setPaletteBackgroundColor("white");
1185 #endif
1186 // the text in the menubar for these menus
1187 QMenuBar *menubar = menuBar();
1188 #if QT_VERSION < 0x40000
1189 menubar->insertItem("&File", pulldown1);
1190 menubar->insertItem("&Type", pulldown4);
1191 menubar->insertItem("&Style", pulldown3);
1192 menubar->insertItem("&Draw Coord", pulldown7);
1193 if (useR3B) menubar->insertItem("&Center", pulldown2);
1194 menubar->insertItem("&Options", pulldown5);
1195 menubar->insertItem("&Help", pulldown6);
1196 #endif
1197
1198 #if defined(__APPLE__) && defined(__MACH__)
1199 // Workaround: do not use native menu bar of Mac OS X Mavericks and later
1200 struct utsname info;
1201 if (uname(&info) >= 0) {
1202 char * dot_position = strchr(info.release, '.');
1203 if (dot_position) {
1204 *dot_position = 0;
1205 if (atoi(info.release) >= 13)
1206 menubar->setNativeMenuBar(false);
1207 }
1208 }
1209 #endif
1210 }
1211
1212
1213 ////////////////////////////////////////////////////////////////////////
1214 //
1215 void
1216 MainWindow::dimensionToggledCB()
1217 //
1218 ////////////////////////////////////////////////////////////////////////
1219 {
1220 static bool buttonState = setShow3D;
1221 buttonState = !buttonState;
1222 if(buttonState)
1223 {
1224 setShow3D = true;
1225 zAxisList->setEnabled(true);
1226 setListValue();
1227 }
1228 else
1229 {
1230 setShow3D = false;
1231 zCoordIndices.clear();
1232 zCoordIndices.push_back(-1);
1233 zAxisList->setEnabled(false);
1234 dimButton->setText("2D");
1235 }
1236
1237 if(whichType != BIFURCATION)
1238 setShow3DSol = setShow3D;
1239 else
1240 setShow3DBif = setShow3D;
1241
1242 updateScene();
1243 }
1244
1245
1246 ////////////////////////////////////////////////////////////////////////
1247 //
1248 void
1249 MainWindow::createBdBoxCB()
1250 //
1251 ////////////////////////////////////////////////////////////////////////
1252 {
1253 static bool btnState = false;
1254 SoSeparator * scene = sceneGraph;
1255 btnState = !btnState;
1256 if(btnState)
1257 scene->addChild(createBoundingBox());
1258 else
1259 {
1260 SoSeparator * bdBox = (SoSeparator *)SoNode::getByName("bdBox");
1261 scene->removeChild(bdBox);
1262 }
1263 }
1264
1265 ////////////////////////////////////////////////////////////////////////
1266 //
1267 // This creates the main window contents. In this case, we have a
1268 // menubar at the top of the window, and a render area filling out
1269 // the remainder. These widgets are layed out with a QMainWindow widget.
1270 //
1271 MainWindow::MainWindow() : QMainWindow()
1272 //
1273 ////////////////////////////////////////////////////////////////////////
1274 {
1275 struct ViewerAndScene
1276 {
1277 SoQtExaminerViewer *viewer;
1278 char *filename;
1279 SoNode *scene;
1280 } ;
1281
1282 sceneGraph = new SoSeparator;
1283 sceneGraph->ref();
1284
1285 SoEventCallback *mouseEventCB = new SoEventCallback;
1286 sceneGraph->addChild(mouseEventCB);
1287 sceneGraph->addChild(root);
1288
1289 // build menubar
1290 buildMenu();
1291
1292 // build carrier for the x, y, z, and label lists.
1293 #if QT_VERSION >= 0x40000
1294 QToolBar *listCarrier = addToolBar("ToolBar");
1295 #define ADD_LISTCARRIER_WIDGET(x) listCarrier->addWidget(x)
1296 #else
1297 QToolBar *listCarrier = new QToolBar( this );
1298 #define ADD_LISTCARRIER_WIDGET(x) (void)x
1299 #endif
1300
1301 #ifdef USE_BK_COLOR
1302 setPaletteBackgroundColor("white");
1303 menuBar()->setPaletteBackgroundColor("white");
1304 listCarrier->setPaletteBackgroundColor("white");
1305 #endif
1306
1307 // build the xAxis drop down list
1308 QLabel *xLbl = new QLabel( " X", listCarrier );
1309 ADD_LISTCARRIER_WIDGET(xLbl);
1310 // Create an editable Combobox
1311 xAxisList = new QComboBox(listCarrier);
1312 xAxisList->setObjectName("xAxis");
1313 xAxisList->setEditable(true);
1314 ADD_LISTCARRIER_WIDGET(xAxisList);
1315 for ( std::vector<std::string>::size_type i = 0; i < xAxis.size(); i++ )
1316 xAxisList->addItem( xAxis[i].c_str() );
1317 xAxisList->setCurrentItem(xCoordIndices[0]);
1318 // Connect the activated SIGNALs of the Comboboxes with SLOTs
1319 connect(xAxisList, SIGNAL(activated(const QString &)),
1320 this, SLOT(xListCallBack(const QString &)));
1321
1322 #ifdef USE_BK_COLOR
1323 xAxisList->setPaletteBackgroundColor("white");
1324 #endif
1325
1326 // build the yAxis drop down list
1327 // Create a editable Combobox
1328 QLabel *yLbl = new QLabel(" Y", listCarrier);
1329 ADD_LISTCARRIER_WIDGET(yLbl);
1330 yAxisList = new QComboBox(listCarrier);
1331 yAxisList->setObjectName("yAxis");
1332 yAxisList->setEditable(true);
1333 ADD_LISTCARRIER_WIDGET(yAxisList);
1334 for ( std::vector<std::string>::size_type i = 0; i < yAxis.size(); i++ )
1335 yAxisList->addItem( yAxis[i].c_str() );
1336 yAxisList->setCurrentItem(yCoordIndices[0]);
1337 // Connect the activated SIGNALs of the Comboboxes with SLOTs
1338 connect(yAxisList, SIGNAL(activated(const QString &)),
1339 this, SLOT(yListCallBack(const QString & )));
1340
1341 #ifdef USE_BK_COLOR
1342 yAxisList->setPaletteBackgroundColor("white");
1343 #endif
1344
1345 //build the zAxis drop down list
1346 // Create a editable Combobox
1347 QLabel *zLbl = new QLabel(" Z", listCarrier);
1348 ADD_LISTCARRIER_WIDGET(zLbl);
1349 zAxisList = new QComboBox(listCarrier);
1350 zAxisList->setObjectName("zAxis");
1351 zAxisList->setEditable(true);
1352 ADD_LISTCARRIER_WIDGET(zAxisList);
1353 for ( std::vector<std::string>::size_type i = 0; i < zAxis.size(); i++ )
1354 zAxisList->addItem( zAxis[i].c_str() );
1355 zAxisList->setCurrentItem(zCoordIndices[0]);
1356 // Connect the activated SIGNALs of the Comboboxes with SLOTs
1357 connect(zAxisList, SIGNAL(activated(const QString &)),
1358 this, SLOT(zListCallBack(const QString &)));
1359
1360 #ifdef USE_BK_COLOR
1361 zAxisList->setPaletteBackgroundColor("white");
1362 #endif
1363
1364 // build the LABELs drop down list
1365 QLabel *lLbl = new QLabel(" Label", listCarrier);
1366 ADD_LISTCARRIER_WIDGET(lLbl);
1367 labelsList = new QComboBox(listCarrier);
1368 labelsList->setObjectName("Labels");
1369 labelsList->setEditable(true);
1370 ADD_LISTCARRIER_WIDGET(labelsList);
1371 for ( std::vector<std::string>::size_type i = 0; i < labels.size(); i++ )
1372 labelsList->addItem( labels[i].c_str() );
1373 labelsList->setCurrentItem(lblChoice[0]+LBL_OFFSET); //lblIndices[0]
1374
1375 // Add Callback function for the LABELs drop down list
1376 connect(labelsList, SIGNAL(activated(const QString &)),
1377 this, SLOT(lblListCallBack(const QString &)));
1378
1379 #ifdef USE_BK_COLOR
1380 labelsList->setPaletteBackgroundColor("white");
1381 labelsList->setPaletteForegroundColor("red");
1382 #endif
1383
1384 // build the COLORING Method drop down list
1385 QLabel *colorLbl = new QLabel(" Color", listCarrier);
1386 ADD_LISTCARRIER_WIDGET(colorLbl);
1387 colorMethodSeletionList = new QComboBox(listCarrier);
1388 colorMethodSeletionList->setObjectName("ColorMethodlist");
1389 colorMethodSeletionList->setEditable(true);
1390 ADD_LISTCARRIER_WIDGET(colorMethodSeletionList);
1391 for ( std::vector<std::string>::size_type i = 0;
1392 i < coloringMethodList.size(); i++ )
1393 colorMethodSeletionList->addItem(coloringMethodList[i].c_str());
1394 colorMethodSeletionList->setCurrentItem(coloringMethod < 0 ?
1395 coloringMethod+CL_SP_ITEMS : coloringMethod+specialColorItems);
1396
1397 // Add Callback function for the coloring method seletion drop down list
1398 connect(colorMethodSeletionList, SIGNAL(activated(const QString &)),
1399 this, SLOT(colorMethodSelectionCB(const QString &)));
1400
1401 //-----------------------------------------------------Nov 06
1402
1403 // build the numPeriodAnimated drop down list
1404 QLabel *numPeriodLbl = new QLabel(" Period", listCarrier);
1405 ADD_LISTCARRIER_WIDGET(numPeriodLbl);
1406 int nItems = 7;
1407 int iam = 1;
1408
1409 QComboBox *numPeriodAnimatedList = new QComboBox(listCarrier);
1410 numPeriodAnimatedList->setObjectName("list");
1411 numPeriodAnimatedList->setEditable(true);
1412 ADD_LISTCARRIER_WIDGET(numPeriodAnimatedList);
1413 for ( int j = 0; j < nItems; j++ ) {
1414 QString numberP;
1415
1416 if (j == 0)
1417 {
1418 numberP = "0";
1419 }
1420 else if (j < nItems - 1)
1421 {
1422 numberP.sprintf("%i", iam);
1423 iam *= 2;
1424 }
1425 else
1426 numberP = "inf";
1427 numPeriodAnimatedList->addItem(numberP);
1428 }
1429
1430 int i;
1431 if (numPeriodAnimated > 0)
1432 i = ((int)(log(numPeriodAnimated)/log(2.0))) + 1;
1433 else if (numPeriodAnimated == 0)
1434 i = 0;
1435 else
1436 i = nItems - 1;
1437 numPeriodAnimatedList->setCurrentItem(i);
1438
1439 // Add Callback function for the numberPeriodAnimated drop down list
1440 connect(numPeriodAnimatedList, SIGNAL(activated(const QString &)),
1441 this, SLOT(numPeriodAnimatedCB(const QString &)));
1442
1443 //----------------------------------------------------------------> Nov 06 End
1444
1445 #ifdef USE_BK_COLOR
1446 //set the background color for the labels
1447 xLbl->setPaletteBackgroundColor("white");
1448 yLbl->setPaletteBackgroundColor("white");
1449 zLbl->setPaletteBackgroundColor("white");
1450 lLbl->setPaletteBackgroundColor("white");
1451 #endif
1452
1453 // create spinbox for the line width control.
1454 QLabel *spLbl = new QLabel(" Line Thickness", listCarrier);
1455 ADD_LISTCARRIER_WIDGET(spLbl);
1456 DecSpinBox *spinBox = new DecSpinBox(10, 100, 1, listCarrier, "spinBox");
1457 ADD_LISTCARRIER_WIDGET(spinBox);
1458 spinBox->setValue(10);
1459
1460 // Callbacks for the spinebox
1461 connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(lineWidthCB(int)));
1462
1463 // Create slider to control speed
1464 QLabel *satSldLbl = new QLabel(useR3B ? " Sat " : " Anim", listCarrier);
1465 ADD_LISTCARRIER_WIDGET(satSldLbl);
1466 satAniSpeedSlider = new QSlider(Qt::Horizontal, listCarrier);
1467 satAniSpeedSlider->setObjectName("Speed");
1468 satAniSpeedSlider->setMinimum(MIN_SAT_SPEED);
1469 satAniSpeedSlider->setMaximum(MAX_SAT_SPEED);
1470 satAniSpeedSlider->setPageStep(1);
1471 satAniSpeedSlider->setValue((int)(satSpeed*100));
1472 ADD_LISTCARRIER_WIDGET(satAniSpeedSlider);
1473 satAniSpeedSlider->setEnabled(options[OPT_SAT_ANI]);
1474
1475 #ifdef USE_BK_COLOR
1476 satAniSpeedSlider->setPaletteBackgroundColor("white");
1477 #endif
1478
1479 // Callbacks for the slider
1480 connect(satAniSpeedSlider, SIGNAL(valueChanged(int)),
1481 this, SLOT(satSpeedCB(int)));
1482
1483 QLabel *orbitSldLbl = new QLabel(" Orbit", listCarrier);
1484 ADD_LISTCARRIER_WIDGET(orbitSldLbl);
1485 orbitAniSpeedSlider = new QSlider(Qt::Horizontal, listCarrier);
1486 orbitAniSpeedSlider->setObjectName("Speed2");
1487 orbitAniSpeedSlider->setMinimum(MIN_ORBIT_SPEED);
1488 orbitAniSpeedSlider->setMaximum(MAX_ORBIT_SPEED);
1489 orbitAniSpeedSlider->setPageStep(1);
1490 orbitAniSpeedSlider->setValue((int)(orbitSpeed*50));
1491 ADD_LISTCARRIER_WIDGET(orbitAniSpeedSlider);
1492 orbitAniSpeedSlider->setEnabled(options[OPT_PERIOD_ANI]);
1493
1494 #ifdef USE_BK_COLOR
1495 orbitAniSpeedSlider->setPaletteBackgroundColor("white");
1496 #endif
1497
1498 // Callbacks for the slider2
1499 connect(orbitAniSpeedSlider, SIGNAL(valueChanged(int)),
1500 this, SLOT(orbitSpeedCB(int)));
1501
1502 QWidget *widget = new QWidget(this);
1503 // create RENDER AREA FOR THE graphics.
1504 renderArea = new SoQtExaminerViewer(widget);
1505 renderArea->setSize(SbVec2s(winWidth, winHeight));
1506 renderArea->setBackgroundColor(envColors[0]);
1507 if(useR3B)
1508 renderArea->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
1509
1510 #ifdef USE_EXAM_VIEWER
1511 QFont f("Helvetica", 8);
1512 QPushButton *newButton = new QPushButton("BOX", renderArea->getAppPushButtonParent());
1513 newButton->setFont(f);
1514 newButton->setFixedSize(27,27);
1515
1516 connect(newButton, SIGNAL(clicked()), this, SLOT(createBdBoxCB()));
1517 renderArea->addAppPushButton(newButton);
1518 #endif
1519
1520 QString xString;
1521 zAxisList->setEnabled(setShow3D);
1522 xString = setShow3D ? "3D" : "2D";
1523
1524 dimButton = new QPushButton(xString, renderArea->getAppPushButtonParent());
1525 dimButton->setFont(f);
1526 dimButton->setFixedSize(27,27);
1527 connect(dimButton, SIGNAL(clicked()), this, SLOT(dimensionToggledCB()));
1528 renderArea->addAppPushButton(dimButton);
1529 setCentralWidget(widget);
1530
1531 // used for printing scene to ps files
1532 #if 0
1533 ViewerAndScene *vwrAndScene = new ViewerAndScene;
1534 vwrAndScene->scene = renderArea->getSceneGraph();
1535 vwrAndScene->viewer = renderArea;
1536 #endif
1537
1538 updateScene();
1539 renderArea->setSceneGraph(sceneGraph);
1540
1541 resize(winWidth,winHeight);
1542
1543 mouseEventCB->addEventCallback(
1544 SoMouseButtonEvent::getClassTypeId(),
1545 myMousePressCB,
1546 renderArea->getSceneManager()->getSceneGraph());
1547
1548 // Set termination condition.
1549 connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
1550 }
1551
1552
1553 ////////////////////////////////////////////////////////////////////////
1554 //
1555 LineColorSpinBox::LineColorSpinBox(int minValue, int maxValue, int step,
1556 QWidget * parent, const char *name, int id)
1557 : DecSpinBox(minValue, maxValue, step, parent, name)
1558 //
1559 ////////////////////////////////////////////////////////////////////////
1560 {
1561 setWrapping(true);
1562 which = id;
1563 setValue((int)(lineColor[id/3][id%3]*10));
1564 connect(this, SIGNAL(valueChanged(int)),
1565 this, SLOT(valueChangedCB(int)));
1566 }
1567
1568 ////////////////////////////////////////////////////////////////////////
1569 //
1570 // When the line color changed, this function will be raised.
1571 //
1572 void
1573 LineColorSpinBox::valueChangedCB(int value)
1574 //
1575 ////////////////////////////////////////////////////////////////////////
1576 {
1577 int lineNumber = which / 3;
1578 int columnNumber = which % 3;
1579 lineColorTemp[lineNumber][columnNumber] = value/10.0;
1580 }
1581
1582
1583 ////////////////////////////////////////////////////////////////////////
1584 //
1585 LinePatternComboBox::LinePatternComboBox(bool rw, QWidget * parent,
1586 const char *name, int id)
1587 : QComboBox(parent)
1588 //
1589 ////////////////////////////////////////////////////////////////////////
1590 {
1591 static const char *systemLinePatternLookAndFeel[] =
1592 {
1593 "SOLID LINE", "--------", ". . . . . ", "_ . _ . _ .",
1594 "_ . . _ . .", "_ . . . _", "___ _ ___ _", "____ __ ____",
1595 "NULL "
1596 };
1597
1598 setEditable(rw);
1599 setObjectName(name);
1600 which = id;
1601 int lengthOfSysPatternArray = LENGTH( systemLinePatternLookAndFeel );
1602 for (int i = 0; i < lengthOfSysPatternArray; i++)
1603 addItem(systemLinePatternLookAndFeel[i]);
1604 connect(this, SIGNAL(activated(int)), this, SLOT(valueChangedCB(int)));
1605 }
1606
1607 ////////////////////////////////////////////////////////////////////////
1608 //
1609 // When the line pattern selection changed, this function will be raised.
1610 //
1611 void
1612 LinePatternComboBox::valueChangedCB(int position)
1613 //
1614 ////////////////////////////////////////////////////////////////////////
1615 {
1616 static const unsigned long systemLinePatternValue[] =
1617 {
1618 0xffff, 0x7777, 0x3333, 0xfafa, 0xeaea, 0xffcc, 0xffdc,0xff9c,0
1619 };
1620
1621 linePatternTemp[which] = systemLinePatternValue[position];
1622 }
1623
1624
1625 ////////////////////////////////////////////////////////////////////////
1626 //
1627 // This creates the COLOR and LINE preference sheet stuff.
1628 //
1629 void
1630 PreferDialog::createLineColorAndPatternPrefSheetGuts(QWidget *form, QGridLayout *layout, const char *name, int id)
1631 //
1632 ////////////////////////////////////////////////////////////////////////
1633 {
1634 QLabel *label = new QLabel(name, form);
1635 int column = (id%2) * 9;
1636 int row = 1 + id/2;
1637
1638 layout->addWidget(label, row, column+1);
1639
1640 // Create the red field
1641 LineColorSpinBox *spinred =
1642 new LineColorSpinBox(0, 10, 1, form, "redText", id*3);
1643 layout->addWidget(spinred, row, column+3);
1644
1645 // Create the green field
1646 LineColorSpinBox *spingreen =
1647 new LineColorSpinBox(0, 10, 1, form, "greenText", id*3+1);
1648 layout->addWidget(spingreen, row, column+4);
1649
1650 // Create the blue field
1651 LineColorSpinBox *spinblue =
1652 new LineColorSpinBox(0, 10, 1, form, "blueText", id*3+2);
1653 layout->addWidget(spinblue, row, column+5);
1654
1655 // create the line pattern
1656 LinePatternComboBox *lpComboBox =
1657 new LinePatternComboBox(false, form, "lpSimple", id);
1658 layout->addWidget(lpComboBox, row, column+7);
1659 }
1660
1661
1662 ////////////////////////////////////////////////////////////////////////
1663 //
1664 void
1665 PreferDialog::createColorAndLinePrefSheetHeader(QWidget *parent,
1666 QGridLayout *layout, int column)
1667 //
1668 ////////////////////////////////////////////////////////////////////////
1669 {
1670 // create the first line
1671 //"| PT TYPE | RED GREEN BLUE | LINE PATTERN |"
1672 const char *names[] = { "|", "PT TYPE", "|", "RED", "GREEN", "BLUE", "|",
1673 "LINE PATTERN", "|" };
1674 for (int i = 0; i < 9; i++) {
1675 QLabel *label = new QLabel(names[i], parent);
1676 label->setAlignment(Qt::AlignHCenter);
1677 layout->addWidget(label, 0, column + i);
1678 }
1679 }
1680
1681
1682 ///////////////////////////////////////////////////////////////////////
1683 //
1684 // This simply creates the default parts of the pref dialog.
1685 //
1686 void
1687 PreferDialog::createLineAttrPrefSheetParts(QWidget *parent, QGridLayout *form,
1688 const char** name)
1689 ////////////////////////////////////////////////////////////////////////
1690 {
1691 for(int i=0; i<NUM_SP_POINTS; ++i)
1692 createLineColorAndPatternPrefSheetGuts(parent, form, name[i], i);
1693 for(int i=1; i<(NUM_SP_POINTS+1)/2; ++i)
1694 form->setRowStretch(i, 1);
1695 }
1696
1697
1698 ////////////////////////////////////////////////////////////////////////
1699 //
1700 void
1701 PreferDialog::createPreferActionFormControls(QWidget *parent)
1702 //
1703 ////////////////////////////////////////////////////////////////////////
1704 {
1705 QPushButton *saveBtn, *closeBtn, *applyBtn, *cancelBtn;
1706 #if QT_VERSION < 0x40000
1707 QHBoxLayout *form = new QHBoxLayout(parent, 5, -1);
1708 #else
1709 QHBoxLayout *form = new QHBoxLayout(parent);
1710 #endif
1711 form->setObjectName("control form");
1712
1713 saveBtn = new QPushButton(" &Save ", parent);
1714 connect(saveBtn, SIGNAL(clicked()),
1715 this, SLOT(savePreferAndUpdateScene()));
1716 form->addWidget(saveBtn);
1717
1718 closeBtn = new QPushButton(" &Update ", parent);
1719 form->addWidget(closeBtn);
1720 connect(closeBtn, SIGNAL(clicked()),
1721 this, SLOT(closePreferDialogAndUpdateScene()));
1722
1723 applyBtn = new QPushButton(" &Apply ", parent);
1724 form->addWidget(applyBtn);
1725 connect(applyBtn, SIGNAL(clicked()),
1726 this, SLOT(applyPreferDialogChangeAndUpdateScene()));
1727
1728 cancelBtn = new QPushButton(" &Cancel ", parent);
1729 form->addWidget(cancelBtn);
1730 connect(cancelBtn, SIGNAL(clicked()),
1731 this, SLOT(closePreferDialogAndGiveUpChange()));
1732 }
1733
1734
1735 ////////////////////////////////////////////////////////////////////////
1736 //
1737 void
1738 PreferDialog::graphCoordinateSystemToggledCB(int which)
1739 //
1740 ////////////////////////////////////////////////////////////////////////
1741 {
1742 if(useR3B) whichCoordSystemTemp = which;
1743 }
1744
1745
1746 ////////////////////////////////////////////////////////////////////////
1747 //
1748 void
1749 PreferDialog::createGraphCoordinateSystemFrameGuts(QGroupBox *frame)
1750 //
1751 ////////////////////////////////////////////////////////////////////////
1752 {
1753 const char *coordSysItems[]=
1754 {
1755 "Rotating Frame", "Barycenter " ,
1756 "Large Primary Center", "Small Primary Center"
1757 };
1758
1759 // create default selections
1760
1761 #if QT_VERSION >= 0x40000
1762 QHBoxLayout *layout = new QHBoxLayout(frame);
1763 #endif
1764 QButtonGroup *group = new QButtonGroup;
1765 connect(group,
1766 #if QT_VERSION >= 0x40000
1767 SIGNAL(buttonClicked(int)),
1768 #else
1769 SIGNAL(clicked(int)),
1770 #endif
1771 this, SLOT(graphCoordinateSystemToggledCB(int)));
1772 coordSysButton = new QRadioButton*[LENGTH (coordSysItems)];
1773 for (unsigned int i = 0; i < LENGTH (coordSysItems); i++)
1774 {
1775 QRadioButton *w = new QRadioButton(coordSysItems[i], frame);
1776 group->addButton(w, i);
1777 #if QT_VERSION >= 0x40000
1778 layout->addWidget(w);
1779 #endif
1780 coordSysButton[i] = w;
1781 }
1782 }
1783
1784
1785 ////////////////////////////////////////////////////////////////////////
1786 //
1787 void
1788 PreferDialog::graphStyleWidgetToggledCB(int which)
1789 //
1790 ////////////////////////////////////////////////////////////////////////
1791 {
1792 whichStyleTemp = which;
1793 }
1794
1795
1796 ////////////////////////////////////////////////////////////////////////
1797 //
1798 void
1799 PreferDialog::createGraphStyleFrameGuts(QGroupBox *frame)
1800 //
1801 ////////////////////////////////////////////////////////////////////////
1802 {
1803 const char * graphStyleItems[]=
1804 {
1805 "Line Style", "Tube Style" , "Surface Style"
1806 };
1807
1808 // create default selections
1809
1810 #if QT_VERSION >= 0x40000
1811 QHBoxLayout *layout = new QHBoxLayout(frame);
1812 #endif
1813 QButtonGroup *group = new QButtonGroup;
1814 connect(group,
1815 #if QT_VERSION >= 0x40000
1816 SIGNAL(buttonClicked(int)),
1817 #else
1818 SIGNAL(clicked(int)),
1819 #endif
1820 this, SLOT(graphStyleWidgetToggledCB(int)));
1821 styleButton = new QRadioButton*[LENGTH (graphStyleItems)];
1822 for (unsigned i = 0; i < LENGTH (graphStyleItems); i++)
1823 {
1824 QRadioButton *w = new QRadioButton(graphStyleItems[i], frame);
1825 group->addButton(w, i);
1826 #if QT_VERSION >= 0x40000
1827 layout->addWidget(w);
1828 #endif
1829 styleButton[i] = w;
1830 }
1831 }
1832
1833
1834 ////////////////////////////////////////////////////////////////////////
1835 //
1836 void
1837 PreferDialog::graphTypeWidgetToggledCB(int which)
1838 //
1839 ////////////////////////////////////////////////////////////////////////
1840 {
1841 whichTypeTemp = which;
1842 }
1843
1844
1845 ////////////////////////////////////////////////////////////////////////
1846 //
1847 void
1848 PreferDialog::graphCoordWidgetToggledCB(int which)
1849 //
1850 ////////////////////////////////////////////////////////////////////////
1851 {
1852 whichCoordTemp = which;
1853 }
1854
1855
1856 ////////////////////////////////////////////////////////////////////////
1857 //
1858 void
1859 PreferDialog::createGraphTypeFrameGuts(QGroupBox *frame)
1860 //
1861 ////////////////////////////////////////////////////////////////////////
1862 {
1863 const char *graphTypeItems[]={ "Solution Diagram" , "Bifurcation Diagram" };
1864
1865 #if QT_VERSION >= 0x40000
1866 QHBoxLayout *layout = new QHBoxLayout(frame);
1867 #endif
1868 QButtonGroup *group = new QButtonGroup;
1869 connect(group,
1870 #if QT_VERSION >= 0x40000
1871 SIGNAL(buttonClicked(int)),
1872 #else
1873 SIGNAL(clicked(int)),
1874 #endif
1875 this, SLOT(graphTypeWidgetToggledCB(int)));
1876 typeButton = new QRadioButton*[LENGTH (graphTypeItems)];
1877 for (unsigned i = 0; i < LENGTH (graphTypeItems); i++)
1878 {
1879 QRadioButton *w = new QRadioButton(graphTypeItems[i], frame);
1880 group->addButton(w, i);
1881 #if QT_VERSION >= 0x40000
1882 layout->addWidget(w);
1883 #endif
1884 typeButton[i] = w;
1885 }
1886 }
1887
1888
1889 ////////////////////////////////////////////////////////////////////////
1890 //
1891 // callback for all ToggleButtons.
1892 //
1893 void
1894 PreferDialog::defaultGraphWidgetToggledCB(int bit)
1895 //
1896 ////////////////////////////////////////////////////////////////////////
1897 {
1898 graphWidgetToggleSetTemp ^= (1 << bit);
1899 }
1900
1901
1902 ////////////////////////////////////////////////////////////////////////
1903 //
1904 void
1905 PreferDialog::createOptionFrameGuts(QGroupBox *frame)
1906 //
1907 ////////////////////////////////////////////////////////////////////////
1908 {
1909 // create default selections
1910
1911 #if QT_VERSION >= 0x40000
1912 QGridLayout *layout = new QGridLayout(frame);
1913 #endif
1914 QButtonGroup *group = new QButtonGroup;
1915 group->setExclusive(false);
1916 connect(group,
1917 #if QT_VERSION >= 0x40000
1918 SIGNAL(buttonClicked(int)),
1919 #else
1920 SIGNAL(clicked(int)),
1921 #endif
1922 this, SLOT(defaultGraphWidgetToggledCB(int)));
1923 widgetButton = new QCheckBox*[LENGTH (graphWidgetItems)];
1924 for (unsigned i = 0; i < LENGTH (graphWidgetItems); i++)
1925 {
1926 if (!useR3B && (i == OPT_PRIMARY || i == OPT_LIB_POINTS)) continue;
1927 QCheckBox *w = new QCheckBox(graphWidgetItems[i], frame);
1928 group->addButton(w, i);
1929 #if QT_VERSION >= 0x40000
1930 layout->addWidget(w, i%2, i/2);
1931 #endif
1932 widgetButton[i] = w;
1933 }
1934 }
1935
1936
1937 ////////////////////////////////////////////////////////////////////////
1938 //
1939 void
1940 PreferDialog::createGraphCoordPartsFrameGuts(QGroupBox *frame)
1941 //
1942 ////////////////////////////////////////////////////////////////////////
1943 {
1944 const char *coordItems[]=
1945 {
1946 "No Coordinate", "At Origin" ,
1947 "At Left && Behind", "At Left && Ahead"
1948 };
1949
1950 // create default selections
1951
1952 #if QT_VERSION >= 0x40000
1953 QHBoxLayout *layout = new QHBoxLayout(frame);
1954 #endif
1955 QButtonGroup *group = new QButtonGroup;
1956 connect(group,
1957 #if QT_VERSION >= 0x40000
1958 SIGNAL(buttonClicked(int)),
1959 #else
1960 SIGNAL(clicked(int)),
1961 #endif
1962 this, SLOT(graphCoordWidgetToggledCB(int)));
1963 coordButton = new QRadioButton*[LENGTH (coordItems)];
1964 for (unsigned i = 0; i < LENGTH (coordItems); i++)
1965 {
1966 QRadioButton *w = new QRadioButton(coordItems[i], frame);
1967 group->addButton(w, i);
1968 #if QT_VERSION >= 0x40000
1969 layout->addWidget(w);
1970 #endif
1971 coordButton[i] = w;
1972 }
1973 }
1974
1975
1976 ////////////////////////////////////////////////////////////////////////
1977 //
1978 void
1979 PreferDialog::createPreferDefaultPages(QWidget *parent)
1980 //
1981 ////////////////////////////////////////////////////////////////////////
1982 {
1983 QGroupBox *frameList[5];
1984 int num;
1985 const char * frmNames[]=
1986 {
1987 "Optional Widgets", "Graph Type", "Graph Style",
1988 "Coordinate System",
1989 "Coordinate Parts"
1990 };
1991
1992 QVBoxLayout *layout = new QVBoxLayout(parent);
1993 unsigned j=0;
1994 for(unsigned i=0; i<LENGTH(frmNames); ++i) {
1995 if(!useR3B && i==3) continue;
1996 #if QT_VERSION >= 0x40000
1997 frameList[j] = new QGroupBox(frmNames[i], parent);
1998 #else
1999 int rows[] = {2, 1, 1, 1, 1};
2000 frameList[j] = new QGroupBox(rows[i], Qt::Vertical, frmNames[i], parent);
2001 #endif
2002 layout->addWidget(frameList[j]);
2003 j++;
2004 }
2005 num = 0;
2006 createOptionFrameGuts(frameList[num++]);
2007 createGraphTypeFrameGuts(frameList[num++]);
2008 createGraphStyleFrameGuts(frameList[num++]);
2009 if(useR3B) createGraphCoordinateSystemFrameGuts(frameList[num++]);
2010 createGraphCoordPartsFrameGuts(frameList[num++]);
2011 }
2012
2013
2014 ////////////////////////////////////////////////////////////////////////
2015 //
2016 void
2017 PreferDialog::createLineAttPages(QWidget *parent)
2018 //
2019 ////////////////////////////////////////////////////////////////////////
2020 {
2021 //const char *tabName[] = { "Line Attributes", "Other Preferences" };
2022 const char *names[] =
2023 {
2024 "DEFAULTS", "BP (ALG)", "LP (ALG)",
2025 "HB ", "UZ 4", "UZ -4",
2026 "LP (DIF)", "BP (DIF)", "PD ",
2027 "TR TORUS", "EP (NOR)", "MX (ABN)",
2028 "OTHERS "
2029 };
2030 const char *names2[] =
2031 {
2032 "Color 1", "Color 2", "Color 3",
2033 "Color 4", "Color 5", "Color 6",
2034 "Color 7", "Color 8", "Color 9",
2035 "Color 10", "Color 11", "Color 12",
2036 "Color 13"
2037 };
2038
2039 #if QT_VERSION < 0x40000
2040 QGridLayout *layout = new QGridLayout(parent, 8, 18);
2041 #else
2042 QGridLayout *layout = new QGridLayout(parent);
2043 #endif
2044 createColorAndLinePrefSheetHeader(parent, layout, 0);
2045 createColorAndLinePrefSheetHeader(parent, layout, 9);
2046 if(coloringMethod == CL_BRANCH_NUMBER || coloringMethod == CL_CURVE_NUMBER)
2047 createLineAttrPrefSheetParts(parent, layout, names2);
2048 else
2049 createLineAttrPrefSheetParts(parent, layout, names);
2050 }
2051
2052
2053 ///////////////////////////////////////////////////////////////////////
2054 //
2055 void
2056 PreferDialog::createPreferNotebookPages(QTabWidget *notebook)
2057 //
2058 ////////////////////////////////////////////////////////////////////////
2059 {
2060 // create the preference sheet shell and form widget
2061 const char *tabName[] = { "Menu Item Preferences", "Line Attributes" };
2062
2063 // create the first page.
2064 QWidget *pageForm0 = new QWidget(notebook);
2065 pageForm0->setObjectName("pageForm0");
2066 createPreferDefaultPages(pageForm0);
2067 notebook->addTab(pageForm0, tabName[0]);
2068
2069 // create the second page.
2070 QWidget *pageForm1 = new QWidget(notebook);
2071 pageForm1->setObjectName("pageForm1");
2072 createLineAttPages(pageForm1);
2073 notebook->addTab(pageForm1, tabName[1]);
2074 }
2075
2076
2077 ////////////////////////////////////////////////////////////////////////
2078 //
2079 // This creates the preference sheet in a separate window. It
2080 // calls other routines to create the actual content of the sheet.
2081 //
2082 void
2083 MainWindow::createPreferDialog()
2084 //
2085 ////////////////////////////////////////////////////////////////////////
2086 {
2087 if(!preferDialog)
2088 {
2089 preferDialog = new PreferDialog(this, "Preference Dialog");
2090 }
2091 preferDialog->update();
2092 preferDialog->show();
2093 }
2094
2095 ////////////////////////////////////////////////////////////////////////
2096 //
2097 PreferDialog::PreferDialog(QWidget * parent, const char *name) :
2098 QDialog(parent)
2099 //
2100 ////////////////////////////////////////////////////////////////////////
2101 {
2102 setObjectName(name);
2103 setCaption("Preference Dialog");
2104 #if QT_VERSION < 0x40000
2105 QVBoxLayout *panedWin = new QVBoxLayout(this, 5, -1);
2106 #else
2107 QVBoxLayout *panedWin = new QVBoxLayout(this);
2108 #endif
2109 panedWin->setObjectName("pane");
2110
2111 // create notebook to hold all the pages
2112 QTabWidget *notebook = new QTabWidget(this);
2113 notebook->setObjectName("Options");
2114 createPreferNotebookPages(notebook);
2115 panedWin->addWidget(notebook);
2116
2117 QWidget *actionForm = new QWidget(this);
2118 actionForm->setObjectName("action form");
2119 createPreferActionFormControls(actionForm);
2120 panedWin->addWidget(actionForm);
2121 setModal(false);
2122 }
2123
2124 ////////////////////////////////////////////////////////////////////////
2125 //
2126 void PreferDialog::update()
2127 //
2128 ////////////////////////////////////////////////////////////////////////
2129 {
2130 for(int i=0; i<NUM_SP_POINTS; ++i)
2131 {
2132 linePatternTemp[i] = linePattern[i];
2133 linePatternOld[i] = linePattern[i];
2134 for(int j=0; j<3; ++j)
2135 {
2136 lineColorTemp[i][j] = lineColor[i][j];
2137 lineColorOld[i][j] = lineColor[i][j];
2138 }
2139 }
2140
2141 whichStyleOld = whichStyle;
2142 whichStyleTemp = whichStyle;
2143 styleButton[whichStyle]->setChecked(true);
2144
2145 whichTypeOld = whichType;
2146 whichTypeTemp = whichType;
2147 typeButton[whichType]->setChecked(true);
2148
2149 graphWidgetToggleSetOld = graphWidgetToggleSet;
2150 graphWidgetToggleSetTemp= graphWidgetToggleSet;
2151 for (unsigned i = 0; i < LENGTH (graphWidgetItems); i++)
2152 {
2153 if (!useR3B && (i == OPT_PRIMARY || i == OPT_LIB_POINTS)) continue;
2154 widgetButton[i]->setChecked((graphWidgetToggleSet & (1<<i)) != 0);
2155 }
2156
2157 whichCoordOld = whichCoord;
2158 whichCoordTemp = whichCoord;
2159 coordButton[whichCoord]->setChecked(true);
2160
2161 if (useR3B)
2162 {
2163 whichCoordSystemOld = whichCoordSystem;
2164 whichCoordSystemTemp = whichCoordSystem;
2165 coordSysButton[whichCoordSystem]->setChecked(true);
2166 }
2167 }
2168
2169 ///////////////////////////////////////////////////////////////////
2170 // CANCEL CALL BACK
2171 //
2172 void
2173 PreferDialog::closePreferDialogAndGiveUpChange()
2174 //
2175 ////////////////////////////////////////////////////////////////////////
2176 {
2177 for(int i=0; i<NUM_SP_POINTS; ++i)
2178 {
2179 linePatternTemp[i] = linePatternOld[i];
2180 linePattern[i] = linePatternOld[i];
2181 for(int j=0; j<3; ++j)
2182 {
2183 lineColorTemp[i][j] = lineColorOld[i][j];
2184 lineColor[i][j] = lineColorOld[i][j];
2185 }
2186 }
2187
2188 whichType = whichTypeOld;
2189 whichTypeTemp = whichTypeOld;
2190 typeMenuItems->which = whichTypeOld;
2191
2192 whichStyle = whichStyleOld;
2193 whichStyleTemp = whichStyleOld;
2194 styleMenuItems->which = whichStyleOld;
2195
2196 if (useR3B)
2197 {
2198 whichCoordSystem = whichCoordSystemOld;
2199 whichCoordSystemTemp = whichCoordSystemOld;
2200 coordSystemMenuItems->which = whichCoordSystemOld;
2201 }
2202
2203 whichCoord = whichCoordOld;
2204 whichCoordTemp = whichCoordOld;
2205 coordMenuItems->which = whichCoordOld;
2206
2207 // cancel the selections and recover the original values.
2208 graphWidgetToggleSetTemp = graphWidgetToggleSetOld;
2209 graphWidgetToggleSet = graphWidgetToggleSetOld;
2210 for (unsigned i = 0; i < LENGTH (graphWidgetItems); i++)
2211 {
2212 options[i] = (graphWidgetToggleSetOld & (1<<i)) ? true : false;
2213 }
2214
2215 satAniSpeedSlider->setEnabled(options[OPT_SAT_ANI]);
2216 orbitAniSpeedSlider->setEnabled(options[OPT_PERIOD_ANI]);
2217 updateScene();
2218 QDialog::reject();
2219 }
2220
2221
2222 ///////////////////////////////////////////////////////////////////
2223 // OK & CLOSE CALL BACK
2224 //
2225 void
2226 PreferDialog::closePreferDialogAndUpdateScene()
2227 //
2228 ////////////////////////////////////////////////////////////////////////
2229 {
2230 for(int i=0; i<NUM_SP_POINTS; ++i)
2231 {
2232 linePattern[i] = linePatternTemp[i];
2233 linePatternOld[i] = linePatternTemp[i];
2234 for(int j=0; j<3; ++j)
2235 {
2236 lineColor[i][j] = lineColorTemp[i][j];
2237 lineColorOld[i][j] = lineColorTemp[i][j];
2238 }
2239 }
2240
2241 whichType = whichTypeTemp;
2242 whichTypeOld = whichTypeTemp;
2243 typeMenuItems->which = whichTypeTemp;
2244
2245 whichStyle = whichStyleTemp;
2246 whichStyleOld = whichStyleTemp;
2247 styleMenuItems->which = whichStyleTemp;
2248
2249 if (useR3B)
2250 {
2251 whichCoordSystem = whichCoordSystemTemp;
2252 whichCoordSystemOld = whichCoordSystemTemp;
2253 coordSystemMenuItems->which = whichCoordSystemTemp;
2254 }
2255 whichCoord = whichCoordTemp;
2256 whichCoordOld = whichCoordTemp;
2257 coordMenuItems->which = whichCoordTemp;
2258
2259 graphWidgetToggleSet = graphWidgetToggleSetTemp;
2260 graphWidgetToggleSetOld = graphWidgetToggleSetTemp;
2261 for (unsigned i = 0; i < LENGTH (graphWidgetItems); i++)
2262 {
2263 options[i] = (graphWidgetToggleSetTemp & (1<<i)) ? true : false;
2264 }
2265
2266 satAniSpeedSlider->setEnabled(options[OPT_SAT_ANI]);
2267 orbitAniSpeedSlider->setEnabled(options[OPT_PERIOD_ANI]);
2268 updateScene();
2269 QDialog::reject();
2270 }
2271
2272
2273 ///////////////////////////////////////////////////////////////////
2274 // OK & SAVE CALL BACK
2275 //
2276 void
2277 PreferDialog::savePreferAndUpdateScene()
2278 //
2279 ////////////////////////////////////////////////////////////////////////
2280 {
2281 for(int i=0; i<NUM_SP_POINTS; ++i)
2282 {
2283 linePattern[i] = linePatternTemp[i];
2284 linePatternOld[i] = linePatternTemp[i];
2285 for(int j=0; j<3; ++j)
2286 {
2287 lineColor[i][j] = lineColorTemp[i][j];
2288 lineColorOld[i][j] = lineColorTemp[i][j];
2289 }
2290 }
2291
2292 whichType = whichTypeTemp;
2293 whichTypeOld = whichTypeTemp;
2294 typeMenuItems->which = whichTypeTemp;
2295
2296 whichStyle = whichStyleTemp;
2297 whichStyleOld = whichStyleTemp;
2298 styleMenuItems->which = whichStyleTemp;
2299
2300 if (useR3B)
2301 {
2302 whichCoordSystem = whichCoordSystemTemp;
2303 whichCoordSystemOld = whichCoordSystemTemp;
2304 coordSystemMenuItems->which = whichCoordSystemTemp;
2305 }
2306
2307 whichCoord = whichCoordTemp;
2308 whichCoordOld = whichCoordTemp;
2309 coordMenuItems->which = whichCoordTemp;
2310
2311 graphWidgetToggleSet = graphWidgetToggleSetTemp;
2312 graphWidgetToggleSetOld = graphWidgetToggleSetTemp;
2313 for (unsigned i = 0; i < LENGTH (graphWidgetItems); i++)
2314 {
2315 options[i] = (graphWidgetToggleSetTemp & (1<<i)) ? true : false;
2316 }
2317
2318 satAniSpeedSlider->setEnabled(options[OPT_SAT_ANI]);
2319 orbitAniSpeedSlider->setEnabled(options[OPT_PERIOD_ANI]);
2320 updateScene();
2321
2322 writePreferValuesToFile();
2323 QDialog::accept();
2324 }
2325
2326
2327 ///////////////////////////////////////////////////////////////////
2328 // APPLY CALL BACK
2329 //
2330 void
2331 PreferDialog::applyPreferDialogChangeAndUpdateScene()
2332 //
2333 ////////////////////////////////////////////////////////////////////////
2334 {
2335 for(int i=0; i<NUM_SP_POINTS; ++i)
2336 {
2337 linePattern[i]=linePatternTemp[i];
2338 for(int j=0; j<3; ++j)
2339 lineColor[i][j]=lineColorTemp[i][j];
2340 }
2341
2342 whichType = whichTypeTemp;
2343 typeMenuItems->which = whichTypeTemp;
2344
2345 whichStyle = whichStyleTemp;
2346 styleMenuItems->which = whichStyleTemp;
2347
2348 if (useR3B) {
2349 whichCoordSystem = whichCoordSystemTemp;
2350 coordSystemMenuItems->which = whichCoordSystemTemp;
2351 }
2352
2353 whichCoord = whichCoordTemp;
2354 coordMenuItems->which = whichCoordTemp;
2355
2356 graphWidgetToggleSet = graphWidgetToggleSetTemp;
2357 for (unsigned i = 0; i < LENGTH (graphWidgetItems); i++)
2358 {
2359 options[i] = (graphWidgetToggleSetTemp & (1<<i)) ? true : false;
2360 }
2361
2362 satAniSpeedSlider->setEnabled(options[OPT_SAT_ANI]);
2363 orbitAniSpeedSlider->setEnabled(options[OPT_PERIOD_ANI]);
2364 updateScene();
2365 }
2366
2367
2368 ////////////////////////////////////////////////////////////////////////
2369 //
2370 // This routine is called to get a file name using the
2371 // standard file dialog.
2372 //
2373 void
2374 MainWindow::getFileName(int fileMode)
2375 //
2376 ////////////////////////////////////////////////////////////////////////
2377 {
2378 QString filename;
2379
2380 if(fileMode == SAVE_ITEM)
2381 filename = QFileDialog::getSaveFileName(QString::null,
2382 "Inventor files (*.iv);;Any files (*)",
2383 this, 0, QString::null);
2384 else if(fileMode == PRINT_ITEM)
2385 filename = QFileDialog::getSaveFileName(QString::null,
2386 "PostScript files (*.ps *.eps);;Any files (*)",
2387 this, "print file dialog", "Choose a file to print to" );
2388 else
2389 filename = QFileDialog::getOpenFileName(QString::null,
2390 "AUTO files (b.* s.* d.*);;Any files (*)", this);
2391 if(filename == QString::null)
2392 return;
2393 if(fileMode == SAVE_ITEM)
2394 writeToFile(filename.toLocal8Bit());
2395 else if(fileMode == PRINT_ITEM)
2396 {
2397 printToPostScript(root,filename.toLocal8Bit(),renderArea,100);
2398 }
2399 else if(fileMode == OPEN_ITEM)
2400 {
2401 deleteScene();
2402 readFile(filename.toLocal8Bit());
2403 }
2404 }
2405
2406
2407 ////////////////////////////////////////////////////////////////////////
2408 //
2409 // Brings up the "ABOUT" dialog
2410 //
2411 void
2412 MainWindow::showAboutDialog()
2413 //
2414 ////////////////////////////////////////////////////////////////////////
2415 {
2416 QString str;
2417 if (useR3B)
2418 str = " AUTO r3bplaut04\n\n"
2419 " Zhang, Chenghai, Dr. Eusebius J. Doedel\n\n "
2420 " Computer Science Department\n"
2421 " Concordia University\n\n"
2422 " Montreal, Quebec\n"
2423 " CANADA\n\n"
2424 " June, 2004 \n";
2425 else
2426 str = " AUTO plaut04\n\n"
2427 " Zhang, Chenghai, Dr. Eusebius J. Doedel\n\n "
2428 " Computer Science Department\n"
2429 " Concordia University\n\n"
2430 " Montreal, Quebec\n"
2431 " CANADA\n\n"
2432 " August, 2004 \n";
2433
2434 QMessageBox::about(this, "About_popup", str);
2435 }
2436
2437 void
2438 MainWindow::showHelp()
2439 {
2440 showHelpDialog();
2441 }
2442
2443 ////////////////////////////////////////////////////////////////////////
2444 //
2445 void
2446 MainWindow::xListCallBack(const QString &str)
2447 //
2448 ////////////////////////////////////////////////////////////////////////
2449 {
2450 char *manyChoice = strdup(str.toLocal8Bit());
2451
2452 char * tmp;
2453 tmp = strtok(manyChoice, ",");
2454 xCoordIndices.clear();
2455 do
2456 {
2457 xCoordIndices.push_back((strcasecmp(tmp,"t")==0) ? 0 : atoi(tmp));
2458 tmp = strtok(NULL,",");
2459 }while(tmp != NULL);
2460 if(whichType != BIFURCATION)
2461 {
2462 dai.solX = xCoordIndices;
2463 } else {
2464 dai.bifX = xCoordIndices;
2465 }
2466 updateScene();
2467 free(manyChoice);
2468 }
2469
2470
2471 ////////////////////////////////////////////////////////////////////////
2472 //
2473 void
2474 MainWindow::yListCallBack(const QString &str)
2475 //
2476 ////////////////////////////////////////////////////////////////////////
2477 {
2478 char *manyChoice = strdup(str.toLocal8Bit());
2479
2480 char * tmp;
2481 tmp = strtok(manyChoice, ",");
2482 yCoordIndices.clear();
2483 do
2484 {
2485 yCoordIndices.push_back((strcasecmp(tmp,"t")==0) ? 0 : atoi(tmp));
2486 tmp = strtok(NULL,",");
2487 }while(tmp != NULL);
2488 if(whichType != BIFURCATION)
2489 {
2490 dai.solY = yCoordIndices;
2491 } else {
2492 dai.bifY = yCoordIndices;
2493 }
2494 updateScene();
2495 free(manyChoice);
2496 }
2497
2498
2499 ////////////////////////////////////////////////////////////////////////
2500 //
2501 void
2502 MainWindow::zListCallBack(const QString &str)
2503 //
2504 ////////////////////////////////////////////////////////////////////////
2505 {
2506 char *manyChoice = strdup(str.toLocal8Bit());
2507
2508 char * tmp;
2509 tmp = strtok(manyChoice, ",");
2510 zCoordIndices.clear();
2511 do
2512 {
2513 zCoordIndices.push_back((strcasecmp(tmp,"t")==0) ? 0 : atoi(tmp));
2514 tmp = strtok(NULL,",");
2515 }while(tmp != NULL);
2516 if(whichType != BIFURCATION)
2517 {
2518 dai.solZ = zCoordIndices;
2519 } else {
2520 dai.bifZ = zCoordIndices;
2521 }
2522 updateScene();
2523 free(manyChoice);
2524 }
2525
2526
2527 ////////////////////////////////////////////////////////////////////////
2528 //
2529 void
2530 MainWindow::lblListCallBack(const QString &str)
2531 //
2532 ////////////////////////////////////////////////////////////////////////
2533 {
2534 char *manyChoice = strdup(str.toLocal8Bit());
2535 int choice = labelsList->currentItem();
2536 int nItems = (whichType != BIFURCATION) ? mySolNode->totalLabels() : myBifNode->totalLabels();
2537 char * tmp;
2538 static int half = 2;
2539 tmp = strtok(manyChoice, ",");
2540 choice -= SP_LBL_ITEMS;
2541 lblIndices.clear();
2542 if(choice <= MY_ALL || choice >= nItems)
2543 {
2544 do
2545 {
2546 lblIndices.push_back((strcasecmp(tmp,"all")==0) ? numLabels + MY_ALL :
2547 atoi(tmp)-myLabels[0]);
2548 tmp = strtok(NULL,",");
2549 }while(tmp != NULL);
2550 half = 2;
2551 }
2552 else if(choice == MY_HALF) // -3
2553 {
2554 for(int j = 0; j < numLabels - SP_LBL_ITEMS; j++)
2555 if(abs(clientData.labelIndex[j][2])!= 4 || (j+1)%half == 0)
2556 lblIndices.push_back(j);
2557 half *= 2;
2558 }
2559 else if(choice == MY_SPEC) // -2
2560 {
2561 for(int j = 0; j < numLabels - SP_LBL_ITEMS; j++)
2562 if(clientData.labelIndex[j][2] != TYPE_UZ && clientData.labelIndex[j][2] != TYPE_RG
2563 && clientData.labelIndex[j][2] != TYPE_EP_ODE && clientData.labelIndex[j][2] != TYPE_MX)
2564 lblIndices.push_back(j);
2565 half = 2;
2566 }
2567 else if(choice == MY_NONE) // -1
2568 {
2569 lblIndices.push_back(numLabels + MY_NONE);
2570 half = 2;
2571 }
2572 else
2573 {
2574 lblIndices.push_back(choice);
2575 half = 2;
2576 }
2577
2578 lblChoice.clear();
2579 if(choice < 0)
2580 lblChoice.push_back(choice);
2581 else for (std::vector<int>::size_type i = 0; i < lblIndices.size(); i++)
2582 lblChoice.push_back(lblIndices[i]);
2583
2584 updateScene();
2585 free(manyChoice);
2586 }
2587
2588
2589 class FmDrawingArea : public QWidget
2590 {
2591 public:
2592 FmDrawingArea( QWidget *parent, const char *name, int nFM )
2593 : QWidget( parent ) { setObjectName(name); numFM = nFM; }
2594
2595 protected:
2596 void paintEvent( QPaintEvent * );
2597 private:
2598 int numFM;
2599 };
2600
2601 ////////////////////////////////////////////////////////////////////////
2602 //
2603 void
2604 FmDrawingArea::paintEvent( QPaintEvent * )
2605 //
2606 ////////////////////////////////////////////////////////////////////////
2607 {
2608 QPainter p( this );
2609
2610 static const char *myText[9] =
2611 {
2612 "-inf", "-100", "-10", "-1", "0", "1", "10", "100", "+inf"
2613 };
2614
2615 // draw Y
2616 p.setPen(QPen(Qt::blue, 2, Qt::SolidLine));
2617 p.drawLine(200, 0, 200, 400);
2618
2619 // draw X
2620 p.setPen(QPen(Qt::red, 2, Qt::SolidLine));
2621 p.drawLine(0, 200, 400, 200);
2622
2623 // draw grid
2624 p.setPen(QPen(Qt::gray, 1, Qt::DotLine));
2625 for(int i=0; i<9; ++i)
2626 p.drawLine(0, 50*i, 400, 50*i);
2627 for(int i=0; i<9; ++i)
2628 p.drawLine(i*50, 0, i*50, 400);
2629
2630 // draw text
2631 p.setPen(Qt::black);
2632 for(int i = 0; i < 9; ++i)
2633 p.drawText(i*50+1 , 215, myText[i]);
2634 for(int i = 0; i < 9; ++i)
2635 p.drawText(210 , 413-i*50, myText[i]);
2636
2637 // draw a unit circle.
2638 if (numFM > 0) {
2639 p.setPen(QPen(Qt::green, 1, Qt::SolidLine));
2640 p.drawArc(150, 150, 100, 100, 0, 360*16);
2641 }
2642
2643 p.setPen(QPen(Qt::black, 2, Qt::SolidLine));
2644
2645 int x, y;
2646
2647 for(int j = 0; j < abs(numFM); ++j)
2648 {
2649 float tmp = fmData[2*j];
2650 if(fabs(tmp) <= 1.1)
2651 x = (tmp>0.0) ? (int)(200+tmp*50) : (int)(200-fabs(tmp)*50);
2652 else
2653 x =(tmp>0.0) ? (int)(250+log10(tmp)*50) : (int)(150-log10(fabs(tmp))*50);
2654
2655 tmp = fmData[2*j+1];
2656 if(fabs(tmp) <= 1.1)
2657 y = (tmp>0.0) ? (int)(200+tmp*50) : (int)(200-fabs(tmp)*50);
2658 else
2659 y =(tmp>0.0) ? (int)(150-log10(tmp)*50): (int)(log10(fabs(tmp))*50+250);
2660
2661 if(x>390) x = 390; if(x<10) y = 10;
2662 if(y>390) y = 390; if(y<10) y = 10;
2663
2664 p.drawLine(x-3, y-3, x+3, y+3);
2665 p.drawLine(x-3, y+3, x+3, y-3);
2666 }
2667 }
2668
2669
2670 ////////////////////////////////////////////////////////////////////////
2671 //
2672 void popupFloquetMultiplierDialog(float data[], int size, int numFM)
2673 //
2674 ////////////////////////////////////////////////////////////////////////
2675 {
2676 static QDialog *dialog_shell = (QDialog *) 0;
2677 QVBoxLayout *pane = (QVBoxLayout *) 0;
2678
2679 QString str = "";
2680
2681 for(int i=0; i<size; ++i)
2682 {
2683 QString temp;
2684 temp.sprintf("Col[%2d ] = %+E", i+1, data[i]);
2685 str += temp;
2686 if(size<20 || (size>=20 && (i+1)%2==0)) str += "\n";
2687 else str += " | ";
2688 }
2689
2690 QString tmpstr = numFM < 0 ? "Eigenvalues:\n" : "Floquet multipliers:\n";
2691 for(int j=0; j<abs(numFM); ++j)
2692 {
2693 QString temp;
2694 if (fmData[j*2+1] < 0)
2695 temp.sprintf(" [%2d] : %E - %Ei\n", j, fmData[j*2], -fmData[j*2+1]);
2696 else if (fmData[j*2+1] > 0)
2697 temp.sprintf(" [%2d] : %E + %Ei\n", j, fmData[j*2], fmData[j*2+1]);
2698 else
2699 temp.sprintf(" [%2d] : %E\n", j, fmData[j*2]);
2700 tmpstr += temp;
2701 }
2702
2703 if (!pane)
2704 {
2705 FmDrawingArea *fmDrawingArea;
2706
2707 dialog_shell = new QDialog(mainWindow);
2708 dialog_shell->setModal(false);
2709 dialog_shell->setObjectName("Dialog");
2710 dialog_shell->setCaption("Dialog");
2711
2712 #if QT_VERSION < 0x40000
2713 pane = new QVBoxLayout(dialog_shell, 5, -1);
2714 #else
2715 pane = new QVBoxLayout(dialog_shell);
2716 #endif
2717 pane->setObjectName("pane");
2718
2719 fmDrawingArea = new FmDrawingArea(dialog_shell, "fmDrawingArea",
2720 numFM);
2721 fmDrawingArea->setMinimumSize(450,450);
2722 pane->addWidget(fmDrawingArea);
2723
2724 QWidget *form = new QWidget(dialog_shell);
2725 form->setObjectName("form");
2726 QHBoxLayout *layout = new QHBoxLayout(form);
2727 layout->setSpacing(5);
2728 QLabel *label3 = new QLabel(str, form);
2729 label3->setObjectName("label");
2730 QLabel *label2 = new QLabel(tmpstr, form);
2731 label2->setObjectName("label");
2732 label2->setAlignment(Qt::AlignLeft);
2733 layout->addWidget(label3);
2734 layout->addWidget(label2);
2735 pane->addWidget(form);
2736
2737 QPushButton *pushButton= new QPushButton("OK", dialog_shell);
2738 pushButton->connect(pushButton, SIGNAL(clicked()),
2739 dialog_shell, SLOT(accept()));
2740 pane->addWidget(pushButton);
2741 dialog_shell->show();
2742 }
2743 }
2744
2745
2746 void soxtmain(int argc, char *argv[])
2747 {
2748 // Initialize Inventor and Qt.
2749 SoQt::init(argc, argv, argv[0]);
2750
2751 root = new SoSeparator;
2752 root->ref();
2753 mainWindow = new MainWindow;
2754
2755 SoQt::show(mainWindow);
2756 SoQt::mainLoop();
2757 root->unref();
2758 }