43 |
tag = map_item->way->tag; |
tag = map_item->way->tag; |
44 |
break; |
break; |
45 |
|
|
46 |
|
case MAP_TYPE_RELATION: |
47 |
|
item_str = "Relation"; |
48 |
|
id = map_item->relation->id; |
49 |
|
tag = map_item->relation->tag; |
50 |
|
break; |
51 |
|
|
52 |
default: |
default: |
53 |
break; |
break; |
54 |
} |
} |
178 |
new_map_item = g_new0(map_item_t, 1); |
new_map_item = g_new0(map_item_t, 1); |
179 |
memcpy(new_map_item, map_item, sizeof(map_item_t)); |
memcpy(new_map_item, map_item, sizeof(map_item_t)); |
180 |
new_map_item->highlight = TRUE; |
new_map_item->highlight = TRUE; |
181 |
map_hl_circle_new(map, CANVAS_GROUP_NODES_HL, new_map_item, |
map_hl_circle_new(map, CANVAS_GROUP_NODES_IHL, new_map_item, |
182 |
x, y, map->style->node.radius, |
x, y, map->style->node.radius, |
183 |
map->style->highlight.node_color); |
map->style->highlight.node_color); |
184 |
} |
} |
240 |
points->coords[2*2+0] = center.x - diff.y - diff.x; |
points->coords[2*2+0] = center.x - diff.y - diff.x; |
241 |
points->coords[2*2+1] = center.y + diff.x - diff.y; |
points->coords[2*2+1] = center.y + diff.x - diff.y; |
242 |
|
|
243 |
map_hl_polygon_new(map, CANVAS_GROUP_NODES_HL, new_map_item, |
map_hl_polygon_new(map, CANVAS_GROUP_WAYS_DIR, new_map_item, |
244 |
points, map->style->highlight.arrow_color); |
points, map->style->highlight.arrow_color); |
245 |
|
|
246 |
canvas_points_free(points); |
canvas_points_free(points); |
258 |
gint x = node_chain->node->lpos.x; |
gint x = node_chain->node->lpos.x; |
259 |
gint y = node_chain->node->lpos.y; |
gint y = node_chain->node->lpos.y; |
260 |
|
|
261 |
map_hl_circle_new(map, CANVAS_GROUP_NODES_HL, new_map_item, |
map_hl_circle_new(map, CANVAS_GROUP_NODES_IHL, new_map_item, |
262 |
x, y, map->style->node.radius, |
x, y, map->style->node.radius, |
263 |
map->style->highlight.node_color); |
map->style->highlight.node_color); |
264 |
} |
} |
296 |
} |
} |
297 |
} |
} |
298 |
|
|
299 |
|
void map_relation_select(appdata_t *appdata, relation_t *relation) { |
300 |
|
map_t *map = appdata->map; |
301 |
|
|
302 |
|
printf("highlighting relation %ld\n", relation->id); |
303 |
|
|
304 |
|
g_assert(!map->highlight); |
305 |
|
map_highlight_t **hl = &map->highlight; |
306 |
|
|
307 |
|
map_item_t *map_item = &map->selected; |
308 |
|
map_item->type = MAP_TYPE_RELATION; |
309 |
|
map_item->relation = relation; |
310 |
|
map_item->highlight = FALSE; |
311 |
|
map_item->item = NULL; |
312 |
|
|
313 |
|
map_statusbar(map, map_item); |
314 |
|
icon_bar_map_item_selected(appdata, map_item, TRUE); |
315 |
|
|
316 |
|
/* process all members */ |
317 |
|
member_t *member = relation->member; |
318 |
|
while(member) { |
319 |
|
canvas_item_t *item = NULL; |
320 |
|
|
321 |
|
switch(member->type) { |
322 |
|
|
323 |
|
case NODE: { |
324 |
|
node_t *node = member->node; |
325 |
|
printf(" -> node %ld\n", node->id); |
326 |
|
|
327 |
|
item = canvas_circle_new(map->canvas, CANVAS_GROUP_NODES_HL, |
328 |
|
node->lpos.x, node->lpos.y, |
329 |
|
map->style->highlight.width + map->style->node.radius, |
330 |
|
0, map->style->highlight.color, NO_COLOR); |
331 |
|
} break; |
332 |
|
|
333 |
|
case WAY: { |
334 |
|
way_t *way = member->way; |
335 |
|
/* a way needs at least 2 points to be drawn */ |
336 |
|
guint nodes = osm_way_number_of_nodes(way); |
337 |
|
if(nodes > 1) { |
338 |
|
|
339 |
|
/* allocate space for nodes */ |
340 |
|
canvas_points_t *points = canvas_points_new(nodes); |
341 |
|
|
342 |
|
int node = 0; |
343 |
|
node_chain_t *node_chain = way->node_chain; |
344 |
|
while(node_chain) { |
345 |
|
canvas_point_set_pos(points, node++, &node_chain->node->lpos); |
346 |
|
node_chain = node_chain->next; |
347 |
|
} |
348 |
|
|
349 |
|
if(way->draw.flags & OSM_DRAW_FLAG_AREA) |
350 |
|
item = canvas_polygon_new(map->canvas, CANVAS_GROUP_WAYS_HL, points, 0, 0, |
351 |
|
map->style->highlight.color); |
352 |
|
else |
353 |
|
item = canvas_polyline_new(map->canvas, CANVAS_GROUP_WAYS_HL, points, |
354 |
|
(way->draw.flags & OSM_DRAW_FLAG_BG)? |
355 |
|
2*map->style->highlight.width + way->draw.bg.width: |
356 |
|
2*map->style->highlight.width + way->draw.width, |
357 |
|
map->style->highlight.color); |
358 |
|
|
359 |
|
canvas_points_free(points); |
360 |
|
} } break; |
361 |
|
|
362 |
|
default: |
363 |
|
break; |
364 |
|
} |
365 |
|
|
366 |
|
/* attach item to item chain */ |
367 |
|
if(item) { |
368 |
|
*hl = g_new0(map_highlight_t, 1); |
369 |
|
(*hl)->item = item; |
370 |
|
hl = &(*hl)->next; |
371 |
|
} |
372 |
|
|
373 |
|
member = member->next; |
374 |
|
} |
375 |
|
} |
376 |
|
|
377 |
static void map_item_select(appdata_t *appdata, map_item_t *map_item) { |
static void map_item_select(appdata_t *appdata, map_item_t *map_item) { |
378 |
switch(map_item->type) { |
switch(map_item->type) { |
379 |
case MAP_TYPE_NODE: |
case MAP_TYPE_NODE: |
539 |
|
|
540 |
canvas_item_set_zoom_max(map_item->item, way->draw.zoom_max); |
canvas_item_set_zoom_max(map_item->item, way->draw.zoom_max); |
541 |
|
|
542 |
|
/* a ways outline itself is never dashed */ |
543 |
if (group != CANVAS_GROUP_WAYS_OL) |
if (group != CANVAS_GROUP_WAYS_OL) |
544 |
if (way->draw.dashed) |
if (way->draw.dashed) |
545 |
canvas_item_set_dashed(map_item->item, width, way->draw.dash_length); |
canvas_item_set_dashed(map_item->item, width, way->draw.dash_length); |
591 |
map_way_new(map, CANVAS_GROUP_POLYGONS, way, points, |
map_way_new(map, CANVAS_GROUP_POLYGONS, way, points, |
592 |
way->draw.width, way->draw.color, way->draw.area.color); |
way->draw.width, way->draw.color, way->draw.area.color); |
593 |
} else { |
} else { |
|
map_way_new(map, CANVAS_GROUP_WAYS, way, points, |
|
|
way->draw.width, way->draw.color, NO_COLOR); |
|
594 |
|
|
595 |
if(way->draw.flags & OSM_DRAW_FLAG_BG) |
if(way->draw.flags & OSM_DRAW_FLAG_BG) { |
596 |
|
map_way_new(map, CANVAS_GROUP_WAYS_INT, way, points, |
597 |
|
way->draw.width, way->draw.color, NO_COLOR); |
598 |
|
|
599 |
map_way_new(map, CANVAS_GROUP_WAYS_OL, way, points, |
map_way_new(map, CANVAS_GROUP_WAYS_OL, way, points, |
600 |
way->draw.bg.width, way->draw.bg.color, NO_COLOR); |
way->draw.bg.width, way->draw.bg.color, NO_COLOR); |
601 |
|
|
602 |
|
} else |
603 |
|
map_way_new(map, CANVAS_GROUP_WAYS, way, points, |
604 |
|
way->draw.width, way->draw.color, NO_COLOR); |
605 |
} |
} |
606 |
canvas_points_free(points); |
canvas_points_free(points); |
607 |
} |
} |
1642 |
|
|
1643 |
case MAP_ACTION_WAY_NODE_ADD: |
case MAP_ACTION_WAY_NODE_ADD: |
1644 |
map_hl_cursor_clear(map); |
map_hl_cursor_clear(map); |
1645 |
map_item_t *item = map_real_item_at(map, x, y); |
map_item_t *item = map_item_at(map, x, y); |
1646 |
if(item) map_edit_way_node_add_highlight(map, item, x, y); |
if(item) map_edit_way_node_add_highlight(map, item, x, y); |
1647 |
break; |
break; |
1648 |
|
|
1649 |
case MAP_ACTION_WAY_CUT: |
case MAP_ACTION_WAY_CUT: |
1650 |
map_hl_cursor_clear(map); |
map_hl_cursor_clear(map); |
1651 |
item = map_real_item_at(map, x, y); |
item = map_item_at(map, x, y); |
1652 |
if(item) map_edit_way_cut_highlight(map, item, x, y); |
if(item) map_edit_way_cut_highlight(map, item, x, y); |
1653 |
break; |
break; |
1654 |
|
|
1827 |
map_item->way->flags &= ~clr; |
map_item->way->flags &= ~clr; |
1828 |
break; |
break; |
1829 |
|
|
1830 |
|
case MAP_TYPE_RELATION: |
1831 |
|
map_item->relation->flags |= set; |
1832 |
|
map_item->relation->flags &= ~clr; |
1833 |
|
break; |
1834 |
|
|
1835 |
default: |
default: |
1836 |
g_assert(0); |
g_assert(0); |
1837 |
break; |
break; |
2251 |
|
|
2252 |
gtk_widget_set_sensitive(appdata->menu_item_map_show_all, FALSE); |
gtk_widget_set_sensitive(appdata->menu_item_map_show_all, FALSE); |
2253 |
} |
} |
2254 |
|
|
2255 |
// vim:et:ts=8:sw=2:sts=2:ai |
// vim:et:ts=8:sw=2:sts=2:ai |