static void popup_traffic_distortion(struct item *item, char *attr) { /* add the configuration directory to the name of the file to use */ char *dist_filename = g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/distortion.txt", NULL); if (dist_filename) /* if we built the filename */ { FILE *map=fopen(dist_filename,"a"); if (map) /* if the file was opened */ { struct coord c; struct map_rect *mr; fprintf(map,"type=traffic_distortion %s\n",attr); mr=map_rect_new(item->map,NULL); item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); while (item_coord_get(item, &c, 1)) { fprintf(map,"0x%x 0x%x\n",c.x,c.y); } fclose(map); } else { dbg(0,"could not open file for distortions !!", item); } /* else - if (map) */ g_free(dist_filename); /* free the file name */ } /* if (dist_filename) */ } /* end: popup_traffic_distortion(..) */
static void popup_show_item(void *popup, struct displayitem *di) { struct map_rect *mr; void *menu, *menu_map, *menu_item; char *label; struct item *item; label=graphics_displayitem_get_label(di); item=graphics_displayitem_get_item(di); if (label) menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(item->type), label); else menu=popup_printf(popup, menu_type_submenu, "%s", item_to_name(item->type)); menu_item=popup_printf(menu, menu_type_submenu, "Item"); popup_printf(menu_item, menu_type_menu, "type: 0x%x", item->type); popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", item->id_hi, item->id_lo); if (item->map) { mr=map_rect_new(item->map,NULL); item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); dbg(1,"item=%p\n", item); if (item) { popup_show_attrs(item->map, menu_item, item); } map_rect_destroy(mr); menu_map=popup_printf(menu, menu_type_submenu, "Map"); } else { popup_printf(menu, menu_type_menu, "(No map)"); } }
static void popup_item_dump(struct item *item) { struct map_rect *mr; mr=map_rect_new(item->map,NULL); item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); dbg(0,"item=%p\n",item); item_dump_filedesc(item,item->map,stdout); map_rect_destroy(mr); }
struct item* bookmarks_get_item(struct bookmarks* this_) { struct item item,*ret; if (this_->current->iter==NULL) { return NULL; } item=((struct bookmark_item_priv*)this_->current->iter->data)->item; this_->current->iter=g_list_next(this_->current->iter); ret = map_rect_get_item_byid(this_->mr, item.id_hi, item.id_lo); return ret; }
static void popup_show_item(struct navit *nav, void *popup, struct displayitem *di) { struct map_rect *mr; void *menu, *menu_map, *menu_item, *menu_dist; char *label; struct item *item,*diitem; int count; label=graphics_displayitem_get_label(di); diitem=graphics_displayitem_get_item(di); count=graphics_displayitem_get_coord_count(di); dbg_assert(diitem); if (label) menu=popup_printf(popup, menu_type_submenu, "%s '%s' (%d coords)", item_to_name(diitem->type), label, count); else menu=popup_printf(popup, menu_type_submenu, "%s (%d coords)", item_to_name(diitem->type), count); menu_item=popup_printf(menu, menu_type_submenu, "Item"); popup_printf(menu_item, menu_type_menu, "type: 0x%x", diitem->type); popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", diitem->id_hi, diitem->id_lo); if (diitem->map) { struct attr type,data; if (!map_get_attr(diitem->map, attr_type, &type, NULL)) type.u.str=""; if (!map_get_attr(diitem->map, attr_data, &data, NULL)) data.u.str=""; popup_printf(menu_item, menu_type_menu, "map: %s:%s", type.u.str, data.u.str); } if (diitem->map) { mr=map_rect_new(diitem->map,NULL); item=map_rect_get_item_byid(mr, diitem->id_hi, diitem->id_lo); dbg(1,"item=%p\n", item); if (item) { popup_show_attrs(item->map, menu_item, item); popup_printf_cb(menu_item, menu_type_menu, callback_new_1(callback_cast(popup_item_dump), diitem), "Dump"); if (item->type < type_line) { struct coord co; struct pcoord *c; if (item_coord_get(item, &co, 1)) { c=g_new(struct pcoord, 1); c->pro = transform_get_projection(navit_get_trans(nav)); c->x = co.x; c->y = co.y; popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c), _("Set as position")); popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c), _("Set as destination")); popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c), _("Add as bookmark")); } } }
static void popup_traffic_distortion(struct item *item, char *attr) { FILE *map=fopen("distortion.txt","a"); struct coord c; struct map_rect *mr; fprintf(map,"type=traffic_distortion %s\n",attr); mr=map_rect_new(item->map,NULL); item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); while (item_coord_get(item, &c, 1)) { fprintf(map,"0x%x 0x%x\n",c.x,c.y); } fclose(map); }
int tracking_get_current_attr(struct tracking *_this, enum attr_type type, struct attr *attr) { struct item *item; struct map_rect *mr; int result=0; if (! _this->curr_line || ! _this->curr_line->street) return 0; item=&_this->curr_line->street->item; mr=map_rect_new(item->map,NULL); item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); if (item_attr_get(item, type, attr)) result=1; map_rect_destroy(mr); return result; }
static void popup_show_item(struct navit *nav, void *popup, struct displayitem *di) { struct map_rect *mr; void *menu, *menu_map, *menu_item; char *label; struct item *item; label=graphics_displayitem_get_label(di); item=graphics_displayitem_get_item(di); if (label) menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(item->type), label); else menu=popup_printf(popup, menu_type_submenu, "%s", item_to_name(item->type)); menu_item=popup_printf(menu, menu_type_submenu, "Item"); popup_printf(menu_item, menu_type_menu, "type: 0x%x", item->type); popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", item->id_hi, item->id_lo); if (item->map) { mr=map_rect_new(item->map,NULL); item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo); dbg(1,"item=%p\n", item); if (item) { popup_show_attrs(item->map, menu_item, item); if (item->type < type_line) { struct coord co; struct pcoord *c; if (item_coord_get(item, &co, 1)) { c=g_new(struct pcoord, 1); c->pro = transform_get_projection(navit_get_trans(nav)); c->x = co.x; c->y = co.y; popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c), _("Set as position")); popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c), _("Set as destination")); popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c), _("Add as bookmark")); } } }