moving the map works different now..

master
steffen 12 years ago
parent cc7d2dd753
commit f844e7e712

@ -1,6 +1,9 @@
Version 0.0.2: name changed to spOSMroute, since on there had been another Version 0.0.2: name changed to spOSMroute, since on there had been another
OSMroute already. OSMroute already.
============================================================================= =============================================================================
(2013-08-01):
- moving around the map works better.
(2013-07-23): (2013-07-23):
- added map_way_append_to_hash and map_area_append_to_hash to speedup - added map_way_append_to_hash and map_area_append_to_hash to speedup
map_hash_realloc, which took most almost 30% of all time. map_hash_realloc, which took most almost 30% of all time.

@ -37,7 +37,8 @@
iPoint mousepos; iPoint mousepos;
int mousebtn; int mousebtn;
time_t mousebtnpresstime; time_t mousebtnpresstime;
iPoint mousebtnpresspos = {0 , 0}; iPoint mousebtnpresspos = {0.0, 0.0};
struct map_pos mousebtnpressgpos = {0, 0};
int mousebtnpresslongtime = 0; int mousebtnpresslongtime = 0;
unsigned long long int mouse_over_way_id = 0; unsigned long long int mouse_over_way_id = 0;
unsigned short int mouse_over_way_sid = 0; unsigned short int mouse_over_way_sid = 0;
@ -51,8 +52,24 @@ char mouse_over_way_name[MAP_W_NAMELEN] = "\0";
* if btn == -1 mean no button pressed or selected * if btn == -1 mean no button pressed or selected
*/ */
void draw_mousemove (int x, int y, int btn) { void draw_mousemove (int x, int y, int btn) {
float lon, lat, lonold, latold;
mousepos.x = x; mousepos.x = x;
mousepos.y = y; mousepos.y = y;
if (mousebtn) {
latold = -map_km2lat(((float)(mousebtnpresspos.y-gfx_screensize.y/2)) * view_scale);
lonold = map_km2lon(((float)(mousebtnpresspos.x-gfx_screensize.x/2)) * view_scale, view_lat + lat);
lat = -map_km2lat(((float)(y-gfx_screensize.y/2)) * view_scale);
lon = map_km2lon(((float)(x-gfx_screensize.x/2)) * view_scale, view_lat + lat);
lat = lat - latold;
lon = lon - lonold;
view_lat = mousebtnpressgpos.lat - lat;
view_lon = mousebtnpressgpos.lon - lon;
draw_del_flag (DRAW_GPSFOLLOW);
}
draw (); draw ();
}; };
@ -61,13 +78,16 @@ void draw_mousebtndown (int x, int y, int btn) {
mousebtnpresstime = time (NULL); mousebtnpresstime = time (NULL);
mousebtnpresspos.x = x; mousebtnpresspos.x = x;
mousebtnpresspos.y = y; mousebtnpresspos.y = y;
mousebtnpressgpos.lon = view_lon;
mousebtnpressgpos.lat = view_lat;
mousebtn = btn; mousebtn = btn;
mousebtnpresslongtime = 0; mousebtnpresslongtime = 0;
draw (); draw ();
}; };
void draw_mousebtnup (int x, int y, int btn) { void draw_mousebtnup (int x, int y, int btn)
{
time_t t = time(NULL); time_t t = time(NULL);
float lon, lat; float lon, lat;
@ -75,33 +95,41 @@ void draw_mousebtnup (int x, int y, int btn) {
mousebtn = 0; mousebtn = 0;
/* check for debugging routeing problems */ /* check for debugging routeing problems */
if (route && y > gfx_screensize.y-32 && y < gfx_screensize.y && x > 0 && x < 100 ) { if (route && y > gfx_screensize.y-32 && y < gfx_screensize.y && x > 0 && x < 100 )
{
view_lon = route->closest_lon; view_lon = route->closest_lon;
view_lat = route->closest_lat; view_lat = route->closest_lat;
draw_del_flag (DRAW_GPSFOLLOW); draw_del_flag (DRAW_GPSFOLLOW);
} }
else { else
{
lat = -map_km2lat(((float)(y-gfx_screensize.y/2)) * view_scale); lat = -map_km2lat(((float)(y-gfx_screensize.y/2)) * view_scale);
lon = map_km2lon(((float)(x-gfx_screensize.x/2)) * view_scale, view_lat + lat); lon = map_km2lon(((float)(x-gfx_screensize.x/2)) * view_scale, view_lat + lat);
if (t - mousebtnpresstime <= 1) { /* short time button pressing */
/* short time button pressing */ if (t - mousebtnpresstime <= 1)
if (btn == 1) { {
view_lat = view_lat + lat; /* check for movement? */
view_lon = view_lon + lon; int dx = abs (mousebtnpresspos.x-x)*100/gfx_screensize.x;
draw_del_flag (DRAW_GPSFOLLOW); int dy = abs (mousebtnpresspos.y-y)*100/gfx_screensize.y;
if (dx < 10 && dy < 10)
{
if (select_enabled)
{
select_enabled = 0;
}
else
{
select_enabled = 1;
select_pos.lat = view_lat + lat;
select_pos.lon = view_lon + lon;
}
} }
} }
else { else
{
/* long time button pressed */ /* long time button pressed */
if (select_enabled) {
select_enabled = 0;
}
else {
select_enabled = 1;
select_pos.lat = view_lat + lat;
select_pos.lon = view_lon + lon;
}
} }
} }
@ -109,10 +137,12 @@ void draw_mousebtnup (int x, int y, int btn) {
}; };
void draw_mouseloop () { void draw_mouseloop ()
{
time_t t = time(NULL); time_t t = time(NULL);
if (mousebtn && t - mousebtnpresstime > 1) { if (mousebtn && t - mousebtnpresstime > 1)
{
mousebtnpresslongtime = 1; mousebtnpresslongtime = 1;
draw (); draw ();
} }

@ -1,4 +1,4 @@
/* $Id: gui.c,v 1.24 2013/06/18 22:24:20 steffen Exp $ */ /* $Id: gui.c,v 1.25 2013/08/01 23:27:38 steffen Exp $ */
/*************************************************************************** /***************************************************************************
* gui.c * gui.c
* *
@ -184,7 +184,7 @@ int gui_event (GUIEvent event) {
draw_mousebtndown (event.scr_mpos.x, event.scr_mpos.y, event.mousebtn); draw_mousebtndown (event.scr_mpos.x, event.scr_mpos.y, event.mousebtn);
break; break;
case (EGUI_MOUSEMOVE): case (EGUI_MOUSEMOVE):
draw_mousemove (event.scr_mpos.x, event.scr_mpos.y, 0); draw_mousemove (event.scr_mpos.x, event.scr_mpos.y, event.mousebtn);
break; break;
default: default:
break; break;

@ -3,7 +3,7 @@ include ../Makefile.rules
OBJBASE = favorites.o main.o OBJBASE = favorites.o main.o
ifeq "$(GTKVERSION)" "1" ifeq "$(GTKVERSION)" "1"
GTK = linux_gps.o gps.o routing.o gui_selectdir.o gui_config.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o GTK = linux_gps.o gps.o routing.o gui_selectdir.o gui_selectfile.o gui_config.o gui_buttons.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o
endif endif
ifeq "$(NCURSESVERSION)" "1" ifeq "$(NCURSESVERSION)" "1"
@ -11,15 +11,15 @@ CURSES = ncurses_main.o
endif endif
ifeq "$(WINVERSION)" "1" ifeq "$(WINVERSION)" "1"
WIN = gps.o routing.o gui_buttons.o gui_config.o gui_selectdir.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o WIN = gps.o routing.o gui_buttons.o gui_config.o gui_selectdir.o gui_selectfile.o gui_favorites.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o
endif endif
ifeq "$(WINCEVERSION)" "1" ifeq "$(WINCEVERSION)" "1"
WIN = gps.o routing.o gui_buttons.o gui_config.o gui_favorites.o gui_selectdir.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o WIN = gps.o routing.o gui_buttons.o gui_config.o gui_favorites.o gui_selectdir.o gui_selectfile.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o
endif endif
ifeq "$(SDLGLVERSION)" "1" ifeq "$(SDLGLVERSION)" "1"
SDLGL = linux_gps.o gps.o routing.o gui_config.o gui_buttons.o gui_favorites.o gui_selectdir.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o SDLGL = linux_gps.o gps.o routing.o gui_config.o gui_buttons.o gui_favorites.o gui_selectdir.o gui_selectfile.o gui_mainmenu.o gui_search.o guiw_gpsfile.o wnd_routing.o
endif endif

@ -70,6 +70,7 @@ char *gpscfg_dev_ptr[8] = {
NULL NULL
}; };
void gui_config_show () { void gui_config_show () {
if (wcfg.screen == NULL) gui_window_new (&wcfg, 220, 280, _("Config")); if (wcfg.screen == NULL) gui_window_new (&wcfg, 220, 280, _("Config"));
wcfg.screen_changed = 1; wcfg.screen_changed = 1;
@ -143,6 +144,7 @@ void gui_config_checkbox_changed () {
else DELFLAG(gpsflags, GPSF_LOG); else DELFLAG(gpsflags, GPSF_LOG);
}; };
void gui_config_gpslist (int nr) { void gui_config_gpslist (int nr) {
d_printf ("select nr:%d", nr); d_printf ("select nr:%d", nr);
if (nr >= 0 && nr < 8) if (nr >= 0 && nr < 8)
@ -161,6 +163,15 @@ void gui_config_seldir () {
void gui_config_gpsfile () { void gui_config_gpsfile () {
char *new_file = NULL;
char text[LEN_FILENAME];
d_printf ("select gps file..."); d_printf ("select gps file...");
new_file = gui_sfile_show ("");
if (new_file != NULL) {
snprintf (text, LEN_FILENAME, "file:%s", new_file);
gui_entry_settext (gps_device, text);
d_printf ("gpsdevice:%s", GUI_ENTRY_T(gps_device)->text);
}
}; };

@ -139,8 +139,13 @@ void gfx_draw_line (struct image *dimg, int x1, int y1, int x2, int y2, struct l
/* polygon mit runden ecken....? bei width > 1 */ /* polygon mit runden ecken....? bei width > 1 */
gfx_fbo_switch (dimg); gfx_fbo_switch (dimg);
if (style.width < 1.0) style.width = 1.0; if (style.width < 1.0) style.width = 1.0;
glLineWidth (style.width);
glColor4f(style.c.c.r, style.c.c.g, style.c.c.b, 1.0); glColor4f(style.c.c.r, style.c.c.g, style.c.c.b, 1.0);
glPointSize(style.width*0.5);
glBegin (GL_POINTS);
glVertex2i (x1, y1);
glVertex2i (x2, y2);
glEnd ();
glLineWidth (style.width);
glBegin (GL_LINES); glBegin (GL_LINES);
glVertex2i (x1, y1); glVertex2i (x1, y1);
glVertex2i (x2, y2); glVertex2i (x2, y2);

Loading…
Cancel
Save