[Gpredict-svn] SF.net SVN: gpredict:[881] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <aa...@us...> - 2011-08-05 00:47:05
|
Revision: 881
http://gpredict.svn.sourceforge.net/gpredict/?rev=881&view=rev
Author: aa1vs
Date: 2011-08-05 00:46:59 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Remember ground tracks and highlight coverages in map view.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/config-keys.h
trunk/src/gtk-sat-map-popup.c
trunk/src/gtk-sat-map.c
trunk/src/gtk-sat-map.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-07-31 12:26:07 UTC (rev 880)
+++ trunk/ChangeLog 2011-08-05 00:46:59 UTC (rev 881)
@@ -1,3 +1,13 @@
+2011-08-04 Charles Suprin <hamaa1vs at gmail.com>
+
+ * ChangeLog
+ * src/gtk-sat-map.c
+ * src/gtk-sat-map.h
+ * src/gtk-sat-map-popup.c
+ * src/config-keys.h
+ Remember ground tracks and highlight coverages in map view.
+ Feature Request: 3179738
+
2011-07-31 Charles Suprin <hamaa1vs at gmail.com>
* src/gtk-rot-knob.c
Modified: trunk/src/config-keys.h
===================================================================
--- trunk/src/config-keys.h 2011-07-31 12:26:07 UTC (rev 880)
+++ trunk/src/config-keys.h 2011-08-05 00:46:59 UTC (rev 881)
@@ -106,6 +106,8 @@
#define MOD_CFG_MAP_TRACK_NUM "TRACK_NUMBER"
#define MOD_CFG_MAP_KEEP_RATIO "KEEP_RATIO"
#define MOD_CFG_MAP_SHADOW_ALPHA "SHADOW_ALPHA"
+#define MOD_CFG_MAP_SHOWTRACKS "SHOWTRACKS"
+#define MOD_CFG_MAP_HIDECOVS "HIDECOVS"
/* polar view specific */
#define MOD_CFG_POLAR_SECTION "POLAR"
Modified: trunk/src/gtk-sat-map-popup.c
===================================================================
--- trunk/src/gtk-sat-map-popup.c 2011-07-31 12:26:07 UTC (rev 880)
+++ trunk/src/gtk-sat-map-popup.c 2011-08-05 00:46:59 UTC (rev 881)
@@ -183,12 +183,14 @@
coverage_toggled (GtkCheckMenuItem *item, gpointer data)
{
sat_map_obj_t *obj = NULL;
+ sat_t *sat;
GtkSatMap *satmap = GTK_SAT_MAP(data);
guint32 covcol;
-
+
/* get satellite object */
obj = SAT_MAP_OBJ(g_object_get_data (G_OBJECT (item), "obj"));
+ sat = SAT(g_object_get_data (G_OBJECT (item), "sat"));
if (obj == NULL) {
sat_log_log (SAT_LOG_LEVEL_BUG,
@@ -201,6 +203,17 @@
obj->showcov = !obj->showcov;
gtk_check_menu_item_set_active (item, obj->showcov);
+ if (obj->showcov) {
+ /* remove it from the storage structure */
+ g_hash_table_remove (satmap->hidecovs,
+ &(sat->tle.catnr));
+
+ } else {
+ g_hash_table_insert (satmap->hidecovs,
+ &(sat->tle.catnr),
+ (gpointer)0x1);
+ }
+
/* set or clear coverage colour */
if (obj->showcov) {
covcol = mod_cfg_get_int (satmap->cfgdata,
@@ -257,11 +270,20 @@
if (obj->showtrack) {
/* create ground track */
ground_track_create (satmap, sat, qth, obj);
+
+ /* add it to the storage structure */
+ g_hash_table_insert (satmap->showtracks,
+ &(sat->tle.catnr),
+ (gpointer)0x1);
}
else {
/* delete ground track with clear_ssp = TRUE */
ground_track_delete (satmap, sat, qth, obj, TRUE);
+
+ /* remove it from the storage structure */
+ g_hash_table_remove (satmap->showtracks,
+ &(sat->tle.catnr));
}
}
Modified: trunk/src/gtk-sat-map.c
===================================================================
--- trunk/src/gtk-sat-map.c 2011-07-31 12:26:07 UTC (rev 880)
+++ trunk/src/gtk-sat-map.c 2011-08-05 00:46:59 UTC (rev 881)
@@ -107,6 +107,10 @@
static void draw_grid_lines (GtkSatMap *satmap, GooCanvasItemModel *root);
static void redraw_grid_lines (GtkSatMap *satmap);
static gchar *aoslos_time_to_str (GtkSatMap *satmap, sat_t *sat);
+static void gtk_sat_map_load_showtracks (GtkSatMap *map);
+static void gtk_sat_map_load_hide_coverages (GtkSatMap *map);
+static void load_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest);
+static void store_binary_hash_cfgdata (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey);
static GtkVBoxClass *parent_class = NULL;
static GooCanvasPoints *points1;
@@ -171,6 +175,8 @@
satmap->sats = NULL;
satmap->qth = NULL;
satmap->obj = NULL;
+ satmap->showtracks= g_hash_table_new_full(g_int_hash,g_int_equal,NULL,NULL);
+ satmap->hidecovs = g_hash_table_new_full(g_int_hash,g_int_equal,NULL,NULL);
satmap->naos = 0.0;
satmap->ncat = 0;
satmap->tstamp = 2458849.5;
@@ -193,6 +199,18 @@
static void
gtk_sat_map_destroy (GtkObject *object)
{
+ gint *showtrack;
+ gint *something;
+ gint i,length;
+ store_binary_hash_cfgdata(GTK_SAT_MAP(object)->cfgdata,
+ GTK_SAT_MAP(object)->showtracks,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SHOWTRACKS);
+ store_binary_hash_cfgdata(GTK_SAT_MAP(object)->cfgdata,
+ GTK_SAT_MAP(object)->hidecovs,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_HIDECOVS);
+
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -293,6 +311,11 @@
g_object_unref (root);
+ /* load the satellites we want to show tracks for */
+ gtk_sat_map_load_showtracks (GTK_SAT_MAP(satmap));
+ /* load the satellites we want to show tracks for */
+ gtk_sat_map_load_hide_coverages (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));
@@ -1805,8 +1828,18 @@
}
obj->selected = FALSE;
- obj->showtrack = FALSE;
- obj->showcov = TRUE;
+
+ if (g_hash_table_lookup(satmap->showtracks,catnum)==NULL) {
+ obj->showtrack = FALSE;
+ } else {
+ obj->showtrack = TRUE;
+ }
+
+ if (g_hash_table_lookup(satmap->hidecovs,catnum)==NULL) {
+ obj->showcov = TRUE;
+ } else {
+ obj->showcov = FALSE;
+ }
obj->istarget = FALSE;
obj->oldrcnum = 0;
obj->newrcnum = 0;
@@ -1827,7 +1860,18 @@
MOD_CFG_MAP_SECTION,
MOD_CFG_MAP_SAT_COV_COL,
SAT_CFG_INT_MAP_SAT_COV_COL);
+ /* coverage color */
+ if (obj->showcov) {
+ covcol = mod_cfg_get_int (satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SAT_COV_COL,
+ SAT_CFG_INT_MAP_SAT_COV_COL);
+ }
+ else {
+ covcol = 0x00000000;
+ }
+
/* shadow colour (only alpha channel) */
shadowcol = mod_cfg_get_int (satmap->cfgdata,
MOD_CFG_MAP_SECTION,
@@ -2551,3 +2595,100 @@
return text;
}
+
+/** \brief Load the satellites that we should show tracks for */
+static void
+gtk_sat_map_load_showtracks (GtkSatMap *satmap)
+{
+ load_integer_list_boolean(satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_SHOWTRACKS,
+ satmap->showtracks);
+}
+
+/** \brief Load the satellites that we should not highlight coverage */
+static void
+gtk_sat_map_load_hide_coverages (GtkSatMap *satmap)
+{
+ load_integer_list_boolean(satmap->cfgdata,
+ MOD_CFG_MAP_SECTION,
+ MOD_CFG_MAP_HIDECOVS,
+ satmap->hidecovs);
+}
+
+/** \brief Load an integer list into a hash table that uses the
+ data in the hash as a boolean
+*/
+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 (dest, tkey) == NULL) {
+ /* just add a one to the value so there is presence indicator */
+ g_hash_table_insert (dest,
+ tkey,
+ (gpointer)0x1);
+ }
+ }
+ g_free(sats);
+}
+
+/** \brief Convert the "boolean" hash back into an integer list and save it. */
+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);
+ }
+}
Modified: trunk/src/gtk-sat-map.h
===================================================================
--- trunk/src/gtk-sat-map.h 2011-07-31 12:26:07 UTC (rev 880)
+++ trunk/src/gtk-sat-map.h 2011-08-05 00:46:59 UTC (rev 881)
@@ -140,6 +140,8 @@
qth_t *qth; /*!< Pointer to current location. */
GHashTable *obj; /*!< Canvas items representing each satellite. */
+ GHashTable *showtracks; /*!< A hash of satellites to show tracks for. */
+ GHashTable *hidecovs; /*!< A hash of satellites to hide coverage for. */
guint x0; /*!< X0 of the canvas map. */
guint y0; /*!< Y0 of the canvas map. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|