56 |
str = g_strdup_printf("%s #%ld", item_str, id); |
str = g_strdup_printf("%s #%ld", item_str, id); |
57 |
|
|
58 |
/* add some tags ... */ |
/* add some tags ... */ |
59 |
|
/* |
60 |
|
* XXX Should we just try to present only the name or the ref (or the |
61 |
|
* alt_name, old_name, whatever) here? Hurling a load of tags in the |
62 |
|
* user's face in some unpredictable, uninformative order isn't very |
63 |
|
* friendly. |
64 |
|
* |
65 |
|
* Actually, a tag_short_desc() function would be useful in dialogs |
66 |
|
* nd user messages too. |
67 |
|
*/ |
68 |
while(tag) { |
while(tag) { |
69 |
if(!collision && info_tag_key_collision(tags, tag)) |
if(!collision && info_tag_key_collision(tags, tag)) |
70 |
collision = TRUE; |
collision = TRUE; |
155 |
|
|
156 |
float radius = map->style->highlight.width + map->style->node.radius; |
float radius = map->style->highlight.width + map->style->node.radius; |
157 |
if(!node->ways) radius += map->style->node.border_radius; |
if(!node->ways) radius += map->style->node.border_radius; |
158 |
if(node->icon_buf && map->style->icon.enable) { |
if(node->icon_buf && map->style->icon.enable && |
159 |
|
!appdata->settings->no_icons) { |
160 |
gint w = gdk_pixbuf_get_width(map_item->node->icon_buf); |
gint w = gdk_pixbuf_get_width(map_item->node->icon_buf); |
161 |
gint h = gdk_pixbuf_get_height(map_item->node->icon_buf); |
gint h = gdk_pixbuf_get_height(map_item->node->icon_buf); |
162 |
/* icons are technically square, so a radius slightly bigger */ |
/* icons are technically square, so a radius slightly bigger */ |
218 |
diff.x = node_chain->node->lpos.x - last->lpos.x; |
diff.x = node_chain->node->lpos.x - last->lpos.x; |
219 |
diff.y = node_chain->node->lpos.y - last->lpos.y; |
diff.y = node_chain->node->lpos.y - last->lpos.y; |
220 |
|
|
221 |
|
/* only draw arrow if there's sufficient space */ |
222 |
|
/* TODO: what if there's not enough space anywhere? */ |
223 |
float len = sqrt(pow(diff.x, 2)+pow(diff.y, 2)); |
float len = sqrt(pow(diff.x, 2)+pow(diff.y, 2)); |
224 |
if(len > map->style->highlight.arrow_limit*arrow_width) { |
if(len > map->style->highlight.arrow_limit*arrow_width) { |
225 |
len /= arrow_width; |
len /= arrow_width; |
378 |
map_item->type = MAP_TYPE_NODE; |
map_item->type = MAP_TYPE_NODE; |
379 |
map_item->node = node; |
map_item->node = node; |
380 |
|
|
381 |
if(!node->icon_buf || !map->style->icon.enable) |
if(!node->icon_buf || !map->style->icon.enable || |
382 |
|
map->appdata->settings->no_icons) |
383 |
map_item->item = canvas_circle_new(map, CANVAS_GROUP_NODES, |
map_item->item = canvas_circle_new(map, CANVAS_GROUP_NODES, |
384 |
node->lpos.x, node->lpos.y, radius, width, fill, border); |
node->lpos.x, node->lpos.y, radius, width, fill, border); |
385 |
else |
else |
443 |
map_item->way = way; |
map_item->way = way; |
444 |
|
|
445 |
if(way->draw.flags & OSM_DRAW_FLAG_AREA) { |
if(way->draw.flags & OSM_DRAW_FLAG_AREA) { |
446 |
if(map->style->area.opaque) |
if(map->style->area.color & 0xff) |
447 |
map_item->item = canvas_polygon_new(map, group, points, |
map_item->item = canvas_polygon_new(map, group, points, |
448 |
width, color, fill_color); |
width, color, fill_color); |
449 |
else |
else |
455 |
|
|
456 |
canvas_item_set_zoom_max(map_item->item, way->draw.zoom_max); |
canvas_item_set_zoom_max(map_item->item, way->draw.zoom_max); |
457 |
|
|
458 |
|
if (group != CANVAS_GROUP_WAYS_OL) |
459 |
|
if (way->draw.dashed) |
460 |
|
canvas_item_set_dashed(map_item->item, width, way->draw.dash_length); |
461 |
|
|
462 |
/* attach map_item to ways map_item_chain */ |
/* attach map_item to ways map_item_chain */ |
463 |
map_item_chain_t **chain = &way->map_item_chain; |
map_item_chain_t **chain = &way->map_item_chain; |
464 |
while(*chain) chain = &(*chain)->next; |
while(*chain) chain = &(*chain)->next; |
475 |
|
|
476 |
void map_show_node(map_t *map, node_t *node) { |
void map_show_node(map_t *map, node_t *node) { |
477 |
map_node_new(map, node, map->style->node.radius, 0, |
map_node_new(map, node, map->style->node.radius, 0, |
478 |
RGB2CANVAS(map->style->node.color), 0); |
map->style->node.color, 0); |
479 |
} |
} |
480 |
|
|
481 |
void map_way_draw(map_t *map, way_t *way) { |
void map_way_draw(map_t *map, way_t *way) { |
490 |
if(nodes == 1) { |
if(nodes == 1) { |
491 |
/* draw a single dot where this single node is */ |
/* draw a single dot where this single node is */ |
492 |
map_way_single_new(map, way, map->style->node.radius, 0, |
map_way_single_new(map, way, map->style->node.radius, 0, |
493 |
RGB2CANVAS(map->style->node.color), 0); |
map->style->node.color, 0); |
494 |
} else { |
} else { |
495 |
canvas_points_t *points = canvas_points_new(nodes); |
canvas_points_t *points = canvas_points_new(nodes); |
496 |
|
|
526 |
map_node_new(map, node, |
map_node_new(map, node, |
527 |
map->style->node.radius, |
map->style->node.radius, |
528 |
map->style->node.border_radius, |
map->style->node.border_radius, |
529 |
RGBA2CANVAS(map->style->node.fill_color, |
map->style->node.fill_color, |
530 |
map->style->node.has_fill_color?0xff:0x00), |
map->style->node.color); |
|
RGB2CANVAS(map->style->node.color)); |
|
531 |
|
|
532 |
else if(map->style->node.show_untagged || osm_node_has_tag(node)) |
else if(map->style->node.show_untagged || osm_node_has_tag(node)) |
533 |
map_node_new(map, node, |
map_node_new(map, node, |
534 |
map->style->node.radius, 0, |
map->style->node.radius, 0, |
535 |
RGB2CANVAS(map->style->node.color), 0); |
map->style->node.color, 0); |
536 |
} |
} |
537 |
|
|
538 |
static void map_item_draw(map_t *map, map_item_t *map_item) { |
static void map_item_draw(map_t *map, map_item_t *map_item) { |
614 |
canvas_points_t *points = canvas_points_new(5); |
canvas_points_t *points = canvas_points_new(5); |
615 |
|
|
616 |
/* don't draw frisket at all if it's completely transparent */ |
/* don't draw frisket at all if it's completely transparent */ |
617 |
if(map->style->frisket.opaque) { |
if(map->style->frisket.color & 0xff) { |
618 |
elemstyle_color_t color = |
elemstyle_color_t color = map->style->frisket.color; |
|
(map->style->background.color<<8) | map->style->frisket.opaque; |
|
619 |
|
|
620 |
float mult = map->style->frisket.mult; |
float mult = map->style->frisket.mult; |
621 |
|
|
780 |
return NULL; |
return NULL; |
781 |
} |
} |
782 |
|
|
783 |
if(map_item->highlight) |
if(map_item->highlight) |
784 |
printf(" item is highlight\n"); |
printf(" item is highlight\n"); |
785 |
|
|
786 |
switch(map_item->type) { |
switch(map_item->type) { |
799 |
} |
} |
800 |
|
|
801 |
/* get the real item (no highlight) at x, y */ |
/* get the real item (no highlight) at x, y */ |
802 |
static map_item_t *map_real_item_at(map_t *map, gint x, gint y) { |
map_item_t *map_real_item_at(map_t *map, gint x, gint y) { |
803 |
map_item_t *map_item = map_item_at(map, x, y); |
map_item_t *map_item = map_item_at(map, x, y); |
804 |
|
|
805 |
/* no item or already a real one */ |
/* no item or already a real one */ |
1001 |
max_y = map->appdata->osm->bounds->max.y; |
max_y = map->appdata->osm->bounds->max.y; |
1002 |
if ( (lpos->x > max_x) || (lpos->x < min_x) |
if ( (lpos->x > max_x) || (lpos->x < min_x) |
1003 |
|| (lpos->y > max_y) || (lpos->y < min_y)) { |
|| (lpos->y > max_y) || (lpos->y < min_y)) { |
1004 |
printf("cannot scroll to (%d, %d): outside the working area\n"); |
printf("cannot scroll to (%d, %d): outside the working area\n", |
1005 |
|
lpos->x, lpos->y); |
1006 |
return; |
return; |
1007 |
} |
} |
1008 |
|
|
1591 |
/* reduce update frequency on hildon to keep screen update fluid */ |
/* reduce update frequency on hildon to keep screen update fluid */ |
1592 |
static guint32 last_time = 0; |
static guint32 last_time = 0; |
1593 |
|
|
1594 |
if(event->time - last_time < 100) return FALSE; |
if(event->time - last_time < 250) return FALSE; |
1595 |
last_time = event->time; |
last_time = event->time; |
1596 |
#endif |
#endif |
1597 |
|
|
1635 |
case MAP_ACTION_NODE_ADD: |
case MAP_ACTION_NODE_ADD: |
1636 |
map_hl_cursor_draw(map, x, y, FALSE, map->style->node.radius); |
map_hl_cursor_draw(map, x, y, FALSE, map->style->node.radius); |
1637 |
break; |
break; |
1638 |
|
|
1639 |
case MAP_ACTION_WAY_ADD: |
case MAP_ACTION_WAY_ADD: |
1640 |
map_hl_cursor_draw(map, x, y, FALSE, map->style->node.radius); |
map_hl_cursor_draw(map, x, y, FALSE, map->style->node.radius); |
1641 |
map_touchnode_update(appdata, x, y); |
map_touchnode_update(appdata, x, y); |
1643 |
|
|
1644 |
case MAP_ACTION_WAY_NODE_ADD: |
case MAP_ACTION_WAY_NODE_ADD: |
1645 |
map_hl_cursor_clear(map); |
map_hl_cursor_clear(map); |
1646 |
map_item_t *item = map_item_at(map, x, y); |
map_item_t *item = map_real_item_at(map, x, y); |
1647 |
if(item) map_edit_way_node_add_highlight(map, item, x, y); |
if(item) map_edit_way_node_add_highlight(map, item, x, y); |
1648 |
break; |
break; |
1649 |
|
|
1650 |
case MAP_ACTION_WAY_CUT: |
case MAP_ACTION_WAY_CUT: |
1651 |
map_hl_cursor_clear(map); |
map_hl_cursor_clear(map); |
1652 |
item = map_item_at(map, x, y); |
item = map_real_item_at(map, x, y); |
1653 |
if(item) map_edit_way_cut_highlight(map, item, x, y); |
if(item) map_edit_way_cut_highlight(map, item, x, y); |
1654 |
break; |
break; |
1655 |
|
|
1740 |
map_t *map = appdata->map = g_new0(map_t, 1); |
map_t *map = appdata->map = g_new0(map_t, 1); |
1741 |
|
|
1742 |
map->style = style_load(appdata, appdata->settings->style); |
map->style = style_load(appdata, appdata->settings->style); |
1743 |
|
if(!map->style) { |
1744 |
|
errorf(NULL, _("Unable to load valid style, terminating.")); |
1745 |
|
g_free(map); |
1746 |
|
return NULL; |
1747 |
|
} |
1748 |
|
|
1749 |
if(appdata->project && appdata->project->map_state) { |
if(appdata->project && appdata->project->map_state) { |
1750 |
printf("Using projects map state\n"); |
printf("Using projects map state\n"); |
1781 |
|
|
1782 |
g_object_set(G_OBJECT(map->canvas), "anchor", GTK_ANCHOR_CENTER, NULL); |
g_object_set(G_OBJECT(map->canvas), "anchor", GTK_ANCHOR_CENTER, NULL); |
1783 |
g_object_set(G_OBJECT(map->canvas), "background-color-rgb", |
g_object_set(G_OBJECT(map->canvas), "background-color-rgb", |
1784 |
map->style->background.color, NULL); |
map->style->background.color >> 8, NULL); |
1785 |
|
|
1786 |
GooCanvasItem *root = goo_canvas_get_root_item(GOO_CANVAS(map->canvas)); |
GooCanvasItem *root = goo_canvas_get_root_item(GOO_CANVAS(map->canvas)); |
1787 |
|
g_object_set(G_OBJECT(root), "antialias", |
1788 |
|
appdata->settings->no_antialias?CAIRO_ANTIALIAS_NONE: |
1789 |
|
CAIRO_ANTIALIAS_DEFAULT, NULL); |
1790 |
|
|
1791 |
/* create the groups */ |
/* create the groups */ |
1792 |
canvas_group_t group; |
canvas_group_t group; |
1896 |
void map_paint(appdata_t *appdata) { |
void map_paint(appdata_t *appdata) { |
1897 |
map_t *map = appdata->map; |
map_t *map = appdata->map; |
1898 |
|
|
1899 |
|
/* user may have changes antialias settings */ |
1900 |
|
GooCanvasItem *root = goo_canvas_get_root_item(GOO_CANVAS(map->canvas)); |
1901 |
|
g_object_set(G_OBJECT(root), "antialias", |
1902 |
|
appdata->settings->no_antialias?CAIRO_ANTIALIAS_NONE: |
1903 |
|
CAIRO_ANTIALIAS_DEFAULT, NULL); |
1904 |
|
|
1905 |
josm_elemstyles_colorize_world(map->style, appdata->osm); |
josm_elemstyles_colorize_world(map->style, appdata->osm); |
1906 |
map_draw(map, appdata->osm); |
map_draw(map, appdata->osm); |
1907 |
} |
} |
2033 |
/* deleting the selected item de-selects it ... */ |
/* deleting the selected item de-selects it ... */ |
2034 |
map_item_deselect(appdata); |
map_item_deselect(appdata); |
2035 |
|
|
2036 |
|
undo_remember_delete(appdata, item.type, item.ptr); |
2037 |
|
|
2038 |
switch(item.type) { |
switch(item.type) { |
2039 |
case MAP_TYPE_NODE: |
case MAP_TYPE_NODE: |
2040 |
printf("request to delete node #%ld\n", item.node->id); |
printf("request to delete node #%ld\n", item.node->id); |
2209 |
if(lpos) |
if(lpos) |
2210 |
appdata->track.gps_item = canvas_circle_new(appdata->map, CANVAS_GROUP_GPS, |
appdata->track.gps_item = canvas_circle_new(appdata->map, CANVAS_GROUP_GPS, |
2211 |
lpos->x, lpos->y, appdata->map->style->track.width/2.0, 0, |
lpos->x, lpos->y, appdata->map->style->track.width/2.0, 0, |
2212 |
RGB2CANVAS(appdata->map->style->track.gps_color), NO_COLOR); |
appdata->map->style->track.gps_color, NO_COLOR); |
2213 |
} |
} |
2214 |
|
|
2215 |
/* ------------------- map background ------------------ */ |
/* ------------------- map background ------------------ */ |
2295 |
|
|
2296 |
gtk_widget_set_sensitive(appdata->menu_item_map_show_all, FALSE); |
gtk_widget_set_sensitive(appdata->menu_item_map_show_all, FALSE); |
2297 |
} |
} |
2298 |
|
// vim:et:ts=8:sw=2:sts=2:ai |