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

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

revision 152 by harbaum, Mon Nov 2 10:53:01 2009 UTC revision 155 by harbaum, Tue Nov 3 08:38:23 2009 UTC
# Line 173  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,  static void map_draw_gpx(appdata_t *appdata, cache_display_t *caches,
177                           GtkWidget *map, gpx_t *gpx,                           GtkWidget *map, gpx_t *gpx,
178                           cache_t *nav, gboolean semi) {                           cache_t *nav, gboolean semi) {
179    if(!gpx->notes_loaded) {    if(!gpx->notes_loaded) {
# Line 183  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      /* if nav is given draw all other caches semitransparent. */      /* search if we have that cache already in our list/displayed */
187      /* if nav is not given do what semi sais */      int i=0;
188      map_draw_cache(map, cache, nav?(cache != nav):semi);      while(caches[i].id && (strcmp(caches[i].id, cache->id) != 0))
189          i++;
190    
191        if(!caches[i].id) {
192          /* if nav is given draw all other caches semitransparent. */
193          /* if nav is not given do what semi sais */
194          map_draw_cache(map, cache, nav?(cache != nav):semi);
195          caches[i].id = cache->id;
196        }
197    
198      cache = cache->next;      cache = cache->next;
199    }    }
200  }  }
# Line 197  static void map_setup(map_context_t *con Line 206  static void map_setup(map_context_t *con
206    int cache_num = gpx_total_caches_global(context->appdata->gpx);    int cache_num = gpx_total_caches_global(context->appdata->gpx);
207    
208    if(context->caches_displayed && (cache_num != context->cache_list_len)) {    if(context->caches_displayed && (cache_num != context->cache_list_len)) {
209        //    printf("re-alloc because %p %d/%d\n", context->caches_displayed,
210        //     cache_num, context->cache_list_len);
211      g_free(context->caches_displayed);      g_free(context->caches_displayed);
212      context->caches_displayed = NULL;      context->caches_displayed = NULL;
213      context->cache_list_len = 0;      context->cache_list_len = 0;
214    }    }
215    
216    /* allocate buffer */    /* allocate buffer */
217    if(cache_num) {    if(cache_num && !context->caches_displayed) {
218      context->cache_list_len = cache_num;      context->cache_list_len = cache_num;
219      context->caches_displayed = g_new0(cache_display_t, cache_num);      context->caches_displayed = g_new0(cache_display_t, cache_num+1);
220      printf("allocated space to handle %d map icons\n", cache_num);      printf("allocated space to handle %d map icons\n", cache_num);
221    }    }
222    
# Line 220  static void map_setup(map_context_t *con Line 231  static void map_setup(map_context_t *con
231    
232        /* clear all existing cache images */        /* clear all existing cache images */
233        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
234          memset(context->caches_displayed, 0,
235                 (cache_num+1) * sizeof(cache_display_t));
236    
237        /* draw all geocaches and none is semi-transparent */        /* draw all geocaches and none is semi-transparent */
238        gpx_t *gpx = context->appdata->gpx;        gpx_t *gpx = context->appdata->gpx;
239        while(gpx) {        while(gpx) {
240          map_draw_gpx(context->appdata, context->widget, gpx, NULL, FALSE);          map_draw_gpx(context->appdata, context->caches_displayed,
241                         context->widget, gpx, NULL, FALSE);
242          gpx = gpx->next;          gpx = gpx->next;
243        }        }
244    
245          {
246            int i=0;
247            while(context->caches_displayed[i].id) i++;
248            printf("number of caches actually displayed: %d\n", i);
249          }
250    
251        name = g_strdup(_("all"));        name = g_strdup(_("all"));
252        context->state = MAP_ALL;        context->state = MAP_ALL;
253      }      }
# Line 241  static void map_setup(map_context_t *con Line 262  static void map_setup(map_context_t *con
262    
263        /* clear all existing ccahe images */        /* clear all existing ccahe images */
264        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));        osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
265          memset(context->caches_displayed, 0,
266                 (cache_num+1) * sizeof(cache_display_t));
267    
268        /* draw all geocaches and all other gpx files are semi-transparent */        /* draw all geocaches and all other gpx files are semi-transparent */
269          map_draw_gpx(context->appdata, context->caches_displayed,
270                       context->widget, context->appdata->cur_gpx, NULL, FALSE);
271    
272        gpx_t *gpx = context->appdata->gpx;        gpx_t *gpx = context->appdata->gpx;
273        while(gpx) {        while(gpx) {
274          map_draw_gpx(context->appdata, context->widget, gpx, NULL,          if(gpx != context->appdata->cur_gpx)
275                       gpx != context->appdata->cur_gpx);            map_draw_gpx(context->appdata, context->caches_displayed,
276                           context->widget, gpx, NULL, TRUE);
277    
278          gpx = gpx->next;          gpx = gpx->next;
279        }        }
280    
# Line 256  static void map_setup(map_context_t *con Line 284  static void map_setup(map_context_t *con
284    } else {    } else {
285      cache_t *cache = context->appdata->cur_cache;      cache_t *cache = context->appdata->cur_cache;
286    
287      printf("map_setp(CACHE)\n");      printf("map_setup(CACHE)\n");
288    
289      /* no balloons in this mode */      /* no balloons in this mode */
290      context->balloon = NULL;      context->balloon = NULL;
# Line 264  static void map_setup(map_context_t *con Line 292  static void map_setup(map_context_t *con
292    
293      /* clear all existing ccahe images */      /* clear all existing ccahe images */
294      osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));      osm_gps_map_clear_images (OSM_GPS_MAP(context->widget));
295        memset(context->caches_displayed, 0,
296               (cache_num+1) * sizeof(cache_display_t));
297    
298      /* draw all geocaches and all but selected one are semi-transparent */      /* draw all geocaches and all but selected one are semi-transparent */
299      gpx_t *gpx = context->appdata->gpx;      gpx_t *gpx = context->appdata->gpx;
300      while(gpx) {      while(gpx) {
301        map_draw_gpx(context->appdata, context->widget, gpx, cache, FALSE);        map_draw_gpx(context->appdata, context->caches_displayed,
302                       context->widget, gpx, cache, FALSE);
303        gpx = gpx->next;        gpx = gpx->next;
304      }      }
305    

Legend:
Removed from v.152  
changed lines
  Added in v.155