[Gpredict-svn] SF.net SVN: gpredict:[818] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <cs...@us...> - 2011-05-01 11:12:09
|
Revision: 818
http://gpredict.svn.sourceforge.net/gpredict/?rev=818&view=rev
Author: csete
Date: 2011-05-01 11:12:02 +0000 (Sun, 01 May 2011)
Log Message:
-----------
New module menu item to allow selection of a satellite in all views at the same time. Related to feature request 3179102: Right click on satellite to add the track (probably the closest we can get to global selection without breaking the design).
Modified Paths:
--------------
trunk/ChangeLog
trunk/NEWS
trunk/src/gtk-event-list.c
trunk/src/gtk-event-list.h
trunk/src/gtk-polar-view.c
trunk/src/gtk-polar-view.h
trunk/src/gtk-sat-list.c
trunk/src/gtk-sat-list.h
trunk/src/gtk-sat-map.c
trunk/src/gtk-sat-map.h
trunk/src/gtk-sat-module-popup.c
trunk/src/gtk-sat-module.c
trunk/src/gtk-sat-module.h
trunk/src/gtk-single-sat.c
trunk/src/gtk-single-sat.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/ChangeLog 2011-05-01 11:12:02 UTC (rev 818)
@@ -1,3 +1,24 @@
+2011-05-01 Alexandru Csete <oz9aec at gmail.com>
+
+ * src/gtk-sat-module-popup.c
+ * src/gtk-sat-module.c
+ * src/gtk-sat-module.h
+ * src/gtk-sat-list.c
+ * src/gtk-sat-list.h
+ * src/gtk-single-sat.c
+ * src/gtk-single-sat.h
+ * src/gtk-event-list.c
+ * src/gtk-event-list.h
+ * src/gtk-sat-map.c
+ * src/gtk-sat-map.h
+ * src/gtk-polar-view.c
+ * src/gtk-polar-view.h
+ New module menu item to allow selection of a satellite in all views at the
+ same time. Related to feature request 3179102: Right click on satellite to
+ add the track (probably the closest we can get to "global selection" without
+ breaking the design).
+
+
2011-04-29 Alexandru Csete <oz9aec at gmail.com>
* data/desktop/gpredict.desktop.in
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/NEWS 2011-05-01 11:12:02 UTC (rev 818)
@@ -1,5 +1,6 @@
Changes in version 1.4 (TBD)
+- New menu item in the module menu for selecting a satellite in all views.
- Feature request 3141555: gpsd support.
- Feature request 2130926: Change frequency using mouse wheel. Also for rotator controller.
- Applied and extended patch 3237220: natural sort for sat list in module config
Modified: trunk/src/gtk-event-list.c
===================================================================
--- trunk/src/gtk-event-list.c 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-event-list.c 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -844,3 +844,39 @@
{
GTK_EVENT_LIST (evlist)->satellites = sats;
}
+
+
+/** \brief Select satellite. */
+void gtk_event_list_select_sat (GtkWidget *widget, gint catnum)
+{
+ GtkEventList *list;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ gint i,n;
+ gint sat;
+
+
+ list = GTK_EVENT_LIST(widget);
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(list->treeview));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list->treeview));
+
+ /* iterate over the satellite list until a amtch is found */
+ n = g_hash_table_size(list->satellites);
+ for (i = 0; i < n; i++) {
+
+ if (gtk_tree_model_iter_nth_child(model, &iter, NULL, i)) {
+ gtk_tree_model_get(model, &iter, EVENT_LIST_COL_CATNUM, &sat, -1);
+ if (sat == catnum) {
+ gtk_tree_selection_select_iter(selection, &iter);
+ i = n;
+ }
+ }
+ else {
+ sat_log_log(SAT_LOG_LEVEL_ERROR,
+ _("%s: GtkEventList has not child with index %d"),
+ __FUNCTION__, i);
+ }
+ }
+
+}
Modified: trunk/src/gtk-event-list.h
===================================================================
--- trunk/src/gtk-event-list.h 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-event-list.h 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -114,8 +114,8 @@
void gtk_event_list_reconf (GtkWidget *widget, GKeyFile *cfgdat);
void gtk_event_list_reload_sats (GtkWidget *satlist, GHashTable *sats);
+void gtk_event_list_select_sat (GtkWidget *widget, gint catnum);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: trunk/src/gtk-polar-view.c
===================================================================
--- trunk/src/gtk-polar-view.c 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-polar-view.c 2011-05-01 11:12:02 UTC (rev 818)
@@ -1616,7 +1616,54 @@
}
+/** \brief Select a satellite (puublic)
+ *
+ * \todo Current selection is loast when satellite goes LOS
+ */
+void gtk_polar_view_select_sat (GtkWidget *widget, gint catnum)
+{
+ GtkPolarView *polv = GTK_POLAR_VIEW(widget);
+ gint *catpoint = NULL;
+ sat_obj_t *obj = NULL;
+ guint32 color;
+ catpoint = g_try_new0 (gint, 1);
+ *catpoint = catnum;
+
+
+ obj = SAT_OBJ (g_hash_table_lookup (polv->obj, catpoint));
+ if (obj == NULL) {
+ sat_log_log (SAT_LOG_LEVEL_DEBUG,
+ _("%s Requested satellite (%d) is not within range"),
+ __FUNCTION__, catnum);
+ }
+ else {
+ obj->selected = TRUE;
+
+ color = mod_cfg_get_int (polv->cfgdata,
+ MOD_CFG_POLAR_SECTION,
+ MOD_CFG_POLAR_SAT_SEL_COL,
+ SAT_CFG_INT_POLAR_SAT_SEL_COL);
+
+ g_object_set (obj->marker,
+ "fill-color-rgba", color,
+ "stroke-color-rgba", color,
+ NULL);
+ g_object_set (obj->label,
+ "fill-color-rgba", color,
+ "stroke-color-rgba", color,
+ NULL);
+
+ }
+
+ /* clear previous selection, if any */
+ g_hash_table_foreach (polv->obj, clear_selection, catpoint);
+
+ g_free (catpoint);
+
+}
+
+
/** \brief Convert LOS timestamp to human readable countdown string */
static gchar *los_time_to_str (GtkPolarView *polv, sat_t *sat)
{
Modified: trunk/src/gtk-polar-view.h
===================================================================
--- trunk/src/gtk-polar-view.h 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-polar-view.h 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -154,8 +154,8 @@
void xy_to_azel (GtkPolarView *p, gfloat x, gfloat y, gfloat *az, gfloat *el);
void gtk_polar_view_reload_sats (GtkWidget *polv, GHashTable *sats);
+void gtk_polar_view_select_sat (GtkWidget *widget, gint catnum);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: trunk/src/gtk-sat-list.c
===================================================================
--- trunk/src/gtk-sat-list.c 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-sat-list.c 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -1387,3 +1387,38 @@
{
GTK_SAT_LIST (satlist)->satellites = sats;
}
+
+/** \brief Select a satellite */
+void gtk_sat_list_select_sat (GtkWidget *satlist, gint catnum)
+{
+ GtkSatList *slist;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ gint i,n;
+ gint sat;
+
+
+ slist = GTK_SAT_LIST(satlist);
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(slist->treeview));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(slist->treeview));
+
+ /* iterate over the satellite list until a amtch is found */
+ n = g_hash_table_size(slist->satellites);
+ for (i = 0; i < n; i++) {
+
+ if (gtk_tree_model_iter_nth_child(model, &iter, NULL, i)) {
+ gtk_tree_model_get(model, &iter, SAT_LIST_COL_CATNUM, &sat, -1);
+ if (sat == catnum) {
+ gtk_tree_selection_select_iter(selection, &iter);
+ i = n;
+ }
+ }
+ else {
+ sat_log_log(SAT_LOG_LEVEL_ERROR,
+ _("%s: GtkSatList has not child with index %d"),
+ __FUNCTION__, i);
+ }
+ }
+
+}
Modified: trunk/src/gtk-sat-list.h
===================================================================
--- trunk/src/gtk-sat-list.h 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-sat-list.h 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -152,6 +152,7 @@
void gtk_sat_list_reconf (GtkWidget *widget, GKeyFile *cfgdat);
void gtk_sat_list_reload_sats (GtkWidget *satlist, GHashTable *sats);
+void gtk_sat_list_select_sat (GtkWidget *satlist, gint catnum);
#ifdef __cplusplus
Modified: trunk/src/gtk-sat-map.c
===================================================================
--- trunk/src/gtk-sat-map.c 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-sat-map.c 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Copyright (C) 2006-2007 William J Beksi, KC2EXL.
Copyright (C) 2011 Charles Suprin, AA1VS.
@@ -1066,6 +1066,57 @@
}
+/** \brief select a satellite */
+void gtk_sat_map_select_sat (GtkWidget *satmap, gint catnum)
+{
+ GtkSatMap *smap = GTK_SAT_MAP(satmap);
+ gint *catpoint = NULL;
+ sat_map_obj_t *obj = NULL;
+ guint32 col;
+
+
+ catpoint = g_try_new0 (gint, 1);
+ *catpoint = catnum;
+
+ obj = SAT_MAP_OBJ (g_hash_table_lookup (smap->obj, catpoint));
+ if (obj == NULL) {
+ sat_log_log (SAT_LOG_LEVEL_BUG,
+ _("%s: Can not find clicked object (%d) in hash table"),
+ __FUNCTION__, catnum);
+ }
+ else {
+ obj->selected = TRUE;
+
+ col = mod_cfg_get_int (smap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SAT_SEL_COL,
+ SAT_CFG_INT_MAP_SAT_SEL_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);
+
+ if (obj->oldrcnum == 2)
+ g_object_set (obj->range2,
+ "stroke-color-rgba", col,
+ NULL);
+
+ /* clear other selections */
+ g_hash_table_foreach (smap->obj, clear_selection, catpoint);
+ }
+
+ g_free (catpoint);
+
+}
+
/** \brief Reconfigure map.
*
* This function should eventually reload all configuration for the GtkSatMap.
Modified: trunk/src/gtk-sat-map.h
===================================================================
--- trunk/src/gtk-sat-map.h 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-sat-map.h 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Copyright (C) 2006-2007 William J Beksi, KC2EXL.
Authors: Alexandru Csete <oz...@gm...>
@@ -182,6 +182,7 @@
gdouble *x, gdouble *y);
void gtk_sat_map_reload_sats (GtkWidget *satmap, GHashTable *sats);
+void gtk_sat_map_select_sat (GtkWidget *satmap, gint catnum);
#ifdef __cplusplus
}
Modified: trunk/src/gtk-sat-module-popup.c
===================================================================
--- trunk/src/gtk-sat-module-popup.c 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-sat-module-popup.c 2011-05-01 11:12:02 UTC (rev 818)
@@ -53,6 +53,7 @@
static void clone_cb (GtkWidget *menuitem, gpointer data);
static void docking_state_cb (GtkWidget *menuitem, gpointer data);
static void screen_state_cb (GtkWidget *menuitem, gpointer data);
+static void sat_selected_cb (GtkWidget *menuitem, gpointer data);
static void sky_at_glance_cb (GtkWidget *menuitem, gpointer data);
static void tmgr_cb (GtkWidget *menuitem, gpointer data);
static void rigctrl_cb (GtkWidget *menuitem, gpointer data);
@@ -78,10 +79,16 @@
*/
void gtk_sat_module_popup (GtkSatModule *module)
{
- GtkWidget *menu;
- GtkWidget *menuitem;
- GtkWidget *image;
- gchar *buff;
+ GtkWidget *menu; /* The pop-up menu */
+ GtkWidget *satsubmenu; /* Satellite selection submenu */
+ GtkWidget *menuitem; /* Widget used to create the menu items */
+ GtkWidget *image; /* Widget used to create menu item icons */
+
+ /* misc variables */
+ GList *sats;
+ sat_t *sat;
+ gchar *buff;
+ guint i,n;
@@ -143,6 +150,27 @@
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
+ /* select satellite submenu */
+ menuitem = gtk_menu_item_new_with_label(_("Select satellite"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+
+ satsubmenu = gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), satsubmenu);
+
+ sats = g_hash_table_get_values(module->satellites); // FIXME: sort list
+ n = g_list_length(sats);
+ for (i = 0; i < n; i++) {
+ sat = SAT(g_list_nth_data(sats, i));
+ menuitem = gtk_menu_item_new_with_label(sat->nickname);
+ g_object_set_data(G_OBJECT(menuitem), "catnum", GINT_TO_POINTER(sat->tle.catnr));
+ g_signal_connect(menuitem, "activate", G_CALLBACK (sat_selected_cb), module);
+ gtk_menu_shell_append(GTK_MENU_SHELL(satsubmenu), menuitem);
+ }
+
+ /* separator */
+ menuitem = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem);
+
/* sky at a glance */
menuitem = gtk_image_menu_item_new_with_label (_("Sky at a glance"));
buff = icon_file_name ("gpredict-planner-small.png");
@@ -747,6 +775,23 @@
}
+/** \brief New satellite selected.
+ * \param data Pointer to the GtkSatModule widget
+ *
+ * This menu item is activated when a new satellite is selected in the
+ * "Select satellite" submenu of the module pop-up. This will trigger a call
+ * to the select_sat() fuinction of the module, which in turn will call the
+ * select_sat() function of each child view.
+ *
+ * The catalog number of the selected satellite is attached to the menu item
+ */
+static void sat_selected_cb (GtkWidget *menuitem, gpointer data)
+{
+ gint catnum = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menuitem), "catnum"));
+ GtkSatModule *module = GTK_SAT_MODULE(data);
+
+ gtk_sat_module_select_sat(module, catnum);
+}
/** \brief Invoke Sky-at-glance.
*
Modified: trunk/src/gtk-sat-module.c
===================================================================
--- trunk/src/gtk-sat-module.c 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-sat-module.c 2011-05-01 11:12:02 UTC (rev 818)
@@ -1460,6 +1460,42 @@
}
+/** \brief Select a new satellite */
+void gtk_sat_module_select_sat (GtkSatModule *module, gint catnum)
+{
+ GtkWidget *child;
+ gint i;
+
+
+ /* select satellite in each child */
+ for (i = 0; i < module->nviews; i++) {
+
+ child = GTK_WIDGET (g_slist_nth_data (module->views, i));
+
+ if (IS_GTK_SINGLE_SAT (G_OBJECT (child))) {
+ gtk_single_sat_select_sat(child, catnum);
+ }
+ else if (IS_GTK_SAT_MAP (child)) {
+ gtk_sat_map_select_sat(child, catnum);
+ }
+ else if (IS_GTK_SAT_LIST (child)) {
+ gtk_sat_list_select_sat(child, catnum);
+ }
+ else if (IS_GTK_EVENT_LIST (child)) {
+ gtk_event_list_select_sat(child, catnum);
+ }
+ else if (IS_GTK_POLAR_VIEW (child)) {
+ gtk_polar_view_select_sat(child, catnum);
+ }
+ else {
+ sat_log_log(SAT_LOG_LEVEL_BUG, _("%s: Unknown child type"), __FUNCTION__);
+ }
+ }
+
+}
+
+
+
/** \brief Re-configure module.
* \param module The module.
* \param local Flag indicating whether reconfiguration is requested from
Modified: trunk/src/gtk-sat-module.h
===================================================================
--- trunk/src/gtk-sat-module.h 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-sat-module.h 2011-05-01 11:12:02 UTC (rev 818)
@@ -174,6 +174,7 @@
void gtk_sat_module_reload_sats (GtkSatModule *module);
void gtk_sat_module_reconf (GtkSatModule *module, gboolean local);
+void gtk_sat_module_select_sat (GtkSatModule *module, gint catnum);
void gtk_sat_module_fix_size (GtkWidget *module);
Modified: trunk/src/gtk-single-sat.c
===================================================================
--- trunk/src/gtk-single-sat.c 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-single-sat.c 2011-05-01 11:12:02 UTC (rev 818)
@@ -325,11 +325,48 @@
}
+/** \brief Select new satellite */
+void gtk_single_sat_select_sat (GtkWidget *single_sat, gint catnum)
+{
+ GtkSingleSat *ssat = GTK_SINGLE_SAT(single_sat);
+ sat_t *sat = NULL;
+ gchar *title;
+ gboolean foundsat = FALSE;
+ gint i,n;
+
+ /* find satellite with catnum */
+ n = g_slist_length (ssat->sats);
+ for (i = 0; i < n; i++) {
+ sat = SAT(g_slist_nth_data(ssat->sats, i));
+ if (sat->tle.catnr == catnum) {
+ /* found satellite */
+ ssat->selected = i;
+ foundsat = TRUE;
+ /* exit loop */
+ i = n;
+ }
+ }
+
+ if (!foundsat) {
+ sat_log_log(SAT_LOG_LEVEL_ERROR,
+ _("%s: Could not find satellite with catalog number %d"),
+ __FUNCTION__, catnum);
+ return;
+ }
+
+ title = g_strdup_printf ("<b>%s</b>", sat->nickname);
+ gtk_label_set_markup (GTK_LABEL (ssat->header), title);
+ g_free (title);
+
+}
+
+
+
/** \brief Update satellites */
void
gtk_single_sat_update (GtkWidget *widget)
Modified: trunk/src/gtk-single-sat.h
===================================================================
--- trunk/src/gtk-single-sat.h 2011-04-29 18:28:15 UTC (rev 817)
+++ trunk/src/gtk-single-sat.h 2011-05-01 11:12:02 UTC (rev 818)
@@ -2,7 +2,7 @@
/*
Gpredict: Real-time satellite tracking and orbit prediction program
- Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
+ Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC.
Authors: Alexandru Csete <oz...@gm...>
@@ -166,8 +166,8 @@
void gtk_single_sat_reload_sats (GtkWidget *single_sat, GHashTable *sats);
+void gtk_single_sat_select_sat (GtkWidget *single_sat, gint catnum);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|