1 /* NIGHTFALL Light Curve Synthesis Program                                 */
2 /* Copyright (C) 1998 Rainer Wichmann                                      */
3 /*                                                                         */
4 /*  This program is free software; you can redistribute it                 */
5 /*  and/or modify                                                          */
6 /*  it under the terms of the GNU General Public License as                */
7 /*  published by                                                           */
8 /*  the Free Software Foundation; either version 2 of the License, or      */
9 /*  (at your option) any later version.                                    */
10 /*                                                                         */
11 /*  This program is distributed in the hope that it will be useful,        */
12 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of         */
13 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
14 /*  GNU General Public License for more details.                           */
15 /*                                                                         */
16 /*  You should have received a copy of the GNU General Public License      */
17 /*  along with this program; if not, write to the Free Software            */
18 /*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
19 
20 /* ANSI C forbids an empty source file, so put this outside                */
21 
22 #include <math.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <float.h>
27 
28 #include "Light.h"
29 
30 #ifdef _WITH_GTK
31 
32 #if !defined(GTK_CHECK_VERSION)
33 #define GTK_CHECK_VERSION(major,minor,micro)    \
34     (GTK_MAJOR_VERSION > (major) || \
35      (GTK_MAJOR_VERSION == (major) && GTK_MINOR_VERSION > (minor)) || \
36      (GTK_MAJOR_VERSION == (major) && GTK_MINOR_VERSION == (minor) && \
37       GTK_MICRO_VERSION >= (micro)))
38 #endif
39 static   GtkWidget   *exit_dialog;           /* exit confirmation            */
40 
41 /******************************************************************
42  @package   nightfall
43  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
44  @version   1.0
45  @short     Handle exit
46  @tip       function arguments are not used
47  @param     (GtkWidget) *widget     Discarded
48  @param     (gpointer)  *data       The button id
49  @return    (void)
50  @heading   Graphical User Interface
51 *******************************************************************/
doQuit()52 void doQuit()
53 {
54 #ifdef HAVE_GNOME
55   int os_x, os_y, os_w, os_h;
56 #endif
57 
58 #ifdef _WITH_GNUPLOT
59     if (Flags.plotOpened == ON) { Flags.plotOpened = OFF; cpgend(); }
60 #endif
61 
62 
63 #ifdef HAVE_GNOME
64   gdk_window_get_position(top_window->window, &os_x, &os_y);
65 #ifdef USING_GTK2
66 #if GTK_CHECK_VERSION(2, 24, 0)
67   os_w = gdk_window_get_width(top_window->window);
68   os_h = gdk_window_get_height(top_window->window);
69 #else
70   gdk_drawable_get_size(top_window->window, &os_w, &os_h);
71 #endif
72 #else
73   gdk_window_get_size(top_window->window, &os_w, &os_h);
74 #endif
75 
76   gnome_config_push_prefix ("nightfall/");
77   if (Flags.GN_rempos) {
78     gnome_config_set_int("Geometry/x",  os_x);
79     gnome_config_set_int("Geometry/y",  os_y);
80     gnome_config_set_int("Geometry/w",  os_w);
81     gnome_config_set_int("Geometry/h",  os_h);
82   }
83   gnome_config_sync();
84   gnome_config_pop_prefix();
85 #endif
86   gtk_main_quit ();
87   exit(0);
88 }
89 
90 /******************************************************************
91  @package   nightfall
92  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
93  @version   1.0
94  @short     Handle exit confirmation
95  @tip       function arguments are not used
96  @param     (GtkWidget) *widget     Discarded
97  @param     (gpointer)  *data       The button id
98  @return    (void)
99  @heading   Graphical User Interface
100 *******************************************************************/
do_exit_app(GtkWidget * widget,gpointer * data)101 void do_exit_app (GtkWidget * widget,
102 		  gpointer *data)
103 {
104   gint button_number;
105 
106   sscanf ((char *) data, "%d", &button_number);
107 
108   switch (button_number) {
109   case 0: /* NO button  */
110     gtk_widget_destroy(GTK_WIDGET(exit_dialog));
111     break;
112   case 1: /* YES button */
113     doQuit();
114     break;
115   default:
116     break;
117   };
118   return;
119 }
120 
121 /******************************************************************
122  @package   nightfall
123  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
124  @version   1.0
125  @short     Exit confirmation
126  @param     (void)
127  @return    (void)
128  @heading   Graphical User Interface
129 *******************************************************************/
do_exit_confirm()130 void do_exit_confirm ()
131 {
132 
133 #ifdef HAVE_GNOME
134   exit_dialog = gnome_message_box_new(_("Really exit ?"),
135 				 GNOME_MESSAGE_BOX_QUESTION,
136 				 GNOME_STOCK_BUTTON_YES,
137 				 GNOME_STOCK_BUTTON_NO, NULL);
138 
139   gnome_dialog_button_connect (GNOME_DIALOG(exit_dialog), 0,
140                                 GTK_SIGNAL_FUNC(do_exit_app),
141                                 (gpointer) "1");
142 
143   gnome_dialog_button_connect (GNOME_DIALOG(exit_dialog), 1,
144                                 GTK_SIGNAL_FUNC(do_exit_app),
145                                 (gpointer) "0");
146 
147   gtk_widget_show(GTK_WIDGET(exit_dialog));
148 #else
149 
150   GtkWidget   *label;
151   GtkWidget   *button;
152   GtkWidget   *box1;
153   GtkWidget   *hbox;
154   GtkWidget   *separator;
155 
156 #ifdef USING_GTK2
157   exit_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
158 #else
159   exit_dialog = gtk_window_new (GTK_WINDOW_DIALOG);
160 #endif
161   gtk_widget_set_usize (exit_dialog, 200, 80);
162   /* gtk_window_set_position(GTK_WINDOW(exit_dialog), GTK_WIN_POS_MOUSE); */
163   gtk_signal_connect (GTK_OBJECT (exit_dialog), "destroy",
164 		      GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
165 
166   box1 = gtk_vbox_new (FALSE, 0);
167   gtk_container_add (GTK_CONTAINER (exit_dialog), box1);
168   gtk_container_set_border_width (GTK_CONTAINER (box1), 5);
169 
170   label = gtk_label_new (_("Really exit ?") );
171   gtk_box_pack_start (GTK_BOX (box1), label, FALSE, TRUE, 5);
172   gtk_widget_show (label);
173 
174   separator = gtk_hseparator_new ();
175   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5);
176   gtk_widget_show (separator);
177 
178   hbox = gtk_hbox_new (TRUE, 0);
179   gtk_box_pack_start (GTK_BOX (box1), hbox, FALSE, TRUE, 0);
180   gtk_widget_show (hbox);
181 
182   button = gtk_button_new_with_label (_("Yes"));
183   gtk_signal_connect (GTK_OBJECT (button), "clicked",
184                       GTK_SIGNAL_FUNC (do_exit_app), "1");
185   gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
186   (GTK_WIDGET_FLAGS (button)  |= (GTK_CAN_DEFAULT));
187   gtk_widget_grab_default (button);
188   gtk_widget_show (button);
189 
190   button = gtk_button_new_with_label (_("No"));
191   gtk_signal_connect (GTK_OBJECT (button), "clicked",
192                       GTK_SIGNAL_FUNC (do_exit_app), "0");
193   gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
194   (GTK_WIDGET_FLAGS (button)  |= (GTK_CAN_DEFAULT));
195   gtk_widget_grab_default (button);
196   gtk_widget_show (button);
197 
198   gtk_widget_show (box1);
199   gtk_widget_show (exit_dialog);
200 #endif
201 
202   return;
203 }
204 
205 
206 /******************************************************************
207  @package   nightfall
208  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
209  @version   1.0
210  @short     Callback function for 'close application'
211  @param     (GtkWidget) *widget     Discarded
212  @param     (gpointer)  *data       Discarded
213  @return    (void)
214  @heading   Graphical User Interface
215 *******************************************************************/
216 void
delete_event(GtkWidget * widget,gpointer * data)217 delete_event (GtkWidget *widget, gpointer *data)
218 {
219 
220 #ifdef HAVE_GNOME
221   if (Flags.GN_exitconfirm)
222     do_exit_confirm();
223   else
224     doQuit();
225 #else
226   if ((char *) data == NULL)
227     do_exit_confirm();
228   else
229     doQuit();
230 #endif
231   /* only returns if not confirmed */
232   return;
233 }
234 
235 /******************************************************************
236  @package   nightfall
237  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
238  @version   1.0
239  @short     Callback function for 'compute lightcurve'
240  @param     (GtkWidget) *widget     Discarded
241  @param     (gpointer)  *data       Discarded
242  @return    (void)
243  @heading   Graphical User Interface
244 *******************************************************************/
245 void
lightcurve_event(GtkWidget * widget,gpointer * data)246 lightcurve_event (GtkWidget *widget, gpointer *data)
247 {
248   int    ErrCode = 0;             /* return status                */
249   double Merit = 0.;              /* merit observed - computed    */
250 
251   /* block GUI                                                    */
252 
253   gtk_widget_set_sensitive(top_window, FALSE);
254 
255   /* validate data                                                */
256   check_data();
257 
258   /* compute                                                      */
259   ErrCode = MainLoop (&Merit);
260   if (ErrCode == 0) {
261     WriteOutput();
262     if (Flags.plot > OFF) {
263 
264 #ifdef _WITH_PGPLOT
265       PlotOutput();
266 #else
267       make_dialog (_(errmsg[14]));
268 #endif
269 
270     }
271   } else {
272     make_dialog (_(errmsg[12]));
273   }
274 
275   gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_bar), 0.0);
276 
277   /* unblock GUI                                                  */
278   gtk_widget_set_sensitive(top_window, TRUE);
279 
280   /* ungray menu items                                            */
281   if (Flags.edu != ON) {
282     gtk_widget_set_sensitive(menu_plot,    TRUE);
283     if (Flags.ProComputed == ON) {
284       gtk_widget_set_sensitive(menu_profile,    TRUE);
285     }
286   }
287 
288   return;
289 }
290 
291 
292 /******************************************************************
293  @package   nightfall
294  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
295  @version   1.0
296  @short     Callback function for 'fit data'
297  @param     (GtkWidget) *widget     Discarded
298  @param     (gpointer)  *data       Discarded
299  @return    (void)
300  @heading   Graphical User Interface
301 *******************************************************************/
302 void
lightfit_event(GtkWidget * widget,gpointer * data)303 lightfit_event (GtkWidget *widget, gpointer *data)
304 {
305   int    WasOn = OFF;             /* flag for animation           */
306   int    ErrCode = 0;             /* return status                */
307 
308   Flags.WantFit = ON;
309 
310   /* block GUI                                                    */
311   gtk_widget_set_sensitive(top_window, FALSE);
312 
313   /* validate data                                                */
314   check_data();
315 
316   /* unset animation                                              */
317   if (Flags.animate == ON) {
318      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_anim_button),
319                                      FALSE);
320      Flags.animate = OFF;
321      WasOn = ON;
322      Flags.plot = ON;
323   }
324 
325   /* compute                                                      */
326   ErrCode = Simplex();
327   if (ErrCode == 0) {
328     WriteOutput();
329   } else {
330     make_dialog (_(errmsg[15]));
331   }
332 
333   gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_bar), 0.0);
334 
335   /* unblock GUI                                                  */
336   gtk_widget_set_sensitive(top_window, TRUE);
337 
338   Flags.WantFit = OFF;
339   Flags.plot    = OFF;
340 
341   /* update with fitted data                                      */
342   UpdateGui();
343 
344   /* ungray menu items                                            */
345   if (Flags.edu != ON) {
346     gtk_widget_set_sensitive(menu_plot,    TRUE);
347     if (Flags.ProComputed == ON) {
348       gtk_widget_set_sensitive(menu_profile,    TRUE);
349     }
350   }
351 
352   if (WasOn == ON) {
353      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_anim_button),
354                                      TRUE);
355      Flags.animate = ON;
356   }
357 
358 
359   return;
360 }
361 
362 /******************************************************************
363  @package   nightfall
364  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
365  @version   1.0
366  @short     Callback function for 'map chi square'
367  @param     (GtkWidget) *widget     Discarded
368  @param     (gpointer)  *data       Discarded
369  @return    (void)
370  @heading   Graphical User Interface
371 *******************************************************************/
lightmap_event(GtkWidget * widget,gpointer * data)372 void lightmap_event (GtkWidget *widget, gpointer *data)
373 {
374   int    WasOn = OFF;             /* flag for animation           */
375   int    ErrCode = 0;             /* return status                */
376 
377   Flags.WantMap = ON;
378 
379   /* block GUI                                                    */
380   gtk_widget_set_sensitive(top_window, FALSE);
381 
382   /* validate data                                                */
383   check_data();
384 
385   /* unset animation                                              */
386   if (Flags.animate == ON) {
387      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_anim_button),
388                                    FALSE);
389      Flags.plot = ON;
390      WasOn = ON;
391      Flags.animate = OFF;
392   }
393 
394   /* compute                                                      */
395   ErrCode = ChiMap();
396   if (ErrCode != 0) {
397     make_dialog (_(errmsg[15]));
398   }
399 
400   gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_bar), 0.0);
401 
402   /* unblock GUI                                                  */
403   gtk_widget_set_sensitive(top_window, TRUE);
404 
405   Flags.WantMap = OFF;
406   Flags.plot    = OFF;
407 
408   /* ungray menu items                                            */
409   if (Flags.edu != ON) {
410     gtk_widget_set_sensitive(menu_plot,    TRUE);
411     if (Flags.ProComputed == ON) {
412       gtk_widget_set_sensitive(menu_profile,    TRUE);
413     }
414   }
415 
416   if (WasOn == ON) {
417      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_anim_button),
418                                      TRUE);
419      Flags.animate = ON;
420   }
421 
422   return;
423 }
424 
425 
426 /******************************************************************
427  @package   nightfall
428  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
429  @version   1.0
430  @short     Callback function for 'Profiler'
431  @param     (GtkWidget) *widget     Discarded
432  @param     (gpointer)  *data       Discarded
433  @return    (void)
434  @heading   Graphical User Interface
435 *******************************************************************/
436 void
profiler_event(GtkWidget * widget,gpointer * data)437 profiler_event (GtkWidget *widget, gpointer *data)
438 {
439   /* check whether profile computed already                       */
440   if (Flags.ProComputed == ON) {
441 #ifdef _WITH_PGPLOT
442     Profiler();
443 #else
444     make_dialog (_(errmsg[14]));
445 #endif
446   } else {
447     make_dialog (_(errmsg[16]));
448   }
449 
450   return;
451 }
452 
453 /******************************************************************
454  @package   nightfall
455  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
456  @version   1.0
457  @short     Callback function for 'Plot Lightcurve'
458  @param     (GtkWidget) *widget     Discarded
459  @param     (gpointer)  *data       Discarded
460  @return    (void)
461  @heading   Graphical User Interface
462 *******************************************************************/
463 void
lightcurveplot_event(GtkWidget * widget,gpointer * data)464 lightcurveplot_event (GtkWidget *widget, gpointer *data)
465 {
466   int store;             /* temporary store plot flag             */
467 
468   /* check whether already computed                               */
469   if (Flags.IsComputed == ON) {
470 
471     store = Flags.plot;
472     Flags.plot = TG_graphstore;
473     if (Flags.plot == OFF) Flags.plot = ON;
474 
475 #ifdef _WITH_PGPLOT
476     PlotOutput();
477 #else
478     make_dialog (_(errmsg[14]));
479 #endif
480 
481     Flags.plot = store;
482 
483   } else {
484     make_dialog (_(errmsg[17]));
485   }
486 
487   return;
488 }
489 
490 /******************************************************************
491  @package   nightfall
492  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
493  @version   1.0
494  @short     Callback function for 'Reset Memory'
495  @param     (GtkWidget) *widget     Discarded
496  @param     (gpointer)  *data       Discarded
497  @return    (void)
498  @heading   Graphical User Interface
499 *******************************************************************/
500 void
reset_event(GtkWidget * widget,gpointer * data)501 reset_event (GtkWidget *widget, gpointer *data)
502 {
503   register int Band;         /* loop variable                     */
504 
505 #ifdef _WITH_GTK
506   if ( Flags.interactive == ON && Flags.parseCL == OFF )
507     my_appbar_push(_("Clearing data memory"));
508 #endif
509 
510   /* set data count for all passbands to zero                     */
511   for ( Band = 0;  Band < (NUM_MAG+2); ++ Band) Flags.Passbands[Band] = 0;
512 
513   /* clear data file list                                         */
514   ClearList();
515 
516   updatepage3 ();
517 
518   return;
519 }
520 
521 /******************************************************************
522  @package   nightfall
523  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
524  @version   1.0
525  @short     Callback function for 'visualize geometry'
526  @param     (GtkWidget) *widget     Discarded
527  @param     (gpointer)  *data       Discarded
528  @return    (void)
529  @heading   Graphical User Interface
530 *******************************************************************/
531 void
lightgeometry_event(GtkWidget * widget,gpointer * data)532 lightgeometry_event (GtkWidget *widget, gpointer *data)
533 {
534   int    ErrCode;       /* exit status                            */
535   int store;            /* temporary store visualize flag         */
536 
537   store = Flags.visualize;
538   Flags.visualize = TG_visualstore;
539 
540   /* validate input data                                          */
541   check_data();
542 
543   /* define geometry                                              */
544 
545   if (Flags.fill == OFF) {
546      /* THE PRIMARY                                               */
547      ErrCode = DefineParam(Primary);
548      /* THE SECONDARY                                             */
549      DefineParam(Secondary);
550   } else {
551      /* Overcontact system                                        */
552      ErrCode = DefineParamOver();
553   }
554 
555   if (ErrCode < 2 ) {
556 #ifdef _WITH_PGPLOT
557     PlotGeometry();
558 #else
559     make_dialog (_(errmsg[14]));
560 #endif
561   } else {
562     make_dialog (_(errmsg[12]));
563   }
564 
565   Flags.visualize = store;
566 
567   return;
568 }
569 
570 /******************************************************************
571  @package   nightfall
572  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
573  @version   1.0
574  @short     Callback function for 'Roche Slicer'
575  @param     (GtkWidget) *widget     Discarded
576  @param     (gpointer)  *data       Discarded
577  @return    (void)
578  @heading   Graphical User Interface
579 *******************************************************************/
580 void
lightslice_event(GtkWidget * widget,gpointer * data)581 lightslice_event (GtkWidget *widget, gpointer *data)
582 {
583   int    ErrCode;                  /* exit status                 */
584 
585 
586   /* validate input data                                          */
587   check_data();
588 
589   /* define geometry                                              */
590 
591   if (Flags.fill == OFF) {
592      /* THE PRIMARY                                               */
593      ErrCode = DefineParam(Primary);
594      /* THE SECONDARY                                             */
595      DefineParam(Secondary);
596   } else {
597      /* Overcontact system                                        */
598      ErrCode = DefineParamOver();
599   }
600 
601   if (ErrCode < 2) {
602 #ifdef _WITH_PGPLOT
603     MakeSliceBox();
604 #else
605     make_dialog (_(errmsg[14]));
606 #endif
607   } else {
608     make_dialog (_(errmsg[12]));
609   }
610 
611   return;
612 }
613 
614 /******************************************************************
615  @package   nightfall
616  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
617  @version   1.0
618  @short     Callback function for 'StarView'
619  @param     (GtkWidget) *widget     Discarded
620  @param     (gpointer)  *data       Discarded
621  @return    (void)
622  @heading   Graphical User Interface
623 *******************************************************************/
624 void
lightstarview_event(GtkWidget * widget,gpointer * data)625 lightstarview_event (GtkWidget *widget, gpointer *data)
626 {
627   int    ErrCode;                  /* exit status                 */
628 
629   /* validate input data                                          */
630   check_data();
631 
632   /* define geometry                                              */
633 
634   if (Flags.fill == OFF) {
635      /* THE PRIMARY                                               */
636      ErrCode = DefineParam(Primary);
637      /* THE SECONDARY                                             */
638      DefineParam(Secondary);
639      /* The disk                                                  */
640 #ifdef HAVE_DISK
641      if (Flags.disk == ON)
642        ErrCode = DefineParamDisk();
643 #endif
644   } else {
645      /* Overcontact system                                        */
646      ErrCode = DefineParamOver();
647   }
648 
649   if (ErrCode < 2 ) {
650 #ifdef _WITH_PGPLOT
651     MakeVbox();
652 #else
653     make_dialog (_(errmsg[14]));
654 #endif
655   } else {
656     make_dialog (_(errmsg[12]));
657   }
658 
659   return;
660 }
661 
662 /******************************************************************
663  @package   nightfall
664  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
665  @version   1.0
666  @short     Toggle fitting of spot
667  @param     (GtkWidget) *widget     Discarded
668  @param     (gpointer)  *data       The spot
669  @return    (void)
670  @heading   Graphical User Interface
671 *******************************************************************/
toggle_fit_spot(GtkWidget * widget,gpointer * data)672 void toggle_fit_spot (GtkWidget *widget, gpointer *data)
673 {
674   int  i;                      /* number of spot                  */
675 
676   sscanf ((char *) data, "%d", &i);
677   if(GTK_TOGGLE_BUTTON (widget)->active) {
678 
679     /* button is down                                             */
680     FitSpotS[i-10] = ON;
681 
682     if ((i < 14) && (SpotActive[0] == ON)) Flags.simplex[i] = ON;
683     if ((i < 18) && (i > 13) && (SpotActive[1] == ON)) {
684        if   (SpotActive[0] == ON) Flags.simplex[i] = ON;
685        else Flags.simplex[i-4] = ON;
686     }
687     if ((i < 22) && (i > 17) && (SpotActive[2] == ON)) Flags.simplex[i] = ON;
688     if ((i < 26) && (i > 21) && (SpotActive[3] == ON)) {
689        if   (SpotActive[2] == ON) Flags.simplex[i] = ON;
690        else Flags.simplex[i-4] = ON;
691     }
692 
693   } else {
694 
695     /* button is up                                               */
696     FitSpotS[i-10] = OFF;
697 
698     if (i < 14 && SpotActive[0] == ON) Flags.simplex[i] = OFF;
699     if ((i < 18) && (i > 13) && (SpotActive[1] == ON)) {
700        if   (SpotActive[0] == ON) Flags.simplex[i] = OFF;
701        else Flags.simplex[i-4] = OFF;
702     }
703     if ((i < 22) && (i > 17) && (SpotActive[2] == ON)) Flags.simplex[i] = OFF;
704     if ((i < 26) && (i > 21) && (SpotActive[3] == ON)) {
705        if   (SpotActive[2] == ON) Flags.simplex[i] = OFF;
706        else Flags.simplex[i-4] = OFF;
707     }
708   }
709 }
710 
711 /******************************************************************
712  @package   nightfall
713  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
714  @version   1.0
715  @short     Reset parameters
716  @param     (GtkWidget) *widget     Discarded
717  @param     (gpointer)  *data       Discarded
718  @return    (void)
719  @heading   Graphical User Interface
720 *******************************************************************/
reset_params(GtkWidget * widget,gpointer * data)721 void reset_params (GtkWidget *widget, gpointer *data)
722 {
723   char           InitString[64];
724 
725   (void) widget;
726   (void) data;
727 
728   Orbit.Inclination             = DTOR * 80.0;
729 
730   Binary[Primary].Mq            = 1.0;
731   Binary[Secondary].Mq          = 1.0;
732 
733   Binary[Primary].Temperature   = 5700.0;
734   Binary[Secondary].Temperature = 5700.0;
735   Binary[Primary].RocheFill     = 0.6;
736   Binary[Secondary].RocheFill   = 0.6;
737   Binary[Primary].log_g         = 4.0;
738   Binary[Secondary].log_g       = 4.0;
739 
740   PhaseSteps                    = DEF_STEPS;
741 
742   if (Flags.edu == ON)
743     {
744       DefineParam(Primary);
745       DefineParam(Secondary);
746     }
747 
748   Flags.PlotBand                = Vmag;
749   Flags.plot                    = ON;
750 
751   updateplotflagpage3 ();
752 
753   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_psp1_button), FALSE);
754   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_psp2_button), FALSE);
755 
756   Spot[Primary][0].longitude    = 0.0;
757   Spot[Primary][0].latitude     = 0.0;
758   Spot[Primary][0].radius       = 1.0;
759   Spot[Primary][0].dimfactor    = 0.5;
760 
761   sprintf(InitString, "%6.3f", Spot[Primary][0].longitude);
762   gtk_entry_set_text (GTK_ENTRY (e_401), InitString);
763 
764   sprintf(InitString, "%6.3f", Spot[Primary][0].latitude);
765   gtk_entry_set_text (GTK_ENTRY (e_402), InitString);
766 
767   sprintf(InitString, "%6.3f", Spot[Primary][0].radius);
768   gtk_entry_set_text (GTK_ENTRY (e_403), InitString);
769 
770   sprintf(InitString, "%6.3f", Spot[Primary][0].dimfactor);
771   gtk_entry_set_text (GTK_ENTRY (e_404), InitString);
772 
773 
774   Spot[Primary][1].longitude    = 0.0;
775   Spot[Primary][1].latitude     = 0.0;
776   Spot[Primary][1].radius       = 1.0;
777   Spot[Primary][1].dimfactor    = 0.5;
778 
779   sprintf(InitString, "%6.3f", Spot[Primary][1].longitude);
780   gtk_entry_set_text (GTK_ENTRY (e_405), InitString);
781 
782   sprintf(InitString, "%6.3f", Spot[Primary][1].latitude);
783   gtk_entry_set_text (GTK_ENTRY (e_406), InitString);
784 
785   sprintf(InitString, "%6.3f", Spot[Primary][1].radius);
786   gtk_entry_set_text (GTK_ENTRY (e_407), InitString);
787 
788   sprintf(InitString, "%6.3f", Spot[Primary][1].dimfactor);
789   gtk_entry_set_text (GTK_ENTRY (e_408), InitString);
790 
791 
792   UpdateGui();
793   return;
794 }
795 
796 
797 /******************************************************************
798  @package   nightfall
799  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
800  @version   1.0
801  @short     Toggle spot 1 on primary active
802  @param     (GtkWidget) *widget     Discarded
803  @param     (gpointer)  *data       Discarded
804  @return    (void)
805  @heading   Graphical User Interface
806 *******************************************************************/
toggle_p_spot1(GtkWidget * widget,gpointer * data)807 void toggle_p_spot1 (GtkWidget *widget, gpointer *data)
808 {
809   int i;                  /* loop variable                        */
810 
811   if(GTK_TOGGLE_BUTTON (widget)->active) {
812 
813     /* we had a first spot before                                 */
814     if (TG_P1spot == ON) {
815       /* shift up spots to make place                             */
816       for ( i=Flags.Spots1; i>0; --i) Spot[Primary][i] = Spot[Primary][i-1];
817       /* increase spot count                                      */
818       ++Flags.Spots1;
819       /* restore spot                                             */
820       Spot[Primary][0] =  SpotStore[Primary][0];
821       /* restore fit params                                       */
822       for (i = 0; i < 4; ++i) Flags.simplex[10+i] = FitSpotS[i];
823       if (TG_P2spot == ON && SpotActive[1] == ON) {
824            for (i = 4; i < 8; ++i) Flags.simplex[10+i] = FitSpotS[i];
825       }
826     } else {
827     /* we had no first spot before                                */
828       TG_P1spot = ON;
829       /* shift up spots to make place                             */
830       for ( i=Flags.Spots1; i>0; --i) Spot[Primary][i] = Spot[Primary][i-1];
831       /* increase spot count                                      */
832       ++Flags.Spots1;
833       /* restore spot                                             */
834       Spot[Primary][0] =  SpotStore[Primary][0];
835       /* restore fit params                                       */
836       for (i = 0; i < 4; ++i) Flags.simplex[10+i] = FitSpotS[i];
837       if (TG_P2spot == ON && SpotActive[1] == ON) {
838            for (i = 4; i < 8; ++i) Flags.simplex[10+i] = FitSpotS[i];
839       }
840     }
841     SpotActive[0] = ON;
842   } else {
843 
844       /* shift down spots                                         */
845       for ( i=0; i<Flags.Spots1; ++i) Spot[Primary][i] = Spot[Primary][i+1];
846       /* decrease spot count                                      */
847       if (Flags.Spots1 > 0) --Flags.Spots1;
848       /* check fit params                                         */
849       for (i = 0; i < 4; ++i) {
850              Flags.simplex[10+i] = FitSpotS[i+4];
851              Flags.simplex[14+i] = 0;
852       }
853       SpotActive[0] = OFF;
854   }
855   return;
856 }
857 
858 /******************************************************************
859  @package   nightfall
860  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
861  @version   1.0
862  @short     Toggle spot 2 on primary active
863  @param     (GtkWidget) *widget     Discarded
864  @param     (gpointer)  *data       Discarded
865  @return    (void)
866  @heading   Graphical User Interface
867 *******************************************************************/
toggle_p_spot2(GtkWidget * widget,gpointer * data)868 void toggle_p_spot2 (GtkWidget *widget, gpointer *data)
869 {
870   int i;                  /* loop variable                        */
871 
872   if(GTK_TOGGLE_BUTTON (widget)->active) {
873 
874     /* we had a second spot before                                */
875     if (TG_P2spot == ON) {
876       /* put into second slot if first spot active                */
877       if (SpotActive[0] == ON) {
878         /* shift up spots to make place                           */
879         for (i=Flags.Spots1; i>1; --i) Spot[Primary][i] = Spot[Primary][i-1];
880         /* increase spot count                                    */
881         ++Flags.Spots1;
882         /* restore spot                                           */
883         Spot[Primary][1] =  SpotStore[Primary][1];
884         /* restore fit params                                     */
885         for (i = 0; i < 4; ++i) Flags.simplex[14+i] = FitSpotS[4+i];
886       } else {
887         /* shift up spots to make place                           */
888         for ( i=Flags.Spots1; i>0; --i) Spot[Primary][i] = Spot[Primary][i-1];
889         /* increase spot count                                    */
890         ++Flags.Spots1;
891         /* restore spot                                           */
892         Spot[Primary][0] =  SpotStore[Primary][1];
893         /* restore fit params                                     */
894         for (i = 0; i < 4; ++i) Flags.simplex[10+i] = FitSpotS[4+i];
895       }
896 
897     } else {
898 
899       /* we had no second spot before                             */
900       TG_P2spot = ON;
901       /* increase spot count                                      */
902       ++Flags.Spots1;
903       if (SpotActive[0] == ON) {
904        /* restore spot                                            */
905        Spot[Primary][1] =  SpotStore[Primary][1];
906        /* restore fit params                                      */
907        for (i = 0; i < 4; ++i) Flags.simplex[14+i] = FitSpotS[4+i];
908       } else {
909        /* restore spot                                            */
910        Spot[Primary][0] =  SpotStore[Primary][1];
911        /* restore fit params                                      */
912        for (i = 0; i < 4; ++i) Flags.simplex[10+i] = FitSpotS[4+i];
913       }
914     }
915     SpotActive[1] = ON;
916 
917   } else {
918 
919       /* decrease spot count                                      */
920       if (Flags.Spots1 > 0) --Flags.Spots1;
921       if (SpotActive[0] == ON) {
922        /* shift down spots to make place                          */
923        for ( i=1; i<Flags.Spots1; ++i) Spot[Primary][i] = Spot[Primary][i+1];
924        /* check fit params                                        */
925        for (i = 0; i < 4; ++i) {
926               Flags.simplex[14+i] = 0;
927        }
928       } else {
929        /* shift down spots to make place                          */
930        for ( i=0; i<Flags.Spots1; ++i) Spot[Primary][i] = Spot[Primary][i+1];
931        /* check fit params                                        */
932        for (i = 0; i < 8; ++i) {
933               Flags.simplex[10+i] = 0;
934        }
935       }
936     SpotActive[1] = OFF;
937 
938   }
939   return;
940 
941 }
942 
943 
944 /******************************************************************
945  @package   nightfall
946  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
947  @version   1.0
948  @short     Toggle spot 1 on secondary active
949  @param     (GtkWidget) *widget     Discarded
950  @param     (gpointer)  *data       Discarded
951  @return    (void)
952  @heading   Graphical User Interface
953 *******************************************************************/
toggle_s_spot1(GtkWidget * widget,gpointer * data)954 void toggle_s_spot1 (GtkWidget *widget, gpointer *data)
955 {
956   int i;                  /* loop variable                        */
957 
958   if(GTK_TOGGLE_BUTTON (widget)->active) {
959 
960     /* we had a first spot before                                 */
961     if (TG_S1spot == ON) {
962       /* shift up spots to make place                             */
963       for ( i=Flags.Spots2; i>0; --i) Spot[Secondary][i]=Spot[Secondary][i-1];
964       /* increase spot count                                      */
965       ++Flags.Spots2;
966       /* restore spot                                             */
967       Spot[Secondary][0] =  SpotStore[Secondary][0];
968       /* restore fit params                                       */
969       for (i = 0; i < 4; ++i) Flags.simplex[18+i] = FitSpotS[8+i];
970       if (TG_S2spot == ON && SpotActive[3] == ON) {
971            for (i = 4; i < 8; ++i) Flags.simplex[18+i] = FitSpotS[8+i];
972       }
973     } else {
974     /* we had no first spot before                                */
975       TG_S1spot = ON;
976       /* shift up spots to make place                             */
977       for ( i=Flags.Spots2; i>0; --i) Spot[Secondary][i]=Spot[Secondary][i-1];
978       /* increase spot count                                      */
979       ++Flags.Spots2;
980       /* restore spot                                             */
981       Spot[Secondary][0] =  SpotStore[Secondary][0];
982       /* restore fit params                                       */
983       for (i = 0; i < 4; ++i) Flags.simplex[18+i] = FitSpotS[8+i];
984       if (TG_S2spot == ON && SpotActive[3] == ON) {
985            for (i = 4; i < 8; ++i) Flags.simplex[18+i] = FitSpotS[8+i];
986       }
987     }
988     SpotActive[2] = ON;
989 
990   } else {
991 
992       /* shift down spots                                         */
993       for ( i=0; i<Flags.Spots2; ++i) Spot[Secondary][i]=Spot[Secondary][i+1];
994       /* decrease spot count                                      */
995       if (Flags.Spots2 > 0) --Flags.Spots2;
996       /* check fit params                                         */
997       for (i = 0; i < 4; ++i) {
998              Flags.simplex[18+i] = FitSpotS[i+12];
999              Flags.simplex[22+i] = 0;
1000       }
1001       SpotActive[2] = OFF;
1002 
1003   }
1004   return;
1005 }
1006 
1007 /******************************************************************
1008  @package   nightfall
1009  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1010  @version   1.0
1011  @short     Toggle spot 2 on secondary active
1012  @param     (GtkWidget) *widget     Discarded
1013  @param     (gpointer)  *data       Discarded
1014  @return    (void)
1015  @heading   Graphical User Interface
1016 *******************************************************************/
toggle_s_spot2(GtkWidget * widget,gpointer * data)1017 void toggle_s_spot2 (GtkWidget *widget, gpointer *data)
1018 {
1019   int i;                  /* loop variable                        */
1020 
1021   if(GTK_TOGGLE_BUTTON (widget)->active) {
1022 
1023     /* we had a second spot before                                */
1024     if (TG_S2spot == ON) {
1025       /* put into second slot if first spot active                */
1026       if (SpotActive[2] == ON) {
1027         /* shift up spots to make place                           */
1028         for (i=Flags.Spots2; i>1; --i) Spot[Secondary][i]=Spot[Secondary][i-1];
1029         /* increase spot count                                    */
1030         ++Flags.Spots2;
1031         /* restore spot                                           */
1032         Spot[Secondary][1] =  SpotStore[Secondary][1];
1033         /* restore fit params                                     */
1034         for (i = 0; i < 4; ++i) Flags.simplex[22+i] = FitSpotS[12+i];
1035       } else {
1036         /* shift up spots to make place                           */
1037         for (i=Flags.Spots2; i>0; --i) Spot[Secondary][i]=Spot[Secondary][i-1];
1038         /* increase spot count                                    */
1039         ++Flags.Spots2;
1040         /* restore spot                                           */
1041         Spot[Secondary][0] =  SpotStore[Secondary][1];
1042         /* restore fit params                                     */
1043         for (i = 0; i < 4; ++i) Flags.simplex[18+i] = FitSpotS[12+i];
1044       }
1045 
1046     } else {
1047 
1048       /* we had no second spot before                             */
1049       TG_S2spot = ON;
1050       /* increase spot count                                      */
1051       ++Flags.Spots2;
1052       if (SpotActive[2] == ON) {
1053        /* restore spot                                            */
1054        Spot[Secondary][1] =  SpotStore[Secondary][1];
1055        /* restore fit params                                      */
1056        for (i = 0; i < 4; ++i) Flags.simplex[22+i] = FitSpotS[12+i];
1057       } else {
1058        /* restore spot                                            */
1059        Spot[Secondary][0] =  SpotStore[Secondary][1];
1060        /* restore fit params                                      */
1061        for (i = 0; i < 4; ++i) Flags.simplex[18+i] = FitSpotS[12+i];
1062       }
1063 
1064     }
1065     SpotActive[3] = ON;
1066 
1067   } else {
1068 
1069       /* decrease spot count                                      */
1070       if (Flags.Spots2 > 0) --Flags.Spots2;
1071       if (SpotActive[2] == ON) {
1072        /* shift down spots to make place                          */
1073        for (i=1; i<Flags.Spots2; ++i) Spot[Secondary][i]=Spot[Secondary][i+1];
1074        /* check fit params                                        */
1075        for (i = 0; i < 4; ++i) {
1076               Flags.simplex[22+i] = 0;
1077        }
1078       } else {
1079        /* shift down spots to make place                          */
1080        for (i=0; i<Flags.Spots2; ++i) Spot[Secondary][i]=Spot[Secondary][i+1];
1081        /* check fit params                                        */
1082        for (i = 0; i < 8; ++i) {
1083               Flags.simplex[18+i] = 0;
1084        }
1085       }
1086 
1087     SpotActive[3] = OFF;
1088   }
1089   return;
1090 }
1091 
1092 
1093 /******************************************************************
1094  @package   nightfall
1095  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1096  @version   1.0
1097  @short     Toggle simulated annealing or MCMC
1098  @param     (GtkWidget) *widget     Discarded
1099  @param     (gpointer)  *data       Sim. Annealing or MCMC
1100  @return    (void)
1101  @heading   Graphical User Interface
1102 *******************************************************************/
toggle_anneal(GtkWidget * widget,gpointer * data)1103 void toggle_anneal (GtkWidget *widget, gpointer *data)
1104 {
1105   if (data != NULL)
1106     {
1107       char * tmp = (char*) data;
1108 
1109       if (tmp[0] == 'A')
1110 	{
1111 	  if(GTK_TOGGLE_BUTTON (widget)->active) {
1112 	    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_mcmc_button),
1113 					  FALSE);
1114 	    Flags.anneal = ON;
1115 	  } else {
1116 	    Flags.anneal = OFF;
1117 	  }
1118 	  return;
1119 	}
1120       if (tmp[0] == 'M')
1121 	{
1122 	  if(GTK_TOGGLE_BUTTON (widget)->active) {
1123 	    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (t_sian_button),
1124 					  FALSE);
1125 	    Flags.anneal = MCMC;
1126 	  } else {
1127 	    Flags.anneal = OFF;
1128 	  }
1129 	  return;
1130 	}
1131     }
1132 }
1133 
1134 #ifdef HAVE_DISK
1135 /******************************************************************
1136  @package   nightfall
1137  @author    Markus Kuster (kuster@astro.uni-tuebingen.de)
1138  @version   1.0
1139  @short     Toggle accretion disk
1140  @param     (GtkWidget) *widget     Discarded
1141  @param     (gpointer)  *data       Discarded
1142  @return    (void)
1143  @heading   Graphical User Interface
1144 *******************************************************************/
toggle_disk(GtkWidget * widget,gpointer * data)1145 void toggle_disk (GtkWidget *widget, gpointer *data)
1146 {
1147   if(GTK_TOGGLE_BUTTON (widget)->active) {
1148 
1149     Flags.disk = ON;
1150     gtk_widget_show (e_114);
1151     gtk_widget_show (orad_label);
1152     gtk_widget_show (e_115);
1153     gtk_widget_show (irad_label);
1154     gtk_widget_show (e_116);
1155     gtk_widget_show (tilt_label);
1156     if (Flags.warp == ON) {
1157       gtk_widget_show (e_117);
1158       gtk_widget_show (warp_label);
1159     }
1160     gtk_widget_show (t_warp_button);
1161     gtk_widget_show (e_118);
1162     gtk_widget_show (thick_label);
1163     gtk_widget_show (e_119);
1164     gtk_widget_show (hr_label);
1165     gtk_widget_show (e_120);
1166     gtk_widget_show (disktmp_label);
1167 
1168     gtk_widget_show (td_button_0);
1169     gtk_widget_show (td_button_1);
1170     gtk_widget_show (td_button_2);
1171 
1172     gtk_widget_show (e_130);
1173     gtk_widget_show (hs_temp_label);
1174     gtk_widget_show (e_131);
1175     gtk_widget_show (hs_longitude_label);
1176     gtk_widget_show (e_132);
1177     gtk_widget_show (hs_extent_label);
1178     gtk_widget_show (e_133);
1179     gtk_widget_show (hs_depth_label);
1180     gtk_widget_show (e_134);
1181     gtk_widget_show (hs_puff_label);
1182 
1183 #if 0
1184     gtk_widget_show (e_140);
1185     gtk_widget_show (wp_max_label);
1186     gtk_widget_show (e_141);
1187     gtk_widget_show (wp_longitude_label);
1188     gtk_widget_show (e_142);
1189     gtk_widget_show (wp_width_label);
1190     gtk_widget_show (e_143);
1191     gtk_widget_show (wp_centre_label);
1192 #endif
1193     gtk_widget_hide (e_140);
1194     gtk_widget_hide (wp_max_label);
1195     gtk_widget_hide (e_141);
1196     gtk_widget_hide (wp_longitude_label);
1197     gtk_widget_hide (e_142);
1198     gtk_widget_hide (wp_width_label);
1199     gtk_widget_hide (e_143);
1200     gtk_widget_hide (wp_centre_label);
1201 
1202 #ifdef _WITH_OPENGL
1203     if ( GLWindowOpened == ON ) {
1204       GLUpdate3d(glArea);
1205       GLDisplay3d(glArea);
1206     }
1207 #endif
1208   } else {
1209 
1210     Flags.disk = OFF;
1211     gtk_widget_hide (e_114);
1212     gtk_widget_hide (orad_label);
1213     gtk_widget_hide (e_115);
1214     gtk_widget_hide (irad_label);
1215     gtk_widget_hide (e_116);
1216     gtk_widget_hide (tilt_label);
1217     gtk_widget_hide (t_warp_button);
1218     gtk_widget_hide (e_117);
1219     gtk_widget_hide (warp_label);
1220     gtk_widget_hide (e_118);
1221     gtk_widget_hide (thick_label);
1222     gtk_widget_hide (e_119);
1223     gtk_widget_hide (hr_label);
1224     gtk_widget_hide (e_120);
1225     gtk_widget_hide (disktmp_label);
1226 
1227     gtk_widget_hide (td_button_0);
1228     gtk_widget_hide (td_button_1);
1229     gtk_widget_hide (td_button_2);
1230 
1231     gtk_widget_hide (e_130);
1232     gtk_widget_hide (hs_temp_label);
1233     gtk_widget_hide (e_131);
1234     gtk_widget_hide (hs_longitude_label);
1235     gtk_widget_hide (e_132);
1236     gtk_widget_hide (hs_extent_label);
1237     gtk_widget_hide (e_133);
1238     gtk_widget_hide (hs_depth_label);
1239     gtk_widget_hide (e_134);
1240     gtk_widget_hide (hs_puff_label);
1241 
1242     gtk_widget_hide (e_140);
1243     gtk_widget_hide (wp_max_label);
1244     gtk_widget_hide (e_141);
1245     gtk_widget_hide (wp_longitude_label);
1246     gtk_widget_hide (e_142);
1247     gtk_widget_hide (wp_width_label);
1248     gtk_widget_hide (e_143);
1249     gtk_widget_hide (wp_centre_label);
1250 
1251 #ifdef _WITH_OPENGL
1252     if ( GLWindowOpened == ON ) {
1253       GLUpdate3d(glArea);
1254       GLDisplay3d(glArea);
1255     }
1256 #endif
1257   }
1258   return;
1259 }
1260 
1261 /******************************************************************
1262  @package   nightfall
1263  @author    Markus Kuster (kuster@astro.uni-tuebingen.de)
1264  @version   1.0
1265  @short     Toggle warped disk
1266  @param     (GtkWidget) *widget     Discarded
1267  @param     (gpointer)  *data       Discarded
1268  @return    (void)
1269  @heading   Graphical User Interface
1270 *******************************************************************/
toggle_warp(GtkWidget * widget,gpointer * data)1271 void toggle_warp (GtkWidget *widget, gpointer *data)
1272 {
1273   if(GTK_TOGGLE_BUTTON (widget)->active) {
1274 
1275     Flags.warp = ON;
1276     gtk_widget_show (e_117);
1277     gtk_widget_show (warp_label);
1278 
1279 #ifdef _WITH_OPENGL
1280     if ( GLWindowOpened == ON ) {
1281       GLUpdate3d(glArea);
1282       GLDisplay3d(glArea);
1283     }
1284 #endif
1285   } else {
1286 
1287     Flags.warp = OFF;
1288     gtk_widget_hide (e_117);
1289     gtk_widget_hide (warp_label);
1290 
1291 #ifdef _WITH_OPENGL
1292     if ( GLWindowOpened == ON ) {
1293       GLUpdate3d(glArea);
1294       GLDisplay3d(glArea);
1295     }
1296 #endif
1297   }
1298   return;
1299 }
1300 #endif
1301 
1302 /******************************************************************
1303  @package   nightfall
1304  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1305  @version   1.0
1306  @short     Toggle elliptic orbit
1307  @param     (GtkWidget) *widget     Discarded
1308  @param     (gpointer)  *data       Discarded
1309  @return    (void)
1310  @heading   Graphical User Interface
1311 *******************************************************************/
toggle_elliptic(GtkWidget * widget,gpointer * data)1312 void toggle_elliptic (GtkWidget *widget, gpointer *data)
1313 {
1314   if(GTK_TOGGLE_BUTTON (widget)->active) {
1315 
1316     Flags.elliptic = ON;
1317     gtk_widget_show (ecc_button);
1318     gtk_widget_show (ome_button);
1319     gtk_widget_show (e_107);
1320     gtk_widget_show (e_108);
1321   } else {
1322 
1323     Flags.elliptic = OFF;
1324     gtk_widget_hide (ecc_button);
1325     gtk_widget_hide (ome_button);
1326     gtk_widget_hide (e_107);
1327     gtk_widget_hide (e_108);
1328   }
1329   return;
1330 }
1331 
1332 /******************************************************************
1333  @package   nightfall
1334  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1335  @version   1.0
1336  @short     Toggle asynchroneous rotation (Primary)
1337  @param     (GtkWidget) *widget     Discarded
1338  @param     (gpointer)  *data       Discarded
1339  @return    (void)
1340  @heading   Graphical User Interface
1341 *******************************************************************/
toggle_fratio1(GtkWidget * widget,gpointer * data)1342 void toggle_fratio1 (GtkWidget *widget, gpointer *data)
1343 {
1344   if(GTK_TOGGLE_BUTTON (widget)->active) {
1345 
1346     Flags.asynchron1 = ON;
1347     gtk_widget_show (as1_button);
1348     gtk_widget_show (e_109);
1349   } else {
1350 
1351     Flags.asynchron1 = OFF;
1352     gtk_widget_hide (as1_button);
1353     gtk_widget_hide (e_109);
1354   }
1355   return;
1356 }
1357 
1358 /******************************************************************
1359  @package   nightfall
1360  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1361  @version   1.0
1362  @short     Toggle asynchroneous rotation (Secondary)
1363  @param     (GtkWidget) *widget     Discarded
1364  @param     (gpointer)  *data       Discarded
1365  @return    (void)
1366  @heading   Graphical User Interface
1367 *******************************************************************/
toggle_fratio2(GtkWidget * widget,gpointer * data)1368 void toggle_fratio2 (GtkWidget *widget, gpointer *data)
1369 {
1370   if(GTK_TOGGLE_BUTTON (widget)->active) {
1371 
1372     Flags.asynchron2 = ON;
1373     gtk_widget_show (as2_button);
1374     gtk_widget_show (e_110);
1375   } else {
1376 
1377     Flags.asynchron2 = OFF;
1378     gtk_widget_hide (as2_button);
1379     gtk_widget_hide (e_110);
1380   }
1381   return;
1382 }
1383 
1384 /******************************************************************
1385  @package   nightfall
1386  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1387  @version   1.0
1388  @short     Toggle blackbody/model atmosphere
1389  @param     (GtkWidget) *widget     Discarded
1390  @param     (gpointer)  *data       Discarded
1391  @return    (void)
1392  @heading   Graphical User Interface
1393 *******************************************************************/
toggle_blackbody(GtkWidget * widget,gpointer * data)1394 void toggle_blackbody (GtkWidget *widget, gpointer *data)
1395 {
1396   char           InitString[64];
1397   if(GTK_TOGGLE_BUTTON (widget)->active) {
1398 
1399     Flags.blackbody = OFF;
1400 
1401     if (Binary[Primary].log_g <= FLT_EPSILON)
1402       Binary[Primary].log_g = 4.0;
1403     if (Binary[Secondary].log_g <= FLT_EPSILON)
1404       Binary[Secondary].log_g = 4.0;
1405 
1406     sprintf(InitString, "%3.1f", Binary[Primary].log_g);
1407     if (e_121)
1408       gtk_entry_set_text (GTK_ENTRY (e_121), InitString);
1409 
1410     sprintf(InitString, "%3.1f", Binary[Secondary].log_g);
1411     if (e_122)
1412       gtk_entry_set_text (GTK_ENTRY (e_122), InitString);
1413 
1414     gtk_widget_show (e_121);
1415     gtk_widget_show (e_122);
1416 
1417   } else {
1418 
1419     Flags.blackbody = ON;
1420     gtk_widget_hide (e_121);
1421     gtk_widget_hide (e_122);
1422 
1423   }
1424   return;
1425 }
1426 
1427 /******************************************************************
1428  @package   nightfall
1429  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1430  @version   1.0
1431  @short     Toggle fractional visbility ON/OFF
1432  @param     (GtkWidget) *widget     Discarded
1433  @param     (gpointer)  *data       Discarded
1434  @return    (void)
1435  @heading   Graphical User Interface
1436 *******************************************************************/
toggle_fractional(GtkWidget * widget,gpointer * data)1437 void toggle_fractional (GtkWidget *widget, gpointer *data)
1438 {
1439   if(GTK_TOGGLE_BUTTON (widget)->active) {
1440 
1441     Flags.fractional = ON;
1442   } else {
1443 
1444     Flags.fractional = OFF;
1445   }
1446   return;
1447 }
1448 
1449 /******************************************************************
1450  @package   nightfall
1451  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1452  @version   1.0
1453  @short     Toggle detailed reflection ON/OFF
1454  @param     (GtkWidget) *widget     Discarded
1455  @param     (gpointer)  *data       Discarded
1456  @return    (void)
1457  @heading   Graphical User Interface
1458 *******************************************************************/
toggle_reflect(GtkWidget * widget,gpointer * data)1459 void toggle_reflect (GtkWidget *widget, gpointer *data)
1460 {
1461   char InitString[4];           /* entry string                   */
1462 
1463   if(GTK_TOGGLE_BUTTON (widget)->active) {
1464 
1465     gtk_widget_show (ref_label);
1466     gtk_widget_show (e_113);
1467     if (TG_reflectstore > 0) {
1468          Flags.reflect = TG_reflectstore;
1469     } else {
1470          Flags.reflect = ON;
1471          sprintf(InitString, "%3d", Flags.reflect);
1472          gtk_entry_set_text (GTK_ENTRY (e_113), InitString);
1473     }
1474   } else {
1475 
1476     gtk_widget_hide (ref_label);
1477     gtk_widget_hide (e_113);
1478     Flags.reflect = OFF;
1479   }
1480   return;
1481 }
1482 
1483 /******************************************************************
1484  @package   nightfall
1485  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1486  @version   1.0
1487  @short     Toggle line profile computation ON/OFF
1488  @param     (GtkWidget) *widget     Discarded
1489  @param     (gpointer)  *data       Discarded
1490  @return    (void)
1491  @heading   Graphical User Interface
1492 *******************************************************************/
toggle_lineprofile(GtkWidget * widget,gpointer * data)1493 void toggle_lineprofile (GtkWidget *widget, gpointer *data)
1494 {
1495   if(GTK_TOGGLE_BUTTON (widget)->active) {
1496 
1497     Flags.lineprofile = ON;
1498   } else {
1499 
1500     Flags.lineprofile = OFF;
1501   }
1502   return;
1503 }
1504 
1505 
1506 /******************************************************************
1507  @package   nightfall
1508  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1509  @version   1.0
1510  @short     Toggle animated mode ON/OFF
1511  @param     (GtkWidget) *widget     Discarded
1512  @param     (gpointer)  *data       Discarded
1513  @return    (void)
1514  @heading   Graphical User Interface
1515 *******************************************************************/
toggle_animate(GtkWidget * widget,gpointer * data)1516 void toggle_animate (GtkWidget *widget, gpointer *data)
1517 {
1518   if(GTK_TOGGLE_BUTTON (widget)->active) {
1519     Flags.animate = ON;
1520   } else {
1521     Flags.animate = OFF;
1522   }
1523   return;
1524 }
1525 
1526 /******************************************************************
1527  @package   nightfall
1528  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1529  @version   1.0
1530  @short     Toggle hardcopy (ps-file) ON/OFF
1531  @param     (GtkWidget) *widget     Discarded
1532  @param     (gpointer)  *data       Discarded
1533  @return    (void)
1534  @heading   Graphical User Interface
1535 *******************************************************************/
toggle_psfile(GtkWidget * widget,gpointer * data)1536 void toggle_psfile (GtkWidget *widget, gpointer *data)
1537 {
1538   if(GTK_TOGGLE_BUTTON (widget)->active) {
1539     Flags.eps = ON;
1540   } else {
1541     Flags.eps = OFF;
1542   }
1543   return;
1544 }
1545 
1546 /******************************************************************
1547  @package   nightfall
1548  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1549  @version   1.1
1550  @short     Toggle use OpenGL ON/OFF
1551  @param     (GtkWidget) *widget     Discarded
1552  @param     (gpointer)  *data       Discarded
1553  @return    (void)
1554  @heading   Graphical User Interface
1555 *******************************************************************/
1556 #ifdef _WITH_OPENGL
toggle_opengl(GtkWidget * widget,gpointer * data)1557 void toggle_opengl (GtkWidget *widget, gpointer *data)
1558 {
1559   if(GTK_TOGGLE_BUTTON (widget)->active) {
1560     Flags.use_opengl = ON;
1561     if ( GLWindowOpened == ON && GLWindowHidden == ON) {
1562       gtk_widget_show(glWindow);
1563     }
1564   } else {
1565     Flags.use_opengl = OFF;
1566     if ( GLWindowOpened == ON ) {
1567       if (GLPrefWinOpened == TRUE) {
1568 	gtk_widget_destroy (GTK_WIDGET (glPrefsWindow) );
1569 	GLPrefWinOpened = OFF;
1570       }
1571 
1572       gtk_widget_hide (glWindow);
1573       GLWindowHidden = ON;
1574       /*
1575       gtk_widget_destroy (GTK_WIDGET (glArea) );
1576       gtk_widget_destroy (GTK_WIDGET (glWindow) );
1577       GLWindowOpened = OFF;
1578       */
1579     }
1580   }
1581   return;
1582 }
1583 #endif
1584 
1585 /******************************************************************
1586  @package   nightfall
1587  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1588  @version   1.0
1589  @short     Toggle data fitting ON/OFF
1590  @param     (GtkWidget) *widget     Discarded
1591  @param     (gpointer)  *data       Which parameter to fit ?
1592  @return    (void)
1593  @heading   Graphical User Interface
1594 *******************************************************************/
toggle_fit(GtkWidget * widget,gpointer * data)1595 void toggle_fit (GtkWidget *widget, gpointer *data)
1596 {
1597   int  i;   /* index on parameter to fit                          */
1598 
1599   if (data != NULL) {
1600     sscanf ((char *) data, "%d", &i);
1601     if(GTK_TOGGLE_BUTTON (widget)->active) {
1602       Flags.simplex[i] = ON;
1603     } else {
1604       Flags.simplex[i] = OFF;
1605     }
1606   } else {
1607     WARNING(_("fit parameter is NULL"));
1608   }
1609   return;
1610 }
1611 
1612 
1613 /******************************************************************
1614  @package   nightfall
1615  @author    Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
1616  @version   1.0
1617  @short     Toggle debug options ON/OFF
1618  @param     (GtkWidget) *widget     Discarded
1619  @param     (gpointer)  *data       Which parameter to fit ?
1620  @return    (void)
1621  @heading   Graphical User Interface
1622 *******************************************************************/
toggle_debug(GtkWidget * widget,gpointer * data)1623 void toggle_debug (GtkWidget *widget, gpointer *data)
1624 {
1625   int  i;    /* index on debug option                             */
1626 
1627   sscanf ((char *) data, "%d", &i);
1628 
1629   if(GTK_TOGGLE_BUTTON (widget)->active) {
1630     if (i == 1) Flags.debug[WARN] = ON;
1631     if (i == 2) Flags.debug[BUSY] = ON;
1632     if (i == 3) Flags.debug[VERBOSE] = ON;
1633   } else {
1634     if (i == 1) Flags.debug[WARN] = OFF;
1635     if (i == 2) Flags.debug[BUSY] = OFF;
1636     if (i == 3) Flags.debug[VERBOSE] = OFF;
1637   }
1638   return;
1639 }
1640 
1641 #endif
1642 
1643 
1644 
1645 
1646 
1647