Changed map_selection data structure for more flexibility in viewport setup
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 6 Dec 2007 21:41:22 +0000 (21:41 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 6 Dec 2007 21:41:22 +0000 (21:41 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@619 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/data/binfile/binfile.c
navit/src/data/garmin/garmin.c
navit/src/data/mg/block.c
navit/src/data/mg/poly.c
navit/src/data/mg/town.c
navit/src/data/textfile/textfile.c
navit/src/graphics.c
navit/src/map.h
navit/src/navit.c
navit/src/point.h
navit/src/route.c

index c208f12..c8e2826 100644 (file)
@@ -259,7 +259,7 @@ selection_contains(struct map_selection *sel, struct coord_rect *r)
        if (! sel)
                return 1;
        while (sel) {
-               if (coord_rect_overlap(r, &sel->rect))
+               if (coord_rect_overlap(r, &sel->u.c_rect))
                        return 1;
                sel=sel->next;
        }
index ab87e71..7fad256 100644 (file)
@@ -549,10 +549,10 @@ garmin_get_selection(struct map_rect_priv *map, struct map_selection *sel)
                flags = GO_GET_SORTED;
 
        if (sel) {
-               r.lulat = sel->rect.lu.y;
-               r.lulong = sel->rect.lu.x;
-               r.rllat = sel->rect.rl.y;
-               r.rllong = sel->rect.rl.x;
+               r.lulat = sel->u.c_rect.lu.y;
+               r.lulong = sel->u.c_rect.lu.x;
+               r.rllat = sel->u.c_rect.rl.y;
+               r.rllong = sel->u.c_rect.rl.x;
                level = get_level(sel);
 //             level = nl2gl[level].g;
                dlog(2, "Looking level=%d for %f %f %f %f\n",
index 75b3892..08e9410 100644 (file)
@@ -131,7 +131,7 @@ block_init(struct map_rect_priv *mr)
                mr->b.bt.p=NULL;
                mr->b.bt.block_count=0;
        }
-       if (mr->cur_sel && !coord_rect_overlap(&mr->cur_sel->rect, &mr->b.b_rect)) 
+       if (mr->cur_sel && !coord_rect_overlap(&mr->cur_sel->u.c_rect, &mr->b.b_rect)) 
                return 0;
        return block_next(mr);
 }
@@ -160,7 +160,7 @@ block_next_lin(struct map_rect_priv *mr)
                        dbg(1,"empty blocks\n");
                        return 0;
                }
-               if (!mr->cur_sel || coord_rect_overlap(&mr->cur_sel->rect, &mr->b.b->r)) {
+               if (!mr->cur_sel || coord_rect_overlap(&mr->cur_sel->u.c_rect, &mr->b.b->r)) {
                        block_active_count++;
                        block_active_mem+=mr->b.b->blocks*512-sizeof(struct block *);
                        dbg(1,"block ok\n");
@@ -223,7 +223,7 @@ block_next(struct map_rect_priv *mr)
                        mr->b.b=NULL;
                        if (blk_num != -1) {
                                block_mem+=8;
-                               if (coord_rect_overlap(&mr->cur_sel->rect, &bt->r_curr)) {
+                               if (coord_rect_overlap(&mr->cur_sel->u.c_rect, &bt->r_curr)) {
                                        mr->b.b=block_get_byid(mr->file, blk_num, &mr->b.p);
                                        mr->b.block_num=blk_num;
                                        g_assert(mr->b.b != NULL);
index a23cdde..b51cbe8 100644 (file)
@@ -112,7 +112,7 @@ poly_get(struct map_rect_priv *mr, struct poly_priv *poly, struct item *item)
                        poly->poly_num++;
                        r.lu=poly->c[0];
                        r.rl=poly->c[1];
-                       if (mr->cur_sel && (poly->order > mr->cur_sel->order[layer_poly]*3 || !coord_rect_overlap(&mr->cur_sel->rect, &r))) {
+                       if (mr->cur_sel && (poly->order > mr->cur_sel->order[layer_poly]*3 || !coord_rect_overlap(&mr->cur_sel->u.c_rect, &r))) {
                                poly->subpoly_num_all+=poly->polys;
                                mr->b.p=poly->poly_next;
                                continue;
index fbcfcff..c7bec31 100644 (file)
@@ -130,7 +130,7 @@ town_get(struct map_rect_priv *mr, struct town_priv *twn, struct item *item)
                twn->cidx=0;
                twn->aidx=0;
                twn->attr_next=attr_label;
-               if (! mr->cur_sel || (twn->order <= limit[mr->cur_sel->order[layer_town]] && coord_rect_contains(&mr->cur_sel->rect,&twn->c))) {
+               if (! mr->cur_sel || (twn->order <= limit[mr->cur_sel->order[layer_town]] && coord_rect_contains(&mr->cur_sel->u.c_rect,&twn->c))) {
                        switch(twn->type) {
                        case 1:
                                size=twn->size;
index 1cb3058..397885e 100644 (file)
@@ -10,7 +10,6 @@
 #include "maptype.h"
 #include "item.h"
 #include "attr.h"
-#include "coord.h"
 #include "transform.h"
 #include "file.h"
 
index bec12e2..760163f 100644 (file)
@@ -464,7 +464,7 @@ do_draw_map(struct displaylist *displaylist, struct transformation *t, struct ma
 
        pro=map_projection(m);
        conv=map_requires_conversion(m);
-       transform_rect(t, pro, &sel->rect);
+       transform_rect(t, pro, &sel->u.c_rect);
        if (route_selection)
                mr=map_rect_new(m, route_selection);
        else
index 31566ad..7d1f31a 100644 (file)
@@ -4,11 +4,15 @@
 struct map_priv;
 struct attr;
 #include "coord.h"
+#include "point.h"
 #include "layer.h"
 
 struct map_selection {
        struct map_selection *next;
-       struct coord_rect rect;
+       union {
+               struct coord_rect c_rect;
+               struct point_rect p_rect;
+       } u;
        int order[layer_end];           
 };
 
index 33ca751..21bd63a 100644 (file)
@@ -851,11 +851,11 @@ navit_window_items_open(struct navit *this_, struct navit_window_items *nwi)
        sel.order[layer_poly]=0;
 #endif
        center=transform_center(this_->trans);
-       sel.rect.lu.x=center->x-dist;
-       sel.rect.lu.y=center->y+dist;
-       sel.rect.rl.x=center->x+dist;
-       sel.rect.rl.y=center->y-dist;
-       dbg(2,"0x%x,0x%x - 0x%x,0x%x\n", sel.rect.lu.x, sel.rect.lu.y, sel.rect.rl.x, sel.rect.rl.y);
+       sel.u.c_rect.lu.x=center->x-dist;
+       sel.u.c_rect.lu.y=center->y+dist;
+       sel.u.c_rect.rl.x=center->x+dist;
+       sel.u.c_rect.rl.y=center->y-dist;
+       dbg(2,"0x%x,0x%x - 0x%x,0x%x\n", sel.u.c_rect.lu.x, sel.u.c_rect.lu.y, sel.u.c_rect.rl.x, sel.u.c_rect.rl.y);
        nwi->click=callback_new_2(callback_cast(navit_window_items_click), this_, nwi);
        nwi->win=gui_datawindow_new(this_->gui, nwi->name, nwi->click, NULL);
        h=mapset_open(navit_get_mapset(this_));
@@ -865,7 +865,7 @@ navit_window_items_open(struct navit *this_, struct navit_window_items *nwi)
                dbg(2,"mr=%p\n", mr);
                while ((item=map_rect_get_item(mr))) {
                        if (item_coord_get(item, &c, 1)) {
-                               if (coord_rect_contains(&sel.rect, &c) && g_hash_table_lookup(nwi->hash, &item->type)) {
+                               if (coord_rect_contains(&sel.u.c_rect, &c) && g_hash_table_lookup(nwi->hash, &item->type)) {
                                        if (! item_attr_get(item, attr_label, &attr)) 
                                                attr.u.str="";
                                        idist=transform_distance(map_projection(item->map), center, &c);
@@ -1299,4 +1299,4 @@ navit_toggle_routegraph_display(struct navit *nav)
        navit_draw(nav);
 }
 
-/** @} */
\ No newline at end of file
+/** @} */
index 1ea5fd2..7f75dd1 100644 (file)
@@ -6,4 +6,8 @@ struct point {
        int y;
 };
 
+struct point_rect {
+       struct point lu;
+       struct point rl;
+};
 #endif
index 878c4be..07544bd 100644 (file)
@@ -297,29 +297,29 @@ route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs)
        dy=c1->y-c2->y;
        if (dx < 0) {
                sx=-1;
-               sel->rect.lu.x=c1->x;
-               sel->rect.rl.x=c2->x;
+               sel->u.c_rect.lu.x=c1->x;
+               sel->u.c_rect.rl.x=c2->x;
        } else {
-               sel->rect.lu.x=c2->x;
-               sel->rect.rl.x=c1->x;
+               sel->u.c_rect.lu.x=c2->x;
+               sel->u.c_rect.rl.x=c1->x;
        }
        if (dy < 0) {
                sy=-1;
-               sel->rect.lu.y=c2->y;
-               sel->rect.rl.y=c1->y;
+               sel->u.c_rect.lu.y=c2->y;
+               sel->u.c_rect.rl.y=c1->y;
        } else {
-               sel->rect.lu.y=c1->y;
-               sel->rect.rl.y=c2->y;
+               sel->u.c_rect.lu.y=c1->y;
+               sel->u.c_rect.rl.y=c2->y;
        }
        if (dx*sx > dy*sy) 
                d=dx*sx;
        else
                d=dy*sy;
        m=d*rel/100+abs;        
-       sel->rect.lu.x-=m;
-       sel->rect.rl.x+=m;
-       sel->rect.lu.y+=m;
-       sel->rect.rl.y-=m;
+       sel->u.c_rect.lu.x-=m;
+       sel->u.c_rect.rl.x+=m;
+       sel->u.c_rect.lu.y+=m;
+       sel->u.c_rect.rl.y-=m;
        sel->next=NULL;
        return sel;
 }