Skip to content

Commit 7adf91d

Browse files
committed
Show/hide satellite name, marker, and footprint on map
Implements both global and module specific config options to show or hide the satellite names, footprints, and markers on the map view. Partially implements issues #242 and #335.
1 parent 4989e14 commit 7adf91d

6 files changed

Lines changed: 196 additions & 42 deletions

File tree

src/config-keys.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
#define MOD_CFG_MAP_REFRESH "REFRESH"
9494
#define MOD_CFG_MAP_FILE "MAP_FILE" /* abs. path = home dir */
9595
#define MOD_CFG_MAP_FONT "TEXT_FONT"
96+
#define MOD_CFG_MAP_SHOW_SAT_NAME "SAT_MAME"
97+
#define MOD_CFG_MAP_SHOW_SAT_FP "SAT_FOOTPRINT"
98+
#define MOD_CFG_MAP_SHOW_SAT_MARKER "SAT_MARKER"
9699
#define MOD_CFG_MAP_SHOW_QTH_INFO "QTH_INFO"
97100
#define MOD_CFG_MAP_SHOW_NEXT_EVENT "NEXT_EVENT"
98101
#define MOD_CFG_MAP_SHOW_CURS_TRACK "CURSOR_TRACK"
@@ -113,7 +116,7 @@
113116
#define MOD_CFG_MAP_KEEP_RATIO "KEEP_RATIO"
114117
#define MOD_CFG_MAP_SHADOW_ALPHA "SHADOW_ALPHA"
115118
#define MOD_CFG_MAP_SHOWTRACKS "SHOWTRACKS"
116-
#define MOD_CFG_MAP_HIDECOVS "HIDECOVS"
119+
#define MOD_CFG_MAP_HIDECOVS "HIDECOVS" // FIXME: redundant
117120

118121
/* polar view specific */
119122
#define MOD_CFG_POLAR_SECTION "POLAR"

src/gtk-sat-map.c

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
#define TERMINATOR_UPDATE_INTERVAL (15.0/86400.0)
5353

5454
static void gtk_sat_map_class_init(GtkSatMapClass * class,
55-
gpointer class_data);
55+
gpointer class_data);
5656
static void gtk_sat_map_init(GtkSatMap * polview,
57-
gpointer g_class);
57+
gpointer g_class);
5858
static void gtk_sat_map_destroy(GtkWidget * widget);
5959
static void size_allocate_cb(GtkWidget * widget,
6060
GtkAllocation * allocation, gpointer data);
@@ -142,7 +142,7 @@ GType gtk_sat_map_get_type()
142142
}
143143

