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 |
} |
} |
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: |
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 |