Diff of /trunk/src/map-tool.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 149 by harbaum, Thu Oct 29 13:59:16 2009 UTC revision 151 by harbaum, Fri Oct 30 20:09:13 2009 UTC
# Line 22  Line 22 
22   * http://topo.geofabrik.de/trail/${z}/${x}/${y}.png   8-15   * http://topo.geofabrik.de/trail/${z}/${x}/${y}.png   8-15
23   */   */
24    
25    /*
26     * TODO:
27     * - draw caches only once
28     * - prefer duplicates from selected files
29     * - make semi-transparent caches selectable
30     */
31    
32  #include "gpxview.h"  #include "gpxview.h"
33  #include "converter.h"  #include "converter.h"
34  #include <math.h>    // for isnan  #include <math.h>    // for isnan
# Line 146  static gboolean map_gps_update(gpointer Line 153  static gboolean map_gps_update(gpointer
153    return TRUE;    return TRUE;
154  }  }
155    
156  static void map_draw_cache(GtkWidget *map, cache_t *cache) {  static void map_draw_cache(GtkWidget *map, cache_t *cache, gboolean semi) {
157    GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type);    GdkPixbuf *icon = icon_get(semi?ICON_CACHE_TYPE_SEMI:ICON_CACHE_TYPE,
158                                 cache->type);
159    
160    /* check if there's also an overwritten coordinate */    /* check if there's also an overwritten coordinate */
161    if(cache->notes && cache->notes->override) {    if(cache->notes && cache->notes->override) {
# Line 165  static void map_draw_cache(GtkWidget *ma Line 173  static void map_draw_cache(GtkWidget *ma
173    }    }
174  }  }
175    
176  static void map_draw_gpx(appdata_t *appdata, GtkWidget *map, gpx_t *gpx) {  static void map_draw_gpx(appdata_t *appdata,
177                             GtkWidget *map, gpx_t *gpx,
178                             cache_t *nav, gboolean semi) {
179    if(!gpx->notes_loaded) {    if(!gpx->notes_loaded) {
180      notes_load_all(appdata, gpx);      notes_load_all(appdata, gpx);
181      gpx->notes_loaded = TRUE;      gpx->notes_loaded = TRUE;
# Line 173  static void map_draw_gpx(appdata_t *appd Line 183  static void map_draw_gpx(appdata_t *appd
183    
184    cache_t *cache = gpx->cache;    cache_t *cache = gpx->cache;
185    while(cache) {    while(cache) {
186      map_draw_cache(map, cache);      /* if nav is given draw all other caches semitransparent. */
187        /* if nav is not given do what semi sais */
188        map_draw_cache(map, cache, nav?(cache != nav):semi);
189      cache = cache->next;      cache = cache->next;
190    }    }
191  }  }
# Line 191  static void map_setup(map_context_t *con Line 203  static void map_setup(map_context_t *con
203        osm_gps_map_osd_clear_nav (OSM_GPS_MAP(context->widget));        osm_gps_map_osd_clear_nav (OSM_GPS_MAP(context->widget));
204  #endif  #endif
205    
206        /* clear all existing ccahe images */        /* clear all existing cache images */
207        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
208    
209        /* draw all geocaches */        /* draw all geocaches and none is semi-transparent */
210        gpx_t *gpx = context->appdata->gpx;        gpx_t *gpx = context->appdata->gpx;
211        while(gpx) {        while(gpx) {
212          map_draw_gpx(context->appdata, context->widget, gpx);          map_draw_gpx(context->appdata, context->widget, gpx, NULL, FALSE);
213          gpx = gpx->next;          gpx = gpx->next;
214        }        }
215        name = g_strdup(_("all"));        name = g_strdup(_("all"));
# Line 215  static void map_setup(map_context_t *con Line 227  static void map_setup(map_context_t *con
227        /* clear all existing ccahe images */        /* clear all existing ccahe images */
228        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
229    
230        map_draw_gpx(context->appdata, context->widget,        /* draw all geocaches and all other gpx files are semi-transparent */
231                     context->appdata->cur_gpx);        gpx_t *gpx = context->appdata->gpx;
232          while(gpx) {
233            map_draw_gpx(context->appdata, context->widget, gpx, NULL,
234                         gpx != context->appdata->cur_gpx);
235            gpx = gpx->next;
236          }
237    
238        name = g_strdup(context->appdata->cur_gpx->name);        name = g_strdup(context->appdata->cur_gpx->name);
239        context->state = MAP_GPX;        context->state = MAP_GPX;
240      }      }
# Line 232  static void map_setup(map_context_t *con Line 250  static void map_setup(map_context_t *con
250      /* clear all existing ccahe images */      /* clear all existing ccahe images */
251      osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));      osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
252    
253      map_draw_cache(context->widget, cache);      /* draw all geocaches and all but selected one are semi-transparent */
254        gpx_t *gpx = context->appdata->gpx;
255        while(gpx) {
256          map_draw_gpx(context->appdata, context->widget, gpx, cache, FALSE);
257          gpx = gpx->next;
258        }
259    
260      name = g_strdup(cache->name);      name = g_strdup(cache->name);
261      context->state = MAP_CACHE;      context->state = MAP_CACHE;
262    

Legend:
Removed from v.149  
changed lines
  Added in v.151