[Gpredict-svn] SF.net SVN: gpredict:[284] trunk/src
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <cs...@us...> - 2009-05-01 23:06:58
|
Revision: 284
http://gpredict.svn.sourceforge.net/gpredict/?rev=284&view=rev
Author: csete
Date: 2009-05-01 23:06:55 +0000 (Fri, 01 May 2009)
Log Message:
-----------
Fixed indent.
Modified Paths:
--------------
trunk/src/gtk-sat-map.c
trunk/src/gtk-sat-map.h
Modified: trunk/src/gtk-sat-map.c
===================================================================
--- trunk/src/gtk-sat-map.c 2009-05-01 23:04:14 UTC (rev 283)
+++ trunk/src/gtk-sat-map.c 2009-05-01 23:06:55 UTC (rev 284)
@@ -58,7 +58,7 @@
#endif
#include <goocanvas.h>
-#define MARKER_SIZE_HALF 1
+#define MARKER_SIZE_HALF 1
static void gtk_sat_map_class_init (GtkSatMapClass *class);
static void gtk_sat_map_init (GtkSatMap *polview);
@@ -70,22 +70,22 @@
static void lonlat_to_xy (GtkSatMap *m, gdouble lon, gdouble lat, gfloat *x, gfloat *y);
static void xy_to_lonlat (GtkSatMap *m, gfloat x, gfloat y, gfloat *lon, gfloat *lat);
static gboolean on_motion_notify (GooCanvasItem *item,
- GooCanvasItem *target,
- GdkEventMotion *event,
- gpointer data);
+ GooCanvasItem *target,
+ GdkEventMotion *event,
+ gpointer data);
static void on_item_created (GooCanvas *canvas,
- GooCanvasItem *item,
- GooCanvasItemModel *model,
- gpointer data);
+ GooCanvasItem *item,
+ GooCanvasItemModel *model,
+ gpointer data);
static void on_canvas_realized (GtkWidget *canvas, gpointer data);
static gboolean on_button_press (GooCanvasItem *item,
- GooCanvasItem *target,
- GdkEventButton *event,
- gpointer data);
+ GooCanvasItem *target,
+ GdkEventButton *event,
+ gpointer data);
static gboolean on_button_release (GooCanvasItem *item,
- GooCanvasItem *target,
- GdkEventButton *event,
- gpointer data);
+ GooCanvasItem *target,
+ GdkEventButton *event,
+ gpointer data);
static void clear_selection (gpointer key, gpointer val, gpointer data);
static void load_map_file (GtkSatMap *satmap);
static GooCanvasItemModel* create_canvas_model (GtkSatMap *satmap);
@@ -111,28 +111,28 @@
GtkType
gtk_sat_map_get_type ()
{
- static GType gtk_sat_map_type = 0;
+ static GType gtk_sat_map_type = 0;
- if (!gtk_sat_map_type) {
- static const GTypeInfo gtk_sat_map_info = {
- sizeof (GtkSatMapClass),
- NULL, /* base init */
- NULL, /* base finalize */
- (GClassInitFunc) gtk_sat_map_class_init,
- NULL, /* class finalize */
- NULL, /* class data */
- sizeof (GtkSatMap),
- 5, /* n_preallocs */
- (GInstanceInitFunc) gtk_sat_map_init,
- };
+ if (!gtk_sat_map_type) {
+ static const GTypeInfo gtk_sat_map_info = {
+ sizeof (GtkSatMapClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) gtk_sat_map_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (GtkSatMap),
+ 5, /* n_preallocs */
+ (GInstanceInitFunc) gtk_sat_map_init,
+ };
- gtk_sat_map_type = g_type_register_static (GTK_TYPE_VBOX,
- "GtkSatMap",
- >k_sat_map_info,
- 0);
- }
+ gtk_sat_map_type = g_type_register_static (GTK_TYPE_VBOX,
+ "GtkSatMap",
+ >k_sat_map_info,
+ 0);
+ }
- return gtk_sat_map_type;
+ return gtk_sat_map_type;
}
@@ -140,20 +140,20 @@
static void
gtk_sat_map_class_init (GtkSatMapClass *class)
{
- GObjectClass *gobject_class;
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
+ GObjectClass *gobject_class;
+ GtkObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
- gobject_class = G_OBJECT_CLASS (class);
- object_class = (GtkObjectClass*) class;
- widget_class = (GtkWidgetClass*) class;
- container_class = (GtkContainerClass*) class;
+ gobject_class = G_OBJECT_CLASS (class);
+ object_class = (GtkObjectClass*) class;
+ widget_class = (GtkWidgetClass*) class;
+ container_class = (GtkContainerClass*) class;
- parent_class = g_type_class_peek_parent (class);
+ parent_class = g_type_class_peek_parent (class);
- object_class->destroy = gtk_sat_map_destroy;
- /* widget_class->size_allocate = gtk_sat_map_size_allocate; */
+ object_class->destroy = gtk_sat_map_destroy;
+ /* widget_class->size_allocate = gtk_sat_map_size_allocate; */
}
@@ -161,24 +161,24 @@
static void
gtk_sat_map_init (GtkSatMap *satmap)
{
- satmap->sats = NULL;
- satmap->qth = NULL;
- satmap->obj = NULL;
- satmap->naos = 2458849.5;
- satmap->ncat = 0;
- satmap->tstamp = 2458849.5;
- satmap->x0 = 0;
- satmap->y0 = 0;
- satmap->width = 0;
- satmap->height = 0;
- satmap->refresh = 0;
- satmap->counter = 0;
- satmap->qthinfo = FALSE;
- satmap->eventinfo = FALSE;
- satmap->cursinfo = FALSE;
- satmap->showgrid = FALSE;
- satmap->keepratio = FALSE;
- satmap->resize = FALSE;
+ satmap->sats = NULL;
+ satmap->qth = NULL;
+ satmap->obj = NULL;
+ satmap->naos = 2458849.5;
+ satmap->ncat = 0;
+ satmap->tstamp = 2458849.5;
+ satmap->x0 = 0;
+ satmap->y0 = 0;
+ satmap->width = 0;
+ satmap->height = 0;
+ satmap->refresh = 0;
+ satmap->counter = 0;
+ satmap->qthinfo = FALSE;
+ satmap->eventinfo = FALSE;
+ satmap->cursinfo = FALSE;
+ satmap->showgrid = FALSE;
+ satmap->keepratio = FALSE;
+ satmap->resize = FALSE;
}
@@ -186,7 +186,7 @@
static void
gtk_sat_map_destroy (GtkObject *object)
{
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -199,99 +199,99 @@
GtkWidget*
gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth)
{
- GtkWidget *satmap;
- GooCanvasItemModel *root;
- guint32 col;
+ GtkWidget *satmap;
+ GooCanvasItemModel *root;
+ guint32 col;
- satmap = g_object_new (GTK_TYPE_SAT_MAP, NULL);
+ satmap = g_object_new (GTK_TYPE_SAT_MAP, NULL);
- GTK_SAT_MAP (satmap)->cfgdata = cfgdata;
- GTK_SAT_MAP (satmap)->sats = sats;
- GTK_SAT_MAP (satmap)->qth = qth;
+ GTK_SAT_MAP (satmap)->cfgdata = cfgdata;
+ GTK_SAT_MAP (satmap)->sats = sats;
+ GTK_SAT_MAP (satmap)->qth = qth;
- GTK_SAT_MAP (satmap)->obj = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL);
+ GTK_SAT_MAP (satmap)->obj = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL);
- /* get settings */
- GTK_SAT_MAP (satmap)->refresh = mod_cfg_get_int (cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_REFRESH,
- SAT_CFG_INT_MAP_REFRESH);
- GTK_SAT_MAP (satmap)->counter = 1;
+ /* get settings */
+ GTK_SAT_MAP (satmap)->refresh = mod_cfg_get_int (cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_REFRESH,
+ SAT_CFG_INT_MAP_REFRESH);
+ GTK_SAT_MAP (satmap)->counter = 1;
- GTK_SAT_MAP (satmap)->qthinfo = mod_cfg_get_bool (cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_SHOW_QTH_INFO,
- SAT_CFG_BOOL_MAP_SHOW_QTH_INFO);
+ GTK_SAT_MAP (satmap)->qthinfo = mod_cfg_get_bool (cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SHOW_QTH_INFO,
+ SAT_CFG_BOOL_MAP_SHOW_QTH_INFO);
- GTK_SAT_MAP (satmap)->eventinfo = mod_cfg_get_bool (cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_SHOW_NEXT_EVENT,
- SAT_CFG_BOOL_MAP_SHOW_NEXT_EV);
+ GTK_SAT_MAP (satmap)->eventinfo = mod_cfg_get_bool (cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SHOW_NEXT_EVENT,
+ SAT_CFG_BOOL_MAP_SHOW_NEXT_EV);
- GTK_SAT_MAP (satmap)->cursinfo = mod_cfg_get_bool (cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_SHOW_CURS_TRACK,
- SAT_CFG_BOOL_MAP_SHOW_CURS_TRACK);
+ GTK_SAT_MAP (satmap)->cursinfo = mod_cfg_get_bool (cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SHOW_CURS_TRACK,
+ SAT_CFG_BOOL_MAP_SHOW_CURS_TRACK);
- GTK_SAT_MAP (satmap)->showgrid = mod_cfg_get_bool (cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_SHOW_GRID,
- SAT_CFG_BOOL_MAP_SHOW_GRID);
+ GTK_SAT_MAP (satmap)->showgrid = mod_cfg_get_bool (cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SHOW_GRID,
+ SAT_CFG_BOOL_MAP_SHOW_GRID);
- GTK_SAT_MAP (satmap)->keepratio = mod_cfg_get_bool (cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_KEEP_RATIO,
- SAT_CFG_BOOL_MAP_KEEP_RATIO);
- col = mod_cfg_get_int (cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_INFO_BGD_COL,
- SAT_CFG_INT_MAP_INFO_BGD_COL);
+ GTK_SAT_MAP (satmap)->keepratio = mod_cfg_get_bool (cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_KEEP_RATIO,
+ SAT_CFG_BOOL_MAP_KEEP_RATIO);
+ col = mod_cfg_get_int (cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_INFO_BGD_COL,
+ SAT_CFG_INT_MAP_INFO_BGD_COL);
- GTK_SAT_MAP (satmap)->infobgd = rgba2html (col);
+ GTK_SAT_MAP (satmap)->infobgd = rgba2html (col);
- /* create the canvas */
- GTK_SAT_MAP (satmap)->canvas = goo_canvas_new ();
+ /* create the canvas */
+ GTK_SAT_MAP (satmap)->canvas = goo_canvas_new ();
- /* safely load a background map */
- load_map_file (GTK_SAT_MAP (satmap));
+ /* safely load a background map */
+ load_map_file (GTK_SAT_MAP (satmap));
- /* Initial size request should be based on map size
- but if we do this we can not shrink the canvas below this size
- even though the map shrinks => better to set default size of
- main container window.
- */
- /* gtk_widget_set_size_request (GTK_SAT_MAP (satmap)->canvas, */
- /* gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap), */
- /* gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap)); */
+ /* Initial size request should be based on map size
+ but if we do this we can not shrink the canvas below this size
+ even though the map shrinks => better to set default size of
+ main container window.
+ */
+ /* gtk_widget_set_size_request (GTK_SAT_MAP (satmap)->canvas, */
+ /* gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap), */
+ /* gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap)); */
- goo_canvas_set_bounds (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), 0, 0,
- gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap),
- gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap));
+ goo_canvas_set_bounds (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), 0, 0,
+ gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap),
+ gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap));
- /* connect size-request signal */
- g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "size-allocate",
- G_CALLBACK (size_allocate_cb), satmap);
- g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "item_created",
- (GtkSignalFunc) on_item_created, satmap);
- g_signal_connect_after (GTK_SAT_MAP (satmap)->canvas, "realize",
- (GtkSignalFunc) on_canvas_realized, satmap);
+ /* connect size-request signal */
+ g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "size-allocate",
+ G_CALLBACK (size_allocate_cb), satmap);
+ g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "item_created",
+ (GtkSignalFunc) on_item_created, satmap);
+ g_signal_connect_after (GTK_SAT_MAP (satmap)->canvas, "realize",
+ (GtkSignalFunc) on_canvas_realized, satmap);
- gtk_widget_show (GTK_SAT_MAP (satmap)->canvas);
+ gtk_widget_show (GTK_SAT_MAP (satmap)->canvas);
- /* create the canvas model */
- root = create_canvas_model (GTK_SAT_MAP (satmap));
- goo_canvas_set_root_item_model (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), root);
+ /* create the canvas model */
+ root = create_canvas_model (GTK_SAT_MAP (satmap));
+ goo_canvas_set_root_item_model (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), root);
- g_object_unref (root);
+ g_object_unref (root);
- /* plot each sat on the canvas */
- g_hash_table_foreach (GTK_SAT_MAP (satmap)->sats, plot_sat, GTK_SAT_MAP (satmap));
+ /* plot each sat on the canvas */
+ g_hash_table_foreach (GTK_SAT_MAP (satmap)->sats, plot_sat, GTK_SAT_MAP (satmap));
- /* gtk_box_pack_start (GTK_BOX (satmap), GTK_SAT_MAP (satmap)->swin, TRUE, TRUE, 0); */
- gtk_container_add (GTK_CONTAINER (satmap), GTK_SAT_MAP (satmap)->canvas);
+ /* gtk_box_pack_start (GTK_BOX (satmap), GTK_SAT_MAP (satmap)->swin, TRUE, TRUE, 0); */
+ gtk_container_add (GTK_CONTAINER (satmap), GTK_SAT_MAP (satmap)->canvas);
- return satmap;
+ return satmap;
}
@@ -305,127 +305,127 @@
static GooCanvasItemModel *
create_canvas_model (GtkSatMap *satmap)
{
- GooCanvasItemModel *root;
- gchar *buff;
- gfloat x,y;
- guint32 col;
+ GooCanvasItemModel *root;
+ gchar *buff;
+ gfloat x,y;
+ guint32 col;
- root = goo_canvas_group_model_new (NULL, NULL);
+ root = goo_canvas_group_model_new (NULL, NULL);
- /* map dimensions */
- satmap->width = gdk_pixbuf_get_width (satmap->origmap);
- satmap->height = gdk_pixbuf_get_height (satmap->origmap);
- satmap->x0 = 0;
- satmap->y0 = 0;
+ /* map dimensions */
+ satmap->width = gdk_pixbuf_get_width (satmap->origmap);
+ satmap->height = gdk_pixbuf_get_height (satmap->origmap);
+ satmap->x0 = 0;
+ satmap->y0 = 0;
- /* background map */
- satmap->map = goo_canvas_image_model_new (root,
- satmap->origmap,
- satmap->x0,
- satmap->y0,
- NULL);
+ /* background map */
+ satmap->map = goo_canvas_image_model_new (root,
+ satmap->origmap,
+ satmap->x0,
+ satmap->y0,
+ NULL);
- goo_canvas_item_model_lower (satmap->map, NULL);
+ goo_canvas_item_model_lower (satmap->map, NULL);
- /* grid lines */
- draw_grid_lines (satmap, root);
+ /* grid lines */
+ draw_grid_lines (satmap, root);
- /* QTH mark */
- col = mod_cfg_get_int (satmap->cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_QTH_COL,
- SAT_CFG_INT_MAP_QTH_COL);
+ /* QTH mark */
+ col = mod_cfg_get_int (satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_QTH_COL,
+ SAT_CFG_INT_MAP_QTH_COL);
- lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y);
-
- satmap->qthmark = goo_canvas_rect_model_new (root,
- x - MARKER_SIZE_HALF,
- y - MARKER_SIZE_HALF,
- 2 * MARKER_SIZE_HALF,
- 2 * MARKER_SIZE_HALF,
- "fill-color-rgba", col,
- "stroke-color-rgba", col,
- NULL);
+ lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y);
+
+ satmap->qthmark = goo_canvas_rect_model_new (root,
+ x - MARKER_SIZE_HALF,
+ y - MARKER_SIZE_HALF,
+ 2 * MARKER_SIZE_HALF,
+ 2 * MARKER_SIZE_HALF,
+ "fill-color-rgba", col,
+ "stroke-color-rgba", col,
+ NULL);
- satmap->qthlabel = goo_canvas_text_model_new (root, satmap->qth->name,
- x, y+2, -1,
- GTK_ANCHOR_NORTH,
- "font", "Sans 8",
- "fill-color-rgba", col,
- NULL);
+ satmap->qthlabel = goo_canvas_text_model_new (root, satmap->qth->name,
+ x, y+2, -1,
+ GTK_ANCHOR_NORTH,
+ "font", "Sans 8",
+ "fill-color-rgba", col,
+ NULL);
- /* QTH info */
- col = mod_cfg_get_int (satmap->cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_INFO_COL,
- SAT_CFG_INT_MAP_INFO_COL);
+ /* QTH info */
+ col = mod_cfg_get_int (satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_INFO_COL,
+ SAT_CFG_INT_MAP_INFO_COL);
- satmap->locnam = goo_canvas_text_model_new (root, "",
- satmap->x0 + 2, satmap->y0 + 1, -1,
- GTK_ANCHOR_NORTH_WEST,
- "font", "Sans 8",
- "fill-color-rgba", col,
- "use-markup", TRUE,
- NULL);
+ satmap->locnam = goo_canvas_text_model_new (root, "",
+ satmap->x0 + 2, satmap->y0 + 1, -1,
+ GTK_ANCHOR_NORTH_WEST,
+ "font", "Sans 8",
+ "fill-color-rgba", col,
+ "use-markup", TRUE,
+ NULL);
- /* set text only if QTH info is enabled */
- if (satmap->qthinfo) {
- /* For now only QTH name and location.
- It would be nice with coordinates (remember NWSE setting)
- and Maidenhead locator, when using hamlib.
-
- Note: I used pango markup to set the background color, I didn't find any
- other obvious ways to get the text height in pixels to draw rectangle.
- */
- buff = g_strdup_printf ("<span background=\"#%s\"> %s \302\267 %s </span>",
- satmap->infobgd,
- satmap->qth->name,
- satmap->qth->loc);
- g_object_set (satmap->locnam, "text", buff, NULL);
- g_free (buff);
- }
+ /* set text only if QTH info is enabled */
+ if (satmap->qthinfo) {
+ /* For now only QTH name and location.
+ It would be nice with coordinates (remember NWSE setting)
+ and Maidenhead locator, when using hamlib.
+
+ Note: I used pango markup to set the background color, I didn't find any
+ other obvious ways to get the text height in pixels to draw rectangle.
+ */
+ buff = g_strdup_printf ("<span background=\"#%s\"> %s \302\267 %s </span>",
+ satmap->infobgd,
+ satmap->qth->name,
+ satmap->qth->loc);
+ g_object_set (satmap->locnam, "text", buff, NULL);
+ g_free (buff);
+ }
- /* next event */
- satmap->next = goo_canvas_text_model_new (root, "",
- satmap->x0+satmap->width - 2,
- satmap->y0 + 1, -1,
- GTK_ANCHOR_NORTH_EAST,
- "font", "Sans 8",
- "fill-color-rgba", col,
- "use-markup", TRUE,
- NULL);
+ /* next event */
+ satmap->next = goo_canvas_text_model_new (root, "",
+ satmap->x0+satmap->width - 2,
+ satmap->y0 + 1, -1,
+ GTK_ANCHOR_NORTH_EAST,
+ "font", "Sans 8",
+ "fill-color-rgba", col,
+ "use-markup", TRUE,
+ NULL);
- /* set text only if QTH info is enabled */
- if (satmap->eventinfo) {
- buff = g_strdup_printf ("<span background=\"#%s\"> ... </span>",
- satmap->infobgd);
- g_object_set (satmap->next, "text", buff, NULL);
- g_free (buff);
- }
+ /* set text only if QTH info is enabled */
+ if (satmap->eventinfo) {
+ buff = g_strdup_printf ("<span background=\"#%s\"> ... </span>",
+ satmap->infobgd);
+ g_object_set (satmap->next, "text", buff, NULL);
+ g_free (buff);
+ }
- /* cursor track */
- satmap->curs = goo_canvas_text_model_new (root, "",
- satmap->x0 + 2,
- satmap->y0 + satmap->height - 1,
- -1,
- GTK_ANCHOR_SOUTH_WEST,
- "font", "Sans 8",
- "fill-color-rgba", col,
- "use-markup", TRUE,
- NULL);
+ /* cursor track */
+ satmap->curs = goo_canvas_text_model_new (root, "",
+ satmap->x0 + 2,
+ satmap->y0 + satmap->height - 1,
+ -1,
+ GTK_ANCHOR_SOUTH_WEST,
+ "font", "Sans 8",
+ "fill-color-rgba", col,
+ "use-markup", TRUE,
+ NULL);
- /* info about a selected satellite */
- satmap->sel = goo_canvas_text_model_new (root, "",
- satmap->x0 + satmap->width - 2,
- satmap->y0 + satmap->height - 1,
- -1,
- GTK_ANCHOR_SOUTH_EAST,
- "font", "Sans 8",
- "fill-color-rgba", col,
- "use-markup", TRUE,
- NULL);
+ /* info about a selected satellite */
+ satmap->sel = goo_canvas_text_model_new (root, "",
+ satmap->x0 + satmap->width - 2,
+ satmap->y0 + satmap->height - 1,
+ -1,
+ GTK_ANCHOR_SOUTH_EAST,
+ "font", "Sans 8",
+ "fill-color-rgba", col,
+ "use-markup", TRUE,
+ NULL);
- return root;
+ return root;
}
@@ -443,7 +443,7 @@
static void
size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
{
- GTK_SAT_MAP (data)->resize = TRUE;
+ GTK_SAT_MAP (data)->resize = TRUE;
}
@@ -468,108 +468,108 @@
static void
update_map_size (GtkSatMap *satmap)
{
- GtkAllocation allocation;
- GdkPixbuf *pbuf;
- gfloat x, y;
- gfloat ratio; /* ratio between map width and height */
- gfloat size; /* size = min (alloc.w, ratio*alloc.h) */
+ GtkAllocation allocation;
+ GdkPixbuf *pbuf;
+ gfloat x, y;
+ gfloat ratio; /* ratio between map width and height */
+ gfloat size; /* size = min (alloc.w, ratio*alloc.h) */
- if (GTK_WIDGET_REALIZED (satmap)) {
- /* get graph dimensions */
- allocation.width = GTK_WIDGET (satmap)->allocation.width;
- allocation.height = GTK_WIDGET (satmap)->allocation.height;
+ if (GTK_WIDGET_REALIZED (satmap)) {
+ /* get graph dimensions */
+ allocation.width = GTK_WIDGET (satmap)->allocation.width;
+ allocation.height = GTK_WIDGET (satmap)->allocation.height;
- if (satmap->keepratio) {
- /* Use allocation->width and allocation->height to calculate
- * new X0 Y0 width and height. Map proportions must be kept.
- */
- ratio = gdk_pixbuf_get_width (satmap->origmap) /
- gdk_pixbuf_get_height (satmap->origmap);
+ if (satmap->keepratio) {
+ /* Use allocation->width and allocation->height to calculate
+ * new X0 Y0 width and height. Map proportions must be kept.
+ */
+ ratio = gdk_pixbuf_get_width (satmap->origmap) /
+ gdk_pixbuf_get_height (satmap->origmap);
- size = MIN(allocation.width, ratio*allocation.height);
+ size = MIN(allocation.width, ratio*allocation.height);
- satmap->width = (guint) size;
- satmap->height = (guint) (size / ratio);
-
- satmap->x0 = (allocation.width - satmap->width) / 2;
- satmap->y0 = (allocation.height - satmap->height) / 2;
+ satmap->width = (guint) size;
+ satmap->height = (guint) (size / ratio);
+
+ satmap->x0 = (allocation.width - satmap->width) / 2;
+ satmap->y0 = (allocation.height - satmap->height) / 2;
- /* rescale pixbuf */
- pbuf = gdk_pixbuf_scale_simple (satmap->origmap,
- satmap->width,
- satmap->height,
- GDK_INTERP_BILINEAR);
- }
- else {
- satmap->x0 = 0;
- satmap->y0 = 0;
- satmap->width = allocation.width;
- satmap->height =allocation.height;
+ /* rescale pixbuf */
+ pbuf = gdk_pixbuf_scale_simple (satmap->origmap,
+ satmap->width,
+ satmap->height,
+ GDK_INTERP_BILINEAR);
+ }
+ else {
+ satmap->x0 = 0;
+ satmap->y0 = 0;
+ satmap->width = allocation.width;
+ satmap->height =allocation.height;
- /* rescale pixbuf */
- pbuf = gdk_pixbuf_scale_simple (satmap->origmap,
- satmap->width,
- satmap->height,
- GDK_INTERP_BILINEAR);
- }
+ /* rescale pixbuf */
+ pbuf = gdk_pixbuf_scale_simple (satmap->origmap,
+ satmap->width,
+ satmap->height,
+ GDK_INTERP_BILINEAR);
+ }
/* set canvas bounds to match new size */
goo_canvas_set_bounds (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), 0, 0,
satmap->width, satmap->height);
- /* redraw static elements */
- g_object_set (satmap->map,
- "pixbuf", pbuf,
- "x", (gdouble) satmap->x0,
- "y", (gdouble) satmap->y0,
- NULL);
- g_object_unref (pbuf);
+ /* redraw static elements */
+ g_object_set (satmap->map,
+ "pixbuf", pbuf,
+ "x", (gdouble) satmap->x0,
+ "y", (gdouble) satmap->y0,
+ NULL);
+ g_object_unref (pbuf);
- /* grid lines */
- redraw_grid_lines (satmap);
-
- /* QTH */
- lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y);
- g_object_set (satmap->qthmark,
- "x", x - MARKER_SIZE_HALF,
- "y", y - MARKER_SIZE_HALF,
- NULL);
- g_object_set (satmap->qthlabel,
- "x", x,
- "y", y+2,
- NULL);
+ /* grid lines */
+ redraw_grid_lines (satmap);
+
+ /* QTH */
+ lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y);
+ g_object_set (satmap->qthmark,
+ "x", x - MARKER_SIZE_HALF,
+ "y", y - MARKER_SIZE_HALF,
+ NULL);
+ g_object_set (satmap->qthlabel,
+ "x", x,
+ "y", y+2,
+ NULL);
- /* QTH info */
- g_object_set (satmap->locnam,
- "x", (gdouble) satmap->x0 + 2,
- "y", (gdouble) satmap->y0 + 1,
- NULL);
+ /* QTH info */
+ g_object_set (satmap->locnam,
+ "x", (gdouble) satmap->x0 + 2,
+ "y", (gdouble) satmap->y0 + 1,
+ NULL);
- /* next event */
- g_object_set (satmap->next,
- "x", (gdouble) satmap->x0 + satmap->width - 2,
- "y", (gdouble) satmap->y0 + 1,
- NULL);
+ /* next event */
+ g_object_set (satmap->next,
+ "x", (gdouble) satmap->x0 + satmap->width - 2,
+ "y", (gdouble) satmap->y0 + 1,
+ NULL);
- /* cursor info */
- g_object_set (satmap->curs,
- "x", (gdouble) satmap->x0 + 2,
- "y", (gdouble) satmap->y0 + satmap->height - 1,
- NULL);
+ /* cursor info */
+ g_object_set (satmap->curs,
+ "x", (gdouble) satmap->x0 + 2,
+ "y", (gdouble) satmap->y0 + satmap->height - 1,
+ NULL);
- /* selected sat info */
- g_object_set (satmap->sel,
- "x", (gdouble) satmap->x0 + satmap->width - 2,
- "y", (gdouble) satmap->y0 + satmap->height - 1,
- NULL);
+ /* selected sat info */
+ g_object_set (satmap->sel,
+ "x", (gdouble) satmap->x0 + satmap->width - 2,
+ "y", (gdouble) satmap->y0 + satmap->height - 1,
+ NULL);
- /* update satellites */
- g_hash_table_foreach (satmap->sats, update_sat, satmap);
+ /* update satellites */
+ g_hash_table_foreach (satmap->sats, update_sat, satmap);
- satmap->resize = FALSE;
- }
+ satmap->resize = FALSE;
+ }
}
@@ -581,13 +581,13 @@
static void
on_canvas_realized (GtkWidget *canvas, gpointer data)
{
- GtkSatMap *satmap = GTK_SAT_MAP(data);
+ GtkSatMap *satmap = GTK_SAT_MAP(data);
- /* raise info items */
- goo_canvas_item_model_raise (satmap->sel, NULL);
- goo_canvas_item_model_raise (satmap->locnam, NULL);
- goo_canvas_item_model_raise (satmap->next, NULL);
- goo_canvas_item_model_raise (satmap->curs, NULL);
+ /* raise info items */
+ goo_canvas_item_model_raise (satmap->sel, NULL);
+ goo_canvas_item_model_raise (satmap->locnam, NULL);
+ goo_canvas_item_model_raise (satmap->next, NULL);
+ goo_canvas_item_model_raise (satmap->curs, NULL);
}
@@ -598,118 +598,118 @@
void
gtk_sat_map_update (GtkWidget *widget)
{
- GtkSatMap *satmap = GTK_SAT_MAP (widget);
- sat_t *sat = NULL;
- gdouble number, now;
- gchar *buff;
- gint *catnr;
- guint h, m, s;
- gchar *ch, *cm, *cs;
+ GtkSatMap *satmap = GTK_SAT_MAP (widget);
+ sat_t *sat = NULL;
+ gdouble number, now;
+ gchar *buff;
+ gint *catnr;
+ guint h, m, s;
+ gchar *ch, *cm, *cs;
- /* check whether there are any pending resize requests */
- if (satmap->resize)
- update_map_size (satmap);
+ /* check whether there are any pending resize requests */
+ if (satmap->resize)
+ update_map_size (satmap);
- /* check refresh rate and refresh sats if time */
- if (satmap->counter < satmap->refresh) {
- satmap->counter++;
- }
- else {
- /* reset data */
- satmap->counter = 1;
- satmap->naos = 2458849.5;
+ /* check refresh rate and refresh sats if time */
+ if (satmap->counter < satmap->refresh) {
+ satmap->counter++;
+ }
+ else {
+ /* reset data */
+ satmap->counter = 1;
+ satmap->naos = 2458849.5;
- /* update sats */
- g_hash_table_foreach (satmap->sats, update_sat, satmap);
+ /* update sats */
+ g_hash_table_foreach (satmap->sats, update_sat, satmap);
- /* update countdown to NEXT AOS label */
- if (satmap->eventinfo) {
+ /* update countdown to NEXT AOS label */
+ if (satmap->eventinfo) {
- if (satmap->ncat > 0) {
+ if (satmap->ncat > 0) {
- catnr = g_try_new0 (gint, 1);
- *catnr = satmap->ncat;
- sat = SAT(g_hash_table_lookup (satmap->sats, catnr));
- g_free (catnr);
+ catnr = g_try_new0 (gint, 1);
+ *catnr = satmap->ncat;
+ sat = SAT(g_hash_table_lookup (satmap->sats, catnr));
+ g_free (catnr);
- /* last desperate sanity check */
- if (sat != NULL) {
+ /* last desperate sanity check */
+ if (sat != NULL) {
- now = satmap->tstamp;//get_current_daynum ();
- number = satmap->naos - now;
+ now = satmap->tstamp;//get_current_daynum ();
+ number = satmap->naos - now;
- /* convert julian date to seconds */
- s = (guint) (number * 86400);
+ /* convert julian date to seconds */
+ s = (guint) (number * 86400);
- /* extract hours */
- h = (guint) floor (s/3600);
- s -= 3600*h;
+ /* extract hours */
+ h = (guint) floor (s/3600);
+ s -= 3600*h;
- /* leading zero */
- if ((h > 0) && (h < 10))
- ch = g_strdup ("0");
- else
- ch = g_strdup ("");
+ /* leading zero */
+ if ((h > 0) && (h < 10))
+ ch = g_strdup ("0");
+ else
+ ch = g_strdup ("");
- /* extract minutes */
- m = (guint) floor (s/60);
- s -= 60*m;
+ /* extract minutes */
+ m = (guint) floor (s/60);
+ s -= 60*m;
- /* leading zero */
- if (m < 10)
- cm = g_strdup ("0");
- else
- cm = g_strdup ("");
+ /* leading zero */
+ if (m < 10)
+ cm = g_strdup ("0");
+ else
+ cm = g_strdup ("");
- /* leading zero */
- if (s < 10)
- cs = g_strdup (":0");
- else
- cs = g_strdup (":");
+ /* leading zero */
+ if (s < 10)
+ cs = g_strdup (":0");
+ else
+ cs = g_strdup (":");
- if (h > 0)
- buff = g_strdup_printf (_("<span background=\"#%s\"> "\
- "Next: %s in %s%d:%s%d%s%d </span>"),
- satmap->infobgd,
- sat->tle.sat_name,
- ch, h, cm, m, cs, s);
- else
- buff = g_strdup_printf (_("<span background=\"#%s\"> " \
- "Next: %s in %s%d%s%d </span>"),
- satmap->infobgd,
- sat->tle.sat_name,
- cm, m, cs, s);
+ if (h > 0)
+ buff = g_strdup_printf (_("<span background=\"#%s\"> "\
+ "Next: %s in %s%d:%s%d%s%d </span>"),
+ satmap->infobgd,
+ sat->tle.sat_name,
+ ch, h, cm, m, cs, s);
+ else
+ buff = g_strdup_printf (_("<span background=\"#%s\"> " \
+ "Next: %s in %s%d%s%d </span>"),
+ satmap->infobgd,
+ sat->tle.sat_name,
+ cm, m, cs, s);
- g_object_set (satmap->next,
- "text", buff,
- NULL);
+ g_object_set (satmap->next,
+ "text", buff,
+ NULL);
- g_free (buff);
- g_free (ch);
- g_free (cm);
- g_free (cs);
- }
- else {
- sat_log_log (SAT_LOG_LEVEL_BUG,
- _("%s: Can not find NEXT satellite."),
- __FUNCTION__);
- g_object_set (satmap->next,
- "text", _("Next: ERR"),
- NULL);
- }
- }
- else {
- g_object_set (satmap->next,
- "text", _("Next: N/A"),
- NULL);
- }
- }
- else {
- g_object_set (satmap->next,
- "text", "",
- NULL);
- }
- }
+ g_free (buff);
+ g_free (ch);
+ g_free (cm);
+ g_free (cs);
+ }
+ else {
+ sat_log_log (SAT_LOG_LEVEL_BUG,
+ _("%s: Can not find NEXT satellite."),
+ __FUNCTION__);
+ g_object_set (satmap->next,
+ "text", _("Next: ERR"),
+ NULL);
+ }
+ }
+ else {
+ g_object_set (satmap->next,
+ "text", _("Next: N/A"),
+ NULL);
+ }
+ }
+ else {
+ g_object_set (satmap->next,
+ "text", "",
+ NULL);
+ }
+ }
}
@@ -724,13 +724,13 @@
static void
lonlat_to_xy (GtkSatMap *p, gdouble lon, gdouble lat, gfloat *x, gfloat *y)
{
- *x = p->x0 + (180.0 - lon) * p->width / 360.0;
- if (*x < 0.0) /* west longitude */
- *x *= -1;
- else /* east longitude */
- *x = p->x0 + (180.0 + lon) * p->width / 360.0;
+ *x = p->x0 + (180.0 - lon) * p->width / 360.0;
+ if (*x < 0.0) /* west longitude */
+ *x *= -1;
+ else /* east longitude */
+ *x = p->x0 + (180.0 + lon) * p->width / 360.0;
- *y = p->y0 + (90.0 - lat) * p->height / 180.0;;
+ *y = p->y0 + (90.0 - lat) * p->height / 180.0;;
}
@@ -748,8 +748,8 @@
static void
xy_to_lonlat (GtkSatMap *p, gfloat x, gfloat y, gfloat *lon, gfloat *lat)
{
- *lat = 90.0 - (180.0 / p->height) * (y - p->y0);
- *lon = (360.0 / p->width) * (x - p->x0) - 180.0;
+ *lat = 90.0 - (180.0 / p->height) * (y - p->y0);
+ *lon = (360.0 / p->width) * (x - p->x0) - 180.0;
}
@@ -760,32 +760,32 @@
*/
static gboolean
on_motion_notify (GooCanvasItem *item,
- GooCanvasItem *target,
- GdkEventMotion *event,
- gpointer data)
+ GooCanvasItem *target,
+ GdkEventMotion *event,
+ gpointer data)
{
- GtkSatMap *satmap = GTK_SAT_MAP (data);
- gfloat lat,lon;
- gchar *text;
+ GtkSatMap *satmap = GTK_SAT_MAP (data);
+ gfloat lat,lon;
+ gchar *text;
- /* set text only if QTH info is enabled */
- if (satmap->cursinfo) {
+ /* set text only if QTH info is enabled */
+ if (satmap->cursinfo) {
- xy_to_lonlat (satmap, event->x, event->y, &lon, &lat);
+ xy_to_lonlat (satmap, event->x, event->y, &lon, &lat);
- /*** FIXME:
- - Add QRA?
- */
- /* cursor track */
- text = g_strdup_printf ("<span background=\"#%s\"> "\
- "LON:%.0f\302\260 LAT:%.0f\302\260 </span>",
- satmap->infobgd, lon, lat);
+ /*** FIXME:
+ - Add QRA?
+ */
+ /* cursor track */
+ text = g_strdup_printf ("<span background=\"#%s\"> "\
+ "LON:%.0f\302\260 LAT:%.0f\302\260 </span>",
+ satmap->infobgd, lon, lat);
- g_object_set (satmap->curs, "text", text, NULL);
- g_free (text);
- }
+ g_object_set (satmap->curs, "text", text, NULL);
+ g_free (text);
+ }
- return TRUE;
+ return TRUE;
}
@@ -805,22 +805,22 @@
*/
static void
on_item_created (GooCanvas *canvas,
- GooCanvasItem *item,
- GooCanvasItemModel *model,
- gpointer data)
+ GooCanvasItem *item,
+ GooCanvasItemModel *model,
+ gpointer data)
{
- if (!goo_canvas_item_model_get_parent (model)) {
- /* root item / canvas */
- g_signal_connect (item, "motion_notify_event",
- (GtkSignalFunc) on_motion_notify, data);
- }
+ if (!goo_canvas_item_model_get_parent (model)) {
+ /* root item / canvas */
+ g_signal_connect (item, "motion_notify_event",
+ (GtkSignalFunc) on_motion_notify, data);
+ }
- else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection")) {
- g_signal_connect (item, "button_press_event",
- (GtkSignalFunc) on_button_press, data);
- g_signal_connect (item, "button_release_event",
- (GtkSignalFunc) on_button_release, data);
- }
+ else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection")) {
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, data);
+ g_signal_connect (item, "button_release_event",
+ (GtkSignalFunc) on_button_release, data);
+ }
}
@@ -832,42 +832,42 @@
*/
static gboolean
on_button_press (GooCanvasItem *item,
- GooCanvasItem *target,
- GdkEventButton *event,
- gpointer data)
+ GooCanvasItem *target,
+ GdkEventButton *event,
+ gpointer data)
{
- GooCanvasItemModel *model = goo_canvas_item_get_model (item);
- GtkSatMap *satmap = GTK_SAT_MAP (data);
- gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum"));
- gint *catpoint = NULL;
- sat_t *sat = NULL;
+ GooCanvasItemModel *model = goo_canvas_item_get_model (item);
+ GtkSatMap *satmap = GTK_SAT_MAP (data);
+ gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum"));
+ gint *catpoint = NULL;
+ sat_t *sat = NULL;
- switch (event->button) {
+ switch (event->button) {
- /* pop-up menu */
- case 3:
- catpoint = g_try_new0 (gint, 1);
- *catpoint = catnum;
+ /* pop-up menu */
+ case 3:
+ catpoint = g_try_new0 (gint, 1);
+ *catpoint = catnum;
- sat = SAT (g_hash_table_lookup (satmap->sats, catpoint));
+ sat = SAT (g_hash_table_lookup (satmap->sats, catpoint));
- if (sat != NULL) {
- gtk_sat_map_popup_exec (sat, satmap->qth, satmap, event,
- gtk_widget_get_toplevel (GTK_WIDGET (satmap)));
- }
- else {
- /* clicked on map -> map pop-up in the future */
- }
+ if (sat != NULL) {
+ gtk_sat_map_popup_exec (sat, satmap->qth, satmap, event,
+ gtk_widget_get_toplevel (GTK_WIDGET (satmap)));
+ }
+ else {
+ /* clicked on map -> map pop-up in the future */
+ }
- g_free (catpoint);
+ g_free (catpoint);
- break;
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
- return TRUE;
+ return TRUE;
}
@@ -880,76 +880,76 @@
*/
static gboolean
on_button_release (GooCanvasItem *item,
- GooCanvasItem *target,
- GdkEventButton *event,
- gpointer data)
+ GooCanvasItem *target,
+ GdkEventButton *event,
+ gpointer data)
{
- GooCanvasItemModel *model = goo_canvas_item_get_model (item);
- GtkSatMap *satmap = GTK_SAT_MAP (data);
- gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum"));
- gint *catpoint = NULL;
- sat_map_obj_t *obj = NULL;
- guint32 col;
+ GooCanvasItemModel *model = goo_canvas_item_get_model (item);
+ GtkSatMap *satmap = GTK_SAT_MAP (data);
+ gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum"));
+ gint *catpoint = NULL;
+ sat_map_obj_t *obj = NULL;
+ guint32 col;
- catpoint = g_try_new0 (gint, 1);
- *catpoint = catnum;
+ catpoint = g_try_new0 (gint, 1);
+ *catpoint = catnum;
- switch (event->button) {
- /* Select / de-select satellite */
- case 1:
- obj = SAT_MAP_OBJ (g_hash_table_lookup (satmap->obj, catpoint));
- if (obj == NULL) {
- sat_log_log (SAT_LOG_LEVEL_BUG,
- _("%s:%d: Can not find clicked object (%d) in hash table"),
- __FILE__, __LINE__, catnum);
- }
- else {
- obj->selected = !obj->selected;
+ switch (event->button) {
+ /* Select / de-select satellite */
+ case 1:
+ obj = SAT_MAP_OBJ (g_hash_table_lookup (satmap->obj, catpoint));
+ if (obj == NULL) {
+ sat_log_log (SAT_LOG_LEVEL_BUG,
+ _("%s:%d: Can not find clicked object (%d) in hash table"),
+ __FILE__, __LINE__, catnum);
+ }
+ else {
+ obj->selected = !obj->selected;
- if (obj->selected) {
- col = mod_cfg_get_int (satmap->cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_SAT_SEL_COL,
- SAT_CFG_INT_MAP_SAT_SEL_COL);
- }
- else {
- col = mod_cfg_get_int (satmap->cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_SAT_COL,
- SAT_CFG_INT_MAP_SAT_COL);
- *catpoint = 0;
+ if (obj->selected) {
+ col = mod_cfg_get_int (satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SAT_SEL_COL,
+ SAT_CFG_INT_MAP_SAT_SEL_COL);
+ }
+ else {
+ col = mod_cfg_get_int (satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SAT_COL,
+ SAT_CFG_INT_MAP_SAT_COL);
+ *catpoint = 0;
- g_object_set (satmap->sel, "text", "", NULL);
- }
+ g_object_set (satmap->sel, "text", "", NULL);
+ }
- g_object_set (obj->marker,
- "fill-color-rgba", col,
- "stroke-color-rgba", col,
- NULL);
- g_object_set (obj->label,
- "fill-color-rgba", col,
- "stroke-color-rgba", col,
- NULL);
- g_object_set (obj->range1,
- "stroke-color-rgba", col,
- NULL);
+ g_object_set (obj->marker,
+ "fill-color-rgba", col,
+ "stroke-color-rgba", col,
+ NULL);
+ g_object_set (obj->label,
+ "fill-color-rgba", col,
+ "stroke-color-rgba", col,
+ NULL);
+ g_object_set (obj->range1,
+ "stroke-color-rgba", col,
+ NULL);
- if (obj->oldrcnum == 2)
- g_object_set (obj->range2,
- "stroke-color-rgba", col,
- NULL);
+ if (obj->oldrcnum == 2)
+ g_object_set (obj->range2,
+ "stroke-color-rgba", col,
+ NULL);
- /* clear other selections */
- g_hash_table_foreach (satmap->obj, clear_selection, catpoint);
- }
- break;
- default:
- break;
- }
+ /* clear other selections */
+ g_hash_table_foreach (satmap->obj, clear_selection, catpoint);
+ }
+ break;
+ default:
+ break;
+ }
- g_free (catpoint);
-
- return TRUE;
+ g_free (catpoint);
+
+ return TRUE;
}
@@ -961,34 +961,34 @@
static void
clear_selection (gpointer key, gpointer val, gpointer data)
{
- gint *old = key;
- gint *new = data;
- sat_map_obj_t *obj = SAT_MAP_OBJ (val);
- guint32 col;
+ gint *old = key;
+ gint *new = data;
+ sat_map_obj_t *obj = SAT_MAP_OBJ (val);
+ guint32 col;
- if ((*old != *new) && (obj->selected)) {
- obj->selected = FALSE;
+ if ((*old != *new) && (obj->selected)) {
+ obj->selected = FALSE;
- /** FIXME: this is only global default; need the satmap here! */
- col = sat_cfg_get_int (SAT_CFG_INT_MAP_SAT_COL);
+ /** FIXME: this is only global default; need the satmap here! */
+ col = sat_cfg_get_int (SAT_CFG_INT_MAP_SAT_COL);
- g_object_set (obj->marker,
- "fill-color-rgba", col,
- "stroke-color-rgba", col,
- NULL);
- g_object_set (obj->label,
- "fill-color-rgba", col,
- "stroke-color-rgba", col,
- NULL);
- g_object_set (obj->range1,
- "stroke-color-rgba", col,
- NULL);
+ g_object_set (obj->marker,
+ "fill-color-rgba", col,
+ "stroke-color-rgba", col,
+ NULL);
+ g_object_set (obj->label,
+ "fill-color-rgba", col,
+ "stroke-color-rgba", col,
+ NULL);
+ g_object_set (obj->range1,
+ "stroke-color-rgba", col,
+ NULL);
- if (obj->oldrcnum == 2)
- g_object_set (obj->range2,
- "stroke-color-rgba", col,
- NULL);
- }
+ if (obj->oldrcnum == 2)
+ g_object_set (obj->range2,
+ "stroke-color-rgba", col,
+ NULL);
+ }
}
@@ -1024,67 +1024,67 @@
static void
load_map_file (GtkSatMap *satmap)
{
- gchar *buff;
- gchar *mapfile;
- GError *error = NULL;
+ gchar *buff;
+ gchar *mapfile;
+ GError *error = NULL;
- /* get local, global or default map file */
- buff = mod_cfg_get_str (satmap->cfgdata,
- MOD_CFG_MAP_SECTION,
- MOD_CFG_MAP_FILE,
- SAT_CFG_STR_MAP_FILE);
+ /* get local, global or default map file */
+ buff = mod_cfg_get_str (satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_FILE,
+ SAT_CFG_STR_MAP_FILE);
- if (g_path_is_absolute (buff)) {
- /* map is user specific, ie. in $HOME/.gpredict2/maps/ */
- mapfile = g_strdup (buff);
- }
- else {
- /* build complete path */
- mapfile = map_file_name (buff);
- }
- g_free (buff);
+ if (g_path_is_absolute (buff)) {
+ /* map is user specific, ie. in $HOME/.gpredict2/maps/ */
+ mapfile = g_strdup (buff);
+ }
+ else {
+ /* build complete path */
+ mapfile = map_file_name (buff);
+ }
+ g_free (buff);
- sat_log_log (SAT_LOG_LEVEL_DEBUG,
- _("%s:%d: Loading map file %s"),
- __FILE__, __LINE__, mapfile);
+ sat_log_log (SAT_LOG_LEVEL_DEBUG,
+ _("%s:%d: Loading map file %s"),
+ __FILE__, __LINE__, mapfile);
- /* check that file exists, if not get the default */
- if (g_file_test (mapfile, G_FILE_TEST_EXISTS)) {
- sat_log_log (SAT_LOG_LEVEL_DEBUG,
- _("%s:%d: Map file found"),
- __FILE__, __LINE__);
- }
- else {
- sat_log_log (SAT_LOG_LEVEL_ERROR,
- _("%s:%d: Could not find map file %s"),
- __FILE__, __LINE__, mapfile);
+ /* check that file exists, if not get the default */
+ if (g_file_test (mapfile, G_FILE_TEST_EXISTS)) {
+ sat_log_log (SAT_LOG_LEVEL_DEBUG,
+ _("%s:%d: Map file found"),
+ __FILE__, __LINE__);
+ }
+ else {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s:%d: Could not find map file %s"),
+ __FILE__, __LINE__, mapfile);
- /* get default map file */
- g_free (mapfile);
- mapfile = sat_cfg_get_str_def (SAT_CFG_STR_MAP_FILE);
+ /* get default map file */
+ g_free (mapfile);
+ mapfile = sat_cfg_get_str_def (SAT_CFG_STR_MAP_FILE);
- sat_log_log (SAT_LOG_LEVEL_ERROR,
- _("%s:%d: Using default map: %s"),
- __FILE__, __LINE__, mapfile);
- }
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s:%d: Using default map: %s"),
+ __FILE__, __LINE__, mapfile);
+ }
- /* try to load the map file */
- satmap->origmap = gdk_pixbuf_new_from_file (mapfile, &error);
+ /* try to load the map file */
+ satmap->origmap = gdk_pixbuf_new_from_file (mapfile, &error);
- if (error != NULL) {
- sat_log_log (SAT_LOG_LEVEL_ERROR,
- _("%s:%d: Error loading map file (%s)"),
- __FILE__, __LINE__, error->message);
- g_clear_error (&error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s:%d: Error loading map file (%s)"),
+ __FILE__, __LINE__, error->message);
+ g_clear_error (&error);
- /* create a dummy GdkPixbuf to avoid crash */
- satmap->origmap = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- FALSE,
- 8, 400, 200);
- gdk_pixbuf_fill (satmap->origmap, 0x0F0F0F0F);
- }
-
- g_free (mapfile);
+ /* create a dummy GdkPixbuf to avoid crash */
+ satmap->origmap = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ FALSE,
+ 8, 400, 200);
+ gdk_pixbuf_fill (satmap->origmap, 0x0F0F0F0F);
+ }
+
+ g_free (mapfile);
}
@@ -1097,14 +1097,14 @@
static gdouble
arccos (gdouble x, gdouble y)
{
- if (x && y) {
- if (y > 0.0)
- return acos (x/y);
- else if (y < 0.0)
- return pi + acos (x/y);
- }
+ if (x && y) {
+ if (y > 0.0)
+ return acos (x/y);
+ else if (y < 0.0)
+ return pi + acos (x/y);
+ }
- return 0.0;
+ return 0.0;
}
@@ -1112,16 +1112,16 @@
static gboolean
pole_is_covered (sat_t *sat)
{
- int ret1,ret2;
- gdouble qrb1, qrb2, az1, az2;
+ int ret1,ret2;
+ gdouble qrb1, qrb2, az1, az2;
- ret1 = qrb (sat->ssplon, sat->ssplat, 0.0, 90.0, &qrb1, &az1);
- ret2 = qrb (sat->ssplon, sat->ssplat, 0.0, -90.0, &qrb2, &az2);
+ ret1 = qrb (sat->ssplon, sat->ssplat, 0.0, 90.0, &qrb1, &az1);
+ ret2 = qrb (sat->ssplon, sat->ssplat, 0.0, -90.0, &qrb2, &az2);
- if ((qrb1 <= 0.5*sat->footprint) || (qrb2 <= 0.5*sat->footprint))
- return TRUE;
-
- return FALSE;
+ if ((qrb1 <= 0.5*sat->footprint) || (qrb2 <= 0.5*sat->footprint))
+ return TRUE;
+
+ return FALSE;
}
@@ -1129,33 +1129,33 @@
static gboolean
mirror_lon (sat_t *sat, gdouble rangelon, gdouble *mlon)
{
- gdouble diff;
- gboolean warped = FALSE;
+ gdouble diff;
+ gboolean warped = FALSE;
- if (sat->ssplon < 0.0) {
- /* western longitude */
- if (rangelon < 0.0) {
- /* rangelon has not been warped over */
- *mlon = sat->ssplon + fabs (rangelon - sat->ssplon);
- }
- else {
- /* rangelon has been warped over */
- diff = 360.0 + sat->ssplon - rangelon;
- *mlon = sat->ssplon + diff;
- warped = TRUE;
- }
- }
- else {
- /* eastern longitude */
- *mlon = sat->ssplon + fabs (rangelon - sat->ssplon);
-
- if (*mlon > 180.0) {
- *mlon -= 360;
- warped = TRUE;
- }
- }
+ if (sat->ssplon < 0.0) {
+ /* western longitude */
+ if (rangelon < 0.0) {
+ /* rangelon has not been warped over */
+ *mlon = sat->ssplon + fabs (rangelon - sat->ssplon);
+ }
+ else {
+ /* rangelon has been warped over */
+ diff = 360.0 + sat->ssplon - rangelon;
+ *mlon = sat->ssplon + diff;
+ warped = TRUE;
+ }
+ }
+ else {
+ /* eastern longitude */
+ *mlon = sat->ssplon + fabs (rangelon - sat->ssplon);
+
+ if (*mlon > 180.0) {
+ *mlon -= 360;
+ warped = TRUE;
+ }
+ }
- return warped;
+ return warped;
}
@@ -1194,99 +1194,99 @@
static guint
calculate_footprint (GtkSatMap *satmap, sat_t *sat)
{
- guint azi;
- gfloat sx, sy, msx, msy, ssx, ssy;
- gdouble ssplat, ssplon, beta, azimuth, num, dem;
- gdouble rangelon, rangelat, mlon;
- gboolean warped = FALSE;
- guint numrc = 1;
+ guint azi;
+ gfloat sx, sy, msx, msy, ssx, ssy;
+ gdouble ssplat, ssplon, beta, azimuth, num, dem;
+ gdouble rangelon, rangelat, mlon;
+ gboolean warped = FALSE;
+ guint numrc = 1;
- /* Range circle calculations.
- * Borrowed from gsat 0.9.0 by Xavier Crehueras, EB3CZS
- * who borrowed from John Magliacane, KD2BD.
- * Optimized by Alexandru Csete and William J Beksi.
- */
- ssplat = sat->ssplat * de2ra;
- ssplon = sat->ssplon * de2ra;
- beta = (0.5 * sat->footprint) / xkmper;
+ /* Range circle calculations.
+ * Borrowed from gsat 0.9.0 by Xavier Crehueras, EB3CZS
+ * who borrowed from John Magliacane, KD2BD.
+ * Optimized by Alexandru Csete and William J Beksi.
+ */
+ ssplat = sat->ssplat * de2ra;
+ ssplon = sat->ssplon * de2ra;
+ beta = (0.5 * sat->footprint) / xkmper;
- for (azi = 0; azi < 180; azi++) {
- azimuth = de2ra * (double)azi;
- rangelat = asin (sin (ssplat) * cos (beta) + cos (azimuth) *
- sin (beta) * cos (ssplat));
- num = cos (beta) - (sin (ssplat) * sin (rangelat));
- dem = cos (ssplat) * cos (rangelat);
-
- if (azi == 0 && (beta > pio2 - ssplat))
- rangelon = ssplon + pi;
-
- else if (azi == 180 && (beta > pio2 + ssplat))
- rangelon = ssplon + pi;
-
- else if (fabs (num / dem) > 1.0)
- rangelon = ssplon;
-
- else {
- if ((180 - azi) >= 0)
- rangelon = ssplon - arccos (num, dem);
- else
- rangelon = ssplon + arccos (num, dem);
- }
-
- while (rangelon < -pi)
- rangelon += twopi;
-
- while (rangelon > (pi))
- rangelon -= twopi;
-
- rangelat = rangelat / de2ra;
- rangelon = rangelon / de2ra;
+ for (azi = 0; azi < 180; azi++) {
+ azimuth = de2ra * (double)azi;
+ rangelat = asin (sin (ssplat) * cos (beta) + cos (azimuth) *
+ sin (beta) * cos (ssplat));
+ num = cos (beta) - (sin (ssplat) * sin (rangelat));
+ dem = cos (ssplat) * cos (rangelat);
+
+ if (azi == 0 && (beta > pio2 - ssplat))
+ rangelon = ssplon + pi;
+
+ else if (azi == 180 && (beta > pio2 + ssplat))
+ rangelon = ssplon + pi;
+
+ else if (fabs (num / dem) > 1.0)
+ rangelon = ssplon;
+
+ else {
+ if ((180 - azi) >= 0)
+ rangelon = ssplon - arccos (num, dem);
+ else
+ rangelon = ssplon + arccos (num, dem);
+ }
+
+ while (rangelon < -pi)
+ rangelon += twopi;
+
+ while (rangelon > (pi))
+ rangelon -= twopi;
+
+ rangelat = rangelat / de2ra;
+ rangelon = rangelon / de2ra;
- /* mirror longitude */
- if (mirror_lon (sat, rangelon, &mlon))
- warped = TRUE;
+ /* mirror longitude */
+ if (mirror_lon (sat, rangelon, &mlon))
+ warped = TRUE;
- lonlat_to_xy (satmap, rangelon, rangelat, &sx, &sy);
- lonlat_to_xy (satmap, mlon, rangelat, &msx, &msy);
+ lonlat_to_xy (satmap, rangelon, rangelat, &sx, &sy);
+ lonlat_to_xy (satmap, mlon, rangelat, &msx, &msy);
- points1->coords[2*azi] = sx;
- points1->coords[2*azi+1] = sy;
-
- /* Add mirrored point */
- points1->coords[718-2*azi] = msx;
- points1->coords[719-2*azi] = msy;
- }
+ points1->coords[2*azi] = sx;
+ points1->coords[2*azi+1] = sy;
+
+ /* Add mirrored point */
+ points1->coords[718-2*azi] = msx;
+ points1->coords[719-2*azi] = msy;
+ }
- /* points1 ow contains 360 pairs of map-based XY coordinates.
- Check whether actions 1, 2 or 3 have to be performed.
- */
+ /* points1 ow contains 360 pairs of map-based XY coordinates.
+ Check whether actions 1, 2 or 3 have to be performed.
+ */
- /* pole is covered => sort points1 and add additional points */
- if (pole_is_covered (sat)) {
+ /* pole is covered => sort points1 and add additional points */
+ if (pole_is_covered (sat)) {
- sort_points_x (satmap, sat, points1, 360);
- numrc = 1;
+ sort_points_x (satmap, sat, points1, 360);
+ numrc = 1;
- }
+ }
- /* pole not covered but range circle has been warped
- => split points */
- else if (warped == TRUE) {
+ /* pole not covered but range circle has been warped
+ => split points */
+ else if (warped == TRUE) {
- lonlat_to_xy (satmap, sat->ssplon, sat->ssplat, &ssx, &ssy);
- split_points (satmap, sat, ssx);
- numrc = 2;
+ lonlat_to_xy (satmap, sat->ssplon, sat->ssplat, &ssx, &ssy);
+ split_points (satmap, sat, ssx);
+ numrc = 2;
- }
+ }
- /* the nominal condition => points1 is adequate */
- else {
+ /* the nominal condition => points1 is adequate */
+ else {
- numrc = 1;
+ ...
[truncated message content] |