enum projection pro;
int mindist;
struct transformation *trans;
+ enum item_type type;
+ int maxlen;
};
struct displaylist {
}
}
+static int
+limit_count(struct coord *c, int count)
+{
+ int i;
+ for (i = 1 ; i < count ; i++) {
+ if (c[i].x == c[0].x && c[i].y == c[0].y)
+ return i+1;
+ }
+ return count;
+}
+
static void
displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc)
{
- int width[16384];
- int i,count;
- struct point pa[16384];
+ int width[dc->maxlen];
+ int i,count=di->count,mindist=dc->mindist;
+ struct point pa[dc->maxlen];
struct graphics *gra=dc->gra;
struct graphics_gc *gc=dc->gc;
struct element *e=dc->e;
gc->meth.gc_set_foreground(gc->priv, &e->color);
dc->gc=gc;
}
- if (dc->e->type == element_polyline) {
- count=transform(dc->trans, dc->pro, di->c, pa, di->count, dc->mindist, e->u.polyline.width, width);
- }
+ if (item_type_is_area(dc->type) && (dc->e->type == element_polyline || dc->e->type == element_text))
+ count=limit_count(di->c, count);
+ if (dc->type == type_poly_water_tiled)
+ mindist=0;
+ if (dc->e->type == element_polyline)
+ count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, e->u.polyline.width, width);
else
- count=transform(dc->trans, dc->pro, di->c, pa, di->count, dc->mindist, 0, NULL);
+ count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL);
switch (e->type) {
case element_polygon:
#if 0
struct element *e;
GList *es,*types;
GHashTable *h;
- enum item_type type;
- int mindist=0;
+ struct display_context *dc=&display_list->dc;
es=itm->elements;
while (es) {
e=es->data;
- display_list->dc.e=e;
+ dc->e=e;
types=itm->type;
while (types) {
- type=GPOINTER_TO_INT(types->data);
- h=g_hash_table_lookup(display_list->dl, GINT_TO_POINTER(type));
+ dc->type=GPOINTER_TO_INT(types->data);
+ h=g_hash_table_lookup(display_list->dl, GINT_TO_POINTER(dc->type));
if (h) {
- if (type == type_poly_water_tiled) {
- mindist=display_list->dc.mindist;
- display_list->dc.mindist=0;
- }
- g_hash_table_foreach(h, (GHFunc)displayitem_draw, &display_list->dc);
- display_context_free(&display_list->dc);
- if (type == type_poly_water_tiled)
- display_list->dc.mindist=mindist;
+ g_hash_table_foreach(h, (GHFunc)displayitem_draw, dc);
+ display_context_free(dc);
}
types=g_list_next(types);
}
do_draw(struct displaylist *displaylist, int cancel, int flags)
{
struct item *item;
- int count,max=16384,workload=0;
+ int count,max=displaylist->dc.maxlen,workload=0;
struct coord ca[max];
struct attr attr;
count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, displaylist->sel);
if (! count)
continue;
- if (count == max)
- dbg(0,"point count overflow %d\n", count);
+ if (count == max) {
+ dbg(0,"point count overflow %d for %s "ITEM_ID_FMT"\n", count,item_to_name(item->type),ITEM_ID_ARGS(*item));
+ displaylist->dc.maxlen=max*2;
+ }
if (!item_attr_get(item, attr_label, &attr))
attr.u.str=NULL;
if (displaylist->conv && attr.u.str && attr.u.str[0]) {
struct displaylist_handle *ret;
ret=g_new0(struct displaylist_handle, 1);
+ if (!displaylist->dl)
+ return NULL;
ret->hl_head=ret->hl=g_hash_to_list(displaylist->dl);
+ if (!ret->hl) {
+ g_free(ret);
+ return NULL;
+ }
ret->l_head=ret->l=g_hash_to_list_keys(ret->hl->data);
return ret;
struct displayitem * graphics_displaylist_next(struct displaylist_handle *dlh)
{
struct displayitem *ret;
+ if (!dlh)
+ return NULL;
if (! dlh->l) {
dlh->hl=g_list_next(dlh->hl);
if (!dlh->hl)
*/
void graphics_displaylist_close(struct displaylist_handle *dlh)
{
- g_list_free(dlh->hl_head);
- g_list_free(dlh->l_head);
- g_free(dlh);
+ if (dlh) {
+ g_list_free(dlh->hl_head);
+ g_list_free(dlh->l_head);
+ g_free(dlh);
+ }
}
/**
struct displaylist *ret=g_new0(struct displaylist, 1);
ret->dl=g_hash_table_new(NULL,NULL);
+ ret->dc.maxlen=16384;
return ret;
}
return &di->item;
}
+int
+graphics_displayitem_get_coord_count(struct displayitem *di)
+{
+ return di->count;
+}
+
/**
* FIXME
* @param <>
return di->label;
}
+int
+graphics_displayitem_get_displayed(struct displayitem *di)
+{
+ return di->displayed;
+}
+
/**
* FIXME
* @param <>
*/
int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist)
{
- struct point pa[16384];
+ struct point pa[displaylist->dc.maxlen];
int count;
count=transform(displaylist->dc.trans, displaylist->dc.pro, di->c, pa, di->count, 1, 0, NULL);
}
-static enum item_type
-graphics_selection_type(enum item_type type)
-{
- if (type < type_line)
- return type_selected_point;
- if (type < type_area)
- return type_selected_line;
- return type_selected_area;
-
-}
-
-
static void
graphics_process_selection_item(struct displaylist *dl, struct item *item)
{
struct displayitem di,*di_res;
GHashTable *h;
+ int count,max=dl->dc.maxlen;
+ struct coord ca[max];
+ struct attr attr;
+ struct map_rect *mr;
di.item=*item;
di.label=NULL;
if (h) {
di_res=g_hash_table_lookup(h, &di);
if (di_res) {
- di.item.type=graphics_selection_type(di.item.type);
+ di.item.type=(enum item_type)item->priv_data;
display_add(dl, &di.item, di_res->count, di_res->c, NULL);
+ return;
}
}
+ mr=map_rect_new(item->map, NULL);
+ item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ count=item_coord_get(item, ca, item->type < type_line ? 1: max);
+ if (!item_attr_get(item, attr_label, &attr))
+ attr.u.str=NULL;
+ if (dl->conv && attr.u.str && attr.u.str[0]) {
+ char *str=map_convert_string(item->map, attr.u.str);
+ display_add(dl, item, count, ca, str);
+ map_convert_free(str);
+ } else
+ display_add(dl, item, count, ca, attr.u.str);
+ map_rect_destroy(mr);
}
void
-graphics_add_selection(struct graphics *gra, struct item *item, struct displaylist *dl)
+graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
{
struct item *item_dup=g_new(struct item, 1);
*item_dup=*item;
+ item_dup->priv_data=(void *)type;
gra->selection=g_list_append(gra->selection, item_dup);
if (dl)
graphics_process_selection_item(dl, item_dup);
}
void
-graphics_remove_selection(struct graphics *gra, struct item *item, struct displaylist *dl)
+graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
{
GList *curr;
int found;
di.label=NULL;
di.displayed=0;
di.count=0;
- di.item.type=graphics_selection_type(di.item.type);
+ di.item.type=type;
h=g_hash_table_lookup(dl->dl, GINT_TO_POINTER(di.item.type));
if (h)
g_hash_table_remove(h, &di);
void
graphics_clear_selection(struct graphics *gra, struct displaylist *dl)
{
- while (gra->selection)
- graphics_remove_selection(gra, (struct item *)gra->selection->data, dl);
+ while (gra->selection) {
+ struct item *item=(struct item *)gra->selection->data;
+ graphics_remove_selection(gra, item, (enum item_type)item->priv_data,dl);
+ }
}
static void