Fix:Core:Various improvements
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 6 Feb 2009 10:52:01 +0000 (10:52 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 6 Feb 2009 10:52:01 +0000 (10:52 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2018 ffa7fe5e-494d-0410-b361-a75ebd5db220

configure.in
navit/Makefile.am
navit/binding/python/navit.c
navit/graphics.c
navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
navit/gui/internal/gui_internal.c
navit/navigation.c
navit/navit.c
navit/navit.h
navit/osd/core/osd_core.c
navit/start.c

index b19bb0b..55cf91f 100644 (file)
@@ -85,6 +85,9 @@ AC_SUBST(cross_compiling)
 AC_SUBST(CC_FOR_BUILD)
 AC_SUBST(CCLD_FOR_BUILD)
 
+AC_ARG_ENABLE(variant, [  --enable-variant=something          set variant], VARIANT=$enableval)
+AC_SUBST(variant)
+
 AC_ARG_ENABLE(avoid-unaligned, [  --enable-avoid-unaligned          avoid unaligned accesses], AVOID_UNALIGNED=$enableval, AVOID_UNALIGNED=no)
 test x"${AVOID_UNALIGNED}" = xyes && AC_DEFINE(AVOID_UNALIGNED,[],Define to avoid unaligned access)
 
index 5139baf..2c86087 100644 (file)
@@ -73,6 +73,7 @@ if SOURCE_MODE_SVN
 else
        echo "#define SVN_VERSION \"@SOURCE_MODE@\"" >>version.h.tmp
 endif
+       echo "#define VARIANT \"@VARIANT@\"" >>version.h.tmp
        if ! diff version.h.tmp version.h >/dev/null 2>/dev/null; \
        then \
                mv version.h.tmp version.h; \
index 17f6ecf..e83619b 100644 (file)
@@ -78,7 +78,7 @@ navit_zoom_to_route_py(navitObject *self, PyObject *args)
 {
        if (!PyArg_ParseTuple(args, ""))
                return NULL;
-       navit_zoom_to_route(self->navit);
+       navit_zoom_to_route(self->navit,0);
        Py_RETURN_NONE;
 }
 
index d265214..e0130f3 100644 (file)
@@ -1280,8 +1280,8 @@ graphics_draw_polygon_clipped(struct graphics *gra, struct graphics_gc *gc, stru
 {
        struct point_rect r=gra->r;
        struct point *pout,*p,*s,pi;
-       struct point p1[count_in+1];
-       struct point p2[count_in+1];
+       struct point p1[count_in*8+1];
+       struct point p2[count_in*8+1];
        int count_out,edge=3;
        int i;
 #if 0
index 59e2e28..472f658 100644 (file)
@@ -853,7 +853,6 @@ static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
                                overlay_rect(gr->parent, gr, 0, &r);    
                                qt_qpainter_draw(gr->parent, &r, 0);
                        } else {
-                               dbg(0,"pixmap %p =%dx%d\n", gr->widget->pixmap, gr->widget->pixmap->width(), gr->widget->pixmap->height());
                                r.setRect(0, 0, gr->widget->pixmap->width(), gr->widget->pixmap->height());
                                qt_qpainter_draw(gr, &r, 0);
                        }
index 2130303..6c070b9 100644 (file)
@@ -1548,8 +1548,12 @@ gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void
        dbg(0,"c=%d:0x%x,0x%x\n", w->c.pro, w->c.x, w->c.y);
        navit_set_destination(this->nav, &w->c, w->name);
        if (this->flags & 512) {
+               struct attr follow;
+               follow.type=attr_follow;
+               follow.u.num=180;
                navit_set_attr(this->nav, &this->osd_configuration);
-               navit_zoom_to_route(this->nav);
+               navit_set_attr(this->nav, &follow);
+               navit_zoom_to_route(this->nav, 0);
        }       
        gui_internal_prune_menu(this, NULL);
 }
index e324089..3e72785 100644 (file)
@@ -1135,7 +1135,7 @@ command_new(struct navigation *this_, struct navigation_itm *itm, int delta)
        dbg(1,"enter this_=%p itm=%p delta=%d\n", this_, itm, delta);
        ret->delta=delta;
        ret->itm=itm;
-       if (itm && itm->prev && !(itm->flags & AF_ROUNDABOUT) && (itm->prev->flags & AF_ROUNDABOUT)) {
+       if (itm && itm->prev && itm->prev->ways && !(itm->flags & AF_ROUNDABOUT) && (itm->prev->flags & AF_ROUNDABOUT)) {
                int len=0;
                int angle;
                int entry_angle;
@@ -1146,7 +1146,7 @@ command_new(struct navigation *this_, struct navigation_itm *itm, int delta)
                        angle=itm2->angle_end;
                        itm2=itm2->prev;
                }
-               if (itm2 && itm2->next && itm2->next->next) {
+               if (itm2 && itm2->next && itm2->next->next && itm2->ways) {
                        itm2=itm2->next->next;
                        entry_angle=angle_median(angle_opposite(itm2->angle_start), itm2->ways->angle2);
                } else {
index 93bf59e..41d5985 100644 (file)
@@ -145,6 +145,9 @@ static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv);
 static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt);
 static int navit_add_vehicle(struct navit *this_, struct vehicle *v);
 static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init);
+static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir);
+static void navit_cmd_zoom_to_route(struct navit *this);
+static void navit_cmd_set_center_cursor(struct navit *this_);
 
 void
 navit_add_mapset(struct navit *this_, struct mapset *ms)
@@ -212,9 +215,10 @@ navit_redraw_route(struct navit *this_, int updated)
        if (updated <= 3)
                return;
        if (this_->vehicle) {
-               if (this_->vehicle->follow == 1)
+               if (this_->vehicle->follow_curr == 1)
                        return;
-               this_->vehicle->follow_curr=this_->vehicle->follow;
+               if (this_->vehicle->follow_curr <= this_->vehicle->follow)
+                       this_->vehicle->follow_curr=this_->vehicle->follow;
        }
        navit_draw(this_);
 }
