1 // StarPlot - A program for interactively viewing 3D maps of stellar positions.
2 // Copyright (C) 2000  Kevin B. McCarty
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 
18 
19 #ifndef _STARPLOT_H
20 #define _STARPLOT_H
21 
22 #include <gtk/gtk.h>
23 #include <cmath>
24 #include <cstdio>
25 #include <cstdlib>
26 
27 #include "../classes/stararray.h"
28 #include "gtkviewer.h"
29 #include "menu.h"
30 
31 #ifndef DATADIR
32 #define DATADIR "/usr/local/share/starplot"
33 #endif
34 
35 #ifndef DOCDIR
36 #define DOCDIR "/usr/local/share/doc/starplot"
37 #endif
38 
39 // Default program values (used if no .starplotrc file is found in $HOME)
40 
41 namespace defaults {
42 
43   // parameters of the GUI
44 
45   const unsigned int  program_width	    = 550;
46   const unsigned int  program_height	    = 500;
47   const unsigned int  program_hr_width	    = 480; // dimensions of HR diagram
48   const unsigned int  program_hr_height	    = 360; //  window
49   const unsigned int  program_button_width  = 75;  // global default size for
50   const unsigned int  program_button_height = 22;  //  OK / Cancel buttons
51   const std::string   program_help_browser  =
52 #ifdef BROWSER
53 					      BROWSER;
54 #else
55 					      "";
56 #endif
57 
58   // parameters controlling what stars are initially displayed
59 
60   const StringList    chart_filenames =
61     StringList(1 /* copy of arg2: */, DATADIR "/sample.stars");
62   const Vector3	      chart_center	= Vector3(0, 0, 0);
63   const SolidAngle    chart_orientation = SolidAngle(21 HOURS, +30 DEGREES);
64   const double	      chart_radius      = 10 /* light-years */;
65   const float	      chart_mag_dim     = +25;
66   const float	      chart_mag_bright	= -25;
67   const bool	      chart_hide_comps	= true; // hide companion stars
68   const bool	      chart_mag_auto	= true; // automatically set dim mag.
69   const bool	      chart_classes[10] =  { true, true, true, true, true,
70 	                                     true, true, true, true, true };
71   const bool	      chart_coord_type  = CELESTIAL;
72 
73   // parameters controlling initial appearance of the chart
74 
75   // If you edit the following two lines, you also must reorder the menu items
76   //  in menuops.cc so that this default is the first of the starlabel menu
77   //  items.  Otherwise the initial toggle setting will not match this default.
78   const star_diameter_t display_starsize= MAGNITUDE_DIAMETERS;
79   const star_label_t  display_label_type= LANDMARK_LABEL;
80 
81   const distance_unit display_units[4]  = { DIST_LY,DIST_LY,DIST_AU,DIST_KM };
82 
83   const bool	      display_bars	= true;
84   const bool	      display_grid	= true;
85   const bool	      display_legend	= true;
86   const std::string   display_fontname	= "Sans 8";
87 
88   // parameters controlling appearance of the HR diagram window
89 
90   const double	      hr_mag_bright	= -8;
91   const double	      hr_mag_dim	= +12;
92 
93   // structure containing default chart parameters
94 
95   const Rules	      chart_rules	= Rules(chart_filenames,
96 						chart_center,
97 						chart_orientation,
98 						chart_radius,
99 						chart_mag_dim,
100 						chart_mag_bright,
101 						chart_hide_comps,
102 						chart_mag_auto,
103 						chart_classes,
104 						chart_coord_type,
105 						display_starsize,
106 						display_label_type,
107 						display_bars,
108 						display_grid,
109 						display_legend,
110 						display_units
111 					       );
112 } // end "defaults" namespace
113 
114 // Values that need to be shared across object files
115 
116 namespace globals {
117 
118   // parameters
119 #ifdef BROWSER
120   const
121 #endif
122   extern std::string  program_help_browser;
123   extern std::string  display_fontname;
124   extern Rules	      chart_rules;
125   extern double	      hr_mag_bright;
126   extern double	      hr_mag_dim;
127 
128   // data
129   extern StarArray    *chart_stararray;
130 
131   // widgets
132   extern GtkWidget    *program_status;	    // status text at bottom of window
133   extern GtkTreeView  *program_treeview;    // Chart Data list of stars
134   extern GTKViewer    *program_viewer;      // The GTKViewer used by StarPlot
135   extern GtkWidget    *program_canvas;      // The GTK_DRAWING_AREA used
136   extern GdkPixmap    *program_pixmap;	    // The backing pixmap
137   extern GTKViewer    *program_hr_viewer;   // HR Diagram GTKViewer
138   extern GtkWidget    *program_hr_canvas;   // HR Diagram GTK_DRAWING_AREA
139   extern GdkPixbuf    *program_icon;	    // used by the window manager
140 
141 } // end "globals" namespace
142 
143 #define RESET_GLOBAL(var)    (globals::var = defaults::var)
144 
145 // Button bar callbacks, defined in menuops.cc
146 
147 extern void button_zoom(GtkWidget *w, gpointer zoomfactor);
148 extern void button_rotate(GtkWidget *w, gpointer angle);
149 extern void button_tilt(GtkWidget *w, gpointer angle);
150 extern void button_magchange(GtkWidget *w, gpointer magchange);
151 
152 // Useful adjunct functions
153 
154 extern bool read_rc_file();
155 extern bool write_rc_file();
156 extern void help_select_and_open();
157 extern double automagnitude (double radius);
158 extern void my_gtk_star_popup (Star &);
159 extern void my_gtk_star_coordinates (GtkWidget **entryboxes, GtkWidget *box);
160 extern void my_gtk_main_menu (GtkWidget *window, GtkWidget **menubar);
161 extern void my_gtk_push_buttons (GtkWidget *window, GtkWidget **buttonbar);
162 extern void my_gtk_button_bar (GtkWidget **OKbtn, GtkWidget **Defaultsbtn,
163 			       GtkWidget **Cancelbtn, GtkWidget *box,
164 			       int spacing = 20);
165 extern void my_gtk_popup_button (GtkWidget **Closebtn, GtkWidget *box,
166 				 GtkWidget *window);
167 extern void my_gtk_buttons_connect_destroy (GtkWidget *btn1, GtkWidget *btn2,
168 					    GtkWidget *btn3, GtkWidget *win);
169 extern void my_gtk_error (GtkWindow *parent_win, const char * error_msg);
170 extern void hr_redraw_display(GtkWidget *hr_display);
171 extern void set_widget_font(GtkWidget *pixmap, std::string font_description);
172 extern void update_info(GtkTreeView *info_treeview);
173 extern void redraw_all (star_changetype_t);
174 
175 // Functions to set menu toggle/radio buttons
176 
177 template<class T> extern void
178 set_item(T *, T, GtkWidget *, bool, star_changetype_t = DECORATIONS_CHANGE);
179 extern void flip_toggle_item(bool *, int, bool);
180 extern void set_toggle_item(bool *, bool, int, bool);
181 extern void set_label_item(star_label_t, bool);
182 extern void set_diameter_item(star_diameter_t, bool);
183 extern void set_coord_item(bool, bool);
184 extern void set_distance_units(const distance_unit[4], bool);
185 
186 #endif // #include _STARPLOT_H
187