diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-02-06 10:52:01 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-02-06 10:52:01 +0000 |
commit | 3f7c80c2a5159221581302a62f84e9059c9e4da9 (patch) | |
tree | 0ec24dc2bb855bbb83ebe46eb5bbce7fc30d65e7 /navit | |
parent | 38a368be52c3f895b6d7bb9c916bedd1f843f527 (diff) | |
download | navit-3f7c80c2a5159221581302a62f84e9059c9e4da9.tar.gz |
Fix:Core:Various improvements
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2018 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r-- | navit/Makefile.am | 1 | ||||
-rw-r--r-- | navit/binding/python/navit.c | 2 | ||||
-rw-r--r-- | navit/graphics.c | 4 | ||||
-rw-r--r-- | navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp | 1 | ||||
-rw-r--r-- | navit/gui/internal/gui_internal.c | 6 | ||||
-rw-r--r-- | navit/navigation.c | 4 | ||||
-rw-r--r-- | navit/navit.c | 101 | ||||
-rw-r--r-- | navit/navit.h | 4 | ||||
-rw-r--r-- | navit/osd/core/osd_core.c | 5 | ||||
-rw-r--r-- | navit/start.c | 2 |
10 files changed, 88 insertions, 42 deletions
diff --git a/navit/Makefile.am b/navit/Makefile.am index 5139bafc0..2c8608797 100644 --- a/navit/Makefile.am +++ b/navit/Makefile.am @@ -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; \ diff --git a/navit/binding/python/navit.c b/navit/binding/python/navit.c index 17f6ecf68..e83619b7b 100644 --- a/navit/binding/python/navit.c +++ b/navit/binding/python/navit.c @@ -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; } diff --git a/navit/graphics.c b/navit/graphics.c index d265214f6..e0130f3ca 100644 --- a/navit/graphics.c +++ b/navit/graphics.c @@ -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 diff --git a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp index 59e2e2820..472f65851 100644 --- a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp +++ b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp @@ -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); } diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c index 21303036e..6c070b915 100644 --- a/navit/gui/internal/gui_internal.c +++ b/navit/gui/internal/gui_internal.c @@ -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); } diff --git a/navit/navigation.c b/navit/navigation.c index e32408957..3e7278557 100644 --- a/navit/navigation.c +++ b/navit/navigation.c @@ -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 { diff --git a/navit/navit.c b/navit/navit.c index 93bf59edb..41d59851d 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -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) diff --git a/navit/navit.h b/navit/navit.h index 10e7e4796..dcd212b9a 100644 --- a/navit/navit.h +++ b/navit/navit.h @@ -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); diff --git a/navit/osd/core/osd_core.c b/navit/osd/core/osd_core.c index 4e1c5bd34..557400220 100644 --- a/navit/osd/core/osd_core.c +++ b/navit/osd/core/osd_core.c @@ -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; diff --git a/navit/start.c b/navit/start.c index 0d607ce80..cc9d7d0d1 100644 --- a/navit/start.c +++ b/navit/start.c @@ -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) |