@@ -266,10 +270,13 @@ navit_popup(void *data)
 }
 
 
-void
+int
 navit_ignore_button(struct navit *this_)
 {
+       if (this_->ignore_button)
+               return 1;
        this_->ignore_button=1;
+       return 0;
 }
 
 void
@@ -553,20 +560,32 @@ navit_zoom_out(struct navit *this_, int factor, struct point *p)
 static int
 navit_cmd_zoom_in(struct navit *this_)
 {
-       navit_zoom_in(this_, 2, NULL);
+       struct point p;
+       if (this_->vehicle && this_->vehicle->follow_curr == 1 && navit_get_cursor_pnt(this_, &p, NULL)) {
+               navit_zoom_in(this_, 2, &p);
+               this_->vehicle->follow_curr=this_->vehicle->follow;
+       } else
+               navit_zoom_in(this_, 2, NULL);
        return 0;
 }
 
 static int
 navit_cmd_zoom_out(struct navit *this_)
 {
-       navit_zoom_out(this_, 2, NULL);
+       struct point p;
+       if (this_->vehicle && this_->vehicle->follow_curr == 1 && navit_get_cursor_pnt(this_, &p, NULL)) {
+               navit_zoom_out(this_, 2, &p);
+               this_->vehicle->follow_curr=this_->vehicle->follow;
+       } else
+               navit_zoom_out(this_, 2, NULL);
        return 0;
 }
 
 static struct command_table commands[] = {
        {"zoom_in",navit_cmd_zoom_in},
        {"zoom_out",navit_cmd_zoom_out},
+       {"zoom_to_route",navit_cmd_zoom_to_route},
+       {"set_center_cursor",navit_cmd_set_center_cursor},
 };
        
 
@@ -1290,27 +1309,27 @@ navit_init(struct navit *this_)
 }
 
 void
