/[zanavi_public1]/navit/navit/graphics.c
ZANavi

Diff of /navit/navit/graphics.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 34 Revision 40
1/** 1/**
2 * ZANavi, Zoff Android Navigation system. 2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2013 Zoff <zoff@zoff.cc> 3 * Copyright (C) 2011-2014 Zoff <zoff@zoff.cc>
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation. 7 * version 2 as published by the Free Software Foundation.
8 * 8 *
69#include "callback.h" 69#include "callback.h"
70#include "file.h" 70#include "file.h"
71#include "event.h" 71#include "event.h"
72// 72//
73#include "attr.h" 73#include "attr.h"
74#include "track.h"
74#include "navit.h" 75#include "navit.h"
75#include "route.h" 76#include "route.h"
76 77
77#ifdef HAVE_API_ANDROID 78#ifdef HAVE_API_ANDROID
78// nothing todo for android 79// nothing todo for android
82#endif 83#endif
83 84
84static pthread_cond_t uiConditionVariable = PTHREAD_COND_INITIALIZER; 85static pthread_cond_t uiConditionVariable = PTHREAD_COND_INITIALIZER;
85static pthread_mutex_t uiConditionMutex = PTHREAD_MUTEX_INITIALIZER; 86static pthread_mutex_t uiConditionMutex = PTHREAD_MUTEX_INITIALIZER;
86 87
88
89
90
91
92// #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1
93
94
95// --------------- debug function calls ------------------
96// --------------- debug function calls ------------------
97#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
98 #undef return2
99 #define return2 dbg_func(0, global_func_indent_counter, "return(%d)\n", __LINE__);global_func_indent_counter--;return
100
101 #define __F_START__ global_func_indent_counter++;dbg_func(0, global_func_indent_counter, "enter\n");
102 #define __F_END__ dbg_func(0, global_func_indent_counter, "leave\n");global_func_indent_counter--;
103#else
104 #undef return2
105 #define return2 return
106
107 #define __F_START__
108 #define __F_END__
109#endif
110// --------------- debug function calls ------------------
111// --------------- debug function calls ------------------
112
113
114
115
116
117
87//############################################################################################################## 118//##############################################################################################################
88//# Description: 119//# Description:
89//# Comment: 120//# Comment:
90//# Authors: Martin Schaller (04/2008) 121//# Authors: Martin Schaller (04/2008)
91//############################################################################################################## 122//##############################################################################################################
92 123
93// above what "order" level to show only prerendered-map or vector-map 124// above what "order" level to show only prerendered-map or vector-map
94#define ORDER_USE_PRERENDERED_MAP 5 125#define ORDER_USE_PRERENDERED_MAP 5
95#define ORDER_USE_NORMAL_MAP 6 126#define ORDER_USE_NORMAL_MAP 6
127#define ORDER_USE_PRERENDERED_MAP__C 4
128#define ORDER_USE_NORMAL_MAP__C 3
96#define ORDER_USE_BORDERS_MAP 14 129#define ORDER_USE_BORDERS_MAP 14
97 130
98// minimum (line legth * 32) squared (in pixel) to show text label 131// minimum (line legth * 32) squared (in pixel) to show text label
99#define MIN_LINE_LENGTH_FOR_TEXT_2 409600 132#define MIN_LINE_LENGTH_FOR_TEXT_2 409600
100// minimum (line legth * 32) squared (in pixel) to show text label -> for middle segments of streets 133// minimum (line legth * 32) squared (in pixel) to show text label -> for middle segments of streets
315 return NULL; 348 return NULL;
316 } 349 }
317 350
318 // dbg(0, "plugins\n"); 351 // dbg(0, "plugins\n");
319 352
353#ifdef PLUGSSS
320 graphicstype_new = plugin_get_graphics_type(type_attr->u.str); 354 graphicstype_new = plugin_get_graphics_type(type_attr->u.str);
321 if (!graphicstype_new) 355 if (!graphicstype_new)
322 { 356 {
323 return NULL; 357 return NULL;
324 } 358 }
359#endif
325 360
326 // dbg(0, "g 003\n"); 361 // dbg(0, "g 003\n");
327 362
328 this_=g_new0(struct graphics, 1); 363 this_=g_new0(struct graphics, 1);
329 this_->cbl = callback_list_new(); 364 this_->cbl = callback_list_new("graphics_new:this_->cbl");
330 // dbg(0, "g 003.1\n"); 365
366#ifdef PLUGSSS
331 this_->priv = (*graphicstype_new)(parent->u.navit, &this_->meth, attrs, this_->cbl); 367 this_->priv = (*graphicstype_new)(parent->u.navit, &this_->meth, attrs, this_->cbl);
332 // dbg(0, "g 003.2\n"); 368#else
369 this_->priv = graphics_android_new(parent->u.navit, &this_->meth, attrs, this_->cbl);
370#endif
371
333 this_->attrs = attr_list_dup(attrs); 372 this_->attrs = attr_list_dup(attrs);
334 this_->brightness = 0; 373 this_->brightness = 0;
335 this_->contrast = 65536; 374 this_->contrast = 65536;
336 this_->gamma = 65536; 375 this_->gamma = 65536;
337 this_->font_size = 20; 376 this_->font_size = 20;
893//# Comment: 932//# Comment:
894//# Authors: Martin Schaller (04/2008) 933//# Authors: Martin Schaller (04/2008)
895//############################################################################################################## 934//##############################################################################################################
896int graphics_draw_drag(struct graphics *this_, struct point *p) 935int graphics_draw_drag(struct graphics *this_, struct point *p)
897{ 936{
898 ////DBG // dbg(0,"ooo enter ooo\n"); 937__F_START__
899 938
900 if (!this_->meth.draw_drag) 939 if (!this_->meth.draw_drag)
901 { 940 {
902 return 0; 941 return2 0;
903 } 942 }
904 ////DBG // dbg(0,"draw DRAG start ...\n"); 943 ////DBG // dbg(0,"draw DRAG start ...\n");
905 this_->meth.draw_drag(this_->priv, p); 944 this_->meth.draw_drag(this_->priv, p);
906 ////DBG // dbg(0,"draw DRAG end ...\n"); 945 ////DBG // dbg(0,"draw DRAG end ...\n");
907 return 1; 946 return2 1;
947
948__F_END__
949
908} 950}
909 951
910void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc) 952void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc)
911{ 953{
912 ////DBG // dbg(0,"ooo enter ooo\n"); 954 ////DBG // dbg(0,"ooo enter ooo\n");
1801 code2 = clipcode(p2, r); 1843 code2 = clipcode(p2, r);
1802 } 1844 }
1803 return ret; 1845 return ret;
1804} 1846}
1805 1847
1848
1849
1850// --------------- COLORs ---------------
1851static struct color bicycle_blue = { 0x0000,0x0000,0xf9f9,0xffff }; // RR GG BB AA
1852static struct color bicycle_green = { 0x0808,0x8a8a,0x0808,0xffff }; // RR GG BB AA
1853// --------------- COLORs ---------------
1854
1855
1806static void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int step, int poly, int order, int oneway, int dashes, struct color *c) 1856static void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int step, int poly, int order, int oneway, int dashes, struct color *c, int mark_way)
1807{ 1857{
1808#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1809 dbg(0,"+#+:enter\n");
1810#endif
1811 1858
1812 struct point *p = g_alloca(sizeof(struct point) * (count + 1)); 1859 struct point *p = g_alloca(sizeof(struct point) * (count + 1));
1813 struct wpoint p1, p2; 1860 struct wpoint p1, p2;
1814 int i; 1861 int i;
1815 int code; 1862 int code;
1816 int wmax; 1863 int wmax;
1817 int out = 0; 1864 int out = 0;
1818 // const int max_segs = 2000; 1865 // const int max_segs = 2000;
1819 int max_segs = 20; // send max this many segments to java with one single call 1866 int max_segs = 20; // send max this many segments to java with one single call
1820 struct point_rect r = gra->r; 1867 struct point_rect r = gra->r;
1868
1821 1869
1822 if (order < global_order_level_for_fast_draw) 1870 if (order < global_order_level_for_fast_draw)
1823 { 1871 {
1824 max_segs = 100; 1872 max_segs = 100;
1825 } 1873 }
1928 // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 1, order, 0); 1976 // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 1, order, 0);
1929 //} 1977 //}
1930 //else 1978 //else
1931 //{ 1979 //{
1932 // draw as line 1980 // draw as line
1981 if (mark_way == 1)
1982 {
1983 // dbg(0, "CYCLE LANE:001\n");
1984 // mark way with bicycle lanes
1985 gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i] + 4, dashes, &bicycle_green, global_clinedrawing_active, 0);
1986 }
1987 else if (mark_way == 2)
1988 {
1989 // dbg(0, "CYCLE LANE:001\n");
1990 // mark way with bicycle tracks
1991 gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i] + 4, dashes, &bicycle_blue, global_clinedrawing_active, 0);
1992 }
1933 gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i], dashes, c); 1993 gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i], dashes, c, global_clinedrawing_active, 1);
1934 //draw_lines_count_3++; 1994 //draw_lines_count_3++;
1935 //} 1995 //}
1936 1996
1937 // one way arrow 1997 // one way arrow
1938 if ((oneway > 0) && (order > 13)) 1998 if ((oneway > 0) && (order > 13))
1953 // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 0, order, 0); 2013 // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 0, order, 0);
1954 //} 2014 //}
1955 //else 2015 //else
1956 //{ 2016 //{
1957 2017
2018 if (mark_way == 1)
2019 {
2020 // mark way with bicycle lanes
2021 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i] + 4, 1, dashes, &bicycle_green, 0);
2022 }
2023 else if (mark_way == 2)
2024 {
2025 // mark way with bicycle track
2026 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i] + 4, 1, dashes, &bicycle_blue, 0);
2027 }
2028
1958 // draw as line 2029 // draw as line
1959 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 1, dashes, c); 2030 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 1, dashes, c, 1);
1960 //draw_lines_count_4++; 2031 //draw_lines_count_4++;
1961 //} 2032 //}
1962 2033
1963 // one way arrow 2034 // one way arrow
1964 if ((oneway > 0) && (order > 13)) 2035 if ((oneway > 0) && (order > 13))
1970 else if (poly == 3) 2041 else if (poly == 3)
1971 { 2042 {
1972 // ******* street has bridge ******** 2043 // ******* street has bridge ********
1973 // ******* street has bridge ******** 2044 // ******* street has bridge ********
1974 // ******* street has bridge ******** 2045 // ******* street has bridge ********
2046
2047 if (mark_way == 1)
2048 {
2049 // mark way with bicycle lanes
2050 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i] + 4, 2, dashes, &bicycle_green, 0);
2051 }
2052 else if (mark_way == 2)
2053 {
2054 // mark way with bicycle track
2055 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i] + 4, 2, dashes, &bicycle_blue, 0);
2056 }
2057
1975 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 2, dashes, c); 2058 gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 2, dashes, c, 1);
1976 //draw_lines_count_4++; 2059 //draw_lines_count_4++;
1977 2060
1978 // one way arrow 2061 // one way arrow
1979 if ((oneway > 0) && (order > 13)) 2062 if ((oneway > 0) && (order > 13))
1980 { 2063 {
1985 // --> now NOT used anymore!! 2068 // --> now NOT used anymore!!
1986 else // poly==0 -> street that is only a line (width=1) 2069 else // poly==0 -> street that is only a line (width=1)
1987 { 2070 {
1988 // OLD // gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, 0); 2071 // OLD // gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, 0);
1989 2072
1990 gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i], dashes, c); 2073 gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i], dashes, c, global_clinedrawing_active, 1);
1991 //draw_lines_count_3++; 2074 //draw_lines_count_3++;
1992 2075
1993 // one way arrow 2076 // one way arrow
1994 if ((oneway > 0) && (order > 13)) 2077 if ((oneway > 0) && (order > 13))
1995 { 2078 {
2068 p1 = pa1; 2151 p1 = pa1;
2069 p2 = pa2; 2152 p2 = pa2;
2070 } 2153 }
2071 else 2154 else
2072 { 2155 {
2073p1 =g_new(struct point, count_in*8+1); 2156 p1 = g_new0(struct point, count_in*8+1);
2074 p2=g_new(struct point, count_in*8+1); 2157 p2 = g_new0(struct point, count_in*8+1);
2075} 2158 }
2076 2159
2077pout=p1; 2160 pout=p1;
2078for (edge = 0; edge < 4; edge++) 2161 for (edge = 0; edge < 4; edge++)
2079{ 2162 {
2080 p=pin; 2163 p=pin;
2081 s=pin+count_in-1; 2164 s=pin+count_in-1;
2082 count_out=0; 2165 count_out=0;
2083 for (i = 0; i < count_in; i++) 2166 for (i = 0; i < count_in; i++)
2084 { 2167 {
2085 if (is_inside(p, &r, edge)) 2168 if (is_inside(p, &r, edge))
2086 {
2087 if (! is_inside(s, &r, edge))
2088 { 2169 {
2170 if (! is_inside(s, &r, edge))
2171 {
2089 poly_intersection(s,p,&r,edge,&pi); 2172 poly_intersection(s,p,&r,edge,&pi);
2090 pout[count_out++]=pi; 2173 pout[count_out++]=pi;
2174 }
2175 pout[count_out++]=*p;
2091 } 2176 }
2177 else
2178 {
2179 if (is_inside(s, &r, edge))
2180 {
2181 poly_intersection(p,s,&r,edge,&pi);
2092 pout[count_out++]=*p; 2182 pout[count_out++]=pi;
2183 }
2184 }
2185 s=p;
2186 p++;
2187 }
2188 count_in=count_out;
2189 if (pin == p1)
2190 {
2191 pin=p2;
2192 pout=p1;
2093 } 2193 }
2094 else 2194 else
2095 { 2195 {
2096 if (is_inside(s, &r, edge))
2097 {
2098 poly_intersection(p,s,&r,edge,&pi);
2099 pout[count_out++]=pi;
2100 }
2101 }
2102 s=p;
2103 p++;
2104 }
2105 count_in=count_out;
2106 if (pin == p1)
2107 {
2108 pin=p2;
2109 pout=p1;
2110 }
2111 else
2112 {
2113 pin=p1; 2196 pin=p1;
2114 pout=p2; 2197 pout=p2;
2115 } 2198 }
2116} 2199 }
2117 2200
2201
2202
2118gra->meth.draw_polygon(gra->priv, gc->priv, pin, count_in); 2203 gra->meth.draw_polygon(gra->priv, gc->priv, pin, count_in);
2119if (count_in >= limit) 2204 if (count_in >= limit)
2120{ 2205 {
2121 g_free(p1); 2206 g_free(p1);
2122 g_free(p2); 2207 g_free(p2);
2123} 2208 }
2124} 2209}
2125 2210
2126static void display_context_free(struct display_context *dc) 2211static void display_context_free(struct display_context *dc)
2127{ 2212{
2128 if (dc->gc) 2213 if (dc->gc)
2141{ 2226{
2142 if (size > 64) 2227 if (size > 64)
2143 { 2228 {
2144 size = 64; 2229 size = 64;
2145 } 2230 }
2231
2146 if (size >= gra->font_len) 2232 if (size >= gra->font_len)
2147 { 2233 {
2148 gra->font=g_renew(struct graphics_font *, gra->font, size+1); 2234 gra->font=g_renew(struct graphics_font *, gra->font, size+1);
2149 while (gra->font_len <= size) 2235 while (gra->font_len <= size)
2150 { 2236 {
2151 gra->font[gra->font_len++] = NULL; 2237 gra->font[gra->font_len++] = NULL;
2152 } 2238 }
2153 } 2239 }
2240
2154 if (!gra->font[size]) 2241 if (!gra->font[size])
2155 { 2242 {
2156 gra->font[size] = graphics_font_new(gra, size * gra->font_size, 0); 2243 gra->font[size] = graphics_font_new(gra, size * gra->font_size, 0);
2157 } 2244 }
2245
2158 return gra->font[size]; 2246 return gra->font[size];
2159} 2247}
2160 2248
2161void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p) 2249void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p)
2162{ 2250{
2231 return i + 1; 2319 return i + 1;
2232 } 2320 }
2233 return count; 2321 return count;
2234} 2322}
2235 2323
2236static void displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc, int order, int allow_dashed, int run_type) 2324static void displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc, int order, int allow_dashed, int run_type, int is_first)
2237{ 2325{
2238#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2239 dbg(0,"+#+:enter\n");
2240#endif
2241
2242 //// dbg(0, "EEnter\n");
2243 2326
2244 int *width = g_alloca(sizeof(int) * dc->maxlen); 2327 int *width = g_alloca(sizeof(int) * dc->maxlen);
2245 struct point *pa = g_alloca(sizeof(struct point) * dc->maxlen); 2328 struct point *pa = g_alloca(sizeof(struct point) * dc->maxlen);
2246 struct graphics *gra = dc->gra; 2329 struct graphics *gra = dc->gra;
2247 struct graphics_gc *gc = dc->gc; 2330 struct graphics_gc *gc = dc->gc;
2250 struct point p; 2333 struct point p;
2251 char *path; 2334 char *path;
2252 struct color custom_color; 2335 struct color custom_color;
2253 int dont_draw = 0; 2336 int dont_draw = 0;
2254 2337
2338 int oneway;
2339 int mark_way;
2340
2255 //if (run_type > 100) // dbg(0,"enter\n"); 2341 //if (run_type > 100) // dbg(0,"enter\n");
2256 2342
2257 while (di) 2343 while (di)
2258 { 2344 {
2259 2345
2372 else 2458 else
2373 { 2459 {
2374 count = transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL); 2460 count = transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL);
2375 } 2461 }
2376 2462
2463 //dbg(0,"**dc->type=%s count=%d\n", item_to_name(dc->type), count);
2464 //dbg(0,"** e->type=%s\n", item_to_name(e->type));
2465
2377 switch (e->type) 2466 switch (e->type)
2378 { 2467 {
2379 case element_polygon: 2468 case element_polygon:
2380 graphics_draw_polygon_clipped(gra, gc, pa, count); 2469 graphics_draw_polygon_clipped(gra, gc, pa, count);
2381 break; 2470 break;
2394 else if (di->item.flags & NAVIT_AF_BRIDGE) 2483 else if (di->item.flags & NAVIT_AF_BRIDGE)
2395 { 2484 {
2396 poly = 3; 2485 poly = 3;
2397 } 2486 }
2398 2487
2399 int oneway = 0; 2488 oneway = 0;
2400
2401 if (di->item.flags & NAVIT_AF_ONEWAYREV) 2489 if (di->item.flags & NAVIT_AF_ONEWAYREV)
2402 { 2490 {
2403 oneway = 2; 2491 oneway = 2;
2492 if (di->item.flags & NAVIT_AF_ONEWAY_BICYCLE_NO)
2493 {
2494 oneway = oneway + 4; // oneway does not apply to bicycles here
2495 }
2404 } 2496 }
2405 else if (di->item.flags & NAVIT_AF_ONEWAY) 2497 else if (di->item.flags & NAVIT_AF_ONEWAY)
2406 { 2498 {
2407 oneway = 1; 2499 oneway = 1;
2500 if (di->item.flags & NAVIT_AF_ONEWAY_BICYCLE_NO)
2501 {
2502 oneway = oneway + 4; // oneway does not apply to bicycles here
2503 }
2504 }
2505
2506 mark_way = 0;
2507 // dbg(0, "CYCLE LANE:002 is_first=%d\n", is_first);
2508 if ((dc->type != type_cycleway) && (is_first == 1) && ((global_vehicle_profile == 1) || (global_vehicle_profile == 2)))
2509 {
2510 if (di->item.flags & NAVIT_AF_BICYCLE_LANE)
2511 {
2512 mark_way = 1; // way with cycle lane
2513 }
2514 else if (di->item.flags & NAVIT_AF_BICYCLE_TRACK)
2515 {
2516 mark_way = 2; // way with cycle track (sperate bicycle lane)
2517 }
2408 } 2518 }
2409 2519
2410 // -------- apply dashes ------- 2520 // -------- apply dashes -------
2411 //if (e->u.polyline.dash_num > 0) 2521 //if (e->u.polyline.dash_num > 0)
2412 //{ 2522 //{
2422 // } 2532 // }
2423 //} 2533 //}
2424 2534
2425 if (dc->type == type_border_country) 2535 if (dc->type == type_border_country)
2426 { 2536 {
2427 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 99, poly, order, oneway, e->u.polyline.dash_num, &e->color); 2537 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 99, poly, order, oneway, e->u.polyline.dash_num, &e->color, 0);
2428 } 2538 }
2429 else 2539 else
2430 { 2540 {
2431 // use custom color for underground trains 2541 // use custom color for underground trains
2432 if (dc->type == type_rail_subway) 2542 if (dc->type == type_rail_subway)
2447 custom_color.g = custom_color.g << 8; 2557 custom_color.g = custom_color.g << 8;
2448 custom_color.b = custom_color.b << 8; 2558 custom_color.b = custom_color.b << 8;
2449 2559
2450 custom_color.a = 0xffff; 2560 custom_color.a = 0xffff;
2451 2561
2452 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &custom_color); 2562 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &custom_color, 0);
2453 } 2563 }
2454 else 2564 else
2455 { 2565 {
2456 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &e->color); 2566 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &e->color, 0);
2457 } 2567 }
2458 } 2568 }
2569 // change color of route if in bicycle-route-mode and we want to drive against the oneway street
2570 else if ((dc->type == type_street_route) && (global_vehicle_profile == 1) && ((di->col_int_value >> 26) & 3))
2571 {
2572 // if oneway and route goes against it
2573 if ( ((di->col_int_value >> 24) & 2) && ((di->col_int_value >> 26) & 1) )
2574 {
2575 //struct attr attr_98;
2576 //if (item_attr_get(&(di->item), attr_direction, &attr_98))
2577 //{
2578
2579 // custom_color.a = ((di->col_int_value >> 24) & 3); // "1" == 1 , "-1" == 3 , "0" == 0 direction of route on street
2580 // ((di->col_int_value >> 26) & 3) // 1 == NAVIT_AF_ONEWAY, 2 == NAVIT_AF_ONEWAYREV
2581
2582 // dbg(0, "direction(2).0=%x\n", di->col_int_value);
2583 // dbg(0, "direction(2)=%x oneway bicycle=%d\n", custom_color.a, ((di->col_int_value >> 26) & 3));
2584 //}
2585
2586 // mark route in ORANGE here
2587 custom_color.r = 0xff << 8;
2588 custom_color.g = 0x80 << 8;
2589 custom_color.b = 0x00 << 8;
2590
2591 custom_color.a = 0xffff;
2592
2593 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &custom_color, 0);
2594 }
2459 else 2595 else
2460 { 2596 {
2461 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &e->color); 2597 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &e->color, 0);
2598 }
2599 }
2600 else // all other ways
2601 {
2602 graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway, e->u.polyline.dash_num, &e->color, mark_way);
2462 } 2603 }
2463 } 2604 }
2464 2605
2465 // -------- cancel dashes ------- 2606 // -------- cancel dashes -------
2466 //if (e->u.polyline.dash_num > 0) 2607 //if (e->u.polyline.dash_num > 0)
2542 2683
2543 // ----------------------------- 2684 // -----------------------------
2544 2685
2545 if (e->text_size) 2686 if (e->text_size)
2546 { 2687 {
2547
2548 struct graphics_font *font = get_font(gra, e->text_size); 2688 struct graphics_font *font = get_font(gra, e->text_size);
2549 struct graphics_gc *gc_background = dc->gc_background; 2689 struct graphics_gc *gc_background = dc->gc_background;
2550 if (!gc_background && e->u.circle.background_color.a) 2690 if (!gc_background && e->u.circle.background_color.a)
2551 { 2691 {
2552 gc_background = graphics_gc_new(gra); 2692 gc_background = graphics_gc_new(gra);
2566 } 2706 }
2567 2707
2568 } 2708 }
2569 } 2709 }
2570 } 2710 }
2711 else // circle without label
2712 {
2713 if (dont_draw == 0)
2714 {
2715 if (e->u.circle.width > 1)
2716 {
2717 gc->meth.gc_set_linewidth(gc->priv, e->u.polyline.width);
2718 }
2719 graphics_draw_circle(gra, gc, pa, e->u.circle.radius);
2720 }
2721 }
2571 } 2722 }
2572 break; 2723 break;
2573 case element_text: 2724 case element_text:
2574 if (count && di->label) 2725 if (count && di->label)
2575 { 2726 {
2600 break; 2751 break;
2601 case element_icon: 2752 case element_icon:
2602 if (count) 2753 if (count)
2603 { 2754 {
2604 dont_draw = 0; 2755 dont_draw = 0;
2756
2605 //dbg(0,"poi-on_map:#%d:%s\n", poi_icon_on_map_count, item_to_name(dc->type)); 2757 // dbg(0,"MAP:poi-on_map:#%d:%s\n", poi_icon_on_map_count, item_to_name(dc->type));
2758
2606 if (item_is_poi(dc->type)) 2759 if (item_is_poi(dc->type))
2607 { 2760 {
2608 if (poi_icon_on_map_count > MAX_POI_ICONS_ON_MAP) 2761 if (poi_icon_on_map_count > MAX_POI_ICONS_ON_MAP)
2609 { 2762 {
2610 dont_draw = 1; 2763 dont_draw = 1;
2631 if (!src || !src[0]) 2784 if (!src || !src[0])
2632 { 2785 {
2633 src = "%s"; 2786 src = "%s";
2634 } 2787 }
2635 icon = g_strdup_printf(src, di->label + strlen(di->label) + 1); 2788 icon = g_strdup_printf(src, di->label + strlen(di->label) + 1);
2789
2636 path = graphics_icon_path(icon); 2790 path = graphics_icon_path(icon);
2637 g_free(icon); 2791 g_free(icon);
2638 } 2792 }
2639 else 2793 else
2640 { 2794 {
2641 path = graphics_icon_path(e->u.icon.src); 2795 path = graphics_icon_path(e->u.icon.src);
2796
2797 // dbg(0,"MAP:icon=%s\n", path);
2642 } 2798 }
2643 2799
2644 img = graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation); 2800 img = graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation);
2645 if (img) 2801 if (img)
2646 { 2802 {
2658 //dbg(0, "img2_icon: '%s'\n", path); 2814 //dbg(0, "img2_icon: '%s'\n", path);
2659 2815
2660 } 2816 }
2661 else 2817 else
2662 { 2818 {
2819 // missing icon //
2663 // missing icon // // dbg(0, "-- ICON MISSING -- failed to load icon '%s'\n", path); 2820 dbg(0, "-- ICON MISSING -- failed to load icon '%s'\n", path);
2664 } 2821 }
2665 2822
2666 g_free(path); 2823 g_free(path);
2667 } 2824 }
2668 2825
2707 } 2864 }
2708 di = di->next; 2865 di = di->next;
2709 } 2866 }
2710 2867
2711 //if (run_type > 100) // dbg(0,"gg099\n"); 2868 //if (run_type > 100) // dbg(0,"gg099\n");
2712
2713} 2869}
2870
2871
2872
2873
2874
2714/** 2875/**
2715 * FIXME 2876 * FIXME
2716 * @param <> 2877 * @param <>
2717 * @returns <> 2878 * @returns <>
2718 * @author Martin Schaller (04/2008) 2879 * @author Martin Schaller (04/2008)
2719 */ 2880 */
2720static void xdisplay_draw_elements(struct graphics *gra, struct displaylist *display_list, struct itemgra *itm, int run_type) 2881static void xdisplay_draw_elements(struct graphics *gra, struct displaylist *display_list, struct itemgra *itm, int run_type)
2721{ 2882{
2722 // // dbg(0,"Enter\n");
2723 2883
2724 struct element *e; 2884 struct element *e;
2725 GList *es, *types; 2885 GList *es, *types;
2726 struct display_context *dc = &display_list->dc; 2886 struct display_context *dc = &display_list->dc;
2727 struct hash_entry *entry; 2887 struct hash_entry *entry;
2728 int draw_it = 1; 2888 int draw_it = 1;
2889 int is_first_item = 1;
2729 2890
2730#ifdef NAVIT_MEASURE_TIME_DEBUG 2891#ifdef NAVIT_MEASURE_TIME_DEBUG
2731 clock_t s_ = debug_measure_start(); 2892 clock_t s_ = debug_measure_start();
2732#endif 2893#endif
2894
2895 is_first_item = 1;
2733 2896
2734 es = itm->elements; 2897 es = itm->elements;
2735 while (es) 2898 while (es)
2736 { 2899 {
2737 //// dbg(0,"*es\n"); 2900 //// dbg(0,"*es\n");
2747 { 2910 {
2748 break; 2911 break;
2749 } 2912 }
2750 2913
2751 dc->type = GPOINTER_TO_INT(types->data); 2914 dc->type = GPOINTER_TO_INT(types->data);
2752 //// dbg(0,"**type=%d\n", dc->type); 2915 // dbg(0,"**type=%s\n", item_to_name(dc->type));
2753 2916
2754 if (global_draw_multipolygons == 0) 2917 if (global_draw_multipolygons == 0)
2755 { 2918 {
2756 if (dc->type == type_poly_water_from_relations) 2919 if (dc->type == type_poly_water_from_relations)
2757 { 2920 {
2779 if (draw_it == 1) 2942 if (draw_it == 1)
2780 { 2943 {
2781 entry = get_hash_entry(display_list, dc->type); 2944 entry = get_hash_entry(display_list, dc->type);
2782 if (entry && entry->di) 2945 if (entry && entry->di)
2783 { 2946 {
2784 // // dbg(0,"++type=%s\n", item_to_name(dc->type)); 2947 //dbg(0,"++type=%s\n", item_to_name(dc->type));
2948 //dbg(0, "is_first_item=%d run_type=%d\n", is_first_item, run_type);
2785 //if (!strcmp(item_to_name(dc->type), "border_country")) 2949 //if (!strcmp(item_to_name(dc->type), "border_country"))
2786 //{ 2950 //{
2787 // displayitem_draw(entry->di, NULL, dc, display_list->order, 1, 101); 2951 // displayitem_draw(entry->di, NULL, dc, display_list->order, 1, 101);
2788 //} 2952 //}
2789 //else 2953 //else
2790 //{ 2954 //{
2791 displayitem_draw(entry->di, NULL, dc, display_list->order, 1, run_type); 2955 displayitem_draw(entry->di, NULL, dc, display_list->order, 1, run_type, is_first_item);
2956 is_first_item = 0;
2792 //} 2957 //}
2793 // // dbg(0,"**+gc free\n"); 2958 // // dbg(0,"**+gc free\n");
2794 display_context_free(dc); 2959 display_context_free(dc);
2795 } 2960 }
2796 } 2961 }
2801 } 2966 }
2802 2967
2803#ifdef NAVIT_MEASURE_TIME_DEBUG 2968#ifdef NAVIT_MEASURE_TIME_DEBUG
2804 debug_mrp("xdisplay_draw_elements:", debug_measure_end(s_)); 2969 debug_mrp("xdisplay_draw_elements:", debug_measure_end(s_));
2805#endif 2970#endif
2971
2972
2806} 2973}
2807 2974
2808void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label) 2975void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label)
2809{ 2976{
2810 // dbg(0, "EEnter\n"); 2977 // dbg(0, "EEnter\n");
2854 di->c[0].y = 0; 3021 di->c[0].y = 0;
2855 di->count = 1; 3022 di->count = 1;
2856 } 3023 }
2857 dc.e = e; 3024 dc.e = e;
2858 di->next = NULL; 3025 di->next = NULL;
2859 displayitem_draw(di, NULL, &dc, transform_get_scale(t), 0, 99); 3026 displayitem_draw(di, NULL, &dc, transform_get_scale(t), 0, 99, 0);
2860 display_context_free(&dc); 3027 display_context_free(&dc);
2861 es = g_list_next(es); 3028 es = g_list_next(es);
2862 } 3029 }
2863} 3030}
2864 3031
2868 * @returns <> 3035 * @returns <>
2869 * @author Martin Schaller (04/2008) 3036 * @author Martin Schaller (04/2008)
2870 */ 3037 */
2871static void xdisplay_draw_layer(struct displaylist *display_list, struct graphics *gra, struct layer *lay, int order) 3038static void xdisplay_draw_layer(struct displaylist *display_list, struct graphics *gra, struct layer *lay, int order)
2872{ 3039{
2873 //DBG // dbg(0,"ooo enter ooo\n");
2874 3040
2875 GList *itms; 3041 GList *itms;
2876 struct itemgra *itm; 3042 struct itemgra *itm;
2877 3043
2878 int run_type = 0; // 99 -> normal 3044 int run_type = 0; // 99 -> normal
2901 //dbg(0,"fast_draw_mode=1\n"); 3067 //dbg(0,"fast_draw_mode=1\n");
2902 fast_draw_mode = 1; 3068 fast_draw_mode = 1;
2903 run_type = 99; // draw only 1 pass, bridges and tunnels will be drawn in any order 3069 run_type = 99; // draw only 1 pass, bridges and tunnels will be drawn in any order
2904 } 3070 }
2905 3071
2906 //// dbg(0,"layer name=%s\n", lay->name); 3072 // dbg(0,"layer name=%s\n", lay->name);
2907
2908 3073
2909 // reset max drawing counters ---------------------- 3074 // reset max drawing counters ----------------------
2910 poi_on_map_count = 0; 3075 poi_on_map_count = 0;
2911 label_on_map_count = 0; 3076 label_on_map_count = 0;
2912 label_district_on_map_count = 0; 3077 label_district_on_map_count = 0;
3121 ldest = g_list_next(ldest); 3286 ldest = g_list_next(ldest);
3122 } 3287 }
3123 } 3288 }
3124 } 3289 }
3125 } 3290 }
3291
3292
3293
3294#ifdef NAVIT_ROUTING_DEBUG_PRINT
3295 // -------- DEBUG -------- draw real GPS position ---------
3296 // -------- DEBUG -------- draw real GPS position ---------
3297 // -------- DEBUG -------- draw real GPS position ---------
3298 if (!global_img_waypoint)
3299 {
3300 char *path2;
3301 path2 = graphics_icon_path("nav_waypoint_bk_center.png");
3302 global_img_waypoint = graphics_image_new_scaled_rotated(gra, path2, 59, 59, 0);
3303
3304 // compensate for streched images on high dpi devices
3305 global_img_waypoint->hot.x = (int)((float)global_img_waypoint->width / 2.0f / (float)global_dpi_factor);
3306 global_img_waypoint->hot.y = (int)((float)global_img_waypoint->height / 2.0f / (float)global_dpi_factor);
3307
3308 g_free(path2);
3309 }
3310
3311 struct coord_geo g33;
3312 struct coord c33;
3313 struct point p2;
3314 g33.lat = global_v_pos_lat;
3315 g33.lng = global_v_pos_lng;
3316
3317 transform_from_geo(projection_mg, &g33, &c33);
3318 enum projection pro = transform_get_projection(global_navit->trans_cursor);
3319
3320
3321 // cos = x
3322 // sin = y
3323 struct point *p_temp3 = g_alloca(sizeof(struct point) * (2 + 1));
3324 struct color debug_red2 = { 0xfafa,0x1010,0x0000,0xffff }; // RR GG BB AA
3325
3326 transform(global_navit->trans, pro, &c33, &p2, 1, 0, 0, NULL);
3327 p_temp3[0].x = p2.x;
3328 p_temp3[0].y = p2.y;
3329
3330 double dd = tracking_get_direction(global_navit->tracking);
3331 double temp_4 = (global_v_pos_dir - dd) - 90.0f;
3332
3333 p_temp3[0].x = p_temp3[0].x + 36 * (navit_cos(temp_4 * M_PI / 180));
3334 p_temp3[0].y = p_temp3[0].y + 36 * (navit_sin(temp_4 * M_PI / 180));
3335
3336 p_temp3[1].x = p_temp3[0].x;
3337 p_temp3[1].y = p_temp3[0].y;
3338
3339 p_temp3[1].x = p_temp3[1].x + 35 * (navit_cos(temp_4 * M_PI / 180));
3340 p_temp3[1].y = p_temp3[1].y + 35 * (navit_sin(temp_4 * M_PI / 180));
3341
3342 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p_temp3, 2, 15, 14, 0, &debug_red2, global_clinedrawing_active, 1);
3343
3344
3345 // ------ text -------
3346 graphics_gc_set_foreground(gra->gc[0], &debug_red2);
3347 graphics_gc_set_linewidth(gra->gc[0], 8);
3348 struct point p7;
3349 struct graphics_font *font8 = get_font(gra, 21);
3350 char *dir_label=g_strdup_printf("%4.1f : %4.1f", (float)global_v_pos_dir, (float)dd);
3351 p7.x = p2.x + 25; // move text label a bit to the right, so it does not overlap the circle
3352 p7.y = p2.y - 160; // move label a bit up (y-axis)
3353 gra->meth.draw_text(gra->priv, gra->gc[0]->priv, NULL, font8->priv, dir_label, &p7, 0x10000, 0);
3354 g_free(dir_label);
3355 // ------ text -------
3356
3357
3358 p2.x = p2.x - global_img_waypoint->hot.x; // hot = 29
3359 p2.y = p2.y - global_img_waypoint->hot.y; // hot = 29
3360 gra->meth.draw_image(gra->priv, gra->gc[0]->priv, &p2, global_img_waypoint->priv);
3361
3362 // -------- DEBUG -------- draw real GPS position ---------
3363 // -------- DEBUG -------- draw real GPS position ---------
3364 // -------- DEBUG -------- draw real GPS position ---------
3365
3366
3367 // -------- DEBUG -------- draw winner track segment ---------
3368 // -------- DEBUG -------- draw winner track segment ---------
3369 // -------- DEBUG -------- draw winner track segment ---------
3370 struct color debug_orange = { 0xffff,0x4040,0x0000,0xffff }; // RR GG BB AA
3371 struct point *p_temp = g_alloca(sizeof(struct point) * (2 + 1));
3372 enum projection pro3 = transform_get_projection(global_navit->trans_cursor);
3373
3374 if (global_navit->route)
3375 {
3376 if (global_navit->destination_valid == 1)
3377 {
3378 transform(global_navit->trans, pro3, &global_debug_route_seg_winner_start, &p_temp[0], 1, 0, 0, NULL);
3379 transform(global_navit->trans, pro3, &global_debug_route_seg_winner_end, &p_temp[1], 1, 0, 0, NULL);
3380 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p_temp, 2, 15, 30, 0, &debug_orange, global_clinedrawing_active, 1);
3381 }
3382 }
3383
3384 struct color debug_turkoise = { 0x0404,0xb4b4,0xaeae,0xffff }; // RR GG BB AA
3385 transform(global_navit->trans, pro3, &global_debug_seg_winner_start, &p_temp[0], 1, 0, 0, NULL);
3386 transform(global_navit->trans, pro3, &global_debug_seg_winner_end, &p_temp[1], 1, 0, 0, NULL);
3387 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p_temp, 2, 15, 20, 0, &debug_turkoise, global_clinedrawing_active, 1);
3388
3389
3390 if (global_navit->route)
3391 {
3392 if (global_navit->destination_valid == 1)
3393 {
3394 struct color debug_red = { 0xffff,0x0000,0x0000,0xffff }; // RR GG BB AA
3395 graphics_gc_set_foreground(gra->gc[0], &debug_red);
3396 graphics_gc_set_linewidth(gra->gc[0], 10);
3397 transform(global_navit->trans, pro3, &global_debug_route_seg_winner_p_start, &p_temp[0], 1, 0, 0, NULL);
3398 gra->meth.draw_circle(gra->priv, gra->gc[0]->priv, &p_temp[0], 44);
3399 }
3400 }
3401
3402 struct color debug_green = { 0x0000,0xffff,0x0000,0xffff }; // RR GG BB AA
3403 graphics_gc_set_foreground(gra->gc[0], &debug_green);
3404 graphics_gc_set_linewidth(gra->gc[0], 8);
3405 transform(global_navit->trans, pro3, &global_debug_seg_winner_p_start, &p_temp[0], 1, 0, 0, NULL);
3406 gra->meth.draw_circle(gra->priv, gra->gc[0]->priv, &p_temp[0], 36);
3407
3408 if (global_navit->route)
3409 {
3410 if (global_navit->destination_valid == 1)
3411 {
3412 struct color debug_yellow = { 0xf7f7,0xfefe,0x2e2e,0xffff }; // RR GG BB AA
3413 transform(global_navit->trans, pro3, &global_debug_seg_route_start, &p_temp[0], 1, 0, 0, NULL);
3414 transform(global_navit->trans, pro3, &global_debug_seg_route_end, &p_temp[1], 1, 0, 0, NULL);
3415 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p_temp, 2, 15, 8, 0, &debug_yellow, global_clinedrawing_active, 1);
3416 }
3417 }
3418
3419
3420
3421
3422
3423
3424
3425// ============================== debug lines ==============================
3426// ============================== debug lines ==============================
3427// ============================== debug lines ==============================
3428#if 0
3429 struct color debug_purple = { 0xffff,0x0000,0xffff,0xffff }; // RR GG BB AA
3430 transform(global_navit->trans, pro3, &global_debug_trlast_start, &p_temp[0], 1, 0, 0, NULL);
3431 transform(global_navit->trans, pro3, &global_debug_trlast_end, &p_temp[1], 1, 0, 0, NULL);
3432 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p_temp, 2, 15, 18, 0, &debug_purple, global_clinedrawing_active, 1);
3433
3434
3435 struct color debug_purple0 = { 0x1010,0xfefe,0xefef,0xffff }; // RR GG BB AA
3436 struct color debug_purple1 = { 0x3030,0xaeae,0x4f4f,0xffff }; // RR GG BB AA
3437 struct color debug_purple2 = { 0x1010,0x7878,0x3030,0xffff }; // RR GG BB AA
3438 struct color debug_red3 = { 0xffff,0x0000,0x0000,0xffff }; // RR GG BB AA
3439 struct color *debug_color_pp;
3440 int ii2;
3441 int jj;
3442
3443 //dbg(0,"global_debug_coord_list:LOOP:num=%d\n", global_debug_coord_list_items);
3444
3445 for (ii2 = 0; ii2 < global_debug_coord_list_items; ii2++)
3446 {
3447
3448 //dbg(0,"global_debug_coord_list:LOOP:coord_list=%d\n", ii2);
3449
3450 transform(global_navit->trans, pro3, &global_debug_coord_list[ii2], &p_temp[0], 1, 0, 0, NULL);
3451 ii2++;
3452 transform(global_navit->trans, pro3, &global_debug_coord_list[ii2], &p_temp[1], 1, 0, 0, NULL);
3453
3454 jj = ((ii2 - 1) % 3);
3455 if (jj == 0)
3456 {
3457 debug_color_pp = &debug_purple0;
3458 }
3459 else if (jj == 1)
3460 {
3461 debug_color_pp = &debug_purple1;
3462 }
3463 else
3464 {
3465 debug_color_pp = &debug_purple2;
3466 }
3467
3468
3469 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p_temp, 2, 15, 6, 0, debug_color_pp, global_clinedrawing_active, 1);
3470
3471 // ------ text -------
3472 graphics_gc_set_foreground(gra->gc[0], &debug_red3);
3473 graphics_gc_set_linewidth(gra->gc[0], 6);
3474 struct point p7;
3475 struct graphics_font *font8 = get_font(gra, 21);
3476 char *dir_label=g_strdup_printf("%d", (ii2 - 1));
3477 p7.x = p_temp[0].x + 0; // move text label a bit to the right, so it does not overlap the circle
3478 p7.y = p_temp[0].y + 0; // move label a bit down (y-axis)
3479 gra->meth.draw_text(gra->priv, gra->gc[0]->priv, NULL, font8->priv, dir_label, &p7, 0x10000, 0);
3480 g_free(dir_label);
3481 // ------ text -------
3482
3483 // ------ text -------
3484 //graphics_gc_set_foreground(gra->gc[0], &debug_red3);
3485 //graphics_gc_set_linewidth(gra->gc[0], 6);
3486 //struct point p7;
3487 //struct graphics_font *font8 = get_font(gra, 21);
3488 dir_label=g_strdup_printf("%d", ii2);
3489 p7.x = p_temp[1].x + 8; // move text label a bit to the right, so it does not overlap the circle
3490 p7.y = p_temp[1].y + 8; // move label a bit down (y-axis)
3491 gra->meth.draw_text(gra->priv, gra->gc[0]->priv, NULL, font8->priv, dir_label, &p7, 0x10000, 0);
3492 g_free(dir_label);
3493 // ------ text -------
3494
3495 }
3496#endif
3497// ============================== debug lines ==============================
3498// ============================== debug lines ==============================
3499// ============================== debug lines ==============================
3500
3501
3502
3503
3504
3505
3506 // -------- DEBUG -------- draw winner track segment ---------
3507 // -------- DEBUG -------- draw winner track segment ---------
3508 // -------- DEBUG -------- draw winner track segment ---------
3509#endif
3510
3511
3126 } 3512 }
3127 // dirty hack to draw "waypoint(s)" --------------------------- 3513 // dirty hack to draw "waypoint(s)" ---------------------------
3514 // dirty hack to draw "route arrows" ---------------------------
3515 else if (strncmp("RouteArrows", lay->name, 11) == 0)
3516 {
3517 if (global_navit->route)
3518 {
3519 if (global_navit->destination_valid == 1)
3520 {
3521
3522#define MAX_ROUTE_ARROW_LINE_LENGTH 50.0f
3523#define MAX_ROUTE_ARROW_LINE_LENGTH_SQ 2500
3524#define MIN_ROUTE_ARROW_LINE_LENGTH_SQ 2000
3525#define MAX_ROUTE_ARROW_TO_SHOW 2 // default 2
3526
3527 struct navigation *nav = NULL;
3528 struct map *map=NULL;
3529 struct map_rect *mr=NULL;
3530 struct item *item8 =NULL;
3531 struct attr attr8;
3532 struct coord c8;
3533 struct coord c11;
3534 struct color route_arrrow_green_1 = { 0x0404,0xb4b4,0xaeae,0xffff }; // RR GG BB AA first line and arrow
3535 struct color route_arrrow_green_2 = { 0x0909,0x8484,0x7f7f,0xffff }; // RR GG BB AA all the next lines and arrows
3536 struct color *route_arrrow_green = &route_arrrow_green_1;
3537 struct point *p8 = g_alloca(sizeof(struct point));
3538 struct point *p9_temp = g_alloca(sizeof(struct point) * (2 + 1));
3539 struct point *p11_temp = g_alloca(sizeof(struct point) * (2 + 1));
3540 enum projection pro3 = transform_get_projection(global_navit->trans_cursor);
3541 int route_arrow_count = 0;
3542 int arrow_waiting = 0;
3543
3544
3545#ifdef NAVIT_SHOW_ROUTE_ARROWS
3546
3547 graphics_gc_set_foreground(gra->gc[0], route_arrrow_green);
3548 graphics_gc_set_linewidth(gra->gc[0], 8);
3549
3550 nav = navit_get_navigation(global_navit);
3551 if (nav)
3552 {
3553 map = navigation_get_map(nav);
3554 if (map)
3555 {
3556 mr = map_rect_new(map,NULL);
3557 if (mr)
3558 {
3559 while ((item8 = map_rect_get_item(mr)))
3560 {
3561
3562 if (item8->type == type_nav_destination)
3563 {
3564 break;
3565 }
3566
3567 if (item_attr_get(item8, attr_navigation_long, &attr8))
3568 {
3569 route_arrow_count++;
3570
3571 if (route_arrow_count > MAX_ROUTE_ARROW_TO_SHOW)
3572 {
3573 break;
3574 }
3575 else if (route_arrow_count == 2)
3576 {
3577 route_arrrow_green = &route_arrrow_green_2;
3578 }
3579
3580 item_coord_get(item8, &c8, 1);
3581
3582#if 0
3583 graphics_gc_set_foreground(gra->gc[0], &route_arrrow_green);
3584 graphics_gc_set_linewidth(gra->gc[0], 8);
3585 transform(global_navit->trans, pro3, &c8, p8, 1, 0, 0, NULL);
3586 gra->meth.draw_circle(gra->priv, gra->gc[0]->priv, p8, 45);
3587
3588 struct graphics_font *font8 = get_font(gra, 25);
3589 char *arrow_label=g_strdup_printf("%d", route_arrow_count);
3590
3591 p8->x = p8->x + 45; // move text label a bit to the right, so it does not overlap the circle
3592 p8->y = p8->y + (int)(25 / 2); // move label a bit down, so that it is in the middle of the circle (on y-axis)
3593
3594 gra->meth.draw_text(gra->priv, gra->gc[0]->priv, NULL, font8->priv, arrow_label, p8, 0x10000, 0);
3595 g_free(arrow_label);
3596#endif
3597
3598
3599 // --- find the segments for this maneuver ---
3600 struct route *route2 = NULL;
3601 struct map *route_map2 = NULL;
3602 struct map_rect *mr2 = NULL;
3603 struct item *item2 = NULL;
3604 struct coord c2;
3605 struct coord c2_prev;
3606 float route_line_length_sq;
3607 int first2 = 1;
3608 int first3 = 0;
3609 int found_seg = 0;
3610 float dx, dy;
3611 int added_seg = 0;
3612
3613 c2.x = 0;
3614 c2.y = 0;
3615 c2_prev.x = c2.x;
3616 c2_prev.y = c2.y;
3617
3618 route2 = navit_get_route(global_navit);
3619 if (route2)
3620 {
3621 route_map2 = route_get_map(route2);
3622 if (route_map2)
3623 {
3624 mr2 = map_rect_new(route_map2, NULL);
3625 if (mr2)
3626 {
3627 item2 = map_rect_get_item(mr2);
3628 while (item2)
3629 {
3630 if (!item_coord_get(item2, &c2, 1))
3631 {
3632 first3 = 1;
3633 item2 = map_rect_get_item(mr2);
3634 continue;
3635 }
3636
3637 // loop all coords of the route ----------------------
3638 if (first3 == 1)
3639 {
3640 first3 = 0;
3641 }
3642 else
3643 {
3644 if ( ((c2.x == c8.x) && (c2.y == c8.y)) || (found_seg == 1) )
3645 {
3646 //if (first2 == 1)
3647 //{
3648 // first2 = 0;
3649 //}
3650 //else
3651 {
3652 //dbg(0, "11draw:c2.x=%d c2.y=%d c2_prev.x=%d c2_prev.y=%d\n", c2.x, c2.y, c2_prev.x, c2_prev.y);
3653 if (found_seg == 1)
3654 {
3655 // draw arrow head at the end
3656
3657 route_line_length_sq = (float)transform_distance_sq(&c2_prev, &c2);
3658 if ((added_seg == 0) && (route_line_length_sq < MIN_ROUTE_ARROW_LINE_LENGTH_SQ))
3659 {
3660 // draw line
3661 transform(global_navit->trans, pro3, &c2_prev, &p9_temp[0], 1, 0, 0, NULL);
3662 transform(global_navit->trans, pro3, &c2, &p9_temp[1], 1, 0, 0, NULL);
3663 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p9_temp, 2, 15, 28, 0, route_arrrow_green, global_clinedrawing_active, 1);
3664
3665 // add next coord to line/arrow
3666 found_seg = 0;
3667 added_seg = 1;
3668 }
3669 else
3670 {
3671 if (route_line_length_sq > MAX_ROUTE_ARROW_LINE_LENGTH_SQ)
3672 {
3673 route_line_length_sq = sqrt(route_line_length_sq);
3674 // make line shorter (move coord c2 backward)
3675 dx = ((float)(c2.x - c2_prev.x)) / route_line_length_sq;
3676 dy = ((float)(c2.y - c2_prev.y)) / route_line_length_sq;
3677 c2.x = c2_prev.x + (int)(dx * MAX_ROUTE_ARROW_LINE_LENGTH);
3678 c2.y = c2_prev.y + (int)(dy * MAX_ROUTE_ARROW_LINE_LENGTH);
3679 }
3680
3681 transform(global_navit->trans, pro3, &c2_prev, &p9_temp[0], 1, 0, 0, NULL);
3682 transform(global_navit->trans, pro3, &c2, &p9_temp[1], 1, 0, 0, NULL);
3683 arrow_waiting = 1;
3684 p11_temp[0].x = p9_temp[0].x;
3685 p11_temp[0].y = p9_temp[0].y;
3686 p11_temp[1].x = p9_temp[1].x;
3687 p11_temp[1].y = p9_temp[1].y;
3688 c11.x = c2.x;
3689 c11.y = c2.y;
3690 // gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p9_temp, 2, 15, 28, 0, route_arrrow_green, global_clinedrawing_active, 4);
3691 }
3692 }
3693 else
3694 {
3695 route_line_length_sq = (float)transform_distance_sq(&c2_prev, &c2);
3696 if (route_line_length_sq > MAX_ROUTE_ARROW_LINE_LENGTH_SQ)
3697 {
3698 route_line_length_sq = sqrt(route_line_length_sq);
3699 // make line shorter (move coord c2_prev forward)
3700 dx = ((float)(c2.x - c2_prev.x)) / route_line_length_sq;
3701 dy = ((float)(c2.y - c2_prev.y)) / route_line_length_sq;
3702 c2_prev.x = c2.x - (int)(dx * MAX_ROUTE_ARROW_LINE_LENGTH);
3703 c2_prev.y = c2.y - (int)(dy * MAX_ROUTE_ARROW_LINE_LENGTH);
3704 }
3705
3706 transform(global_navit->trans, pro3, &c2_prev, &p9_temp[0], 1, 0, 0, NULL);
3707 transform(global_navit->trans, pro3, &c2, &p9_temp[1], 1, 0, 0, NULL);
3708
3709 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p9_temp, 2, 15, 28, 0, route_arrrow_green, global_clinedrawing_active, 1);
3710
3711 if (arrow_waiting == 1)
3712 {
3713 arrow_waiting = 0;
3714 if (((abs(c2.x - c11.x)<4) && (abs(c2.y - c11.y)<4)) || ((abs(c2_prev.x - c11.x)<4) && (abs(c2_prev.y - c11.y)<4)))
3715 {
3716 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p11_temp, 2, 15, 28, 0, route_arrrow_green, global_clinedrawing_active, 1);
3717 }
3718 else
3719 {
3720 if (route_arrow_count == 2)
3721 {
3722 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p11_temp, 2, 15, 28, 0, &route_arrrow_green_1, global_clinedrawing_active, 4);
3723 }
3724 else
3725 {
3726 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p11_temp, 2, 15, 28, 0, &route_arrrow_green_2, global_clinedrawing_active, 4);
3727 }
3728 }
3729 }
3730
3731 }
3732 }
3733
3734 if (found_seg == 0)
3735 {
3736 found_seg++;
3737 }
3738 else if (found_seg == 1)
3739 {
3740 break;
3741 }
3742
3743 }
3744 }
3745 c2_prev.x = c2.x;
3746 c2_prev.y = c2.y;
3747
3748 // loop all coords of the route ----------------------
3749 }
3750 map_rect_destroy(mr2);
3751 }
3752 }
3753 }
3754 // --- find the segments for this maneuver ---
3755
3756 }
3757 }
3758 map_rect_destroy(mr);
3759
3760 if (arrow_waiting == 1)
3761 {
3762 // if there is still an arrow to be drawn, draw it now
3763 arrow_waiting = 0;
3764 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p11_temp, 2, 15, 28, 0, route_arrrow_green, global_clinedrawing_active, 4);
3765 }
3766
3767 }
3768 }
3769 }
3770
3771#endif
3772
3773
3774
3775#ifdef NAVIT_FREE_TEXT_DEBUG_PRINT
3776 // ------- free text list ----------
3777 // ------- free text list ----------
3778
3779 struct color debug_blue2a = { 0x0000,0x0000,0xffff,0xffff }; // RR GG BB AA
3780 struct color debug_black2a = { 0x0000,0x0000,0x0000,0xffff }; // RR GG BB AA
3781 struct point *p_temp13a = g_alloca(sizeof(struct point));
3782 struct point *p9_temp13a = g_alloca(sizeof(struct point) * (2 + 1));
3783 enum projection pro4a = transform_get_projection(global_navit->trans_cursor);
3784 graphics_gc_set_linewidth(gra->gc[0], 8);
3785
3786 int ij1a;
3787 for (ij1a=0; ij1a < global_freetext_list_count; ij1a++)
3788 {
3789 transform(global_navit->trans, pro4a, &global_freetext_list[ij1a].c1, p_temp13a, 1, 0, 0, NULL);
3790 graphics_gc_set_foreground(gra->gc[0], &debug_blue2a);
3791 gra->meth.draw_circle(gra->priv, gra->gc[0]->priv, p_temp13a, 36);
3792
3793 // ------ text -------
3794 struct point p7a;
3795 struct graphics_font *font8a = get_font(gra, 10);
3796 graphics_gc_set_foreground(gra->gc[0], &debug_black2a);
3797 p7a.x = p_temp13a->x + 25; // move text label a bit to the right, so it does not overlap the circle
3798 p7a.y = p_temp13a->y + 25; // move label a bit down (y-axis)
3799 gra->meth.draw_text(gra->priv, gra->gc[0]->priv, NULL, font8a->priv, global_freetext_list[ij1a].text, &p7a, 0x10000, 0);
3800 // ------ text -------
3801 }
3802
3803 // ------- free text list ----------
3804 // ------- free text list ----------
3805#endif
3806
3807
3808
3809
3810
3811
3812 // ------- sharp turn angle list ----------
3813 // ------- sharp turn angle list ----------
3814#ifdef NAVIT_ANGLE_LIST_DEBUG_PRINT_DRAW
3815 struct color debug_green2 = { 0x0000,0xffff,0x0000,0xffff }; // RR GG BB AA
3816 struct color debug_blue2 = { 0x0000,0x0000,0xffff,0xffff }; // RR GG BB AA
3817 struct color debug_red2 = { 0xffff,0x0000,0x0000,0xffff }; // RR GG BB AA
3818 struct point *p_temp13 = g_alloca(sizeof(struct point));
3819 struct point *p9_temp13 = g_alloca(sizeof(struct point) * (2 + 1));
3820 enum projection pro4 = transform_get_projection(global_navit->trans_cursor);
3821 graphics_gc_set_linewidth(gra->gc[0], 8);
3822
3823 int ij1;
3824 for (ij1=0; ij1 < global_sharp_turn_list_count;ij1++)
3825 {
3826 transform(global_navit->trans, pro4, &global_sharp_turn_list[ij1].c1, p_temp13, 1, 0, 0, NULL);
3827 if (global_sharp_turn_list[ij1].dir == 1)
3828 {
3829 graphics_gc_set_foreground(gra->gc[0], &debug_green2);
3830 }
3831 else
3832 {
3833 graphics_gc_set_foreground(gra->gc[0], &debug_blue2);
3834 }
3835 gra->meth.draw_circle(gra->priv, gra->gc[0]->priv, p_temp13, 36);
3836
3837
3838 // --- line of turn angle ---
3839 p9_temp13[0].x = p_temp13->x;
3840 p9_temp13[0].y = p_temp13->y;
3841 transform(global_navit->trans, pro3, &global_sharp_turn_list[ij1].cs, &p9_temp13[1], 1, 0, 0, NULL);
3842 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p9_temp13, 2, 15, 12, 0, &debug_red2, global_clinedrawing_active, 1);
3843 transform(global_navit->trans, pro3, &global_sharp_turn_list[ij1].ce, &p9_temp13[1], 1, 0, 0, NULL);
3844 gra->meth.draw_lines3(gra->priv, gra->gc[0]->priv, p9_temp13, 2, 15, 5, 0, &debug_green2, global_clinedrawing_active, 1);
3845 // --- line of turn angle ---
3846
3847
3848
3849 // ------ text -------
3850 // graphics_gc_set_foreground(gra->gc[0], &debug_red2);
3851 // graphics_gc_set_linewidth(gra->gc[0], 8);
3852 struct point p7;
3853 struct graphics_font *font8 = get_font(gra, 21);
3854 char *dir_label=g_strdup_printf("%d", global_sharp_turn_list[ij1].angle);
3855
3856 if (global_sharp_turn_list[ij1].angle > 0)
3857 {
3858 p7.x = p_temp13->x + 25; // move text label a bit to the right, so it does not overlap the circle
3859 p7.y = p_temp13->y + 25 + (int)((float)global_sharp_turn_list[ij1].angle / 2.0f); // move label a bit down (y-axis)
3860 }
3861 else
3862 {
3863 p7.x = p_temp13->x + 25; // move text label a bit to the right, so it does not overlap the circle
3864 p7.y = p_temp13->y + 0 + (int)((float)global_sharp_turn_list[ij1].angle / 2.0f); // move label a bit down (y-axis)
3865 }
3866 gra->meth.draw_text(gra->priv, gra->gc[0]->priv, NULL, font8->priv, dir_label, &p7, 0x10000, 0);
3867 g_free(dir_label);
3868 // ------ text -------
3869
3870 }
3871#endif
3872 // ------- sharp turn angle list ----------
3873 // ------- sharp turn angle list ----------
3874
3875 }
3876 }
3877 }
3878 // dirty hack to draw "route arrows" ---------------------------
3128 3879
3129 3880
3130 if (send_refresh == 1) 3881 if (send_refresh == 1)
3131 { 3882 {
3132 // dummy "ready" signal ------------------------------------------ 3883 // dummy "ready" signal ------------------------------------------
3133 // dbg(0, "dummy \"ready\" signal (layers)\n"); 3884 // dbg(0, "dummy \"ready\" signal (layers)\n");
3134 gra->meth.draw_lines4(gra->priv, NULL, NULL, NULL, 1, 1, 96, 0, NULL); 3885 gra->meth.draw_lines4(gra->priv, NULL, NULL, NULL, 1, 1, 96, 0, NULL, 1);
3135 // dummy "ready" signal ------------------------------------------ 3886 // dummy "ready" signal ------------------------------------------
3136 } 3887 }
3137 3888
3138} 3889}
3139 3890
3143 * @returns <> 3894 * @returns <>
3144 * @author Martin Schaller (04/2008) 3895 * @author Martin Schaller (04/2008)
3145 */ 3896 */
3146static void xdisplay_draw(struct displaylist *display_list, struct graphics *gra, struct layout *l, int order) 3897static void xdisplay_draw(struct displaylist *display_list, struct graphics *gra, struct layout *l, int order)
3147{ 3898{
3148 ////DBG // dbg(0,"ooo enter ooo\n"); 3899__F_START__
3149 3900
3150 GList *lays; 3901 GList *lays;
3151 struct layer *lay; 3902 struct layer *lay;
3152 3903
3153 // int draw_vector_map = 1; 3904 // int draw_vector_map = 1;
3253 // reset value; 4004 // reset value;
3254 // cancel_drawing_global = 0; 4005 // cancel_drawing_global = 0;
3255 4006
3256 // dummy "start" signal ------------------------------------------ 4007 // dummy "start" signal ------------------------------------------
3257 // // dbg(0, "dummy \"start\" signal\n"); 4008 // // dbg(0, "dummy \"start\" signal\n");
3258 // gra->meth.draw_lines4(gra->priv, NULL, NULL, NULL, 1, 1, 97); 4009 // gra->meth.draw_lines4(gra->priv, NULL, NULL, NULL, 1, 1, 97, 0);
3259 // dummy "start" signal ------------------------------------------ 4010 // dummy "start" signal ------------------------------------------
3260 4011
4012__F_END__
3261} 4013}
3262 4014
3263/** 4015/**
3264 * FIXME 4016 * FIXME
3265 * @param <> 4017 * @param <>
3315} 4067}
3316 4068
3317static void do_draw(struct displaylist *displaylist, int cancel, int flags) 4069static void do_draw(struct displaylist *displaylist, int cancel, int flags)
3318{ 4070{
3319 4071
3320#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4072__F_START__
3321 dbg(0,"+#+:enter\n");
3322#endif
3323 4073
3324 // int rnd = rand(); 4074 // int rnd = rand();
3325 // dbg(0, "DO__DRAW:%d enter\n", rnd); 4075 // dbg(0, "DO__DRAW:%d enter\n", rnd);
3326 4076
3327 // try to cancel any previous drawing that might be going on ... 4077 // try to cancel any previous drawing that might be going on ...
3364 // dbg(0,"DO__DRAW:%d UN-lock mutex 001\n", rnd); 4114 // dbg(0,"DO__DRAW:%d UN-lock mutex 001\n", rnd);
3365 pthread_mutex_unlock(&uiConditionMutex); 4115 pthread_mutex_unlock(&uiConditionMutex);
3366 // dbg(0,"DO__DRAW:%d OK UN-lock mutex 001\n", rnd); 4116 // dbg(0,"DO__DRAW:%d OK UN-lock mutex 001\n", rnd);
3367 4117
3368 // dbg(0,"DO__DRAW:%d return 001\n", rnd); 4118 // dbg(0,"DO__DRAW:%d return 001\n", rnd);
3369 return; 4119 return2;
3370 } 4120 }
3371 // ---- disable map view ----- 4121 // ---- disable map view -----
3372 // ---- disable map view ----- 4122 // ---- disable map view -----
3373 // ---- disable map view ----- 4123 // ---- disable map view -----
3374#endif 4124#endif
3410 } 4160 }
3411 4161
3412 pro = transform_get_projection(displaylist->dc.trans); 4162 pro = transform_get_projection(displaylist->dc.trans);
3413 4163
3414 // if zoomed out too much then use prerendered map tiles 4164 // if zoomed out too much then use prerendered map tiles
4165 if (global_clinedrawing_active)
4166 {
4167 if (displaylist->order_hashed < ORDER_USE_PRERENDERED_MAP__C)
4168 {
4169 draw_vector_map = 0;
4170 }
4171
4172 if (displaylist->order_hashed > ORDER_USE_NORMAL_MAP__C)
4173 {
4174 draw_tile_map = 0;
4175 }
4176 }
4177 else
4178 {
3415 if (displaylist->order_hashed < ORDER_USE_PRERENDERED_MAP) // ==5 , (4,3,2,1,0)--> no vector map 4179 if (displaylist->order_hashed < ORDER_USE_PRERENDERED_MAP) // ==5 , (4,3,2,1,0)--> no vector map
3416 { 4180 {
3417 draw_vector_map = 0; 4181 draw_vector_map = 0;
3418 } 4182 }
3419 4183
3420 if (displaylist->order_hashed > ORDER_USE_NORMAL_MAP) // ==6 , (7,8,9, ...)--> no tile map 4184 if (displaylist->order_hashed > ORDER_USE_NORMAL_MAP) // ==6 , (7,8,9, ...)--> no tile map
3421 { 4185 {
3422 draw_tile_map = 0; 4186 draw_tile_map = 0;
4187 }
3423 } 4188 }
3424 4189
3425 displaylist->order = order_corrected; 4190 displaylist->order = order_corrected;
3426 4191
3427 //DBG // dbg(0, "XXXXXYYYYYYY Draw: 003\n"); 4192 //DBG // dbg(0, "XXXXXYYYYYYY Draw: 003\n");
3428 4193
3429 // reset value; 4194 // reset value;
3430 // cancel_drawing_global = 0; 4195 // cancel_drawing_global = 0;
4196
4197 char *ttt22 = NULL;
4198
3431 4199
3432 while (!cancel) 4200 while (!cancel)
3433 { 4201 {
3434 if (!displaylist->msh) 4202 if (!displaylist->msh)
3435 { 4203 {
3452 4220
3453 struct attr map_name_attr; 4221 struct attr map_name_attr;
3454 4222
3455 if (map_get_attr(displaylist->m, attr_name, &map_name_attr, NULL)) 4223 if (map_get_attr(displaylist->m, attr_name, &map_name_attr, NULL))
3456 { 4224 {
3457 //dbg(0,"#+* start reading map file #+*=%s\n",map_name_attr.u.str); 4225 // dbg(0,"MAP:#+* start reading map file #+*=%s\n", map_name_attr.u.str);
4226 if (ttt22)
4227 {
4228 g_free(ttt22);
4229 }
4230 ttt22 = g_strdup(map_name_attr.u.str);
4231
3458 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) 4232 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0)
3459 { 4233 {
3460 if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0) 4234 if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0)
3461 { 4235 {
3462 if (draw_tile_map == 1) 4236 if (draw_tile_map == 1)
3574 displaylist->sel = transform_get_selection(displaylist->dc.trans, displaylist->dc.pro, displaylist->order); 4348 displaylist->sel = transform_get_selection(displaylist->dc.trans, displaylist->dc.pro, displaylist->order);
3575 } 4349 }
3576 displaylist->mr = map_rect_new(displaylist->m, displaylist->sel); 4350 displaylist->mr = map_rect_new(displaylist->m, displaylist->sel);
3577 } 4351 }
3578 4352
4353
3579 if (displaylist->mr) 4354 if (displaylist->mr)
3580 { 4355 {
4356 // dbg(0,"MAP:001:map=%s\n", ttt22);
3581 // draw vector map, or not? 4357 // draw vector map, or not?
3582 // dbg(0,"draw_vector_map=%d mapset_need_draw=%d\n", draw_vector_map, mapset_need_draw); 4358 // dbg(0,"draw_vector_map=%d mapset_need_draw=%d\n", draw_vector_map, mapset_need_draw);
3583 // ****** if ((draw_vector_map) || (mapset_need_draw == 1)) 4359 // ****** if ((draw_vector_map) || (mapset_need_draw == 1))
3584 if (mapset_need_draw == 1) 4360 if (mapset_need_draw == 1)
3585 { 4361 {
4362 //dbg(0,"MAP:002:map=%s\n", ttt22);
3586 4363
3587 //// dbg(0, "XXXXXYYYYYYY Draw: A.01\n"); 4364 //// dbg(0, "XXXXXYYYYYYY Draw: A.01\n");
3588 4365
3589 4366
3590 // ------ READ all items in this map rectangle --------- 4367 // ------ READ all items in this map rectangle ---------
3594 // ------ READ all items in this map rectangle --------- 4371 // ------ READ all items in this map rectangle ---------
3595 // dbg(0,"#+* start reading map file #+*\n"); 4372 // dbg(0,"#+* start reading map file #+*\n");
3596 int _item_counter_ = 0; 4373 int _item_counter_ = 0;
3597 while ((item = map_rect_get_item(displaylist->mr))) 4374 while ((item = map_rect_get_item(displaylist->mr)))
3598 { 4375 {
4376 //dbg(0,"MAP:003:map=%s\n", ttt22);
4377
3599 _item_counter_++; 4378 _item_counter_++;
3600 4379
3601 int label_count = 0; 4380 int label_count = 0;
3602 char *labels[3]; 4381 char *labels[3];
3603 struct hash_entry *entry; 4382 struct hash_entry *entry;
3623 pthread_mutex_unlock(&uiConditionMutex); 4402 pthread_mutex_unlock(&uiConditionMutex);
3624 // dbg(0, "DO__DRAW:%d OK UN-lock mutex 002\n", rnd); 4403 // dbg(0, "DO__DRAW:%d OK UN-lock mutex 002\n", rnd);
3625 4404
3626 //// dbg(0,"return 002\n"); 4405 //// dbg(0,"return 002\n");
3627 // dbg(0, "DO__DRAW:%d return 002\n", rnd); 4406 // dbg(0, "DO__DRAW:%d return 002\n", rnd);
3628 return; 4407 return2;
3629 } 4408 }
3630 else 4409 else
3631 { 4410 {
3632 continue; 4411 continue;
3633 } 4412 }
3663 4442
3664 if (!count) 4443 if (!count)
3665 { 4444 {
3666 continue; 4445 continue;
3667 } 4446 }
4447
4448 //dbg(0,"MAP:004:map=%s\n", ttt22);
3668 4449
3669 //// dbg(0, "XXXXXYYYYYYY Draw: A.item2\n"); 4450 //// dbg(0, "XXXXXYYYYYYY Draw: A.item2\n");
3670 4451
3671 if (displaylist->dc.pro != pro) 4452 if (displaylist->dc.pro != pro)
3672 { 4453 {
3831 else 4612 else
3832 { 4613 {
3833 col_int_value = 0; 4614 col_int_value = 0;
3834 } 4615 }
3835 4616
4617
4618 struct attr attr_88;
4619 if (item->type == type_street_route)
4620 {
4621 if (item_attr_get(item, attr_direction, &attr_88))
4622 {
4623 //dbg(0, "direction(1a1)=%d %x\n", attr_88.u.num, col_int_value);
4624 col_int_value = col_int_value & 0xffffff;
4625 //dbg(0, "direction(1a2)=%x %x\n", attr_88.u.num, col_int_value);
4626 //dbg(0, "direction(1a2.1)=%x %x\n", (attr_88.u.num & 3), ((attr_88.u.num & 3) << 24));
4627 col_int_value = col_int_value | ((attr_88.u.num & 3) << 24);
4628 //dbg(0, "direction(1a3)=%x %x\n", attr_88.u.num, col_int_value);
4629 }
4630 else
4631 {
4632 //dbg(0, "direction(1b1)=%x\n", col_int_value);
4633 col_int_value = col_int_value & 0xffffff;
4634 //dbg(0, "direction(1b2)=%x\n", col_int_value);
4635 }
4636
4637 if (item_attr_get(item, attr_details, &attr_88))
4638 {
4639 // dbg(0, "direction(0)=%x\n", attr_88.u.num);
4640
4641 // #define NAVIT_AF_ONEWAY (1<<0)
4642 // #define NAVIT_AF_ONEWAYREV (1<<1)
4643 // #define NAVIT_AF_ONEWAY_BICYCLE_NO (1<<16)
4644
4645 if (attr_88.u.num & NAVIT_AF_ONEWAY_BICYCLE_NO)
4646 {
4647 // dbg(0, "direction(0)=%x\n", (attr_88.u.num & (NAVIT_AF_ONEWAY|NAVIT_AF_ONEWAYREV)));
4648 // dbg(0, "direction(0.1)=%x %x\n", col_int_value, (attr_88.u.num & (NAVIT_AF_ONEWAY|NAVIT_AF_ONEWAYREV)) << 26 );
4649 col_int_value = col_int_value | ((attr_88.u.num & (NAVIT_AF_ONEWAY|NAVIT_AF_ONEWAYREV)) << 26);
4650 }
4651 }
4652 }
4653
4654
3836 // --------======== LABELS ========-------- 4655 // --------======== LABELS ========--------
3837 // --------======== LABELS ========-------- 4656 // --------======== LABELS ========--------
3838 if (label_count > 0) 4657 if (label_count > 0)
3839 { 4658 {
3840 labels[0] = map_convert_string(displaylist->m, labels[0]); 4659 labels[0] = map_convert_string(displaylist->m, labels[0]);
3882 4701
3883 // dbg(0,"set:0:displaylist->busy=%d\n",displaylist->busy); 4702 // dbg(0,"set:0:displaylist->busy=%d\n",displaylist->busy);
3884 displaylist->busy = 0; 4703 displaylist->busy = 0;
3885 4704
3886 // dbg(0,"return 003\n"); 4705 // dbg(0,"return 003\n");
3887 return; 4706 return2;
3888 } 4707 }
3889 */ 4708 */
3890 4709
3891 } // while item=map_rect_get_item 4710 } // while item=map_rect_get_item
3892 // ------ READ all items in this map rectangle --------- 4711 // ------ READ all items in this map rectangle ---------
3893 // ------ READ all items in this map rectangle --------- 4712 // ------ READ all items in this map rectangle ---------
3894 // ------ READ all items in this map rectangle --------- 4713 // ------ READ all items in this map rectangle ---------
3895 // ------ READ all items in this map rectangle --------- 4714 // ------ READ all items in this map rectangle ---------
3896 // ------ READ all items in this map rectangle --------- 4715 // ------ READ all items in this map rectangle ---------
3897 4716
4717 //dbg(0,"MAP:013:map=%s\n", ttt22);
3898 4718
3899 ////DBG // dbg(0, "XXXXXYYYYYYY Draw: A.02\n"); 4719 ////DBG // dbg(0, "XXXXXYYYYYYY Draw: A.02\n");
3900 4720
3901 // ************** map_rect_destroy(displaylist->mr); 4721 // ************** map_rect_destroy(displaylist->mr);
3902 } 4722 }
3920 4740
3921#ifdef NAVIT_MEASURE_TIME_DEBUG 4741#ifdef NAVIT_MEASURE_TIME_DEBUG
3922 debug_mrp("do_draw:load", debug_measure_end(s_)); 4742 debug_mrp("do_draw:load", debug_measure_end(s_));
3923#endif 4743#endif
3924 s_ = debug_measure_start(); 4744 s_ = debug_measure_start();
4745
4746
4747
4748 // dbg(0, "DO__DRAW:%d dummy \"draw-start\" signal\n", rnd);
4749#ifdef HAVE_API_ANDROID
4750 android_return_generic_int(2, 77);
4751#endif
3925 4752
3926 // remove the "wait" screen 4753 // remove the "wait" screen
3927 //#ifdef HAVE_API_ANDROID 4754 //#ifdef HAVE_API_ANDROID
3928 // android_return_generic_int(2, 0); 4755 // android_return_generic_int(2, 0);
3929 //#endif 4756 //#endif
4063 } 4890 }
4064 4891
4065 // dbg(0, "DO__DRAW:%d leave\n", rnd); 4892 // dbg(0, "DO__DRAW:%d leave\n", rnd);
4066 // dbg(0, "DO__DRAW:%d __\n", rnd); 4893 // dbg(0, "DO__DRAW:%d __\n", rnd);
4067 4894
4068#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4895__F_END__
4069 dbg(0,"+#+:leave\n");
4070#endif
4071
4072} 4896}
4073 4897
4074/** 4898/**
4075 * FIXME 4899 * FIXME
4076 * @param <> 4900 * @param <>
4077 * @returns <> 4901 * @returns <>
4078 * @author Martin Schaller (04/2008) 4902 * @author Martin Schaller (04/2008)
4079 */ 4903 */
4080void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags) 4904void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags)
4081{ 4905{
4082#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4906__F_START__
4083 dbg(0,"+#+:enter\n");
4084#endif
4085 4907
4086 // // dbg(0,"ooo enter ooo flags=%d\n", flags); 4908 // // dbg(0,"ooo enter ooo flags=%d\n", flags);
4087 4909
4088 4910
4089 int order = transform_get_order(trans); 4911 int order = transform_get_order(trans);
4125 graphics_background_gc(gra, gra->gc[0]); 4947 graphics_background_gc(gra, gra->gc[0]);
4126 4948
4127 if (flags & 1) 4949 if (flags & 1)
4128 { 4950 {
4129 // calls -> navit.c navit_predraw --> draw all vehicles 4951 // calls -> navit.c navit_predraw --> draw all vehicles
4130 callback_list_call_attr_0(gra->cbl, attr_predraw); 4952 // *********++-- DISABLED --++******* // callback_list_call_attr_0(gra->cbl, attr_predraw);
4953 navit_predraw(global_navit);
4131 } 4954 }
4132 4955
4133 gra->meth.draw_mode(gra->priv, (flags & 8) ? draw_mode_begin_clear : draw_mode_begin); 4956 gra->meth.draw_mode(gra->priv, (flags & 8) ? draw_mode_begin_clear : draw_mode_begin);
4134 4957
4135 if (!(flags & 2)) 4958 if (!(flags & 2))
4150 xdisplay_draw(displaylist, gra, l, order + l->order_delta); 4973 xdisplay_draw(displaylist, gra, l, order + l->order_delta);
4151 } 4974 }
4152 4975
4153 if (flags & 1) 4976 if (flags & 1)
4154 { 4977 {
4155 callback_list_call_attr_0(gra->cbl, attr_postdraw); 4978 // calls: "graphics_displaylist_draw"
4979 // ***********++-- DISABLED --++*********** // callback_list_call_attr_0(gra->cbl, attr_postdraw);
4156 } 4980 }
4157 4981
4158 if (!(flags & 4)) 4982 if (!(flags & 4))
4159 { 4983 {
4160 gra->meth.draw_mode(gra->priv, draw_mode_end); 4984 gra->meth.draw_mode(gra->priv, draw_mode_end);
4161 } 4985 }
4162 4986
4163#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT 4987__F_END__
4164 dbg(0,"+#+:leave\n");
4165#endif
4166
4167} 4988}
4168 4989
4169static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) 4990static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
4170{ 4991{
4171 // dbg(0, "DO__DRAW:gl_ms enter\n"); 4992__F_START__
4172 4993
4173 int order = transform_get_order(trans); 4994 int order = transform_get_order(trans);
4174 4995
4175 //// dbg(0,"enter displaylist->busy=%d\n",displaylist->busy);
4176 //// dbg(0,"async=%d\n",async);
4177 if (displaylist->busy) 4996 if (displaylist->busy)
4178 { 4997 {
4179 if (async == 1) 4998 if (async == 1)
4180 { 4999 {
4181 //// dbg(0,"**draw 1.a\n");
4182 // dbg(0, "DO__DRAW:gl_ms return 001\n");
4183 return; 5000 return2;
4184 } 5001 }
4185 ///// dbg(0,"**draw 1\n");
4186 // dbg(0, "DO__DRAW:gl_ms return 002\n");
4187 return; 5002 return2;
4188 //do_draw(displaylist, 1, flags);
4189 } 5003 }
4190 xdisplay_free(displaylist); 5004 xdisplay_free(displaylist);
4191 5005
4192 displaylist->dc.gra = gra; 5006 displaylist->dc.gra = gra;
4193 displaylist->ms = mapset; 5007 displaylist->ms = mapset;
4199 if (l) 5013 if (l)
4200 { 5014 {
4201 order += l->order_delta; 5015 order += l->order_delta;
4202 } 5016 }
4203 displaylist->order = order; 5017 displaylist->order = order;
4204 //// dbg(0,"set:1:displaylist->busy=%d\n",displaylist->busy);
4205 displaylist->busy = 1; 5018 displaylist->busy = 1;
4206 displaylist->layout = l; 5019 displaylist->layout = l;
4207 5020
4208 // ---------- DISABLED ------ no more async!! 5021 // ---------- DISABLED ------ no more async!!
4209 /* 5022 /*
4225 } 5038 }
4226 */ 5039 */
4227 5040
4228 if (async) 5041 if (async)
4229 { 5042 {
4230 if (!displaylist->idle_cb) 5043 //if (!displaylist->idle_cb)
4231 { 5044 //{
4232 //dbg(0,"**draw 2.b1\n"); 5045 // this calls "do_draw"
4233 displaylist->idle_cb = callback_new_3(callback_cast(do_draw), displaylist, 0, flags); 5046 // *++*-- DISABLED --*++* // displaylist->idle_cb = callback_new_3(callback_cast(do_draw), displaylist, 0, flags);
4234 callback_add_names(displaylist->idle_cb, "graphics_load_mapset", "do_draw"); 5047 // *++*-- DISABLED --*++* // callback_add_names(displaylist->idle_cb, "graphics_load_mapset", "do_draw");
4235 //// dbg(0,"**draw 2.b2\n"); 5048 do_draw(displaylist, 0, flags);
4236 } 5049 //}
4237 //dbg(0,"**draw 2.b3\n");
4238 //dbg(0, "DO__DRAW:call 003 (async callback)\n"); 5050 //dbg(0, "DO__DRAW:call 003 (async callback)\n");
4239 displaylist->idle_ev = event_add_idle(1000, displaylist->idle_cb); 5051 // *++*-- DISABLED --*++* // displaylist->idle_ev = event_add_idle(1000, displaylist->idle_cb);
4240 // dbg(0, "**draw 2.b4 %p\n", displaylist->idle_ev);
4241 } 5052 }
4242 else 5053 else
4243 { 5054 {
4244 //// dbg(0,"**draw 2.b5\n"); 5055 //// dbg(0,"**draw 2.b5\n");
4245 // dbg(0, "DO__DRAW:call 001\n"); 5056 // dbg(0, "DO__DRAW:call 001\n");
4246 do_draw(displaylist, 0, flags); 5057 do_draw(displaylist, 0, flags);
4247 } 5058 }
4248 5059
4249 // dbg(0, "DO__DRAW:gl_ms leave\n"); 5060__F_END__
4250} 5061}
4251 5062
4252/** 5063/**
4253 * FIXME 5064 * FIXME
4254 * @param <> 5065 * @param <>
4255 * @returns <> 5066 * @returns <>
4256 * @author Martin Schaller (04/2008) 5067 * @author Martin Schaller (04/2008)
4257 */ 5068 */
4258void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) 5069void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
4259{ 5070{
5071__F_START__
4260 //// dbg(0,"ooo enter ooo\n"); 5072 //// dbg(0,"ooo enter ooo\n");
4261 5073
4262 // dbg(0, "DO__DRAW:gras_draw enter\n"); 5074 // dbg(0, "DO__DRAW:gras_draw enter\n");
4263 graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb, flags); 5075 graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb, flags);
4264 // dbg(0, "DO__DRAW:gras_draw leave\n"); 5076 // dbg(0, "DO__DRAW:gras_draw leave\n");
5077__F_END__
4265} 5078}
4266 5079
4267int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist) 5080int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist)
4268{ 5081{
4269 //DBG // dbg(0,"ooo enter ooo\n"); 5082__F_START__
4270 5083
4271 if (!displaylist->busy) 5084 if (!displaylist->busy)
4272 { 5085 {
4273 return 0; 5086 return2 0;
4274 } 5087 }
4275 // dbg(0, "DO__DRAW:call 002\n"); 5088 // dbg(0, "DO__DRAW:call 002\n");
4276 do_draw(displaylist, 1, 0); 5089 do_draw(displaylist, 1, 0);
4277 return 1; 5090 return2 1;
5091
5092__F_END__
4278} 5093}
4279 5094
4280/** 5095/**
4281 * FIXME 5096 * FIXME
4282 * @param <> 5097 * @param <>

Legend:
Removed from v.34  
changed lines
  Added in v.40

   
Visit the ZANavi Wiki