166 |
|
|
167 |
map_hl_circle_new(map, CANVAS_GROUP_NODES_HL, new_map_item, |
map_hl_circle_new(map, CANVAS_GROUP_NODES_HL, new_map_item, |
168 |
x, y, radius, map->style->highlight.color); |
x, y, radius, map->style->highlight.color); |
169 |
|
|
170 |
if(!map_item->item) { |
if(!map_item->item) { |
171 |
/* and draw a fake node */ |
/* and draw a fake node */ |
172 |
new_map_item = g_new0(map_item_t, 1); |
new_map_item = g_new0(map_item_t, 1); |
380 |
|
|
381 |
if(!node->icon_buf || !map->style->icon.enable || |
if(!node->icon_buf || !map->style->icon.enable || |
382 |
map->appdata->settings->no_icons) |
map->appdata->settings->no_icons) |
383 |
map_item->item = canvas_circle_new(map, CANVAS_GROUP_NODES, |
map_item->item = canvas_circle_new(map->canvas, 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 |
386 |
map_item->item = canvas_image_new(map, CANVAS_GROUP_NODES, |
map_item->item = canvas_image_new(map->canvas, CANVAS_GROUP_NODES, |
387 |
node->icon_buf, |
node->icon_buf, |
388 |
node->lpos.x - map->style->icon.scale/2 * |
node->lpos.x - map->style->icon.scale/2 * |
389 |
gdk_pixbuf_get_width(node->icon_buf), |
gdk_pixbuf_get_width(node->icon_buf), |
415 |
map_item_t *map_item = g_new0(map_item_t, 1); |
map_item_t *map_item = g_new0(map_item_t, 1); |
416 |
map_item->type = MAP_TYPE_WAY; |
map_item->type = MAP_TYPE_WAY; |
417 |
map_item->way = way; |
map_item->way = way; |
418 |
map_item->item = canvas_circle_new(map, CANVAS_GROUP_WAYS, |
map_item->item = canvas_circle_new(map->canvas, CANVAS_GROUP_WAYS, |
419 |
way->node_chain->node->lpos.x, way->node_chain->node->lpos.y, |
way->node_chain->node->lpos.x, way->node_chain->node->lpos.y, |
420 |
radius, width, fill, border); |
radius, width, fill, border); |
421 |
|
|
444 |
|
|
445 |
if(way->draw.flags & OSM_DRAW_FLAG_AREA) { |
if(way->draw.flags & OSM_DRAW_FLAG_AREA) { |
446 |
if(map->style->area.color & 0xff) |
if(map->style->area.color & 0xff) |
447 |
map_item->item = canvas_polygon_new(map, group, points, |
map_item->item = canvas_polygon_new(map->canvas, group, points, |
448 |
width, color, fill_color); |
width, color, fill_color); |
449 |
else |
else |
450 |
map_item->item = canvas_polyline_new(map, group, points, |
map_item->item = canvas_polyline_new(map->canvas, group, points, |
451 |
width, color); |
width, color); |
452 |
} else { |
} else { |
453 |
map_item->item = canvas_polyline_new(map, group, points, width, color); |
map_item->item = canvas_polyline_new(map->canvas, group, points, width, color); |
454 |
} |
} |
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); |
622 |
/* top rectangle */ |
/* top rectangle */ |
623 |
map_frisket_rectangle(points, mult*bounds->min.x, mult*bounds->max.x, |
map_frisket_rectangle(points, mult*bounds->min.x, mult*bounds->max.x, |
624 |
mult*bounds->min.y, bounds->min.y); |
mult*bounds->min.y, bounds->min.y); |
625 |
canvas_polygon_new(map, CANVAS_GROUP_NODES, points, 1, NO_COLOR, color); |
canvas_polygon_new(map->canvas, CANVAS_GROUP_FRISKET, points, |
626 |
|
1, NO_COLOR, color); |
627 |
|
|
628 |
/* bottom rectangle */ |
/* bottom rectangle */ |
629 |
map_frisket_rectangle(points, mult*bounds->min.x, mult*bounds->max.x, |
map_frisket_rectangle(points, mult*bounds->min.x, mult*bounds->max.x, |
630 |
bounds->max.y, mult*bounds->max.y); |
bounds->max.y, mult*bounds->max.y); |
631 |
canvas_polygon_new(map, CANVAS_GROUP_NODES, points, 1, NO_COLOR, color); |
canvas_polygon_new(map->canvas, CANVAS_GROUP_FRISKET, points, |
632 |
|
1, NO_COLOR, color); |
633 |
|
|
634 |
/* left rectangle */ |
/* left rectangle */ |
635 |
map_frisket_rectangle(points, mult*bounds->min.x, bounds->min.x, |
map_frisket_rectangle(points, mult*bounds->min.x, bounds->min.x, |
636 |
mult*bounds->min.y, mult*bounds->max.y); |
mult*bounds->min.y, mult*bounds->max.y); |
637 |
canvas_polygon_new(map, CANVAS_GROUP_NODES, points, 1, NO_COLOR, color); |
canvas_polygon_new(map->canvas, CANVAS_GROUP_FRISKET, points, |
638 |
|
1, NO_COLOR, color); |
639 |
|
|
640 |
/* right rectangle */ |
/* right rectangle */ |
641 |
map_frisket_rectangle(points, bounds->max.x, mult*bounds->max.x, |
map_frisket_rectangle(points, bounds->max.x, mult*bounds->max.x, |
642 |
mult*bounds->min.y, mult*bounds->max.y); |
mult*bounds->min.y, mult*bounds->max.y); |
643 |
canvas_polygon_new(map, CANVAS_GROUP_NODES, points, 1, NO_COLOR, color); |
canvas_polygon_new(map->canvas, CANVAS_GROUP_FRISKET, points, |
644 |
|
1, NO_COLOR, color); |
645 |
|
|
646 |
} |
} |
647 |
|
|
652 |
bounds->min.x-ew2, bounds->max.x+ew2, |
bounds->min.x-ew2, bounds->max.x+ew2, |
653 |
bounds->min.y-ew2, bounds->max.y+ew2); |
bounds->min.y-ew2, bounds->max.y+ew2); |
654 |
|
|
655 |
canvas_polyline_new(map, CANVAS_GROUP_NODES, points, |
canvas_polyline_new(map->canvas, CANVAS_GROUP_FRISKET, points, |
656 |
map->style->frisket.border.width, |
map->style->frisket.border.width, |
657 |
map->style->frisket.border.color); |
map->style->frisket.border.color); |
658 |
|
|
845 |
|
|
846 |
/* Limitations on the amount by which we can scroll. Keeps part of the |
/* Limitations on the amount by which we can scroll. Keeps part of the |
847 |
* map visible at all times */ |
* map visible at all times */ |
848 |
static void map_limit_scroll(map_t *map, gint *sx, gint *sy) { |
static void map_limit_scroll(map_t *map, canvas_unit_t unit, |
849 |
gdouble zoom = goo_canvas_get_scale(GOO_CANVAS(map->canvas)); |
gint *sx, gint *sy) { |
|
|
|
|
gint sx_cu = *sx / zoom; |
|
|
gint sy_cu = *sy / zoom; |
|
|
|
|
|
// Canvas viewport dimensions |
|
|
GtkAllocation *a = >K_WIDGET(map->canvas)->allocation; |
|
|
gint aw_cu = a->width / zoom; |
|
|
gint ah_cu = a->height / zoom; |
|
|
|
|
|
// Data rect minimum and maximum |
|
|
gint min_x, min_y, max_x, max_y; |
|
|
min_x = map->appdata->osm->bounds->min.x; |
|
|
min_y = map->appdata->osm->bounds->min.y; |
|
|
max_x = map->appdata->osm->bounds->max.x; |
|
|
max_y = map->appdata->osm->bounds->max.y; |
|
850 |
|
|
851 |
// limit stops - prevent scrolling beyond these |
/* get scale factor for pixel->meter conversion. set to 1 if */ |
852 |
gint min_sy_cu = 0.95*(min_y - ah_cu); |
/* given coordinates are already in meters */ |
853 |
gint min_sx_cu = 0.95*(min_x - aw_cu); |
gdouble scale = (unit == CANVAS_UNIT_METER)?1.0:canvas_get_zoom(map->canvas); |
854 |
gint max_sy_cu = 0.95*(max_y); |
|
855 |
gint max_sx_cu = 0.95*(max_x); |
/* convert pixels to meters if necessary */ |
856 |
if (sy_cu < min_sy_cu) { *sy = min_sy_cu*zoom; } |
gdouble sx_cu = *sx / scale; |
857 |
if (sx_cu < min_sx_cu) { *sx = min_sx_cu*zoom; } |
gdouble sy_cu = *sy / scale; |
858 |
if (sy_cu > max_sy_cu) { *sy = max_sy_cu*zoom; } |
|
859 |
if (sx_cu > max_sx_cu) { *sx = max_sx_cu*zoom; } |
/* get size of visible area in canvas units (meters) */ |
860 |
|
gint aw_cu = canvas_get_viewport_width(map->canvas, CANVAS_UNIT_METER); |
861 |
|
gint ah_cu = canvas_get_viewport_height(map->canvas, CANVAS_UNIT_METER); |
862 |
|
|
863 |
|
// Data rect minimum and maximum |
864 |
|
gint min_x, min_y, max_x, max_y; |
865 |
|
min_x = map->appdata->osm->bounds->min.x; |
866 |
|
min_y = map->appdata->osm->bounds->min.y; |
867 |
|
max_x = map->appdata->osm->bounds->max.x; |
868 |
|
max_y = map->appdata->osm->bounds->max.y; |
869 |
|
|
870 |
|
// limit stops - prevent scrolling beyond these |
871 |
|
gint min_sy_cu = 0.95*(min_y - ah_cu); |
872 |
|
gint min_sx_cu = 0.95*(min_x - aw_cu); |
873 |
|
gint max_sy_cu = 0.95*(max_y); |
874 |
|
gint max_sx_cu = 0.95*(max_x); |
875 |
|
if (sy_cu < min_sy_cu) { *sy = min_sy_cu * scale; } |
876 |
|
if (sx_cu < min_sx_cu) { *sx = min_sx_cu * scale; } |
877 |
|
if (sy_cu > max_sy_cu) { *sy = max_sy_cu * scale; } |
878 |
|
if (sx_cu > max_sx_cu) { *sx = max_sx_cu * scale; } |
879 |
} |
} |
880 |
|
|
881 |
|
|
889 |
max_x = map->appdata->osm->bounds->max.x; |
max_x = map->appdata->osm->bounds->max.x; |
890 |
max_y = map->appdata->osm->bounds->max.y; |
max_y = map->appdata->osm->bounds->max.y; |
891 |
|
|
892 |
// Canvas viewport dimensions |
/* get size of visible area in pixels and convert to meters of intended */ |
893 |
GtkAllocation *a = >K_WIDGET(map->canvas)->allocation; |
/* zoom by deviding by zoom (which is basically pix/m) */ |
894 |
gint ah_cu = a->height / *zoom; |
gint aw_cu = |
895 |
gint aw_cu = a->width / *zoom; |
canvas_get_viewport_width(map->canvas, CANVAS_UNIT_PIXEL) / *zoom; |
896 |
|
gint ah_cu = |
897 |
|
canvas_get_viewport_height(map->canvas, CANVAS_UNIT_PIXEL) / *zoom; |
898 |
|
|
899 |
gdouble oldzoom = *zoom; |
gdouble oldzoom = *zoom; |
900 |
if (ah_cu < aw_cu) { |
if (ah_cu < aw_cu) { |
941 |
} |
} |
942 |
|
|
943 |
// Viewport dimensions in canvas space |
// Viewport dimensions in canvas space |
944 |
gdouble zoom = goo_canvas_get_scale(GOO_CANVAS(map->canvas)); |
|
945 |
GtkAllocation *a = >K_WIDGET(map->canvas)->allocation; |
/* get size of visible area in canvas units (meters) */ |
946 |
gdouble aw = a->width / zoom; |
gdouble pix_per_meter = canvas_get_zoom(map->canvas); |
947 |
gdouble ah = a->height / zoom; |
gdouble aw = canvas_get_viewport_width(map->canvas, CANVAS_UNIT_METER); |
948 |
|
gdouble ah = canvas_get_viewport_height(map->canvas, CANVAS_UNIT_METER); |
949 |
|
|
950 |
// Is the point still onscreen? |
// Is the point still onscreen? |
951 |
gboolean vert_recentre_needed = FALSE; |
gboolean vert_recentre_needed = FALSE; |
952 |
gboolean horiz_recentre_needed = FALSE; |
gboolean horiz_recentre_needed = FALSE; |
953 |
gint sx, sy; |
gint sx, sy; |
954 |
canvas_get_scroll_offsets(map->canvas, &sx, &sy); |
canvas_scroll_get(map->canvas, CANVAS_UNIT_PIXEL, &sx, &sy); |
955 |
gint viewport_left = (sx/zoom); |
gint viewport_left = (sx/pix_per_meter); |
956 |
gint viewport_right = (sx/zoom)+aw; |
gint viewport_right = (sx/pix_per_meter)+aw; |
957 |
gint viewport_top = (sy/zoom); |
gint viewport_top = (sy/pix_per_meter); |
958 |
gint viewport_bottom = (sy/zoom)+ah; |
gint viewport_bottom = (sy/pix_per_meter)+ah; |
959 |
if (lpos->x > viewport_right) { |
if (lpos->x > viewport_right) { |
960 |
printf("** off right edge (%d > %d)\n", lpos->x, viewport_right); |
printf("** off right edge (%d > %d)\n", lpos->x, viewport_right); |
961 |
horiz_recentre_needed = TRUE; |
horiz_recentre_needed = TRUE; |
977 |
gint new_sx, new_sy; |
gint new_sx, new_sy; |
978 |
|
|
979 |
// Just centre both at once |
// Just centre both at once |
980 |
new_sx = zoom * (lpos->x - (aw/2)); |
new_sx = pix_per_meter * (lpos->x - (aw/2)); |
981 |
new_sy = zoom * (lpos->y - (ah/2)); |
new_sy = pix_per_meter * (lpos->y - (ah/2)); |
982 |
|
|
983 |
map_limit_scroll(map, &new_sx, &new_sy); |
map_limit_scroll(map, CANVAS_UNIT_PIXEL, &new_sx, &new_sy); |
984 |
canvas_scroll_to(map->canvas, new_sx, new_sy); |
canvas_scroll_to(map->canvas, CANVAS_UNIT_PIXEL, new_sx, new_sy); |
985 |
} |
} |
986 |
} |
} |
987 |
|
|
1016 |
|
|
1017 |
map_deselect_if_zoom_below_zoom_max(map); |
map_deselect_if_zoom_below_zoom_max(map); |
1018 |
|
|
1019 |
if (update_scroll_offsets) { |
if(update_scroll_offsets) { |
1020 |
if (!at_zoom_limit) { |
if (!at_zoom_limit) { |
1021 |
/* zooming affects the scroll offsets */ |
/* zooming affects the scroll offsets */ |
1022 |
gint sx, sy; |
gint sx, sy; |
1023 |
canvas_get_scroll_offsets(map->canvas, &sx, &sy); |
canvas_scroll_get(map->canvas, CANVAS_UNIT_PIXEL, &sx, &sy); |
1024 |
map_limit_scroll(map, &sx, &sy); |
map_limit_scroll(map, CANVAS_UNIT_PIXEL, &sx, &sy); |
1025 |
canvas_scroll_to(map->canvas, sx, sy); // keep the map visible |
|
1026 |
map->state->scroll_offset.x = sx; |
// keep the map visible |
1027 |
map->state->scroll_offset.y = sy; |
canvas_scroll_to(map->canvas, CANVAS_UNIT_PIXEL, sx, sy); |
1028 |
} |
} |
1029 |
|
|
1030 |
|
canvas_scroll_get(map->canvas, CANVAS_UNIT_METER, |
1031 |
|
&map->state->scroll_offset.x, |
1032 |
|
&map->state->scroll_offset.y); |
1033 |
} |
} |
1034 |
} |
} |
1035 |
|
|
1054 |
static gboolean distance_above(map_t *map, gint x, gint y, gint limit) { |
static gboolean distance_above(map_t *map, gint x, gint y, gint limit) { |
1055 |
gint sx, sy; |
gint sx, sy; |
1056 |
|
|
|
#ifdef USE_GNOMECANVAS |
|
|
gnome_canvas_get_scroll_offsets(GNOME_CANVAS(map->canvas), &sx, &sy); |
|
|
|
|
|
/* add offsets generated by mouse within map and map scrolling */ |
|
|
sx = (x-map->pen_down.at.x) + (map->pen_down.so.x-sx); |
|
|
sy = (y-map->pen_down.at.y) + (map->pen_down.so.y-sy); |
|
|
#else |
|
1057 |
/* add offsets generated by mouse within map and map scrolling */ |
/* add offsets generated by mouse within map and map scrolling */ |
1058 |
sx = (x-map->pen_down.at.x); |
sx = (x-map->pen_down.at.x); |
1059 |
sy = (y-map->pen_down.at.y); |
sy = (y-map->pen_down.at.y); |
|
#endif |
|
1060 |
|
|
1061 |
return(sx*sx + sy*sy > limit*limit); |
return(sx*sx + sy*sy > limit*limit); |
1062 |
} |
} |
1065 |
static void map_do_scroll(map_t *map, gint x, gint y) { |
static void map_do_scroll(map_t *map, gint x, gint y) { |
1066 |
gint sx, sy; |
gint sx, sy; |
1067 |
|
|
1068 |
canvas_get_scroll_offsets(map->canvas, &sx, &sy); |
canvas_scroll_get(map->canvas, CANVAS_UNIT_PIXEL, &sx, &sy); |
1069 |
sx -= x-map->pen_down.at.x; |
sx -= x-map->pen_down.at.x; |
1070 |
sy -= y-map->pen_down.at.y; |
sy -= y-map->pen_down.at.y; |
1071 |
map_limit_scroll(map, &sx, &sy); |
map_limit_scroll(map, CANVAS_UNIT_PIXEL, &sx, &sy); |
1072 |
canvas_scroll_to(map->canvas, sx, sy); |
canvas_scroll_to(map->canvas, CANVAS_UNIT_PIXEL, sx, sy); |
1073 |
map->state->scroll_offset.x = sx; |
|
1074 |
map->state->scroll_offset.y = sy; |
canvas_scroll_get(map->canvas, CANVAS_UNIT_METER, |
1075 |
|
&map->state->scroll_offset.x, |
1076 |
|
&map->state->scroll_offset.y); |
1077 |
} |
} |
1078 |
|
|
1079 |
|
|
1080 |
/* scroll a certain step */ |
/* scroll a certain step */ |
1081 |
static void map_do_scroll_step(map_t *map, gint x, gint y) { |
static void map_do_scroll_step(map_t *map, gint x, gint y) { |
1082 |
gint sx, sy; |
gint sx, sy; |
1083 |
canvas_get_scroll_offsets(map->canvas, &sx, &sy); |
canvas_scroll_get(map->canvas, CANVAS_UNIT_PIXEL, &sx, &sy); |
1084 |
sx += x; |
sx += x; |
1085 |
sy += y; |
sy += y; |
1086 |
map_limit_scroll(map, &sx, &sy); |
map_limit_scroll(map, CANVAS_UNIT_PIXEL, &sx, &sy); |
1087 |
canvas_scroll_to(map->canvas, sx, sy); |
canvas_scroll_to(map->canvas, CANVAS_UNIT_PIXEL, sx, sy); |
|
map->state->scroll_offset.x = sx; |
|
|
map->state->scroll_offset.y = sy; |
|
|
} |
|
1088 |
|
|
1089 |
|
canvas_scroll_get(map->canvas, CANVAS_UNIT_METER, |
1090 |
|
&map->state->scroll_offset.x, |
1091 |
|
&map->state->scroll_offset.y); |
1092 |
|
} |
1093 |
|
|
1094 |
gboolean map_item_is_selected_node(map_t *map, map_item_t *map_item) { |
gboolean map_item_is_selected_node(map_t *map, map_item_t *map_item) { |
1095 |
printf("check if item is a selected node\n"); |
printf("check if item is a selected node\n"); |
1308 |
map->pen_down.at.y = y; |
map->pen_down.at.y = y; |
1309 |
map->pen_down.drag = FALSE; // don't assume drag yet |
map->pen_down.drag = FALSE; // don't assume drag yet |
1310 |
|
|
|
#ifdef USE_GNOMECANVAS |
|
|
/* save initial scroll offset */ |
|
|
gnome_canvas_get_scroll_offsets(GNOME_CANVAS(map->canvas), |
|
|
&map->pen_down.so.x, &map->pen_down.so.y); |
|
|
#endif |
|
|
|
|
1311 |
/* determine wether this press was on an item */ |
/* determine wether this press was on an item */ |
1312 |
map->pen_down.on_item = map_real_item_at(map, x, y); |
map->pen_down.on_item = map_real_item_at(map, x, y); |
1313 |
|
|
1671 |
map->appdata = appdata; |
map->appdata = appdata; |
1672 |
map->action.type = MAP_ACTION_IDLE; |
map->action.type = MAP_ACTION_IDLE; |
1673 |
|
|
1674 |
#ifdef USE_GNOMECANVAS |
map->canvas = canvas_new(map->style->background.color); |
1675 |
map->canvas = gnome_canvas_new_aa(); // _aa |
canvas_set_antialias(map->canvas, !appdata->settings->no_antialias); |
|
|
|
|
/* create the groups */ |
|
|
canvas_group_t group; |
|
|
for(group = 0; group < CANVAS_GROUPS; group++) |
|
|
map->group[group] = gnome_canvas_item_new( |
|
|
gnome_canvas_root(GNOME_CANVAS(map->canvas)), |
|
|
GNOME_TYPE_CANVAS_GROUP, |
|
|
NULL); |
|
1676 |
|
|
1677 |
gtk_widget_modify_bg(map->canvas, GTK_STATE_NORMAL, |
GtkWidget *canvas_widget = canvas_get_widget(map->canvas); |
|
&map->canvas->style->white); |
|
1678 |
|
|
1679 |
#else |
gtk_widget_set_events(canvas_widget, |
|
map->canvas = goo_canvas_new(); |
|
|
|
|
|
g_object_set(G_OBJECT(map->canvas), "anchor", GTK_ANCHOR_CENTER, NULL); |
|
|
g_object_set(G_OBJECT(map->canvas), "background-color-rgb", |
|
|
map->style->background.color >> 8, NULL); |
|
|
|
|
|
GooCanvasItem *root = goo_canvas_get_root_item(GOO_CANVAS(map->canvas)); |
|
|
g_object_set(G_OBJECT(root), "antialias", |
|
|
appdata->settings->no_antialias?CAIRO_ANTIALIAS_NONE: |
|
|
CAIRO_ANTIALIAS_DEFAULT, NULL); |
|
|
|
|
|
/* create the groups */ |
|
|
canvas_group_t group; |
|
|
for(group = 0; group < CANVAS_GROUPS; group++) |
|
|
map->group[group] = goo_canvas_group_new(root, NULL); |
|
|
|
|
|
#endif |
|
|
|
|
|
gtk_widget_set_events(map->canvas, |
|
1680 |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_PRESS_MASK |
1681 |
| GDK_BUTTON_RELEASE_MASK |
| GDK_BUTTON_RELEASE_MASK |
1682 |
| GDK_SCROLL_MASK |
| GDK_SCROLL_MASK |
1683 |
| GDK_POINTER_MOTION_MASK |
| GDK_POINTER_MOTION_MASK |
1684 |
| GDK_POINTER_MOTION_HINT_MASK); |
| GDK_POINTER_MOTION_HINT_MASK); |
1685 |
|
|
1686 |
gtk_signal_connect(GTK_OBJECT(map->canvas), |
gtk_signal_connect(GTK_OBJECT(canvas_widget), |
1687 |
"button_press_event", G_CALLBACK(map_button_event), appdata); |
"button_press_event", G_CALLBACK(map_button_event), appdata); |
1688 |
gtk_signal_connect(GTK_OBJECT(map->canvas), |
gtk_signal_connect(GTK_OBJECT(canvas_widget), |
1689 |
"button_release_event", G_CALLBACK(map_button_event), appdata); |
"button_release_event", G_CALLBACK(map_button_event), appdata); |
1690 |
gtk_signal_connect(GTK_OBJECT(map->canvas), |
gtk_signal_connect(GTK_OBJECT(canvas_widget), |
1691 |
"motion_notify_event", G_CALLBACK(map_motion_notify_event), appdata); |
"motion_notify_event", G_CALLBACK(map_motion_notify_event), appdata); |
1692 |
gtk_signal_connect(GTK_OBJECT(map->canvas), |
gtk_signal_connect(GTK_OBJECT(canvas_widget), |
1693 |
"scroll_event", G_CALLBACK(map_scroll_event), appdata); |
"scroll_event", G_CALLBACK(map_scroll_event), appdata); |
1694 |
|
|
1695 |
gtk_signal_connect(GTK_OBJECT(map->canvas), |
gtk_signal_connect(GTK_OBJECT(canvas_widget), |
1696 |
"destroy", G_CALLBACK(map_destroy_event), appdata); |
"destroy", G_CALLBACK(map_destroy_event), appdata); |
1697 |
|
|
1698 |
return map->canvas; |
return canvas_widget; |
1699 |
} |
} |
1700 |
|
|
1701 |
void map_init(appdata_t *appdata) { |
void map_init(appdata_t *appdata) { |
1714 |
mult*appdata->osm->bounds->max.x, |
mult*appdata->osm->bounds->max.x, |
1715 |
mult*appdata->osm->bounds->max.y); |
mult*appdata->osm->bounds->max.y); |
1716 |
|
|
1717 |
printf("restore scroll offsets %d/%d\n", |
printf("restore scroll position %d/%d\n", |
1718 |
map->state->scroll_offset.x, map->state->scroll_offset.y); |
map->state->scroll_offset.x, map->state->scroll_offset.y); |
1719 |
|
|
1720 |
canvas_scroll_to(map->canvas, |
map_limit_scroll(map, CANVAS_UNIT_METER, |
1721 |
map->state->scroll_offset.x, map->state->scroll_offset.y); |
&map->state->scroll_offset.x, &map->state->scroll_offset.y); |
1722 |
|
canvas_scroll_to(map->canvas, CANVAS_UNIT_METER, |
1723 |
|
map->state->scroll_offset.x, map->state->scroll_offset.y); |
1724 |
} |
} |
1725 |
|
|
1726 |
|
|
1743 |
} |
} |
1744 |
} |
} |
1745 |
|
|
1746 |
void map_clear(appdata_t *appdata, gint layer_mask) { |
void map_clear(appdata_t *appdata, gint group_mask) { |
1747 |
map_t *map = appdata->map; |
map_t *map = appdata->map; |
1748 |
|
|
1749 |
printf("freeing map contents\n"); |
printf("freeing map contents\n"); |
1753 |
/* remove a possibly existing highlight */ |
/* remove a possibly existing highlight */ |
1754 |
map_item_deselect(appdata); |
map_item_deselect(appdata); |
1755 |
|
|
1756 |
canvas_group_t group; |
canvas_erase(map->canvas, group_mask); |
|
for(group=0;group<CANVAS_GROUPS;group++) { |
|
|
|
|
|
#ifdef USE_GNOMECANVAS |
|
|
/* destroy the entire group */ |
|
|
canvas_item_destroy(map->group[group]); |
|
|
|
|
|
/* and create an empty new one */ |
|
|
map->group[group] = gnome_canvas_item_new( |
|
|
gnome_canvas_root(GNOME_CANVAS(map->canvas)), |
|
|
GNOME_TYPE_CANVAS_GROUP, |
|
|
NULL); |
|
|
#else |
|
|
if(layer_mask & (1<<group)) { |
|
|
gint children = goo_canvas_item_get_n_children(map->group[group]); |
|
|
printf("Removing %d children from layer %d\n", children, group); |
|
|
while(children--) |
|
|
goo_canvas_item_remove_child(map->group[group], children); |
|
|
} |
|
|
#endif |
|
|
} |
|
1757 |
} |
} |
1758 |
|
|
1759 |
void map_paint(appdata_t *appdata) { |
void map_paint(appdata_t *appdata) { |
1760 |
map_t *map = appdata->map; |
map_t *map = appdata->map; |
1761 |
|
|
1762 |
/* user may have changed antialias settings */ |
/* user may have changed antialias settings */ |
1763 |
GooCanvasItem *root = goo_canvas_get_root_item(GOO_CANVAS(map->canvas)); |
canvas_set_antialias(map->canvas, !appdata->settings->no_antialias); |
|
g_object_set(G_OBJECT(root), "antialias", |
|
|
appdata->settings->no_antialias?CAIRO_ANTIALIAS_NONE: |
|
|
CAIRO_ANTIALIAS_DEFAULT, NULL); |
|
1764 |
|
|
1765 |
josm_elemstyles_colorize_world(map->style, appdata->osm); |
josm_elemstyles_colorize_world(map->style, appdata->osm); |
1766 |
map_draw(map, appdata->osm); |
map_draw(map, appdata->osm); |
1979 |
if(pnum == 1) { |
if(pnum == 1) { |
1980 |
g_assert(!seg->item); |
g_assert(!seg->item); |
1981 |
|
|
1982 |
seg->item = canvas_circle_new(map, CANVAS_GROUP_TRACK, |
seg->item = canvas_circle_new(map->canvas, CANVAS_GROUP_TRACK, |
1983 |
seg->track_point->lpos.x, seg->track_point->lpos.y, |
seg->track_point->lpos.x, seg->track_point->lpos.y, |
1984 |
map->style->track.width/2.0, 0, map->style->track.color, NO_COLOR); |
map->style->track.width/2.0, 0, map->style->track.color, NO_COLOR); |
1985 |
} |
} |
2001 |
if(seg->item) |
if(seg->item) |
2002 |
canvas_item_destroy(seg->item); |
canvas_item_destroy(seg->item); |
2003 |
|
|
2004 |
seg->item = canvas_polyline_new(map, CANVAS_GROUP_TRACK, |
seg->item = canvas_polyline_new(map->canvas, CANVAS_GROUP_TRACK, |
2005 |
points, map->style->track.width, map->style->track.color); |
points, map->style->track.width, map->style->track.color); |
2006 |
|
|
2007 |
canvas_points_free(points); |
canvas_points_free(points); |
2067 |
} |
} |
2068 |
|
|
2069 |
if(lpos) |
if(lpos) |
2070 |
appdata->track.gps_item = canvas_circle_new(appdata->map, CANVAS_GROUP_GPS, |
appdata->track.gps_item = |
2071 |
|
canvas_circle_new(appdata->map->canvas, CANVAS_GROUP_GPS, |
2072 |
lpos->x, lpos->y, appdata->map->style->track.width/2.0, 0, |
lpos->x, lpos->y, appdata->map->style->track.width/2.0, 0, |
2073 |
appdata->map->style->track.gps_color, NO_COLOR); |
appdata->map->style->track.gps_color, NO_COLOR); |
2074 |
} |
} |
2111 |
map->bg.scale.y = (float)(bounds->max.y - bounds->min.y)/ |
map->bg.scale.y = (float)(bounds->max.y - bounds->min.y)/ |
2112 |
(float)gdk_pixbuf_get_height(map->bg.pix); |
(float)gdk_pixbuf_get_height(map->bg.pix); |
2113 |
|
|
2114 |
map->bg.item = canvas_image_new(map, CANVAS_GROUP_BG, map->bg.pix, |
map->bg.item = canvas_image_new(map->canvas, CANVAS_GROUP_BG, map->bg.pix, |
2115 |
bounds->min.x, bounds->min.y, map->bg.scale.x, map->bg.scale.y); |
bounds->min.x, bounds->min.y, map->bg.scale.x, map->bg.scale.y); |
2116 |
|
|
2117 |
canvas_item_destroy_connect(map->bg.item, |
canvas_item_destroy_connect(map->bg.item, |