[Gpredict-svn] SF.net SVN: gpredict:[903] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <aa...@us...> - 2011-09-23 00:13:14
|
Revision: 903
http://gpredict.svn.sourceforge.net/gpredict/?rev=903&view=rev
Author: aa1vs
Date: 2011-09-23 00:13:07 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Saves polarview showtrack information from one session to another.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/gtk-polar-view-popup.c
trunk/src/gtk-polar-view.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-09-21 20:25:08 UTC (rev 902)
+++ trunk/ChangeLog 2011-09-23 00:13:07 UTC (rev 903)
@@ -1,3 +1,11 @@
+2011-09-22 Charles Suprin <hamaa1vs at gmail.com>
+
+ * ChangeLog
+ * src/gtk-polar-view.c
+ * src/gtk-polar-view-popup.c
+ Saves polarview showtrack information from one session to another.
+
+
2011-09-21 Charles Suprin <hamaa1vs at gmail.com>
* ChangeLog
Modified: trunk/src/gtk-polar-view-popup.c
===================================================================
--- trunk/src/gtk-polar-view-popup.c 2011-09-21 20:25:08 UTC (rev 902)
+++ trunk/src/gtk-polar-view-popup.c 2011-09-23 00:13:07 UTC (rev 903)
@@ -208,7 +208,16 @@
if (obj->showtrack) {
/* add sky track */
+
+ /* add it to the storage structure */
+ g_hash_table_insert (pv->showtracks_on,
+ &(sat->tle.catnr),
+ NULL);
+ /* remove it from the don't show */
+ g_hash_table_remove (pv->showtracks_off,
+ &(sat->tle.catnr));
+
/* create points */
num = g_slist_length (obj->pass->details);
if (num == 0) {
@@ -273,6 +282,13 @@
}
else {
+ /* add it to the hide */
+ g_hash_table_insert (pv->showtracks_off,
+ &(sat->tle.catnr),
+ NULL);
+ /* remove it from the show */
+ g_hash_table_remove (pv->showtracks_on,
+ &(sat->tle.catnr));
/* delete sky track */
idx = goo_canvas_item_model_find_child (root, obj->track);
Modified: trunk/src/gtk-polar-view.c
===================================================================
--- trunk/src/gtk-polar-view.c 2011-09-21 20:25:08 UTC (rev 902)
+++ trunk/src/gtk-polar-view.c 2011-09-23 00:13:07 UTC (rev 903)
@@ -92,8 +92,11 @@
static GooCanvasItemModel* create_canvas_model (GtkPolarView *polv);
static void get_canvas_bg_color (GtkPolarView *polv, GdkColor *color);
static gchar *los_time_to_str (GtkPolarView *polv, sat_t *sat);
+static void gtk_polar_view_store_showtracks (GtkPolarView *pv);
+static void gtk_polar_view_load_showtracks (GtkPolarView *pv);
+static void store_binary_hash_cfgdata (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey) ;
+static void load_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest);
-
static GtkVBoxClass *parent_class = NULL;
@@ -172,6 +175,7 @@
static void
gtk_polar_view_destroy (GtkObject *object)
{
+ gtk_polar_view_store_showtracks ( GTK_POLAR_VIEW(object));
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -249,6 +253,7 @@
MOD_CFG_POLAR_SECTION,
MOD_CFG_POLAR_SHOW_EXTRA_AZ_TICKS,
SAT_CFG_BOOL_POL_SHOW_EXTRA_AZ_TICKS);
+ gtk_polar_view_load_showtracks (GTK_POLAR_VIEW(polv));
/* create the canvas */
GTK_POLAR_VIEW (polv)->canvas = goo_canvas_new ();
@@ -1002,9 +1007,19 @@
NULL);
g_free (tooltip);
+ if (goo_canvas_item_model_find_child(root, obj->marker) != -1)
+ goo_canvas_item_model_raise (obj->marker, NULL);
+ else
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: marker added to polarview not showing %d."),
+ __FUNCTION__, *catnum);
- goo_canvas_item_model_raise (obj->marker, NULL);
- goo_canvas_item_model_raise (obj->label, NULL);
+ if (goo_canvas_item_model_find_child(root, obj->label) != -1)
+ goo_canvas_item_model_raise (obj->label, NULL);
+ else
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: label added to polarview not showing %d."),
+ __FUNCTION__, *catnum);
g_object_set_data (G_OBJECT (obj->marker), "catnum", GINT_TO_POINTER(*catnum));
g_object_set_data (G_OBJECT (obj->label), "catnum", GINT_TO_POINTER(*catnum));
@@ -1745,3 +1760,112 @@
return text;
}
+
+static void
+gtk_polar_view_store_showtracks (GtkPolarView *pv) {
+ store_binary_hash_cfgdata(pv->cfgdata,
+ pv->showtracks_on,
+ MOD_CFG_POLAR_SECTION,
+ MOD_CFG_POLAR_SHOWTRACKS);
+ store_binary_hash_cfgdata(pv->cfgdata,
+ pv->showtracks_off,
+ MOD_CFG_POLAR_SECTION,
+ MOD_CFG_POLAR_HIDETRACKS);
+}
+
+/** \brief Load the satellites that we should not highlight coverage */
+static void
+gtk_polar_view_load_showtracks (GtkPolarView *pv)
+{
+ load_integer_list_boolean(pv->cfgdata,
+ MOD_CFG_POLAR_SECTION,
+ MOD_CFG_POLAR_HIDETRACKS,
+ pv->showtracks_off);
+
+ load_integer_list_boolean(pv->cfgdata,
+ MOD_CFG_POLAR_SECTION,
+ MOD_CFG_POLAR_SHOWTRACKS,
+ pv->showtracks_on);
+
+}
+
+/** \brief Load an integer list into a hash table that uses the
+ existinence of datain the hash as a boolean.
+ It loads NULL's into the hash table.
+*/
+static void load_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest) {
+ gint *sats = NULL;
+ gsize length;
+ GError *error = NULL;
+ guint i;
+ guint *tkey;
+
+ sats = g_key_file_get_integer_list (cfgdata,
+ section,
+ key,
+ &length,
+ &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Failed to get list of satellites (%s)"),
+ __FUNCTION__, error->message);
+
+ g_clear_error (&error);
+
+ /* GLib API says nothing about the contents in case of error */
+ if (sats) {
+ g_free (sats);
+ }
+
+ return;
+ }
+
+ /* read each satellite into hash table */
+ for (i = 0; i < length; i++) {
+ tkey = g_new0 (guint, 1);
+ *tkey = sats[i];
+ //printf("loading sat %d\n",sats[i]);
+ if (!(g_hash_table_lookup_extended (dest, tkey, NULL, NULL))) {
+ /* just add a one to the value so there is presence indicator */
+ g_hash_table_insert (dest,
+ tkey,
+ NULL);
+ }
+ }
+ g_free(sats);
+}
+
+/** \brief Convert the "boolean" hash back into an integer list and
+ save it to the cfgdata. */
+static void
+store_binary_hash_cfgdata (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey)
+{
+ gint *showtrack;
+ gint *something;
+ gint i,length;
+ GList *keys = g_hash_table_get_keys(hash);
+
+ length = g_list_length(keys);
+ if (g_list_length(keys)>0) {
+
+ showtrack = g_try_new0(gint,g_list_length(keys));
+ for (i=0;i<length;i++) {
+ something=g_list_nth_data(keys,i);
+ showtrack[i]=*something;
+ }
+ g_key_file_set_integer_list (cfgdata,
+ cfgsection,
+ cfgkey,
+ showtrack,
+ g_list_length(keys)
+ );
+
+ } else {
+ g_key_file_remove_key(cfgdata,
+ cfgsection,
+ cfgkey,
+ NULL);
+ }
+
+ g_list_free (keys);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|