gpredict-svn Mailing List for Gpredict (Page 7)
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
You can subscribe to this list here.
2008 |
Jan
(24) |
Feb
|
Mar
(6) |
Apr
(14) |
May
(9) |
Jun
|
Jul
|
Aug
(25) |
Sep
(60) |
Oct
(26) |
Nov
|
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
|
Feb
(2) |
Mar
(22) |
Apr
(61) |
May
(57) |
Jun
|
Jul
(3) |
Aug
(83) |
Sep
(35) |
Oct
(50) |
Nov
(28) |
Dec
(34) |
2010 |
Jan
(29) |
Feb
(15) |
Mar
(2) |
Apr
|
May
(6) |
Jun
(2) |
Jul
(24) |
Aug
(2) |
Sep
(9) |
Oct
(43) |
Nov
(22) |
Dec
(6) |
2011 |
Jan
(24) |
Feb
(22) |
Mar
(31) |
Apr
(13) |
May
(10) |
Jun
(10) |
Jul
(43) |
Aug
(12) |
Sep
(18) |
Oct
(33) |
Nov
(18) |
Dec
(4) |
From: <aa...@us...> - 2011-04-18 11:36:30
|
Revision: 815 http://gpredict.svn.sourceforge.net/gpredict/?rev=815&view=rev Author: aa1vs Date: 2011-04-18 11:36:23 +0000 (Mon, 18 Apr 2011) Log Message: ----------- Added mlos and maos to list view. Modified Paths: -------------- branches/mlos/src/gtk-mlos-glance.c branches/mlos/src/gtk-mlos-glance.h branches/mlos/src/gtk-sat-data.c branches/mlos/src/gtk-sat-list.c branches/mlos/src/gtk-sat-map.c branches/mlos/src/gtk-sat-map.h branches/mlos/src/gtk-sat-module.c branches/mlos/src/gtk-sat-module.h branches/mlos/src/mod-cfg.c branches/mlos/src/predict-tools.c branches/mlos/src/predict-tools.h branches/mlos/src/qth-data.c branches/mlos/src/qth-data.h branches/mlos/src/sgpsdp/sgp4sdp4.h branches/mlos/src/sgpsdp/sgp_math.c Modified: branches/mlos/src/gtk-mlos-glance.c =================================================================== --- branches/mlos/src/gtk-mlos-glance.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-mlos-glance.c 2011-04-18 11:36:23 UTC (rev 815) @@ -242,7 +242,7 @@ * \param ts The t0 for the timeline or 0 to use the current date and time. */ GtkWidget* -gtk_mlos_glance_new (GHashTable *sats, qth_t *qth, GHashTable *groundstations, gdouble ts) +gtk_mlos_glance_new (GHashTable *sats, qth_t *qth, GSList *groundstations, gdouble ts) { GtkWidget *skg; GooCanvasItemModel *root; @@ -260,7 +260,7 @@ } /* check that we have at least one groundstation */ - number = g_hash_table_size (groundstations); + number = g_slist_length (groundstations); if (number == 0) { /* no satellites */ skg = gtk_label_new (_("This module has no other groundstations!")); @@ -280,7 +280,7 @@ /* get settings */ GTK_MLOS_GLANCE (skg)->numsat = g_hash_table_size (sats); - GTK_MLOS_GLANCE (skg)->numqth = g_hash_table_size (groundstations); + GTK_MLOS_GLANCE (skg)->numqth = g_slist_length (groundstations); /* if ts = 0 use current time */ if (ts > 0.0) { @@ -476,9 +476,9 @@ skg->x0 = 0; skg->y0 = 0; - skg->pps = (skg->h - SKG_MARGIN) / (skg->numsat*skg->numqth) - SKG_MARGIN; + skg->pps = (skg->h - SKG_MARGIN) / (g_slist_length(skg->satlab)) - SKG_MARGIN; - goo_canvas_set_bounds (GOO_CANVAS (GTK_MLOS_GLANCE (skg)->canvas), 0, 0, + goo_canvas_set_bounds (GOO_CANVAS (skg->canvas), 0, 0, allocation->width, allocation->height); @@ -774,7 +774,6 @@ /* get pointer to pass_t structure */ mlos_t *pass = (mlos_t *) g_object_get_data(G_OBJECT(item_model), "pass"); - mlos_t *new_pass; if G_UNLIKELY(pass == NULL) { @@ -986,7 +985,6 @@ sat_t *sat = SAT(value); GtkMlosGlance *skg = GTK_MLOS_GLANCE(data); GSList *passes = NULL; - GSList *grounds = NULL; gdouble maxdt; guint i,n,jj,m; mlos_t *tmppass = NULL; @@ -1000,28 +998,16 @@ gchar *tooltip; /* the complete tooltips string */ gchar aosstr[100]; /* AOS time string */ gchar losstr[100]; /* LOS time string */ - gchar tcastr[100]; /* TCA time string */ - - grounds = g_hash_table_get_values (skg->grounds); - /* FIXME: - Include current pass if sat is up now - */ - - /* check that we didn't exceed 10 sats */ - /* if (++skg->satcnt > 10) { */ - /* return; */ - /* } */ - /* get canvas root */ root = goo_canvas_get_root_item_model (GOO_CANVAS (skg->canvas)); get_colours (skg->paircnt++, &bcol, &fcol); maxdt = skg->te - skg->ts; - m = g_slist_length (grounds); + m = g_slist_length (skg->grounds); for (jj=0;jj<m;jj++){ - qth2 = QTH(g_slist_nth_data(grounds,jj)); + qth2 = QTH(g_slist_nth_data(skg->grounds,jj)); //printf("Processing %s\n",qth2->name); /* get mutual visibility for satellite at this qth and qth2*/ Modified: branches/mlos/src/gtk-mlos-glance.h =================================================================== --- branches/mlos/src/gtk-mlos-glance.h 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-mlos-glance.h 2011-04-18 11:36:23 UTC (rev 815) @@ -74,7 +74,7 @@ GtkWidget *canvas; /*!< The canvas widget */ GHashTable *sats; /*!< Copy of satellites. */ - GHashTable *grounds; /*!< Copy of groundstations. */ + GSList *grounds; /*!< Copy of groundstations. */ qth_t *qth; /*!< Pointer to current location. */ GSList *passes; /*!< Canvas items representing each pass. @@ -118,7 +118,7 @@ GtkType gtk_mlos_glance_get_type (void); -GtkWidget* gtk_mlos_glance_new (GHashTable *sats, qth_t *qth, GHashTable *groundstations, gdouble ts); +GtkWidget* gtk_mlos_glance_new (GHashTable *sats, qth_t *qth,GSList *groundstations, gdouble ts); /* void gtk_mlos_glance_reconf (GtkWidget *skg); Modified: branches/mlos/src/gtk-sat-data.c =================================================================== --- branches/mlos/src/gtk-sat-data.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-sat-data.c 2011-04-18 11:36:23 UTC (rev 815) @@ -144,6 +144,8 @@ sat->phase = 0.0; sat->aos = 0.0; sat->los = 0.0; + sat->maos = 0.0; + sat->mlos = 0.0; /* calculate satellite data at epoch */ gtk_sat_data_init_sat (sat, NULL); @@ -194,9 +196,9 @@ /* execute computations */ if (sat->flags & DEEP_SPACE_EPHEM_FLAG) - SDP4 (sat, 0.0); + SDP4 (sat, jul_utc); else - SGP4 (sat, 0.0); + SGP4 (sat, jul_utc); /* scale position and velocity to km and km/sec */ Convert_Sat_State (&sat->pos, &sat->vel); Modified: branches/mlos/src/gtk-sat-list.c =================================================================== --- branches/mlos/src/gtk-sat-list.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-sat-list.c 2011-04-18 11:36:23 UTC (rev 815) @@ -744,19 +744,33 @@ gchar *tfstr; gchar *fmtstr; gchar *alstr; + + /* next event is LOS */ + number = sat->los; + alstr = g_strdup ("LOS: "); + if ( sat->mlos < number && sat->mlos != 0.0) { + /* next event is MLOS */ + number = sat->mlos; + g_free(alstr); + alstr = g_strdup ("MLOS: "); + } - if (sat->aos > sat->los) { - /* next event is LOS */ - number = sat->los; - alstr = g_strdup ("LOS: "); - } - else { + if (sat->aos < number && sat->aos != 0.0) { /* next event is AOS */ number = sat->aos; + g_free(alstr); alstr = g_strdup ("AOS: "); } + + if ( sat->maos < number && sat->maos != 0.0) { + /* next event is MAOS */ + number = sat->maos; + g_free(alstr); + alstr = g_strdup ("MAOS: "); + } + if (number == 0.0) { gtk_list_store_set (GTK_LIST_STORE (model), iter, SAT_LIST_COL_NEXT_EVENT, "--- N/A ---", Modified: branches/mlos/src/gtk-sat-map.c =================================================================== --- branches/mlos/src/gtk-sat-map.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-sat-map.c 2011-04-18 11:36:23 UTC (rev 815) @@ -71,9 +71,9 @@ static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data); static void update_map_size (GtkSatMap *satmap); static void update_sat (gpointer key, gpointer value, gpointer data); -static void update_groundstation (gpointer key, gpointer value, gpointer data); +static void update_groundstation (gpointer value, gpointer data); static void plot_sat (gpointer key, gpointer value, gpointer data); -static void plot_groundstation (gpointer key, gpointer value, gpointer data); +static void plot_groundstation (gpointer value, gpointer data); static void lonlat_to_xy (GtkSatMap *m, gdouble lon, gdouble lat, gfloat *x, gfloat *y); static void xy_to_lonlat (GtkSatMap *m, gfloat x, gfloat y, gfloat *lon, gfloat *lat); static gboolean on_motion_notify (GooCanvasItem *item, @@ -173,6 +173,7 @@ satmap->qth = NULL; satmap->obj = NULL; satmap->groundobj = NULL; + satmap->groundstations = NULL; satmap->naos = 2458849.5; satmap->ncat = 0; satmap->tstamp = 2458849.5; @@ -206,11 +207,12 @@ * */ GtkWidget* -gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth, GHashTable *groundstations) +gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth, GSList *groundstations) { GtkWidget *satmap; GooCanvasItemModel *root; guint32 col; + gint m; satmap = g_object_new (GTK_TYPE_SAT_MAP, NULL); @@ -301,9 +303,10 @@ g_hash_table_foreach (GTK_SAT_MAP (satmap)->sats, plot_sat, GTK_SAT_MAP (satmap)); /* plot each groundstation on the canvas */ - g_hash_table_foreach (GTK_SAT_MAP (satmap)->groundstations, plot_groundstation, GTK_SAT_MAP (satmap)); - - /* gtk_box_pack_start (GTK_BOX (satmap), GTK_SAT_MAP (satmap)->swin, TRUE, TRUE, 0); */ + for (m=0;m<g_slist_length(GTK_SAT_MAP(satmap)->groundstations);m++) { + plot_groundstation(g_slist_nth_data(GTK_SAT_MAP(satmap)->groundstations,m), GTK_SAT_MAP(satmap)); + } + gtk_container_add (GTK_CONTAINER (satmap), GTK_SAT_MAP (satmap)->canvas); return satmap; @@ -488,6 +491,7 @@ gfloat x, y; gfloat ratio; /* ratio between map width and height */ gfloat size; /* size = min (alloc.w, ratio*alloc.h) */ + gint m; if (GTK_WIDGET_REALIZED (satmap)) { /* get graph dimensions */ @@ -583,8 +587,9 @@ /* update satellites */ g_hash_table_foreach (satmap->sats, update_sat, satmap); /* update grounds */ - g_hash_table_foreach (satmap->groundstations, update_groundstation, satmap); - + for (m=0;m<g_slist_length(GTK_SAT_MAP(satmap)->groundstations);m++) { + update_groundstation(g_slist_nth_data(GTK_SAT_MAP(satmap)->groundstations,m), GTK_SAT_MAP(satmap)); + } satmap->resize = FALSE; } } @@ -689,8 +694,9 @@ /* update sats */ g_hash_table_foreach (satmap->sats, update_sat, satmap); /* update sats */ - g_hash_table_foreach (satmap->groundstations, update_groundstation, satmap); - + for (m=0;m<g_slist_length(GTK_SAT_MAP(satmap)->groundstations);m++) { + update_groundstation(g_slist_nth_data(GTK_SAT_MAP(satmap)->groundstations,m), GTK_SAT_MAP(satmap)); + } /* update countdown to NEXT AOS label */ if (satmap->eventinfo) { @@ -1864,7 +1870,7 @@ g_hash_table_insert (satmap->obj, catnum, obj); } static void -plot_groundstation (gpointer key, gpointer value, gpointer data) +plot_groundstation (gpointer value, gpointer data) { GtkSatMap *satmap = GTK_SAT_MAP (data); sat_map_ground_t *obj = NULL; @@ -1872,7 +1878,7 @@ GooCanvasItemModel *root; guint32 col; gfloat x,y; - gchar *tooltip; + gchar *tooltip; lonlat_to_xy (satmap, ground->lon, ground->lat, &x, &y); @@ -2167,7 +2173,7 @@ } static void -update_groundstation (gpointer key, gpointer value, gpointer data) +update_groundstation (gpointer value, gpointer data) { GtkSatMap *satmap = GTK_SAT_MAP (data); sat_map_ground_t *obj = NULL; Modified: branches/mlos/src/gtk-sat-map.h =================================================================== --- branches/mlos/src/gtk-sat-map.h 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-sat-map.h 2011-04-18 11:36:23 UTC (rev 815) @@ -150,7 +150,7 @@ GKeyFile *cfgdata; /*!< Module configuration data. */ GHashTable *sats; /*!< Pointer to satellites (owned by parent GtkSatModule). */ - GHashTable *groundstations; /*!< Pointer to groundstations (owned by parent GtkSatModule). */ + GSList *groundstations; /*!< Pointer to groundstations (owned by parent GtkSatModule). */ qth_t *qth; /*!< Pointer to current location. */ GHashTable *obj; /*!< Canvas items representing each satellite. */ @@ -188,7 +188,7 @@ GtkWidget* gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth, - GHashTable *groundstations); + GSList *groundstations); void gtk_sat_map_update (GtkWidget *widget); void gtk_sat_map_reconf (GtkWidget *widget, GKeyFile *cfgdat); Modified: branches/mlos/src/gtk-sat-module.c =================================================================== --- branches/mlos/src/gtk-sat-module.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-sat-module.c 2011-04-18 11:36:23 UTC (rev 815) @@ -104,6 +104,9 @@ static void update_skg (GtkSatModule *module); static void update_mlos (GtkSatModule *module); +static gdouble find_mlos_single_sat_mult_qth(sat_t *sat, qth_t *qth, GSList *grounds, gdouble start, gdouble maxdt); +static gdouble find_maos_single_sat_mult_qth(sat_t *sat, qth_t *qth, GSList *grounds, gdouble start, gdouble maxdt); + static GtkVBoxClass *parent_class = NULL; @@ -171,29 +174,20 @@ g_free, gtk_sat_module_free_sat); - module->groundstations = g_hash_table_new_full (g_int_hash, - g_int_equal, - g_free, - NULL); - - module->rotctrlwin = NULL; module->rotctrl = NULL; module->rigctrlwin = NULL; module->rigctrl = NULL; module->skgwin = NULL; module->skg = NULL; - module->mloswin = NULL; - module->mlos = NULL; + module->mloswin = NULL; + module->mlos = NULL; + module->groundstations = NULL; module->lastSkgUpd = 0.0; module->state = GTK_SAT_MOD_STATE_DOCKED; module->busy = g_mutex_new(); - /* open the gpsd device */ - module->gps_data = NULL; - - module->grid = NULL; module->views = NULL; module->nviews = 0; @@ -258,7 +252,7 @@ /* clean up groundstations */ if (module->groundstations) { - g_hash_table_destroy (module->groundstations); + g_slist_free (module->groundstations); module->groundstations = NULL; } @@ -761,7 +755,6 @@ guint i; qth_t *qth; - gint *key = NULL; guint succ = 0; gchar *confdir = NULL; gchar *qth_file = NULL; @@ -808,16 +801,12 @@ /* check whether satellite is already in list in order to avoid duplicates */ - key = g_new0 (gint, 1); - *key = g_str_hash(qth->name); - if (g_hash_table_lookup (module->groundstations, key) == NULL) { + if (g_slist_find_custom (module->groundstations, qth, (GCompareFunc) qth_name_compare) == NULL) { qth_data_update_init (qth); - g_hash_table_insert (module->groundstations, - key, - qth); + module->groundstations = g_slist_insert_sorted (module->groundstations, qth, (GCompareFunc) qth_name_compare); succ++; @@ -1070,9 +1059,6 @@ GtkSatModule *module; gdouble daynum; double age; - obs_set_t obs_set = {0,0,0,0}; - geodetic_t sat_geodetic = {0,0,0,0}; - geodetic_t obs_geodetic = {0,0,0,0}; gdouble maxdt; g_return_if_fail ((val != NULL) && (data != NULL)); @@ -1080,11 +1066,11 @@ sat = SAT(val); module = GTK_SAT_MODULE (data); - - + + /* get current time (real or simulated */ daynum = module->tmgCdnum; - + /* update events if the event counter has been reset and the other requirements are fulfilled */ @@ -1101,66 +1087,26 @@ sat->aos = find_aos (sat, module->qth, daynum, maxdt); sat->los = find_los (sat, module->qth, daynum, maxdt); + /*update the mlos information for each of the other groundstations*/ + if (sat->maos>0) + sat->mlos = find_mlos_single_sat_mult_qth ( sat, module->qth, module->groundstations, daynum, maxdt); + sat->maos = find_maos_single_sat_mult_qth ( sat, module->qth, module->groundstations, daynum, maxdt); + } else { + if (has_aos(sat,module->qth) && sat->aos > 0.0){ + maxdt = (gdouble) sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD); + if (sat->mlos < daynum && sat->mlos > 0.0 && sat->maos > 0.0) + sat->mlos = find_mlos_single_sat_mult_qth ( sat, module->qth, module->groundstations, daynum, maxdt); + if (sat->maos < daynum && sat->maos > 0.0) + sat->maos = find_maos_single_sat_mult_qth ( sat, module->qth, module->groundstations, daynum, maxdt); + } + + } - /*data may have been updated by gpsd*/ - obs_geodetic.lon = module->qth->lon * de2ra; - obs_geodetic.lat = module->qth->lat * de2ra; - obs_geodetic.alt = module->qth->alt / 1000.0; - obs_geodetic.theta = 0; + predict_calc(sat,module->qth,daynum); + - - sat->jul_utc = daynum; - sat->tsince = (sat->jul_utc - sat->jul_epoch) * xmnpda; - - - - /* call the norad routines according to the deep-space flag */ - if (sat->flags & DEEP_SPACE_EPHEM_FLAG) - SDP4 (sat, sat->tsince); - else - SGP4 (sat, sat->tsince); - - /* scale position and velocity to km and km/sec */ - Convert_Sat_State (&sat->pos, &sat->vel); - - /* get the velocity of the satellite */ - Magnitude (&sat->vel); - sat->velo = sat->vel.w; - Calculate_Obs (sat->jul_utc, &sat->pos, &sat->vel, &obs_geodetic, &obs_set); - Calculate_LatLonAlt (sat->jul_utc, &sat->pos, &sat_geodetic); - - /*** FIXME: should we ensure sat_geodetic.lon stays between -pi and pi? */ - while (sat_geodetic.lon < -pi) - sat_geodetic.lon += twopi; - - while (sat_geodetic.lon > (pi)) - sat_geodetic.lon -= twopi; - - sat->az = Degrees (obs_set.az); - sat->el = Degrees (obs_set.el); - sat->range = obs_set.range; - sat->range_rate = obs_set.range_rate; - sat->ssplat = Degrees (sat_geodetic.lat); - sat->ssplon = Degrees (sat_geodetic.lon); - sat->alt = sat_geodetic.alt; - sat->ma = Degrees (sat->phase); - sat->ma *= 256.0/360.0; - sat->phase = Degrees (sat->phase); - - /* same formulas, but the one from predict is nicer */ - //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); - sat->footprint = 12756.33 * acos (xkmper / (xkmper+sat->alt)); - age = sat->jul_utc - sat->jul_epoch; - sat->orbit = (long) floor((sat->tle.xno * xmnpda/twopi + - age * sat->tle.bstar * ae) * age + - sat->tle.xmo/twopi) + sat->tle.revnum - 1; - - - /*** FIXME: Squint + AOS / LOS code */ - - } @@ -1696,3 +1642,55 @@ qth_small_save(module->qth,&(module->lastMlosUpdqth)); } } + +gdouble find_mlos_single_sat_mult_qth(sat_t *sat, qth_t *qth, GSList *grounds, gdouble start, gdouble maxdt){ + guint i,m; + gdouble mlos = 0, mlos_temp = 0; + qth_t* qthb; + + m = g_slist_length(grounds); + i = 0; + //printf("start is %f\n",start); + while (mlos == 0 && i<m) { + qthb = QTH( g_slist_nth_data(grounds,i)); + mlos = find_mlos(sat,qth,qthb,start,maxdt); + //printf("Mlos is %f\n",mlos); + if (mlos<start) + mlos = 0; + i++; + } + while (i<m) { + qthb = QTH( g_slist_nth_data(grounds,i)); + //printf("Mlos is %f\n",mlos); + mlos_temp = find_mlos(sat,qth,qthb,start,mlos-start); + if (mlos_temp<mlos && mlos_temp>0.0) + mlos = mlos_temp; + i++; + } + return (mlos); +} + +gdouble find_maos_single_sat_mult_qth(sat_t *sat, qth_t *qth, GSList *grounds, gdouble start, gdouble maxdt){ + guint i,m; + gdouble maos = 0, maos_temp = 0; + qth_t* qthb; + + m = g_slist_length(grounds); + i = 0; + + while (maos == 0 && i<m) { + qthb = QTH( g_slist_nth_data(grounds,i)); + maos = find_maos(sat,qth,qthb,start,maxdt); + if (maos < start) + maos = 0; + i++; + } + while (i<m) { + qthb = QTH( g_slist_nth_data(grounds,i)); + maos_temp = find_maos(sat,qth,qthb,start,maos-start); + if (maos_temp<maos && maos_temp >0.0) + maos = maos_temp; + i++; + } + return (maos); +} Modified: branches/mlos/src/gtk-sat-module.h =================================================================== --- branches/mlos/src/gtk-sat-module.h 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/gtk-sat-module.h 2011-04-18 11:36:23 UTC (rev 815) @@ -126,7 +126,7 @@ qth_t *qth; /*!< QTH information. */ qth_small_t qth_event; /*!< QTH information for last AOS/LOS update. */ GHashTable *satellites; /*!< Satellites. */ - GHashTable *groundstations;/*!< Other Ground Stations. */ + GSList *groundstations;/*!< Other Ground Stations. */ guint32 timeout; /*!< Timeout value [msec] */ Modified: branches/mlos/src/mod-cfg.c =================================================================== --- branches/mlos/src/mod-cfg.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/mod-cfg.c 2011-04-18 11:36:23 UTC (rev 815) @@ -79,8 +79,6 @@ static void addbut_clicked_cb (GtkButton *button, GtkSatSelector *selector); static void delbut_clicked_cb (GtkButton *button, GtkSatSelector *selector); -static gint qth_name_compare (const gchar *a, const gchar *b); - /** \brief Create a new module. * * This function creates a new module. The name of the module is @@ -1255,8 +1253,3 @@ } } - - -static gint qth_name_compare (const gchar* a,const gchar *b){ - return (gpredict_strcmp(a,b)); -} Modified: branches/mlos/src/predict-tools.c =================================================================== --- branches/mlos/src/predict-tools.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/predict-tools.c 2011-04-18 11:36:23 UTC (rev 815) @@ -507,40 +507,78 @@ } else { pass2=get_pass(sat,qth2,start,maxdt); } - - while (pass1 && pass2 && !done) { - if (pass1->los < pass2->aos){ - /*pass1 finishs before pass2 starts*/ - /*no overlap so no mlos*/ - temptime=pass1->los+10.0/86400.0; - free_pass(pass1); - pass1=get_pass(sat,qth1,temptime,maxdt+start-temptime); - } else if (pass2->los < pass1->aos){ - /*pass2 finishs before pass1 starts*/ - /*no overlap so no mlos*/ - temptime=pass2->los+10.0/86400.0; - free_pass(pass2); - pass2=get_pass(sat,qth2,temptime,maxdt+start-temptime); - } else { - mlos = g_new (mlos_t, 1); - - /*passes overlap*/ - if (pass1->aos < pass2->aos) { - /*passes have overlap and pass1 starts first*/ - mlos->start=pass2->aos; - }else { - mlos->start=pass1->aos; + + if (maxdt>0.0) { + while (pass1 && pass2 && !done) { + if (pass1->los < pass2->aos){ + /*pass1 finishs before pass2 starts*/ + /*no overlap so no mlos*/ + temptime=pass2->aos; + free_pass(pass1); + pass1=get_pass(sat,qth1,temptime,maxdt+start-temptime); + } else if (pass2->los < pass1->aos){ + /*pass2 finishs before pass1 starts*/ + /*no overlap so no mlos*/ + temptime=pass1->aos; + free_pass(pass2); + pass2=get_pass(sat,qth2,temptime,maxdt+start-temptime); + } else { + mlos = g_new (mlos_t, 1); + + /*passes overlap*/ + if (pass1->aos < pass2->aos) { + /*passes have overlap and pass1 starts first*/ + mlos->start=pass2->aos; + }else { + mlos->start=pass1->aos; + } + + if (pass1->los < pass2->los) { + /*passes have overlap and pass1 finishes first*/ + mlos->finish=pass1->los; + }else { + mlos->finish=pass2->los; + } + done=TRUE; + valid=TRUE; + } - - if (pass1->los < pass2->los) { - /*passes have overlap and pass1 finishes first*/ - mlos->finish=pass1->los; - }else { - mlos->finish=pass2->los; + } + } else { + while (pass1 && pass2 && !done) { + if (pass1->los < pass2->aos){ + /*pass1 finishs before pass2 starts*/ + /*no overlap so no mlos*/ + temptime=pass1->los+10.0/86400.0; + free_pass(pass1); + pass1=get_pass(sat,qth1,temptime,maxdt); + } else if (pass2->los < pass1->aos){ + /*pass2 finishs before pass1 starts*/ + /*no overlap so no mlos*/ + temptime=pass2->los+10.0/86400.0; + free_pass(pass2); + pass2=get_pass(sat,qth2,temptime,maxdt); + } else { + mlos = g_new (mlos_t, 1); + + /*passes overlap*/ + if (pass1->aos < pass2->aos) { + /*passes have overlap and pass1 starts first*/ + mlos->start=pass2->aos; + }else { + mlos->start=pass1->aos; + } + + if (pass1->los < pass2->los) { + /*passes have overlap and pass1 finishes first*/ + mlos->finish=pass1->los; + }else { + mlos->finish=pass2->los; + } + done=TRUE; + valid=TRUE; + } - done=TRUE; - valid=TRUE; - } } if (pass1) { @@ -561,13 +599,43 @@ gdouble find_mlos(sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt) { mlos_t *temp; - gdouble temptime; + gdouble temptime = 0; temp = get_mlos(sat, qth1, qth2, start, maxdt); - temptime = temp->finish; - free_mlos(temp); + if (temp) { + temptime = temp->finish; + free_mlos(temp); + if (temptime < start) { + temp = get_mlos(sat, qth1, qth2, temptime + 60.0/86400.0, maxdt); + if (temp) { + temptime = temp->finish; + free_mlos(temp); + } + } + } + + return (temptime); } +gdouble find_maos(sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt) { + mlos_t *temp; + gdouble temptime = 0; + temp = get_mlos(sat, qth1, qth2, start, maxdt); + if (temp) { + temptime = temp->start; + free_mlos(temp); + if (temptime < start) { + temptime = temp->finish; + temp = get_mlos(sat, qth1, qth2, temp->finish + 60.0/86400.0, maxdt); + if (temp) { + temptime = temp->start; + free_mlos(temp); + } + } + } + return (temptime); +} + /** \brief Predict first pass after a certain time. * \param sat Pointer to the satellite data. * \param qth Pointer to the location data. @@ -622,8 +690,13 @@ while (!done) { /* Find los of next pass or of current pass */ - los = find_los (sat, qth, t0, maxdt); // See if a pass is ongoing - aos = find_aos (sat, qth, t0, start + maxdt - t0); + if (maxdt>0.0) { + los = find_los (sat, qth, t0, start + maxdt-t0); // See if a pass is ongoing + aos = find_aos (sat, qth, t0, start + maxdt - t0); + } else { + los = find_los (sat, qth, t0, maxdt); // See if a pass is ongoing + aos = find_aos (sat, qth, t0, maxdt); + } /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */ /* __FILE__, */ /* __FUNCTION__, */ @@ -1087,14 +1160,17 @@ mlos_t * copy_mlos ( mlos_t *mlos) { - mlos_t *new; + mlos_t *new=NULL; - new = g_try_new(pass_t,1); - - if (new != NULL) { - new->start = mlos->start; - new->finish = mlos->finish; + if (mlos) { + new = g_try_new(mlos_t,1); + + if (new != NULL) { + new->start = mlos->start; + new->finish = mlos->finish; + } } + return new; } void Modified: branches/mlos/src/predict-tools.h =================================================================== --- branches/mlos/src/predict-tools.h 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/predict-tools.h 2011-04-18 11:36:23 UTC (rev 815) @@ -112,6 +112,9 @@ mlos_t *get_mlos (sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt); GSList *get_mloses (sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt, guint num); +gdouble find_mlos(sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt); +gdouble find_maos(sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt); + /* copying */ pass_t *copy_pass (pass_t *pass); mlos_t *copy_mlos (mlos_t *pass); Modified: branches/mlos/src/qth-data.c =================================================================== --- branches/mlos/src/qth-data.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/qth-data.c 2011-04-18 11:36:23 UTC (rev 815) @@ -40,6 +40,7 @@ #include "orbit-tools.h" #include "time-tools.h" #include "locator.h" +#include "gpredict-utils.h" #ifdef HAS_LIBGPS # include <gps.h> #endif @@ -836,3 +837,9 @@ qrb(qth->lon,qth->lat,qth_small.lon,qth_small.lat,&distance,&azimuth); return(distance); } + +gint qth_name_compare (qth_t *qtha, qth_t *qthb){ + return gpredict_strcmp(qtha->name,qthb->name); +} + + Modified: branches/mlos/src/qth-data.h =================================================================== --- branches/mlos/src/qth-data.h 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/qth-data.h 2011-04-18 11:36:23 UTC (rev 815) @@ -51,6 +51,12 @@ gdouble gpsd_connected; /*!< Time last GPSD update was last attempted to connect. */ struct gps_data_t *gps_data; /*!< gpsd data structure. */ GKeyFile *data; /*!< Raw data from cfg file. */ + + /*added to support multiple ground stations and mutual events*/ + gdouble mlos; + gint mloscatnum; + gdouble maos; + gint maoscatnum; } qth_t; /** \brief Compact QTH data structure for tagging data and comparing. */ @@ -79,4 +85,5 @@ void qth_small_save(qth_t *qth,qth_small_t *qth_small); void qth_init(qth_t* qth); void qth_safe(qth_t* qth); +gint qth_name_compare (qth_t *qtha, qth_t *qthb); #endif Modified: branches/mlos/src/sgpsdp/sgp4sdp4.h =================================================================== --- branches/mlos/src/sgpsdp/sgp4sdp4.h 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/sgpsdp/sgp4sdp4.h 2011-04-18 11:36:23 UTC (rev 815) @@ -15,7 +15,7 @@ #include <unistd.h> #undef select - +#define AcTan(y,x) (atan2(y,x)) /** Type definitions **/ @@ -176,6 +176,8 @@ double tsince; double aos; /*!< Next AOS. */ double los; /*!< Next LOS */ + double mlos; /*!< Next MLOS */ + double maos; /*!< Next MAOS */ double az; /*!< Azimuth [deg] */ double el; /*!< Elevation [deg] */ Modified: branches/mlos/src/sgpsdp/sgp_math.c =================================================================== --- branches/mlos/src/sgpsdp/sgp_math.c 2011-04-08 15:27:48 UTC (rev 814) +++ branches/mlos/src/sgpsdp/sgp_math.c 2011-04-18 11:36:23 UTC (rev 815) @@ -185,7 +185,7 @@ /*------------------------------------------------------------------*/ /* Four-quadrant arctan function */ -double +/*double AcTan(double sinx, double cosx) { if(cosx == 0) @@ -208,7 +208,8 @@ return ( pi + atan(sinx/cosx) ); } -} /* Function AcTan */ + } */ +/* Function AcTan */ /*------------------------------------------------------------------*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-04-08 15:27:54
|
Revision: 814 http://gpredict.svn.sourceforge.net/gpredict/?rev=814&view=rev Author: aa1vs Date: 2011-04-08 15:27:48 +0000 (Fri, 08 Apr 2011) Log Message: ----------- Add tooltip to sat-map for new groundstations and add free_mlos function. Modified Paths: -------------- branches/mlos/ChangeLog branches/mlos/src/gtk-sat-map.c branches/mlos/src/predict-tools.c branches/mlos/src/predict-tools.h Modified: branches/mlos/ChangeLog =================================================================== --- branches/mlos/ChangeLog 2011-04-03 16:04:20 UTC (rev 813) +++ branches/mlos/ChangeLog 2011-04-08 15:27:48 UTC (rev 814) @@ -1,3 +1,10 @@ +2011-04-08 Charles Suprin <hamaa1vs at gmail.com> + + * src/gtk-sat-map.c + * src/predict-tools.c + * src/predict-tools.h + Add tooltip to sat-map for new groundstations and add free_mlos function. + 2011-04-03 Charles Suprin <hamaa1vs at gmail.com> * src/gtk-sat-module-popup.c Modified: branches/mlos/src/gtk-sat-map.c =================================================================== --- branches/mlos/src/gtk-sat-map.c 2011-04-03 16:04:20 UTC (rev 813) +++ branches/mlos/src/gtk-sat-map.c 2011-04-08 15:27:48 UTC (rev 814) @@ -1872,6 +1872,7 @@ GooCanvasItemModel *root; guint32 col; gfloat x,y; + gchar *tooltip; lonlat_to_xy (satmap, ground->lon, ground->lat, &x, &y); @@ -1886,17 +1887,25 @@ obj->ground_mark = NULL; obj->ground_label = NULL; + + /* create tooltip */ + tooltip = g_strdup_printf("<big><b>%s</b>\n</big>"\ + "<tt>Lon: %5.1f\302\260\n" \ + "Lat: %5.1f\302\260</tt>", + ground->name, + ground->lon, ground->lat); - root = goo_canvas_get_root_item_model (GOO_CANVAS (satmap->canvas)); obj->ground_mark = goo_canvas_rect_model_new (root, - x - MARKER_SIZE_HALF, - y - MARKER_SIZE_HALF, - 2 * MARKER_SIZE_HALF, - 2 * MARKER_SIZE_HALF, - "fill-color-rgba", col, - "stroke-color-rgba", col, - NULL); + x - MARKER_SIZE_HALF, + y - MARKER_SIZE_HALF, + 2 * MARKER_SIZE_HALF, + 2 * MARKER_SIZE_HALF, + "fill-color-rgba", col, + "stroke-color-rgba", col, + "tooltip", tooltip, + NULL); + g_free(tooltip); /* add groundstation to hash table */ g_hash_table_insert (satmap->groundobj, ground->name, obj); Modified: branches/mlos/src/predict-tools.c =================================================================== --- branches/mlos/src/predict-tools.c 2011-04-03 16:04:20 UTC (rev 813) +++ branches/mlos/src/predict-tools.c 2011-04-08 15:27:48 UTC (rev 814) @@ -559,6 +559,14 @@ return NULL; } +gdouble find_mlos(sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt) { + mlos_t *temp; + gdouble temptime; + temp = get_mlos(sat, qth1, qth2, start, maxdt); + temptime = temp->finish; + free_mlos(temp); + return (temptime); +} /** \brief Predict first pass after a certain time. * \param sat Pointer to the satellite data. @@ -1102,7 +1110,7 @@ mlos = g_slist_nth_data (mloses, i); /* free element data */ - g_free (mlos); + free_mlos (mlos); } @@ -1110,3 +1118,7 @@ g_slist_free (mloses); mloses = NULL; } + +void free_mlos (mlos_t* mlos){ + g_free(mlos); +} Modified: branches/mlos/src/predict-tools.h =================================================================== --- branches/mlos/src/predict-tools.h 2011-04-03 16:04:20 UTC (rev 813) +++ branches/mlos/src/predict-tools.h 2011-04-08 15:27:48 UTC (rev 814) @@ -121,6 +121,7 @@ /* memory cleaning */ void free_pass (pass_t *pass); void free_passes (GSList *passes); +void free_mlos (mlos_t *mloses); void free_mloses (GSList *mloses); void free_pass_detail (pass_detail_t *detail); void free_pass_details (GSList *details); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-04-03 16:04:26
|
Revision: 813 http://gpredict.svn.sourceforge.net/gpredict/?rev=813&view=rev Author: aa1vs Date: 2011-04-03 16:04:20 +0000 (Sun, 03 Apr 2011) Log Message: ----------- Cleanup some inital bugs. Modified Paths: -------------- branches/mlos/ChangeLog branches/mlos/src/gtk-mlos-glance.c branches/mlos/src/gtk-mlos-glance.h branches/mlos/src/gtk-sat-module-popup.c branches/mlos/src/predict-tools.c branches/mlos/src/predict-tools.h Modified: branches/mlos/ChangeLog =================================================================== --- branches/mlos/ChangeLog 2011-04-03 14:51:33 UTC (rev 812) +++ branches/mlos/ChangeLog 2011-04-03 16:04:20 UTC (rev 813) @@ -8,7 +8,8 @@ * src/gtk-mlos-glance.h * src/predict-tools.c * src/predict-tools.h - Demonstrate initial implementation of get_mlos and get_mloses with sky at glance like window. + Demonstrate initial implementation of get_mlos and get_mloses with sky at glance like window. + Cleanup initial implementation. 2011-04-01 Charles Suprin <hamaa1vs at gmail.com> Modified: branches/mlos/src/gtk-mlos-glance.c =================================================================== --- branches/mlos/src/gtk-mlos-glance.c 2011-04-03 14:51:33 UTC (rev 812) +++ branches/mlos/src/gtk-mlos-glance.c 2011-04-03 16:04:20 UTC (rev 813) @@ -263,7 +263,7 @@ number = g_hash_table_size (groundstations); if (number == 0) { /* no satellites */ - skg = gtk_label_new (_("This module has no satellites!")); + skg = gtk_label_new (_("This module has no other groundstations!")); return skg; } @@ -280,6 +280,7 @@ /* get settings */ GTK_MLOS_GLANCE (skg)->numsat = g_hash_table_size (sats); + GTK_MLOS_GLANCE (skg)->numqth = g_hash_table_size (groundstations); /* if ts = 0 use current time */ if (ts > 0.0) { @@ -294,8 +295,8 @@ /* calculate preferred sizes */ GTK_MLOS_GLANCE (skg)->w = SKG_DEFAULT_WIDTH; - GTK_MLOS_GLANCE (skg)->h = GTK_MLOS_GLANCE (skg)->numsat * SKG_PIX_PER_SAT + - (GTK_MLOS_GLANCE (skg)->numsat + 1) * SKG_MARGIN; + GTK_MLOS_GLANCE (skg)->h = GTK_MLOS_GLANCE (skg)->numsat*GTK_MLOS_GLANCE(skg)->numqth * SKG_PIX_PER_SAT + + (GTK_MLOS_GLANCE (skg)->numsat*GTK_MLOS_GLANCE(skg)->numqth + 1) * SKG_MARGIN; GTK_MLOS_GLANCE (skg)->pps = SKG_PIX_PER_SAT; /* create the canvas */ @@ -458,6 +459,7 @@ GooCanvasItem *obj; gint i,j,n; guint curcat; + guint curqth; gdouble th,tm; gdouble xh,xm; mlos_pass_t *skp; @@ -474,7 +476,7 @@ skg->x0 = 0; skg->y0 = 0; - skg->pps = (skg->h - SKG_MARGIN) / skg->numsat - SKG_MARGIN; + skg->pps = (skg->h - SKG_MARGIN) / (skg->numsat*skg->numqth) - SKG_MARGIN; goo_canvas_set_bounds (GOO_CANVAS (GTK_MLOS_GLANCE (skg)->canvas), 0, 0, allocation->width, allocation->height); @@ -565,6 +567,7 @@ n = g_slist_length (skg->passes); j = -1; curcat = 0; + curqth = 1<<15; y = 10.0; h = 10.0; for (i = 0; i < n; i++) { @@ -577,10 +580,11 @@ w = t2x (skg, skp->pass->finish) - x; if (w>0) { - /* new satellite? */ - if (skp->catnum != curcat) { + /* new satellite qth pair? */ + if (skp->catnum != curcat || skp->qthnum != curqth) { j++; curcat = skp->catnum; + curqth = skp->qthnum; y = j * (skg->pps + SKG_MARGIN) + SKG_MARGIN; h = skg->pps; @@ -784,7 +788,7 @@ switch (event->button) { /* LEFT button released */ - case 1: + //case 1: //new_pass = copy_pass (pass); //sat_log_log (SAT_LOG_LEVEL_BUG, // _("%s::%s: Showing pass details for %s - we may have a memory leak here"), @@ -793,7 +797,7 @@ /* show the pass details */ //show_pass (pass->satname, skg->qth, new_pass, NULL); - break; + //break; default: sat_log_log (SAT_LOG_LEVEL_DEBUG, @@ -991,7 +995,7 @@ guint bcol,fcol; /* colours */ GooCanvasItemModel *root; GooCanvasItemModel *lab; - + gchar *tmplab; /* tooltips vars */ gchar *tooltip; /* the complete tooltips string */ gchar aosstr[100]; /* AOS time string */ @@ -1016,84 +1020,82 @@ maxdt = skg->te - skg->ts; m = g_slist_length (grounds); - for (jj=0;jj<1;jj++){ + for (jj=0;jj<m;jj++){ qth2 = QTH(g_slist_nth_data(grounds,jj)); //printf("Processing %s\n",qth2->name); - - /* get passes for satellite */ - - passes = get_mloses (sat, skg->qth, qth2, skg->ts, maxdt, 10); - n = g_slist_length (passes); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: %s has %d passes within %.4f days\n"), - __FILE__, __LINE__, sat->nickname, n, maxdt); - - /* add mlos_pass_t items to skg->passes */ - if (passes != NULL) { - - /* add pass items */ - for (i = 0; i < n; i++) { + + /* get mutual visibility for satellite at this qth and qth2*/ + + passes = get_mloses (sat, skg->qth, qth2, skg->ts, maxdt, 10); + n = g_slist_length (passes); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: %s has %d passes within %.4f days\n"), + __FILE__, __LINE__, sat->nickname, n, maxdt); + + /* add mlos_pass_t items to skg->passes */ + if (passes != NULL) { - mlospass = g_try_new (mlos_pass_t, 1); - if (mlospass != NULL) { - - /* create pass structure items */ - mlospass->catnum = sat->tle.catnr; - tmppass = (mlos_t *) g_slist_nth_data (passes, i); - //printf("Reading MLOS for %s at %s and %s from %f to %f.\n",sat->nickname,skg->qth->name,qth2->name, tmppass->start, tmppass->finish); - - mlospass->pass = g_try_new (mlos_t, 1); - mlospass->pass->start = tmppass->start; - mlospass->pass->finish = tmppass->finish; - - daynum_to_str (aosstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),mlospass->pass->start); - daynum_to_str (losstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),mlospass->pass->finish); - - - /* box tooltip will contain pass summary */ - tooltip = g_strdup_printf("<big><b>%s with %s</b>\n</big>\n" \ - "<tt>MAOS: %s\n" \ - "MLOS: %s</tt>\n" \ - "\n<i>Click for details</i>", - sat->nickname, - qth2->name, - aosstr, - losstr); + /* add pass items */ + for (i = 0; i < n; i++) { - mlospass->box = goo_canvas_rect_model_new (root, 10, 10, 20, 20, /* dummy coordinates */ - "stroke-color-rgba", bcol, - "fill-color-rgba", fcol, - "line-width", 1.0, - "antialias", CAIRO_ANTIALIAS_NONE, - "tooltip", tooltip, - NULL); - g_free (tooltip); - - /* store this pass in list */ - skg->passes = g_slist_append (skg->passes, mlospass); - //printf("Added MLOS pass for %d from %f to %f.\n",mlospass->catnum,mlospass->pass->start, mlospass->pass->finish); - /* store a pointer to the pass data in the GooCanvasItem so that we - can access it later during various events, e.g mouse click */ - g_object_set_data (G_OBJECT (mlospass->box), "pass", mlospass->pass); - + mlospass = g_try_new (mlos_pass_t, 1); + if (mlospass != NULL) { + + /* create pass structure items */ + mlospass->catnum = sat->tle.catnr; + mlospass->qthnum = jj; + tmppass = (mlos_t *) g_slist_nth_data (passes, i); + mlospass->pass = copy_mlos(tmppass); + + daynum_to_str (aosstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),mlospass->pass->start); + daynum_to_str (losstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),mlospass->pass->finish); + + + /* box tooltip will contain pass summary */ + tooltip = g_strdup_printf("<big><b>%s with %s</b>\n</big>\n" \ + "<tt>MAOS: %s\n" \ + "MLOS: %s</tt>\n" \ + "\n<i>Click for details</i>", + sat->nickname, + qth2->name, + aosstr, + losstr); + + mlospass->box = goo_canvas_rect_model_new (root, 10, 10, 20, 20, /* dummy coordinates */ + "stroke-color-rgba", bcol, + "fill-color-rgba", fcol, + "line-width", 1.0, + "antialias", CAIRO_ANTIALIAS_NONE, + "tooltip", tooltip, + NULL); + g_free (tooltip); + + /* store this pass in list */ + skg->passes = g_slist_append (skg->passes, mlospass); + + /* store a pointer to the pass data in the GooCanvasItem so that we + can access it later during various events, e.g mouse click */ + g_object_set_data (G_OBJECT (mlospass->box), "pass", mlospass->pass); + + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Could not allocate memory for pass object"), + __FILE__, __LINE__); + } + } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Could not allocate memory for pass object"), - __FILE__, __LINE__); - } - + + free_mloses (passes); + + /* add satellite label */ + tmplab = g_strdup_printf ("%s with %s",sat->nickname,qth2->name); + lab = goo_canvas_text_model_new (root, tmplab, + 5, 0, -1, GTK_ANCHOR_W, + "font", "Sans 8", + "fill-color-rgba", bcol, + NULL); + skg->satlab = g_slist_append (skg->satlab, lab); } - - //free_passes (passes); - - /* add satellite label */ - lab = goo_canvas_text_model_new (root, sat->nickname, - 5, 0, -1, GTK_ANCHOR_W, - "font", "Sans 8", - "fill-color-rgba", bcol, - NULL); - skg->satlab = g_slist_append (skg->satlab, lab); } - } } Modified: branches/mlos/src/gtk-mlos-glance.h =================================================================== --- branches/mlos/src/gtk-mlos-glance.h 2011-04-03 14:51:33 UTC (rev 812) +++ branches/mlos/src/gtk-mlos-glance.h 2011-04-03 16:04:20 UTC (rev 813) @@ -57,6 +57,7 @@ /** \brief Satellite object on graph. */ typedef struct { guint catnum; /*!< Catalogue number of satellite */ + guint qthnum; /*!< list element number of satellite */ mlos_t *pass; /*!< Details of the corresponding pass. */ GooCanvasItemModel *box; /*!< Canvas item showing the pass */ } mlos_pass_t; Modified: branches/mlos/src/gtk-sat-module-popup.c =================================================================== --- branches/mlos/src/gtk-sat-module-popup.c 2011-04-03 14:51:33 UTC (rev 812) +++ branches/mlos/src/gtk-sat-module-popup.c 2011-04-03 16:04:20 UTC (rev 813) @@ -157,7 +157,7 @@ G_CALLBACK (sky_at_glance_cb), module); /* mlos */ - menuitem = gtk_image_menu_item_new_with_label (_("MLOS at a glance")); + menuitem = gtk_image_menu_item_new_with_label (_("Mutual Contact")); buff = icon_file_name ("gpredict-planner-small.png"); image = gtk_image_new_from_file (buff); g_free (buff); @@ -846,7 +846,7 @@ /* create window */ module->mloswin = gtk_window_new (GTK_WINDOW_TOPLEVEL); - buff = g_strdup_printf (_("The MLOS win (%s)"), module->name); + buff = g_strdup_printf (_("The Mutual Contact Window (%s)"), module->name); gtk_window_set_title (GTK_WINDOW (module->mloswin), buff); g_free (buff); g_signal_connect (G_OBJECT (module->mloswin), "delete_event", G_CALLBACK (window_delete), NULL); Modified: branches/mlos/src/predict-tools.c =================================================================== --- branches/mlos/src/predict-tools.c 2011-04-03 14:51:33 UTC (rev 812) +++ branches/mlos/src/predict-tools.c 2011-04-03 16:04:20 UTC (rev 813) @@ -457,7 +457,7 @@ pass = get_mlos (sat, qth, qth2, t, maxdt); if (pass != NULL) { passes = g_slist_prepend (passes, pass); - t = pass->finish + 0.014; + t = pass->finish + 0.014; /* twenty minute ?*/ if ((maxdt > 0.0) && (t >= (start+maxdt))) { i = num; } @@ -482,9 +482,7 @@ gdouble temptime; gboolean valid=FALSE; gboolean done=FALSE; - gdouble aos1,aos2,los1,los2,t; - mlos = g_new (mlos_t, 1); /* get information on the first qth with that satellite */ predict_calc(sat,qth1,start); @@ -494,6 +492,9 @@ pass1=get_pass(sat,qth1,start,maxdt); } /* + for testing to make sure it matches sky at a glance + */ + /* done=TRUE; valid=TRUE; mlos->start=pass1->aos; @@ -521,6 +522,8 @@ free_pass(pass2); pass2=get_pass(sat,qth2,temptime,maxdt+start-temptime); } else { + mlos = g_new (mlos_t, 1); + /*passes overlap*/ if (pass1->aos < pass2->aos) { /*passes have overlap and pass1 starts first*/ @@ -551,7 +554,6 @@ return (mlos); } else { - g_free( mlos); return NULL; } return NULL; @@ -1073,3 +1075,38 @@ } return pass; } + +mlos_t * +copy_mlos ( mlos_t *mlos) +{ + mlos_t *new; + + new = g_try_new(pass_t,1); + + if (new != NULL) { + new->start = mlos->start; + new->finish = mlos->finish; + } +} + +void +free_mloses (GSList *mloses) +{ + guint n,i; + gpointer mlos; + + n = g_slist_length (mloses); + + for (i = 0; i < n; i++) { + + mlos = g_slist_nth_data (mloses, i); + + /* free element data */ + g_free (mlos); + + } + + /* now free the list elements */ + g_slist_free (mloses); + mloses = NULL; +} Modified: branches/mlos/src/predict-tools.h =================================================================== --- branches/mlos/src/predict-tools.h 2011-04-03 14:51:33 UTC (rev 812) +++ branches/mlos/src/predict-tools.h 2011-04-03 16:04:20 UTC (rev 813) @@ -114,12 +114,14 @@ GSList *get_mloses (sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt, guint num); /* copying */ pass_t *copy_pass (pass_t *pass); +mlos_t *copy_mlos (mlos_t *pass); GSList *copy_pass_details (GSList *details); pass_detail_t *copy_pass_detail (pass_detail_t *detail); /* memory cleaning */ void free_pass (pass_t *pass); void free_passes (GSList *passes); +void free_mloses (GSList *mloses); void free_pass_detail (pass_detail_t *detail); void free_pass_details (GSList *details); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2011-04-03 14:51:39
|
Revision: 812 http://gpredict.svn.sourceforge.net/gpredict/?rev=812&view=rev Author: csete Date: 2011-04-03 14:51:33 +0000 (Sun, 03 Apr 2011) Log Message: ----------- Updated user manual with info about using mouse wheel on frequency and rotor digits. Modified Paths: -------------- trunk/ChangeLog trunk/doc/um/gpredict-user-manual.odt Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-04-03 14:45:09 UTC (rev 811) +++ trunk/ChangeLog 2011-04-03 14:51:33 UTC (rev 812) @@ -6,6 +6,9 @@ * src/gtk-freq-knob.h Allow changing radio frequency and rotator position using mouse buttons and wheel (feature req 2130926). Up/down arrows are kept for now. + + * doc/um/gpredict-user-manual.odt + Updated with info about using the mouse wheel over the digits. 2011-04-01 Charles Suprin <hamaa1vs at gmail.com> Modified: trunk/doc/um/gpredict-user-manual.odt =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2011-04-03 14:45:15
|
Revision: 811 http://gpredict.svn.sourceforge.net/gpredict/?rev=811&view=rev Author: csete Date: 2011-04-03 14:45:09 +0000 (Sun, 03 Apr 2011) Log Message: ----------- Updated. Modified Paths: -------------- trunk/NEWS Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2011-04-03 14:41:24 UTC (rev 810) +++ trunk/NEWS 2011-04-03 14:45:09 UTC (rev 811) @@ -1,10 +1,12 @@ Changes in version 1.4 (TBD) - 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 - Improve handling of decayed satellites. - Fixed bug 3250344: Win32 uild not working with hamlib + Changes in version 1.3 (1 Mar 2011) - Feature request 2873824: Flip Passes. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2011-04-03 14:41:31
|
Revision: 810 http://gpredict.svn.sourceforge.net/gpredict/?rev=810&view=rev Author: csete Date: 2011-04-03 14:41:24 +0000 (Sun, 03 Apr 2011) Log Message: ----------- Allow changing radio frequency and rotator position using mouse buttons and wheel (feature req 2130926). Up/down arrows are kept for now. Modified Paths: -------------- trunk/ChangeLog trunk/src/gtk-freq-knob.c trunk/src/gtk-freq-knob.h trunk/src/gtk-rot-knob.c trunk/src/gtk-rot-knob.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-04-03 13:21:00 UTC (rev 809) +++ trunk/ChangeLog 2011-04-03 14:41:24 UTC (rev 810) @@ -1,3 +1,13 @@ +2011-04-03 Alexandru Csete <oz9aec at gmail.com> + + * src/gtk-rot-knob.c + * src/gtk-rot-knob.h + * src/gtk-freq-knob.c + * src/gtk-freq-knob.h + Allow changing radio frequency and rotator position using mouse buttons + and wheel (feature req 2130926). Up/down arrows are kept for now. + + 2011-04-01 Charles Suprin <hamaa1vs at gmail.com> * win32/gpredict.rc @@ -5,6 +15,7 @@ * win32/build-config.h Apply Alan Moffet's changes for win32 build. + 2011-04-01 Alexandru Csete <oz9aec at gmail.com> * src/pass-to-txt.c @@ -30,6 +41,7 @@ * src/gtk-sat-selector.c Remove strverscmp reference. + 2011-03-27 Charles Suprin <hamaa1vs at gmail.com> * src/gtk-azel-plot.c Modified: trunk/src/gtk-freq-knob.c =================================================================== --- trunk/src/gtk-freq-knob.c 2011-04-03 13:21:00 UTC (rev 809) +++ trunk/src/gtk-freq-knob.c 2011-04-03 14:41:24 UTC (rev 810) @@ -49,7 +49,10 @@ static void gtk_freq_knob_destroy (GtkObject *object); static void gtk_freq_knob_update (GtkFreqKnob *knob); static void button_clicked_cb (GtkWidget *button, gpointer data); +static gboolean on_button_press (GtkWidget *digit, GdkEventButton *event, gpointer data); +static gboolean on_button_scroll (GtkWidget *digit, GdkEventScroll *event, gpointer data); + static GtkHBoxClass *parent_class = NULL; #define FMTSTR "<span size='xx-large'>%c</span>" @@ -164,7 +167,7 @@ gint delta; - widget = g_object_new (GTK_TYPE_FREQ_KNOB, NULL); + widget = g_object_new (GTK_TYPE_FREQ_KNOB, NULL); GTK_FREQ_KNOB(widget)->value = val; @@ -174,10 +177,32 @@ for (i = 0; i < 10; i++) { /* labels */ GTK_FREQ_KNOB(widget)->digits[i] = gtk_label_new (NULL); - gtk_table_attach (GTK_TABLE (table), GTK_FREQ_KNOB(widget)->digits[i], - idx[i], idx[i]+1, 1, 2, GTK_SHRINK, GTK_FILL | GTK_EXPAND, 0, 0); - - if (buttons) { + + if (!buttons) { + /* passive display widget without event boxes or buttons */ + gtk_table_attach (GTK_TABLE (table), GTK_FREQ_KNOB(widget)->digits[i], + idx[i], idx[i]+1, 1, 2, GTK_SHRINK, GTK_FILL | GTK_EXPAND, 0, 0); + } + else { + /* active widget that allows changing the value */ + + gtk_widget_set_tooltip_text(GTK_FREQ_KNOB(widget)->digits[i], + _("Use mouse buttons and wheel to change value")); + + /* Event boxes for catching mouse evetns */ + GTK_FREQ_KNOB(widget)->evtbox[i] = gtk_event_box_new (); + g_object_set_data(G_OBJECT(GTK_FREQ_KNOB(widget)->evtbox[i]), "index", GUINT_TO_POINTER(i)); + gtk_container_add(GTK_CONTAINER(GTK_FREQ_KNOB(widget)->evtbox[i]), + GTK_FREQ_KNOB(widget)->digits[i]); + gtk_table_attach (GTK_TABLE (table), GTK_FREQ_KNOB(widget)->evtbox[i], + idx[i], idx[i]+1, 1, 2, GTK_SHRINK, GTK_FILL | GTK_EXPAND, 0, 0); + + g_signal_connect (GTK_FREQ_KNOB(widget)->evtbox[i], "button_press_event", + (GtkSignalFunc) on_button_press, widget); + g_signal_connect (GTK_FREQ_KNOB(widget)->evtbox[i], "scroll_event", + (GtkSignalFunc) on_button_scroll, widget); + + /* UP buttons */ GTK_FREQ_KNOB(widget)->buttons[i] = gtk_button_new (); @@ -232,12 +257,12 @@ gtk_container_add (GTK_CONTAINER (widget), table); gtk_widget_show_all (widget); - return widget; + return widget; } /** \brief Set the value of the frequency control widget. - * \param[in] knob THe frequency control widget. + * \param[in] knob The frequency control widget. * \param[in] val The new value. * */ @@ -316,3 +341,138 @@ g_signal_emit (G_OBJECT (data), freq_changed_signal, 0); } + +/** \brief Manage button press events + * \param digit Pointer to the event box that received the event + * \param event Pointer to the GdkEventButton that contains details for te event + * \param data Pointer to the GtkFreqKnob widget (we need it to update the value) + * \return Always TRUE to prevent further propagation of the event + * + * This function is called when a mouse button is pressed on a digit. This is used + * to increment or decrement the value: + * - Left button: up + * - Right button: down + * - Middle button: set digit to 0 (TBC) + * + * Wheel up/down are managed in a separate callback since these are treated as scroll events + * rather than button press events (they used to be button press events though) + * + * The digit labels are stored in an array. To get the amount of change corresponding to the + * clicked label we can convert the index (attached to the evtbox): delta = 10^(9-index) + * + * Whether the delta is positive or negative depends on which mouse button triggered the event. + */ +static gboolean on_button_press (GtkWidget *evtbox, + GdkEventButton *event, + gpointer data) +{ + GtkFreqKnob *knob = GTK_FREQ_KNOB(data); + guint idx = GPOINTER_TO_UINT(g_object_get_data (G_OBJECT (evtbox), "index")); + gdouble delta = pow(10, 9-idx); + gdouble value; + + + if (delta < 1.0) { + /* no change */ + return TRUE; + } + + if (event->type != GDK_BUTTON_PRESS) { + /* wrong event (not possible?) */ + return TRUE; + } + + + switch (event->button) { + + /* left button */ + case 1: + value = gtk_freq_knob_get_value(knob) + delta; + gtk_freq_knob_set_value(knob, value); + g_signal_emit(G_OBJECT (data), freq_changed_signal, 0); + break; + + /* middle button */ + case 2: + break; + + /* right button */ + case 3: + value = gtk_freq_knob_get_value(knob) - delta; + gtk_freq_knob_set_value(knob, value); + g_signal_emit(G_OBJECT (data), freq_changed_signal, 0); + break; + + default: + break; + } + + + return TRUE; +} + +/** \brief Manage scroll wheel events + * \param digit Pointer to the event box that received the event + * \param event Pointer to the GdkEventScroll that contains details for te event + * \param data Pointer to the GtkFreqKnob widget (we need it to update the value) + * \return Always TRUE to prevent further propagation of the event + * + * This function is called when the mouse wheel is moved up or down. This is used to increment + * or decrement the value. + * + * Button presses are managed in a separate callback since these are treated as different + * events. + * + * The digit labels are stored in an array. To get the amount of change corresponding to the + * clicked label we can convert the index (attached to the evtbox): delta = 10^(9-index) + * + * Whether the delta is positive or negative depends on the scroll direction. + */ +static gboolean on_button_scroll (GtkWidget *evtbox, + GdkEventScroll *event, + gpointer data) +{ + GtkFreqKnob *knob = GTK_FREQ_KNOB(data); + guint idx = GPOINTER_TO_UINT(g_object_get_data (G_OBJECT (evtbox), "index")); + gdouble delta = pow(10, 9-idx); + gdouble value; + + + if (delta < 0.01) { + /* no change, user clicked on sign or decimal separator */ + return TRUE; + } + + if (event->type != GDK_SCROLL) { + /* wrong event (not possible?) */ + return TRUE; + } + + + switch (event->direction) { + + /* decrease value by delta */ + case GDK_SCROLL_DOWN: + case GDK_SCROLL_LEFT: + value = gtk_freq_knob_get_value(knob) - delta; + gtk_freq_knob_set_value(knob, value); + g_signal_emit(G_OBJECT (data), freq_changed_signal, 0); + break; + + /* increase value by delta */ + case GDK_SCROLL_UP: + case GDK_SCROLL_RIGHT: + value = gtk_freq_knob_get_value(knob) + delta; + gtk_freq_knob_set_value(knob, value); + g_signal_emit(G_OBJECT (data), freq_changed_signal, 0); + break; + + default: + break; + } + + + return TRUE; +} + + Modified: trunk/src/gtk-freq-knob.h =================================================================== --- trunk/src/gtk-freq-knob.h 2011-04-03 13:21:00 UTC (rev 809) +++ trunk/src/gtk-freq-knob.h 2011-04-03 14:41:24 UTC (rev 810) @@ -62,6 +62,7 @@ GtkVBox vbox; GtkWidget *digits[10]; /*!< Labels for the digits */ + GtkWidget *evtbox[10]; /*!< Event boxes to catch mouse events over the digits */ GtkWidget *buttons[20]; /*!< Buttons; 0..9 up; 10..19 down */ gdouble min; Modified: trunk/src/gtk-rot-knob.c =================================================================== --- trunk/src/gtk-rot-knob.c 2011-04-03 13:21:00 UTC (rev 809) +++ trunk/src/gtk-rot-knob.c 2011-04-03 14:41:24 UTC (rev 810) @@ -52,13 +52,15 @@ static void gtk_rot_knob_update (GtkRotKnob *knob); static void button_clicked_cb (GtkWidget *button, gpointer data); +static gboolean on_button_press (GtkWidget *digit, GdkEventButton *event, gpointer data); +static gboolean on_button_scroll (GtkWidget *digit, GdkEventScroll *event, gpointer data); - static GtkHBoxClass *parent_class = NULL; +/** \brief Convert digit index (in the digit array) to amount of change. */ +const gdouble INDEX_TO_DELTA[] = {0.0, 100.0, 10.0, 1.0, 0.0, 0.1, 0.01}; - GType gtk_rot_knob_get_type () @@ -145,10 +147,10 @@ GTK_ROT_KNOB(widget)->min = min; GTK_ROT_KNOB(widget)->max = max; GTK_ROT_KNOB(widget)->value = val; - + /* create table */ table = gtk_table_new (3, 8, FALSE); - + /* create buttons */ /* +100 deg */ GTK_ROT_KNOB(widget)->buttons[0] = gtk_button_new (); @@ -282,9 +284,23 @@ /* create labels */ for (i = 0; i < 7; i++) { + /* labels showing the digits */ GTK_ROT_KNOB(widget)->digits[i] = gtk_label_new (NULL); - gtk_table_attach (GTK_TABLE (table), GTK_ROT_KNOB(widget)->digits[i], + gtk_widget_set_tooltip_text(GTK_ROT_KNOB(widget)->digits[i], + _("Use mouse buttons and wheel to change value")); + + /* Event boxes for catching mouse evetns */ + GTK_ROT_KNOB(widget)->evtbox[i] = gtk_event_box_new (); + g_object_set_data(G_OBJECT(GTK_ROT_KNOB(widget)->evtbox[i]), "index", GUINT_TO_POINTER(i)); + gtk_container_add(GTK_CONTAINER(GTK_ROT_KNOB(widget)->evtbox[i]), GTK_ROT_KNOB(widget)->digits[i]); + gtk_table_attach (GTK_TABLE (table), GTK_ROT_KNOB(widget)->evtbox[i], i, i+1, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0); + + g_signal_connect (GTK_ROT_KNOB(widget)->evtbox[i], "button_press_event", + (GtkSignalFunc) on_button_press, widget); + g_signal_connect (GTK_ROT_KNOB(widget)->evtbox[i], "scroll_event", + (GtkSignalFunc) on_button_scroll, widget); + } /* degree sign */ @@ -296,10 +312,9 @@ gtk_rot_knob_update (GTK_ROT_KNOB(widget)); gtk_container_add (GTK_CONTAINER (widget), table); - gtk_widget_show_all (widget); + gtk_widget_show_all (widget); - - return widget; + return widget; } @@ -474,3 +489,130 @@ } +/** \brief Manage button press events + * \param digit Pointer to the event box that received the event + * \param event Pointer to the GdkEventButton that contains details for te event + * \param data Pointer to the GtkRotKnob widget (we need it to update the value) + * \return Always TRUE to prevent further propagation of the event + * + * This function is called when a mouse button is pressed on a digit. This is used + * to increment or decrement the value: + * - Left button: up + * - Right button: down + * - Middle button: set digit to 0 (TBC) + * + * Wheel up/down are managed in a separate callback since these are treated as scroll events + * rather than button press events (they used to be button press events though) + * + * The digit labels are stored in an array that also contains the sign and the + * decimal separator. To get the amount of change corresponding to the clicked label we + * can use the INDEX_TO_DELTA[] array. The index to this table is attached to the evtbox. + * Whether the delta is positive or negative depends on which mouse button triggered the event. + */ +static gboolean on_button_press (GtkWidget *evtbox, + GdkEventButton *event, + gpointer data) +{ + GtkRotKnob *knob = GTK_ROT_KNOB(data); + guint idx = GPOINTER_TO_UINT(g_object_get_data (G_OBJECT (evtbox), "index")); + gdouble delta = INDEX_TO_DELTA[idx]; + gdouble value; + + if (delta < 0.01) { + /* no change, user clicked on sign or decimal separator */ + return TRUE; + } + + if (event->type != GDK_BUTTON_PRESS) { + /* wrong event (not possible?) */ + return TRUE; + } + + + switch (event->button) { + + /* left button */ + case 1: + value = gtk_rot_knob_get_value(knob) + delta; + gtk_rot_knob_set_value(knob, value); + break; + + /* middle button */ + case 2: + break; + + /* right button */ + case 3: + value = gtk_rot_knob_get_value(knob) - delta; + gtk_rot_knob_set_value(knob, value); + break; + + default: + break; + } + + + return TRUE; +} + +/** \brief Manage scroll wheel events + * \param digit Pointer to the event box that received the event + * \param event Pointer to the GdkEventScroll that contains details for te event + * \param data Pointer to the GtkRotKnob widget (we need it to update the value) + * \return Always TRUE to prevent further propagation of the event + * + * This function is called when the mouse wheel is moved up or down. This is used to increment + * or decrement the value. + * + * Button presses are managed in a separate callback since these are treated as different + * events. + * + * The digit labels are stored in an array that also contains the sign and the + * decimal separator. To get the amount of change corresponding to the clicked label we + * can use the INDEX_TO_DELTA[] array. The index is attached to the evtbox. + * Whether the delta is positive or negative depends on the scroll direction. + */ +static gboolean on_button_scroll (GtkWidget *evtbox, + GdkEventScroll *event, + gpointer data) +{ + GtkRotKnob *knob = GTK_ROT_KNOB(data); + guint idx = GPOINTER_TO_UINT(g_object_get_data (G_OBJECT (evtbox), "index")); + gdouble delta = INDEX_TO_DELTA[idx]; + gdouble value; + + if (delta < 0.01) { + /* no change, user clicked on sign or decimal separator */ + return TRUE; + } + + if (event->type != GDK_SCROLL) { + /* wrong event (not possible?) */ + return TRUE; + } + + + switch (event->direction) { + + /* decrease value by delta */ + case GDK_SCROLL_DOWN: + case GDK_SCROLL_LEFT: + value = gtk_rot_knob_get_value(knob) - delta; + gtk_rot_knob_set_value(knob, value); + break; + + /* increase value by delta */ + case GDK_SCROLL_UP: + case GDK_SCROLL_RIGHT: + value = gtk_rot_knob_get_value(knob) + delta; + gtk_rot_knob_set_value(knob, value); + break; + + default: + break; + } + + + return TRUE; +} + Modified: trunk/src/gtk-rot-knob.h =================================================================== --- trunk/src/gtk-rot-knob.h 2011-04-03 13:21:00 UTC (rev 809) +++ trunk/src/gtk-rot-knob.h 2011-04-03 14:41:24 UTC (rev 810) @@ -59,9 +59,10 @@ struct _gtk_rot_knob { - GtkVBox vbox; + GtkVBox vbox; GtkWidget *digits[7]; /*!< Labels for the digits */ + GtkWidget *evtbox[7]; /*!< Event boxes to catch mouse events over the digits */ GtkWidget *buttons[10]; /*!< Buttons; 0..4 up; 5..9 down */ gdouble min; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-04-03 13:21:07
|
Revision: 809 http://gpredict.svn.sourceforge.net/gpredict/?rev=809&view=rev Author: aa1vs Date: 2011-04-03 13:21:00 +0000 (Sun, 03 Apr 2011) Log Message: ----------- Demonstrate initial implementation of get_mlos and get_mloses with sky at glance like window. Modified Paths: -------------- branches/mlos/ChangeLog branches/mlos/src/Makefile.am branches/mlos/src/gtk-sat-module-popup.c branches/mlos/src/gtk-sat-module.c branches/mlos/src/gtk-sat-module.h branches/mlos/src/predict-tools.c branches/mlos/src/predict-tools.h Added Paths: ----------- branches/mlos/src/gtk-mlos-glance.c branches/mlos/src/gtk-mlos-glance.h Modified: branches/mlos/ChangeLog =================================================================== --- branches/mlos/ChangeLog 2011-04-02 02:44:13 UTC (rev 808) +++ branches/mlos/ChangeLog 2011-04-03 13:21:00 UTC (rev 809) @@ -1,3 +1,15 @@ +2011-04-03 Charles Suprin <hamaa1vs at gmail.com> + + * src/gtk-sat-module-popup.c + * src/Makefile.am + * src/gtk-sat-module.c + * src/gtk-sat-module.h + * src/gtk-mlos-glance.c + * src/gtk-mlos-glance.h + * src/predict-tools.c + * src/predict-tools.h + Demonstrate initial implementation of get_mlos and get_mloses with sky at glance like window. + 2011-04-01 Charles Suprin <hamaa1vs at gmail.com> * win32/gpredict.rc Modified: branches/mlos/src/Makefile.am =================================================================== --- branches/mlos/src/Makefile.am 2011-04-02 02:44:13 UTC (rev 808) +++ branches/mlos/src/Makefile.am 2011-04-03 13:21:00 UTC (rev 809) @@ -56,6 +56,7 @@ gtk-sat-selector.c gtk-sat-selector.h \ gtk-single-sat.c gtk-single-sat.h \ gtk-sky-glance.c gtk-sky-glance.h \ + gtk-mlos-glance.c gtk-mlos-glance.h \ gui.c gui.h \ loc-tree.c loc-tree.h \ locator.c locator.h \ Added: branches/mlos/src/gtk-mlos-glance.c =================================================================== --- branches/mlos/src/gtk-mlos-glance.c (rev 0) +++ branches/mlos/src/gtk-mlos-glance.c 2011-04-03 13:21:00 UTC (rev 809) @@ -0,0 +1,1099 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2010 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ +*/ +/** \brief Mlos at a glance Widget. + * + * The mlos at a glance widget provides a convenient overview of the upcoming + * satellite passes in a timeline format. The widget is tied to a specific + * module and uses the QTH and satellite data from the module. + * + * Note about the sizing policy: + * Initially we require 10 pixels per sat + 5 pix margin between the sats. + * + * When we get additional space due to resizing, the space will be allocated + * to make the rectangles taller. + * + */ +#include <gtk/gtk.h> +#include <glib/gi18n.h> +#include "sgpsdp/sgp4sdp4.h" +#include "sat-log.h" +#include "config-keys.h" +#include "sat-cfg.h" +#include "mod-cfg-get-param.h" +#include "time-tools.h" +#include "gtk-sat-data.h" +#include "gpredict-utils.h" +#include "predict-tools.h" +#include "sat-pass-dialogs.h" +#include "time-tools.h" +//#include "gtk-mlos-glance-popup.h" +#include "gtk-mlos-glance.h" +#ifdef HAVE_CONFIG_H +# include <build-config.h> +#endif +#include <goocanvas.h> + + + +#define SKG_DEFAULT_WIDTH 600 +#define SKG_DEFAULT_HEIGHT 300 +#define SKG_PIX_PER_SAT 10 +#define SKG_MARGIN 15 +#define SKG_FOOTER 50 + + +static void gtk_mlos_glance_class_init (GtkMlosGlanceClass *class); +static void gtk_mlos_glance_init (GtkMlosGlance *skg); +static void gtk_mlos_glance_destroy (GtkObject *object); +static void size_allocate_cb (GtkWidget *widget, + GtkAllocation *allocation, + gpointer data); +static gboolean on_motion_notify (GooCanvasItem *item, + GooCanvasItem *target, + GdkEventMotion *event, + gpointer data); +static void on_item_created (GooCanvas *canvas, + GooCanvasItem *item, + GooCanvasItemModel *model, + gpointer data); +static void on_canvas_realized (GtkWidget *canvas, gpointer data); +static gboolean on_button_press (GooCanvasItem *item, + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); +static gboolean on_button_release (GooCanvasItem *item, + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); + +static gboolean on_mouse_enter (GooCanvasItem *item, + GooCanvasItem *target_item, + GdkEventCrossing *event, + gpointer data); +static gboolean on_mouse_leave (GooCanvasItem *item, + GooCanvasItem *target_item, + GdkEventCrossing *event, + gpointer data); + + +static GooCanvasItemModel* create_canvas_model (GtkMlosGlance *skg); + + +static void create_sat (gpointer key, gpointer value, gpointer data); + +static gdouble t2x (GtkMlosGlance *skg, gdouble t); +static gdouble x2t (GtkMlosGlance *skg, gdouble x); + +static GtkVBoxClass *parent_class = NULL; + + +GtkType +gtk_mlos_glance_get_type () +{ + static GType gtk_mlos_glance_type = 0; + + if (!gtk_mlos_glance_type) { + static const GTypeInfo gtk_mlos_glance_info = { + sizeof (GtkMlosGlanceClass), + NULL, /* base init */ + NULL, /* base finalise */ + (GClassInitFunc) gtk_mlos_glance_class_init, + NULL, /* class finalise */ + NULL, /* class data */ + sizeof (GtkMlosGlance), + 1, /* n_preallocs */ + (GInstanceInitFunc) gtk_mlos_glance_init, + }; + + gtk_mlos_glance_type = g_type_register_static (GTK_TYPE_VBOX, + "GtkMlosGlance", + >k_mlos_glance_info, + 0); + } + + return gtk_mlos_glance_type; +} + + +static void +gtk_mlos_glance_class_init (GtkMlosGlanceClass *class) +{ + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; + + gobject_class = G_OBJECT_CLASS (class); + object_class = (GtkObjectClass*) class; + widget_class = (GtkWidgetClass*) class; + container_class = (GtkContainerClass*) class; + + parent_class = g_type_class_peek_parent (class); + + object_class->destroy = gtk_mlos_glance_destroy; + //widget_class->size_allocate = gtk_mlos_glance_size_allocate; +} + + +static void +gtk_mlos_glance_init (GtkMlosGlance *skg) +{ + skg->sats = NULL; + skg->qth = NULL; + skg->passes = NULL; + skg->satlab = NULL; + skg->x0 = 0; + skg->y0 = 0; + skg->w = 0; + skg->h = 0; + skg->pps = 0; + skg->numsat = 0; + skg->numqth = 0; + skg->paircnt = 0; + skg->ts = 0.0; + skg->te = 0.0; +} + + +/** \brief Destroy the GtkMlosGlance widget + * \param object Pointer to the GtkMlosGlance widget + * + * This function is called when the GtkMlosGlance widget is destroyed. It frees + * the memory that has been allocated when the widget was created. + * + * \bug For some reason, this function is called twice when parent is destroyed. + */ +static void +gtk_mlos_glance_destroy (GtkObject *object) +{ + mlos_pass_t *mlospass; + guint i, n; + + + /* free passes */ + /* FIXME: TBC whether this is enough */ + if (GTK_MLOS_GLANCE (object)->passes != NULL) { + + n = g_slist_length (GTK_MLOS_GLANCE (object)->passes); + for (i = 0; i < n; i++) { + mlospass = (mlos_pass_t *) g_slist_nth_data (GTK_MLOS_GLANCE (object)->passes, i); + g_free (mlospass->pass); + g_free (mlospass); + } + + g_slist_free (GTK_MLOS_GLANCE (object)->passes); + GTK_MLOS_GLANCE (object)->passes = NULL; + } + + /* for the rest we only need to free the GSList because the + canvas items will be freed when removed from canvas. + */ + if (GTK_MLOS_GLANCE (object)->satlab != NULL) { + g_slist_free (GTK_MLOS_GLANCE (object)->satlab); + GTK_MLOS_GLANCE (object)->satlab = NULL; + } + if (GTK_MLOS_GLANCE (object)->majors != NULL) { + g_slist_free (GTK_MLOS_GLANCE (object)->majors); + GTK_MLOS_GLANCE (object)->majors = NULL; + } + if (GTK_MLOS_GLANCE (object)->minors != NULL) { + g_slist_free (GTK_MLOS_GLANCE (object)->minors); + GTK_MLOS_GLANCE (object)->minors = NULL; + } + if (GTK_MLOS_GLANCE (object)->labels != NULL) { + g_slist_free (GTK_MLOS_GLANCE (object)->labels); + GTK_MLOS_GLANCE (object)->labels = NULL; + } + + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + +} + + + +/** \brief Create a new GtkMlosGlance widget. + * \param sats Pointer to the hash table containing the asociated satellites. + * \param qth Pointer to the ground station data. + * \param ts The t0 for the timeline or 0 to use the current date and time. + */ +GtkWidget* +gtk_mlos_glance_new (GHashTable *sats, qth_t *qth, GHashTable *groundstations, gdouble ts) +{ + GtkWidget *skg; + GooCanvasItemModel *root; + GdkColor bg_color = {0, 0xFFFF, 0xFFFF, 0xFFFF}; + guint number; + + + /* check that we have at least one satellite */ + number = g_hash_table_size (sats); + if (number == 0) { + /* no satellites */ + skg = gtk_label_new (_("This module has no satellites!")); + + return skg; + } + + /* check that we have at least one groundstation */ + number = g_hash_table_size (groundstations); + if (number == 0) { + /* no satellites */ + skg = gtk_label_new (_("This module has no satellites!")); + + return skg; + } + + + + skg = g_object_new (GTK_TYPE_MLOS_GLANCE, NULL); + + /* FIXME? */ + GTK_MLOS_GLANCE (skg)->sats = sats; + GTK_MLOS_GLANCE (skg)->grounds = groundstations; + GTK_MLOS_GLANCE (skg)->qth = qth; + + + /* get settings */ + GTK_MLOS_GLANCE (skg)->numsat = g_hash_table_size (sats); + + /* if ts = 0 use current time */ + if (ts > 0.0) { + GTK_MLOS_GLANCE (skg)->ts = ts; + } + else { + GTK_MLOS_GLANCE (skg)->ts = get_current_daynum (); + } + + GTK_MLOS_GLANCE (skg)->te = GTK_MLOS_GLANCE (skg)->ts + + sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME)*(1.0/24.0); + + /* calculate preferred sizes */ + GTK_MLOS_GLANCE (skg)->w = SKG_DEFAULT_WIDTH; + GTK_MLOS_GLANCE (skg)->h = GTK_MLOS_GLANCE (skg)->numsat * SKG_PIX_PER_SAT + + (GTK_MLOS_GLANCE (skg)->numsat + 1) * SKG_MARGIN; + GTK_MLOS_GLANCE (skg)->pps = SKG_PIX_PER_SAT; + + /* create the canvas */ + GTK_MLOS_GLANCE (skg)->canvas = goo_canvas_new (); + g_object_set (G_OBJECT (GTK_MLOS_GLANCE(skg)->canvas), "has-tooltip", TRUE, NULL); + gtk_widget_modify_base (GTK_MLOS_GLANCE (skg)->canvas, GTK_STATE_NORMAL, &bg_color); + gtk_widget_set_size_request (GTK_MLOS_GLANCE (skg)->canvas, + GTK_MLOS_GLANCE (skg)->w, + GTK_MLOS_GLANCE (skg)->h + SKG_FOOTER); + goo_canvas_set_bounds (GOO_CANVAS (GTK_MLOS_GLANCE (skg)->canvas), 0, 0, + GTK_MLOS_GLANCE (skg)->w, + GTK_MLOS_GLANCE (skg)->h + SKG_FOOTER); + + /* connect size-request signal */ + g_signal_connect (GTK_MLOS_GLANCE (skg)->canvas, "size-allocate", + G_CALLBACK (size_allocate_cb), skg); + g_signal_connect (GTK_MLOS_GLANCE (skg)->canvas, "item_created", + (GtkSignalFunc) on_item_created, skg); + g_signal_connect_after (GTK_MLOS_GLANCE (skg)->canvas, "realize", + (GtkSignalFunc) on_canvas_realized, skg); + + gtk_widget_show (GTK_MLOS_GLANCE (skg)->canvas); + + + /* Create the canvas model */ + root = create_canvas_model (GTK_MLOS_GLANCE (skg)); + goo_canvas_set_root_item_model (GOO_CANVAS (GTK_MLOS_GLANCE (skg)->canvas), root); + + g_object_unref (root); + + /* add satellite passes */ + g_hash_table_foreach (GTK_MLOS_GLANCE (skg)->sats, create_sat, skg); + + gtk_container_add (GTK_CONTAINER (skg), GTK_MLOS_GLANCE (skg)->canvas); + + return skg; +} + + +/** \brief Create the model for the GtkMlosGlance canvas + * \param skg Pointer to the GtkMlosGlance widget + */ +static GooCanvasItemModel * +create_canvas_model (GtkMlosGlance *skg) +{ + GooCanvasItemModel *root; + GooCanvasItemModel *hrt,*hrl,*hrm; + guint i,n; + gdouble th,tm; + gdouble xh,xm; + gchar buff[3]; + + + root = goo_canvas_group_model_new (NULL, NULL); + + /* cursor tracking line */ + skg->cursor = goo_canvas_polyline_model_new_line (root, + skg->x0, skg->y0, skg->x0, skg->h, + "stroke-color-rgba", 0x000000AF, + "line-width", 0.5, + NULL); + + /* time label */ + skg->timel = goo_canvas_text_model_new (root, "--:--", skg->x0 + 5, skg->y0, -1, GTK_ANCHOR_NW, + "font", "Sans 8", + "fill-color-rgba", 0x000000AF, + NULL); + + /* footer */ + skg->footer = goo_canvas_rect_model_new (root, + skg->x0, skg->h, + skg->w, SKG_FOOTER, + "fill-color-rgba", 0x00003FFF, + "stroke-color-rgba", 0xFFFFFFFF, + NULL); + + /* time ticks and labels */ + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) + skg->axisl = goo_canvas_text_model_new (root, _("TIME"), + skg->w / 2, skg->h + SKG_FOOTER - 5, + -1, GTK_ANCHOR_S, + "font", "Sans 9", + "fill-color-rgba", 0xFFFFFFFF, + NULL); + else + skg->axisl = goo_canvas_text_model_new (root, _("UTC"), + skg->w / 2, skg->h + SKG_FOOTER - 5, + -1, GTK_ANCHOR_S, + "font", "Sans 9", + "fill-color-rgba", 0xFFFFFFFF, + NULL); + + /* get the first hour and first 30 min slot */ + th = ceil (skg->ts * 24.0) / 24.0; + + /* workaround for bug 1839140 (first hour incorrexct) */ + th += 0.00069; + + /* the first 30 min tick can be either before + or after the first hour tick + */ + if ((th - skg->ts) > 0.0208333) { + tm = th - 0.0208333; + } + else { + tm = th + 0.0208333; + } + + /* the number of steps equals the number of hours */ + n = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME); + for (i = 0; i < n; i++) { + + /* hour tick */ + xh = t2x (skg, th); + hrt = goo_canvas_polyline_model_new_line (root, xh, skg->h, xh, skg->h + 10, + "stroke-color-rgba", 0xFFFFFFFF, + NULL); + + /* hour tick label */ + daynum_to_str (buff, 3, "%H", th); + + hrl = goo_canvas_text_model_new (root, buff, xh, skg->h + 12, + -1, GTK_ANCHOR_N, + "font", "Sans 8", + "fill-color-rgba", 0xFFFFFFFF, + NULL); + + /* 30 min tick */ + xm = t2x (skg, tm); + hrm = goo_canvas_polyline_model_new_line (root, xm, skg->h, xm, skg->h + 5, + "stroke-color-rgba", 0xFFFFFFFF, + NULL); + + /* store canvas items */ + skg->majors = g_slist_append (skg->majors, hrt); + skg->labels = g_slist_append (skg->labels, hrl); + skg->minors = g_slist_append (skg->minors, hrm); + + th += 0.0416667; + tm += 0.0416667; + } + + return root; +} + + + + +/** \brief Manage new size allocation. + * + * This function is called when the canvas receives a new size allocation, + * e.g. when the container is re-sized. The function re-calculates the graph + * dimensions based on the new canvas size. + */ +static void +size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data) +{ + GtkMlosGlance *skg; + GooCanvasPoints *pts; + GooCanvasItem *obj; + gint i,j,n; + guint curcat; + gdouble th,tm; + gdouble xh,xm; + mlos_pass_t *skp; + gdouble x,y,w,h; + + + if (GTK_WIDGET_REALIZED (widget)) { + + /* get graph dimensions */ + skg = GTK_MLOS_GLANCE (data); + + skg->w = allocation->width; + skg->h = allocation->height - SKG_FOOTER; + skg->x0 = 0; + skg->y0 = 0; + + skg->pps = (skg->h - SKG_MARGIN) / skg->numsat - SKG_MARGIN; + + goo_canvas_set_bounds (GOO_CANVAS (GTK_MLOS_GLANCE (skg)->canvas), 0, 0, + allocation->width, allocation->height); + + + /* update cursor tracking line */ + pts = goo_canvas_points_new (2); + pts->coords[0] = skg->x0; + pts->coords[1] = skg->y0; + pts->coords[2] = skg->x0; + pts->coords[3] = skg->h; + g_object_set (skg->cursor, "points", pts, NULL); + goo_canvas_points_unref (pts); + + /* time label */ + g_object_set (skg->timel, + "x", (gdouble) skg->x0 + 5, + NULL); + + + /* update footer */ + g_object_set (skg->footer, + "x", (gdouble) skg->x0, + "y", (gdouble) skg->h, + "width", (gdouble) skg->w, + "height", (gdouble) SKG_FOOTER, + NULL); + + g_object_set (skg->axisl, + "x", (gdouble) (skg->w / 2), + "y", (gdouble) (skg->h + SKG_FOOTER - 5), + NULL); + + /* get the first hour and first 30 min slot */ + th = ceil (skg->ts * 24.0) / 24.0; + + /* workaround for bug 1839140 (first hour incorrexct) */ + th += 0.00069; + + if ((th - skg->ts) > 0.0208333) { + tm = th - 0.0208333; + } + else { + tm = th + 0.0208333; + } + + /* the number of steps equals the number of hours */ + n = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME); + for (i = 0; i < n; i++) { + xh = t2x (skg, th); + + pts = goo_canvas_points_new (2); + pts->coords[0] = xh; + pts->coords[1] = skg->h; + pts->coords[2] = xh; + pts->coords[3] = skg->h + 10; + + obj = g_slist_nth_data (skg->majors, i); + g_object_set (obj, "points", pts, NULL); + + goo_canvas_points_unref (pts); + + obj = g_slist_nth_data (skg->labels, i); + g_object_set (obj, + "x", (gdouble) xh, + "y", (gdouble) (skg->h + 12), + NULL); + + /* 30 min tick */ + xm = t2x (skg, tm); + + pts = goo_canvas_points_new (2); + pts->coords[0] = xm; + pts->coords[1] = skg->h; + pts->coords[2] = xm; + pts->coords[3] = skg->h + 5; + + obj = g_slist_nth_data (skg->minors, i); + g_object_set (obj, "points", pts, NULL); + + goo_canvas_points_unref (pts); + + th += 0.04167; + tm += 0.04167; + } + + /* update pass items */ + n = g_slist_length (skg->passes); + j = -1; + curcat = 0; + y = 10.0; + h = 10.0; + for (i = 0; i < n; i++) { + + /* get pass */ + skp = (mlos_pass_t *) g_slist_nth_data (skg->passes, i); + //printf("Reading MLOS from %f to %f.\n",skp->pass->start, skp->pass->finish); + + x = t2x (skg, skp->pass->start); + w = t2x (skg, skp->pass->finish) - x; + + if (w>0) { + /* new satellite? */ + if (skp->catnum != curcat) { + j++; + curcat = skp->catnum; + y = j * (skg->pps + SKG_MARGIN) + SKG_MARGIN; + h = skg->pps; + + /* update label */ + obj = g_slist_nth_data (skg->satlab, j); + if (x > (skg->x0 + 100)) + g_object_set (obj, "x", x-5, "y", y+h/2.0, + "anchor", GTK_ANCHOR_E, NULL); + else + g_object_set (obj, "x", x+w+5, "y", y+h/2.0, + "anchor", GTK_ANCHOR_W, NULL); + } + + g_object_set (skp->box, + "x", x, + "y", y, + "width", w, + "height", h, + NULL); + } + } + + } +} + + +/** \brief Manage canvas realise signals. + * + * This function is used to re-initialise the graph dimensions when + * the graph is realized, i.e. displayed for the first time. This is + * necessary in order to compensate for missing "re-allocate" signals for + * graphs that have not yet been realised, e.g. when opening several module + */ +static void +on_canvas_realized (GtkWidget *canvas, gpointer data) +{ + GtkAllocation aloc; + + aloc.width = canvas->allocation.width; + aloc.height = canvas->allocation.height; + size_allocate_cb (canvas, &aloc, data); + +} + + +/** \brief Manage mouse motion events. */ +static gboolean +on_motion_notify (GooCanvasItem *item, + GooCanvasItem *target, + GdkEventMotion *event, + gpointer data) +{ + GtkMlosGlance *skg = GTK_MLOS_GLANCE (data); + GooCanvasPoints *pts; + gdouble t; + gchar buff[6]; + + /* update cursor tracking line and time label */ + pts = goo_canvas_points_new (2); + pts->coords[0] = event->x; + pts->coords[1] = skg->y0; + pts->coords[2] = event->x; + pts->coords[3] = skg->h; + g_object_set (skg->cursor, "points", pts, NULL); + goo_canvas_points_unref (pts); + + /* get time corresponding to x */ + t = x2t (skg, event->x); + + daynum_to_str (buff, 6, "%H:%M", t); + + /* in order to avoid label clipping close to the edges of + the chart, the label is placed left/right of the cursor + tracking line depending on which half we are in. + => Currently disabled, time display stays in upper left corner + */ +/* + if (event->x > (skg->w / 2)) { + g_object_set (skg->timel, + "text", buff, + "x", (gdouble) event->x - 5, + "anchor", GTK_ANCHOR_NE, + NULL); + } + else { + g_object_set (skg->timel, + "text", buff, + "x", (gdouble) event->x + 5, + "anchor", GTK_ANCHOR_NW, + NULL); + } +*/ + g_object_set (skg->timel, + "text", buff, + NULL); + + + + return TRUE; +} + + +/** \brief Finish canvas item setup. + * \param canvas Pointer to the GooCanvas object + * \param item Pointer to the GooCanvasItem that received the signals + * \param model Pointer to the model associated with the GooCanvasItem object + * \param data Pointer to the GtkMlosGlance object. + * + * This function is called when a canvas item is created. Its purpose is to connect + * the corresponding signals to the created items. + */ +static void +on_item_created (GooCanvas *canvas, + GooCanvasItem *item, + GooCanvasItemModel *model, + gpointer data) +{ + if (!goo_canvas_item_model_get_parent (model)) { + /* root item / canvas */ + g_signal_connect (item, "motion_notify_event", (GtkSignalFunc) on_motion_notify, data); + } + + else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection")) { + //g_signal_connect (item, "button_press_event", (GtkSignalFunc) on_button_press, data); + g_signal_connect (item, "button_release_event", (GtkSignalFunc) on_button_release, data); + g_signal_connect (item, "enter_notify_event", (GtkSignalFunc) on_mouse_enter, data); + g_signal_connect (item, "leave_notify_event", (GtkSignalFunc) on_mouse_leave, data); + } +} + + +/** \brief Manage button press events + * \param item The GooCanvasItem object that received the button press event. + * \param target The target of the event (what?). + * \param event Event data, such as X and Y coordinates. + * \param data User data; points to the GtkMlosAtGlance object. + * \return Always TRUE to prevent further propagation of the event. + * + * This function is called when a mouse button is pressed on a satellite pass object. + * If the pressed button is 1 (left) pass details will be show. + */ +static gboolean +on_button_press (GooCanvasItem *item, + GooCanvasItem *target, + GdkEventButton *event, + gpointer data) +{ +/* GooCanvasItemModel *model = goo_canvas_item_get_model (item); */ +/* GtkMlosGlance *skg = GTK_MLOS_GLANCE (data); */ + + + switch (event->button) { + + default: + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s::%s: Button %d has no function..."), + __FILE__, __FUNCTION__, event->button); + + break; + } + + return TRUE; +} + + +/** \brief Manage button release events. + * \param item The GooCanvasItem object that received the button press event. + * \param target The target of the event (what?). + * \param event Event data, such as X and Y coordinates. + * \param data User data; points to the GtkMlosAtGlance object. + * \return Always TRUE to prevent further propagation of the event. + * + * This function is called when the mouse button is released above + * a satellite pass object. + * + * We do not currently use this for anything. + */ +static gboolean +on_button_release (GooCanvasItem *item, + GooCanvasItem *target, + GdkEventButton *event, + gpointer data) +{ + + GooCanvasItemModel *item_model = goo_canvas_item_get_model (item); + GtkMlosGlance *skg = GTK_MLOS_GLANCE (data); + + /* get pointer to pass_t structure */ + mlos_t *pass = (mlos_t *) g_object_get_data(G_OBJECT(item_model), "pass"); + mlos_t *new_pass; + + + if G_UNLIKELY(pass == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s::%s: Could not retrieve mlos_t object"), + __FILE__, __FUNCTION__); + return TRUE; + } + + + switch (event->button) { + + /* LEFT button released */ + case 1: + //new_pass = copy_pass (pass); + //sat_log_log (SAT_LOG_LEVEL_BUG, + // _("%s::%s: Showing pass details for %s - we may have a memory leak here"), + // __FILE__, __FUNCTION__, pass->satname); + + /* show the pass details */ + //show_pass (pass->satname, skg->qth, new_pass, NULL); + + break; + + default: + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s::%s: Button %d has no function..."), + __FILE__, __FUNCTION__, event->button); + break; + } + + return TRUE; +} + + +/** \brief Manage mouse-enter events on canvas items (satellite pass boxes) + * \param item The GooCanvasItem that received the signal + * \param target_item The target if the even (have no idea what this is...) + * \param event Info about the event + * \param data Pointer to the GtkMlosAtGlance object + * \return Always TRUE to prevent further propagation of the event. + * + * This function is used to be notified when the mouse enters over a satellite + * pass box. We could use it to highlihght the pass under the mouse. + */ +static gboolean on_mouse_enter (GooCanvasItem *item, + GooCanvasItem *target_item, + GdkEventCrossing *event, + gpointer data) +{ + GooCanvasItemModel *item_model = goo_canvas_item_get_model (item); + GtkMlosGlance *skg = GTK_MLOS_GLANCE (data); + + /* get pointer to pass_t structure */ + mlos_t *pass = (mlos_t *) g_object_get_data(G_OBJECT(item_model), "pass"); + if G_UNLIKELY(pass == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s::%s: Could not retrieve mlos_t object"), + __FILE__, __FUNCTION__); + return TRUE; + } + + //g_print("Mouse enter: %s AOS:\n"); + + return TRUE; +} + + +/** \brief Manage mouse-leave events on canvas items (satellite pass boxes) + * \param item The GooCanvasItem that received the signal + * \param target_item The target if the even (have no idea what this is...) + * \param event Info about the event + * \param data Pointer to the GtkMlosAtGlance object + * \return Always TRUE to prevent further propagation of the event. + * + * This function is used to be notified when the mouse leaves a satellite + * pass box. + */ +static gboolean on_mouse_leave (GooCanvasItem *item, + GooCanvasItem *target_item, + GdkEventCrossing *event, + gpointer data) +{ + //g_print("Mouse leave\n"); + + return TRUE; +} + + + + + +/** \brief Convert time value to x position. + * \param skg The GtkMlosGlance widget. + * \param t Julian dateuser is presented with brief info about the + * satellite pass and a suggestion to click on the box for more info. + * \return X coordinate. + * + * No error checking is made to ensure that we are within visible range. + * + */ +static gdouble t2x (GtkMlosGlance *skg, gdouble t) +{ + gdouble frac; + + frac = (t - skg->ts) / (skg->te - skg->ts); + + return (skg->x0 + frac * skg->w); + +} + + +/** \brief Convert x coordinate to Julian date. + * \param skg The GtkMlosGlance widget. + * \param x The X coordinate. + * \return The Julian date corresponding to X. + * + * No error checking is made to ensure that we are within visible range. + * + */ +static gdouble x2t (GtkMlosGlance *skg, gdouble x) +{ + gdouble frac; + + frac = (x - skg->x0) / skg->w; + + return (skg->ts + frac * (skg->te - skg->ts)); +} + + +/** \brief Fetch the basic colour and add alpha channel */ +static void get_colours (guint i, guint *bcol, guint *fcol) +{ + guint tmp; + + /* ensure that we are within 1..10 */ + i = i % 10; + + switch (i) { + + case 0: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_01); + break; + + case 1: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_02); + break; + + case 2: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_03); + break; + + case 3: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_04); + break; + + case 4: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_05); + break; + + case 5: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_06); + break; + + case 6: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_07); + break; + + case 7: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_08); + break; + + case 8: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_09); + break; + + case 9: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_10); + break; + + default: + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s:%d: Colour index out of valid range (%d)"), + __FILE__, __LINE__, i); + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_01); + break; + } + + /* border colour is solid with no tranparency */ + *bcol = (tmp * 0x100) | 0xFF; + + /* fill colour is slightly transparent */ + *fcol = (tmp * 0x100) | 0xA0; +} + + +/** \brief Create canvas items for a satellite + * \param key Pointer to the hash key (catnum of sat) + * \param value Pointer to the current satellite. + * \param data Pointer to the GtkMlosGlance object. + * + * This function is called by g_hash_table_foreach with each satellite in the + * satellite hash table. It gets the passes for the current satellite and creates + * the corresponding canvas items. + */ +static void +create_sat (gpointer key, gpointer value, gpointer data) +{ + sat_t *sat = SAT(value); + GtkMlosGlance *skg = GTK_MLOS_GLANCE(data); + GSList *passes = NULL; + GSList *grounds = NULL; + gdouble maxdt; + guint i,n,jj,m; + mlos_t *tmppass = NULL; + qth_t *qth2; + mlos_pass_t *mlospass; + guint bcol,fcol; /* colours */ + GooCanvasItemModel *root; + GooCanvasItemModel *lab; + + /* tooltips vars */ + gchar *tooltip; /* the complete tooltips string */ + gchar aosstr[100]; /* AOS time string */ + gchar losstr[100]; /* LOS time string */ + gchar tcastr[100]; /* TCA time string */ + + + grounds = g_hash_table_get_values (skg->grounds); + /* FIXME: + Include current pass if sat is up now + */ + + /* check that we didn't exceed 10 sats */ + /* if (++skg->satcnt > 10) { */ + /* return; */ + /* } */ + + /* get canvas root */ + root = goo_canvas_get_root_item_model (GOO_CANVAS (skg->canvas)); + + get_colours (skg->paircnt++, &bcol, &fcol); + + maxdt = skg->te - skg->ts; + m = g_slist_length (grounds); + for (jj=0;jj<1;jj++){ + qth2 = QTH(g_slist_nth_data(grounds,jj)); + //printf("Processing %s\n",qth2->name); + + /* get passes for satellite */ + + passes = get_mloses (sat, skg->qth, qth2, skg->ts, maxdt, 10); + n = g_slist_length (passes); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: %s has %d passes within %.4f days\n"), + __FILE__, __LINE__, sat->nickname, n, maxdt); + + /* add mlos_pass_t items to skg->passes */ + if (passes != NULL) { + + /* add pass items */ + for (i = 0; i < n; i++) { + + mlospass = g_try_new (mlos_pass_t, 1); + if (mlospass != NULL) { + + /* create pass structure items */ + mlospass->catnum = sat->tle.catnr; + tmppass = (mlos_t *) g_slist_nth_data (passes, i); + //printf("Reading MLOS for %s at %s and %s from %f to %f.\n",sat->nickname,skg->qth->name,qth2->name, tmppass->start, tmppass->finish); + + mlospass->pass = g_try_new (mlos_t, 1); + mlospass->pass->start = tmppass->start; + mlospass->pass->finish = tmppass->finish; + + daynum_to_str (aosstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),mlospass->pass->start); + daynum_to_str (losstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),mlospass->pass->finish); + + + /* box tooltip will contain pass summary */ + tooltip = g_strdup_printf("<big><b>%s with %s</b>\n</big>\n" \ + "<tt>MAOS: %s\n" \ + "MLOS: %s</tt>\n" \ + "\n<i>Click for details</i>", + sat->nickname, + qth2->name, + aosstr, + losstr); + + mlospass->box = goo_canvas_rect_model_new (root, 10, 10, 20, 20, /* dummy coordinates */ + "stroke-color-rgba", bcol, + "fill-color-rgba", fcol, + "line-width", 1.0, + "antialias", CAIRO_ANTIALIAS_NONE, + "tooltip", tooltip, + NULL); + g_free (tooltip); + + /* store this pass in list */ + skg->passes = g_slist_append (skg->passes, mlospass); + //printf("Added MLOS pass for %d from %f to %f.\n",mlospass->catnum,mlospass->pass->start, mlospass->pass->finish); + /* store a pointer to the pass data in the GooCanvasItem so that we + can access it later during various events, e.g mouse click */ + g_object_set_data (G_OBJECT (mlospass->box), "pass", mlospass->pass); + + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Could not allocate memory for pass object"), + __FILE__, __LINE__); + } + + } + + //free_passes (passes); + + /* add satellite label */ + lab = goo_canvas_text_model_new (root, sat->nickname, + 5, 0, -1, GTK_ANCHOR_W, + "font", "Sans 8", + "fill-color-rgba", bcol, + NULL); + skg->satlab = g_slist_append (skg->satlab, lab); + } + } +} Added: branches/mlos/src/gtk-mlos-glance.h =================================================================== --- branches/mlos/src/gtk-mlos-glance.h (rev 0) +++ branches/mlos/src/gtk-mlos-glance.h 2011-04-03 13:21:00 UTC (rev 809) @@ -0,0 +1,133 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2010 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ +*/ +#ifndef __GTK_MLOS_GLANCE_H__ +#define __GTK_MLOS_GLANCE_H__ 1 + +#include <glib.h> +#include <glib/gi18n.h> +#include <gdk/gdk.h> +#include <gtk/gtkwidget.h> +#include <gtk/gtkvbox.h> +#include "gtk-sat-data.h" +#include "predict-tools.h" +#include <goocanvas.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +#define GTK_MLOS_GLANCE(obj) GTK_CHECK_CAST (obj, gtk_mlos_glance_get_type (), GtkMlosGlance) +#define GTK_MLOS_GLANCE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_mlos_glance_get_type (), GtkMlosGlanceClass) +#define GTK_IS_MLOS_GLANCE(obj) GTK_CHECK_TYPE (obj, gtk_mlos_glance_get_type ()) +#define GTK_TYPE_MLOS_GLANCE (gtk_mlos_glance_get_type ()) +#define IS_GTK_MLOS_GLANCE(obj) GTK_CHECK_TYPE (obj, gtk_mlos_glance_get_type ()) + +typedef struct _GtkMlosGlance GtkMlosGlance; +typedef struct _GtkMlosGlanceClass GtkMlosGlanceClass; + + +/** \brief Satellite object on graph. */ +typedef struct { + guint catnum; /*!< Catalogue number of satellite */ + mlos_t *pass; /*!< Details of the corresponding pass. */ + GooCanvasItemModel *box; /*!< Canvas item showing the pass */ +} mlos_pass_t; + + +#define MLOS_PASS_T(obj) ((mlos_pass_t *)obj) + + +/** \brief GtkMlosglance widget */ +struct _GtkMlosGlance +{ + GtkVBox vbox; + + GtkWidget *canvas; /*!< The canvas widget */ + + GHashTable *sats; /*!< Copy of satellites. */ + GHashTable *grounds; /*!< Copy of groundstations. */ + qth_t *qth; /*!< Pointer to current location. */ + + GSList *passes; /*!< Canvas items representing each pass. + Each element in the list is of type mlos_pass_t. + */ + GSList *satlab; /*!< Canvas items showing satellite names. */ + + + guint x0; /*!< X0 */ + guint y0; /*!< Y0 */ + guint w; /*!< width of the plot */ + guint h; /*!< height of the plot */ + guint pps; /*!< pixels per satellite */ + + guint numsat; /*!< Number of satellites */ + guint numqth; /*!< Number of qth's not the primary */ + guint paircnt; /*!< Counter to keep track of how many satellites we have + plotted so far when creating the boxes. + This is needed to ensure that we do not plot more + than 10 satellites and to know which colour to fetch + from sat-cfg. + */ + gdouble ts,te; /*!< Start and end times (Julian date) */ + + GSList *majors; /*!< Major ticks for every hour */ + GSList *minors; /*!< Minor ticks for every 30 min */ + GSList *labels; /*!< Tick labels for every hour */ + + GooCanvasItemModel *footer; /*!< Footer area with time ticks and labels */ + GooCanvasItemModel *axisl; /*!< Axis label */ + GooCanvasItemModel *cursor; /*!< Vertical line tracking the cursor */ + GooCanvasItemModel *timel; /*!< Label showing time under cursor */ + +}; + +struct _GtkMlosGlanceClass +{ + GtkVBoxClass parent_class; +}; + + + +GtkType gtk_mlos_glance_get_type (void); +GtkWidget* gtk_mlos_glance_new (GHashTable *sats, qth_t *qth, GHashTable *groundstations, gdouble ts); + +/* +void gtk_mlos_glance_reconf (GtkWidget *skg); + +void gtk_mlos_glance_reload_sats (GtkWidget *skg, GHashTable *sats); +*/ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __GTK_MLOS_GLANCE_H__ */ Modified: branches/mlos/src/gtk-sat-module-popup.c =================================================================== --- branches/mlos/src/gtk-sat-module-popup.c 2011-04-02 02:44:13 UTC (rev 808) +++ branches/mlos/src/gtk-sat-module-popup.c 2011-04-03 13:21:00 UTC (rev 809) @@ -34,6 +34,7 @@ #include "mod-mgr.h" #include "compat.h" #include "gtk-sky-glance.h" +#include "gtk-mlos-glance.h" #include "sat-cfg.h" #ifdef HAVE_CONFIG_H # include <build-config.h> @@ -54,6 +55,7 @@ static void docking_state_cb (GtkWidget *menuitem, gpointer data); static void screen_state_cb (GtkWidget *menuitem, gpointer data); static void sky_at_glance_cb (GtkWidget *menuitem, gpointer data); +static void mlos_cb (GtkWidget *menuitem, gpointer data); static void tmgr_cb (GtkWidget *menuitem, gpointer data); static void rigctrl_cb (GtkWidget *menuitem, gpointer data); static void rotctrl_cb (GtkWidget *menuitem, gpointer data); @@ -63,6 +65,7 @@ static void destroy_rotctrl (GtkWidget *window, gpointer data); static void destroy_rigctrl (GtkWidget *window, gpointer data); static void destroy_skg (GtkWidget *window, gpointer data); +static void destroy_mlos (GtkWidget *window, gpointer data); static gint window_delete (GtkWidget *widget, GdkEvent *event, gpointer data); @@ -153,6 +156,17 @@ g_signal_connect (menuitem, "activate", G_CALLBACK (sky_at_glance_cb), module); + /* mlos */ + menuitem = gtk_image_menu_item_new_with_label (_("MLOS at a glance")); + buff = icon_file_name ("gpredict-planner-small.png"); + image = gtk_image_new_from_file (buff); + g_free (buff); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); + gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); + g_signal_connect (menuitem, "activate", + G_CALLBACK (mlos_cb), module); + + /* time manager */ menuitem = gtk_image_menu_item_new_with_label (_("Time Controller")); buff = icon_file_name ("gpredict-clock-small.png"); @@ -809,6 +823,61 @@ } +static void mlos_cb (GtkWidget *menuitem, gpointer data) +{ + GtkSatModule *module = GTK_SAT_MODULE (data); + //GtkWidget *skg; + //GtkWidget *window; + gchar *buff; + + + /* if module is busy wait until done then go on */ + g_mutex_lock(module->busy); + + + if (module->mloswin != NULL) { + /* there is already a sky at glance for this module */ + gtk_window_present (GTK_WINDOW (module->mloswin)); + g_mutex_unlock(module->busy); + + return; + } + + + /* create window */ + module->mloswin = gtk_window_new (GTK_WINDOW_TOPLEVEL); + buff = g_strdup_printf (_("The MLOS win (%s)"), module->name); + gtk_window_set_title (GTK_WINDOW (module->mloswin), buff); + g_free (buff); + g_signal_connect (G_OBJECT (module->mloswin), "delete_event", G_CALLBACK (window_delete), NULL); + g_signal_connect (G_OBJECT (module->mloswin), "destroy", G_CALLBACK (destroy_mlos), module); + + /* window icon */ + buff = icon_file_name ("gpredict-planner.png"); + gtk_window_set_icon_from_file (GTK_WINDOW (module->mloswin), buff, NULL); + g_free (buff); + + + /* create sky at a glance widget */ + if (sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0)) { + module->mlos = gtk_mlos_glance_new (module->satellites, module->qth, module->groundstations,0.0); + } + else { + module->mlos = gtk_mlos_glance_new (module->satellites, module->qth, module->groundstations, module->tmgCdnum); + } + + /* store time at which GtkSkyGlance has been created */ + module->lastMlosUpd = module->tmgCdnum; + + gtk_container_set_border_width (GTK_CONTAINER (module->mloswin), 10); + gtk_container_add (GTK_CONTAINER (module->mloswin), module->mlos); + + gtk_widget_show_all (module->mloswin); + + g_mutex_unlock(module->busy); + +} + /** \brief Open time manager. */ static void tmgr_cb (GtkWidget *menuitem, gpointer data) { @@ -972,7 +1041,15 @@ module->skg = NULL; } +static void destroy_mlos (GtkWidget *window, gpointer data) +{ + GtkSatModule *module = GTK_SAT_MODULE (data); + + module->mloswin = NULL; + module->mlos = NULL; +} + /** \brief Ensure that deleted top-level windows are destroyed */ static gint window_delete (GtkWidget *widget, GdkEvent *event, Modified: branches/mlos/src/gtk-sat-module.c =================================================================== --- branches/mlos/src/gtk-sat-module.c 2011-04-02 02:44:13 UTC (rev 808) +++ branches/mlos/src/gtk-sat-module.c 2011-04-03 13:21:00 UTC (rev 809) @@ -68,6 +68,7 @@ #include "gtk-rig-ctrl.h" #include "gtk-rot-ctrl.h" #include "gtk-sky-glance.h" +#include "gtk-mlos-glance.h" #include "compat.h" #include "time-tools.h" @@ -101,8 +102,8 @@ static void reload_sats_in_child (GtkWidget *widget, GtkSatModule *module); static void update_skg (GtkSatModule *module); +static void update_mlos (GtkSatModule *module); - static GtkVBoxClass *parent_class = NULL; @@ -182,6 +183,8 @@ module->rigctrl = NULL; module->skgwin = NULL; module->skg = NULL; + module->mloswin = NULL; + module->mlos = NULL; module->lastSkgUpd = 0.0; module->state = GTK_SAT_MOD_STATE_DOCKED; @@ -236,6 +239,10 @@ if (module->skgwin) { gtk_widget_destroy (module->skgwin); } + /* destroy mlos window */ + if (module->mloswin) { + gtk_widget_destroy (module->mloswin); + } /* clean up QTH */ if (module->qth) { @@ -766,7 +773,7 @@ MOD_CFG_GROUNDS_KEY, &length, &error); - + if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to get list of groundstations (%s)"), @@ -801,8 +808,7 @@ /* check whether satellite is already in list in order to avoid duplicates */ - printf("Howdy 1 %s\n",qth->name); - key = g_new0 (guint, 1); + key = g_new0 (gint, 1); *key = g_str_hash(qth->name); if (g_hash_table_lookup (module->groundstations, key) == NULL) { @@ -979,7 +985,10 @@ if (mod->skg) update_skg (mod); + if (mod->mlos) + update_mlos (mod); + mod->event_count++; /* store time keeping variables */ @@ -1657,3 +1666,33 @@ qth_small_save(module->qth,&(module->lastSkgUpdqth)); } } + + +static void update_mlos (GtkSatModule *module) +{ + gboolean update_needed=FALSE; + /* threshold is ~60 seconds */ + if (G_UNLIKELY(fabs(module->tmgCdnum - module->lastMlosUpd) > 7.0e-4)) { + update_needed=TRUE; + } + /* threshold is 1km */ + if (G_UNLIKELY(qth_small_dist(module->qth, module->lastMlosUpdqth) >1.0)) { + update_needed=TRUE; + } + + + if (G_UNLIKELY(update_needed==TRUE)) { + + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Updating GtkMlosGlance for %s"), + __FUNCTION__, module->name); + + gtk_container_remove (GTK_CONTAINER (module->mloswin), module->mlos); + module->mlos = gtk_mlos_glance_new (module->satellites, module->qth, module->groundstations, module->tmgCdnum); + gtk_container_add (GTK_CONTAINER (module->mloswin), module->mlos); + gtk_widget_show_all (module->mlos); + + module->lastMlosUpd = module->tmgCdnum; + qth_small_save(module->qth,&(module->lastMlosUpdqth)); + } +} Modified: branches/mlos/src/gtk-sat-module.h =================================================================== --- branches/mlos/src/gtk-sat-module.h 2011-04-02 02:44:13 UTC (rev 808) +++ branches/mlos/src/gtk-sat-module.h 2011-04-03 13:21:00 UTC (rev 809) @@ -103,9 +103,14 @@ GtkWidget *rigctrl; /*!< Radio controller widget */ GtkWidget *skgwin; /*!< Sky at glance window */ GtkWidget *skg; /*!< Sky at glance widget */ + GtkWidget *mloswin; /*!< MLOS window */ + GtkWidget *mlos; /*!< MLOS widget */ + gdouble lastSkgUpd; /*!< Daynum of last GtkSkyGlance update */ + gdouble lastMlosUpd; /*!< Daynum of last MLOS update */ qth_small_t lastSkgUpdqth; /*!< QTH information for last GtkSkyGlance update. */ - + qth_small_t lastMlosUpdqth; /*!< QTH information for last GtkSkyGlance update. */ + GtkWidget *header; guint head_count; guint head_timeout; Modified: branches/mlos/src/predict-tools.c =================================================================== --- branches/mlos/src/predict-tools.c 2011-04-02 02:44:13 UTC (rev 808) +++ branches/mlos/src/predict-tools.c 2011-04-03 13:21:00 UTC (rev 809) @@ -446,7 +446,118 @@ return get_pass_engine (sat_in, qth, start, maxdt, 0.0); } +GSList * +get_mloses (sat_t *sat, qth_t *qth, qth_t *qth2, gdouble start, gdouble maxdt, guint num) { + GSList *passes = NULL; + mlos_t *pass = NULL; + guint i; + gdouble t; + t = start; + for (i = 0; (i < num) ; i++) { + pass = get_mlos (sat, qth, qth2, t, maxdt); + if (pass != NULL) { + passes = g_slist_prepend (passes, pass); + t = pass->finish + 0.014; + if ((maxdt > 0.0) && (t >= (start+maxdt))) { + i = num; + } + } else { + i = num; + } + } + if (passes != NULL) + passes = g_slist_reverse (passes); + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Found %d passes for %s in time window [%f;%f]"), + __FUNCTION__, g_slist_length (passes), sat->nickname, start, start+maxdt); + + return passes; +} +mlos_t * +get_mlos (sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt) { + + mlos_t *mlos; + pass_t *pass1,*pass2; + gdouble temptime; + gboolean valid=FALSE; + gboolean done=FALSE; + gdouble aos1,aos2,los1,los2,t; + + mlos = g_new (mlos_t, 1); + /* get information on the first qth with that satellite */ + predict_calc(sat,qth1,start); + + if (sat->el > 0.0) { + pass1=get_current_pass(sat,qth1,start); + } else { + pass1=get_pass(sat,qth1,start,maxdt); + } + /* + done=TRUE; + valid=TRUE; + mlos->start=pass1->aos; + mlos->finish=pass1->los; + */ + + predict_calc(sat,qth2,start); + if (sat->el > 0.0) { + pass2=get_current_pass(sat,qth2,start); + } else { + pass2=get_pass(sat,qth2,start,maxdt); + } + + while (pass1 && pass2 && !done) { + if (pass1->los < pass2->aos){ + /*pass1 finishs before pass2 starts*/ + /*no overlap so no mlos*/ + temptime=pass1->los+10.0/86400.0; + free_pass(pass1); + pass1=get_pass(sat,qth1,temptime,maxdt+start-temptime); + } else if (pass2->los < pass1->aos){ + /*pass2 finishs before pass1 starts*/ + /*no overlap so no mlos*/ + temptime=pass2->los+10.0/86400.0; + free_pass(pass2); + pass2=get_pass(sat,qth2,temptime,maxdt+start-temptime); + } else { + /*passes overlap*/ + if (pass1->aos < pass2->aos) { + /*passes have overlap and pass1 starts first*/ + mlos->start=pass2->aos; + }else { + mlos->start=pass1->aos; + } + + if (pass1->los < pass2->los) { + /*passes have overlap and pass1 finishes first*/ + mlos->finish=pass1->los; + }else { + mlos->finish=pass2->los; + } + done=TRUE; + valid=TRUE; + + } + } + if (pass1) { + free_pass(pass1); + } + if (pass2) { + free_pass(pass2); + } + + if (valid==TRUE) { + return (mlos); + } + else { + g_free( mlos); + return NULL; + } + return NULL; +} + + /** \brief Predict first pass after a certain time. * \param sat Pointer to the satellite data. * \param qth Pointer to the location data. Modified: branches/mlos/src/predict-tools.h =================================================================== --- branches/mlos/src/predict-tools.h 2011-04-02 02:44:13 UTC (rev 808) +++ branches/mlos/src/predict-tools.h 2011-04-03 13:21:00 UTC (rev 809) @@ -53,6 +53,11 @@ qth_small_t qth_comp; /*!< Short version of qth at time computed */ } pass_t; +/** \brief Brief mlos info. A window where two ground stations can see the same satellite*/ +typedef struct { + gdouble start; /*!< Start time in "jul_utc" */ + gdouble finish; /*!< Finish time in "jul_utc" */ +} mlos_t; /** \brief Pass detail entry. * @@ -105,6 +110,8 @@ pass_t *get_current_pass (sat_t *sat, qth_t *qth, gdouble start); pass_t *get_pass_no_min_el (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt); +mlos_t *get_mlos (sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt); +GSList *get_mloses (sat_t *sat, qth_t *qth1, qth_t *qth2, gdouble start, gdouble maxdt, guint num); /* copying */ pass_t *copy_pass (pass_t *pass); GSList *copy_pass_details (GSList *details); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-04-02 02:44:20
|
Revision: 808 http://gpredict.svn.sourceforge.net/gpredict/?rev=808&view=rev Author: aa1vs Date: 2011-04-02 02:44:13 +0000 (Sat, 02 Apr 2011) Log Message: ----------- Backend plotting for feature request:2689352 Modified Paths: -------------- branches/mlos/ChangeLog branches/mlos/src/config-keys.h branches/mlos/src/gtk-sat-map.c branches/mlos/src/gtk-sat-map.h branches/mlos/src/gtk-sat-module.c branches/mlos/src/gtk-sat-module.h branches/mlos/src/qth-data.h Added Paths: ----------- branches/mlos/ Modified: branches/mlos/ChangeLog =================================================================== --- trunk/ChangeLog 2011-04-01 12:35:03 UTC (rev 807) +++ branches/mlos/ChangeLog 2011-04-02 02:44:13 UTC (rev 808) @@ -5,6 +5,13 @@ * win32/build-config.h Apply Alan Moffet's changes for win32 build. + * src/qth_data.h + * src/config_keys.h + * src/gtk-sat-module.[ch] + * src/gtk-sat-map.[ch] + Implement backend for Stephane's recommendation regarding mutual LOS/AOS. + Feature Request: 2689352 + 2011-04-01 Alexandru Csete <oz9aec at gmail.com> * src/pass-to-txt.c Modified: branches/mlos/src/config-keys.h =================================================================== --- trunk/src/config-keys.h 2011-04-01 12:35:03 UTC (rev 807) +++ branches/mlos/src/config-keys.h 2011-04-02 02:44:13 UTC (rev 808) @@ -67,6 +67,7 @@ #define MOD_CFG_GLOBAL_SECTION "GLOBAL" #define MOD_CFG_QTH_FILE_KEY "QTHFILE" #define MOD_CFG_SATS_KEY "SATELLITES" +#define MOD_CFG_GROUNDS_KEY "GROUNDSTATIONS" #define MOD_CFG_TIMEOUT_KEY "TIMEOUT" #define MOD_CFG_WARP_KEY "WARP" #define MOD_CFG_LAYOUT "LAYOUT" /* Old layout before v1.2 */ Modified: branches/mlos/src/gtk-sat-map.c =================================================================== --- trunk/src/gtk-sat-map.c 2011-04-01 12:35:03 UTC (rev 807) +++ branches/mlos/src/gtk-sat-map.c 2011-04-02 02:44:13 UTC (rev 808) @@ -71,7 +71,9 @@ static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data); static void update_map_size (GtkSatMap *satmap); static void update_sat (gpointer key, gpointer value, gpointer data); +static void update_groundstation (gpointer key, gpointer value, gpointer data); static void plot_sat (gpointer key, gpointer value, gpointer data); +static void plot_groundstation (gpointer key, gpointer value, gpointer data); static void lonlat_to_xy (GtkSatMap *m, gdouble lon, gdouble lat, gfloat *x, gfloat *y); static void xy_to_lonlat (GtkSatMap *m, gfloat x, gfloat y, gfloat *lon, gfloat *lat); static gboolean on_motion_notify (GooCanvasItem *item, @@ -170,6 +172,7 @@ satmap->sats = NULL; satmap->qth = NULL; satmap->obj = NULL; + satmap->groundobj = NULL; satmap->naos = 2458849.5; satmap->ncat = 0; satmap->tstamp = 2458849.5; @@ -203,7 +206,7 @@ * */ GtkWidget* -gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth) +gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth, GHashTable *groundstations) { GtkWidget *satmap; GooCanvasItemModel *root; @@ -213,9 +216,11 @@ GTK_SAT_MAP (satmap)->cfgdata = cfgdata; GTK_SAT_MAP (satmap)->sats = sats; + GTK_SAT_MAP (satmap)->groundstations = groundstations; GTK_SAT_MAP (satmap)->qth = qth; GTK_SAT_MAP (satmap)->obj = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL); + GTK_SAT_MAP (satmap)->groundobj = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); /* get settings */ GTK_SAT_MAP (satmap)->refresh = mod_cfg_get_int (cfgdata, @@ -295,6 +300,9 @@ /* plot each sat on the canvas */ g_hash_table_foreach (GTK_SAT_MAP (satmap)->sats, plot_sat, GTK_SAT_MAP (satmap)); + /* plot each groundstation on the canvas */ + g_hash_table_foreach (GTK_SAT_MAP (satmap)->groundstations, plot_groundstation, GTK_SAT_MAP (satmap)); + /* gtk_box_pack_start (GTK_BOX (satmap), GTK_SAT_MAP (satmap)->swin, TRUE, TRUE, 0); */ gtk_container_add (GTK_CONTAINER (satmap), GTK_SAT_MAP (satmap)->canvas); @@ -574,6 +582,8 @@ /* update satellites */ g_hash_table_foreach (satmap->sats, update_sat, satmap); + /* update grounds */ + g_hash_table_foreach (satmap->groundstations, update_groundstation, satmap); satmap->resize = FALSE; } @@ -649,7 +659,6 @@ } /* check refresh rate and refresh sats/qth if time */ - /* FIXME add location check*/ if (satmap->counter < satmap->refresh) { satmap->counter++; } @@ -679,6 +688,8 @@ /* update sats */ g_hash_table_foreach (satmap->sats, update_sat, satmap); + /* update sats */ + g_hash_table_foreach (satmap->groundstations, update_groundstation, satmap); /* update countdown to NEXT AOS label */ if (satmap->eventinfo) { @@ -1331,7 +1342,7 @@ points1->coords[719-2*azi] = msy; } - /* points1 ow contains 360 pairs of map-based XY coordinates. + /* points1 now contains 360 pairs of map-based XY coordinates. Check whether actions 1, 2 or 3 have to be performed. */ @@ -1852,8 +1863,46 @@ /* add sat to hash table */ g_hash_table_insert (satmap->obj, catnum, obj); } +static void +plot_groundstation (gpointer key, gpointer value, gpointer data) +{ + GtkSatMap *satmap = GTK_SAT_MAP (data); + sat_map_ground_t *obj = NULL; + qth_t *ground = QTH(value); + GooCanvasItemModel *root; + guint32 col; + gfloat x,y; + lonlat_to_xy (satmap, ground->lon, ground->lat, &x, &y); + + col = mod_cfg_get_int (satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_QTH_COL, + SAT_CFG_INT_MAP_QTH_COL); + + /* create and initialize a sat object */ + obj = g_try_new (sat_map_ground_t, 1); + + obj->ground_mark = NULL; + obj->ground_label = NULL; + + + root = goo_canvas_get_root_item_model (GOO_CANVAS (satmap->canvas)); + obj->ground_mark = goo_canvas_rect_model_new (root, + x - MARKER_SIZE_HALF, + y - MARKER_SIZE_HALF, + 2 * MARKER_SIZE_HALF, + 2 * MARKER_SIZE_HALF, + "fill-color-rgba", col, + "stroke-color-rgba", col, + NULL); + /* add groundstation to hash table */ + g_hash_table_insert (satmap->groundobj, ground->name, obj); + +} + + /** \brief Update a given satellite. */ static void @@ -2108,7 +2157,76 @@ g_free (catnum); } +static void +update_groundstation (gpointer key, gpointer value, gpointer data) +{ + GtkSatMap *satmap = GTK_SAT_MAP (data); + sat_map_ground_t *obj = NULL; + qth_t *qth = QTH(value); + gfloat x, y; + gdouble oldx, oldy; + GooCanvasItemModel *root; + //gdouble sspla,ssplo; + root = goo_canvas_get_root_item_model (GOO_CANVAS (satmap->canvas)); + + obj = SAT_MAP_GROUND (g_hash_table_lookup (satmap->groundobj, qth->name)); + + if (obj == NULL) { + return; + } + + lonlat_to_xy (satmap, qth->lon, qth->lat, &x, &y); + + /* update only if satellite has moved at least + 2 * MARKER_SIZE_HALF (no need to drain CPU all the time) + */ + g_object_get (obj->ground_mark, + "x", &oldx, + "y", &oldy, + NULL); + + if ((fabs (oldx-x) >= 2*MARKER_SIZE_HALF) || + (fabs (oldy-y) >= 2*MARKER_SIZE_HALF)) { + + /* update ground mark */ + g_object_set (obj->ground_mark, + "x", (gdouble) (x - MARKER_SIZE_HALF), + "y", (gdouble) (y - MARKER_SIZE_HALF), + NULL); + + /* update ground label */ + if (obj->ground_label) { + if (x < 50) { + g_object_set (obj->ground_label, + "x", (gdouble) (x+3), + "y", (gdouble) (y), + "anchor", GTK_ANCHOR_WEST, + NULL); + } else if ((satmap->width - x ) < 50) { + g_object_set (obj->ground_label, + "x", (gdouble) (x-3), + "y", (gdouble) (y), + "anchor", GTK_ANCHOR_EAST, + NULL); + } else if ((satmap->height - y) < 25) { + g_object_set (obj->ground_label, + "x", (gdouble) (x), + "y", (gdouble) (y-2), + "anchor", GTK_ANCHOR_SOUTH, + NULL); + } else { + g_object_set (obj->ground_label, + "x", (gdouble) (x), + "y", (gdouble) (y+2), + "anchor", GTK_ANCHOR_NORTH, + NULL); + } + } + } +} + + /** \brief Update information about the selected satellite. * \param satmap Pointer to the GtkSatMap widget. * \param sat Pointer to the selected satellite Modified: branches/mlos/src/gtk-sat-map.h =================================================================== --- trunk/src/gtk-sat-map.h 2011-04-01 12:35:03 UTC (rev 807) +++ branches/mlos/src/gtk-sat-map.h 2011-04-02 02:44:13 UTC (rev 808) @@ -109,7 +109,19 @@ #define SAT_MAP_OBJ(obj) ((sat_map_obj_t *)obj) +/** \brief Groundstation object. + * + * This data structure represents a groundstation object on the map. + * + */ +typedef struct { + GooCanvasItemModel *ground_mark; + GooCanvasItemModel *ground_label; + gchar *qth_string; +} sat_map_ground_t; +#define SAT_MAP_GROUND(obj) ((sat_map_ground_t *)obj) + /** \brief The satellite map data structure. */ typedef struct { GtkVBox vbox; @@ -138,9 +150,11 @@ GKeyFile *cfgdata; /*!< Module configuration data. */ GHashTable *sats; /*!< Pointer to satellites (owned by parent GtkSatModule). */ + GHashTable *groundstations; /*!< Pointer to groundstations (owned by parent GtkSatModule). */ qth_t *qth; /*!< Pointer to current location. */ GHashTable *obj; /*!< Canvas items representing each satellite. */ + GHashTable *groundobj; /*!< Canvas items representing each groundstation. */ guint x0; /*!< X0 of the canvas map. */ guint y0; /*!< Y0 of the canvas map. */ @@ -173,7 +187,8 @@ GtkType gtk_sat_map_get_type (void); GtkWidget* gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, - qth_t *qth); + qth_t *qth, + GHashTable *groundstations); void gtk_sat_map_update (GtkWidget *widget); void gtk_sat_map_reconf (GtkWidget *widget, GKeyFile *cfgdat); Modified: branches/mlos/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2011-04-01 12:35:03 UTC (rev 807) +++ branches/mlos/src/gtk-sat-module.c 2011-04-02 02:44:13 UTC (rev 808) @@ -83,6 +83,7 @@ const gchar *cfgfile); static void gtk_sat_module_load_sats (GtkSatModule *module); +static void gtk_sat_module_load_groundstations (GtkSatModule *module); static void gtk_sat_module_free_sat (gpointer sat); static gboolean gtk_sat_module_timeout_cb (gpointer module); static void gtk_sat_module_update_sat (gpointer key, @@ -169,6 +170,12 @@ g_free, gtk_sat_module_free_sat); + module->groundstations = g_hash_table_new_full (g_int_hash, + g_int_equal, + g_free, + NULL); + + module->rotctrlwin = NULL; module->rotctrl = NULL; module->rigctrlwin = NULL; @@ -242,6 +249,12 @@ module->satellites = NULL; } + /* clean up groundstations */ + if (module->groundstations) { + g_hash_table_destroy (module->groundstations); + module->groundstations = NULL; + } + if (module->grid) { g_free (module->grid); module->grid = NULL; @@ -323,6 +336,9 @@ /* load satellites */ gtk_sat_module_load_sats (GTK_SAT_MODULE (widget)); + + /* load groundstations */ + gtk_sat_module_load_groundstations (GTK_SAT_MODULE (widget)); /* create buttons */ GTK_SAT_MODULE (widget)->popup_button = @@ -449,7 +465,8 @@ case GTK_SAT_MOD_VIEW_MAP: view = gtk_sat_map_new (module->cfgdata, module->satellites, - module->qth); + module->qth, + module->groundstations); break; case GTK_SAT_MOD_VIEW_POLAR: @@ -728,7 +745,105 @@ } +static void +gtk_sat_module_load_groundstations (GtkSatModule *module) +{ + gchar **grounds = NULL; + gsize length; + GError *error = NULL; + guint i; + qth_t *qth; + gint *key = NULL; + guint succ = 0; + gchar *confdir = NULL; + gchar *qth_file = NULL; + + confdir = get_user_conf_dir (); + /* get list of satellites from config file; abort in case of error */ + grounds = g_key_file_get_string_list (module->cfgdata, + MOD_CFG_GLOBAL_SECTION, + MOD_CFG_GROUNDS_KEY, + &length, + &error); + + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to get list of groundstations (%s)"), + __FUNCTION__, error->message); + + g_clear_error (&error); + + /* GLib API says nothing about the contents in case of error */ + if (grounds) { + g_strfreev (grounds); + } + + return; + } + + /* read each satellite into hash table */ + for (i = 0; i < length; i++) { + + qth_file = g_strconcat (confdir, G_DIR_SEPARATOR_S, grounds[i], NULL); + qth = g_new (qth_t, 1); + + if (qth_data_read (qth_file, qth)==FALSE) { + + /* the satellite could not be read */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading data for #%d"), + __FUNCTION__, grounds[i]); + + g_free (qth); + } + else { + /* check whether satellite is already in list + in order to avoid duplicates + */ + printf("Howdy 1 %s\n",qth->name); + key = g_new0 (guint, 1); + *key = g_str_hash(qth->name); + + if (g_hash_table_lookup (module->groundstations, key) == NULL) { + + qth_data_update_init (qth); + + g_hash_table_insert (module->groundstations, + key, + qth); + + succ++; + + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Read data for #%d"), + __FUNCTION__, grounds[i]); + + + } + else { + sat_log_log (SAT_LOG_LEVEL_WARN, + _("%s: Qth #%d already in list"), + __FUNCTION__, grounds[i]); + + /* it is not needed in this case */ + qth_data_free (qth); + } + } + g_free (qth_file); + } + + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Read %d out of %d groundstations"), + __FUNCTION__, + succ, + length); + g_free (confdir); + g_strfreev (grounds); + +} + + /** \brief Free satellite data * * This function is called automatically for each satellite when Modified: branches/mlos/src/gtk-sat-module.h =================================================================== --- trunk/src/gtk-sat-module.h 2011-04-01 12:35:03 UTC (rev 807) +++ branches/mlos/src/gtk-sat-module.h 2011-04-02 02:44:13 UTC (rev 808) @@ -121,6 +121,7 @@ qth_t *qth; /*!< QTH information. */ qth_small_t qth_event; /*!< QTH information for last AOS/LOS update. */ GHashTable *satellites; /*!< Satellites. */ + GHashTable *groundstations;/*!< Other Ground Stations. */ guint32 timeout; /*!< Timeout value [msec] */ Modified: branches/mlos/src/qth-data.h =================================================================== --- trunk/src/qth-data.h 2011-04-01 12:35:03 UTC (rev 807) +++ branches/mlos/src/qth-data.h 2011-04-02 02:44:13 UTC (rev 808) @@ -67,6 +67,7 @@ QTH_GPSD_TYPE } qth_data_type; +#define QTH(qth) ((qth_t *) (qth)) gint qth_data_read (const gchar *filename, qth_t *qth); gint qth_data_save (const gchar *filename, qth_t *qth); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-04-01 12:35:09
|
Revision: 807 http://gpredict.svn.sourceforge.net/gpredict/?rev=807&view=rev Author: aa1vs Date: 2011-04-01 12:35:03 +0000 (Fri, 01 Apr 2011) Log Message: ----------- Apply Alan Moffet's changes for win32 build. Modified Paths: -------------- trunk/ChangeLog trunk/win32/build-config.h trunk/win32/gpredict.exe.manifest trunk/win32/gpredict.rc Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-04-01 12:15:25 UTC (rev 806) +++ trunk/ChangeLog 2011-04-01 12:35:03 UTC (rev 807) @@ -1,3 +1,10 @@ +2011-04-01 Charles Suprin <hamaa1vs at gmail.com> + + * win32/gpredict.rc + * win32/gpredict.exe.manifest + * win32/build-config.h + Apply Alan Moffet's changes for win32 build. + 2011-04-01 Alexandru Csete <oz9aec at gmail.com> * src/pass-to-txt.c Modified: trunk/win32/build-config.h =================================================================== --- trunk/win32/build-config.h 2011-04-01 12:15:25 UTC (rev 806) +++ trunk/win32/build-config.h 2011-04-01 12:35:03 UTC (rev 807) @@ -90,5 +90,5 @@ #define GETTEXT_PACKAGE "gpredict" -#define HAS_LIBGPS 0 +#undef HAS_LIBGPS Modified: trunk/win32/gpredict.exe.manifest =================================================================== --- trunk/win32/gpredict.exe.manifest 2011-04-01 12:15:25 UTC (rev 806) +++ trunk/win32/gpredict.exe.manifest 2011-04-01 12:35:03 UTC (rev 807) @@ -1,5 +1,7 @@ <?xml version='1.0' encoding='UTF-8' standalone='yes'?> <assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <assemblyIdentity name="GPredict" processorArchitecture="x86" version="1.3.0.0" type="win32"/> + <description>Gpredict: Real-time satellite tracking and orbit prediction program</description> <dependency> <dependentAssembly> <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' @@ -7,4 +9,12 @@ publicKeyToken='1fc8b3b9a1e18e3b' /> </dependentAssembly> </dependency> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> + <security> + <requestedPrivileges/> + </security> + </trustInfo> + <asmv3:application> + <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"/> + </asmv3:application> </assembly> Modified: trunk/win32/gpredict.rc =================================================================== --- trunk/win32/gpredict.rc 2011-04-01 12:15:25 UTC (rev 806) +++ trunk/win32/gpredict.rc 2011-04-01 12:35:03 UTC (rev 807) @@ -1,7 +1,38 @@ #include <windows.h> -#include <winuser.h> +#include <commctrl.h> +#include <richedit.h> +#include "resource.h" -/* icon for the program itself */ -icon_0 ICON "icons/gpredict-icon.ico" -2 RT_MANIFEST gpredict.exe.manifest +A ICON "icons/gpredict-icon.ico" +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +1 VERSIONINFO + FILEVERSION 1,3,0,0 + PRODUCTVERSION 1,3,0,0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + FILEFLAGSMASK 0x00000000 + FILEFLAGS 0x00000000 +{ + BLOCK "StringFileInfo" + { + BLOCK "040904e4" + { + VALUE "CompanyName", "Alexandru Csete, OZ9AEC" + VALUE "FileDescription", "Gpredict: Real-time satellite tracking and orbit prediction program" + VALUE "FileVersion", "1.3.0.0" + VALUE "InternalName", "GPredict" + VALUE "LegalCopyright", "Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC" + VALUE "ProductName", "GPredict" + VALUE "ProductVersion", "1.3" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 0x04E4 + } +} + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +2 RT_MANIFEST "gpredict.exe.manifest" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2011-04-01 12:15:31
|
Revision: 806 http://gpredict.svn.sourceforge.net/gpredict/?rev=806&view=rev Author: csete Date: 2011-04-01 12:15:25 +0000 (Fri, 01 Apr 2011) Log Message: ----------- Trying to sync AUTHORS and about.c Modified Paths: -------------- trunk/AUTHORS trunk/ChangeLog trunk/src/about.c Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2011-04-01 11:48:05 UTC (rev 805) +++ trunk/AUTHORS 2011-04-01 12:15:25 UTC (rev 806) @@ -3,8 +3,8 @@ Contributors: - William J Beksi, KC2EXL, Map view. -- Charles Suprin, AA1VS, various multithread fixes. -- Valentin Yakovenkov, Windows build. +- Charles Suprin, AA1VS, GPS support and many other improvements. +- Alan Moffet KE7IJZ and Valentin Yakovenkov, Windows build. - David VK5DG, transponder data files - Dr. T.S. Kelso, the author original SGP4/SDP4 algorithms in FORTRAN and Pascal. - Neoklis Kyriazis, 5B4AZ, conversion of the algorithms to C. @@ -16,7 +16,9 @@ - Paul Schulz, VK5FPAW (various patches). - Martin Pool, for his natural string compare routines see http://sourcefrog.net/projects/natsort/ +- Patrick Strasser, OE6PSE (natural sorting) + Imagery: Most of the maps originate from NASA Visible Earth, http://visibleearth.nasa.gov/ Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-04-01 11:48:05 UTC (rev 805) +++ trunk/ChangeLog 2011-04-01 12:15:25 UTC (rev 806) @@ -8,6 +8,10 @@ * src/gtk-polar-view.c Appied patch 3261586: Remove leading zero code from time formatting functions (thanks to Paul Schulz). + + * src/about.c + * AUTHORS + Trying to sync AUTHORS and about.c 2011-03-28 Charles Suprin <hamaa1vs at gmail.com> Modified: trunk/src/about.c =================================================================== --- trunk/src/about.c 2011-04-01 11:48:05 UTC (rev 805) +++ trunk/src/about.c 2011-04-01 12:15:25 UTC (rev 806) @@ -40,9 +40,9 @@ "", "Contributors:", "David VK5DG (Transponder data files)", - "Charles Suprin, AA1VS (Various multithread fixes)", + "Charles Suprin, AA1VS (GPS support and many other improvements)", + "Alan Moffet, KE7IJZ (windows build)," "Valentin Yakovenkov (Windows build)", - "Bruce Cowan (Gio port of TLE updater)", "Damon Chaplin (GooCanvas)", "Dr. T.S. Kelso (SGP4/SDP4 algorithms)", "John A. Magliacane, KD2BD (prediction code)", @@ -54,6 +54,7 @@ "Mirko Caserta (locator.c)", "S. R. Sampson (locator.c)", "Paul Schulz, VK5FPAW (various patches)", + "Patrick Strasser, OE6PSE (natural sorting)", "Martin Pool (natural sorting)", "", "Imagery:", @@ -64,7 +65,7 @@ const gchar license[] = N_("Copyright (C) 2001-2011 Alexandru Csete OZ9AEC and contributors.\n"\ - "Contact: oz9aec at googlemail.com\n\n"\ + "Contact: oz9aec at gmail.com\n\n"\ "Gpredict is free software; you can redistribute it and "\ "mofdify it under the terms of the GNU General Public License "\ "as published by the Free Software Foundation; either version 2 "\ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2011-04-01 11:48:11
|
Revision: 805 http://gpredict.svn.sourceforge.net/gpredict/?rev=805&view=rev Author: csete Date: 2011-04-01 11:48:05 +0000 (Fri, 01 Apr 2011) Log Message: ----------- Appied patch 3261586: Remove leading zero code from time formatting functions (thanks to Paul Schulz). Modified Paths: -------------- trunk/ChangeLog trunk/src/gtk-event-list.c trunk/src/gtk-polar-view.c trunk/src/gtk-rig-ctrl.c trunk/src/gtk-rot-ctrl.c trunk/src/pass-to-txt.c trunk/src/sat-pass-dialogs.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-31 00:03:48 UTC (rev 804) +++ trunk/ChangeLog 2011-04-01 11:48:05 UTC (rev 805) @@ -1,3 +1,15 @@ +2011-04-01 Alexandru Csete <oz9aec at gmail.com> + + * src/pass-to-txt.c + * src/sat-pass-dialogs.c + * src/gtk-rig-ctrl.c + * src/gtk-event-list.c + * src/gtk-rot-ctrl.c + * src/gtk-polar-view.c + Appied patch 3261586: Remove leading zero code from time formatting + functions (thanks to Paul Schulz). + + 2011-03-28 Charles Suprin <hamaa1vs at gmail.com> * src/gtk-rig-ctrl.c Modified: trunk/src/gtk-event-list.c =================================================================== --- trunk/src/gtk-event-list.c 2011-03-31 00:03:48 UTC (rev 804) +++ trunk/src/gtk-event-list.c 2011-04-01 11:48:05 UTC (rev 805) @@ -577,7 +577,6 @@ guint coli = GPOINTER_TO_UINT (column); guint h,m,s; - gchar *ch,*cm,*cs; /* get cell data */ @@ -596,39 +595,17 @@ 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) { - buff = g_strdup_printf ("%s%d:%s%d%s%d", ch, h, cm, m, cs, s); + buff = g_strdup_printf ("%02d:%02d:%02d", h, m, s); } else { - buff = g_strdup_printf ("%s%d%s%d", cm, m, cs, s); + buff = g_strdup_printf ("%02d:%02d", m, s); } - g_free (ch); - g_free (cm); - g_free (cs); - } /* render the cell */ Modified: trunk/src/gtk-polar-view.c =================================================================== --- trunk/src/gtk-polar-view.c 2011-03-31 00:03:48 UTC (rev 804) +++ trunk/src/gtk-polar-view.c 2011-04-01 11:48:05 UTC (rev 805) @@ -677,7 +677,6 @@ gdouble number, now; gchar *buff; guint h,m,s; - gchar *ch,*cm,*cs; sat_t *sat = NULL; gint *catnr; @@ -721,34 +720,16 @@ 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) - buff = g_strdup_printf (_("Next: %s\nin %s%d:%s%d%s%d"), - sat->nickname, ch, h, cm, m, cs, s); + buff = g_strdup_printf (_("Next: %s\nin %02d:%02d:%02d"), + sat->nickname, h, m, s); else - buff = g_strdup_printf (_("Next: %s\nin %s%d%s%d"), - sat->nickname, cm, m, cs, s); + buff = g_strdup_printf (_("Next: %s\nin %02d:%02d"), + sat->nickname, m, s); g_object_set (polv->next, @@ -756,9 +737,6 @@ NULL); g_free (buff); - g_free (ch); - g_free (cm); - g_free (cs); } else { sat_log_log (SAT_LOG_LEVEL_BUG, @@ -1643,7 +1621,6 @@ 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; @@ -1658,37 +1635,16 @@ 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); + text = g_strdup_printf (_("LOS in %02d:%02d:%02d"), h, m, s); } else { - text = g_strdup_printf (_("LOS in %s%d%s%d"), cm, m, cs, s); + text = g_strdup_printf (_("LOS in %02d:%02d"), m, s); } - g_free (ch); - g_free (cm); - g_free (cs); return text; } Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2011-03-31 00:03:48 UTC (rev 804) +++ trunk/src/gtk-rig-ctrl.c 2011-04-01 11:48:05 UTC (rev 805) @@ -2244,7 +2244,6 @@ gdouble delta; gchar *buff; guint h,m,s; - gchar *ch,*cm,*cs; gchar *aoslos; @@ -2267,42 +2266,21 @@ 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) - buff = g_strdup_printf ("<span size='xx-large'><b>%s %s%d:%s%d%s%d</b></span>", - aoslos, ch, h, cm, m, cs, s); + buff = g_strdup_printf ("<span size='xx-large'><b>%s %02d:%02d:%02d</b></span>", + aoslos, h, m, s); else - buff = g_strdup_printf ("<span size='xx-large'><b>%s %s%d%s%d</b></span>", - aoslos, cm, m, cs, s); + buff = g_strdup_printf ("<span size='xx-large'><b>%s %02d:%02d</b></span>", + aoslos, m, s); gtk_label_set_markup (GTK_LABEL (ctrl->SatCnt), buff); g_free (buff); g_free (aoslos); - g_free (ch); - g_free (cm); - g_free (cs); } Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2011-03-31 00:03:48 UTC (rev 804) +++ trunk/src/gtk-rot-ctrl.c 2011-04-01 11:48:05 UTC (rev 805) @@ -1225,7 +1225,6 @@ gdouble delta; gchar *buff; guint h,m,s; - gchar *ch,*cm,*cs; /* select AOS or LOS time depending on target elevation */ @@ -1243,39 +1242,18 @@ 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) - buff = g_strdup_printf ("%s%d:%s%d%s%d", ch, h, cm, m, cs, s); + buff = g_strdup_printf ("%02d:%02d:%02d", h, m, s); else - buff = g_strdup_printf ("%s%d%s%d", cm, m, cs, s); + buff = g_strdup_printf ("%02d:%02d", m, s); gtk_label_set_text (GTK_LABEL (ctrl->SatCnt), buff); g_free (buff); - g_free (ch); - g_free (cm); - g_free (cs); } Modified: trunk/src/pass-to-txt.c =================================================================== --- trunk/src/pass-to-txt.c 2011-03-31 00:03:48 UTC (rev 804) +++ trunk/src/pass-to-txt.c 2011-04-01 11:48:05 UTC (rev 805) @@ -567,7 +567,6 @@ /* Duration */ if (fields & (1 << MULTI_PASS_COL_DURATION)) { guint h,m,s; - gchar *ch,*cm,*cs; /* convert julian date to seconds */ s = (guint) ((pass->los - pass->aos) * 86400); @@ -576,35 +575,14 @@ h = (guint) floor (s/3600); s -= 3600*h; - /* leading zero */ - if (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 (":"); - - buff = g_strdup_printf ("%s %s%d%s%d%s%d", line, ch, h, cm, m, cs, s); + buff = g_strdup_printf ("%s %02d:%02d:%02d", line, h, m, s); g_free (line); line = g_strdup (buff); g_free (buff); - g_free (ch); - g_free (cm); - g_free (cs); } /* Max El */ Modified: trunk/src/sat-pass-dialogs.c =================================================================== --- trunk/src/sat-pass-dialogs.c 2011-03-31 00:03:48 UTC (rev 804) +++ trunk/src/sat-pass-dialogs.c 2011-04-01 11:48:05 UTC (rev 805) @@ -1226,7 +1226,6 @@ gchar *buff; guint coli = GPOINTER_TO_UINT (column); guint h,m,s; - gchar *ch,*cm,*cs; @@ -1246,39 +1245,17 @@ h = (guint) floor (s/3600); s -= 3600*h; - /* leading zero */ - if (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 (":"); + buff = g_strdup_printf ("%02d:%02d:%02d", h, m, s); - /* leading zero */ - if (s < 10) - cs = g_strdup (":0"); - else - cs = g_strdup (":"); - - - buff = g_strdup_printf ("%s%d%s%d%s%d", ch, h, cm, m, cs, s); - g_object_set (renderer, "text", buff, NULL); g_free (buff); - g_free (ch); - g_free (cm); - g_free (cs); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-31 00:03:55
|
Revision: 804 http://gpredict.svn.sourceforge.net/gpredict/?rev=804&view=rev Author: aa1vs Date: 2011-03-31 00:03:48 +0000 (Thu, 31 Mar 2011) Log Message: ----------- Update Authors and about.c for Win32 network fixes. Modified Paths: -------------- trunk/AUTHORS trunk/src/about.c trunk/src/main.c Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2011-03-30 23:50:34 UTC (rev 803) +++ trunk/AUTHORS 2011-03-31 00:03:48 UTC (rev 804) @@ -12,7 +12,8 @@ see http://www.dachaplin.dsl.pipex.com/goocanvas/ - Maidenhead locator functions are based on work done by Stephane Fillod, Nate Bargmann, Dave Hines, Mirko Caserta, and S. R. Sampson. -- Paul Schulz, various patches. +- Win32 networking in rig and rotor control fixed by Stephane Fillod, +- Paul Schulz, VK5FPAW (various patches). - Martin Pool, for his natural string compare routines see http://sourcefrog.net/projects/natsort/ Modified: trunk/src/about.c =================================================================== --- trunk/src/about.c 2011-03-30 23:50:34 UTC (rev 803) +++ trunk/src/about.c 2011-03-31 00:03:48 UTC (rev 804) @@ -48,12 +48,12 @@ "John A. Magliacane, KD2BD (prediction code)", "Neoklis Kyriazis, 5B4AZ (SGP4/SDP4 in C)", "William J Beksi, KC2EXL (GtkSatMap)", - "Stephane Fillod (Rig controller and locator.c)", + "Stephane Fillod (Win32 network fixes, rig controller and locator.c)", "Nate Bargmann (locator.c)", "Dave Hines (locator.c)", "Mirko Caserta (locator.c)", "S. R. Sampson (locator.c)", - "Paul Schulz (various patches)", + "Paul Schulz, VK5FPAW (various patches)", "Martin Pool (natural sorting)", "", "Imagery:", Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2011-03-30 23:50:34 UTC (rev 803) +++ trunk/src/main.c 2011-03-31 00:03:48 UTC (rev 804) @@ -438,7 +438,7 @@ * * If the time to update the TLE has come, it will either notify * the user, or fork a separate task which will update the TLE data - * in the background (depending on user settings. + * in the background (depending on user settings). * * In case of notification, the task will be removed in order to * avoid a new notification the next time the taks would be run. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-30 23:50:41
|
Revision: 803 http://gpredict.svn.sourceforge.net/gpredict/?rev=803&view=rev Author: aa1vs Date: 2011-03-30 23:50:34 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Change definition of HAS_LIBGPS. Modified Paths: -------------- trunk/configure.ac trunk/src/qth-data.c trunk/src/qth-editor.c trunk/src/sat-pref-qth-editor.c trunk/src/sat-pref-qth.c Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2011-03-30 23:16:02 UTC (rev 802) +++ trunk/configure.ac 2011-03-30 23:50:34 UTC (rev 803) @@ -37,8 +37,6 @@ AC_DEFINE(HAS_LIBGPS, 1, [Define if libgps is available]) ], [ havelibgps=false; - AC_DEFINE(HAS_LIBGPS, 0, [Define if libgps is unvailable]) - ]) dnl Hamlib not needed if we go for the TCP based I/F Modified: trunk/src/qth-data.c =================================================================== --- trunk/src/qth-data.c 2011-03-30 23:16:02 UTC (rev 802) +++ trunk/src/qth-data.c 2011-03-30 23:50:34 UTC (rev 803) @@ -40,7 +40,7 @@ #include "orbit-tools.h" #include "time-tools.h" #include "locator.h" -#if HAS_LIBGPS +#ifdef HAS_LIBGPS # include <gps.h> #endif @@ -499,7 +499,7 @@ } if (qth->gps_data!=NULL) { -#if HAS_LIBGPS +#ifdef HAS_LIBGPS switch (GPSD_API_MAJOR_VERSION){ case 4: #if GPSD_API_MAJOR_VERSION==4 @@ -621,7 +621,7 @@ /*nothing to do. the data never updates*/ break; case QTH_GPSD_TYPE: -#if HAS_LIBGPS +#ifdef HAS_LIBGPS switch (GPSD_API_MAJOR_VERSION) { case 4: #if GPSD_API_MAJOR_VERSION==4 @@ -696,7 +696,7 @@ /* close gpsd socket */ if (qth->gps_data !=NULL){ -#if HAS_LIBGPS +#ifdef HAS_LIBGPS switch (GPSD_API_MAJOR_VERSION) { case 4: gps_close(qth->gps_data); Modified: trunk/src/qth-editor.c =================================================================== --- trunk/src/qth-editor.c 2011-03-30 23:16:02 UTC (rev 802) +++ trunk/src/qth-editor.c 2011-03-30 23:50:34 UTC (rev 803) @@ -73,9 +73,11 @@ static GtkWidget *location; /* QTH location */ static GtkWidget *desc; /* QTH description */ static GtkWidget *lat,*lon,*alt; /* LAT, LON and ALT */ +#ifdef HAS_LIBGPS static GtkWidget *type; /* GPSD type */ static GtkWidget *server; /* GPSD Server */ static GtkWidget *port; /* GPSD Port */ +#endif static GtkWidget *ns,*ew; static GtkWidget *qra; /* QRA locator */ @@ -376,7 +378,7 @@ GUINT_TO_POINTER (SELECTION_MODE_WX)); gtk_table_attach_defaults (GTK_TABLE (table), wxbut, 3, 4, 7, 8); -# if HAS_LIBGPS +# ifdef HAS_LIBGPS /* GPSD enabled*/ label = gtk_label_new (_("QTH Type")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -506,9 +508,11 @@ const gchar *qthdesc = NULL; const gchar *qthwx = NULL; const gchar *qthqra= NULL; +#ifdef HAS_LIBGPS const gchar *gpsdserver= NULL; guint gpsdport; guint gpsdenabled; +#endif gdouble qthlat; gdouble qthlon; guint qthalt; @@ -533,9 +537,11 @@ qthalt = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alt)); qthqra = gtk_entry_get_text (GTK_ENTRY (qra)); +#ifdef HAS_LIBGPS gpsdenabled = gtk_combo_box_get_active ( GTK_COMBO_BOX (type) ); gpsdserver = gtk_entry_get_text (GTK_ENTRY (server)); gpsdport = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (port)); +#endif /* clear qth struct if not empty */ /* if (qth->name != NULL) */ @@ -571,14 +577,18 @@ if (qthqra != NULL) qth->qra = g_strdup (qthqra); +#ifdef HAS_LIBGPS if (gpsdserver != NULL) qth->gpsd_server = g_strdup (gpsdserver); - +#endif qth->lat = qthlat; qth->lon = qthlon; qth->alt = qthalt; + +#ifdef HAS_LIBGPS qth->type = gpsdenabled; qth->gpsd_port = gpsdport; +#endif /* store values */ confdir = get_user_conf_dir (); Modified: trunk/src/sat-pref-qth-editor.c =================================================================== --- trunk/src/sat-pref-qth-editor.c 2011-03-30 23:16:02 UTC (rev 802) +++ trunk/src/sat-pref-qth-editor.c 2011-03-30 23:50:34 UTC (rev 803) @@ -80,9 +80,11 @@ static GtkWidget *ns,*ew; static GtkWidget *qra; /* QRA locator */ +#ifdef HAS_LIBGPS static GtkWidget *type; /* GPSD type */ static GtkWidget *server; /* GPSD Server */ static GtkWidget *port; /* GPSD Port */ +#endif static gulong latsigid,lonsigid,nssigid,ewsigid,qrasigid; static GtkWidget *wx; /* weather station */ @@ -361,7 +363,7 @@ GUINT_TO_POINTER (SELECTION_MODE_WX)); gtk_table_attach_defaults (GTK_TABLE (table), wxbut, 3, 4, 7, 8); -# if HAS_LIBGPS +# ifdef HAS_LIBGPS /* GPSD enabled*/ label = gtk_label_new (_("QTH Type")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -468,11 +470,12 @@ gtk_entry_set_text (GTK_ENTRY (wx), qthwx); g_free (qthwx); } +#ifdef HAS_LIBGPS if (qthgpsdserver) { gtk_entry_set_text (GTK_ENTRY (server), qthgpsdserver); g_free (qthgpsdserver); } - +#endif if (qthlat < 0.00) gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 1); else @@ -488,8 +491,10 @@ gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), fabs (qthlon)); gtk_spin_button_set_value (GTK_SPIN_BUTTON (alt), qthalt); +#ifdef HAS_LIBGPS gtk_spin_button_set_value (GTK_SPIN_BUTTON (port), qthgpsdport); gtk_combo_box_set_active (GTK_COMBO_BOX (type), qthtype); +#endif sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s:%d: Loaded %s for editing:\n"\ @@ -560,7 +565,10 @@ qthloc = gtk_entry_get_text (GTK_ENTRY (location)); qthdesc = gtk_entry_get_text (GTK_ENTRY (desc)); qthwx = gtk_entry_get_text (GTK_ENTRY (wx)); + +#ifdef HAS_LIBGPS qthgpsdserver = gtk_entry_get_text (GTK_ENTRY (server)); +#endif qthlat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lat)); if (gtk_combo_box_get_active (GTK_COMBO_BOX (ns))) @@ -571,8 +579,11 @@ qthlon = -qthlon; qthalt = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alt)); + +#ifdef HAS_LIBGPS qthgpsdport = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (port)); qthtype = gtk_combo_box_get_active ( GTK_COMBO_BOX (type)); +#endif /* get liststore */ liststore = GTK_LIST_STORE (gtk_tree_view_get_model (treeview)); Modified: trunk/src/sat-pref-qth.c =================================================================== --- trunk/src/sat-pref-qth.c 2011-03-30 23:16:02 UTC (rev 802) +++ trunk/src/sat-pref-qth.c 2011-03-30 23:50:34 UTC (rev 803) @@ -270,7 +270,7 @@ g_signal_connect (qthlist, "row-activated", G_CALLBACK (row_activated_cb), NULL); -# if HAS_LIBGPS +# ifdef HAS_LIBGPS /* GPSD enabled*/ /*server*/ renderer = gtk_cell_renderer_text_new (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-30 23:16:08
|
Revision: 802 http://gpredict.svn.sourceforge.net/gpredict/?rev=802&view=rev Author: aa1vs Date: 2011-03-30 23:16:02 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Check-in 1.3 windows packaging diff. Modified Paths: -------------- trunk/src/gpredict-utils.c trunk/src/gpredict-utils.h trunk/src/gtk-sat-map-popup.c trunk/src/gtk-sat-selector.c trunk/src/qth-data.c trunk/src/qth-editor.c trunk/src/sat-pref-qth-editor.c trunk/src/sat-pref-qth.c trunk/win32/Makefile trunk/win32/build-config.h trunk/win32/config.mk Modified: trunk/src/gpredict-utils.c =================================================================== --- trunk/src/gpredict-utils.c 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/gpredict-utils.c 2011-03-30 23:16:02 UTC (rev 802) @@ -498,3 +498,18 @@ return strnatcasecmp(s1,s2); #endif } + +char * gpredict_strcasestr(const char *s1, const char *s2) +{ + size_t s1_len = strlen(s1); + size_t s2_len = strlen(s2); + while (s1_len >= s2_len) { + if (strncasecmp(s1, s2, s2_len) == 0) + return (char *) s1; + + s1++; + s1_len--; + } + + return NULL; +} Modified: trunk/src/gpredict-utils.h =================================================================== --- trunk/src/gpredict-utils.h 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/gpredict-utils.h 2011-03-30 23:16:02 UTC (rev 802) @@ -63,4 +63,5 @@ void gdk2rgba (const GdkColor *color, guint16 alpha, guint *rgba); gchar *rgba2html (guint rgba); int gpredict_strcmp (const char *s1, const char *s2); +char *gpredict_strcasestr(const char *s1, const char *s2); #endif Modified: trunk/src/gtk-sat-map-popup.c =================================================================== --- trunk/src/gtk-sat-map-popup.c 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/gtk-sat-map-popup.c 2011-03-30 23:16:02 UTC (rev 802) @@ -345,7 +345,7 @@ sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - /* check wheather sat actially has AOS */ + /* check whether sat actually has AOS */ if (has_aos (sat, qth)) { if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { Modified: trunk/src/gtk-sat-selector.c =================================================================== --- trunk/src/gtk-sat-selector.c 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/gtk-sat-selector.c 2011-03-30 23:16:02 UTC (rev 802) @@ -924,7 +924,7 @@ /*if it is already selected then remove it from the available list*/ if (selected) return( FALSE); - if( strcasestr( satname, searchstring ) != (char *)NULL ) + if( gpredict_strcasestr( satname, searchstring ) != (char *)NULL ) return( TRUE ); else return( FALSE ); Modified: trunk/src/qth-data.c =================================================================== --- trunk/src/qth-data.c 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/qth-data.c 2011-03-30 23:16:02 UTC (rev 802) @@ -41,7 +41,7 @@ #include "time-tools.h" #include "locator.h" #if HAS_LIBGPS -#include <gps.h> +# include <gps.h> #endif void qth_validate(qth_t*qth); Modified: trunk/src/qth-editor.c =================================================================== --- trunk/src/qth-editor.c 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/qth-editor.c 2011-03-30 23:16:02 UTC (rev 802) @@ -348,10 +348,10 @@ gtk_table_attach_defaults (GTK_TABLE (table), alt, 1, 2, 6, 7); if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_IMPERIAL)) { - label = gtk_label_new (_("ft asl")); + label = gtk_label_new (_("ft above sea level")); } else { - label = gtk_label_new (_("m asl")); + label = gtk_label_new (_("m above sea level")); } gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 6, 7); @@ -376,6 +376,7 @@ GUINT_TO_POINTER (SELECTION_MODE_WX)); gtk_table_attach_defaults (GTK_TABLE (table), wxbut, 3, 4, 7, 8); +# if HAS_LIBGPS /* GPSD enabled*/ label = gtk_label_new (_("QTH Type")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -414,8 +415,8 @@ _("Set the port for GPSD to use. Default for gpsd is 2947."), NULL); gtk_table_attach_defaults (GTK_TABLE (table), port, 1, 2, 10, 11); +# endif - if (qth->name != NULL) update_widgets (qth); Modified: trunk/src/sat-pref-qth-editor.c =================================================================== --- trunk/src/sat-pref-qth-editor.c 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/sat-pref-qth-editor.c 2011-03-30 23:16:02 UTC (rev 802) @@ -333,10 +333,10 @@ gtk_table_attach_defaults (GTK_TABLE (table), alt, 1, 2, 6, 7); if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_IMPERIAL)) { - label = gtk_label_new (_("ft asl")); + label = gtk_label_new (_("ft above sea level")); } else { - label = gtk_label_new (_("m asl")); + label = gtk_label_new (_("m above sea level")); } gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 6, 7); @@ -360,6 +360,8 @@ G_CALLBACK (select_location), GUINT_TO_POINTER (SELECTION_MODE_WX)); gtk_table_attach_defaults (GTK_TABLE (table), wxbut, 3, 4, 7, 8); + +# if HAS_LIBGPS /* GPSD enabled*/ label = gtk_label_new (_("QTH Type")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); @@ -398,8 +400,8 @@ _("Set the port for GPSD to use. Default for gpsd is 2947."), NULL); gtk_table_attach_defaults (GTK_TABLE (table), port, 1, 2, 10, 11); +# endif - if (!new) update_widgets (treeview); Modified: trunk/src/sat-pref-qth.c =================================================================== --- trunk/src/sat-pref-qth.c 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/src/sat-pref-qth.c 2011-03-30 23:16:02 UTC (rev 802) @@ -187,6 +187,7 @@ column = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, "text", QTH_LIST_COL_NAME, NULL); + gtk_tree_view_column_set_expand(column, TRUE); gtk_tree_view_insert_column (GTK_TREE_VIEW (qthlist), column, -1); /* location column */ @@ -194,6 +195,7 @@ column = gtk_tree_view_column_new_with_attributes (_("Location"), renderer, "text", QTH_LIST_COL_LOC, NULL); + gtk_tree_view_column_set_expand(column, TRUE); gtk_tree_view_insert_column (GTK_TREE_VIEW (qthlist), column, -1); /* lat column */ @@ -267,6 +269,9 @@ g_signal_connect (qthlist, "row-activated", G_CALLBACK (row_activated_cb), NULL); + +# if HAS_LIBGPS + /* GPSD enabled*/ /*server*/ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (_("GPSD\nServer"), renderer, @@ -289,6 +294,7 @@ NULL); gtk_tree_view_insert_column (GTK_TREE_VIEW (qthlist), column, -1); gtk_tree_view_column_set_alignment (column, 0.5); +# endif return qthlist; } @@ -827,7 +833,7 @@ /* function below not used */ #if 0 -/** \brief Callback function to check each QTH for beeing the default */ +/** \brief Callback function to check each QTH for being the default */ static gboolean check_and_set_default_qth (GtkTreeModel *model, GtkTreePath *path, Modified: trunk/win32/Makefile =================================================================== --- trunk/win32/Makefile 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/win32/Makefile 2011-03-30 23:16:02 UTC (rev 802) @@ -5,8 +5,10 @@ # directories topsrc = .. -gcincdir = c:/mingw/include/goocanvas-0.10/goocanvas/ -gcsrcdir = $(topsrc)/goocanv8/src +glibdir = c:/mingw/include/glib-2.0 +gcincdir = c:/mingw/include/goocanvas/ +gcsrcdir = $(topsrc)/goocanvas-0.15/src + gpreddir = $(topsrc)/src sgpsdpdir = $(gpreddir)/sgpsdp @@ -22,13 +24,12 @@ # libraries GTKLIBS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs gtk+-win32-2.0) GLIBLIB := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs glib-2.0 gthread-2.0) -GUI_LIBS = $(GTKLIBS) $(GLIBLIB) -lgoocanvas libsgpsdp.lib -lcurldll -lwinmm -lws2_32 +GUI_LIBS = $(GTKLIBS) $(GLIBLIB) -lgoocanvas libsgpsdp.lib -lcurl.dll -lwinmm -lws2_32 LIBS = -lm - # flags/defines CFLAGS = -DHAVE_CONFIG_H -DHAVE_LIBCURL -DPACKAGE_LOCALE_DIR=\"/\" \ - -I. -I.. -I$(gpreddir) -I$(gcincdir) -I$(gcsrcdir) -I$(CROSSDIR)/include + -I. -I.. -I$(glibdir) -I$(gpreddir) -I$(gcincdir) -I$(gcsrcdir) -I$(CROSSDIR)/include GTK_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags gtk+-win32-2.0) # source paths @@ -121,6 +122,7 @@ pass-popup-menu.c \ pass-to-txt.c \ predict-tools.c \ + print-pass.c \ qth-data.c \ qth-editor.c \ radio-conf.c \ @@ -159,6 +161,7 @@ sat-pref-tle.c \ sat-vis.c \ save-pass.c \ + strnatcmp.c \ time-tools.c \ tle-tools.c \ tle-update.c \ Modified: trunk/win32/build-config.h =================================================================== --- trunk/win32/build-config.h 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/win32/build-config.h 2011-03-30 23:16:02 UTC (rev 802) @@ -86,4 +86,9 @@ #undef STDC_HEADERS /* Version number of package */ -#define VERSION "1.1" +#define VERSION "1.3" + +#define GETTEXT_PACKAGE "gpredict" + +#define HAS_LIBGPS 0 + Modified: trunk/win32/config.mk =================================================================== --- trunk/win32/config.mk 2011-03-29 00:55:07 UTC (rev 801) +++ trunk/win32/config.mk 2011-03-30 23:16:02 UTC (rev 802) @@ -1,7 +1,7 @@ # Configuration variables governing the build of grig for win32 # directory containing the cross tools -#CROSSDIR = /grga/mingw32/buildenv +CROSSDIR = /cygdrive/c/mingw # prefix for mingw tools (e.g. i586-mingw32msvc-gcc) #MGW_PREFIX = i586-mingw32msvc- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-29 00:55:13
|
Revision: 801 http://gpredict.svn.sourceforge.net/gpredict/?rev=801&view=rev Author: aa1vs Date: 2011-03-29 00:55:07 +0000 (Tue, 29 Mar 2011) Log Message: ----------- Update ChangeLog and NEWS Modified Paths: -------------- trunk/ChangeLog trunk/NEWS Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-29 00:42:01 UTC (rev 800) +++ trunk/ChangeLog 2011-03-29 00:55:07 UTC (rev 801) @@ -1,3 +1,29 @@ +2011-03-28 Charles Suprin <hamaa1vs at gmail.com> + + * src/gtk-rig-ctrl.c + * src/gtk-rot-ctrl.c + Apply Stephane Fillods patch to repair Win32 networking. + + * src/gtk-sat-selector.c + Remove strverscmp reference. + +2011-03-27 Charles Suprin <hamaa1vs at gmail.com> + + * src/gtk-azel-plot.c + * src/gtk-polar-plot.c + * src/gtk-polar-view-popup.c + * src/gtk-polar-view.c + * src/gtk-sat-list.c + * src/gtk-sat-module.c + * src/gtk-sat-selector.c + * src/gtk-single-sat.c + * src/gtk-sky-glance.c + * src/pass-to-txt.c + * src/sat-pass-dialogs.c + * src/time-tools.c + * src/time-tools.h + Rename julian_print_time daynum_to_str. + 2011-03-26 Charles Suprin <hamaa1vs at gmail.com> * src/predict-tools.c @@ -3,4 +29,12 @@ Change get_current_pass to log error if returned pass is not current. + * src/gtk-polar-view.c + * src/gtk-sat-list.c + * src/gtk-sat-map.c + * src/gtk-sat-selector.c + * src/sat-pass-dialogs.c + Clean up compiler warnings. + + 2011-03-25 Charles Suprin <hamaa1vs at gmail.com> Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2011-03-29 00:42:01 UTC (rev 800) +++ trunk/NEWS 2011-03-29 00:55:07 UTC (rev 801) @@ -3,6 +3,7 @@ - Feature request 3141555: gpsd support. - Applied and extended patch 3237220: natural sort for sat list in module config - Improve handling of decayed satellites. +- Fixed bug 3250344: Win32 uild not working with hamlib Changes in version 1.3 (1 Mar 2011) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-29 00:42:06
|
Revision: 800 http://gpredict.svn.sourceforge.net/gpredict/?rev=800&view=rev Author: aa1vs Date: 2011-03-29 00:42:01 +0000 (Tue, 29 Mar 2011) Log Message: ----------- Apply Stephan Fillods patch to repair Win32 networking. Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c trunk/src/gtk-rot-ctrl.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2011-03-29 00:30:50 UTC (rev 799) +++ trunk/src/gtk-rig-ctrl.c 2011-03-29 00:42:01 UTC (rev 800) @@ -2540,7 +2540,7 @@ return FALSE; } /* try to read answer */ - size = read (sock, buffout, 127); + size = recv (sock, buffout, 127, 0); if (size == -1) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: rigctld port closed"), @@ -2742,11 +2742,12 @@ #ifndef WIN32 shutdown (*sock, SHUT_RDWR); + close (*sock); #else shutdown (*sock, SD_BOTH); + closesocket (*sock); #endif - close (*sock); *sock = 0; Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2011-03-29 00:30:50 UTC (rev 799) +++ trunk/src/gtk-rot-ctrl.c 2011-03-29 00:42:01 UTC (rev 800) @@ -1372,12 +1372,12 @@ #ifndef WIN32 shutdown (*sock, SHUT_RDWR); + close (*sock); #else shutdown (*sock, SD_BOTH); + closesocket (*sock); #endif - close (*sock); - *sock=0; return TRUE; @@ -1414,7 +1414,7 @@ } /* try to read answer */ - size = read (ctrl->sock, buffout, sizeout); + size = recv (ctrl->sock, buffout, sizeout, 0); if (size == -1) { sat_log_log (SAT_LOG_LEVEL_ERROR, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-29 00:30:56
|
Revision: 799 http://gpredict.svn.sourceforge.net/gpredict/?rev=799&view=rev Author: aa1vs Date: 2011-03-29 00:30:50 +0000 (Tue, 29 Mar 2011) Log Message: ----------- Remove strverscmp reference. Modified Paths: -------------- trunk/src/gtk-sat-selector.c Modified: trunk/src/gtk-sat-selector.c =================================================================== --- trunk/src/gtk-sat-selector.c 2011-03-28 00:17:18 UTC (rev 798) +++ trunk/src/gtk-sat-selector.c 2011-03-29 00:30:50 UTC (rev 799) @@ -615,7 +615,7 @@ gtk_tree_model_get(model, a, GTK_SAT_SELECTOR_COL_NAME, &sat1, -1); gtk_tree_model_get(model, b, GTK_SAT_SELECTOR_COL_NAME, &sat2, -1); - ret = strverscmp (sat1, sat2); + ret = gpredict_strcmp (sat1, sat2); g_free (sat1); g_free (sat2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-28 00:17:24
|
Revision: 798 http://gpredict.svn.sourceforge.net/gpredict/?rev=798&view=rev Author: aa1vs Date: 2011-03-28 00:17:18 +0000 (Mon, 28 Mar 2011) Log Message: ----------- Rename julian_print_time daynum_to_str. Modified Paths: -------------- trunk/src/gtk-azel-plot.c trunk/src/gtk-polar-plot.c trunk/src/gtk-polar-view-popup.c trunk/src/gtk-polar-view.c trunk/src/gtk-sat-list.c trunk/src/gtk-sat-module.c trunk/src/gtk-sat-selector.c trunk/src/gtk-single-sat.c trunk/src/gtk-sky-glance.c trunk/src/pass-to-txt.c trunk/src/sat-pass-dialogs.c trunk/src/time-tools.c trunk/src/time-tools.h Modified: trunk/src/gtk-azel-plot.c =================================================================== --- trunk/src/gtk-azel-plot.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-azel-plot.c 2011-03-28 00:17:18 UTC (rev 798) @@ -297,7 +297,7 @@ /* get time */ xy_to_graph (polv, polv->x0 + (i+1) * xstep, 0.0, &t, &az, &el); - julian_print_time (buff, 7, "%H:%M", t); + daynum_to_str (buff, 7, "%H:%M", t); polv->xlab[i] = goo_canvas_text_model_new (root, buff, (gfloat) (polv->x0 + (i+1) * xstep), @@ -704,7 +704,7 @@ xy_to_graph (polv, x, y, &t, &az, &el); - julian_print_time(buff, 10, "%H:%M:%S", t); + daynum_to_str(buff, 10, "%H:%M:%S", t); /* cursor track */ text = g_strdup_printf ("T: %s, AZ: %.0f\302\260, EL: %.0f\302\260", buff, az, el); Modified: trunk/src/gtk-polar-plot.c =================================================================== --- trunk/src/gtk-polar-plot.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-polar-plot.c 2011-03-28 00:17:18 UTC (rev 798) @@ -979,7 +979,7 @@ col = sat_cfg_get_int (SAT_CFG_INT_POLAR_TRACK_COL); - julian_print_time (buff, 8, "%H:%M", time); + daynum_to_str (buff, 8, "%H:%M", time); if (x > pv->cx) { anchor = GTK_ANCHOR_EAST; Modified: trunk/src/gtk-polar-view-popup.c =================================================================== --- trunk/src/gtk-polar-view-popup.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-polar-view-popup.c 2011-03-28 00:17:18 UTC (rev 798) @@ -337,7 +337,7 @@ MOD_CFG_POLAR_TRACK_COL, SAT_CFG_INT_POLAR_TRACK_COL); - julian_print_time (buff, 8, "%H:%M", time); + daynum_to_str (buff, 8, "%H:%M", time); if (x > pv->cx) { anchor = GTK_ANCHOR_EAST; Modified: trunk/src/gtk-polar-view.c =================================================================== --- trunk/src/gtk-polar-view.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-polar-view.c 2011-03-28 00:17:18 UTC (rev 798) @@ -1113,7 +1113,7 @@ MOD_CFG_POLAR_TRACK_COL, SAT_CFG_INT_POLAR_TRACK_COL); - julian_print_time (buff, 8, "%H:%M", time); + daynum_to_str (buff, 8, "%H:%M", time); if (x > pv->cx) { anchor = GTK_ANCHOR_EAST; Modified: trunk/src/gtk-sat-list.c =================================================================== --- trunk/src/gtk-sat-list.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-sat-list.c 2011-03-28 00:17:18 UTC (rev 798) @@ -769,7 +769,7 @@ fmtstr = g_strconcat (alstr, tfstr, NULL); g_free (tfstr); - julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); + daynum_to_str (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); gtk_list_store_set (GTK_LIST_STORE (model), iter, SAT_LIST_COL_NEXT_EVENT, buff, @@ -1110,7 +1110,7 @@ /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); + daynum_to_str (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); g_object_set (renderer, "text", buff, Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-sat-module.c 2011-03-28 00:17:18 UTC (rev 798) @@ -1352,7 +1352,7 @@ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, module->tmgCdnum); + daynum_to_str (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, module->tmgCdnum); if (module->qth->type==QTH_GPSD_TYPE) { buff2=g_strdup_printf("%s GPS %0.3f seconds old", buff,fabs(module->tmgCdnum-module->qth->gpsd_update)*(24*3600)); Modified: trunk/src/gtk-sat-selector.c =================================================================== --- trunk/src/gtk-sat-selector.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-sat-selector.c 2011-03-28 00:17:18 UTC (rev 798) @@ -786,7 +786,7 @@ /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time(buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); + daynum_to_str(buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); g_object_set (renderer, "text", buff, Modified: trunk/src/gtk-single-sat.c =================================================================== --- trunk/src/gtk-single-sat.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-single-sat.c 2011-03-28 00:17:18 UTC (rev 798) @@ -495,7 +495,7 @@ /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, number); + daynum_to_str (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, number); g_free (fmtstr); @@ -516,7 +516,7 @@ /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time(tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, sat->aos); + daynum_to_str(tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, sat->aos); g_free (fmtstr); @@ -533,7 +533,7 @@ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, sat->los); + daynum_to_str (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, sat->los); g_free (fmtstr); Modified: trunk/src/gtk-sky-glance.c =================================================================== --- trunk/src/gtk-sky-glance.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/gtk-sky-glance.c 2011-03-28 00:17:18 UTC (rev 798) @@ -402,7 +402,7 @@ NULL); /* hour tick label */ - julian_print_time (buff, 3, "%H", th); + daynum_to_str (buff, 3, "%H", th); hrl = goo_canvas_text_model_new (root, buff, xh, skg->h + 12, -1, GTK_ANCHOR_N, @@ -634,7 +634,7 @@ /* get time corresponding to x */ t = x2t (skg, event->x); - julian_print_time (buff, 6, "%H:%M", t); + daynum_to_str (buff, 6, "%H:%M", t); /* in order to avoid label clipping close to the edges of the chart, the label is placed left/right of the cursor @@ -1019,9 +1019,9 @@ tmppass = (pass_t *) g_slist_nth_data (passes, i); skypass->pass = copy_pass (tmppass); - julian_print_time (aosstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->aos); - julian_print_time (losstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->los); - julian_print_time (tcastr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->tca); + daynum_to_str (aosstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->aos); + daynum_to_str (losstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->los); + daynum_to_str (tcastr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->tca); /* box tooltip will contain pass summary */ tooltip = g_strdup_printf("<big><b>%s</b>\n</big>\n"\ Modified: trunk/src/pass-to-txt.c =================================================================== --- trunk/src/pass-to-txt.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/pass-to-txt.c 2011-03-28 00:17:18 UTC (rev 798) @@ -203,7 +203,7 @@ /* first, get the length of the time field */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - size = julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); + size = daynum_to_str (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); g_free (fmtstr); @@ -257,7 +257,7 @@ /* first, get the length of the time field */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); + daynum_to_str (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); /* get number of rows */ num = g_slist_length (pass->details); @@ -268,7 +268,7 @@ detail = PASS_DETAIL (g_slist_nth_data (pass->details, i)); /* time */ - julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, detail->time); + daynum_to_str (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, detail->time); line = g_strdup_printf (" %s", tbuff); @@ -481,7 +481,7 @@ /* first, get the length of the time field */ pass = PASS (g_slist_nth_data (passes, 0)); fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - size = julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); + size = daynum_to_str (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); g_free (fmtstr); @@ -534,7 +534,7 @@ /* first, get the length of the time field */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); + daynum_to_str(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); /* get number of rows */ num = g_slist_length (passes); @@ -544,12 +544,12 @@ pass = PASS (g_slist_nth_data (passes, i)); /* AOS */ - julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); + daynum_to_str(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); line = g_strdup_printf (" %s", tbuff); /* TCA */ - julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->tca); + daynum_to_str(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->tca); buff = g_strdup (line); g_free (line); @@ -557,7 +557,7 @@ g_free (buff); /* LOS */ - julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->los); + daynum_to_str(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->los); buff = g_strdup (line); g_free (line); Modified: trunk/src/sat-pass-dialogs.c =================================================================== --- trunk/src/sat-pass-dialogs.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/sat-pass-dialogs.c 2011-03-28 00:17:18 UTC (rev 798) @@ -863,7 +863,7 @@ /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); + daynum_to_str (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); g_object_set (renderer, "text", buff, Modified: trunk/src/time-tools.c =================================================================== --- trunk/src/time-tools.c 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/time-tools.c 2011-03-28 00:17:18 UTC (rev 798) @@ -64,7 +64,7 @@ } int -julian_print_time(char *s, size_t max, const char *format, gdouble jultime){ +daynum_to_str(char *s, size_t max, const char *format, gdouble jultime){ // printf("Someone called me\n"); time_t tim; size_t size=0; Modified: trunk/src/time-tools.h =================================================================== --- trunk/src/time-tools.h 2011-03-26 20:09:02 UTC (rev 797) +++ trunk/src/time-tools.h 2011-03-28 00:17:18 UTC (rev 798) @@ -30,7 +30,7 @@ gdouble get_current_daynum (void); //long get_daynum_from_dmy (int d, int m, int y); -int julian_print_time(char *s, size_t max, const char *format, gdouble jultime); +int daynum_to_str(char *s, size_t max, const char *format, gdouble jultime); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Alexandru C. <oz...@gm...> - 2011-03-26 21:24:28
|
Nice cleanup, but the name julian_print_time() seems a bit misleading. Maybe something like daynum_to_str() or strftime_jd() since it is a wrapper around strftime()? Alex On Sat, Mar 26, 2011 at 8:56 PM, <aa...@us...> wrote: > Revision: 796 > http://gpredict.svn.sourceforge.net/gpredict/?rev=796&view=rev > Author: aa1vs > Date: 2011-03-26 19:56:13 +0000 (Sat, 26 Mar 2011) > > Log Message: > ----------- > Change time printing routines to julian_print_time in time-tools.c. > > Modified Paths: > -------------- > trunk/src/gtk-azel-plot.c > trunk/src/gtk-polar-plot.c > trunk/src/gtk-polar-view-popup.c > trunk/src/gtk-polar-view.c > trunk/src/gtk-sat-list.c > trunk/src/gtk-sat-module.c > trunk/src/gtk-sat-selector.c > trunk/src/gtk-single-sat.c > trunk/src/gtk-sky-glance.c > trunk/src/pass-to-txt.c > trunk/src/predict-tools.c > trunk/src/sat-pass-dialogs.c > trunk/src/time-tools.c > trunk/src/time-tools.h > .... > > Modified: trunk/src/time-tools.c > =================================================================== > --- trunk/src/time-tools.c 2011-03-26 17:38:17 UTC (rev 795) > +++ trunk/src/time-tools.c 2011-03-26 19:56:13 UTC (rev 796) > @@ -34,6 +34,7 @@ > #endif > #include "sgpsdp/sgp4sdp4.h" > #include "time-tools.h" > +#include "sat-cfg.h" > //#ifdef G_OS_WIN32 > //# include "libc_internal.h" > //# include "libc_interface.h" > @@ -62,7 +63,24 @@ > return daynum; > } > > +int > +julian_print_time(char *s, size_t max, const char *format, gdouble jultime){ > + // printf("Someone called me\n"); > + time_t tim; > + size_t size=0; > + tim = (jultime - 2440587.5)*86400.0; > + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) > + size = strftime (s, max, format, localtime (&tim)); > + else > + size = strftime (s, max, format, gmtime (&tim)); > > + if (size<max) > + s[size] = '\0'; > + else > + s[max-1] = '\0'; > + return size; > +} > + > /* This function calculates the day number from m/d/y. */ > /* Legacy code no longer in use > long > > Modified: trunk/src/time-tools.h > =================================================================== > --- trunk/src/time-tools.h 2011-03-26 17:38:17 UTC (rev 795) > +++ trunk/src/time-tools.h 2011-03-26 19:56:13 UTC (rev 796) > @@ -30,6 +30,7 @@ > > gdouble get_current_daynum (void); > //long get_daynum_from_dmy (int d, int m, int y); > +int julian_print_time(char *s, size_t max, const char *format, gdouble jultime); > #endif > |
From: <aa...@us...> - 2011-03-26 20:09:09
|
Revision: 797 http://gpredict.svn.sourceforge.net/gpredict/?rev=797&view=rev Author: aa1vs Date: 2011-03-26 20:09:02 +0000 (Sat, 26 Mar 2011) Log Message: ----------- Clean up compiler warnings. Modified Paths: -------------- trunk/src/gtk-polar-view.c trunk/src/gtk-sat-list.c trunk/src/gtk-sat-map.c trunk/src/gtk-sat-selector.c trunk/src/sat-pass-dialogs.c Modified: trunk/src/gtk-polar-view.c =================================================================== --- trunk/src/gtk-polar-view.c 2011-03-26 19:56:13 UTC (rev 796) +++ trunk/src/gtk-polar-view.c 2011-03-26 20:09:02 UTC (rev 797) @@ -42,6 +42,7 @@ #include "gtk-polar-view-popup.h" #include "gtk-polar-view.h" #include "sat-info.h" +#include "time-tools.h" #ifdef HAVE_CONFIG_H # include <build-config.h> #endif @@ -1100,7 +1101,6 @@ static GooCanvasItemModel *create_time_tick (GtkPolarView *pv, gdouble time, gfloat x, gfloat y) { GooCanvasItemModel *item; - time_t t; gchar buff[7]; GtkAnchorType anchor; GooCanvasItemModel *root; Modified: trunk/src/gtk-sat-list.c =================================================================== --- trunk/src/gtk-sat-list.c 2011-03-26 19:56:13 UTC (rev 796) +++ trunk/src/gtk-sat-list.c 2011-03-26 20:09:02 UTC (rev 797) @@ -44,6 +44,7 @@ #include "sat-vis.h" #include "sat-info.h" #include "time-tools.h" +#include "orbit-tools.h" #ifdef HAVE_CONFIG_H # include <build-config.h> #endif Modified: trunk/src/gtk-sat-map.c =================================================================== --- trunk/src/gtk-sat-map.c 2011-03-26 19:56:13 UTC (rev 796) +++ trunk/src/gtk-sat-map.c 2011-03-26 20:09:02 UTC (rev 797) @@ -57,6 +57,7 @@ #include "sat-debugger.h" #include "sat-info.h" #include "predict-tools.h" +#include "orbit-tools.h" #ifdef HAVE_CONFIG_H # include <build-config.h> #endif @@ -1890,7 +1891,6 @@ /*get rid of a decayed satellite*/ if (decayed(sat) && obj!=NULL) { - SAT_MAP_OBJ (g_hash_table_remove (satmap->obj, catnum)); /*remove items*/ idx = goo_canvas_item_model_find_child (root,obj->marker); if (idx !=-1) Modified: trunk/src/gtk-sat-selector.c =================================================================== --- trunk/src/gtk-sat-selector.c 2011-03-26 19:56:13 UTC (rev 796) +++ trunk/src/gtk-sat-selector.c 2011-03-26 20:09:02 UTC (rev 797) @@ -46,8 +46,8 @@ #include "sat-cfg.h" #include "gtk-sat-selector.h" #include "gpredict-utils.h" +#include "time-tools.h" - static void gtk_sat_selector_class_init (GtkSatSelectorClass *class); static void gtk_sat_selector_init (GtkSatSelector *selector); static void gtk_sat_selector_destroy (GtkObject *object); @@ -773,8 +773,6 @@ gchar buff[TIME_FORMAT_MAX_LENGTH]; gchar *fmtstr; guint coli = GPOINTER_TO_UINT (column); - time_t t; - guint size; gtk_tree_model_get (model, iter, coli, &number, -1); Modified: trunk/src/sat-pass-dialogs.c =================================================================== --- trunk/src/sat-pass-dialogs.c 2011-03-26 19:56:13 UTC (rev 796) +++ trunk/src/sat-pass-dialogs.c 2011-03-26 20:09:02 UTC (rev 797) @@ -47,6 +47,7 @@ #include "gtk-azel-plot.h" #include "save-pass.h" #include "print-pass.h" +#include "time-tools.h" @@ -849,8 +850,6 @@ gchar buff[TIME_FORMAT_MAX_LENGTH]; gchar *fmtstr; guint coli = GPOINTER_TO_UINT (column); - time_t t; - guint size; gtk_tree_model_get (model, iter, coli, &number, -1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-26 19:56:20
|
Revision: 796 http://gpredict.svn.sourceforge.net/gpredict/?rev=796&view=rev Author: aa1vs Date: 2011-03-26 19:56:13 +0000 (Sat, 26 Mar 2011) Log Message: ----------- Change time printing routines to julian_print_time in time-tools.c. Modified Paths: -------------- trunk/src/gtk-azel-plot.c trunk/src/gtk-polar-plot.c trunk/src/gtk-polar-view-popup.c trunk/src/gtk-polar-view.c trunk/src/gtk-sat-list.c trunk/src/gtk-sat-module.c trunk/src/gtk-sat-selector.c trunk/src/gtk-single-sat.c trunk/src/gtk-sky-glance.c trunk/src/pass-to-txt.c trunk/src/predict-tools.c trunk/src/sat-pass-dialogs.c trunk/src/time-tools.c trunk/src/time-tools.h Modified: trunk/src/gtk-azel-plot.c =================================================================== --- trunk/src/gtk-azel-plot.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-azel-plot.c 2011-03-26 19:56:13 UTC (rev 796) @@ -234,7 +234,6 @@ guint i; gdouble xstep,ystep; gdouble t,az,el; - time_t tim; gchar buff[7]; gchar *txt; @@ -298,17 +297,8 @@ /* get time */ xy_to_graph (polv, polv->x0 + (i+1) * xstep, 0.0, &t, &az, &el); - /* convert julian date to struct tm */ - tim = (t - 2440587.5)*86400.0; + julian_print_time (buff, 7, "%H:%M", t); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 7, "%H:%M", localtime (&tim)); - else - strftime (buff, 7, "%H:%M", gmtime (&tim)); - - buff[6]='\0'; - polv->xlab[i] = goo_canvas_text_model_new (root, buff, (gfloat) (polv->x0 + (i+1) * xstep), (gfloat) (polv->y0 + 5), @@ -694,7 +684,6 @@ { GtkAzelPlot *polv = GTK_AZEL_PLOT (data); gdouble t,az,el; - time_t tim; gfloat x,y; gchar *text; gchar buff[10]; @@ -715,17 +704,8 @@ xy_to_graph (polv, x, y, &t, &az, &el); - /* convert julian date to struct tm */ - tim = (t - 2440587.5)*86400.0; + julian_print_time(buff, 10, "%H:%M:%S", t); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 10, "%H:%M:%S", localtime (&tim)); - else - strftime (buff, 10, "%H:%M:%S", gmtime (&tim)); - - buff[8]='\0'; - /* cursor track */ text = g_strdup_printf ("T: %s, AZ: %.0f\302\260, EL: %.0f\302\260", buff, az, el); g_object_set (polv->curs, "text", text, NULL); Modified: trunk/src/gtk-polar-plot.c =================================================================== --- trunk/src/gtk-polar-plot.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-polar-plot.c 2011-03-26 19:56:13 UTC (rev 796) @@ -970,7 +970,6 @@ create_time_tick (GtkPolarPlot *pv, gdouble time, gfloat x, gfloat y) { GooCanvasItemModel *item; - time_t t; gchar buff[7]; GtkAnchorType anchor; GooCanvasItemModel *root; @@ -980,17 +979,8 @@ col = sat_cfg_get_int (SAT_CFG_INT_POLAR_TRACK_COL); - /* convert julian date to struct tm */ - t = (time - 2440587.5)*86400.; + julian_print_time (buff, 8, "%H:%M", time); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 8, "%H:%M", localtime (&t)); - else - strftime (buff, 8, "%H:%M", gmtime (&t)); - - buff[6]='\0'; - if (x > pv->cx) { anchor = GTK_ANCHOR_EAST; x -= 5; Modified: trunk/src/gtk-polar-view-popup.c =================================================================== --- trunk/src/gtk-polar-view-popup.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-polar-view-popup.c 2011-03-26 19:56:13 UTC (rev 796) @@ -325,7 +325,6 @@ create_time_tick (GtkPolarView *pv, gdouble time, gfloat x, gfloat y) { GooCanvasItemModel *item; - time_t t; gchar buff[7]; GtkAnchorType anchor; GooCanvasItemModel *root; @@ -338,17 +337,8 @@ MOD_CFG_POLAR_TRACK_COL, SAT_CFG_INT_POLAR_TRACK_COL); - /* convert julian date to struct tm */ - t = (time - 2440587.5)*86400.; + julian_print_time (buff, 8, "%H:%M", time); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 8, "%H:%M", localtime (&t)); - else - strftime (buff, 8, "%H:%M", gmtime (&t)); - - buff[6]='\0'; - if (x > pv->cx) { anchor = GTK_ANCHOR_EAST; x -= 5; Modified: trunk/src/gtk-polar-view.c =================================================================== --- trunk/src/gtk-polar-view.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-polar-view.c 2011-03-26 19:56:13 UTC (rev 796) @@ -1113,17 +1113,8 @@ MOD_CFG_POLAR_TRACK_COL, SAT_CFG_INT_POLAR_TRACK_COL); - /* convert julian date to struct tm */ - t = (time - 2440587.5)*86400.; - - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 8, "%H:%M", localtime (&t)); - else - strftime (buff, 8, "%H:%M", gmtime (&t)); - - buff[6]='\0'; - + julian_print_time (buff, 8, "%H:%M", time); + if (x > pv->cx) { anchor = GTK_ANCHOR_EAST; x -= 5; Modified: trunk/src/gtk-sat-list.c =================================================================== --- trunk/src/gtk-sat-list.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-sat-list.c 2011-03-26 19:56:13 UTC (rev 796) @@ -43,6 +43,7 @@ #include "locator.h" #include "sat-vis.h" #include "sat-info.h" +#include "time-tools.h" #ifdef HAVE_CONFIG_H # include <build-config.h> #endif @@ -742,8 +743,6 @@ gchar *tfstr; gchar *fmtstr; gchar *alstr; - time_t t; - guint size; if (sat->aos > sat->los) { @@ -764,26 +763,13 @@ } else { - /* convert julian date to struct tm */ - t = (number - 2440587.5)*86400.; - /* format the number */ tfstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); fmtstr = g_strconcat (alstr, tfstr, NULL); g_free (tfstr); + + julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, - fmtstr, localtime (&t)); - else - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, - fmtstr, gmtime (&t)); - - if (size == 0) - /* size > MAX_LENGTH */ - buff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - gtk_list_store_set (GTK_LIST_STORE (model), iter, SAT_LIST_COL_NEXT_EVENT, buff, -1); @@ -1109,8 +1095,6 @@ gchar buff[TIME_FORMAT_MAX_LENGTH]; gchar *fmtstr; guint coli = GPOINTER_TO_UINT (column); - time_t t; - guint size; gtk_tree_model_get (model, iter, coli, &number, -1); @@ -1121,22 +1105,11 @@ NULL); } else { - - /* convert julian date to struct tm */ - t = (number - 2440587.5)*86400.; - + /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > TIME_FORMAT_MAX_LENGTH */ - buff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; + julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); g_object_set (renderer, "text", buff, Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-sat-module.c 2011-03-26 19:56:13 UTC (rev 796) @@ -69,6 +69,7 @@ #include "gtk-rot-ctrl.h" #include "gtk-sky-glance.h" #include "compat.h" +#include "time-tools.h" //#ifdef G_OS_WIN32 //# include "libc_internal.h" @@ -1345,27 +1346,14 @@ update_header (GtkSatModule *module) { gchar *fmtstr; - time_t t; - guint size; gchar buff[TIME_FORMAT_MAX_LENGTH+1]; gchar *buff2; - t = (module->tmgCdnum - 2440587.5)*86400.; - fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - if (size < TIME_FORMAT_MAX_LENGTH) - buff[size]='\0'; - else - buff[TIME_FORMAT_MAX_LENGTH]='\0'; - + julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, module->tmgCdnum); + if (module->qth->type==QTH_GPSD_TYPE) { buff2=g_strdup_printf("%s GPS %0.3f seconds old", buff,fabs(module->tmgCdnum-module->qth->gpsd_update)*(24*3600)); gtk_label_set_text (GTK_LABEL (module->header), buff2); Modified: trunk/src/gtk-sat-selector.c =================================================================== --- trunk/src/gtk-sat-selector.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-sat-selector.c 2011-03-26 19:56:13 UTC (rev 796) @@ -786,22 +786,10 @@ } else { - /* convert julian date to struct tm */ - t = (number - 2440587.5)*86400.; - /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); + julian_print_time(buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > TIME_FORMAT_MAX_LENGTH */ - buff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - g_object_set (renderer, "text", buff, NULL); Modified: trunk/src/gtk-single-sat.c =================================================================== --- trunk/src/gtk-single-sat.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-single-sat.c 2011-03-26 19:56:13 UTC (rev 796) @@ -49,8 +49,8 @@ #include "orbit-tools.h" #include "predict-tools.h" #include "sat-pass-dialogs.h" +#include "time-tools.h" - /** \brief Column titles indexed with column symb. refs. */ const gchar *SINGLE_SAT_FIELD_TITLE[SINGLE_SAT_FIELD_NUMBER] = { N_("Azimuth"), @@ -392,8 +392,6 @@ gint retcode; gchar *fmtstr; gchar *alstr; - time_t t; - guint size; sat_vis_t vis; @@ -495,22 +493,10 @@ } if (number > 0.0) { - /* convert julian date to struct tm */ - t = (number - 2440587.5)*86400.; - /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); + julian_print_time (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, number); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > MAX_LENGTH */ - tbuf[TIME_FORMAT_MAX_LENGTH-1]='\0'; - g_free (fmtstr); buff = g_strconcat (alstr, tbuf, NULL); @@ -527,21 +513,10 @@ case SINGLE_SAT_FIELD_AOS: if (sat->aos > 0.0) { - /* convert julian date to struct tm */ - t = (sat->aos - 2440587.5)*86400.; - /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > MAX_LENGTH */ - tbuf[TIME_FORMAT_MAX_LENGTH-1]='\0'; + julian_print_time(tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, sat->aos); g_free (fmtstr); @@ -555,21 +530,10 @@ case SINGLE_SAT_FIELD_LOS: if (sat->los > 0.0) { - /* convert julian date to struct tm */ - t = (sat->los - 2440587.5)*86400.; - /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > MAX_LENGTH */ - tbuf[TIME_FORMAT_MAX_LENGTH-1]='\0'; + julian_print_time (tbuf, TIME_FORMAT_MAX_LENGTH, fmtstr, sat->los); g_free (fmtstr); Modified: trunk/src/gtk-sky-glance.c =================================================================== --- trunk/src/gtk-sky-glance.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/gtk-sky-glance.c 2011-03-26 19:56:13 UTC (rev 796) @@ -108,9 +108,7 @@ static gdouble t2x (GtkSkyGlance *skg, gdouble t); static gdouble x2t (GtkSkyGlance *skg, gdouble x); -static gchar *time_to_str (gdouble julutc); - static GtkVBoxClass *parent_class = NULL; @@ -334,7 +332,6 @@ GooCanvasItemModel *hrt,*hrl,*hrm; guint i,n; gdouble th,tm; - time_t tt; gdouble xh,xm; gchar buff[3]; @@ -405,13 +402,8 @@ NULL); /* hour tick label */ - tt = (th - 2440587.5)*86400.0; - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 3, "%H", localtime (&tt)); - else - strftime (buff, 3, "%H", gmtime (&tt)); - - buff[2] = '\0'; + julian_print_time (buff, 3, "%H", th); + hrl = goo_canvas_text_model_new (root, buff, xh, skg->h + 12, -1, GTK_ANCHOR_N, "font", "Sans 8", @@ -628,7 +620,6 @@ GtkSkyGlance *skg = GTK_SKY_GLANCE (data); GooCanvasPoints *pts; gdouble t; - time_t tt; gchar buff[6]; /* update cursor tracking line and time label */ @@ -643,17 +634,8 @@ /* get time corresponding to x */ t = x2t (skg, event->x); - /* convert julian date to struct tm */ - tt = (t - 2440587.5)*86400.; + julian_print_time (buff, 6, "%H:%M", t); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 6, "%H:%M", localtime (&tt)); - else - strftime (buff, 6, "%H:%M", gmtime (&tt)); - - buff[5] = '\0'; - /* in order to avoid label clipping close to the edges of the chart, the label is placed left/right of the cursor tracking line depending on which half we are in. @@ -994,9 +976,9 @@ /* tooltips vars */ gchar *tooltip; /* the complete tooltips string */ - gchar *aosstr; /* AOS time string */ - gchar *losstr; /* LOS time string */ - gchar *tcastr; /* TCA time string */ + gchar aosstr[100]; /* AOS time string */ + gchar losstr[100]; /* LOS time string */ + gchar tcastr[100]; /* TCA time string */ /* FIXME: @@ -1037,9 +1019,9 @@ tmppass = (pass_t *) g_slist_nth_data (passes, i); skypass->pass = copy_pass (tmppass); - aosstr = time_to_str (skypass->pass->aos); - losstr = time_to_str (skypass->pass->los); - tcastr = time_to_str (skypass->pass->tca); + julian_print_time (aosstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->aos); + julian_print_time (losstr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->los); + julian_print_time (tcastr,TIME_FORMAT_MAX_LENGTH, sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT),skypass->pass->tca); /* box tooltip will contain pass summary */ tooltip = g_strdup_printf("<big><b>%s</b>\n</big>\n"\ @@ -1052,10 +1034,6 @@ tcastr, skypass->pass->maxel_az, skypass->pass->max_el, losstr, skypass->pass->los_az); - g_free (aosstr); - g_free (losstr); - g_free (tcastr); - skypass->box = goo_canvas_rect_model_new (root, 10, 10, 20, 20, /* dummy coordinates */ "stroke-color-rgba", bcol, "fill-color-rgba", fcol, @@ -1092,47 +1070,3 @@ skg->satlab = g_slist_append (skg->satlab, lab); } } - - - -/** \brief Convert "jul_utc" time to formatted string - * \param julutc The time to convert - * \return A newly allocated string containing the formatted time (should be freed by caller) - * - * \bug This code is duplicated many places. - */ -static gchar *time_to_str (gdouble julutc) -{ - gchar buff[TIME_FORMAT_MAX_LENGTH]; - gchar *fmtstr; - gchar *timestr; - time_t t; - guint size; - - - /* convert julian date to struct time_t */ - t = (julutc - 2440587.5)*86400.; - - /* format the number */ - fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) { - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - } - else { - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - } - - g_free (fmtstr); - - - if (size == 0) - /* size > MAX_LENGTH */ - buff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - - timestr = g_strdup (buff); - - - return timestr; -} Modified: trunk/src/pass-to-txt.c =================================================================== --- trunk/src/pass-to-txt.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/pass-to-txt.c 2011-03-26 19:56:13 UTC (rev 796) @@ -34,6 +34,7 @@ #include "locator.h" #include "sat-vis.h" #include "pass-to-txt.h" +#include "time-tools.h" #ifdef HAVE_CONFIG_H # include <build-config.h> #endif @@ -191,7 +192,6 @@ pass_to_txt_tblheader (pass_t *pass, qth_t *qth, gint fields) { gchar *fmtstr; - time_t t; guint size; gchar tbuff[TIME_FORMAT_MAX_LENGTH]; guint i; @@ -203,13 +203,8 @@ /* first, get the length of the time field */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - t = (pass->aos - 2440587.5)*86400.; + size = julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - g_free (fmtstr); /* add time column */ @@ -249,8 +244,6 @@ pass_to_txt_tblcontents (pass_t *pass, qth_t *qth, gint fields) { gchar *fmtstr; - time_t t; - guint size; gchar tbuff[TIME_FORMAT_MAX_LENGTH]; guint i,num; gchar *line; @@ -264,17 +257,8 @@ /* first, get the length of the time field */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - t = (pass->aos - 2440587.5)*86400.; + julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > MAX_LENGTH */ - tbuff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - /* get number of rows */ num = g_slist_length (pass->details); @@ -284,15 +268,7 @@ detail = PASS_DETAIL (g_slist_nth_data (pass->details, i)); /* time */ - t = (detail->time - 2440587.5)*86400.; - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > MAX_LENGTH */ - tbuff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; + julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, detail->time); line = g_strdup_printf (" %s", tbuff); @@ -492,7 +468,6 @@ passes_to_txt_tblheader (GSList *passes, qth_t *qth, gint fields) { gchar *fmtstr; - time_t t; guint size; gchar tbuff[TIME_FORMAT_MAX_LENGTH]; guint i; @@ -506,17 +481,8 @@ /* first, get the length of the time field */ pass = PASS (g_slist_nth_data (passes, 0)); fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - t = (pass->aos - 2440587.5)*86400.; + size = julian_print_time (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > TIME_FORMAT_MAX_LENGTH */ - tbuff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - g_free (fmtstr); /* add AOS, TCA, and LOS columns */ @@ -556,8 +522,6 @@ passes_to_txt_tblcontents (GSList *passes, qth_t *qth, gint fields) { gchar *fmtstr; - time_t t; - guint size; gchar tbuff[TIME_FORMAT_MAX_LENGTH]; guint i,num; gchar *line = NULL; @@ -570,17 +534,8 @@ /* first, get the length of the time field */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); - t = (pass->aos - 2440587.5)*86400.; + julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > TIME_FORMAT_MAX_LENGTH */ - tbuff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - /* get number of rows */ num = g_slist_length (passes); @@ -589,47 +544,21 @@ pass = PASS (g_slist_nth_data (passes, i)); /* AOS */ - t = (pass->aos - 2440587.5)*86400.; - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); + julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->aos); - if (size == 0) - /* size > TIME_FORMAT_MAX_LENGTH */ - tbuff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - line = g_strdup_printf (" %s", tbuff); /* TCA */ - t = (pass->tca - 2440587.5)*86400.; - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); + julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->tca); - if (size == 0) - /* size > TIME_FORMAT_MAX_LENGTH */ - tbuff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - - buff = g_strdup (line); g_free (line); line = g_strdup_printf ("%s %s", buff, tbuff); g_free (buff); /* LOS */ - t = (pass->los - 2440587.5)*86400.; - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); + julian_print_time(tbuff, TIME_FORMAT_MAX_LENGTH, fmtstr, pass->los); - if (size == 0) - /* size > TIME_FORMAT_MAX_LENGTH */ - tbuff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - - buff = g_strdup (line); g_free (line); line = g_strdup_printf ("%s %s", buff, tbuff); Modified: trunk/src/predict-tools.c =================================================================== --- trunk/src/predict-tools.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/predict-tools.c 2011-03-26 19:56:13 UTC (rev 796) @@ -502,7 +502,7 @@ /* Find los of next pass or of current pass */ los = find_los (sat, qth, t0, maxdt); // See if a pass is ongoing - aos = find_aos (sat, qth, t0, maxdt); + aos = find_aos (sat, qth, t0, start + maxdt - t0); /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */ /* __FILE__, */ /* __FUNCTION__, */ Modified: trunk/src/sat-pass-dialogs.c =================================================================== --- trunk/src/sat-pass-dialogs.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/sat-pass-dialogs.c 2011-03-26 19:56:13 UTC (rev 796) @@ -862,27 +862,10 @@ } else { - /* convert julian date to struct tm */ - t = (number - 2440587.5)*86400.; - /* format the number */ fmtstr = sat_cfg_get_str (SAT_CFG_STR_TIME_FORMAT); + julian_print_time (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, number); - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, localtime (&t)); - else - size = strftime (buff, TIME_FORMAT_MAX_LENGTH, fmtstr, gmtime (&t)); - - if (size == 0) - /* size > MAX_LENGTH */ - buff[TIME_FORMAT_MAX_LENGTH-1] = '\0'; - /* - if (size < TIME_FORMAT_MAX_LENGTH) - buff[size]='\0'; - else - buff[TIME_FORMAT_MAX_LENGTH]='\0'; -*/ g_object_set (renderer, "text", buff, NULL); Modified: trunk/src/time-tools.c =================================================================== --- trunk/src/time-tools.c 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/time-tools.c 2011-03-26 19:56:13 UTC (rev 796) @@ -34,6 +34,7 @@ #endif #include "sgpsdp/sgp4sdp4.h" #include "time-tools.h" +#include "sat-cfg.h" //#ifdef G_OS_WIN32 //# include "libc_internal.h" //# include "libc_interface.h" @@ -62,7 +63,24 @@ return daynum; } +int +julian_print_time(char *s, size_t max, const char *format, gdouble jultime){ + // printf("Someone called me\n"); + time_t tim; + size_t size=0; + tim = (jultime - 2440587.5)*86400.0; + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) + size = strftime (s, max, format, localtime (&tim)); + else + size = strftime (s, max, format, gmtime (&tim)); + if (size<max) + s[size] = '\0'; + else + s[max-1] = '\0'; + return size; +} + /* This function calculates the day number from m/d/y. */ /* Legacy code no longer in use long Modified: trunk/src/time-tools.h =================================================================== --- trunk/src/time-tools.h 2011-03-26 17:38:17 UTC (rev 795) +++ trunk/src/time-tools.h 2011-03-26 19:56:13 UTC (rev 796) @@ -30,6 +30,7 @@ gdouble get_current_daynum (void); //long get_daynum_from_dmy (int d, int m, int y); +int julian_print_time(char *s, size_t max, const char *format, gdouble jultime); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-26 17:38:23
|
Revision: 795 http://gpredict.svn.sourceforge.net/gpredict/?rev=795&view=rev Author: aa1vs Date: 2011-03-26 17:38:17 +0000 (Sat, 26 Mar 2011) Log Message: ----------- Change get current pass to log error if non-current pass returned. Modified Paths: -------------- trunk/ChangeLog trunk/src/predict-tools.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-26 17:13:33 UTC (rev 794) +++ trunk/ChangeLog 2011-03-26 17:38:17 UTC (rev 795) @@ -1,3 +1,8 @@ +2011-03-26 Charles Suprin <hamaa1vs at gmail.com> + + * src/predict-tools.c + Change get_current_pass to log error if returned pass is not current. + 2011-03-25 Charles Suprin <hamaa1vs at gmail.com> * AUTHORS Modified: trunk/src/predict-tools.c =================================================================== --- trunk/src/predict-tools.c 2011-03-26 17:13:33 UTC (rev 794) +++ trunk/src/predict-tools.c 2011-03-26 17:38:17 UTC (rev 795) @@ -913,9 +913,11 @@ pass_t * get_current_pass (sat_t *sat_in, qth_t *qth, gdouble start) { - gdouble t; + gdouble t,t0; + gdouble el0; sat_t *sat,sat_working; - + pass_t *pass; + /*copy sat_in to a working structure*/ sat = memcpy(&sat_working,sat_in,sizeof(sat_t)); @@ -925,6 +927,10 @@ t = get_current_daynum (); predict_calc (sat, qth, t); + /*save initial conditions for later comparison*/ + t0 = t; + el0 = sat->el; + /* check whether satellite has aos */ if (!has_aos (sat, qth)) { @@ -933,10 +939,26 @@ } /* find a time before AOS */ - while (sat->el > -2.0) { + while (sat->el > 0.0) { predict_calc (sat, qth, t); t -= 0.007; // +10 min } - return get_pass_no_min_el (sat, qth, t, 0.0); + pass = get_pass_no_min_el (sat, qth, t, 0.0); + if (el0 > 0.0) { + /* this function is only specified if the elevation + is greater than zero at the time it is called*/ + if (pass){ + if (pass->aos > t0) + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Returning a pass for %s that starts after the seeded time."), + __FUNCTION__,sat->nickname); + + if (pass->los < t0) + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Returning a pass for %s that ends before the seeded time."), + __FUNCTION__,sat->nickname); + } + } + return pass; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-26 17:13:39
|
Revision: 794 http://gpredict.svn.sourceforge.net/gpredict/?rev=794&view=rev Author: aa1vs Date: 2011-03-26 17:13:33 +0000 (Sat, 26 Mar 2011) Log Message: ----------- Updated NEWS Modified Paths: -------------- trunk/NEWS Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2011-03-26 01:10:20 UTC (rev 793) +++ trunk/NEWS 2011-03-26 17:13:33 UTC (rev 794) @@ -1,6 +1,7 @@ Changes in version 1.4 (TBD) - Feature request 3141555: gpsd support. +- Applied and extended patch 3237220: natural sort for sat list in module config - Improve handling of decayed satellites. Changes in version 1.3 (1 Mar 2011) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-26 01:10:27
|
Revision: 793 http://gpredict.svn.sourceforge.net/gpredict/?rev=793&view=rev Author: aa1vs Date: 2011-03-26 01:10:20 +0000 (Sat, 26 Mar 2011) Log Message: ----------- Add natural comparison by Martin Pool Modified Paths: -------------- trunk/AUTHORS trunk/ChangeLog trunk/src/Makefile.am trunk/src/about.c trunk/src/gpredict-utils.c trunk/src/gpredict-utils.h trunk/src/gtk-rig-ctrl.c trunk/src/gtk-rot-ctrl.c trunk/src/gtk-sat-selector.c trunk/src/gtk-single-sat.c trunk/src/menubar.c trunk/src/mod-cfg.c Added Paths: ----------- trunk/src/strnatcmp.c trunk/src/strnatcmp.h Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/AUTHORS 2011-03-26 01:10:20 UTC (rev 793) @@ -13,6 +13,8 @@ - Maidenhead locator functions are based on work done by Stephane Fillod, Nate Bargmann, Dave Hines, Mirko Caserta, and S. R. Sampson. - Paul Schulz, various patches. +- Martin Pool, for his natural string compare routines + see http://sourcefrog.net/projects/natsort/ Imagery: Most of the maps originate from NASA Visible Earth, http://visibleearth.nasa.gov/ Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/ChangeLog 2011-03-26 01:10:20 UTC (rev 793) @@ -1,3 +1,20 @@ +2011-03-25 Charles Suprin <hamaa1vs at gmail.com> + + * AUTHORS + * src/about.c + * src/Makefile.am + * src/menubar.c + * src/mod-cfg.c + * src/gpredict-utils.c + * src/gpredict-utils.h + * src/gtk-rig-ctrl.c + * src/gtk-rot-ctrl.c + * src/gtk-sat-selector.c + * src/gtk-single-sat.c + * src/strnatcmp.c + * src/strnatcmp.h + Added "natural comparison" by Martin Pool from patch 3237220 by Patrick Strasser. + 2011-03-24 Charles Suprin <hamaa1vs at gmail.com> * src/predict-tools.c Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/Makefile.am 2011-03-26 01:10:20 UTC (rev 793) @@ -112,7 +112,8 @@ time-tools.c time-tools.h \ tle-tools.c tle-tools.h \ tle-update.c tle-update.h \ - sat-debugger.c sat-debugger.h + sat-debugger.c sat-debugger.h \ + strnatcmp.c strnatcmp.h Modified: trunk/src/about.c =================================================================== --- trunk/src/about.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/about.c 2011-03-26 01:10:20 UTC (rev 793) @@ -54,6 +54,7 @@ "Mirko Caserta (locator.c)", "S. R. Sampson (locator.c)", "Paul Schulz (various patches)", + "Martin Pool (natural sorting)", "", "Imagery:", "Most of the maps originate from NASA Visible Earth", Modified: trunk/src/gpredict-utils.c =================================================================== --- trunk/src/gpredict-utils.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/gpredict-utils.c 2011-03-26 01:10:20 UTC (rev 793) @@ -28,6 +28,9 @@ /** \brief Various utility functions. * */ + +#define _GNU_SOURCE +#include <ctype.h> #include <gtk/gtk.h> #include <glib/gi18n.h> #include <glib/gstdio.h> @@ -37,9 +40,11 @@ #include "compat.h" #include "sat-log.h" #include "gpredict-utils.h" +#include "strnatcmp.h" + static void set_combo_tooltip (GtkWidget *combo, gpointer text); @@ -477,3 +482,19 @@ return col; } +int gpredict_strcmp (const char *s1, const char *s2) { +#if 0 + + gchar *a,*b; + int retval; + a=g_ascii_strup(s1,-1); + b=g_ascii_strup(s2,-1); + + retval=strverscmp(a,b); + g_free(a); + g_free(b); + return retval; +#else + return strnatcasecmp(s1,s2); +#endif +} Modified: trunk/src/gpredict-utils.h =================================================================== --- trunk/src/gpredict-utils.h 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/gpredict-utils.h 2011-03-26 01:10:20 UTC (rev 793) @@ -62,5 +62,5 @@ void gdk2rgb (const GdkColor *color, guint *rgb); void gdk2rgba (const GdkColor *color, guint16 alpha, guint *rgba); gchar *rgba2html (guint rgba); - +int gpredict_strcmp (const char *s1, const char *s2); #endif Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/gtk-rig-ctrl.c 2011-03-26 01:10:20 UTC (rev 793) @@ -2755,11 +2755,11 @@ /*simple function to sort the list of satellites in the combo box.*/ static gint sat_name_compare (sat_t* a,sat_t*b){ - return (g_ascii_strcasecmp(a->nickname,b->nickname)); + return (gpredict_strcmp(a->nickname,b->nickname)); } static gint rig_name_compare (const gchar* a,const gchar *b){ - return (g_ascii_strcasecmp(a,b)); + return (gpredict_strcmp(a,b)); } static inline gboolean check_set_response (gchar *buffback,gboolean retcode,const gchar *function){ Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/gtk-rot-ctrl.c 2011-03-26 01:10:20 UTC (rev 793) @@ -42,6 +42,7 @@ #include "compat.h" #include "sat-log.h" #include "predict-tools.h" +#include "gpredict-utils.h" #include "gtk-polar-plot.h" #include "gtk-rot-knob.h" #include "gtk-rot-ctrl.h" @@ -1444,14 +1445,14 @@ *simple function to sort the list of satellites in the combo box. */ static gint sat_name_compare (sat_t* a,sat_t*b){ - return (g_ascii_strcasecmp(a->nickname,b->nickname)); + return (gpredict_strcmp(a->nickname,b->nickname)); } /** \brief Compare Rotator Names. */ static gint rot_name_compare (const gchar* a,const gchar *b){ - return (g_ascii_strcasecmp(a,b)); + return (gpredict_strcmp(a,b)); } Modified: trunk/src/gtk-sat-selector.c =================================================================== --- trunk/src/gtk-sat-selector.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/gtk-sat-selector.c 2011-03-26 01:10:20 UTC (rev 793) @@ -32,6 +32,7 @@ /*needed _gnu_source to have strcasestr defined*/ #define _GNU_SOURCE + #include <string.h> #include <gtk/gtk.h> #include <glib/gi18n.h> @@ -44,9 +45,9 @@ #include "compat.h" #include "sat-cfg.h" #include "gtk-sat-selector.h" +#include "gpredict-utils.h" - static void gtk_sat_selector_class_init (GtkSatSelectorClass *class); static void gtk_sat_selector_init (GtkSatSelector *selector); static void gtk_sat_selector_destroy (GtkObject *object); @@ -614,7 +615,7 @@ gtk_tree_model_get(model, a, GTK_SAT_SELECTOR_COL_NAME, &sat1, -1); gtk_tree_model_get(model, b, GTK_SAT_SELECTOR_COL_NAME, &sat2, -1); - ret = g_ascii_strcasecmp (sat1, sat2); + ret = strverscmp (sat1, sat2); g_free (sat1); g_free (sat2); @@ -900,7 +901,7 @@ cat_a = load_cat_file_cat (a); cat_b = load_cat_file_cat (b); - temp = g_ascii_strcasecmp (cat_a,cat_b); + temp = gpredict_strcmp (cat_a,cat_b); g_free (cat_a); g_free (cat_b); return (temp); Modified: trunk/src/gtk-single-sat.c =================================================================== --- trunk/src/gtk-single-sat.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/gtk-single-sat.c 2011-03-26 01:10:20 UTC (rev 793) @@ -51,7 +51,6 @@ #include "sat-pass-dialogs.h" - /** \brief Column titles indexed with column symb. refs. */ const gchar *SINGLE_SAT_FIELD_TITLE[SINGLE_SAT_FIELD_NUMBER] = { N_("Azimuth"), @@ -1146,5 +1145,5 @@ } static gint sat_name_compare (sat_t *a,sat_t *b) { - return g_ascii_strcasecmp(a->nickname,b->nickname); + return gpredict_strcmp(a->nickname,b->nickname); } Modified: trunk/src/menubar.c =================================================================== --- trunk/src/menubar.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/menubar.c 2011-03-26 01:10:20 UTC (rev 793) @@ -48,6 +48,7 @@ #include "gtk-sat-module.h" #include "gtk-sat-module-popup.h" #include "gpredict-help.h" +#include "gpredict-utils.h" #include "tle-update.h" #include "compat.h" #include "menubar.h" @@ -1083,7 +1084,7 @@ gtk_tree_model_get(model, a, 0, &sat1, -1); gtk_tree_model_get(model, b, 0, &sat2, -1); - ret = g_ascii_strcasecmp (sat1, sat2); + ret = gpredict_strcmp (sat1, sat2); g_free (sat1); g_free (sat2); Modified: trunk/src/mod-cfg.c =================================================================== --- trunk/src/mod-cfg.c 2011-03-26 00:55:01 UTC (rev 792) +++ trunk/src/mod-cfg.c 2011-03-26 01:10:20 UTC (rev 793) @@ -39,7 +39,6 @@ #include "sat-pref-modules.h" #include "qth-editor.h" #include "mod-cfg.h" - #include "gtk-sat-selector.h" @@ -1164,7 +1163,7 @@ gtk_tree_model_get(model, a, GTK_SAT_SELECTOR_COL_NAME, &sat1, -1); gtk_tree_model_get(model, b, GTK_SAT_SELECTOR_COL_NAME, &sat2, -1); - ret = g_ascii_strcasecmp (sat1, sat2); + ret = gpredict_strcmp (sat1, sat2); g_free (sat1); g_free (sat2); @@ -1259,5 +1258,5 @@ static gint qth_name_compare (const gchar* a,const gchar *b){ - return (g_ascii_strcasecmp(a,b)); + return (gpredict_strcmp(a,b)); } Added: trunk/src/strnatcmp.c =================================================================== --- trunk/src/strnatcmp.c (rev 0) +++ trunk/src/strnatcmp.c 2011-03-26 01:10:20 UTC (rev 793) @@ -0,0 +1,178 @@ +/* -*- mode: c; c-file-style: "k&r" -*- + + strnatcmp.c -- Perform 'natural order' comparisons of strings in C. + Copyright (C) 2000, 2004 by Martin Pool <mbp sourcefrog net> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + + +/* partial change history: + * + * 2004-10-10 mbp: Lift out character type dependencies into macros. + * + * Eric Sosman pointed out that ctype functions take a parameter whose + * value must be that of an unsigned int, even on platforms that have + * negative chars in their default char type. + */ + +#include <ctype.h> +#include <string.h> +#include <assert.h> +#include <stdio.h> + +#include "strnatcmp.h" + + +/* These are defined as macros to make it easier to adapt this code to + * different characters types or comparison functions. */ +static inline int +nat_isdigit(nat_char a) +{ + return isdigit((unsigned char) a); +} + + +static inline int +nat_isspace(nat_char a) +{ + return isspace((unsigned char) a); +} + + +static inline nat_char +nat_toupper(nat_char a) +{ + return toupper((unsigned char) a); +} + + + +static int +compare_right(nat_char const *a, nat_char const *b) +{ + int bias = 0; + + /* The longest run of digits wins. That aside, the greatest + value wins, but we can't know that it will until we've scanned + both numbers to know that they have the same magnitude, so we + remember it in BIAS. */ + for (;; a++, b++) { + if (!nat_isdigit(*a) && !nat_isdigit(*b)) + return bias; + else if (!nat_isdigit(*a)) + return -1; + else if (!nat_isdigit(*b)) + return +1; + else if (*a < *b) { + if (!bias) + bias = -1; + } else if (*a > *b) { + if (!bias) + bias = +1; + } else if (!*a && !*b) + return bias; + } + + return 0; +} + + +static int +compare_left(nat_char const *a, nat_char const *b) +{ + /* Compare two left-aligned numbers: the first to have a + different value wins. */ + for (;; a++, b++) { + if (!nat_isdigit(*a) && !nat_isdigit(*b)) + return 0; + else if (!nat_isdigit(*a)) + return -1; + else if (!nat_isdigit(*b)) + return +1; + else if (*a < *b) + return -1; + else if (*a > *b) + return +1; + } + + return 0; +} + + +static int strnatcmp0(nat_char const *a, nat_char const *b, int fold_case) +{ + int ai, bi; + nat_char ca, cb; + int fractional, result; + + assert(a && b); + ai = bi = 0; + while (1) { + ca = a[ai]; cb = b[bi]; + + /* skip over leading spaces or zeros */ + while (nat_isspace(ca)) + ca = a[++ai]; + + while (nat_isspace(cb)) + cb = b[++bi]; + + /* process run of digits */ + if (nat_isdigit(ca) && nat_isdigit(cb)) { + fractional = (ca == '0' || cb == '0'); + + if (fractional) { + if ((result = compare_left(a+ai, b+bi)) != 0) + return result; + } else { + if ((result = compare_right(a+ai, b+bi)) != 0) + return result; + } + } + + if (!ca && !cb) { + /* The strings compare the same. Perhaps the caller + will want to call strcmp to break the tie. */ + return 0; + } + + if (fold_case) { + ca = nat_toupper(ca); + cb = nat_toupper(cb); + } + + if (ca < cb) + return -1; + else if (ca > cb) + return +1; + + ++ai; ++bi; + } +} + + + +int strnatcmp(nat_char const *a, nat_char const *b) { + return strnatcmp0(a, b, 0); +} + + +/* Compare, recognizing numeric string and ignoring case. */ +int strnatcasecmp(nat_char const *a, nat_char const *b) { + return strnatcmp0(a, b, 1); +} Added: trunk/src/strnatcmp.h =================================================================== --- trunk/src/strnatcmp.h (rev 0) +++ trunk/src/strnatcmp.h 2011-03-26 01:10:20 UTC (rev 793) @@ -0,0 +1,31 @@ +/* -*- mode: c; c-file-style: "k&r" -*- + + strnatcmp.c -- Perform 'natural order' comparisons of strings in C. + Copyright (C) 2000, 2004 by Martin Pool <mbp sourcefrog net> + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + + +/* CUSTOMIZATION SECTION + * + * You can change this typedef, but must then also change the inline + * functions in strnatcmp.c */ +typedef char nat_char; + +int strnatcmp(nat_char const *a, nat_char const *b); +int strnatcasecmp(nat_char const *a, nat_char const *b); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aa...@us...> - 2011-03-26 00:55:07
|
Revision: 792 http://gpredict.svn.sourceforge.net/gpredict/?rev=792&view=rev Author: aa1vs Date: 2011-03-26 00:55:01 +0000 (Sat, 26 Mar 2011) Log Message: ----------- Unify get_pass and get_pass_no_min_el with same code. Modified Paths: -------------- trunk/ChangeLog trunk/NEWS trunk/src/predict-tools.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-03-24 23:38:54 UTC (rev 791) +++ trunk/ChangeLog 2011-03-26 00:55:01 UTC (rev 792) @@ -1,3 +1,29 @@ +2011-03-24 Charles Suprin <hamaa1vs at gmail.com> + + * src/predict-tools.c + Unify get_pass and get_pass_no_min_el to use common pass generator. + + +2011-03-22 Charles Suprin <hamaa1vs at gmail.com> + + * src/gtk-sat-map.c + Remove decayed satellites from map view. + +2011-03-21 Charles Suprin <hamaa1vs at gmail.com> + + * src/gtk-event-list-popup.c + * src/gtk-polar-view-popup.c + * src/gtk-sat-list-popup.c + * src/gtk-sat-list.c + * src/gtk-sat-map-ground-track.c + * src/gtk-sat-map-popup.c + * src/gtk-sat-module.c + * src/gtk-single-sat.c + * src/orbit-tools.c + * src/predict-tools.c + Include geo and decayed orbits in has_aos and make dynamic calls to + decayed instead of static orbit type check. + 2011-03-20 Charles Suprin <hamaa1vs at gmail.com> Merged gpsd_testing branch into trunk. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2011-03-24 23:38:54 UTC (rev 791) +++ trunk/NEWS 2011-03-26 00:55:01 UTC (rev 792) @@ -1,6 +1,7 @@ Changes in version 1.4 (TBD) - Feature request 3141555: gpsd support. +- Improve handling of decayed satellites. Changes in version 1.3 (1 Mar 2011) Modified: trunk/src/predict-tools.c =================================================================== --- trunk/src/predict-tools.c 2011-03-24 23:38:54 UTC (rev 791) +++ trunk/src/predict-tools.c 2011-03-26 00:55:01 UTC (rev 792) @@ -43,6 +43,8 @@ #include "sat-log.h" +static pass_t * get_pass_engine (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt, gdouble min_el); + /** \brief SGP4SDP4 driver for doing AOS/LOS calculations. * \param sat Pointer to the satellite data. * \param qth Pointer to the QTH data. @@ -420,6 +422,38 @@ * \param maxdt The maximum number of days to look ahead (0 for no limit). * \return Pointer to a newly allocated pass_t structure or NULL if * there was an error. + * This function assumes that you want a pass that achieves the + * minimum elevation of is configured for. + */ + +pass_t * +get_pass (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) { + return get_pass_engine (sat_in, qth, start, maxdt, 1.0*sat_cfg_get_int (SAT_CFG_INT_PRED_MIN_EL)); +} + +/** \brief Predict first pass after a certain time ignoring the min elevation. + * \param sat Pointer to the satellite data. + * \param qth Pointer to the location data. + * \param start Starting time. + * \param maxdt The maximum number of days to look ahead (0 for no limit). + * \return Pointer to a newly allocated pass_t structure or NULL if + * there was an error. + * This function assumes that you want a pass that achieves the + * minimum elevation of is configured for. + */ +pass_t * +get_pass_no_min_el (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) { + return get_pass_engine (sat_in, qth, start, maxdt, 0.0); +} + + +/** \brief Predict first pass after a certain time. + * \param sat Pointer to the satellite data. + * \param qth Pointer to the location data. + * \param start Starting time. + * \param maxdt The maximum number of days to look ahead (0 for no limit). + * \return Pointer to a newly allocated pass_t structure or NULL if + * there was an error. * * This function will find the first upcoming pass with AOS no earlier than * t = start and no later than t = (start+maxdt). @@ -434,8 +468,9 @@ * Therefore, the elements are prepended whereafter the GSList is * reversed */ -pass_t * -get_pass (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) + +static pass_t * +get_pass_engine (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt, gdouble min_el) { gdouble aos = 0.0; /* time of AOS */ gdouble tca = 0.0; /* time of TCA */ @@ -601,7 +636,7 @@ pass->tca = tca; /* check whether this pass is good */ - if (max_el >= sat_cfg_get_int (SAT_CFG_INT_PRED_MIN_EL)) { + if (max_el >= min_el) { done = TRUE; } else { @@ -858,187 +893,6 @@ details = NULL; } - - -/** \brief Predict first pass after a certain time disergarding any minimum El setting. - * \param sat Pointer to the satellite data. - * \param qth Pointer to the location data. - * \param start Starting time. - * \param maxdt The maximum number of days to look ahead (0 for no limit). - * \return Pointer to a newly allocated pass_t structure or NULL if - * there was an error. - * - * This function will find the first upcoming pass with AOS no earlier than - * t = start and no later than t = (start+maxdt). Since the intented use of this - * function is to get the details of the current pass of a satellite, this function - * does not care of the minimum elevation setting in sat-cfg. - * - * \note For no time limit use maxdt = 0.0 - * - * \note the data in sat will be corrupt (future) and must be refreshed - * by the caller, if the caller will need it later on (eg. if the caller - * is GtkSatList). - * - * \note Prepending to a singly linked list is much faster than appending. - * Therefore, the elements are prepended whereafter the GSList is - * reversed - */ -pass_t * -get_pass_no_min_el (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) -{ - gdouble aos = 0.0; /* time of AOS */ - gdouble tca = 0.0; /* time of TCA */ - gdouble los = 0.0; /* time of LOS */ - gdouble dt = 0.0; /* time diff */ - gdouble step = 0.0; /* time step */ - gdouble t0 = start; - gdouble t; /* current time counter */ - gdouble tres = 0.0; /* required time resolution */ - gdouble max_el = 0.0; /* maximum elevation */ - pass_t *pass = NULL; - pass_detail_t *detail = NULL; - gboolean done = FALSE; - sat_t *sat,sat_working; - - /* FIXME: watchdog */ - - /*copy sat_in to a working structure*/ - sat = memcpy(&sat_working,sat_in,sizeof(sat_t)); - - /* get time resolution; sat-cfg stores it in seconds */ - tres = sat_cfg_get_int (SAT_CFG_INT_PRED_RESOLUTION) / 86400.0; - - - aos = find_aos (sat, qth, t0, maxdt); - - - /* aos = 0.0 means no aos */ - if (aos == 0.0) { - done = TRUE; - } - - /* check whether we are within time limits; - maxdt = 0 mean no time limit. - */ - else if ((maxdt > 0.0) && (aos > (start + maxdt))) { - done = TRUE; - } - else { - los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later - dt = los - aos; - - /* get time step, which will give us the max number of entries */ - step = dt / sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_ENTRIES); - - /* but if this is smaller than the required resolution - we go with the resolution - */ - if (step < tres) - step = tres; - - /* create a pass_t entry; FIXME: g_try_new in 2.8 */ - pass = g_new (pass_t, 1); - - pass->aos = aos; - pass->los = los; - pass->max_el = 0.0; - pass->aos_az = 0.0; - pass->los_az = 0.0; - pass->maxel_az = 0.0; - pass->vis[0] = '-'; - pass->vis[1] = '-'; - pass->vis[2] = '-'; - pass->vis[3] = 0; - pass->satname = g_strdup (sat->nickname); - pass->details = NULL; - /*copy qth data into the pass for later comparisons*/ - qth_small_save(qth,&(pass->qth_comp)); - - /* iterate over each time step */ - for (t = pass->aos; t <= pass->los; t += step) { - - /* calculate satellite data */ - predict_calc (sat, qth, t); - - /* in the first iter we want to store - pass->aos_az - */ - if (t == pass->aos) { - pass->aos_az = sat->az; - pass->orbit = sat->orbit; - } - - /* append details to sat->details */ - detail = g_new (pass_detail_t, 1); - detail->time = t; - detail->pos.x = sat->pos.x; - detail->pos.y = sat->pos.y; - detail->pos.z = sat->pos.z; - detail->pos.w = sat->pos.w; - detail->vel.x = sat->vel.x; - detail->vel.y = sat->vel.y; - detail->vel.z = sat->vel.z; - detail->vel.w = sat->vel.w; - detail->velo = sat->velo; - detail->az = sat->az; - detail->el = sat->el; - detail->range = sat->range; - detail->range_rate = sat->range_rate; - detail->lat = sat->ssplat; - detail->lon = sat->ssplon; - detail->alt = sat->alt; - detail->ma = sat->ma; - detail->phase = sat->phase; - detail->footprint = sat->footprint; - detail->orbit = sat->orbit; - detail->vis = get_sat_vis (sat, qth, t); - - /* also store visibility "bit" */ - switch (detail->vis) { - case SAT_VIS_VISIBLE: - pass->vis[0] = 'V'; - break; - case SAT_VIS_DAYLIGHT: - pass->vis[1] = 'D'; - break; - case SAT_VIS_ECLIPSED: - pass->vis[2] = 'E'; - break; - default: - break; - } - - pass->details = g_slist_prepend (pass->details, detail); - - /* store elevation if greater than the - previously stored one - */ - if (sat->el > max_el) { - max_el = sat->el; - tca = t; - pass->maxel_az = sat->az; - } - - /* g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */ - /* t, sat->az, sat->el, max_el); */ - } - - pass->details = g_slist_reverse (pass->details); - - /* calculate satellite data */ - predict_calc (sat, qth, pass->los); - /* store los_az, max_el and tca */ - pass->los_az = sat->az; - pass->max_el = max_el; - pass->tca = tca; - - } - - return pass; -} - - - /** \brief Get current pass. * \param sat Pointer to the satellite data. * \param qth Pointer to the QTH data. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |