[Gpredict-svn] SF.net SVN: gpredict:[645] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <cs...@us...> - 2010-07-12 19:46:54
|
Revision: 645
http://gpredict.svn.sourceforge.net/gpredict/?rev=645&view=rev
Author: csete
Date: 2010-07-12 19:46:48 +0000 (Mon, 12 Jul 2010)
Log Message:
-----------
Added satellite tooltips in polar view showing current Az, El and time to LOS.
Modified Paths:
--------------
trunk/ChangeLog
trunk/NEWS
trunk/src/gtk-polar-view.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-07-12 14:32:25 UTC (rev 644)
+++ trunk/ChangeLog 2010-07-12 19:46:48 UTC (rev 645)
@@ -18,7 +18,10 @@
* src/sat-cfg.c:
Changed default value of SKY_AT_GLANCE/COLOUR_07 to be darker.
+ * src/gtk-polar-view.c:
+ Added satellite tooltips showing current Az, El and time to LOS.
+
2010-07-11 Alexandru Csete <oz9aec at gmail.com>
* data/satdata:
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2010-07-12 14:32:25 UTC (rev 644)
+++ trunk/NEWS 2010-07-12 19:46:48 UTC (rev 645)
@@ -6,6 +6,7 @@
Closes feature request 2821408.
- Sky at a glance is now more interactive. Show pass summary when mouse hovers over pass and
click on pass shows the details.
+- Added satellite tooltips in polar view showing current Az, El and time to LOS.
* Feature request 2866570: Set operating mode via CAT.
* Feature request 2873824: Flip Passes.
* Feature request 2778735: Visual indicator for RX/TX/TRX.
Modified: trunk/src/gtk-polar-view.c
===================================================================
--- trunk/src/gtk-polar-view.c 2010-07-12 14:32:25 UTC (rev 644)
+++ trunk/src/gtk-polar-view.c 2010-07-12 19:46:48 UTC (rev 645)
@@ -88,6 +88,7 @@
static void clear_selection (gpointer key, gpointer val, gpointer data);
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 GtkVBoxClass *parent_class = NULL;
@@ -237,12 +238,13 @@
/* create the canvas */
GTK_POLAR_VIEW (polv)->canvas = goo_canvas_new ();
+ g_object_set (G_OBJECT (GTK_POLAR_VIEW (polv)->canvas), "has-tooltip", TRUE, NULL);
get_canvas_bg_color (GTK_POLAR_VIEW (polv), &bg_color);
gtk_widget_modify_base (GTK_POLAR_VIEW (polv)->canvas, GTK_STATE_NORMAL, &bg_color);
gtk_widget_set_size_request (GTK_POLAR_VIEW (polv)->canvas,
POLV_DEFAULT_SIZE, POLV_DEFAULT_SIZE);
goo_canvas_set_bounds (GOO_CANVAS (GTK_POLAR_VIEW (polv)->canvas), 0, 0,
- POLV_DEFAULT_SIZE, POLV_DEFAULT_SIZE);
+ POLV_DEFAULT_SIZE, POLV_DEFAULT_SIZE);
/* connect size-request signal */
@@ -792,6 +794,8 @@
gint idx,i;
gdouble now;// = get_current_daynum ();
gchar *text;
+ gchar *losstr;
+ gchar *tooltip;
guint32 colour;
@@ -870,78 +874,48 @@
/* if sat is already on canvas */
if (obj != NULL) {
- /* update sat */
+
+ /* update LOS count down */
+ if (sat->los > 0.0) {
+ losstr = los_time_to_str(polv, sat);
+ }
+ else {
+ losstr = g_strdup_printf (_("%s\nAlways in range"), sat->nickname);
+ }
+
+ /* update tooltip */
+ tooltip = g_strdup_printf("<big><b>%s</b>\n</big>"\
+ "<tt>Az: %5.1f\302\260\n" \
+ "El: %5.1f\302\260\n" \
+ "%s</tt>",
+ sat->nickname,
+ sat->az, sat->el,
+ losstr);
+
g_object_set (obj->marker,
"x", x - MARKER_SIZE_HALF,
"y", y - MARKER_SIZE_HALF,
+ "tooltip", tooltip,
NULL);
g_object_set (obj->label,
"x", x,
"y", y+2,
+ "tooltip", tooltip,
NULL);
+ g_free (tooltip);
+
/* update selection info if satellite is
selected
*/
if (obj->selected) {
- guint h,m,s;
- gchar *ch,*cm,*cs;
- gdouble number, now;
-
- if (sat->los > 0.0) {
- now = polv->tstamp;//get_current_daynum ();
- number = sat->los - now;
-
- /* convert julian date to seconds */
- s = (guint) (number * 86400);
-
- /* 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 ("");
-
- /* 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 (s < 10)
- cs = g_strdup (":0");
- else
- cs = g_strdup (":");
-
- if (h > 0) {
- text = g_strdup_printf (_("%s\nLOS in %s%d:%s%d%s%d"),
- sat->nickname, ch, h, cm, m, cs, s);
- }
- else {
- text = g_strdup_printf (_("%s\nLOS in %s%d%s%d"),
- sat->nickname, cm, m, cs, s);
- }
- g_free (ch);
- g_free (cm);
- g_free (cs);
- }
- else {
- text = g_strdup_printf (_("%s\nAlways in range"), sat->nickname);
- }
+ text = g_strdup_printf ("%s\n%s",sat->nickname, losstr);
g_object_set (polv->sel, "text", text, NULL);
-
g_free (text);
}
- g_free (catnum);
+ g_free (losstr);
+ g_free (catnum); // FIXME: why free here, what about else?
}
else {
/* add sat to canvas */
@@ -957,6 +931,14 @@
MOD_CFG_POLAR_SAT_COL,
SAT_CFG_INT_POLAR_SAT_COL);
+ /* create tooltip */
+ tooltip = g_strdup_printf("<big><b>%s</b>\n</big>"\
+ "<tt>Az: %5.1f\302\260\n" \
+ "El: %5.1f\302\260\n" \
+ "</tt>",
+ sat->nickname,
+ sat->az, sat->el);
+
obj->marker = goo_canvas_rect_model_new (root,
x - MARKER_SIZE_HALF,
y - MARKER_SIZE_HALF,
@@ -964,6 +946,7 @@
2*MARKER_SIZE_HALF,
"fill-color-rgba", colour,
"stroke-color-rgba", colour,
+ "tooltip", tooltip,
NULL);
obj->label = goo_canvas_text_model_new (root, sat->nickname,
x,
@@ -972,7 +955,10 @@
GTK_ANCHOR_NORTH,
"font", "Sans 8",
"fill-color-rgba", colour,
+ "tooltip", tooltip,
NULL);
+
+ g_free (tooltip);
goo_canvas_item_model_raise (obj->marker, NULL);
goo_canvas_item_model_raise (obj->label, NULL);
@@ -1604,3 +1590,59 @@
GTK_POLAR_VIEW (polv)->naos = 0.0;
GTK_POLAR_VIEW (polv)->ncat = 0;
}
+
+
+
+/** \brief Convert LOS timestamp to human readable countdown string */
+static gchar *los_time_to_str (GtkPolarView *polv, sat_t *sat)
+{
+ guint h,m,s;
+ gchar *ch,*cm,*cs;
+ gdouble number, now;
+ gchar *text = NULL;
+
+
+ now = polv->tstamp;//get_current_daynum ();
+ number = sat->los - now;
+
+ /* convert julian date to seconds */
+ s = (guint) (number * 86400);
+
+ /* 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 ("");
+
+ /* 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 (s < 10)
+ cs = g_strdup (":0");
+ else
+ cs = g_strdup (":");
+
+ if (h > 0) {
+ text = g_strdup_printf (_("LOS in %s%d:%s%d%s%d"), ch, h, cm, m, cs, s);
+ }
+ else {
+ text = g_strdup_printf (_("LOS in %s%d%s%d"), cm, m, cs, s);
+ }
+ g_free (ch);
+ g_free (cm);
+ g_free (cs);
+
+ return text;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|