144144
static void gtk_sat_map_class_init(GtkSatMapClass * class,
145-
gpointer class_data)
145+
gpointer class_data)
146146
{
147147
GtkWidgetClass *widget_class;
148148

@@ -154,7 +154,7 @@ static void gtk_sat_map_class_init(GtkSatMapClass * class,
154154
}
155155

156156
static void gtk_sat_map_init(GtkSatMap * satmap,
157-
gpointer g_class)
157+
gpointer g_class)
158158
{
159159
(void)g_class;
160160

@@ -174,6 +174,9 @@ static void gtk_sat_map_init(GtkSatMap * satmap,
174174
satmap->height = 0;
175175
satmap->refresh = 0;
176176
satmap->counter = 0;
177+
satmap->satname = FALSE;
178+
satmap->satfp = FALSE;
179+
satmap->satmarker = FALSE;
177180
satmap->show_terminator = FALSE;
178181
satmap->qthinfo = FALSE;
179182
satmap->eventinfo = FALSE;
@@ -301,6 +304,19 @@ GtkWidget *gtk_sat_map_new(GKeyFile * cfgdata, GHashTable * sats,
301304
SAT_CFG_INT_MAP_REFRESH);
302305
satmap->counter = 1;
303306

307+
satmap->satname = mod_cfg_get_bool(cfgdata,
308+
MOD_CFG_MAP_SECTION,
309+
MOD_CFG_MAP_SHOW_SAT_NAME,
310+
SAT_CFG_BOOL_MAP_SHOW_SAT_NAME);
311+
satmap->satfp = mod_cfg_get_bool(cfgdata,
312+
MOD_CFG_MAP_SECTION,
313+
MOD_CFG_MAP_SHOW_SAT_FP,
314+
SAT_CFG_BOOL_MAP_SHOW_SAT_FP);
315+
satmap->satmarker = mod_cfg_get_bool(cfgdata,
316+
MOD_CFG_MAP_SECTION,
317+
MOD_CFG_MAP_SHOW_SAT_MARKER,
318+
SAT_CFG_BOOL_MAP_SHOW_SAT_MARKER);
319+
304320
satmap->qthinfo = mod_cfg_get_bool(cfgdata,
305321
MOD_CFG_MAP_SECTION,
306322
MOD_CFG_MAP_SHOW_QTH_INFO,
@@ -984,6 +1000,9 @@ static gboolean on_button_release(GooCanvasItem * item,
9841000

9851001
/* clear other selections */
9861002
g_hash_table_foreach(satmap->obj, clear_selection, catpoint);
1003+
1004+
/* update all satellites to update marker visibilities */
1005+
g_hash_table_foreach(satmap->sats, update_sat, satmap);
9871006
}
9881007
break;
9891008
default:
@@ -1009,12 +1028,9 @@ static void clear_selection(gpointer key, gpointer val, gpointer data)
10091028
/** FIXME: this is only global default; need the satmap here! */
10101029
col = sat_cfg_get_int(SAT_CFG_INT_MAP_SAT_COL);
10111030

1012-
g_object_set(obj->marker,
1013-
"fill-color-rgba", col, "stroke-color-rgba", col, NULL);
1014-
g_object_set(obj->label,
1015-
"fill-color-rgba", col, "stroke-color-rgba", col, NULL);
1031+
g_object_set(obj->marker, "fill-color-rgba", col, "stroke-color-rgba", col, NULL);
1032+
g_object_set(obj->label, "fill-color-rgba", col, "stroke-color-rgba", col, NULL);
10161033
g_object_set(obj->range1, "stroke-color-rgba", col, NULL);
1017-
10181034
if (obj->oldrcnum == 2)
10191035
g_object_set(obj->range2, "stroke-color-rgba", col, NULL);
10201036
}
@@ -1057,6 +1073,9 @@ void gtk_sat_map_select_sat(GtkWidget * satmap, gint catnum)
10571073

10581074
/* clear other selections */
10591075
g_hash_table_foreach(smap->obj, clear_selection, catpoint);
1076+
1077+
/* update all satellites to update marker visibilities */
1078+
g_hash_table_foreach(smap->sats, update_sat, smap);
10601079
}
10611080

10621081
g_free(catpoint);
@@ -1978,6 +1997,24 @@ static void plot_sat(gpointer key, gpointer value, gpointer data)
19781997

19791998
/* add sat to hash table */
19801999
g_hash_table_insert(satmap->obj, catnum, obj);
2000+
2001+
/* hide objects if so configured */
2002+
if (!satmap->satname)
2003+
{
2004+
g_object_set(obj->label, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
2005+
g_object_set(obj->shadowl, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
2006+
}
2007+
if (!satmap->satfp)
2008+
{
2009+
g_object_set(obj->range1, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
2010+
if (obj->newrcnum == 2)
2011+
g_object_set(obj->range2, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
2012+
}
2013+
if (!satmap->satmarker)
2014+
{
2015+
g_object_set(obj->marker, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
2016+
g_object_set(obj->shadowm, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
2017+
}
19812018
}
19822019

19832020
/**
@@ -2215,17 +2252,10 @@ static void update_sat(gpointer key, gpointer value, gpointer data)
22152252
SAT_CFG_INT_MAP_SAT_COL);
22162253
}
22172254
/* coverage color */
2218-
if (obj->showcov)
2219-
{
2220-
covcol = mod_cfg_get_int(satmap->cfgdata,
2221-
MOD_CFG_MAP_SECTION,
2222-
MOD_CFG_MAP_SAT_COV_COL,
2223-
SAT_CFG_INT_MAP_SAT_COV_COL);
2224-
}
2225-
else
2226-
{
2227-
covcol = 0x00000000;
2228-
}
2255+
covcol = mod_cfg_get_int(satmap->cfgdata,
2256+
MOD_CFG_MAP_SECTION,
2257+
MOD_CFG_MAP_SAT_COV_COL,
2258+
SAT_CFG_INT_MAP_SAT_COV_COL);
22292259
obj->range2 = goo_canvas_polyline_model_new(root, FALSE, 0,
22302260
"points", points2,
22312261
"line-width", 1.0,
@@ -2239,6 +2269,10 @@ static void update_sat(gpointer key, gpointer value, gpointer data)
22392269
NULL);
22402270
g_object_set_data(G_OBJECT(obj->range2), "catnum",
22412271
GINT_TO_POINTER(*catnum));
2272+
2273+
if (!satmap->satfp && !obj->selected)
2274+
g_object_set(obj->range2, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
2275+
22422276
}
22432277
else
22442278
{
@@ -2282,6 +2316,20 @@ static void update_sat(gpointer key, gpointer value, gpointer data)
22822316
}
22832317
}
22842318

2319+
/* update marker visibilities */
2320+
gboolean vis = satmap->satname || obj->selected;
2321+
g_object_set(obj->label, "visibility", vis ? GOO_CANVAS_ITEM_VISIBLE : GOO_CANVAS_ITEM_INVISIBLE, NULL);
2322+
g_object_set(obj->shadowl, "visibility", vis ? GOO_CANVAS_ITEM_VISIBLE : GOO_CANVAS_ITEM_INVISIBLE, NULL);
2323+
2324+
vis = satmap->satfp || obj->selected;
2325+
g_object_set(obj->range1, "visibility", vis ? GOO_CANVAS_ITEM_VISIBLE : GOO_CANVAS_ITEM_INVISIBLE, NULL);
2326+
if (obj->newrcnum == 2)
2327+
g_object_set(obj->range2, "visibility", vis ? GOO_CANVAS_ITEM_VISIBLE : GOO_CANVAS_ITEM_INVISIBLE, NULL);
2328+
2329+
vis = satmap->satmarker || obj->selected;
2330+
g_object_set(obj->marker, "visibility", vis ? GOO_CANVAS_ITEM_VISIBLE : GOO_CANVAS_ITEM_INVISIBLE, NULL);
2331+
g_object_set(obj->shadowm, "visibility", vis ? GOO_CANVAS_ITEM_VISIBLE : GOO_CANVAS_ITEM_INVISIBLE, NULL);
2332+
22852333
g_free(catnum);
22862334
}
22872335

src/gtk-sat-map.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ typedef struct {
5151
/* flags */
5252
gboolean selected; /*!< Is satellite selected? */
5353
gboolean showtrack; /*!< Show ground track */
54-
gboolean showcov; /*!< Show coverage area. */
54+
gboolean showcov; /*!< Show coverage area. FIXME: redundant*/
5555
gboolean istarget; /*!< is this object the target */
5656

5757
/* graphical elements */
@@ -122,6 +122,9 @@ typedef struct {
122122
guint refresh; /*!< Refresh rate. */
123123
guint counter; /*!< Cycle counter. */
124124

125+
gboolean satname; /*!< Show the satellite name. */
126+
gboolean satfp; /*!< Show the satellite footprint. */
127+
gboolean satmarker; /*!< Show the satellite marker. */
125128
gboolean show_terminator; /*!< show solar terminator. */
126129
gboolean qthinfo; /*!< Show the QTH info. */
127130
gboolean eventinfo; /*!< Show info about the next event. */

src/sat-cfg.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ sat_cfg_bool_t sat_cfg_bool[SAT_CFG_BOOL_NUM] = {
118118
{"GLOBAL", "MOD_WIN_POS", FALSE},
119119
{"GLOBAL", "MOD_STATE", FALSE},
120120
{"MODULES", "RULES_HINT", FALSE},
121+
{"MODULES", "MAP_SAT_NAME", TRUE},
122+
{"MODULES", "MAP_SAT_FOTPRINT", TRUE},
123+
{"MODULES", "MAP_SAT_MARKER", TRUE},
121124
{"MODULES", "MAP_QTH_INFO", TRUE},
122125
{"MODULES", "MAP_NEXT_EVENT", TRUE},
123126
{"MODULES", "MAP_CURSOR_TRACK", FALSE},

src/sat-cfg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ typedef enum {
3838
SAT_CFG_BOOL_MOD_WIN_POS, /*!< Restore size and position of module windows */
3939
SAT_CFG_BOOL_MOD_STATE, /*!< Restore module state */
4040
SAT_CFG_BOOL_RULES_HINT_OBSOLETE, /*!< Enable rules hint in GtkSatList. */
41+
SAT_CFG_BOOL_MAP_SHOW_SAT_NAME, /*!< Show satellite name on map. */
42+
SAT_CFG_BOOL_MAP_SHOW_SAT_FP, /*!< Show satellite footprint on map. */
43+
SAT_CFG_BOOL_MAP_SHOW_SAT_MARKER, /*!< Show satellite marker on map. */
4144
SAT_CFG_BOOL_MAP_SHOW_QTH_INFO, /*!< Show QTH info on map */
4245
SAT_CFG_BOOL_MAP_SHOW_NEXT_EV, /*!< Show next event on map */
4346
SAT_CFG_BOOL_MAP_SHOW_CURS_TRACK, /*!< Track mouse cursor on map. */

0 commit comments

Comments
 (0)