-navit_zoom_to_route(struct navit *this_)
+navit_zoom_to_route(struct navit *this_, int orientation)
 {
        struct map *map;
        struct map_rect *mr=NULL;
        struct item *item;
-       struct coord c,*ct;
+       struct coord c;
        struct coord_rect r;
        int count=0,scale=16;
        if (! this_->route)
                return;
-       dbg(0,"enter\n");
+       dbg(1,"enter\n");
        map=route_get_map(this_->route);
-       dbg(0,"map=%p\n",map);
+       dbg(1,"map=%p\n",map);
        if (map)
                mr=map_rect_new(map, NULL);
-       dbg(0,"mr=%p\n",mr);
+       dbg(1,"mr=%p\n",mr);
        if (mr) {
                while ((item=map_rect_get_item(mr))) {
-                       dbg(0,"item=%s\n", item_to_name(item->type));
+                       dbg(1,"item=%s\n", item_to_name(item->type));
                        while (item_coord_get(item, &c, 1)) {
-                               dbg(0,"coord\n");
+                               dbg(1,"coord\n");
                                if (!count) 
                                        r.lu=r.rl=c;
                                else
@@ -1323,17 +1342,18 @@ navit_zoom_to_route(struct navit *this_)
                return;
        c.x=(r.rl.x+r.lu.x)/2;
        c.y=(r.rl.y+r.lu.y)/2;
-       dbg(0,"count=%d\n",count);
-       ct=transform_center(this_->trans);
-       *ct=c;
-       dbg(0,"%x,%x-%x,%x\n", r.rl.x,r.rl.y,r.lu.x,r.lu.y);
+       dbg(1,"count=%d\n",count);
+       if (orientation != -1)
+               transform_set_yaw(this_->trans, orientation);
+       transform_set_center(this_->trans, &c);
+       dbg(1,"%x,%x-%x,%x\n", r.rl.x,r.rl.y,r.lu.x,r.lu.y);
        while (scale < 1<<20) {
                struct point p1,p2;
                transform_set_scale(this_->trans, scale);
                transform_setup_source_rect(this_->trans);
                transform(this_->trans, transform_get_projection(this_->trans), &r.lu, &p1, 1, 0, 0, NULL);
                transform(this_->trans, transform_get_projection(this_->trans), &r.rl, &p2, 1, 0, 0, NULL);
-               dbg(0,"%d,%d-%d,%d\n",p1.x,p1.y,p2.x,p2.y);
+               dbg(1,"%d,%d-%d,%d\n",p1.x,p1.y,p2.x,p2.y);
                if (p1.x < 0 || p2.x < 0 || p1.x > this_->w || p2.x > this_->w ||
                    p1.y < 0 || p2.y < 0 || p1.y > this_->h || p2.y > this_->h)
                        scale*=2;
@@ -1342,7 +1362,13 @@ navit_zoom_to_route(struct navit *this_)
        
        }
        if (this_->ready == 3)
-               navit_draw(this_);
+               navit_draw_async(this_,0);
+}
+
+static void
+navit_cmd_zoom_to_route(struct navit *this)
+{
+       navit_zoom_to_route(this, 0);
 }
 
 /**
@@ -1383,24 +1409,34 @@ navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point
        update_transformation(this_->trans, &po, p, NULL);
 }
 
-static void
-navit_set_center_cursor(struct navit *this_)
+static int
+navit_get_cursor_pnt(struct navit *this_, struct point *p, int *dir)
 {
-       int width, height, dir;
+       int width, height;
        struct navit_vehicle *nv=this_->vehicle;
-       struct point pn;
-       dbg(0,"enter\n");
        transform_get_size(this_->trans, &width, &height);
        if (this_->orientation == -1) {
-               pn.x=50*width/100;
-               pn.y=80*height/100;
-               dir=nv->dir;
+               p->x=50*width/100;
+               p->y=80*height/100;
+               if (dir)
+                       *dir=nv->dir;
        } else {
-               dir=nv->dir-this_->orientation;
-               pn.x=(50 - 30.*sin(M_PI*dir/180.))*width/100;
-               pn.y=(50 + 30.*cos(M_PI*dir/180.))*height/100;
-               dir=this_->orientation;
+               int mdir=nv->dir-this_->orientation;
+               p->x=(50 - 30.*sin(M_PI*mdir/180.))*width/100;
+               p->y=(50 + 30.*cos(M_PI*mdir/180.))*height/100;
+               if (dir)
+                       *dir=this_->orientation;
        }
+       return 1;
+}
+
+static void
+navit_set_center_cursor(struct navit *this_)
+{
+       int dir;
+       struct point pn;
+       struct navit_vehicle *nv=this_->vehicle;
+       navit_get_cursor_pnt(this_, &pn, &dir);
        transform_set_yaw(this_->trans, dir);
        navit_set_center_coord_screen(this_, &nv->coord, &pn);
        navit_autozoom(this_, &nv->coord, nv->speed, 0);
@@ -1408,6 +1444,11 @@ navit_set_center_cursor(struct navit *this_)
                navit_draw_async(this_, 1);
 }
 
+static void
+navit_cmd_set_center_cursor(struct navit *this_)
+{
+       navit_set_center_cursor(this_);
+}
 
 void
 navit_set_center_screen(struct navit *this_, struct point *p)
index 10e7e47..dcd212b 100644 (file)
@@ -54,7 +54,7 @@ void navit_handle_resize(struct navit *this_, int w, int h);
 int navit_get_width(struct navit *this_);
 int navit_check_route(struct navit *this_);
 int navit_get_height(struct navit *this_);
-void navit_ignore_button(struct navit *this_);
+int navit_ignore_button(struct navit *this_);
 void navit_ignore_graphics_events(struct navit *this_, int ignore);
 int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback);
 void navit_handle_motion(struct navit *this_, struct point *p);
@@ -74,7 +74,7 @@ struct navit_window_items *navit_window_items_new(const char *name, int distance
 void navit_window_items_add_item(struct navit_window_items *nwi, enum item_type type);
 void navit_add_window_items(struct navit *this_, struct navit_window_items *nwi);
 void navit_init(struct navit *this_);
-void navit_zoom_to_route(struct navit *this_);
+void navit_zoom_to_route(struct navit *this_, int orientation);
 void navit_set_center(struct navit *this_, struct pcoord *center);
 void navit_set_center_screen(struct navit *this_, struct point *p);
 int navit_set_attr(struct navit *this_, struct attr *attr);
index 4e1c5bd..5574002 100644 (file)
@@ -76,9 +76,10 @@ osd_std_click(struct osd_item *this, struct navit *nav, int pressed, int button,
 {
        struct point bp = this->p;
        wrap_point(&bp, nav);
-       if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + this->w || p->y > bp.y + this->h) && !this->pressed)
+       if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + this->w || p->y > bp.y + this->h || !this->configured) && !this->pressed)
+               return;
+       if (navit_ignore_button(nav))
                return;
-       navit_ignore_button(nav);
        this->pressed = pressed;
        if (pressed) {
                struct attr navit;
index 0d607ce..cc9d7d0 100644 (file)
@@ -42,7 +42,7 @@
 #include <winbase.h>
 #endif
 
-char *version=PACKAGE_VERSION" "SVN_VERSION; 
+char *version=PACKAGE_VERSION" "SVN_VERSION""VARIANT; 
 
 static void
 print_usage(void)