Parent Directory | Revision Log
updates
1 | zoff99 | 2 | /** |
2 | zoff99 | 27 | * ZANavi, Zoff Android Navigation system. |
3 | zoff99 | 40 | * Copyright (C) 2011-2014 Zoff <zoff@zoff.cc> |
4 | zoff99 | 27 | * |
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * version 2 as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | zoff99 | 2 | * Navit, a modular navigation system. |
22 | * Copyright (C) 2005-2009 Navit Team | ||
23 | * | ||
24 | * This program is free software; you can redistribute it and/or | ||
25 | * modify it under the terms of the GNU General Public License | ||
26 | * version 2 as published by the Free Software Foundation. | ||
27 | * | ||
28 | * This program is distributed in the hope that it will be useful, | ||
29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
31 | * GNU General Public License for more details. | ||
32 | * | ||
33 | * You should have received a copy of the GNU General Public License | ||
34 | * along with this program; if not, write to the | ||
35 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
36 | * Boston, MA 02110-1301, USA. | ||
37 | */ | ||
38 | |||
39 | #define _USE_MATH_DEFINES 1 | ||
40 | #include "config.h" | ||
41 | #ifdef HAVE_UNISTD_H | ||
42 | #include <unistd.h> | ||
43 | #endif | ||
44 | #include <stdio.h> | ||
45 | #include <stdlib.h> | ||
46 | #include <signal.h> | ||
47 | #include <string.h> | ||
48 | #include <fcntl.h> | ||
49 | #include <glib.h> | ||
50 | #include <math.h> | ||
51 | #include <time.h> | ||
52 | #include "debug.h" | ||
53 | #include "navit.h" | ||
54 | #include "callback.h" | ||
55 | #include "gui.h" | ||
56 | #include "item.h" | ||
57 | #include "projection.h" | ||
58 | #include "map.h" | ||
59 | #include "mapset.h" | ||
60 | #include "main.h" | ||
61 | #include "coord.h" | ||
62 | #include "point.h" | ||
63 | #include "transform.h" | ||
64 | #include "param.h" | ||
65 | #include "menu.h" | ||
66 | #include "graphics.h" | ||
67 | #include "popup.h" | ||
68 | #include "data_window.h" | ||
69 | #include "route.h" | ||
70 | #include "navigation.h" | ||
71 | #include "speech.h" | ||
72 | #include "track.h" | ||
73 | #include "vehicle.h" | ||
74 | #include "layout.h" | ||
75 | #include "log.h" | ||
76 | #include "attr.h" | ||
77 | #include "event.h" | ||
78 | #include "file.h" | ||
79 | #include "profile.h" | ||
80 | #include "command.h" | ||
81 | #include "navit_nls.h" | ||
82 | #include "map.h" | ||
83 | #include "util.h" | ||
84 | #include "messages.h" | ||
85 | #include "vehicleprofile.h" | ||
86 | #include "sunriset.h" | ||
87 | #include "bookmarks.h" | ||
88 | zoff99 | 27 | #include "map.h" |
89 | zoff99 | 2 | #ifdef HAVE_API_WIN32_BASE |
90 | #include <windows.h> | ||
91 | #include "util.h" | ||
92 | #endif | ||
93 | #ifdef HAVE_API_WIN32_CE | ||
94 | #include "libc.h" | ||
95 | #endif | ||
96 | |||
97 | zoff99 | 40 | |
98 | |||
99 | |||
100 | |||
101 | |||
102 | |||
103 | |||
104 | |||
105 | |||
106 | |||
107 | |||
108 | |||
109 | // #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1 | ||
110 | |||
111 | |||
112 | // --------------- debug function calls ------------------ | ||
113 | // --------------- debug function calls ------------------ | ||
114 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT | ||
115 | #undef return2 | ||
116 | #define return2 dbg_func(0, global_func_indent_counter, "return(%d)\n", __LINE__);global_func_indent_counter--;return | ||
117 | |||
118 | #define __F_START__ global_func_indent_counter++;dbg_func(0, global_func_indent_counter, "enter\n"); | ||
119 | #define __F_END__ dbg_func(0, global_func_indent_counter, "leave\n");global_func_indent_counter--; | ||
120 | #else | ||
121 | #undef return2 | ||
122 | #define return2 return | ||
123 | |||
124 | #define __F_START__ | ||
125 | #define __F_END__ | ||
126 | #endif | ||
127 | // --------------- debug function calls ------------------ | ||
128 | // --------------- debug function calls ------------------ | ||
129 | |||
130 | |||
131 | |||
132 | |||
133 | |||
134 | |||
135 | zoff99 | 2 | /** |
136 | * @defgroup navit the navit core instance. navit is the object containing nearly everything: A set of maps, one or more vehicle, a graphics object for rendering the map, a gui object for displaying the user interface, a route object, a navigation object and so on. Be warned that it is theoretically possible to have more than one navit object | ||
137 | * @{ | ||
138 | */ | ||
139 | |||
140 | struct gui *main_loop_gui; | ||
141 | |||
142 | zoff99 | 27 | struct attr_iter |
143 | { | ||
144 | union | ||
145 | { | ||
146 | zoff99 | 2 | GList *list; |
147 | struct mapset_handle *mapset_handle; | ||
148 | } u; | ||
149 | }; | ||
150 | |||
151 | zoff99 | 29 | static int dist_to_street = 100000; |
152 | |||
153 | zoff99 | 2 | static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv); |
154 | static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt); | ||
155 | static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init); | ||
156 | static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir); | ||
157 | static void navit_cmd_zoom_to_route(struct navit *this); | ||
158 | static void navit_cmd_set_center_cursor(struct navit *this_); | ||
159 | static void navit_cmd_announcer_toggle(struct navit *this_); | ||
160 | static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv); | ||
161 | |||
162 | zoff99 | 30 | int allow_gui_internal = 0; // disable old GUI internal. it will not work anymore! |
163 | zoff99 | 2 | int routing_mode = 0; |
164 | int MYSTERY_SPEED = 2; | ||
165 | zoff99 | 14 | int offline_search_filter_duplicates = 0; |
166 | int offline_search_break_searching = 0; | ||
167 | zoff99 | 27 | char *navit_maps_dir; |
168 | zoff99 | 34 | char *navit_share_dir; |
169 | char *navit_data_dir; | ||
170 | zoff99 | 27 | int cancel_drawing_global = 0; |
171 | int global_speak_streetnames = 1; | ||
172 | int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now | ||
173 | int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB) | ||
174 | int draw_polylines_fast = 0; // default: 0 | ||
175 | int limit_order_corrected = 4; // remain at this order level for drawing streets etc. | ||
176 | zoff99 | 28 | int shift_order = 0; // shift order level (for displaying objects) by this values (should only be bigger than zero!!) |
177 | zoff99 | 40 | int global_search_street_size_factor = 1; // make search radius for streets bigger (not used on indexsearch) |
178 | zoff99 | 28 | int disable_map_drawing = 0; // dont draw the map and dont read data from file (hopefully saving resources) |
179 | int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing | ||
180 | zoff99 | 30 | int global_stop_demo_vehicle = 0; // 0 -> demo vehicle can move, 1 -> demo vehicle stands still |
181 | zoff99 | 31 | int global_show_route_rectangles = 0; // 1 -> show route rectangles, 0 -> dont show route rectangles |
182 | int global_traffic_light_delay = 0; // 0 -> dont account for traffic lights in route, >0 -> calc a delay for each traffic light | ||
183 | zoff99 | 40 | int global_clinedrawing_active = 0; // 0 -> java line drawing, 1 -> C line drawing |
184 | zoff99 | 31 | int global_draw_multipolygons = 1; // 0 -> dont draw lines and triangles from multipolygons, 1 -> draw them |
185 | zoff99 | 34 | int global_have_dpi_value = 240; |
186 | float global_dpi_factor = 1.0f; | ||
187 | int global_order_level_for_fast_draw = 13; | ||
188 | int global_show_english_labels = 1; // 0 -> only "normal" names/labels shown on map | ||
189 | // 1 -> show "normal, english" | ||
190 | // 2 -> show only "english" labels | ||
191 | zoff99 | 41 | int global_routing_engine = 0; // 0 -> offline ZANavi, 1 -> online OSRM |
192 | float global_overspill_factor = 1.0f; // overspill factor from Java code | ||
193 | zoff99 | 40 | int global_avoid_sharp_turns_flag = 0; // 0 -> normal routing, 1 -> try to avoid sharp turns / u-turns |
194 | int global_avoid_sharp_turns_min_angle = 40; // at what angle is it a sharp turn? | ||
195 | zoff99 | 41 | int global_avoid_sharp_turns_min_penalty = 1000; // routing penalty for sharp turns (DEFAULT = 1000) |
196 | zoff99 | 2 | |
197 | zoff99 | 40 | int global_search_radius_for_housenumbers = 300; // search this far around street-coord to find potential housenumbers for this street |
198 | int global_vehicle_profile = 0; // 0 -> car, 1 -> bicycle, 2 -> bicylce no one-ways | ||
199 | int global_cycle_lanes_prio = 5; // how much prio weight will be subtracted from prio weight if a road has a cycle lane (painted white line for bicycles) | ||
200 | int global_cycle_track_prio = 1; // unused for now!! | ||
201 | |||
202 | double global_v_pos_lat = 0.0; // global vehicle position | ||
203 | double global_v_pos_lng = 0.0; // global vehicle position | ||
204 | double global_v_pos_dir = 0.0; // global vehicle direction | ||
205 | |||
206 | zoff99 | 41 | struct coord global_vehicle_pos_onscreen; |
207 | struct coord_geo global_last_vehicle_pos_geo; | ||
208 | double ggggg_lat = 0; | ||
209 | double ggggg_lon = 0; | ||
210 | |||
211 | |||
212 | zoff99 | 40 | int global_demo_vehicle = 0; |
213 | int global_demo_vehicle_short_switch = 0; | ||
214 | long global_last_spoken = -1; | ||
215 | long global_last_spoken_base = 0; | ||
216 | zoff99 | 41 | float global_road_speed_factor = 0.85f; |
217 | zoff99 | 40 | |
218 | zoff99 | 47 | float global_level0_announcement = 5.0f; |
219 | float global_level1_announcement = 11.0f; | ||
220 | float global_level2_announcement = 24.3f; | ||
221 | zoff99 | 41 | float global_levelx_announcement_factor = 6.0f / 4.0f; |
222 | |||
223 | float global_b_level0_announcement = 4.8f; | ||
224 | float global_b_level1_announcement = 11.1f; | ||
225 | float global_b_level2_announcement = 21.1f; | ||
226 | float global_b_levelx_announcement_factor = 6.0f / 4.0f; | ||
227 | |||
228 | int global_driven_away_from_route = 0; | ||
229 | |||
230 | int global_enhance_cycleway = 0; | ||
231 | int global_tracking_show_real_gps_pos = 0; | ||
232 | zoff99 | 46 | int global_show_maps_debug_view = 0; |
233 | zoff99 | 50 | int global_cancel_preview_map_drawing = 0; |
234 | zoff99 | 51 | int global_night_mode = 0; |
235 | int global_test_number = -1; | ||
236 | zoff99 | 41 | |
237 | zoff99 | 40 | GList *global_all_cbs = NULL; |
238 | |||
239 | struct coord global_debug_route_seg_winner_start; | ||
240 | struct coord global_debug_route_seg_winner_end; | ||
241 | struct coord global_debug_seg_winner_start; | ||
242 | struct coord global_debug_seg_winner_end; | ||
243 | struct coord global_debug_route_seg_winner_p_start; | ||
244 | struct coord global_debug_route_seg_winner_p_end; | ||
245 | struct coord global_debug_seg_winner_p_start; | ||
246 | struct coord global_debug_seg_route_start; | ||
247 | struct coord global_debug_seg_route_end; | ||
248 | struct coord global_debug_trlast_start; | ||
249 | struct coord global_debug_trlast_end; | ||
250 | |||
251 | struct coord *global_debug_coord_list; | ||
252 | int global_debug_coord_list_items = 0; | ||
253 | int global_has_gpsfix = 0; | ||
254 | int global_pos_is_underground = 0; | ||
255 | |||
256 | |||
257 | int global_sharp_turn_list_count = 0; | ||
258 | struct global_sharp_turn *global_sharp_turn_list = NULL; | ||
259 | |||
260 | int global_freetext_list_count = 0; | ||
261 | struct global_freetext *global_freetext_list = NULL; | ||
262 | |||
263 | |||
264 | zoff99 | 31 | GHashTable *global_transform_hash = NULL; |
265 | GHashTable *global_transform_hash2 = NULL; | ||
266 | |||
267 | zoff99 | 28 | long long draw_lines_count_2 = 0; |
268 | long long draw_lines_count_3 = 0; | ||
269 | long long draw_lines_count_4 = 0; | ||
270 | zoff99 | 34 | int poi_on_map_count = 0; |
271 | int label_on_map_count = 0; | ||
272 | int label_district_on_map_count = 0; | ||
273 | int label_major_on_map_count = 0; | ||
274 | int poi_icon_on_map_count = 0; | ||
275 | zoff99 | 28 | |
276 | int mapdraw_time[11 + 5]; // time to draw map on screen (in 1/1000 of a second) [add 5, just in case we inc it 2 times at same time because of threads] | ||
277 | int cur_mapdraw_time_index = 0; | ||
278 | |||
279 | zoff99 | 30 | int route_status_previous = 0; |
280 | zoff99 | 31 | long long global_route_memory_size = 0; |
281 | zoff99 | 34 | int global_old_vehicle_speed = -1; |
282 | int global_old_vehicle_speed_for_autozoom = -1; | ||
283 | zoff99 | 52 | long global_scale = 100; |
284 | zoff99 | 30 | |
285 | zoff99 | 27 | void navit_add_mapset(struct navit *this_, struct mapset *ms) |
286 | zoff99 | 2 | { |
287 | this_->mapsets = g_list_append(this_->mapsets, ms); | ||
288 | } | ||
289 | |||
290 | struct mapset * | ||
291 | navit_get_mapset(struct navit *this_) | ||
292 | { | ||
293 | zoff99 | 27 | if (this_->mapsets) |
294 | { | ||
295 | zoff99 | 2 | return this_->mapsets->data; |
296 | } | ||
297 | zoff99 | 27 | else |
298 | { | ||
299 | //DBG dbg(0,"No mapsets enabled! Is it on purpose? Navit can't draw a map. Please check your navit.xml\n"); | ||
300 | } | ||
301 | zoff99 | 2 | return NULL; |
302 | } | ||
303 | |||
304 | struct tracking * | ||
305 | navit_get_tracking(struct navit *this_) | ||
306 | { | ||
307 | return this_->tracking; | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * @brief Get the user data directory. | ||
312 | * @param[in] create - create the directory if it does not exist | ||
313 | * | ||
314 | * @return char * to the data directory string. | ||
315 | * | ||
316 | * returns the directory used to store user data files (center.txt, | ||
317 | * destination.txt, bookmark.txt, ...) | ||
318 | * | ||
319 | */ | ||
320 | char* | ||
321 | zoff99 | 27 | navit_get_user_data_directory(int create) |
322 | { | ||
323 | zoff99 | 2 | char *dir; |
324 | zoff99 | 34 | // dir = getenv("NAVIT_USER_DATADIR"); |
325 | dir = navit_share_dir; | ||
326 | zoff99 | 27 | if (create && !file_exists(dir)) |
327 | { | ||
328 | //DBG dbg(0, "creating dir %s\n", dir); | ||
329 | if (file_mkdir(dir, 0)) | ||
330 | { | ||
331 | //DBG dbg(0, "failed creating dir %s\n", dir); | ||
332 | zoff99 | 2 | return NULL; |
333 | } | ||
334 | } | ||
335 | return dir; | ||
336 | } /* end: navit_get_user_data_directory(gboolean create) */ | ||
337 | |||
338 | zoff99 | 27 | void navit_draw_async(struct navit *this_, int async) |
339 | zoff99 | 2 | { |
340 | zoff99 | 40 | __F_START__ |
341 | zoff99 | 30 | |
342 | zoff99 | 28 | //dbg(0,"EEnter this_->blocked=%d\n",this_->blocked); |
343 | zoff99 | 2 | if (this_->blocked) |
344 | { | ||
345 | this_->blocked |= 2; | ||
346 | zoff99 | 28 | //dbg(0,"set this_->blocked=%d\n",this_->blocked); |
347 | zoff99 | 30 | // dbg(0,"DO__DRAW:ndasync return 001\n"); |
348 | zoff99 | 40 | return2; |
349 | zoff99 | 2 | } |
350 | zoff99 | 40 | |
351 | zoff99 | 2 | transform_setup_source_rect(this_->trans); |
352 | zoff99 | 28 | //dbg(0,"call graphics_draw\n"); |
353 | zoff99 | 30 | |
354 | // dbg(0,"DO__DRAW:gras_draw call\n"); | ||
355 | zoff99 | 27 | graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1); |
356 | zoff99 | 30 | // dbg(0,"DO__DRAW:ndasync leave\n"); |
357 | zoff99 | 40 | |
358 | __F_END__ | ||
359 | zoff99 | 2 | } |
360 | |||
361 | zoff99 | 27 | void navit_draw(struct navit *this_) |
362 | zoff99 | 2 | { |
363 | zoff99 | 40 | __F_START__ |
364 | zoff99 | 28 | |
365 | //dbg(0,"EEnter this_->ready=%d\n",this_->ready); | ||
366 | zoff99 | 2 | if (this_->ready == 3) |
367 | { | ||
368 | zoff99 | 40 | // dbg(0,"navit_draw_async_001\n"); |
369 | zoff99 | 30 | // dbg(0,"DO__DRAW:navit_draw_async call\n"); |
370 | zoff99 | 2 | navit_draw_async(this_, 0); |
371 | } | ||
372 | zoff99 | 30 | |
373 | zoff99 | 40 | __F_END__ |
374 | zoff99 | 2 | } |
375 | |||
376 | zoff99 | 27 | int navit_get_ready(struct navit *this_) |
377 | zoff99 | 2 | { |
378 | return this_->ready; | ||
379 | } | ||
380 | |||
381 | zoff99 | 30 | // UNUSED ----- |
382 | // UNUSED ----- | ||
383 | zoff99 | 27 | void navit_draw_displaylist(struct navit *this_) |
384 | zoff99 | 2 | { |
385 | if (this_->ready == 3) | ||
386 | { | ||
387 | zoff99 | 27 | // //DBG dbg(0,"call graphics_displaylist_draw 2") |
388 | graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags | 1); | ||
389 | zoff99 | 2 | } |
390 | } | ||
391 | |||
392 | zoff99 | 27 | static void navit_map_progress(struct navit *this_) |
393 | zoff99 | 2 | { |
394 | struct map *map; | ||
395 | struct mapset *ms; | ||
396 | struct mapset_handle *msh; | ||
397 | struct attr attr; | ||
398 | struct point p; | ||
399 | if (this_->ready != 3) | ||
400 | return; | ||
401 | zoff99 | 27 | p.x = 10; |
402 | p.y = 32; | ||
403 | zoff99 | 2 | |
404 | zoff99 | 27 | ms = this_->mapsets->data; |
405 | msh = mapset_open(ms); | ||
406 | while (msh && (map = mapset_next(msh, 0))) | ||
407 | { | ||
408 | if (map_get_attr(map, attr_progress, &attr, NULL)) | ||
409 | { | ||
410 | char *str = g_strdup_printf("%s ", attr.u.str); | ||
411 | zoff99 | 2 | graphics_draw_mode(this_->gra, draw_mode_begin); |
412 | graphics_draw_text_std(this_->gra, 16, str, &p); | ||
413 | g_free(str); | ||
414 | zoff99 | 27 | p.y += 32; |
415 | zoff99 | 2 | graphics_draw_mode(this_->gra, draw_mode_end); |
416 | } | ||
417 | } | ||
418 | mapset_close(msh); | ||
419 | } | ||
420 | |||
421 | zoff99 | 27 | static void navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr) |
422 | zoff99 | 2 | { |
423 | zoff99 | 40 | __F_START__ |
424 | zoff99 | 28 | |
425 | zoff99 | 2 | int updated; |
426 | |||
427 | zoff99 | 27 | if ((this_->route) && (this_->route->route_status_was_updated == 1)) |
428 | zoff99 | 2 | { |
429 | zoff99 | 27 | this_->route->route_status_was_updated = 0; |
430 | zoff99 | 2 | // send route_status to java |
431 | #ifdef HAVE_API_ANDROID | ||
432 | android_return_generic_int(1, this_->route->route_status); | ||
433 | #endif | ||
434 | } | ||
435 | |||
436 | if (attr->type != attr_route_status) | ||
437 | { | ||
438 | zoff99 | 40 | return2; |
439 | zoff99 | 2 | } |
440 | zoff99 | 40 | |
441 | zoff99 | 27 | updated = attr->u.num; |
442 | zoff99 | 40 | |
443 | zoff99 | 2 | if (this_->ready != 3) |
444 | { | ||
445 | zoff99 | 40 | return2; |
446 | zoff99 | 2 | } |
447 | zoff99 | 40 | |
448 | zoff99 | 2 | if (updated != route_status_path_done_new) |
449 | { | ||
450 | zoff99 | 40 | return2; |
451 | zoff99 | 2 | } |
452 | zoff99 | 40 | |
453 | zoff99 | 2 | if (this_->vehicle) |
454 | { | ||
455 | if (this_->vehicle->follow_curr == 1) | ||
456 | { | ||
457 | zoff99 | 27 | ////DBG dbg(0,"disabled -> we want redraw!!\n"); |
458 | zoff99 | 40 | // return2; |
459 | zoff99 | 2 | } |
460 | zoff99 | 40 | |
461 | zoff99 | 2 | if (this_->vehicle->follow_curr <= this_->vehicle->follow) |
462 | { | ||
463 | zoff99 | 27 | this_->vehicle->follow_curr = this_->vehicle->follow; |
464 | zoff99 | 2 | } |
465 | } | ||
466 | zoff99 | 40 | |
467 | // *++*-- DISABLED --*++* // navit_draw(this_); | ||
468 | |||
469 | __F_END__ | ||
470 | zoff99 | 2 | } |
471 | |||
472 | zoff99 | 27 | void navit_handle_resize(struct navit *this_, int w, int h) |
473 | zoff99 | 2 | { |
474 | zoff99 | 40 | __F_START__ |
475 | zoff99 | 28 | |
476 | zoff99 | 2 | struct map_selection sel; |
477 | zoff99 | 40 | |
478 | zoff99 | 27 | int callback = (this_->ready == 1); |
479 | zoff99 | 28 | this_->ready = this_->ready | 2; |
480 | zoff99 | 40 | |
481 | zoff99 | 2 | memset(&sel, 0, sizeof(sel)); |
482 | zoff99 | 40 | |
483 | zoff99 | 27 | this_->w = w; |
484 | this_->h = h; | ||
485 | sel.u.p_rect.rl.x = w; | ||
486 | sel.u.p_rect.rl.y = h; | ||
487 | zoff99 | 2 | transform_set_screen_selection(this_->trans, &sel); |
488 | graphics_init(this_->gra); | ||
489 | graphics_set_rect(this_->gra, &sel.u.p_rect); | ||
490 | zoff99 | 40 | |
491 | zoff99 | 27 | if (callback) |
492 | { | ||
493 | zoff99 | 40 | // HINT: this triggers all the OSD drawing (next turn, ETA, etc.) |
494 | zoff99 | 2 | callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); |
495 | zoff99 | 27 | } |
496 | zoff99 | 40 | |
497 | zoff99 | 2 | if (this_->ready == 3) |
498 | { | ||
499 | zoff99 | 40 | // dbg(0,"navit_draw_async_007\n"); |
500 | zoff99 | 28 | navit_draw_async(this_, 0); |
501 | zoff99 | 2 | } |
502 | zoff99 | 30 | |
503 | zoff99 | 40 | __F_END__ |
504 | zoff99 | 2 | } |
505 | |||
506 | zoff99 | 27 | void navit_resize(void *data, int w, int h) |
507 | zoff99 | 2 | { |
508 | zoff99 | 27 | struct navit *this = data; |
509 | zoff99 | 2 | if (!this->ignore_graphics_events) |
510 | zoff99 | 27 | { |
511 | //DBG dbg(0,"11\n"); | ||
512 | zoff99 | 2 | navit_handle_resize(this, w, h); |
513 | zoff99 | 27 | } |
514 | zoff99 | 2 | } |
515 | |||
516 | zoff99 | 27 | int navit_get_width(struct navit *this_) |
517 | zoff99 | 2 | { |
518 | return this_->w; | ||
519 | } | ||
520 | |||
521 | zoff99 | 27 | int navit_get_height(struct navit *this_) |
522 | zoff99 | 2 | { |
523 | return this_->h; | ||
524 | } | ||
525 | |||
526 | zoff99 | 27 | static void navit_popup(void *data) |
527 | zoff99 | 2 | { |
528 | zoff99 | 27 | struct navit *this_ = data; |
529 | zoff99 | 2 | popup(this_, 1, &this_->pressed); |
530 | zoff99 | 27 | this_->button_timeout = NULL; |
531 | this_->popped = 1; | ||
532 | zoff99 | 2 | } |
533 | |||
534 | zoff99 | 27 | int navit_ignore_button(struct navit *this_) |
535 | zoff99 | 2 | { |
536 | if (this_->ignore_button) | ||
537 | return 1; | ||
538 | zoff99 | 40 | |
539 | zoff99 | 27 | this_->ignore_button = 1; |
540 | zoff99 | 2 | return 0; |
541 | } | ||
542 | |||
543 | zoff99 | 27 | void navit_ignore_graphics_events(struct navit *this_, int ignore) |
544 | zoff99 | 2 | { |
545 | zoff99 | 27 | this_->ignore_graphics_events = ignore; |
546 | zoff99 | 2 | } |
547 | |||
548 | zoff99 | 28 | void update_transformation(struct transformation *tr, struct point *old, struct point *new, struct point *rot) |
549 | zoff99 | 2 | { |
550 | zoff99 | 27 | struct coord co, cn; |
551 | struct coord c, *cp; | ||
552 | zoff99 | 2 | int yaw; |
553 | zoff99 | 27 | double angleo, anglen; |
554 | zoff99 | 2 | |
555 | if (!transform_reverse(tr, old, &co)) | ||
556 | return; | ||
557 | zoff99 | 27 | if (rot) |
558 | { | ||
559 | angleo = atan2(old->y - rot->y, old->x - rot->x) * 180 / M_PI; | ||
560 | anglen = atan2(new->y - rot->y, new->x - rot->x) * 180 / M_PI; | ||
561 | yaw = transform_get_yaw(tr) + angleo - anglen; | ||
562 | zoff99 | 2 | transform_set_yaw(tr, yaw % 360); |
563 | } | ||
564 | if (!transform_reverse(tr, new, &cn)) | ||
565 | return; | ||
566 | zoff99 | 27 | cp = transform_get_center(tr); |
567 | c.x = cp->x + co.x - cn.x; | ||
568 | c.y = cp->y + co.y - cn.y; | ||
569 | // dbg(1, "from 0x%x,0x%x to 0x%x,0x%x\n", cp->x, cp->y, c.x, c.y); | ||
570 | zoff99 | 2 | transform_set_center(tr, &c); |
571 | } | ||
572 | |||
573 | zoff99 | 27 | void navit_set_timeout(struct navit *this_) |
574 | zoff99 | 2 | { |
575 | zoff99 | 28 | // --------- DISABLE ----------- |
576 | return; | ||
577 | // --------- DISABLE ----------- | ||
578 | zoff99 | 2 | } |
579 | |||
580 | zoff99 | 27 | int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback) |
581 | zoff99 | 2 | { |
582 | zoff99 | 27 | int border = 16; |
583 | zoff99 | 2 | |
584 | zoff99 | 27 | // dbg(1, "enter %d %d (ignore %d)\n", pressed, button, this_->ignore_button); |
585 | zoff99 | 2 | callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p); |
586 | zoff99 | 27 | if (this_->ignore_button) |
587 | { | ||
588 | this_->ignore_button = 0; | ||
589 | zoff99 | 2 | return 0; |
590 | } | ||
591 | zoff99 | 27 | if (pressed) |
592 | { | ||
593 | this_->pressed = *p; | ||
594 | this_->last = *p; | ||
595 | this_->zoomed = 0; | ||
596 | if (button == 1) | ||
597 | { | ||
598 | this_->button_pressed = 1; | ||
599 | this_->moved = 0; | ||
600 | this_->popped = 0; | ||
601 | zoff99 | 28 | // ---- DISBALED -------- |
602 | /* | ||
603 | zoff99 | 30 | if (popup_callback) |
604 | this_->button_timeout = event_add_timeout(500, 0, popup_callback); | ||
605 | */ | ||
606 | zoff99 | 2 | } |
607 | if (button == 2) | ||
608 | navit_set_center_screen(this_, p, 1); | ||
609 | if (button == 3) | ||
610 | popup(this_, button, p); | ||
611 | zoff99 | 27 | if (button == 4 && this_->use_mousewheel) |
612 | { | ||
613 | zoff99 | 2 | this_->zoomed = 1; |
614 | navit_zoom_in(this_, 2, p); | ||
615 | } | ||
616 | zoff99 | 27 | if (button == 5 && this_->use_mousewheel) |
617 | { | ||
618 | zoff99 | 2 | this_->zoomed = 1; |
619 | navit_zoom_out(this_, 2, p); | ||
620 | } | ||
621 | zoff99 | 27 | } |
622 | else | ||
623 | { | ||
624 | zoff99 | 2 | |
625 | zoff99 | 27 | this_->button_pressed = 0; |
626 | if (this_->button_timeout) | ||
627 | { | ||
628 | zoff99 | 2 | event_remove_timeout(this_->button_timeout); |
629 | zoff99 | 27 | this_->button_timeout = NULL; |
630 | if (!this_->moved && !transform_within_border(this_->trans, p, border)) | ||
631 | { | ||
632 | zoff99 | 2 | navit_set_center_screen(this_, p, !this_->zoomed); |
633 | } | ||
634 | } | ||
635 | zoff99 | 27 | if (this_->motion_timeout) |
636 | { | ||
637 | zoff99 | 2 | event_remove_timeout(this_->motion_timeout); |
638 | zoff99 | 27 | this_->motion_timeout = NULL; |
639 | zoff99 | 2 | } |
640 | zoff99 | 27 | if (this_->moved) |
641 | { | ||
642 | zoff99 | 2 | struct point pr; |
643 | zoff99 | 27 | pr.x = this_->w / 2; |
644 | pr.y = this_->h; | ||
645 | zoff99 | 2 | #if 0 |
646 | update_transformation(this_->trans, &this_->pressed, p, &pr); | ||
647 | #else | ||
648 | update_transformation(this_->trans, &this_->pressed, p, NULL); | ||
649 | #endif | ||
650 | graphics_draw_drag(this_->gra, NULL); | ||
651 | transform_copy(this_->trans, this_->trans_cursor); | ||
652 | graphics_overlay_disable(this_->gra, 0); | ||
653 | zoff99 | 27 | if (!this_->zoomed) |
654 | zoff99 | 40 | { |
655 | zoff99 | 2 | navit_set_timeout(this_); |
656 | zoff99 | 40 | } |
657 | zoff99 | 2 | navit_draw(this_); |
658 | zoff99 | 27 | } |
659 | else | ||
660 | zoff99 | 2 | return 1; |
661 | } | ||
662 | return 0; | ||
663 | } | ||
664 | |||
665 | zoff99 | 27 | static void navit_button(void *data, int pressed, int button, struct point *p) |
666 | zoff99 | 2 | { |
667 | zoff99 | 27 | struct navit *this = data; |
668 | // dbg(1, "enter %d %d ignore %d\n", pressed, button, this->ignore_graphics_events); | ||
669 | if (!this->ignore_graphics_events) | ||
670 | { | ||
671 | if (!this->popup_callback) | ||
672 | zoff99 | 28 | { |
673 | zoff99 | 27 | this->popup_callback = callback_new_1(callback_cast(navit_popup), this); |
674 | zoff99 | 30 | callback_add_names(this->popup_callback, "navit_button", "navit_popup"); |
675 | zoff99 | 28 | } |
676 | zoff99 | 2 | navit_handle_button(this, pressed, button, p, this->popup_callback); |
677 | } | ||
678 | } | ||
679 | |||
680 | zoff99 | 30 | // UNUSED --- |
681 | // UNUSED --- | ||
682 | zoff99 | 27 | static void navit_motion_timeout(struct navit *this_) |
683 | zoff99 | 2 | { |
684 | int dx, dy; | ||
685 | |||
686 | zoff99 | 27 | if (this_->drag_bitmap) |
687 | { | ||
688 | zoff99 | 2 | struct point point; |
689 | zoff99 | 27 | point.x = (this_->current.x - this_->pressed.x); |
690 | point.y = (this_->current.y - this_->pressed.y); | ||
691 | if (graphics_draw_drag(this_->gra, &point)) | ||
692 | { | ||
693 | zoff99 | 2 | graphics_overlay_disable(this_->gra, 1); |
694 | graphics_draw_mode(this_->gra, draw_mode_end); | ||
695 | zoff99 | 27 | this_->moved = 1; |
696 | this_->motion_timeout = NULL; | ||
697 | zoff99 | 2 | return; |
698 | } | ||
699 | zoff99 | 27 | } |
700 | dx = (this_->current.x - this_->last.x); | ||
701 | dy = (this_->current.y - this_->last.y); | ||
702 | if (dx || dy) | ||
703 | { | ||
704 | zoff99 | 2 | struct transformation *tr; |
705 | struct point pr; | ||
706 | zoff99 | 27 | this_->last = this_->current; |
707 | zoff99 | 2 | graphics_overlay_disable(this_->gra, 1); |
708 | zoff99 | 27 | tr = transform_dup(this_->trans); |
709 | pr.x = this_->w / 2; | ||
710 | pr.y = this_->h; | ||
711 | zoff99 | 2 | #if 0 |
712 | update_transformation(tr, &this_->pressed, &this_->current, &pr); | ||
713 | #else | ||
714 | update_transformation(tr, &this_->pressed, &this_->current, NULL); | ||
715 | #endif | ||
716 | #if 0 | ||
717 | graphics_displaylist_move(this_->displaylist, dx, dy); | ||
718 | #endif | ||
719 | zoff99 | 30 | graphics_draw_cancel(this_->gra, this_->displaylist); // --> calls "do_draw" normally |
720 | zoff99 | 2 | graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, this_->graphics_flags); |
721 | zoff99 | 30 | |
722 | zoff99 | 2 | transform_destroy(tr); |
723 | zoff99 | 27 | this_->moved = 1; |
724 | zoff99 | 2 | } |
725 | zoff99 | 27 | this_->motion_timeout = NULL; |
726 | zoff99 | 2 | return; |
727 | } | ||
728 | |||
729 | zoff99 | 27 | void navit_handle_motion(struct navit *this_, struct point *p) |
730 | zoff99 | 2 | { |
731 | zoff99 | 40 | __F_START__ |
732 | |||
733 | zoff99 | 2 | int dx, dy; |
734 | |||
735 | zoff99 | 27 | if (this_->button_pressed && !this_->popped) |
736 | { | ||
737 | dx = (p->x - this_->pressed.x); | ||
738 | dy = (p->y - this_->pressed.y); | ||
739 | if (dx < -8 || dx > 8 || dy < -8 || dy > 8) | ||
740 | { | ||
741 | this_->moved = 1; | ||
742 | if (this_->button_timeout) | ||
743 | { | ||
744 | zoff99 | 2 | event_remove_timeout(this_->button_timeout); |
745 | zoff99 | 27 | this_->button_timeout = NULL; |
746 | zoff99 | 2 | } |
747 | zoff99 | 27 | this_->current = *p; |
748 | zoff99 | 28 | |
749 | // -------- DISABLE ------- | ||
750 | // -------- DISABLE ------- | ||
751 | // -------- DISABLE ------- | ||
752 | /* | ||
753 | zoff99 | 30 | if (!this_->motion_timeout_callback) |
754 | this_->motion_timeout_callback = callback_new_1(callback_cast(navit_motion_timeout), this_); | ||
755 | if (!this_->motion_timeout) | ||
756 | this_->motion_timeout = event_add_timeout(100, 0, this_->motion_timeout_callback); | ||
757 | */ | ||
758 | zoff99 | 28 | // -------- DISABLE ------- |
759 | // -------- DISABLE ------- | ||
760 | // -------- DISABLE ------- | ||
761 | zoff99 | 2 | } |
762 | } | ||
763 | zoff99 | 40 | |
764 | __F_END__ | ||
765 | zoff99 | 2 | } |
766 | |||
767 | zoff99 | 28 | void navit_motion(void *data, struct point *p) |
768 | zoff99 | 2 | { |
769 | zoff99 | 27 | struct navit *this = data; |
770 | if (!this->ignore_graphics_events) | ||
771 | zoff99 | 28 | { |
772 | zoff99 | 2 | navit_handle_motion(this, p); |
773 | zoff99 | 28 | } |
774 | zoff99 | 2 | } |
775 | |||
776 | zoff99 | 40 | void navit_predraw(struct navit *this_) |
777 | zoff99 | 2 | { |
778 | zoff99 | 40 | __F_START__ |
779 | |||
780 | zoff99 | 2 | GList *l; |
781 | struct navit_vehicle *nv; | ||
782 | transform_copy(this_->trans, this_->trans_cursor); | ||
783 | zoff99 | 27 | l = this_->vehicles; |
784 | zoff99 | 2 | while (l) |
785 | { | ||
786 | zoff99 | 27 | nv = l->data; |
787 | ////DBG dbg(0,"* here *\n"); | ||
788 | ////DBG dbg(0,"vehicle_draw_004\n"); | ||
789 | zoff99 | 2 | navit_vehicle_draw(this_, nv, NULL); |
790 | zoff99 | 27 | l = g_list_next(l); |
791 | zoff99 | 2 | } |
792 | zoff99 | 40 | |
793 | __F_END__ | ||
794 | zoff99 | 2 | } |
795 | |||
796 | zoff99 | 27 | static void navit_scale(struct navit *this_, long scale, struct point *p, int draw) |
797 | zoff99 | 2 | { |
798 | struct coord c1, c2, *center; | ||
799 | |||
800 | if (scale < this_->zoom_min) | ||
801 | { | ||
802 | zoff99 | 27 | scale = this_->zoom_min; |
803 | zoff99 | 2 | } |
804 | |||
805 | if (scale > this_->zoom_max) | ||
806 | { | ||
807 | zoff99 | 27 | scale = this_->zoom_max; |
808 | zoff99 | 2 | } |
809 | |||
810 | zoff99 | 52 | global_scale = scale; |
811 | |||
812 | zoff99 | 2 | // return scale value to android |
813 | #ifdef HAVE_API_ANDROID | ||
814 | android_return_generic_int(3, (int)scale); | ||
815 | #endif | ||
816 | |||
817 | zoff99 | 34 | //dbg(0, "zoom to scale=%d", (int)scale); |
818 | |||
819 | |||
820 | zoff99 | 2 | if (p) |
821 | { | ||
822 | transform_reverse(this_->trans, p, &c1); | ||
823 | } | ||
824 | |||
825 | transform_set_scale(this_->trans, scale); | ||
826 | |||
827 | if (p) | ||
828 | { | ||
829 | transform_reverse(this_->trans, p, &c2); | ||
830 | center = transform_center(this_->trans); | ||
831 | center->x += c1.x - c2.x; | ||
832 | center->y += c1.y - c2.y; | ||
833 | } | ||
834 | |||
835 | zoff99 | 27 | //DBG dbg(0,"aa331\n"); |
836 | |||
837 | zoff99 | 2 | if (draw) |
838 | { | ||
839 | navit_draw(this_); | ||
840 | } | ||
841 | zoff99 | 27 | |
842 | //DBG dbg(0,"leave\n"); | ||
843 | zoff99 | 2 | } |
844 | |||
845 | /** | ||
846 | * @brief Automatically adjusts zoom level | ||
847 | * | ||
848 | * This function automatically adjusts the current | ||
849 | * zoom level according to the current speed. | ||
850 | * | ||
851 | * @param this_ The navit struct | ||
852 | * @param center The "immovable" point - i.e. the vehicles position if we're centering on the vehicle | ||
853 | * @param speed The vehicles speed in meters per second | ||
854 | * @param dir The direction into which the vehicle moves | ||
855 | */ | ||
856 | zoff99 | 41 | static long navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw, int *lold, int *lnew) |
857 | zoff99 | 2 | { |
858 | struct point pc; | ||
859 | zoff99 | 41 | int w, h; |
860 | float distance; | ||
861 | zoff99 | 34 | long new_scale; |
862 | zoff99 | 2 | long scale; |
863 | |||
864 | zoff99 | 27 | if (!this_->autozoom_active) |
865 | { | ||
866 | zoff99 | 34 | return -1; |
867 | zoff99 | 2 | } |
868 | |||
869 | zoff99 | 34 | if (global_old_vehicle_speed < 1) |
870 | { | ||
871 | return -1; | ||
872 | } | ||
873 | zoff99 | 2 | |
874 | zoff99 | 41 | // --- no autozoom at slow speed --- |
875 | //if (speed < 20) | ||
876 | //{ | ||
877 | // return -1; | ||
878 | //} | ||
879 | // --- no autozoom at slow speed --- | ||
880 | zoff99 | 34 | |
881 | zoff99 | 41 | |
882 | |||
883 | zoff99 | 34 | // this is kaputt!! |
884 | #if 0 | ||
885 | if (global_old_vehicle_speed_for_autozoom > 0) | ||
886 | { | ||
887 | if (abs(global_old_vehicle_speed_for_autozoom - speed) < 10) | ||
888 | { | ||
889 | // change in speed not significant | ||
890 | return; | ||
891 | } | ||
892 | } | ||
893 | global_old_vehicle_speed_for_autozoom = speed; | ||
894 | #endif | ||
895 | // this is kaputt!! | ||
896 | |||
897 | zoff99 | 41 | |
898 | |||
899 | zoff99 | 34 | // distance = speed * this_->autozoom_secs; |
900 | if (speed > 109) | ||
901 | { | ||
902 | zoff99 | 46 | distance = (float)speed * 16.4f; |
903 | zoff99 | 34 | } |
904 | zoff99 | 43 | else if (speed > 75) |
905 | { | ||
906 | zoff99 | 46 | distance = (float)speed * 10.3f; |
907 | zoff99 | 43 | } |
908 | zoff99 | 34 | else |
909 | { | ||
910 | zoff99 | 43 | distance = (float)speed * 7.3f; |
911 | zoff99 | 34 | } |
912 | |||
913 | zoff99 | 43 | // dbg(0,"autozoom: dis1=%f\n", distance); |
914 | |||
915 | zoff99 | 41 | // if overspill > 1 ? |
916 | if (global_overspill_factor > 1.0f) | ||
917 | { | ||
918 | distance = distance * global_overspill_factor; | ||
919 | } | ||
920 | |||
921 | |||
922 | zoff99 | 34 | // scale = this_->trans->scale * 16; |
923 | scale = transform_get_scale(this_->trans); | ||
924 | |||
925 | zoff99 | 2 | transform_get_size(this_->trans, &w, &h); |
926 | transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL); | ||
927 | |||
928 | zoff99 | 43 | #if 0 |
929 | // dbg(0,"autozoom:ovrspll=%f\n", global_overspill_factor); | ||
930 | dbg(0,"autozoom: dist=%f\n", distance); | ||
931 | dbg(0,"autozoom: scale=%d\n", (int)scale); | ||
932 | dbg(0,"autozoom:o speed=%d\n", speed); | ||
933 | dbg(0,"autozoom:n speed=%d\n", global_old_vehicle_speed); | ||
934 | #endif | ||
935 | zoff99 | 34 | |
936 | zoff99 | 2 | /* We make sure that the point we want to see is within a certain range |
937 | * around the vehicle. The radius of this circle is the size of the | ||
938 | * screen. This doesn't necessarily mean the point is visible because of | ||
939 | * perspective etc. Quite rough, but should be enough. */ | ||
940 | zoff99 | 27 | |
941 | if (w > h) | ||
942 | { | ||
943 | zoff99 | 41 | new_scale = (long)( (distance / (float)h) * 16); |
944 | zoff99 | 2 | } |
945 | zoff99 | 27 | else |
946 | { | ||
947 | zoff99 | 41 | new_scale = (long)( (distance / (float)w) * 16); |
948 | zoff99 | 27 | } |
949 | zoff99 | 2 | |
950 | zoff99 | 34 | if (new_scale < this_->autozoom_min) |
951 | zoff99 | 27 | { |
952 | zoff99 | 34 | new_scale = this_->autozoom_min; |
953 | zoff99 | 2 | } |
954 | zoff99 | 27 | |
955 | zoff99 | 43 | #if 0 |
956 | dbg(0,"autozoom:w n.scale=%d o.scale=%d\n", (int)new_scale, (int)scale); | ||
957 | #endif | ||
958 | zoff99 | 34 | |
959 | //if (abs(new_scale - scale) < 2) | ||
960 | //{ | ||
961 | // return; // Smoothing | ||
962 | //} | ||
963 | |||
964 | if (new_scale > scale) | ||
965 | zoff99 | 27 | { |
966 | zoff99 | 40 | // zoom out |
967 | zoff99 | 34 | if (new_scale > (scale + 20)) |
968 | { | ||
969 | scale = scale + 10; | ||
970 | } | ||
971 | else if (new_scale > (scale + 5)) | ||
972 | { | ||
973 | scale = scale + 4; | ||
974 | } | ||
975 | else | ||
976 | { | ||
977 | zoff99 | 41 | scale = scale + 1; |
978 | zoff99 | 34 | } |
979 | zoff99 | 27 | } |
980 | zoff99 | 34 | else if (new_scale < scale) |
981 | zoff99 | 27 | { |
982 | zoff99 | 40 | // zoom in |
983 | zoff99 | 41 | if ((new_scale + 220500) < scale) // lower threshold |
984 | zoff99 | 27 | { |
985 | zoff99 | 41 | scale = (int)((float)scale * 0.85f); |
986 | // dbg(0,"autozoom:step 8\n"); | ||
987 | zoff99 | 40 | } |
988 | zoff99 | 41 | else if ((new_scale + 130500) < scale) // lower threshold |
989 | zoff99 | 40 | { |
990 | zoff99 | 41 | scale = (int)((float)scale * 0.85f); |
991 | // dbg(0,"autozoom:step 7\n"); | ||
992 | zoff99 | 40 | } |
993 | zoff99 | 41 | else if ((new_scale + 4000) < scale) // lower threshold |
994 | zoff99 | 40 | { |
995 | zoff99 | 41 | scale = (int)((float)scale * 0.85f); |
996 | // dbg(0,"autozoom:step 6\n"); | ||
997 | zoff99 | 40 | } |
998 | zoff99 | 41 | else if ((new_scale + 1850) < scale) // lower threshold |
999 | zoff99 | 40 | { |
1000 | zoff99 | 41 | // scale = scale - 1000; |
1001 | scale = (int)((float)scale * 0.85f); | ||
1002 | // dbg(0,"autozoom:step 5\n"); | ||
1003 | zoff99 | 2 | } |
1004 | zoff99 | 41 | else if ((new_scale + 90) < scale) // lower threshold |
1005 | zoff99 | 34 | { |
1006 | zoff99 | 41 | // scale = scale - 200; |
1007 | scale = (int)((float)scale * 0.85f); | ||
1008 | // dbg(0,"autozoom:step 4\n"); | ||
1009 | zoff99 | 34 | } |
1010 | zoff99 | 41 | else if ((new_scale + 25) < scale) // lower threshold |
1011 | { | ||
1012 | scale = scale - 8; | ||
1013 | // dbg(0,"autozoom:step 3\n"); | ||
1014 | } | ||
1015 | else if ((new_scale + 7) < scale) // lower threshold | ||
1016 | { | ||
1017 | scale = scale - 2; | ||
1018 | // dbg(0,"autozoom:step 2\n"); | ||
1019 | } | ||
1020 | zoff99 | 34 | else |
1021 | { | ||
1022 | zoff99 | 41 | scale = scale - 1; |
1023 | // dbg(0,"autozoom:step 1\n"); | ||
1024 | zoff99 | 34 | } |
1025 | zoff99 | 2 | } |
1026 | zoff99 | 34 | else |
1027 | { | ||
1028 | // no change | ||
1029 | return -1; | ||
1030 | } | ||
1031 | |||
1032 | zoff99 | 41 | // dbg(0,"autozoom:n scale=%d\n", (int)scale); |
1033 | zoff99 | 34 | |
1034 | zoff99 | 41 | // OLD zoom is applied here ------------------------- |
1035 | struct coord c_left; | ||
1036 | struct point p_left; | ||
1037 | p_left.x = 0; | ||
1038 | p_left.y = 200; | ||
1039 | transform_reverse(this_->trans, &p_left, &c_left); | ||
1040 | struct coord c_right; | ||
1041 | struct point p_right; | ||
1042 | p_right.x = 200; | ||
1043 | p_right.y = 200; | ||
1044 | transform_reverse(this_->trans, &p_right, &c_right); | ||
1045 | // OLD zoom is applied here ------------------------- | ||
1046 | |||
1047 | |||
1048 | zoff99 | 34 | if (scale >= this_->autozoom_min) |
1049 | { | ||
1050 | navit_scale(this_, (long) scale, &pc, 0); | ||
1051 | } | ||
1052 | else | ||
1053 | { | ||
1054 | //if (scale != this_->autozoom_min) | ||
1055 | //{ | ||
1056 | navit_scale(this_, this_->autozoom_min, &pc, 0); | ||
1057 | //} | ||
1058 | } | ||
1059 | |||
1060 | zoff99 | 41 | // new zoom is applied here already ----------------- |
1061 | struct point p_new_left; | ||
1062 | transform(global_navit->trans, transform_get_projection(this_->trans), &c_left, &p_new_left, 1, 0, 0, NULL); | ||
1063 | struct point p_new_right; | ||
1064 | transform(global_navit->trans, transform_get_projection(this_->trans), &c_right, &p_new_right, 1, 0, 0, NULL); | ||
1065 | |||
1066 | *lold = 200; | ||
1067 | *lnew = abs(p_new_right.x - p_new_left.x); | ||
1068 | // new zoom is applied here already ----------------- | ||
1069 | |||
1070 | |||
1071 | zoff99 | 34 | // return new scale value |
1072 | return scale; | ||
1073 | zoff99 | 2 | } |
1074 | |||
1075 | /** | ||
1076 | * Change the current zoom level, zooming closer to the ground | ||
1077 | * | ||
1078 | * @param navit The navit instance | ||
1079 | * @param factor The zoom factor, usually 2 | ||
1080 | * @param p The invariant point (if set to NULL, default to center) | ||
1081 | * @returns nothing | ||
1082 | */ | ||
1083 | zoff99 | 27 | void navit_zoom_in(struct navit *this_, int factor, struct point *p) |
1084 | zoff99 | 2 | { |
1085 | zoff99 | 27 | long scale = transform_get_scale(this_->trans) / factor; |
1086 | zoff99 | 2 | if (scale < 1) |
1087 | zoff99 | 34 | { |
1088 | zoff99 | 27 | scale = 1; |
1089 | zoff99 | 34 | } |
1090 | zoff99 | 27 | ////DBG dbg(0,"zoom in -> scale=%d",scale); |
1091 | zoff99 | 2 | navit_scale(this_, scale, p, 1); |
1092 | } | ||
1093 | |||
1094 | /** | ||
1095 | * Change the current zoom level | ||
1096 | * | ||
1097 | * @param navit The navit instance | ||
1098 | * @param factor The zoom factor, usually 2 | ||
1099 | * @param p The invariant point (if set to NULL, default to center) | ||
1100 | * @returns nothing | ||
1101 | */ | ||
1102 | zoff99 | 27 | void navit_zoom_out(struct navit *this_, int factor, struct point *p) |
1103 | zoff99 | 2 | { |
1104 | zoff99 | 27 | long scale = transform_get_scale(this_->trans) * factor; |
1105 | ////DBG dbg(0,"zoom out -> scale=%d",scale); | ||
1106 | zoff99 | 2 | navit_scale(this_, scale, p, 1); |
1107 | } | ||
1108 | |||
1109 | zoff99 | 27 | int navit_get_cur_pnt(struct navit *this_, struct point *p) |
1110 | zoff99 | 2 | { |
1111 | return navit_get_cursor_pnt(this_, p, 0, NULL); | ||
1112 | } | ||
1113 | |||
1114 | zoff99 | 27 | void navit_zoom_in_cursor(struct navit *this_, int factor) |
1115 | zoff99 | 2 | { |
1116 | struct point p; | ||
1117 | zoff99 | 27 | if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) |
1118 | { | ||
1119 | zoff99 | 2 | navit_zoom_in(this_, factor, &p); |
1120 | zoff99 | 27 | this_->vehicle->follow_curr = this_->vehicle->follow; |
1121 | } | ||
1122 | else | ||
1123 | zoff99 | 34 | { |
1124 | zoff99 | 2 | navit_zoom_in(this_, factor, NULL); |
1125 | zoff99 | 34 | } |
1126 | zoff99 | 2 | } |
1127 | |||
1128 | zoff99 | 41 | void navit_zoom_to_scale_no_draw(struct navit *this_, int new_scale) |
1129 | { | ||
1130 | long scale = transform_get_scale(this_->trans); | ||
1131 | long new_scale_long = new_scale; | ||
1132 | |||
1133 | // only do something if scale changed! | ||
1134 | if (scale != new_scale_long) | ||
1135 | { | ||
1136 | navit_scale(this_, new_scale_long, NULL, 0); | ||
1137 | } | ||
1138 | } | ||
1139 | |||
1140 | |||
1141 | zoff99 | 27 | void navit_zoom_to_scale(struct navit *this_, int new_scale) |
1142 | zoff99 | 2 | { |
1143 | zoff99 | 27 | long scale = transform_get_scale(this_->trans); |
1144 | long new_scale_long = new_scale; | ||
1145 | //DBG dbg(0,"zoom to scale -> old scale=%d",scale); | ||
1146 | //DBG dbg(0,"zoom to scale -> want scale=%d",new_scale_long); | ||
1147 | zoff99 | 2 | |
1148 | // only do something if scale changed! | ||
1149 | if (scale != new_scale_long) | ||
1150 | { | ||
1151 | navit_scale(this_, new_scale_long, NULL, 1); | ||
1152 | } | ||
1153 | } | ||
1154 | |||
1155 | zoff99 | 28 | void navit_zoom_to_scale_with_center_point(struct navit *this_, int new_scale, struct point *p) |
1156 | { | ||
1157 | long scale = transform_get_scale(this_->trans); | ||
1158 | long new_scale_long = new_scale; | ||
1159 | |||
1160 | zoff99 | 34 | //dbg(0, "zoom to scale -> old scale=%d", scale); |
1161 | //dbg(0, "zoom to scale -> want scale=%d", new_scale_long); | ||
1162 | |||
1163 | zoff99 | 28 | // only do something if scale changed! |
1164 | if (scale != new_scale_long) | ||
1165 | { | ||
1166 | navit_scale(this_, new_scale_long, p, 1); | ||
1167 | } | ||
1168 | } | ||
1169 | |||
1170 | zoff99 | 27 | void navit_zoom_out_cursor(struct navit *this_, int factor) |
1171 | zoff99 | 2 | { |
1172 | struct point p; | ||
1173 | zoff99 | 27 | if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) |
1174 | { | ||
1175 | zoff99 | 2 | navit_zoom_out(this_, 2, &p); |
1176 | zoff99 | 27 | this_->vehicle->follow_curr = this_->vehicle->follow; |
1177 | } | ||
1178 | else | ||
1179 | zoff99 | 34 | { |
1180 | zoff99 | 2 | navit_zoom_out(this_, 2, NULL); |
1181 | zoff99 | 34 | } |
1182 | zoff99 | 2 | } |
1183 | |||
1184 | zoff99 | 27 | static int navit_cmd_zoom_in(struct navit *this_) |
1185 | zoff99 | 2 | { |
1186 | navit_zoom_in_cursor(this_, 2); | ||
1187 | return 0; | ||
1188 | } | ||
1189 | |||
1190 | zoff99 | 27 | static int navit_cmd_zoom_out(struct navit *this_) |
1191 | zoff99 | 2 | { |
1192 | navit_zoom_out_cursor(this_, 2); | ||
1193 | return 0; | ||
1194 | } | ||
1195 | |||
1196 | zoff99 | 27 | static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1197 | zoff99 | 2 | { |
1198 | zoff99 | 27 | if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1199 | { | ||
1200 | zoff99 | 2 | navit_say(this, in[0]->u.str); |
1201 | zoff99 | 27 | } |
1202 | zoff99 | 2 | } |
1203 | |||
1204 | static GHashTable *cmd_int_var_hash = NULL; | ||
1205 | static GHashTable *cmd_attr_var_hash = NULL; | ||
1206 | |||
1207 | /** | ||
1208 | * Store key value pair for the command system (for int typed values) | ||
1209 | * | ||
1210 | * @param navit The navit instance | ||
1211 | * @param function unused (needed to match command function signiture) | ||
1212 | * @param in input attributes in[0] is the key string, in[1] is the integer value to store | ||
1213 | * @param out output attributes, unused | ||
1214 | * @param valid unused | ||
1215 | * @returns nothing | ||
1216 | */ | ||
1217 | zoff99 | 27 | static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1218 | zoff99 | 2 | { |
1219 | char*key; | ||
1220 | struct attr*val; | ||
1221 | zoff99 | 27 | if (!cmd_int_var_hash) |
1222 | { | ||
1223 | zoff99 | 2 | cmd_int_var_hash = g_hash_table_new(g_str_hash, g_str_equal); |
1224 | } | ||
1225 | |||
1226 | zoff99 | 27 | if ((in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) && (in && in[1] && ATTR_IS_NUMERIC(in[1]->type))) |
1227 | { | ||
1228 | zoff99 | 2 | val = g_new(struct attr,1); |
1229 | zoff99 | 27 | attr_dup_content(in[1], val); |
1230 | zoff99 | 2 | key = g_strdup(in[0]->u.str); |
1231 | g_hash_table_insert(cmd_int_var_hash, key, val); | ||
1232 | zoff99 | 27 | } |
1233 | zoff99 | 2 | } |
1234 | |||
1235 | /** | ||
1236 | * Store key value pair for the command system (for attr typed values, can be used as opaque handles) | ||
1237 | * | ||
1238 | * @param navit The navit instance | ||
1239 | * @param function unused (needed to match command function signiture) | ||
1240 | * @param in input attributes in[0] is the key string, in[1] is the attr* value to store | ||
1241 | * @param out output attributes, unused | ||
1242 | * @param valid unused | ||
1243 | * @returns nothing | ||
1244 | */ | ||
1245 | //TODO free stored attributes on navit_destroy | ||
1246 | zoff99 | 27 | static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1247 | zoff99 | 2 | { |
1248 | char*key; | ||
1249 | struct attr*val; | ||
1250 | zoff99 | 27 | if (!cmd_attr_var_hash) |
1251 | { | ||
1252 | zoff99 | 2 | cmd_attr_var_hash = g_hash_table_new(g_str_hash, g_str_equal); |
1253 | } | ||
1254 | |||
1255 | zoff99 | 27 | if ((in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) && (in && in[1])) |
1256 | { | ||
1257 | zoff99 | 2 | val = attr_dup(in[1]); |
1258 | //val = in[1]; | ||
1259 | key = g_strdup(in[0]->u.str); | ||
1260 | g_hash_table_insert(cmd_attr_var_hash, key, val); | ||
1261 | zoff99 | 27 | } |
1262 | zoff99 | 2 | } |
1263 | |||
1264 | /** | ||
1265 | * command to toggle the active state of a named layer of the current layout | ||
1266 | * | ||
1267 | * @param navit The navit instance | ||
1268 | * @param function unused (needed to match command function signiture) | ||
1269 | * @param in input attribute in[0] is the name of the layer | ||
1270 | * @param out output unused | ||
1271 | * @param valid unused | ||
1272 | * @returns nothing | ||
1273 | */ | ||
1274 | zoff99 | 27 | static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1275 | zoff99 | 2 | { |
1276 | zoff99 | 27 | if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1277 | { | ||
1278 | if (this->layout_current && this->layout_current->layers) | ||
1279 | { | ||
1280 | zoff99 | 2 | GList* layers = this->layout_current->layers; |
1281 | zoff99 | 27 | while (layers) |
1282 | { | ||
1283 | struct layer*l = layers->data; | ||
1284 | if (l && !strcmp(l->name, in[0]->u.str)) | ||
1285 | { | ||
1286 | zoff99 | 2 | l->active ^= 1; |
1287 | navit_draw(this); | ||
1288 | return; | ||
1289 | } | ||
1290 | zoff99 | 27 | layers = g_list_next(layers); |
1291 | zoff99 | 2 | } |
1292 | } | ||
1293 | zoff99 | 27 | } |
1294 | zoff99 | 2 | } |
1295 | |||
1296 | zoff99 | 40 | |
1297 | zoff99 | 41 | void navit_enhance_cycleway(struct navit *this) |
1298 | { | ||
1299 | GList *itms; | ||
1300 | struct itemgra *itm; | ||
1301 | struct element *e; | ||
1302 | GList *es, *types; | ||
1303 | int found = 0; | ||
1304 | GList* layers = this->layout_current->layers; | ||
1305 | |||
1306 | global_enhance_cycleway = 1; | ||
1307 | |||
1308 | while (layers) | ||
1309 | { | ||
1310 | |||
1311 | struct layer*l = layers->data; | ||
1312 | if (l) | ||
1313 | { | ||
1314 | |||
1315 | itms = l->itemgras; | ||
1316 | while (itms) | ||
1317 | { | ||
1318 | itm = itms->data; | ||
1319 | found = 0; | ||
1320 | |||
1321 | types = itm->type; | ||
1322 | while (types) | ||
1323 | { | ||
1324 | if (GPOINTER_TO_INT(types->data) == type_cycleway) | ||
1325 | { | ||
1326 | found = 1; | ||
1327 | } | ||
1328 | types = g_list_next(types); | ||
1329 | } | ||
1330 | |||
1331 | if (found == 1) | ||
1332 | { | ||
1333 | |||
1334 | dbg(0, "CYC:001:min=%d max=%d\n", itm->order.min, itm->order.max); | ||
1335 | |||
1336 | if (itm->order.min == 14) | ||
1337 | { | ||
1338 | itm->order.min = 10; | ||
1339 | } | ||
1340 | |||
1341 | es = itm->elements; | ||
1342 | while (es) | ||
1343 | { | ||
1344 | e = es->data; | ||
1345 | |||
1346 | if (e->type == element_polyline) | ||
1347 | { | ||
1348 | e->u.polyline.width = e->u.polyline.width * 2; | ||
1349 | } | ||
1350 | |||
1351 | es = g_list_next(es); | ||
1352 | } | ||
1353 | } | ||
1354 | |||
1355 | itms = g_list_next(itms); | ||
1356 | } | ||
1357 | |||
1358 | } | ||
1359 | layers = g_list_next(layers); | ||
1360 | |||
1361 | } | ||
1362 | |||
1363 | } | ||
1364 | |||
1365 | |||
1366 | void navit_reset_cycleway(struct navit *this) | ||
1367 | { | ||
1368 | GList *itms; | ||
1369 | struct itemgra *itm; | ||
1370 | struct element *e; | ||
1371 | GList *es, *types; | ||
1372 | int found = 0; | ||
1373 | GList* layers = this->layout_current->layers; | ||
1374 | |||
1375 | global_enhance_cycleway = 0; | ||
1376 | |||
1377 | while (layers) | ||
1378 | { | ||
1379 | |||
1380 | struct layer*l = layers->data; | ||
1381 | if (l) | ||
1382 | { | ||
1383 | |||
1384 | itms = l->itemgras; | ||
1385 | while (itms) | ||
1386 | { | ||
1387 | itm = itms->data; | ||
1388 | found = 0; | ||
1389 | |||
1390 | types = itm->type; | ||
1391 | while (types) | ||
1392 | { | ||
1393 | if (GPOINTER_TO_INT(types->data) == type_cycleway) | ||
1394 | { | ||
1395 | found = 1; | ||
1396 | } | ||
1397 | types = g_list_next(types); | ||
1398 | } | ||
1399 | |||
1400 | if (found == 1) | ||
1401 | { | ||
1402 | if (itm->order.min == 10) | ||
1403 | { | ||
1404 | itm->order.min = 14; | ||
1405 | } | ||
1406 | |||
1407 | es = itm->elements; | ||
1408 | while (es) | ||
1409 | { | ||
1410 | e = es->data; | ||
1411 | |||
1412 | if (e->type == element_polyline) | ||
1413 | { | ||
1414 | e->u.polyline.width = e->u.polyline.width / 2; | ||
1415 | } | ||
1416 | |||
1417 | es = g_list_next(es); | ||
1418 | } | ||
1419 | } | ||
1420 | |||
1421 | itms = g_list_next(itms); | ||
1422 | } | ||
1423 | |||
1424 | } | ||
1425 | layers = g_list_next(layers); | ||
1426 | |||
1427 | } | ||
1428 | |||
1429 | } | ||
1430 | |||
1431 | |||
1432 | zoff99 | 40 | void navit_layer_toggle_active(struct navit *this, char *name, int draw) |
1433 | { | ||
1434 | if (name) | ||
1435 | { | ||
1436 | if (this->layout_current && this->layout_current->layers) | ||
1437 | { | ||
1438 | GList* layers = this->layout_current->layers; | ||
1439 | while (layers) | ||
1440 | { | ||
1441 | struct layer *l = layers->data; | ||
1442 | if (l && !strcmp(l->name, name)) | ||
1443 | { | ||
1444 | l->active ^= 1; | ||
1445 | if (draw == 1) | ||
1446 | { | ||
1447 | navit_draw(this); | ||
1448 | } | ||
1449 | return; | ||
1450 | } | ||
1451 | layers = g_list_next(layers); | ||
1452 | } | ||
1453 | } | ||
1454 | } | ||
1455 | } | ||
1456 | |||
1457 | |||
1458 | |||
1459 | zoff99 | 2 | /** |
1460 | zoff99 | 28 | * command to set the active state of a named layer of the current layout |
1461 | * | ||
1462 | * @param navit The navit instance | ||
1463 | * @param name name of the layer | ||
1464 | * @param active 0 -> inactive, 1 -> active | ||
1465 | * @param draw 0 -> dont redraw, 1 -> redraw | ||
1466 | * @returns nothing | ||
1467 | */ | ||
1468 | void navit_layer_set_active(struct navit *this, char *name, int active, int draw) | ||
1469 | { | ||
1470 | if (name) | ||
1471 | { | ||
1472 | if (this->layout_current && this->layout_current->layers) | ||
1473 | { | ||
1474 | GList* layers = this->layout_current->layers; | ||
1475 | while (layers) | ||
1476 | { | ||
1477 | struct layer *l = layers->data; | ||
1478 | if (l && !strcmp(l->name, name)) | ||
1479 | { | ||
1480 | l->active = active; | ||
1481 | if (draw == 1) | ||
1482 | { | ||
1483 | navit_draw(this); | ||
1484 | } | ||
1485 | return; | ||
1486 | } | ||
1487 | layers = g_list_next(layers); | ||
1488 | } | ||
1489 | } | ||
1490 | } | ||
1491 | } | ||
1492 | |||
1493 | /** | ||
1494 | zoff99 | 2 | * adds an item with the current coordinate of the vehicle to a named map |
1495 | * | ||
1496 | * @param navit The navit instance | ||
1497 | * @param function unused (needed to match command function signiture) | ||
1498 | * @param in input attribute in[0] is the name of the map | ||
1499 | * @param out output attribute, 0 on error or the id of the created item on success | ||
1500 | * @param valid unused | ||
1501 | * @returns nothing | ||
1502 | */ | ||
1503 | zoff99 | 27 | static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1504 | zoff99 | 2 | { |
1505 | struct attr **list = g_new0(struct attr *,2); | ||
1506 | struct attr*val = g_new0(struct attr,1); | ||
1507 | struct mapset* ms; | ||
1508 | struct map_selection sel; | ||
1509 | const int selection_range = 10; | ||
1510 | enum item_type item_type; | ||
1511 | struct item *it; | ||
1512 | struct map* curr_map = NULL; | ||
1513 | struct coord curr_coord; | ||
1514 | struct map_rect *mr; | ||
1515 | |||
1516 | zoff99 | 27 | val->type = attr_type_item_begin; |
1517 | val->u.item = NULL; //return invalid item on error | ||
1518 | list[0] = val; | ||
1519 | list[1] = NULL; | ||
1520 | zoff99 | 2 | *out = list; |
1521 | zoff99 | 27 | if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name |
1522 | in[1] && ATTR_IS_STRING(in[1]->type) && in[1]->u.str //item type | ||
1523 | ) | ||
1524 | { | ||
1525 | zoff99 | 2 | |
1526 | zoff99 | 27 | if (!(ms = navit_get_mapset(this))) |
1527 | { | ||
1528 | zoff99 | 2 | return; |
1529 | } | ||
1530 | |||
1531 | zoff99 | 27 | if ((item_type = item_from_name(in[1]->u.str)) == type_none) |
1532 | { | ||
1533 | zoff99 | 2 | return; |
1534 | } | ||
1535 | |||
1536 | curr_map = mapset_get_map_by_name(ms, in[0]->u.str); | ||
1537 | |||
1538 | //no map with the given name found | ||
1539 | zoff99 | 27 | if (!curr_map) |
1540 | { | ||
1541 | zoff99 | 2 | return; |
1542 | } | ||
1543 | zoff99 | 27 | |
1544 | if (this->vehicle && this->vehicle->vehicle) | ||
1545 | { | ||
1546 | zoff99 | 2 | struct attr pos_attr; |
1547 | zoff99 | 27 | if (vehicle_get_attr(this->vehicle->vehicle, attr_position_coord_geo, &pos_attr, NULL)) |
1548 | { | ||
1549 | zoff99 | 2 | transform_from_geo(projection_mg, pos_attr.u.coord_geo, &curr_coord); |
1550 | zoff99 | 27 | } |
1551 | else | ||
1552 | { | ||
1553 | zoff99 | 2 | return; |
1554 | } | ||
1555 | zoff99 | 27 | } |
1556 | else | ||
1557 | { | ||
1558 | zoff99 | 2 | return; |
1559 | } | ||
1560 | |||
1561 | zoff99 | 27 | sel.next = NULL; |
1562 | sel.order = 18; | ||
1563 | sel.range.min = type_none; | ||
1564 | sel.range.max = type_tec_common; | ||
1565 | sel.u.c_rect.lu.x = curr_coord.x - selection_range; | ||
1566 | sel.u.c_rect.lu.y = curr_coord.y + selection_range; | ||
1567 | sel.u.c_rect.rl.x = curr_coord.x + selection_range; | ||
1568 | sel.u.c_rect.rl.y = curr_coord.y - selection_range; | ||
1569 | |||
1570 | zoff99 | 2 | mr = map_rect_new(curr_map, &sel); |
1571 | zoff99 | 27 | if (mr) |
1572 | { | ||
1573 | it = map_rect_create_item(mr, item_type); | ||
1574 | item_coord_set(it, &curr_coord, 1, change_mode_modify); | ||
1575 | val->u.item = it; | ||
1576 | zoff99 | 2 | } |
1577 | map_rect_destroy(mr); | ||
1578 | zoff99 | 27 | } |
1579 | zoff99 | 2 | } |
1580 | |||
1581 | /** | ||
1582 | * sets an attribute (name value pair) of a map item specified by map name and item id | ||
1583 | * | ||
1584 | * @param navit The navit instance | ||
1585 | * @param function unused (needed to match command function signiture) | ||
1586 | * @param in input attribute in[0] - name of the map ; in[1] - item ; in[2] - attr name ; in[3] - attr value | ||
1587 | * @param out output attribute, 0 on error, 1 on success | ||
1588 | * @param valid unused | ||
1589 | * @returns nothing | ||
1590 | */ | ||
1591 | zoff99 | 27 | static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1592 | zoff99 | 2 | { |
1593 | zoff99 | 27 | if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name |
1594 | in[1] && ATTR_IS_ITEM(in[1]->type) && //item | ||
1595 | in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str | ||
1596 | in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str | ||
1597 | ) | ||
1598 | { | ||
1599 | zoff99 | 2 | struct attr attr_to_set; |
1600 | struct map* curr_map = NULL; | ||
1601 | struct mapset *ms; | ||
1602 | struct map_selection sel; | ||
1603 | const int selection_range = 500; | ||
1604 | struct coord curr_coord; | ||
1605 | struct item *it; | ||
1606 | zoff99 | 27 | |
1607 | if (ATTR_IS_STRING(attr_from_name(in[2]->u.str))) | ||
1608 | { | ||
1609 | zoff99 | 2 | attr_to_set.u.str = in[3]->u.str; |
1610 | attr_to_set.type = attr_from_name(in[2]->u.str); | ||
1611 | } | ||
1612 | zoff99 | 27 | else if (ATTR_IS_INT(attr_from_name(in[2]->u.str))) |
1613 | { | ||
1614 | zoff99 | 2 | attr_to_set.u.num = atoi(in[3]->u.str); |
1615 | attr_to_set.type = attr_from_name(in[2]->u.str); | ||
1616 | } | ||
1617 | zoff99 | 27 | else if (ATTR_IS_DOUBLE(attr_from_name(in[2]->u.str))) |
1618 | { | ||
1619 | zoff99 | 2 | double* val = g_new0(double,1); |
1620 | *val = atof(in[3]->u.str); | ||
1621 | attr_to_set.u.numd = val; | ||
1622 | attr_to_set.type = attr_from_name(in[2]->u.str); | ||
1623 | } | ||
1624 | |||
1625 | ms = navit_get_mapset(this); | ||
1626 | |||
1627 | curr_map = mapset_get_map_by_name(ms, in[0]->u.str); | ||
1628 | |||
1629 | zoff99 | 27 | if (!curr_map) |
1630 | { | ||
1631 | zoff99 | 2 | return; |
1632 | } | ||
1633 | zoff99 | 27 | sel.next = NULL; |
1634 | sel.order = 18; | ||
1635 | sel.range.min = type_none; | ||
1636 | sel.range.max = type_tec_common; | ||
1637 | sel.u.c_rect.lu.x = curr_coord.x - selection_range; | ||
1638 | sel.u.c_rect.lu.y = curr_coord.y + selection_range; | ||
1639 | sel.u.c_rect.rl.x = curr_coord.x + selection_range; | ||
1640 | sel.u.c_rect.rl.y = curr_coord.y - selection_range; | ||
1641 | |||
1642 | zoff99 | 2 | it = in[1]->u.item; |
1643 | zoff99 | 27 | if (it) |
1644 | { | ||
1645 | zoff99 | 2 | item_attr_set(it, &attr_to_set, change_mode_modify); |
1646 | } | ||
1647 | } | ||
1648 | } | ||
1649 | |||
1650 | /** | ||
1651 | * Get attr variable given a key string for the command system (for opaque usage) | ||
1652 | * | ||
1653 | * @param navit The navit instance | ||
1654 | * @param function unused (needed to match command function signiture) | ||
1655 | * @param in input attribute in[0] is the key string | ||
1656 | * @param out output attribute, the attr for the given key string if exists or NULL | ||
1657 | * @param valid unused | ||
1658 | * @returns nothing | ||
1659 | */ | ||
1660 | zoff99 | 27 | static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1661 | zoff99 | 2 | { |
1662 | struct attr **list = g_new0(struct attr *,2); | ||
1663 | zoff99 | 27 | if (!cmd_int_var_hash) |
1664 | { | ||
1665 | zoff99 | 2 | struct attr*val = g_new0(struct attr,1); |
1666 | zoff99 | 27 | val->type = attr_type_item_begin; |
1667 | zoff99 | 2 | val->u.item = NULL; |
1668 | zoff99 | 27 | list[0] = val; |
1669 | zoff99 | 2 | } |
1670 | zoff99 | 27 | if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1671 | { | ||
1672 | zoff99 | 2 | struct attr*ret = g_hash_table_lookup(cmd_attr_var_hash, in[0]->u.str); |
1673 | zoff99 | 27 | if (ret) |
1674 | { | ||
1675 | zoff99 | 2 | list[0] = attr_dup(ret); |
1676 | } | ||
1677 | zoff99 | 27 | else |
1678 | { | ||
1679 | zoff99 | 2 | struct attr*val = g_new0(struct attr,1); |
1680 | zoff99 | 27 | val->type = attr_type_int_begin; |
1681 | zoff99 | 2 | val->u.item = NULL; |
1682 | zoff99 | 27 | list[0] = val; |
1683 | zoff99 | 2 | } |
1684 | zoff99 | 27 | } |
1685 | zoff99 | 2 | list[1] = NULL; |
1686 | *out = list; | ||
1687 | } | ||
1688 | |||
1689 | /** | ||
1690 | * Get value given a key string for the command system | ||
1691 | * | ||
1692 | * @param navit The navit instance | ||
1693 | * @param function unused (needed to match command function signiture) | ||
1694 | * @param in input attribute in[0] is the key string | ||
1695 | * @param out output attribute, the value for the given key string if exists or 0 | ||
1696 | * @param valid unused | ||
1697 | * @returns nothing | ||
1698 | */ | ||
1699 | zoff99 | 27 | static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1700 | zoff99 | 2 | { |
1701 | struct attr **list = g_new0(struct attr *,2); | ||
1702 | zoff99 | 27 | if (!cmd_int_var_hash) |
1703 | { | ||
1704 | zoff99 | 2 | struct attr*val = g_new0(struct attr,1); |
1705 | zoff99 | 27 | val->type = attr_type_int_begin; |
1706 | val->u.num = 0; | ||
1707 | list[0] = val; | ||
1708 | zoff99 | 2 | } |
1709 | zoff99 | 27 | if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) |
1710 | { | ||
1711 | zoff99 | 2 | struct attr*ret = g_hash_table_lookup(cmd_int_var_hash, in[0]->u.str); |
1712 | zoff99 | 27 | if (ret) |
1713 | { | ||
1714 | zoff99 | 2 | list[0] = ret; |
1715 | } | ||
1716 | zoff99 | 27 | else |
1717 | { | ||
1718 | zoff99 | 2 | struct attr*val = g_new0(struct attr,1); |
1719 | zoff99 | 27 | val->type = attr_type_int_begin; |
1720 | val->u.num = 0; | ||
1721 | list[0] = val; | ||
1722 | zoff99 | 2 | } |
1723 | zoff99 | 27 | } |
1724 | zoff99 | 2 | list[1] = NULL; |
1725 | *out = list; | ||
1726 | } | ||
1727 | |||
1728 | GList *cmd_int_var_stack = NULL; | ||
1729 | |||
1730 | /** | ||
1731 | * Push an integer to the stack for the command system | ||
1732 | * | ||
1733 | * @param navit The navit instance | ||
1734 | * @param function unused (needed to match command function signiture) | ||
1735 | * @param in input attribute in[0] is the integer attibute to push | ||
1736 | * @param out output attributes, unused | ||
1737 | * @param valid unused | ||
1738 | * @returns nothing | ||
1739 | */ | ||
1740 | zoff99 | 27 | static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1741 | zoff99 | 2 | { |
1742 | zoff99 | 27 | if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type)) |
1743 | { | ||
1744 | zoff99 | 2 | struct attr*val = g_new(struct attr,1); |
1745 | zoff99 | 27 | attr_dup_content(in[0], val); |
1746 | zoff99 | 2 | cmd_int_var_stack = g_list_prepend(cmd_int_var_stack, val); |
1747 | } | ||
1748 | } | ||
1749 | |||
1750 | /** | ||
1751 | * Pop an integer from the command system's integer stack | ||
1752 | * | ||
1753 | * @param navit The navit instance | ||
1754 | * @param function unused (needed to match command function signiture) | ||
1755 | * @param in input attributes unused | ||
1756 | * @param out output attribute, the value popped if stack isn't empty or 0 | ||
1757 | * @param valid unused | ||
1758 | * @returns nothing | ||
1759 | */ | ||
1760 | zoff99 | 27 | static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1761 | zoff99 | 2 | { |
1762 | struct attr **list = g_new0(struct attr *,2); | ||
1763 | zoff99 | 27 | if (!cmd_int_var_stack) |
1764 | { | ||
1765 | zoff99 | 2 | struct attr*val = g_new0(struct attr,1); |
1766 | val->type = attr_type_int_begin; | ||
1767 | zoff99 | 27 | val->u.num = 0; |
1768 | list[0] = val; | ||
1769 | zoff99 | 2 | } |
1770 | zoff99 | 27 | else |
1771 | { | ||
1772 | zoff99 | 2 | list[0] = cmd_int_var_stack->data; |
1773 | zoff99 | 27 | cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack); |
1774 | zoff99 | 2 | } |
1775 | list[1] = NULL; | ||
1776 | *out = list; | ||
1777 | } | ||
1778 | |||
1779 | /** | ||
1780 | * Get current size of command system's integer stack | ||
1781 | * | ||
1782 | * @param navit The navit instance | ||
1783 | * @param function unused (needed to match command function signiture) | ||
1784 | * @param in input attributes unused | ||
1785 | * @param out output attribute, the size of stack | ||
1786 | * @param valid unused | ||
1787 | * @returns nothing | ||
1788 | */ | ||
1789 | zoff99 | 27 | static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1790 | zoff99 | 2 | { |
1791 | struct attr **list; | ||
1792 | zoff99 | 27 | struct attr *attr = g_new0(struct attr ,1); |
1793 | attr->type = attr_type_int_begin; | ||
1794 | if (!cmd_int_var_stack) | ||
1795 | { | ||
1796 | attr->u.num = 0; | ||
1797 | zoff99 | 2 | } |
1798 | zoff99 | 27 | else |
1799 | { | ||
1800 | attr->u.num = g_list_length(cmd_int_var_stack); | ||
1801 | }list = g_new0(struct attr *,2); | ||
1802 | zoff99 | 2 | list[0] = attr; |
1803 | list[1] = NULL; | ||
1804 | *out = list; | ||
1805 | zoff99 | 27 | cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack); |
1806 | zoff99 | 2 | } |
1807 | |||
1808 | zoff99 | 27 | static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1809 | zoff99 | 2 | { |
1810 | struct pcoord pc; | ||
1811 | zoff99 | 27 | char *description = NULL; |
1812 | zoff99 | 2 | if (!in) |
1813 | return; | ||
1814 | if (!in[0]) | ||
1815 | return; | ||
1816 | pc.pro = transform_get_projection(this->trans); | ||
1817 | zoff99 | 27 | if (ATTR_IS_COORD(in[0]->type)) |
1818 | { | ||
1819 | pc.x = in[0]->u.coord->x; | ||
1820 | pc.y = in[0]->u.coord->y; | ||
1821 | zoff99 | 2 | in++; |
1822 | zoff99 | 27 | } |
1823 | else if (ATTR_IS_PCOORD(in[0]->type)) | ||
1824 | { | ||
1825 | pc = *in[0]->u.pcoord; | ||
1826 | zoff99 | 2 | in++; |
1827 | zoff99 | 27 | } |
1828 | else if (in[1] && in[2] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type) && ATTR_IS_INT(in[2]->type)) | ||
1829 | { | ||
1830 | pc.pro = in[0]->u.num; | ||
1831 | pc.x = in[1]->u.num; | ||
1832 | pc.y = in[2]->u.num; | ||
1833 | in += 3; | ||
1834 | } | ||
1835 | else if (in[1] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type)) | ||
1836 | { | ||
1837 | pc.x = in[0]->u.num; | ||
1838 | pc.y = in[1]->u.num; | ||
1839 | in += 2; | ||
1840 | } | ||
1841 | else | ||
1842 | { | ||
1843 | zoff99 | 2 | return; |
1844 | zoff99 | 27 | } |
1845 | zoff99 | 2 | if (in[0] && ATTR_IS_STRING(in[0]->type)) |
1846 | zoff99 | 27 | { |
1847 | description = in[0]->u.str; | ||
1848 | } | ||
1849 | zoff99 | 2 | navit_set_destination(this, &pc, description, 1); |
1850 | } | ||
1851 | |||
1852 | zoff99 | 27 | static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1853 | zoff99 | 2 | { |
1854 | struct attr attr; | ||
1855 | zoff99 | 27 | attr.type = attr_type_string_begin; |
1856 | attr.u.str = "Fix me"; | ||
1857 | if (out) | ||
1858 | { | ||
1859 | *out = attr_generic_add_attr(*out, &attr); | ||
1860 | zoff99 | 2 | } |
1861 | } | ||
1862 | |||
1863 | /** | ||
1864 | * Join several string attributes into one | ||
1865 | * | ||
1866 | * @param navit The navit instance | ||
1867 | * @param function unused (needed to match command function signiture) | ||
1868 | * @param in input attributes in[0] - separator, in[1..] - attributes to join | ||
1869 | * @param out output attribute joined attribute as string | ||
1870 | * @param valid unused | ||
1871 | * @returns nothing | ||
1872 | */ | ||
1873 | zoff99 | 27 | static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1874 | zoff99 | 2 | { |
1875 | struct attr attr; | ||
1876 | gchar *ret, *sep; | ||
1877 | int i; | ||
1878 | zoff99 | 27 | attr.type = attr_type_string_begin; |
1879 | attr.u.str = NULL; | ||
1880 | if (in[0] && in[1]) | ||
1881 | { | ||
1882 | sep = attr_to_text(in[0], NULL, 1); | ||
1883 | ret = attr_to_text(in[1], NULL, 1); | ||
1884 | for (i = 2; in[i]; i++) | ||
1885 | { | ||
1886 | gchar *in_i = attr_to_text(in[i], NULL, 1); | ||
1887 | gchar *r = g_strjoin(sep, ret, in_i, NULL); | ||
1888 | zoff99 | 2 | g_free(in_i); |
1889 | g_free(ret); | ||
1890 | zoff99 | 27 | ret = r; |
1891 | zoff99 | 2 | } |
1892 | g_free(sep); | ||
1893 | zoff99 | 27 | attr.u.str = ret; |
1894 | if (out) | ||
1895 | { | ||
1896 | *out = attr_generic_add_attr(*out, &attr); | ||
1897 | zoff99 | 2 | } |
1898 | g_free(ret); | ||
1899 | } | ||
1900 | } | ||
1901 | |||
1902 | /** | ||
1903 | * Call external program | ||
1904 | * | ||
1905 | * @param navit The navit instance | ||
1906 | * @param function unused (needed to match command function signiture) | ||
1907 | * @param in input attributes in[0] - name of executable, in[1..] - parameters | ||
1908 | * @param out output attribute unused | ||
1909 | * @param valid unused | ||
1910 | * @returns nothing | ||
1911 | */ | ||
1912 | zoff99 | 27 | static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) |
1913 | zoff99 | 2 | { |
1914 | zoff99 | 27 | int i, j, nparms, nvalid; |
1915 | const char ** argv = NULL; | ||
1916 | zoff99 | 2 | struct spawn_process_info *pi; |
1917 | |||
1918 | zoff99 | 27 | nparms = 0; |
1919 | nvalid = 0; | ||
1920 | if (in) | ||
1921 | { | ||
1922 | while (in[nparms]) | ||
1923 | { | ||
1924 | if (in[nparms]->type != attr_none) | ||
1925 | zoff99 | 2 | nvalid++; |
1926 | nparms++; | ||
1927 | } | ||
1928 | } | ||
1929 | zoff99 | 27 | |
1930 | if (nvalid > 0) | ||
1931 | { | ||
1932 | zoff99 | 2 | argv=g_new(char*,nvalid+1); |
1933 | zoff99 | 27 | for (i = 0, j = 0; in[i]; i++) |
1934 | { | ||
1935 | if (in[i]->type != attr_none) | ||
1936 | { | ||
1937 | argv[j++] = attr_to_text(in[i], NULL, 1); | ||
1938 | zoff99 | 2 | } |
1939 | zoff99 | 27 | else |
1940 | { | ||
1941 | //DBG dbg(0, "Parameter #%i is attr_none - skipping\n", i); | ||
1942 | } | ||
1943 | zoff99 | 2 | } |
1944 | zoff99 | 27 | argv[j] = NULL; |
1945 | pi = spawn_process(argv); | ||
1946 | |||
1947 | zoff99 | 2 | // spawn_process() testing suite - uncomment following code to test. |
1948 | //sleep(3); | ||
1949 | // example of non-blocking wait | ||
1950 | zoff99 | 27 | //int st=spawn_process_check_status(pi,0);//DBG dbg(0,"status %i\n",st); |
1951 | zoff99 | 2 | // example of blocking wait |
1952 | zoff99 | 27 | //st=spawn_process_check_status(pi,1);//DBG dbg(0,"status %i\n",st); |
1953 | zoff99 | 2 | // example of wait after process is finished and status is |
1954 | // already tested | ||
1955 | zoff99 | 27 | //st=spawn_process_check_status(pi,1);//DBG dbg(0,"status %i\n",st); |
1956 | zoff99 | 2 | // example of wait after process is finished and status is |
1957 | // already tested - unblocked | ||
1958 | zoff99 | 27 | //st=spawn_process_check_status(pi,0);//DBG dbg(0,"status %i\n",st); |
1959 | |||
1960 | zoff99 | 2 | // End testing suite |
1961 | spawn_process_info_free(pi); | ||
1962 | zoff99 | 27 | for (i = 0; argv[i]; i++) |
1963 | zoff99 | 2 | g_free(argv[i]); |
1964 | g_free(argv); | ||
1965 | } | ||
1966 | } | ||
1967 | |||
1968 | zoff99 | 30 | static struct command_table |
1969 | commands[] = | ||
1970 | { { "zoom_in", command_cast(navit_cmd_zoom_in) }, { "zoom_out", command_cast(navit_cmd_zoom_out) }, { "zoom_to_route", command_cast(navit_cmd_zoom_to_route) }, { "say", command_cast(navit_cmd_say) }, { "set_center_cursor", command_cast(navit_cmd_set_center_cursor) }, { "set_destination", command_cast(navit_cmd_set_destination) }, { "announcer_toggle", command_cast(navit_cmd_announcer_toggle) }, { "fmt_coordinates", command_cast(navit_cmd_fmt_coordinates) }, { "set_int_var", command_cast(navit_cmd_set_int_var) }, { "get_int_var", command_cast(navit_cmd_get_int_var) }, { "push_int", command_cast(navit_cmd_push_int) }, { "pop_int", command_cast(navit_cmd_pop_int) }, { "int_stack_size", command_cast(navit_cmd_int_stack_size) }, { "toggle_layer", command_cast(navit_cmd_toggle_layer) }, { "strjoin", command_cast(navit_cmd_strjoin) }, { "spawn", command_cast(navit_cmd_spawn) }, { "map_add_curr_pos", command_cast(navit_cmd_map_add_curr_pos) }, { "map_item_set_attr", command_cast(navit_cmd_map_item_set_attr) }, { "set_attr_var", command_cast(navit_cmd_set_attr_var) }, { "get_attr_var", command_cast(navit_cmd_get_attr_var) }, }; | ||
1971 | zoff99 | 2 | |
1972 | zoff99 | 27 | void navit_command_add_table(struct navit*this_, struct command_table *commands, int count) |
1973 | zoff99 | 2 | { |
1974 | zoff99 | 27 | command_add_table(this_->attr_cbl, commands, count, this_); |
1975 | zoff99 | 2 | } |
1976 | |||
1977 | zoff99 | 40 | |
1978 | zoff99 | 2 | struct navit * |
1979 | navit_new(struct attr *parent, struct attr **attrs) | ||
1980 | { | ||
1981 | struct navit *this_=g_new0(struct navit, 1); | ||
1982 | struct pcoord center; | ||
1983 | struct coord co; | ||
1984 | struct coord_geo g; | ||
1985 | zoff99 | 27 | enum projection pro = projection_mg; |
1986 | zoff99 | 2 | int zoom = 256; |
1987 | zoff99 | 27 | g.lat = 53.13; |
1988 | g.lng = 11.70; | ||
1989 | zoff99 | 2 | |
1990 | zoff99 | 40 | |
1991 | global_demo_vehicle = 0; | ||
1992 | global_demo_vehicle_short_switch = 0; | ||
1993 | |||
1994 | |||
1995 | // set base for timestamps | ||
1996 | struct timeval tv2; | ||
1997 | if (gettimeofday(&tv2, NULL) == -1) | ||
1998 | { | ||
1999 | global_last_spoken_base = 0; | ||
2000 | } | ||
2001 | else | ||
2002 | { | ||
2003 | global_last_spoken_base = (long)tv2.tv_sec; | ||
2004 | } | ||
2005 | |||
2006 | global_debug_coord_list = g_new0(struct coord, (2 * (MAX_DEBUG_COORDS + 2))); | ||
2007 | global_debug_coord_list_items = 0; | ||
2008 | |||
2009 | global_debug_route_seg_winner_start.x = 0; | ||
2010 | global_debug_route_seg_winner_start.y = 0; | ||
2011 | global_debug_route_seg_winner_end.x = 0; | ||
2012 | global_debug_route_seg_winner_end.y = 0; | ||
2013 | |||
2014 | global_debug_seg_winner_start.x = 0; | ||
2015 | global_debug_seg_winner_start.y = 0; | ||
2016 | global_debug_seg_winner_end.x = 0; | ||
2017 | global_debug_seg_winner_end.y = 0; | ||
2018 | |||
2019 | global_debug_route_seg_winner_p_start.x = 0; | ||
2020 | global_debug_route_seg_winner_p_start.y = 0; | ||
2021 | |||
2022 | global_debug_seg_winner_p_start.x = 0; | ||
2023 | global_debug_seg_winner_p_start.y = 0; | ||
2024 | |||
2025 | global_debug_seg_route_start.x = 0; | ||
2026 | global_debug_seg_route_start.y = 0; | ||
2027 | |||
2028 | global_debug_seg_route_end.x = 0; | ||
2029 | global_debug_seg_route_end.y = 0; | ||
2030 | |||
2031 | |||
2032 | |||
2033 | zoff99 | 27 | this_->self.type = attr_navit; |
2034 | this_->self.u.navit = this_; | ||
2035 | zoff99 | 40 | this_->attr_cbl = callback_list_new("navit_new:this_->attr_cbl"); |
2036 | zoff99 | 2 | |
2037 | zoff99 | 27 | this_->orientation = -1; |
2038 | this_->tracking_flag = 1; | ||
2039 | this_->recentdest_count = 10; | ||
2040 | this_->osd_configuration = -1; | ||
2041 | zoff99 | 2 | |
2042 | // changed default to 1 | ||
2043 | this_->center_timeout = 1; | ||
2044 | this_->use_mousewheel = 1; | ||
2045 | this_->autozoom_secs = 10; | ||
2046 | zoff99 | 41 | this_->autozoom_min = 5; |
2047 | zoff99 | 2 | this_->autozoom_active = 0; |
2048 | this_->zoom_min = 1; | ||
2049 | this_->zoom_max = 1048576; //-> order=-2 // 2097152 -> order=-3; | ||
2050 | this_->follow_cursor = 1; | ||
2051 | this_->radius = 30; | ||
2052 | this_->border = 16; | ||
2053 | |||
2054 | zoff99 | 30 | // dbg(0, "GGGGG:set global_navit\n"); |
2055 | global_navit = this_; | ||
2056 | |||
2057 | zoff99 | 2 | this_->trans = transform_new(); |
2058 | this_->trans_cursor = transform_new(); | ||
2059 | transform_from_geo(pro, &g, &co); | ||
2060 | zoff99 | 27 | center.x = co.x; |
2061 | center.y = co.y; | ||
2062 | zoff99 | 2 | center.pro = pro; |
2063 | |||
2064 | zoff99 | 31 | transform_init(); |
2065 | |||
2066 | zoff99 | 27 | //DBG dbg(0, "setting center from xmlfile [hardcoded]\n"); |
2067 | zoff99 | 2 | transform_setup(this_->trans, ¢er, zoom, (this_->orientation != -1) ? this_->orientation : 0); |
2068 | |||
2069 | zoff99 | 31 | // initialze trans_cursor here |
2070 | zoff99 | 2 | transform_copy(this_->trans, this_->trans_cursor); |
2071 | zoff99 | 31 | // initialze trans_cursor here |
2072 | zoff99 | 2 | |
2073 | zoff99 | 31 | |
2074 | dbg(0, "ii 001\n"); | ||
2075 | zoff99 | 27 | this_->bookmarks = bookmarks_new(&this_->self, NULL, this_->trans); |
2076 | zoff99 | 31 | //this_->bookmarks = NULL; |
2077 | dbg(0, "ii 002\n"); | ||
2078 | zoff99 | 2 | |
2079 | zoff99 | 27 | this_->prevTs = 0; |
2080 | zoff99 | 2 | |
2081 | zoff99 | 27 | for (; *attrs; attrs++) |
2082 | { | ||
2083 | zoff99 | 2 | navit_set_attr_do(this_, *attrs, 1); |
2084 | } | ||
2085 | zoff99 | 27 | this_->displaylist = graphics_displaylist_new(); |
2086 | command_add_table(this_->attr_cbl, commands, sizeof(commands) / sizeof(struct command_table), this_); | ||
2087 | zoff99 | 2 | |
2088 | zoff99 | 31 | dbg(0, "ii 009\n"); |
2089 | |||
2090 | zoff99 | 27 | // this_->messages = messagelist_new(attrs); |
2091 | zoff99 | 2 | |
2092 | zoff99 | 31 | dbg(0, "111111\n"); |
2093 | zoff99 | 27 | |
2094 | zoff99 | 2 | return this_; |
2095 | } | ||
2096 | |||
2097 | zoff99 | 27 | static int navit_set_gui(struct navit *this_, struct gui *gui) |
2098 | zoff99 | 2 | { |
2099 | if (this_->gui) | ||
2100 | return 0; | ||
2101 | zoff99 | 40 | |
2102 | zoff99 | 27 | this_->gui = gui; |
2103 | zoff99 | 40 | |
2104 | zoff99 | 27 | if (gui_has_main_loop(this_->gui)) |
2105 | { | ||
2106 | if (!main_loop_gui) | ||
2107 | { | ||
2108 | main_loop_gui = this_->gui; | ||
2109 | } | ||
2110 | else | ||
2111 | { | ||
2112 | //DBG dbg(0, "gui with main loop already active, ignoring this instance"); | ||
2113 | zoff99 | 2 | return 0; |
2114 | } | ||
2115 | } | ||
2116 | return 1; | ||
2117 | } | ||
2118 | |||
2119 | zoff99 | 27 | void navit_add_message(struct navit *this_, char *message) |
2120 | zoff99 | 2 | { |
2121 | zoff99 | 27 | // message_new(this_->messages, message); |
2122 | zoff99 | 2 | } |
2123 | |||
2124 | zoff99 | 27 | struct message *navit_get_messages(struct navit *this_) |
2125 | zoff99 | 2 | { |
2126 | zoff99 | 27 | // return message_get(this_->messages); |
2127 | zoff99 | 2 | } |
2128 | |||
2129 | zoff99 | 27 | static int navit_set_graphics(struct navit *this_, struct graphics *gra) |
2130 | zoff99 | 2 | { |
2131 | if (this_->gra) | ||
2132 | zoff99 | 40 | { |
2133 | zoff99 | 2 | return 0; |
2134 | zoff99 | 40 | } |
2135 | |||
2136 | zoff99 | 27 | this_->gra = gra; |
2137 | zoff99 | 28 | |
2138 | /* | ||
2139 | zoff99 | 30 | this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_); |
2140 | graphics_add_callback(gra, this_->resize_callback); | ||
2141 | this_->button_callback = callback_new_attr_1(callback_cast(navit_button), attr_button, this_); | ||
2142 | graphics_add_callback(gra, this_->button_callback); | ||
2143 | this_->motion_callback = callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_); | ||
2144 | graphics_add_callback(gra, this_->motion_callback); | ||
2145 | */ | ||
2146 | zoff99 | 28 | |
2147 | // this draw the vehicle // very stupid | ||
2148 | zoff99 | 27 | this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_); |
2149 | zoff99 | 30 | callback_add_names(this_->predraw_callback, "navit_set_graphics", "navit_predraw"); |
2150 | zoff99 | 2 | graphics_add_callback(gra, this_->predraw_callback); |
2151 | zoff99 | 28 | |
2152 | zoff99 | 2 | return 1; |
2153 | } | ||
2154 | |||
2155 | struct graphics * | ||
2156 | navit_get_graphics(struct navit *this_) | ||
2157 | { | ||
2158 | return this_->gra; | ||
2159 | } | ||
2160 | |||
2161 | struct vehicleprofile * | ||
2162 | navit_get_vehicleprofile(struct navit *this_) | ||
2163 | { | ||
2164 | return this_->vehicleprofile; | ||
2165 | } | ||
2166 | |||
2167 | GList * | ||
2168 | navit_get_vehicleprofiles(struct navit *this_) | ||
2169 | { | ||
2170 | return this_->vehicleprofiles; | ||
2171 | } | ||
2172 | |||
2173 | zoff99 | 27 | static void navit_projection_set(struct navit *this_, enum projection pro, int draw) |
2174 | zoff99 | 2 | { |
2175 | zoff99 | 40 | |
2176 | |||
2177 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2178 | zoff99 | 2 | struct coord_geo g; |
2179 | struct coord *c; | ||
2180 | |||
2181 | zoff99 | 27 | c = transform_center(this_->trans); |
2182 | zoff99 | 2 | transform_to_geo(transform_get_projection(this_->trans), c, &g); |
2183 | transform_set_projection(this_->trans, pro); | ||
2184 | transform_from_geo(pro, &g, c); | ||
2185 | if (draw) | ||
2186 | zoff99 | 28 | { |
2187 | zoff99 | 2 | navit_draw(this_); |
2188 | zoff99 | 28 | } |
2189 | zoff99 | 2 | } |
2190 | |||
2191 | /** | ||
2192 | * Start the route computing to a given set of coordinates | ||
2193 | * | ||
2194 | * @param navit The navit instance | ||
2195 | * @param c The coordinate to start routing to | ||
2196 | * @param description A label which allows the user to later identify this destination in the former destinations selection | ||
2197 | * @returns nothing | ||
2198 | */ | ||
2199 | zoff99 | 27 | void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async) |
2200 | zoff99 | 2 | { |
2201 | zoff99 | 40 | |
2202 | |||
2203 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2204 | zoff99 | 2 | char *destination_file; |
2205 | zoff99 | 27 | if (c) |
2206 | { | ||
2207 | this_->destination = *c; | ||
2208 | this_->destination_valid = 1; | ||
2209 | //dbg(0, "navit->navit_set_destination %i\n", c->x); | ||
2210 | //dbg(0, "navit->navit_set_destination %i\n", c->y); | ||
2211 | } | ||
2212 | else | ||
2213 | { | ||
2214 | this_->destination_valid = 0; | ||
2215 | } | ||
2216 | //destination_file = bookmarks_get_destination_file(TRUE); | ||
2217 | //bookmarks_append_coord(this_->bookmarks, destination_file, c, 1, "former_destination", description, NULL, this_->recentdest_count); | ||
2218 | //g_free(destination_file); | ||
2219 | callback_list_call_attr_0(this_->attr_cbl, attr_destination); | ||
2220 | if (this_->route) | ||
2221 | { | ||
2222 | //dbg(0, "navit->navit_set_destination 2: %i %i\n", c->x, c->y); | ||
2223 | zoff99 | 2 | |
2224 | route_set_destination(this_->route, c, async); | ||
2225 | if (this_->ready == 3) | ||
2226 | zoff99 | 27 | { |
2227 | zoff99 | 2 | navit_draw(this_); |
2228 | zoff99 | 27 | } |
2229 | zoff99 | 2 | } |
2230 | } | ||
2231 | |||
2232 | /** | ||
2233 | zoff99 | 27 | * add a waypoint to an active route |
2234 | * | ||
2235 | * @param navit The navit instance | ||
2236 | * @param c The coordinate of the waypoint | ||
2237 | * @param description A dummy string | ||
2238 | * @returns nothing | ||
2239 | */ | ||
2240 | void navit_add_waypoint_to_route(struct navit *this_, struct pcoord *c, const char *description, int async) | ||
2241 | { | ||
2242 | zoff99 | 40 | |
2243 | |||
2244 | zoff99 | 27 | if (this_->destination_valid == 1) |
2245 | { | ||
2246 | //int count = 0; | ||
2247 | //count = g_list_length(this_->route->destinations); | ||
2248 | //DBG dbg(0, "count=%d\n", count); | ||
2249 | |||
2250 | //dbg(0, "navit->navit_add_waypoint_to_route 1: %i %i\n", c->x, c->y); | ||
2251 | |||
2252 | route_add_destination(this_->route, c, async); | ||
2253 | |||
2254 | this_->destination = *c; | ||
2255 | this_->destination_valid = 1; | ||
2256 | } | ||
2257 | else | ||
2258 | { | ||
2259 | //dbg(0, "navit->navit_add_waypoint_to_route 2: %i %i\n", c->x, c->y); | ||
2260 | navit_set_destination(this_, c, description, async); | ||
2261 | } | ||
2262 | } | ||
2263 | |||
2264 | /** | ||
2265 | zoff99 | 2 | * Start the route computing to a given set of coordinates including waypoints |
2266 | * | ||
2267 | * @param navit The navit instance | ||
2268 | * @param c The coordinate to start routing to | ||
2269 | * @param description A label which allows the user to later identify this destination in the former destinations selection | ||
2270 | * @returns nothing | ||
2271 | */ | ||
2272 | zoff99 | 27 | void navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async) |
2273 | zoff99 | 2 | { |
2274 | zoff99 | 40 | |
2275 | |||
2276 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2277 | zoff99 | 2 | char *destination_file; |
2278 | zoff99 | 27 | if (c && count) |
2279 | { | ||
2280 | this_->destination = c[count - 1]; | ||
2281 | this_->destination_valid = 1; | ||
2282 | //dbg(0, "navit->navit_set_destinations 1: %i %i\n", c[count-1].x, c[count-1].y); | ||
2283 | } | ||
2284 | else | ||
2285 | { | ||
2286 | this_->destination_valid = 0; | ||
2287 | } | ||
2288 | //destination_file = bookmarks_get_destination_file(TRUE); | ||
2289 | //bookmarks_append_coord(this_->bookmarks, destination_file, c, count, "former_itinerary", description, NULL, this_->recentdest_count); | ||
2290 | //g_free(destination_file); | ||
2291 | zoff99 | 2 | callback_list_call_attr_0(this_->attr_cbl, attr_destination); |
2292 | zoff99 | 27 | if (this_->route) |
2293 | { | ||
2294 | zoff99 | 2 | route_set_destinations(this_->route, c, count, async); |
2295 | if (this_->ready == 3) | ||
2296 | zoff99 | 27 | { |
2297 | zoff99 | 2 | navit_draw(this_); |
2298 | zoff99 | 27 | } |
2299 | zoff99 | 2 | } |
2300 | } | ||
2301 | |||
2302 | /** | ||
2303 | * @brief Checks if a route is calculated | ||
2304 | * | ||
2305 | * This function checks if a route is calculated. | ||
2306 | * | ||
2307 | * @param this_ The navit struct whose route should be checked. | ||
2308 | * @return True if the route is set, false otherwise. | ||
2309 | */ | ||
2310 | zoff99 | 27 | int navit_check_route(struct navit *this_) |
2311 | zoff99 | 2 | { |
2312 | zoff99 | 40 | |
2313 | |||
2314 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2315 | if (this_->route) | ||
2316 | { | ||
2317 | zoff99 | 2 | return route_get_path_set(this_->route); |
2318 | } | ||
2319 | |||
2320 | return 0; | ||
2321 | } | ||
2322 | |||
2323 | zoff99 | 27 | static int navit_former_destinations_active(struct navit *this_) |
2324 | zoff99 | 2 | { |
2325 | zoff99 | 40 | |
2326 | |||
2327 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2328 | |||
2329 | return 0; | ||
2330 | // disable this function!! | ||
2331 | |||
2332 | |||
2333 | zoff99 | 2 | char *destination_file = bookmarks_get_destination_file(FALSE); |
2334 | FILE *f; | ||
2335 | zoff99 | 27 | int active = 0; |
2336 | zoff99 | 2 | char buffer[3]; |
2337 | zoff99 | 27 | f = fopen(destination_file, "r"); |
2338 | if (f) | ||
2339 | { | ||
2340 | if (!fseek(f, -2, SEEK_END) && fread(buffer, 2, 1, f) == 1 && (buffer[0] != '\n' || buffer[1] != '\n')) | ||
2341 | { | ||
2342 | active = 1; | ||
2343 | } | ||
2344 | zoff99 | 2 | fclose(f); |
2345 | } | ||
2346 | g_free(destination_file); | ||
2347 | zoff99 | 27 | |
2348 | zoff99 | 2 | return active; |
2349 | } | ||
2350 | |||
2351 | zoff99 | 27 | static void navit_add_former_destinations_from_file(struct navit *this_) |
2352 | zoff99 | 2 | { |
2353 | zoff99 | 40 | |
2354 | |||
2355 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2356 | zoff99 | 2 | char *destination_file = bookmarks_get_destination_file(FALSE); |
2357 | struct attr *attrs[4]; | ||
2358 | struct map_rect *mr; | ||
2359 | struct item *item; | ||
2360 | zoff99 | 27 | int i, valid = 0, count = 0; |
2361 | zoff99 | 2 | struct coord c[16]; |
2362 | struct pcoord pc[16]; | ||
2363 | struct attr parent; | ||
2364 | struct attr type; | ||
2365 | struct attr data; | ||
2366 | struct attr flags; | ||
2367 | |||
2368 | zoff99 | 27 | parent.type = attr_navit; |
2369 | parent.u.navit = this_; | ||
2370 | zoff99 | 2 | |
2371 | zoff99 | 27 | type.type = attr_type; |
2372 | type.u.str = "textfile"; | ||
2373 | zoff99 | 2 | |
2374 | zoff99 | 27 | data.type = attr_data; |
2375 | data.u.str = destination_file; | ||
2376 | zoff99 | 2 | |
2377 | zoff99 | 27 | flags.type = attr_flags; |
2378 | flags.u.num = 1; | ||
2379 | zoff99 | 2 | |
2380 | zoff99 | 27 | attrs[0] = &type; |
2381 | attrs[1] = &data; | ||
2382 | attrs[2] = &flags; | ||
2383 | attrs[3] = NULL; | ||
2384 | zoff99 | 2 | |
2385 | zoff99 | 27 | this_->former_destination = map_new(&parent, attrs); |
2386 | zoff99 | 2 | g_free(destination_file); |
2387 | if (!this_->route || !navit_former_destinations_active(this_)) | ||
2388 | zoff99 | 27 | return; |
2389 | mr = map_rect_new(this_->former_destination, NULL); | ||
2390 | while ((item = map_rect_get_item(mr))) | ||
2391 | { | ||
2392 | if ((item->type == type_former_destination || item->type == type_former_itinerary || item->type == type_former_itinerary_part) && (count = item_coord_get(item, c, 16))) | ||
2393 | valid = 1; | ||
2394 | zoff99 | 2 | } |
2395 | map_rect_destroy(mr); | ||
2396 | zoff99 | 27 | if (valid && count > 0) |
2397 | { | ||
2398 | for (i = 0; i < count; i++) | ||
2399 | { | ||
2400 | pc[i].pro = map_projection(this_->former_destination); | ||
2401 | pc[i].x = c[i].x; | ||
2402 | pc[i].y = c[i].y; | ||
2403 | zoff99 | 2 | } |
2404 | if (count == 1) | ||
2405 | zoff99 | 27 | { |
2406 | zoff99 | 2 | route_set_destination(this_->route, &pc[0], 1); |
2407 | zoff99 | 27 | } |
2408 | zoff99 | 2 | else |
2409 | zoff99 | 27 | { |
2410 | zoff99 | 2 | route_set_destinations(this_->route, pc, count, 1); |
2411 | zoff99 | 27 | } |
2412 | this_->destination = pc[count - 1]; | ||
2413 | this_->destination_valid = 1; | ||
2414 | zoff99 | 2 | } |
2415 | } | ||
2416 | |||
2417 | zoff99 | 27 | void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...) |
2418 | zoff99 | 2 | { |
2419 | zoff99 | 40 | |
2420 | |||
2421 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2422 | zoff99 | 2 | va_list ap; |
2423 | zoff99 | 27 | char *str1, *str2; |
2424 | zoff99 | 2 | va_start(ap, fmt); |
2425 | zoff99 | 27 | if (this_->textfile_debug_log && this_->vehicle) |
2426 | { | ||
2427 | str1 = g_strdup_vprintf(fmt, ap); | ||
2428 | str2 = g_strdup_printf("0x%x 0x%x%s%s\n", this_->vehicle->coord.x, this_->vehicle->coord.y, strlen(str1) ? " " : "", str1); | ||
2429 | zoff99 | 2 | log_write(this_->textfile_debug_log, str2, strlen(str2), 0); |
2430 | g_free(str2); | ||
2431 | g_free(str1); | ||
2432 | } | ||
2433 | zoff99 | 27 | va_end(ap); |
2434 | zoff99 | 2 | } |
2435 | |||
2436 | zoff99 | 27 | void navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...) |
2437 | zoff99 | 2 | { |
2438 | zoff99 | 40 | |
2439 | |||
2440 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2441 | zoff99 | 2 | va_list ap; |
2442 | zoff99 | 27 | char *str1, *str2; |
2443 | zoff99 | 2 | va_start(ap, fmt); |
2444 | zoff99 | 27 | if (this_->textfile_debug_log && this_->vehicle) |
2445 | { | ||
2446 | str1 = g_strdup_vprintf(fmt, ap); | ||
2447 | str2 = g_strdup_printf("0x%x 0x%x%s%s\n", pc->x, pc->y, strlen(str1) ? " " : "", str1); | ||
2448 | zoff99 | 2 | log_write(this_->textfile_debug_log, str2, strlen(str2), 0); |
2449 | g_free(str2); | ||
2450 | g_free(str1); | ||
2451 | } | ||
2452 | zoff99 | 27 | va_end(ap); |
2453 | zoff99 | 2 | } |
2454 | |||
2455 | zoff99 | 27 | void navit_say(struct navit *this_, char *text) |
2456 | zoff99 | 2 | { |
2457 | zoff99 | 40 | |
2458 | |||
2459 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2460 | if (this_->speech) | ||
2461 | { | ||
2462 | zoff99 | 40 | //dbg(0,"say(1) s=%s\n", text); |
2463 | zoff99 | 2 | speech_say(this_->speech, text); |
2464 | } | ||
2465 | } | ||
2466 | |||
2467 | /** | ||
2468 | * @brief Toggles the navigation announcer for navit | ||
2469 | * @param this_ The navit object | ||
2470 | */ | ||
2471 | zoff99 | 27 | static void navit_cmd_announcer_toggle(struct navit *this_) |
2472 | zoff99 | 2 | { |
2473 | zoff99 | 40 | |
2474 | |||
2475 | zoff99 | 27 | struct attr attr, speechattr; |
2476 | zoff99 | 2 | |
2477 | zoff99 | 27 | // search for the speech attribute |
2478 | if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) | ||
2479 | return; | ||
2480 | // find out if the corresponding attribute attr_active has been set | ||
2481 | if (speech_get_attr(speechattr.u.speech, attr_active, &attr, NULL)) | ||
2482 | { | ||
2483 | // flip it then... | ||
2484 | attr.u.num = !attr.u.num; | ||
2485 | } | ||
2486 | else | ||
2487 | { | ||
2488 | // otherwise disable it because voice is enabled by default | ||
2489 | attr.type = attr_active; | ||
2490 | attr.u.num = 0; | ||
2491 | } | ||
2492 | zoff99 | 2 | |
2493 | zoff99 | 27 | // apply the new state |
2494 | if (!speech_set_attr(speechattr.u.speech, &attr)) | ||
2495 | return; | ||
2496 | zoff99 | 2 | |
2497 | zoff99 | 27 | // announce that the speech attribute has changed |
2498 | callback_list_call_attr_0(this_->attr_cbl, attr_speech); | ||
2499 | zoff99 | 2 | } |
2500 | |||
2501 | zoff99 | 27 | void navit_cmd_announcer_on(struct navit *this_) |
2502 | zoff99 | 2 | { |
2503 | zoff99 | 40 | |
2504 | |||
2505 | zoff99 | 27 | struct attr attr, speechattr; |
2506 | zoff99 | 2 | |
2507 | zoff99 | 27 | // search for the speech attribute |
2508 | if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) | ||
2509 | return; | ||
2510 | zoff99 | 2 | |
2511 | attr.type = attr_active; | ||
2512 | attr.u.num = 1; | ||
2513 | |||
2514 | zoff99 | 27 | // apply the new state |
2515 | if (!speech_set_attr(speechattr.u.speech, &attr)) | ||
2516 | return; | ||
2517 | zoff99 | 2 | |
2518 | zoff99 | 27 | // announce that the speech attribute has changed |
2519 | callback_list_call_attr_0(this_->attr_cbl, attr_speech); | ||
2520 | zoff99 | 2 | } |
2521 | |||
2522 | zoff99 | 27 | void navit_cmd_announcer_off(struct navit *this_) |
2523 | zoff99 | 2 | { |
2524 | zoff99 | 40 | |
2525 | |||
2526 | zoff99 | 27 | struct attr attr, speechattr; |
2527 | zoff99 | 2 | |
2528 | zoff99 | 27 | // search for the speech attribute |
2529 | if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) | ||
2530 | return; | ||
2531 | zoff99 | 2 | |
2532 | attr.type = attr_active; | ||
2533 | attr.u.num = 0; | ||
2534 | |||
2535 | zoff99 | 27 | // apply the new state |
2536 | if (!speech_set_attr(speechattr.u.speech, &attr)) | ||
2537 | return; | ||
2538 | zoff99 | 2 | |
2539 | zoff99 | 27 | // announce that the speech attribute has changed |
2540 | callback_list_call_attr_0(this_->attr_cbl, attr_speech); | ||
2541 | zoff99 | 2 | } |
2542 | |||
2543 | zoff99 | 27 | void navit_speak(struct navit *this_) |
2544 | zoff99 | 2 | { |
2545 | zoff99 | 40 | |
2546 | |||
2547 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2548 | struct navigation *nav = this_->navigation; | ||
2549 | struct map *map = NULL; | ||
2550 | struct map_rect *mr = NULL; | ||
2551 | zoff99 | 2 | struct item *item; |
2552 | struct attr attr; | ||
2553 | |||
2554 | zoff99 | 27 | if (!speech_get_attr(this_->speech, attr_active, &attr, NULL)) |
2555 | zoff99 | 40 | { |
2556 | zoff99 | 27 | attr.u.num = 1; |
2557 | zoff99 | 40 | } |
2558 | |||
2559 | zoff99 | 27 | // dbg(1, "this_.speech->active %i\n", attr.u.num); |
2560 | zoff99 | 40 | |
2561 | zoff99 | 41 | dbg(0, "NAV_TURNAROUND:008:enter\n"); |
2562 | |||
2563 | zoff99 | 27 | if (!attr.u.num) |
2564 | zoff99 | 40 | { |
2565 | zoff99 | 27 | return; |
2566 | zoff99 | 40 | } |
2567 | zoff99 | 2 | |
2568 | if (nav) | ||
2569 | zoff99 | 27 | map = navigation_get_map(nav); |
2570 | zoff99 | 40 | |
2571 | zoff99 | 2 | if (map) |
2572 | zoff99 | 27 | mr = map_rect_new(map, NULL); |
2573 | zoff99 | 40 | |
2574 | zoff99 | 27 | if (mr) |
2575 | { | ||
2576 | while ((item = map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none)) | ||
2577 | zoff99 | 41 | { |
2578 | dbg(0, "NAV_TURNAROUND:008a:%s\n", item_to_name(item->type)); | ||
2579 | } | ||
2580 | zoff99 | 40 | |
2581 | zoff99 | 41 | dbg(0, "NAV_TURNAROUND:008b:item=%p\n", item); |
2582 | |||
2583 | if (item && item_attr_get(item, attr_navigation_speech, &attr)) // this calls --> navigation_map_item_attr_get(...) --> show_next_maneuvers(...) | ||
2584 | zoff99 | 27 | { |
2585 | zoff99 | 40 | //dbg(0,"say(2) s=X%sX\n", attr.u.str); |
2586 | zoff99 | 41 | |
2587 | dbg(0, "NAV_TURNAROUND:009:%s\n", attr.u.str); | ||
2588 | |||
2589 | zoff99 | 40 | if (strlen(attr.u.str) > 0) |
2590 | { | ||
2591 | speech_say(this_->speech, attr.u.str); | ||
2592 | } | ||
2593 | zoff99 | 27 | //navit_add_message(this_, attr.u.str); |
2594 | zoff99 | 40 | // navit_textfile_debug_log(this_, "type=announcement label=\"%s\"", attr.u.str); |
2595 | zoff99 | 2 | } |
2596 | map_rect_destroy(mr); | ||
2597 | } | ||
2598 | } | ||
2599 | |||
2600 | zoff99 | 27 | static void navit_window_roadbook_update(struct navit *this_) |
2601 | zoff99 | 2 | { |
2602 | zoff99 | 40 | |
2603 | |||
2604 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
2605 | struct navigation *nav = this_->navigation; | ||
2606 | struct map *map = NULL; | ||
2607 | struct map_rect *mr = NULL; | ||
2608 | zoff99 | 2 | struct item *item; |
2609 | struct attr attr; | ||
2610 | struct param_list param[5]; | ||
2611 | int secs; | ||
2612 | |||
2613 | zoff99 | 27 | // dbg(1, "enter\n"); |
2614 | zoff99 | 2 | datawindow_mode(this_->roadbook_window, 1); |
2615 | if (nav) | ||
2616 | zoff99 | 27 | map = navigation_get_map(nav); |
2617 | zoff99 | 2 | if (map) |
2618 | zoff99 | 27 | mr = map_rect_new(map, NULL); |
2619 | ////DBG dbg(0,"nav=%p map=%p mr=%p\n", nav, map, mr); | ||
2620 | if (mr) | ||
2621 | { | ||
2622 | ////DBG dbg(0,"while loop\n"); | ||
2623 | while ((item = map_rect_get_item(mr))) | ||
2624 | { | ||
2625 | ////DBG dbg(0,"item=%p\n", item); | ||
2626 | attr.u.str = NULL; | ||
2627 | if (item->type != type_nav_position) | ||
2628 | { | ||
2629 | zoff99 | 2 | item_attr_get(item, attr_navigation_long, &attr); |
2630 | zoff99 | 27 | if (attr.u.str == NULL) |
2631 | { | ||
2632 | zoff99 | 2 | continue; |
2633 | } | ||
2634 | dbg(2, "Command='%s'\n", attr.u.str); | ||
2635 | zoff99 | 27 | param[0].value = g_strdup(attr.u.str); |
2636 | } | ||
2637 | else | ||
2638 | param[0].value = _("Position"); | ||
2639 | param[0].name = _("Command"); | ||
2640 | zoff99 | 2 | |
2641 | item_attr_get(item, attr_length, &attr); | ||
2642 | dbg(2, "Length=%d\n", attr.u.num); | ||
2643 | zoff99 | 27 | param[1].name = _("Length"); |
2644 | zoff99 | 2 | |
2645 | zoff99 | 27 | if (attr.u.num >= 2000) |
2646 | zoff99 | 2 | { |
2647 | zoff99 | 27 | param[1].value = g_strdup_printf("%5.1f %s", (float) attr.u.num / 1000, _("km")); |
2648 | zoff99 | 2 | } |
2649 | else | ||
2650 | { | ||
2651 | zoff99 | 27 | param[1].value = g_strdup_printf("%7d %s", attr.u.num, _("m")); |
2652 | zoff99 | 2 | } |
2653 | |||
2654 | item_attr_get(item, attr_time, &attr); | ||
2655 | dbg(2, "Time=%d\n", attr.u.num); | ||
2656 | zoff99 | 27 | secs = attr.u.num / 10; |
2657 | param[2].name = _("Time"); | ||
2658 | if (secs >= 3600) | ||
2659 | zoff99 | 2 | { |
2660 | zoff99 | 27 | param[2].value = g_strdup_printf("%d:%02d:%02d", secs / 60, (secs / 60) % 60, secs % 60); |
2661 | zoff99 | 2 | } |
2662 | else | ||
2663 | { | ||
2664 | zoff99 | 27 | param[2].value = g_strdup_printf("%d:%02d", secs / 60, secs % 60); |
2665 | zoff99 | 2 | } |
2666 | |||
2667 | item_attr_get(item, attr_destination_length, &attr); | ||
2668 | dbg(2, "Destlength=%d\n", attr.u.num); | ||
2669 | zoff99 | 27 | param[3].name = _("Destination Length"); |
2670 | if (attr.u.num >= 2000) | ||
2671 | zoff99 | 2 | { |
2672 | zoff99 | 27 | param[3].value = g_strdup_printf("%5.1f %s", (float) attr.u.num / 1000, _("km")); |
2673 | zoff99 | 2 | } |
2674 | else | ||
2675 | { | ||
2676 | zoff99 | 27 | param[3].value = g_strdup_printf("%d %s", attr.u.num, _("m")); |
2677 | zoff99 | 2 | } |
2678 | |||
2679 | item_attr_get(item, attr_destination_time, &attr); | ||
2680 | dbg(2, "Desttime=%d\n", attr.u.num); | ||
2681 | zoff99 | 27 | secs = attr.u.num / 10; |
2682 | param[4].name = _("Destination Time"); | ||
2683 | if (secs >= 3600) | ||
2684 | zoff99 | 2 | { |
2685 | zoff99 | 27 | param[4].value = g_strdup_printf("%d:%02d:%02d", secs / 3600, (secs / 60) % 60, secs % 60); |
2686 | zoff99 | 2 | } |
2687 | else | ||
2688 | { | ||
2689 | zoff99 | 27 | param[4].value = g_strdup_printf("%d:%02d", secs / 60, secs % 60); |
2690 | zoff99 | 2 | } |
2691 | datawindow_add(this_->roadbook_window, param, 5); | ||
2692 | } | ||
2693 | map_rect_destroy(mr); | ||
2694 | } | ||
2695 | datawindow_mode(this_->roadbook_window, 0); | ||
2696 | } | ||
2697 | |||
2698 | zoff99 | 27 | void navit_window_roadbook_destroy(struct navit *this_) |
2699 | zoff99 | 2 | { |
2700 | zoff99 | 40 | |
2701 | |||
2702 | zoff99 | 27 | ////DBG dbg(0, "enter\n"); |
2703 | zoff99 | 2 | navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback); |
2704 | zoff99 | 27 | this_->roadbook_window = NULL; |
2705 | this_->roadbook_callback = NULL; | ||
2706 | zoff99 | 2 | } |
2707 | zoff99 | 28 | |
2708 | zoff99 | 27 | void navit_window_roadbook_new(struct navit *this_) |
2709 | zoff99 | 2 | { |
2710 | zoff99 | 40 | |
2711 | |||
2712 | zoff99 | 27 | if (!this_->gui || this_->roadbook_callback || this_->roadbook_window) |
2713 | { | ||
2714 | zoff99 | 2 | return; |
2715 | } | ||
2716 | |||
2717 | zoff99 | 27 | this_->roadbook_callback = callback_new_1(callback_cast(navit_window_roadbook_update), this_); |
2718 | zoff99 | 2 | navigation_register_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback); |
2719 | zoff99 | 27 | this_->roadbook_window = gui_datawindow_new(this_->gui, _("Roadbook"), NULL, callback_new_1(callback_cast(navit_window_roadbook_destroy), this_)); |
2720 | zoff99 | 2 | navit_window_roadbook_update(this_); |
2721 | } | ||
2722 | |||
2723 | zoff99 | 27 | void navit_remove_all_maps(struct navit *this_) |
2724 | zoff99 | 2 | { |
2725 | zoff99 | 40 | |
2726 | |||
2727 | |||
2728 | dbg(0,"ROUTExxPOSxx:navit_remove_all_maps:enter\n"); | ||
2729 | |||
2730 | zoff99 | 2 | struct mapset *ms; |
2731 | struct map *map3; | ||
2732 | |||
2733 | zoff99 | 28 | // hold map drawing |
2734 | // this_->ready = 1; | ||
2735 | |||
2736 | zoff99 | 27 | // first: stop navigation! |
2737 | //if (global_navit->destination_valid != 0) | ||
2738 | //{ | ||
2739 | navit_set_destination(global_navit, NULL, NULL, 0); | ||
2740 | //} | ||
2741 | |||
2742 | |||
2743 | zoff99 | 34 | if (this_->tracking) |
2744 | { | ||
2745 | tracking_flush(this_->tracking); | ||
2746 | } | ||
2747 | |||
2748 | zoff99 | 28 | if (this_->route) |
2749 | { | ||
2750 | struct attr callback; | ||
2751 | // this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); | ||
2752 | zoff99 | 40 | |
2753 | |||
2754 | zoff99 | 28 | callback.type = attr_callback; |
2755 | callback.u.callback = this_->route_cb; | ||
2756 | route_remove_attr(this_->route, &callback); | ||
2757 | zoff99 | 27 | |
2758 | zoff99 | 28 | this_->route->ms = NULL; |
2759 | // route_set_mapset(this_->route, ms); | ||
2760 | // route_set_projection(this_->route, transform_get_projection(this_->trans)); | ||
2761 | zoff99 | 27 | |
2762 | zoff99 | 28 | //*********route_destroy(this_->route); |
2763 | zoff99 | 27 | |
2764 | zoff99 | 28 | //route_path_destroy(this_->route->path2,1); |
2765 | //this_->route->path2 = NULL; | ||
2766 | //route_graph_destroy(this_->route->graph); | ||
2767 | //this_->route->graph=NULL; | ||
2768 | } | ||
2769 | zoff99 | 27 | |
2770 | /* | ||
2771 | map_rect_destroy(displaylist->mr); | ||
2772 | if (!route_selection) | ||
2773 | map_selection_destroy(displaylist->sel); | ||
2774 | mapset_close(displaylist->msh); | ||
2775 | displaylist->mr=NULL; | ||
2776 | displaylist->sel=NULL; | ||
2777 | displaylist->m=NULL; | ||
2778 | displaylist->msh=NULL; | ||
2779 | profile(1,"callback\n"); | ||
2780 | callback_call_1(displaylist->cb, cancel); | ||
2781 | */ | ||
2782 | |||
2783 | struct displaylist *dl = navit_get_displaylist(this_); | ||
2784 | dl->m = NULL; | ||
2785 | dl->msh = NULL; | ||
2786 | |||
2787 | zoff99 | 2 | if (this_->mapsets) |
2788 | { | ||
2789 | struct mapset_handle *msh; | ||
2790 | zoff99 | 27 | ms = this_->mapsets->data; |
2791 | msh = mapset_open(ms); | ||
2792 | ////DBG dbg(0,"removing map bb0\n"); | ||
2793 | while (msh && (map3 = mapset_next(msh, 0))) | ||
2794 | zoff99 | 2 | { |
2795 | zoff99 | 27 | ////DBG dbg(0,"removing map bb1\n"); |
2796 | zoff99 | 2 | struct attr map_name_attr; |
2797 | zoff99 | 27 | if (map_get_attr(map3, attr_name, &map_name_attr, NULL)) |
2798 | zoff99 | 2 | { |
2799 | zoff99 | 27 | //DBG dbg(0, "map name=%s", map_name_attr.u.str); |
2800 | zoff99 | 2 | if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) |
2801 | { | ||
2802 | zoff99 | 28 | dbg(0, "removing map name=%s", map_name_attr.u.str); |
2803 | zoff99 | 27 | //DBG dbg(0, "removing map a0\n"); |
2804 | struct attr active; | ||
2805 | active.type = attr_active; | ||
2806 | active.u.num = 0; | ||
2807 | //map_set_attr(map3, &active); | ||
2808 | |||
2809 | //DBG dbg(0, "removing map a1\n"); | ||
2810 | zoff99 | 2 | struct attr map_attr; |
2811 | zoff99 | 27 | map_attr.u.map = map3; |
2812 | map_attr.type = attr_map; | ||
2813 | zoff99 | 2 | mapset_remove_attr(ms, &map_attr); |
2814 | zoff99 | 27 | |
2815 | //DBG dbg(0, "removing map a2\n"); | ||
2816 | map3->refcount = 1; | ||
2817 | zoff99 | 2 | map_destroy(map3); |
2818 | zoff99 | 27 | //DBG dbg(0, "removing map a3\n"); |
2819 | map3 = NULL; | ||
2820 | zoff99 | 2 | } |
2821 | zoff99 | 28 | else if (strncmp("-special-:", map_name_attr.u.str, 10) == 0) |
2822 | { | ||
2823 | dbg(0, "removing (special) map name=%s", map_name_attr.u.str); | ||
2824 | struct attr active; | ||
2825 | active.type = attr_active; | ||
2826 | active.u.num = 0; | ||
2827 | |||
2828 | struct attr map_attr; | ||
2829 | map_attr.u.map = map3; | ||
2830 | map_attr.type = attr_map; | ||
2831 | mapset_remove_attr(ms, &map_attr); | ||
2832 | |||
2833 | map3->refcount = 1; | ||
2834 | map_destroy(map3); | ||
2835 | map3 = NULL; | ||
2836 | } | ||
2837 | zoff99 | 2 | } |
2838 | } | ||
2839 | mapset_close(msh); | ||
2840 | zoff99 | 27 | //DBG dbg(0, "removing map bb4\n"); |
2841 | zoff99 | 2 | } |
2842 | zoff99 | 27 | |
2843 | dl->ms = this_->mapsets->data; | ||
2844 | |||
2845 | // int async = 0; | ||
2846 | // transform_setup_source_rect(this_->trans); | ||
2847 | // graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1); | ||
2848 | //this_->displaylist->ms=this_->mapsets->data; | ||
2849 | |||
2850 | zoff99 | 2 | } |
2851 | |||
2852 | zoff99 | 28 | void navit_map_active_flag(struct navit *this_, int activate, const char *mapname) |
2853 | { | ||
2854 | // activate = 0 -> deactivate | ||
2855 | // activate = 1 -> activate | ||
2856 | |||
2857 | zoff99 | 40 | |
2858 | |||
2859 | zoff99 | 28 | struct mapset *ms; |
2860 | struct map *map3; | ||
2861 | |||
2862 | if (this_->mapsets) | ||
2863 | { | ||
2864 | struct mapset_handle *msh; | ||
2865 | ms = this_->mapsets->data; | ||
2866 | msh = mapset_open(ms); | ||
2867 | while (msh && (map3 = mapset_next(msh, 0))) | ||
2868 | { | ||
2869 | struct attr map_name_attr; | ||
2870 | if (map_get_attr(map3, attr_name, &map_name_attr, NULL)) | ||
2871 | { | ||
2872 | dbg(0, "map name=%s\n", map_name_attr.u.str); | ||
2873 | if (strcmp(mapname, map_name_attr.u.str) == 0) | ||
2874 | { | ||
2875 | dbg(0, "setting active flag on map:%s\n", map_name_attr.u.str); | ||
2876 | |||
2877 | struct attr active; | ||
2878 | active.type = attr_active; | ||
2879 | active.u.num = activate; | ||
2880 | map_set_attr(map3, &active); | ||
2881 | } | ||
2882 | } | ||
2883 | } | ||
2884 | mapset_close(msh); | ||
2885 | } | ||
2886 | |||
2887 | } | ||
2888 | |||
2889 | zoff99 | 27 | void navit_add_all_maps(struct navit *this_) |
2890 | zoff99 | 2 | { |
2891 | zoff99 | 40 | __F_START__ |
2892 | |||
2893 | zoff99 | 2 | struct map *map3; |
2894 | |||
2895 | if (this_->mapsets) | ||
2896 | { | ||
2897 | zoff99 | 27 | //DBG dbg(0, "xADDx all maps - start\n"); |
2898 | zoff99 | 2 | |
2899 | zoff99 | 27 | struct mapset *ms; |
2900 | ms = this_->mapsets->data; | ||
2901 | |||
2902 | zoff99 | 2 | struct attr type; |
2903 | struct attr parent; | ||
2904 | struct attr data; | ||
2905 | struct attr flags; | ||
2906 | struct map *map2; | ||
2907 | struct attr map2_attr; | ||
2908 | struct attr *attrs[4]; | ||
2909 | char *map_file; | ||
2910 | |||
2911 | zoff99 | 40 | dbg(0, "001\n"); |
2912 | |||
2913 | zoff99 | 27 | parent.type = attr_navit; |
2914 | parent.u.navit = this_; | ||
2915 | type.type = attr_type; | ||
2916 | type.u.str = "binfile"; | ||
2917 | data.type = attr_data; | ||
2918 | map_file = g_strdup_printf("%sborders.bin", navit_maps_dir); | ||
2919 | data.u.str = map_file; | ||
2920 | zoff99 | 2 | |
2921 | zoff99 | 27 | ////DBG dbg(0,"map name=%s",map_file); |
2922 | zoff99 | 2 | |
2923 | zoff99 | 27 | flags.type = attr_flags; |
2924 | flags.u.num = 0; | ||
2925 | attrs[0] = &type; | ||
2926 | attrs[1] = &data; | ||
2927 | attrs[2] = &flags; | ||
2928 | attrs[3] = NULL; | ||
2929 | map2 = map_new(&parent, attrs); | ||
2930 | zoff99 | 2 | if (map2) |
2931 | { | ||
2932 | zoff99 | 27 | map2_attr.u.data = map2; |
2933 | map2_attr.type = attr_map; | ||
2934 | // mapset_add_attr_name(ms, &map2_attr); | ||
2935 | mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/borders.bin"); | ||
2936 | struct attr active; | ||
2937 | active.type = attr_active; | ||
2938 | active.u.num = 0; | ||
2939 | //map_set_attr(map2, &active); | ||
2940 | zoff99 | 34 | |
2941 | active.type = attr_route_active; | ||
2942 | active.u.num = 0; // by default deactivate rounting on this map | ||
2943 | map_set_attr(map2, &active); | ||
2944 | zoff99 | 2 | } |
2945 | g_free(map_file); | ||
2946 | |||
2947 | zoff99 | 50 | |
2948 | |||
2949 | /* | ||
2950 | zoff99 | 27 | parent.type = attr_navit; |
2951 | parent.u.navit = this_; | ||
2952 | type.type = attr_type; | ||
2953 | type.u.str = "binfile"; | ||
2954 | data.type = attr_data; | ||
2955 | map_file = g_strdup_printf("%scoastline.bin", navit_maps_dir); | ||
2956 | data.u.str = map_file; | ||
2957 | zoff99 | 2 | |
2958 | zoff99 | 27 | ////DBG dbg(0,"map name=%s",map_file); |
2959 | zoff99 | 2 | |
2960 | zoff99 | 27 | flags.type = attr_flags; |
2961 | flags.u.num = 0; | ||
2962 | attrs[0] = &type; | ||
2963 | attrs[1] = &data; | ||
2964 | attrs[2] = &flags; | ||
2965 | attrs[3] = NULL; | ||
2966 | map2 = map_new(&parent, attrs); | ||
2967 | zoff99 | 2 | if (map2) |
2968 | { | ||
2969 | zoff99 | 27 | map2_attr.u.data = map2; |
2970 | map2_attr.type = attr_map; | ||
2971 | // mapset_add_attr_name(ms, &map2_attr); | ||
2972 | mapset_add_attr_name_str(ms, &map2_attr, "/sdcard/zanavi/maps/coastline.bin"); | ||
2973 | struct attr active; | ||
2974 | active.type = attr_active; | ||
2975 | active.u.num = 0; | ||
2976 | //map_set_attr(map2, &active); | ||
2977 | zoff99 | 34 | |
2978 | active.type = attr_route_active; | ||
2979 | active.u.num = 0; // by default deactivate rounting on this map | ||
2980 | map_set_attr(map2, &active); | ||
2981 | zoff99 | 2 | } |
2982 | g_free(map_file); | ||
2983 | |||
2984 | zoff99 | 50 | |
2985 | */ | ||
2986 | |||
2987 | |||
2988 | zoff99 | 28 | // gpx tracks map -------------------- |
2989 | parent.type = attr_navit; | ||
2990 | parent.u.navit = this_; | ||
2991 | type.type = attr_type; | ||
2992 | type.u.str = "textfile"; | ||
2993 | data.type = attr_data; | ||
2994 | map_file = g_strdup_printf("%sgpxtracks.txt", navit_maps_dir); | ||
2995 | data.u.str = map_file; | ||
2996 | |||
2997 | flags.type = attr_flags; | ||
2998 | flags.u.num = 0; | ||
2999 | attrs[0] = &type; | ||
3000 | attrs[1] = &data; | ||
3001 | attrs[2] = &flags; | ||
3002 | attrs[3] = NULL; | ||
3003 | map2 = map_new(&parent, attrs); | ||
3004 | if (map2) | ||
3005 | { | ||
3006 | map2_attr.u.data = map2; | ||
3007 | map2_attr.type = attr_map; | ||
3008 | mapset_add_attr_name_str(ms, &map2_attr, "-special-:gpxtracks.txt"); | ||
3009 | struct attr active; | ||
3010 | active.type = attr_active; | ||
3011 | active.u.num = 0; | ||
3012 | //map_set_attr(map2, &active); | ||
3013 | } | ||
3014 | g_free(map_file); | ||
3015 | // gpx tracks map -------------------- | ||
3016 | |||
3017 | |||
3018 | // traffic map -------------------- | ||
3019 | parent.type = attr_navit; | ||
3020 | parent.u.navit = this_; | ||
3021 | type.type = attr_type; | ||
3022 | type.u.str = "textfile"; | ||
3023 | data.type = attr_data; | ||
3024 | map_file = g_strdup_printf("%straffic.txt", navit_maps_dir); | ||
3025 | data.u.str = map_file; | ||
3026 | |||
3027 | flags.type = attr_flags; | ||
3028 | flags.u.num = 0; | ||
3029 | attrs[0] = &type; | ||
3030 | attrs[1] = &data; | ||
3031 | attrs[2] = &flags; | ||
3032 | attrs[3] = NULL; | ||
3033 | map2 = map_new(&parent, attrs); | ||
3034 | if (map2) | ||
3035 | { | ||
3036 | map2_attr.u.data = map2; | ||
3037 | map2_attr.type = attr_map; | ||
3038 | mapset_add_attr_name_str(ms, &map2_attr, "-special-:traffic.txt"); | ||
3039 | struct attr active; | ||
3040 | active.type = attr_active; | ||
3041 | active.u.num = 0; | ||
3042 | //map_set_attr(map2, &active); | ||
3043 | } | ||
3044 | g_free(map_file); | ||
3045 | // traffic map -------------------- | ||
3046 | |||
3047 | |||
3048 | zoff99 | 40 | dbg(0, "002\n"); |
3049 | zoff99 | 34 | |
3050 | zoff99 | 40 | |
3051 | zoff99 | 34 | // world map2 -------------------- |
3052 | parent.type = attr_navit; | ||
3053 | parent.u.navit = this_; | ||
3054 | type.type = attr_type; | ||
3055 | type.u.str = "textfile"; | ||
3056 | data.type = attr_data; | ||
3057 | map_file = g_strdup_printf("%sworldmap2.txt", navit_maps_dir); | ||
3058 | data.u.str = map_file; | ||
3059 | |||
3060 | dbg(0, "activate map:%s\n", map_file); | ||
3061 | |||
3062 | flags.type = attr_flags; | ||
3063 | flags.u.num = 0; | ||
3064 | attrs[0] = &type; | ||
3065 | attrs[1] = &data; | ||
3066 | attrs[2] = &flags; | ||
3067 | attrs[3] = NULL; | ||
3068 | map2 = map_new(&parent, attrs); | ||
3069 | if (map2) | ||
3070 | { | ||
3071 | map2_attr.u.data = map2; | ||
3072 | map2_attr.type = attr_map; | ||
3073 | mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap2.txt"); | ||
3074 | struct attr active; | ||
3075 | active.type = attr_active; | ||
3076 | active.u.num = 1; // by default activate map | ||
3077 | // map_set_attr(map2, &active); | ||
3078 | |||
3079 | active.type = attr_route_active; | ||
3080 | active.u.num = 0; // by default deactivate routing on this map | ||
3081 | map_set_attr(map2, &active); | ||
3082 | |||
3083 | } | ||
3084 | g_free(map_file); | ||
3085 | // world map2 -------------------- | ||
3086 | |||
3087 | |||
3088 | // world map5 -------------------- | ||
3089 | parent.type = attr_navit; | ||
3090 | parent.u.navit = this_; | ||
3091 | type.type = attr_type; | ||
3092 | type.u.str = "textfile"; | ||
3093 | data.type = attr_data; | ||
3094 | map_file = g_strdup_printf("%sworldmap5.txt", navit_maps_dir); | ||
3095 | data.u.str = map_file; | ||
3096 | |||
3097 | dbg(0, "activate map:%s\n", map_file); | ||
3098 | |||
3099 | flags.type = attr_flags; | ||
3100 | flags.u.num = 0; | ||
3101 | attrs[0] = &type; | ||
3102 | attrs[1] = &data; | ||
3103 | attrs[2] = &flags; | ||
3104 | attrs[3] = NULL; | ||
3105 | map2 = map_new(&parent, attrs); | ||
3106 | if (map2) | ||
3107 | { | ||
3108 | map2_attr.u.data = map2; | ||
3109 | map2_attr.type = attr_map; | ||
3110 | mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap5.txt"); | ||
3111 | struct attr active; | ||
3112 | active.type = attr_active; | ||
3113 | active.u.num = 1; // by default activate map | ||
3114 | // map_set_attr(map2, &active); | ||
3115 | |||
3116 | active.type = attr_route_active; | ||
3117 | active.u.num = 0; // by default deactivate routing on this map | ||
3118 | map_set_attr(map2, &active); | ||
3119 | } | ||
3120 | g_free(map_file); | ||
3121 | // world map5 -------------------- | ||
3122 | |||
3123 | zoff99 | 40 | dbg(0, "003\n"); |
3124 | zoff99 | 34 | |
3125 | zoff99 | 40 | |
3126 | zoff99 | 34 | #if 0 |
3127 | // world map6 -------------------- | ||
3128 | parent.type = attr_navit; | ||
3129 | parent.u.navit = this_; | ||
3130 | type.type = attr_type; | ||
3131 | type.u.str = "textfile"; | ||
3132 | data.type = attr_data; | ||
3133 | map_file = g_strdup_printf("%sworldmap6.txt", navit_maps_dir); | ||
3134 | data.u.str = map_file; | ||
3135 | |||
3136 | dbg(0, "activate map:%s\n", map_file); | ||
3137 | |||
3138 | flags.type = attr_flags; | ||
3139 | flags.u.num = 0; | ||
3140 | attrs[0] = &type; | ||
3141 | attrs[1] = &data; | ||
3142 | attrs[2] = &flags; | ||
3143 | attrs[3] = NULL; | ||
3144 | map2 = map_new(&parent, attrs); | ||
3145 | if (map2) | ||
3146 | { | ||
3147 | map2_attr.u.data = map2; | ||
3148 | map2_attr.type = attr_map; | ||
3149 | mapset_add_attr_name_str(ms, &map2_attr, "-special-:worldmap6.txt"); | ||
3150 | struct attr active; | ||
3151 | active.type = attr_active; | ||
3152 | active.u.num = 1; // by default activate map | ||
3153 | // map_set_attr(map2, &active); | ||
3154 | |||
3155 | active.type = attr_route_active; | ||
3156 | active.u.num = 0; // by default deactivate routing on this map | ||
3157 | map_set_attr(map2, &active); | ||
3158 | } | ||
3159 | g_free(map_file); | ||
3160 | // world map6 -------------------- | ||
3161 | #endif | ||
3162 | |||
3163 | zoff99 | 40 | dbg(0, "004\n"); |
3164 | zoff99 | 34 | |
3165 | zoff99 | 40 | |
3166 | zoff99 | 27 | int i = 1; |
3167 | for (i = 1; i < 10; i++) | ||
3168 | zoff99 | 2 | { |
3169 | struct map *map22; | ||
3170 | struct attr map22_attr; | ||
3171 | zoff99 | 27 | parent.type = attr_navit; |
3172 | parent.u.navit = this_; | ||
3173 | type.type = attr_type; | ||
3174 | type.u.str = "binfile"; | ||
3175 | data.type = attr_data; | ||
3176 | map_file = g_strdup_printf("%snavitmap_00%d.bin", navit_maps_dir, i); | ||
3177 | data.u.str = map_file; | ||
3178 | flags.type = attr_flags; | ||
3179 | flags.u.num = 0; | ||
3180 | attrs[0] = &type; | ||
3181 | attrs[1] = &data; | ||
3182 | attrs[2] = &flags; | ||
3183 | attrs[3] = NULL; | ||
3184 | map22 = map_new(&parent, attrs); | ||
3185 | zoff99 | 2 | if (map22) |
3186 | { | ||
3187 | zoff99 | 27 | //DBG dbg(0, "*add* map name=%s\n", map_file); |
3188 | map22_attr.u.data = map22; | ||
3189 | map22_attr.type = attr_map; | ||
3190 | // mapset_add_attr_name(ms, &map22_attr); | ||
3191 | char *map_name_str; | ||
3192 | map_name_str = g_strdup_printf("/sdcard/zanavi/maps/navitmap_00%d.bin", i); | ||
3193 | mapset_add_attr_name_str(ms, &map22_attr, map_name_str); | ||
3194 | struct attr active; | ||
3195 | active.type = attr_active; | ||
3196 | active.u.num = 0; | ||
3197 | //map_set_attr(map22, &active); | ||
3198 | g_free(map_name_str); | ||
3199 | zoff99 | 2 | } |
3200 | g_free(map_file); | ||
3201 | } | ||
3202 | |||
3203 | zoff99 | 27 | i = 10; |
3204 | zoff99 | 50 | for (i = 10; i < 61; i++) |
3205 | zoff99 | 2 | { |
3206 | zoff99 | 27 | parent.type = attr_navit; |
3207 | parent.u.navit = this_; | ||
3208 | type.type = attr_type; | ||
3209 | type.u.str = "binfile"; | ||
3210 | data.type = attr_data; | ||
3211 | map_file = g_strdup_printf("%snavitmap_0%d.bin", navit_maps_dir, i); | ||
3212 | data.u.str = map_file; | ||
3213 | ////DBG dbg(0,"map name=%s",map_file); | ||
3214 | flags.type = attr_flags; | ||
3215 | flags.u.num = 0; | ||
3216 | attrs[0] = &type; | ||
3217 | attrs[1] = &data; | ||
3218 | attrs[2] = &flags; | ||
3219 | attrs[3] = NULL; | ||
3220 | map2 = map_new(&parent, attrs); | ||
3221 | zoff99 | 2 | if (map2) |
3222 | { | ||
3223 | zoff99 | 27 | map2_attr.u.data = map2; |
3224 | map2_attr.type = attr_map; | ||
3225 | // mapset_add_attr_name(ms, &map2_attr); | ||
3226 | char *map_name_str; | ||
3227 | map_name_str = g_strdup_printf("/sdcard/zanavi/maps/navitmap_0%d.bin", i); | ||
3228 | mapset_add_attr_name_str(ms, &map2_attr, map_name_str); | ||
3229 | struct attr active; | ||
3230 | active.type = attr_active; | ||
3231 | active.u.num = 0; | ||
3232 | //map_set_attr(map2, &active); | ||
3233 | g_free(map_name_str); | ||
3234 | zoff99 | 2 | } |
3235 | g_free(map_file); | ||
3236 | } | ||
3237 | } | ||
3238 | zoff99 | 27 | |
3239 | /* | ||
3240 | if (this_->mapsets) | ||
3241 | { | ||
3242 | struct mapset_handle *msh; | ||
3243 | struct map *map; | ||
3244 | struct mapset *ms; | ||
3245 | |||
3246 | //DBG dbg(0,"xx ms callbacks xx\n"); | ||
3247 | |||
3248 | ms=this_->mapsets->data; | ||
3249 | this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); | ||
3250 | msh=mapset_open(ms); | ||
3251 | while (msh && (map=mapset_next(msh, 0))) | ||
3252 | { | ||
3253 | //pass new callback instance for each map in the mapset to make map callback list destruction work correctly | ||
3254 | struct callback *pcb = callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); | ||
3255 | map_add_callback(map, pcb); | ||
3256 | } | ||
3257 | mapset_close(msh); | ||
3258 | } | ||
3259 | */ | ||
3260 | |||
3261 | zoff99 | 28 | /* |
3262 | zoff99 | 30 | struct attr parent; |
3263 | parent.type = attr_navit; | ||
3264 | parent.u.navit = global_navit; | ||
3265 | zoff99 | 27 | |
3266 | zoff99 | 30 | struct attr *attrs_r[2]; |
3267 | attrs_r[0] = NULL; | ||
3268 | attrs_r[1] = NULL; | ||
3269 | */ | ||
3270 | zoff99 | 27 | |
3271 | //***this_->route = route_new(&parent, attrs_r); | ||
3272 | |||
3273 | |||
3274 | //int async = 0; | ||
3275 | //transform_setup_source_rect(this_->trans); | ||
3276 | //graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1); | ||
3277 | |||
3278 | zoff99 | 40 | if (this_->mapsets) |
3279 | zoff99 | 27 | { |
3280 | zoff99 | 40 | dbg(0, "005\n"); |
3281 | zoff99 | 27 | |
3282 | zoff99 | 40 | struct displaylist *dl = navit_get_displaylist(this_); |
3283 | dbg(0, "005a dl=%p\n", dl); | ||
3284 | dbg(0, "005a1 ms=%p\n", this_->mapsets); | ||
3285 | dbg(0, "005a2 ms=%p\n", this_->mapsets->data); | ||
3286 | dl->ms = this_->mapsets->data; | ||
3287 | dbg(0, "005b\n"); | ||
3288 | dl->m = NULL; | ||
3289 | dbg(0, "005c\n"); | ||
3290 | dl->msh = NULL; | ||
3291 | zoff99 | 27 | |
3292 | zoff99 | 40 | dbg(0, "005.1\n"); |
3293 | zoff99 | 27 | |
3294 | if (this_->route) | ||
3295 | { | ||
3296 | zoff99 | 40 | dbg(0, "005.2\n"); |
3297 | |||
3298 | struct mapset *ms; | ||
3299 | dbg(0, "005.3\n"); | ||
3300 | ms = this_->mapsets->data; | ||
3301 | dbg(0, "005.4\n"); | ||
3302 | route_set_mapset(this_->route, ms); | ||
3303 | |||
3304 | dbg(0, "005.5\n"); | ||
3305 | |||
3306 | struct attr callback; | ||
3307 | this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); | ||
3308 | dbg(0, "005.6\n"); | ||
3309 | callback_add_names(this_->route_cb, "navit_add_all_maps", "navit_redraw_route"); | ||
3310 | dbg(0, "005.7\n"); | ||
3311 | callback.type = attr_callback; | ||
3312 | dbg(0, "005.8\n"); | ||
3313 | callback.u.callback = this_->route_cb; | ||
3314 | dbg(0, "005.9\n"); | ||
3315 | route_add_attr(this_->route, &callback); | ||
3316 | dbg(0, "005.10\n"); | ||
3317 | // ***** route_set_projection(this_->route, transform_get_projection(this_->trans)); | ||
3318 | |||
3319 | |||
3320 | zoff99 | 27 | } |
3321 | zoff99 | 40 | |
3322 | |||
3323 | dbg(0, "006\n"); | ||
3324 | |||
3325 | |||
3326 | if (this_->tracking) | ||
3327 | { | ||
3328 | struct mapset *ms; | ||
3329 | ms = this_->mapsets->data; | ||
3330 | |||
3331 | tracking_set_mapset(this_->tracking, ms); | ||
3332 | if (this_->route) | ||
3333 | { | ||
3334 | tracking_set_route(this_->tracking, this_->route); | ||
3335 | } | ||
3336 | } | ||
3337 | |||
3338 | zoff99 | 27 | } |
3339 | |||
3340 | zoff99 | 28 | // ready for drawing map |
3341 | // this_->ready = 3; | ||
3342 | zoff99 | 27 | |
3343 | zoff99 | 28 | // draw map |
3344 | // navit_draw(this_); | ||
3345 | zoff99 | 40 | |
3346 | __F_END__ | ||
3347 | zoff99 | 2 | } |
3348 | |||
3349 | zoff99 | 27 | void navit_reload_maps(struct navit *this_) |
3350 | zoff99 | 2 | { |
3351 | zoff99 | 40 | |
3352 | |||
3353 | |||
3354 | dbg(0,"ROUTExxPOSxx:navit_reload_maps:enter\n"); | ||
3355 | |||
3356 | zoff99 | 2 | navit_remove_all_maps(this_); |
3357 | navit_add_all_maps(this_); | ||
3358 | } | ||
3359 | |||
3360 | zoff99 | 40 | |
3361 | // --- forward def ---- | ||
3362 | void navit_set_vehicle_position_to_screen_center(struct navit *this_); | ||
3363 | // --- forward def ---- | ||
3364 | |||
3365 | zoff99 | 27 | void navit_init(struct navit *this_) |
3366 | zoff99 | 2 | { |
3367 | zoff99 | 40 | |
3368 | |||
3369 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
3370 | zoff99 | 2 | struct mapset *ms; |
3371 | struct map *map; | ||
3372 | int callback; | ||
3373 | char *center_file; | ||
3374 | |||
3375 | zoff99 | 30 | // dbg(0,"GGGGG:set global_navit\n"); |
3376 | // global_navit = this_; | ||
3377 | |||
3378 | zoff99 | 27 | // default value |
3379 | navit_maps_dir = "/sdcard/zanavi/maps/"; | ||
3380 | zoff99 | 2 | |
3381 | zoff99 | 27 | global_img_waypoint = NULL; |
3382 | |||
3383 | //DBG dbg(0, "enter gui %p graphics %p\n", this_->gui, this_->gra); | ||
3384 | |||
3385 | if (!this_->gui && !(this_->flags & 2)) | ||
3386 | { | ||
3387 | dbg(0, "no gui\n"); | ||
3388 | zoff99 | 2 | navit_destroy(this_); |
3389 | return; | ||
3390 | } | ||
3391 | zoff99 | 27 | |
3392 | if (!this_->gra && !(this_->flags & 1)) | ||
3393 | { | ||
3394 | dbg(0, "no graphics\n"); | ||
3395 | zoff99 | 2 | navit_destroy(this_); |
3396 | return; | ||
3397 | } | ||
3398 | zoff99 | 27 | |
3399 | zoff99 | 40 | |
3400 | #ifdef NAVIT_FREE_TEXT_DEBUG_PRINT | ||
3401 | dbg(0, "DEST::route_clear_freetext_list(000)\n"); | ||
3402 | route_clear_freetext_list(); | ||
3403 | #endif | ||
3404 | |||
3405 | |||
3406 | zoff99 | 27 | //DBG dbg(0, "Connecting gui to graphics\n"); |
3407 | |||
3408 | if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra)) | ||
3409 | { | ||
3410 | zoff99 | 2 | struct attr attr_type_gui, attr_type_graphics; |
3411 | gui_get_attr(this_->gui, attr_type, &attr_type_gui, NULL); | ||
3412 | graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL); | ||
3413 | |||
3414 | zoff99 | 28 | dbg(0, "failed to connect to graphics\n"); |
3415 | zoff99 | 2 | navit_destroy(this_); |
3416 | return; | ||
3417 | } | ||
3418 | zoff99 | 27 | |
3419 | if (this_->speech && this_->navigation) | ||
3420 | { | ||
3421 | zoff99 | 2 | struct attr speech; |
3422 | zoff99 | 27 | speech.type = attr_speech; |
3423 | speech.u.speech = this_->speech; | ||
3424 | zoff99 | 2 | navigation_set_attr(this_->navigation, &speech); |
3425 | } | ||
3426 | zoff99 | 27 | |
3427 | //DBG dbg(0, "Initializing graphics\n"); | ||
3428 | //DBG dbg(0, "Setting Vehicle\n"); | ||
3429 | zoff99 | 2 | navit_set_vehicle(this_, this_->vehicle); |
3430 | zoff99 | 28 | |
3431 | zoff99 | 27 | //DBG dbg(0, "Adding dynamic maps to mapset %p\n", this_->mapsets); |
3432 | if (this_->mapsets) | ||
3433 | { | ||
3434 | zoff99 | 2 | struct mapset_handle *msh; |
3435 | zoff99 | 27 | ms = this_->mapsets->data; |
3436 | // **D** // this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); | ||
3437 | msh = mapset_open(ms); | ||
3438 | while (msh && (map = mapset_next(msh, 0))) | ||
3439 | { | ||
3440 | zoff99 | 2 | //pass new callback instance for each map in the mapset to make map callback list destruction work correctly |
3441 | zoff99 | 27 | // **D** // struct callback *pcb = callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); |
3442 | // **D** // map_add_callback(map, pcb); | ||
3443 | zoff99 | 2 | } |
3444 | mapset_close(msh); | ||
3445 | zoff99 | 27 | |
3446 | if (this_->route) | ||
3447 | { | ||
3448 | if ((map = route_get_map(this_->route))) | ||
3449 | { | ||
3450 | struct attr map_a, map_name; | ||
3451 | map_a.type = attr_map; | ||
3452 | map_a.u.map = map; | ||
3453 | map_name.type = attr_name; | ||
3454 | map_name.u.str = "_ms_route"; | ||
3455 | zoff99 | 2 | map_set_attr(map_a.u.map, &map_name); |
3456 | mapset_add_attr(ms, &map_a); | ||
3457 | } | ||
3458 | zoff99 | 27 | |
3459 | if ((map = route_get_graph_map(this_->route))) | ||
3460 | { | ||
3461 | struct attr map_a, active, map_name; | ||
3462 | map_a.type = attr_map; | ||
3463 | map_a.u.map = map; | ||
3464 | active.type = attr_active; | ||
3465 | active.u.num = 0; | ||
3466 | map_name.type = attr_name; | ||
3467 | map_name.u.str = "_ms_route_graph"; | ||
3468 | zoff99 | 2 | map_set_attr(map_a.u.map, &map_name); |
3469 | mapset_add_attr(ms, &map_a); | ||
3470 | map_set_attr(map, &active); | ||
3471 | } | ||
3472 | route_set_mapset(this_->route, ms); | ||
3473 | route_set_projection(this_->route, transform_get_projection(this_->trans)); | ||
3474 | } | ||
3475 | zoff99 | 27 | |
3476 | if (this_->tracking) | ||
3477 | { | ||
3478 | zoff99 | 2 | tracking_set_mapset(this_->tracking, ms); |
3479 | if (this_->route) | ||
3480 | zoff99 | 27 | { |
3481 | zoff99 | 2 | tracking_set_route(this_->tracking, this_->route); |
3482 | zoff99 | 27 | } |
3483 | zoff99 | 2 | } |
3484 | zoff99 | 27 | |
3485 | if (this_->navigation) | ||
3486 | { | ||
3487 | if ((map = navigation_get_map(this_->navigation))) | ||
3488 | { | ||
3489 | struct attr map_a, active, map_name; | ||
3490 | map_a.type = attr_map; | ||
3491 | map_a.u.map = map; | ||
3492 | active.type = attr_active; | ||
3493 | active.u.num = 0; | ||
3494 | map_name.type = attr_name; | ||
3495 | map_name.u.str = "_ms_navigation"; | ||
3496 | zoff99 | 2 | map_set_attr(map_a.u.map, &map_name); |
3497 | mapset_add_attr(ms, &map_a); | ||
3498 | map_set_attr(map, &active); | ||
3499 | } | ||
3500 | } | ||
3501 | zoff99 | 27 | |
3502 | if (this_->tracking) | ||
3503 | { | ||
3504 | if ((map = tracking_get_map(this_->tracking))) | ||
3505 | { | ||
3506 | struct attr map_a, active, map_name; | ||
3507 | map_a.type = attr_map; | ||
3508 | map_a.u.map = map; | ||
3509 | active.type = attr_active; | ||
3510 | active.u.num = 0; | ||
3511 | map_name.type = attr_name; | ||
3512 | map_name.u.str = "_ms_tracking"; | ||
3513 | zoff99 | 14 | map_set_attr(map_a.u.map, &map_name); |
3514 | zoff99 | 2 | mapset_add_attr(ms, &map_a); |
3515 | map_set_attr(map, &active); | ||
3516 | } | ||
3517 | } | ||
3518 | zoff99 | 14 | // *DISABLED* navit_add_former_destinations_from_file(this_); |
3519 | zoff99 | 2 | } |
3520 | zoff99 | 27 | |
3521 | if (this_->route) | ||
3522 | { | ||
3523 | zoff99 | 40 | /* |
3524 | *DISABLED* done in "navit_add_all_maps" | ||
3525 | |||
3526 | zoff99 | 2 | struct attr callback; |
3527 | zoff99 | 27 | this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); |
3528 | zoff99 | 30 | callback_add_names(this_->route_cb, "navit_init", "navit_redraw_route"); |
3529 | zoff99 | 27 | callback.type = attr_callback; |
3530 | callback.u.callback = this_->route_cb; | ||
3531 | zoff99 | 2 | route_add_attr(this_->route, &callback); |
3532 | zoff99 | 40 | */ |
3533 | zoff99 | 2 | } |
3534 | zoff99 | 27 | |
3535 | if (this_->navigation) | ||
3536 | { | ||
3537 | if (this_->speech) | ||
3538 | { | ||
3539 | this_->nav_speech_cb = callback_new_1(callback_cast(navit_speak), this_); | ||
3540 | zoff99 | 30 | callback_add_names(this_->nav_speech_cb, "navit_init", "navit_speak"); |
3541 | zoff99 | 2 | navigation_register_callback(this_->navigation, attr_navigation_speech, this_->nav_speech_cb); |
3542 | } | ||
3543 | zoff99 | 27 | |
3544 | zoff99 | 2 | if (this_->route) |
3545 | zoff99 | 27 | { |
3546 | zoff99 | 2 | navigation_set_route(this_->navigation, this_->route); |
3547 | zoff99 | 27 | } |
3548 | zoff99 | 2 | } |
3549 | zoff99 | 27 | |
3550 | dbg(0, "Setting Center\n"); | ||
3551 | zoff99 | 2 | center_file = bookmarks_get_center_file(FALSE); |
3552 | zoff99 | 27 | //dbg(0, "g0\n"); |
3553 | zoff99 | 2 | bookmarks_set_center_from_file(this_->bookmarks, center_file); |
3554 | g_free(center_file); | ||
3555 | zoff99 | 30 | |
3556 | zoff99 | 40 | dbg(0, "Set Vehicle Position to Center\n"); |
3557 | navit_set_vehicle_position_to_screen_center(this_); | ||
3558 | |||
3559 | zoff99 | 2 | #if 0 |
3560 | zoff99 | 27 | if (this_->menubar) |
3561 | { | ||
3562 | zoff99 | 2 | men=menu_add(this_->menubar, "Data", menu_type_submenu, NULL); |
3563 | zoff99 | 27 | if (men) |
3564 | { | ||
3565 | zoff99 | 2 | navit_add_menu_windows_items(this_, men); |
3566 | } | ||
3567 | } | ||
3568 | #endif | ||
3569 | zoff99 | 30 | |
3570 | zoff99 | 2 | #if 0 |
3571 | navit_window_roadbook_new(this_); | ||
3572 | navit_window_items_new(this_); | ||
3573 | #endif | ||
3574 | |||
3575 | zoff99 | 27 | //dbg(0, "g1\n"); |
3576 | //messagelist_init(this_->messages); | ||
3577 | zoff99 | 2 | |
3578 | zoff99 | 27 | //dbg(0, "g2\n"); |
3579 | zoff99 | 2 | navit_set_cursors(this_); |
3580 | |||
3581 | callback_list_call_attr_1(this_->attr_cbl, attr_navit, this_); | ||
3582 | zoff99 | 27 | callback = (this_->ready == 2); |
3583 | zoff99 | 28 | dbg(0, "pre this_->ready=%d\n", this_->ready); |
3584 | this_->ready = this_->ready | 1; | ||
3585 | dbg(0, "set this_->ready=%d\n", this_->ready); | ||
3586 | zoff99 | 27 | ////DBG dbg(0,"ready=%d\n",this_->ready); |
3587 | |||
3588 | zoff99 | 28 | |
3589 | //if (this_->ready == 3) | ||
3590 | //{ | ||
3591 | // ////DBG dbg(0,"navit_draw_async_003\n"); | ||
3592 | // navit_draw_async(this_, 1); | ||
3593 | //} | ||
3594 | |||
3595 | zoff99 | 30 | dbg(0, "init ready=%d\n", this_->ready); |
3596 | zoff99 | 28 | |
3597 | // draw??????? | ||
3598 | // dbg(0,"init DRAW 11\n"); | ||
3599 | // ready to draw map | ||
3600 | // navit_draw(this_); | ||
3601 | // dbg(0,"init DRAW 22\n"); | ||
3602 | // draw??????? | ||
3603 | |||
3604 | zoff99 | 2 | if (callback) |
3605 | zoff99 | 27 | { |
3606 | zoff99 | 2 | callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); |
3607 | zoff99 | 27 | } |
3608 | zoff99 | 2 | #if 0 |
3609 | routech_test(this_); | ||
3610 | #endif | ||
3611 | zoff99 | 27 | //dbg(0, "1111111111\n"); |
3612 | zoff99 | 2 | } |
3613 | |||
3614 | zoff99 | 40 | |
3615 | |||
3616 | // ----- forward def! ----- | ||
3617 | void navit_set_position_without_map_drawing(struct navit *this_, struct pcoord *c); | ||
3618 | // ----- forward def! ----- | ||
3619 | |||
3620 | void navit_set_vehicle_position_to_screen_center_only_for_route_struct(struct navit *this_) | ||
3621 | { | ||
3622 | struct coord c; | ||
3623 | char *center_file; | ||
3624 | center_file = bookmarks_get_center_file(FALSE); | ||
3625 | bookmarks_get_center_from_file(this_->bookmarks, center_file, &c); | ||
3626 | g_free(center_file); | ||
3627 | |||
3628 | struct pcoord pc; | ||
3629 | pc.x = c.x; | ||
3630 | pc.y = c.y; | ||
3631 | pc.pro = transform_get_projection(this_->trans); | ||
3632 | // result: pc.x, pc.y | ||
3633 | |||
3634 | // set position | ||
3635 | navit_set_position_without_map_drawing(this_, &pc); | ||
3636 | } | ||
3637 | |||
3638 | void navit_set_vehicle_position_to_screen_center(struct navit *this_) | ||
3639 | { | ||
3640 | |||
3641 | // map center to pixel x,y on screen | ||
3642 | // enum projection pro = transform_get_projection(this_->trans); | ||
3643 | // struct point pnt; | ||
3644 | // struct coord *c992; | ||
3645 | // c992 = transform_get_center(this_->trans); | ||
3646 | // transform(this_->trans, pro, c992, &pnt, 1, 0, 0, NULL); | ||
3647 | // dbg(0, "navit_set_vehicle_position_to_screen_center pnt.x=%d pnt.y=%d\n", pnt.x, pnt.y); | ||
3648 | // result: pnt.x, pnt.y | ||
3649 | |||
3650 | |||
3651 | // geo to pixel-on-screen | ||
3652 | // struct coord c99; | ||
3653 | // struct coord_geo g99; | ||
3654 | // g99.lat = lat; | ||
3655 | // g99.lng = lon; | ||
3656 | // dbg(0,"zzzzz %f, %f\n",a, b); | ||
3657 | // dbg(0,"yyyyy %f, %f\n",g99.lat, g99.lng); | ||
3658 | // transform_from_geo(projection_mg, &g99, &c99); | ||
3659 | // dbg(0,"%d %d %f %f\n",c99.x, c99.y, g99.lat, g99.lng); | ||
3660 | |||
3661 | // enum projection pro = transform_get_projection(global_navit->trans_cursor); | ||
3662 | // struct point pnt; | ||
3663 | // transform(global_navit->trans, pro, &c99, &pnt, 1, 0, 0, NULL); | ||
3664 | // dbg(0,"x=%d\n",pnt.x); | ||
3665 | // dbg(0,"y=%d\n",pnt.y); | ||
3666 | |||
3667 | |||
3668 | struct coord c; | ||
3669 | char *center_file; | ||
3670 | center_file = bookmarks_get_center_file(FALSE); | ||
3671 | bookmarks_get_center_from_file(this_->bookmarks, center_file, &c); | ||
3672 | g_free(center_file); | ||
3673 | |||
3674 | |||
3675 | // coord to geo | ||
3676 | struct coord_geo g22; | ||
3677 | // struct coord c22; | ||
3678 | ////DBG // dbg(0,"%f, %f\n",a, b); | ||
3679 | ////DBG // dbg(0,"%d, %d\n",p.x, p.y); | ||
3680 | transform_to_geo(projection_mg, &c, &g22); | ||
3681 | dbg(0,"navit_set_vehicle_position_to_screen_center: %d, %d, %f, %f\n",c.x, c.y, g22.lat, g22.lng); | ||
3682 | // result = g_strdup_printf("%f:%f", g22.lat, g22.lng); | ||
3683 | |||
3684 | |||
3685 | // set vehicle position to pixel x,y | ||
3686 | //struct point p; | ||
3687 | //struct coord c; | ||
3688 | |||
3689 | // pixel-x | ||
3690 | //p.x = pnt.x; | ||
3691 | // pixel-y | ||
3692 | //p.y = pnt.y; | ||
3693 | |||
3694 | //transform_reverse(this_->trans, &p, &c); | ||
3695 | |||
3696 | struct pcoord pc; | ||
3697 | pc.x = c.x; | ||
3698 | pc.y = c.y; | ||
3699 | pc.pro = transform_get_projection(this_->trans); | ||
3700 | // result: pc.x, pc.y | ||
3701 | |||
3702 | // set position | ||
3703 | navit_set_position_without_map_drawing(this_, &pc); | ||
3704 | |||
3705 | |||
3706 | //center.pro = projection_screen; | ||
3707 | //center.x = 0; | ||
3708 | //center.y = 0; | ||
3709 | //DBG dbg(0, "veh new 5\n"); | ||
3710 | // transform_setup(this_->vehicle->vehicle->trans, &pc, 16, 0); | ||
3711 | // transform_set_center(this_->vehicle->vehicle->trans, &c); | ||
3712 | // zzzzzzzzzzzzzz int vehicle_set_cursor_data_01(struct vehicle *this, struct point *pnt) | ||
3713 | |||
3714 | if ((this_) && (this_->vehicle)) | ||
3715 | { | ||
3716 | this_->vehicle->coord.x = c.x; | ||
3717 | this_->vehicle->coord.y = c.y; | ||
3718 | } | ||
3719 | |||
3720 | if ((this_) && (this_->vehicle) && (this_->vehicle->vehicle)) | ||
3721 | { | ||
3722 | float speed = 0; | ||
3723 | float direction = 0; | ||
3724 | double height = 0; | ||
3725 | float radius = 0; | ||
3726 | long gpstime = 0; | ||
3727 | vehicle_update_(this_->vehicle->vehicle, g22.lat, g22.lng, speed, direction, height, radius, gpstime); | ||
3728 | } | ||
3729 | else | ||
3730 | { | ||
3731 | dbg(0, "navit_set_vehicle_position_to_screen_center: no vehicle set !!\n"); | ||
3732 | } | ||
3733 | } | ||
3734 | |||
3735 | |||
3736 | |||
3737 | |||
3738 | zoff99 | 27 | void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r) |
3739 | zoff99 | 2 | { |
3740 | struct coord c; | ||
3741 | zoff99 | 27 | int scale = 16; |
3742 | zoff99 | 2 | |
3743 | zoff99 | 27 | c.x = (r->rl.x + r->lu.x) / 2; |
3744 | c.y = (r->rl.y + r->lu.y) / 2; | ||
3745 | zoff99 | 2 | transform_set_center(this_->trans, &c); |
3746 | zoff99 | 40 | |
3747 | zoff99 | 27 | while (scale < 1 << 20) |
3748 | { | ||
3749 | struct point p1, p2; | ||
3750 | zoff99 | 2 | transform_set_scale(this_->trans, scale); |
3751 | transform_setup_source_rect(this_->trans); | ||
3752 | transform(this_->trans, transform_get_projection(this_->trans), &r->lu, &p1, 1, 0, 0, NULL); | ||
3753 | transform(this_->trans, transform_get_projection(this_->trans), &r->rl, &p2, 1, 0, 0, NULL); | ||
3754 | zoff99 | 40 | |
3755 | zoff99 | 27 | 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) |
3756 | zoff99 | 40 | { |
3757 | zoff99 | 27 | scale *= 2; |
3758 | zoff99 | 40 | } |
3759 | zoff99 | 2 | else |
3760 | zoff99 | 40 | { |
3761 | zoff99 | 2 | break; |
3762 | zoff99 | 40 | } |
3763 | } | ||
3764 | zoff99 | 27 | |
3765 | zoff99 | 40 | dbg(0, "scale=%d\n", scale); |
3766 | dbg(0, "this_->ready=%d\n", this_->ready); | ||
3767 | |||
3768 | zoff99 | 2 | if (this_->ready == 3) |
3769 | { | ||
3770 | zoff99 | 40 | // dbg(0,"navit_draw_async_004\n"); |
3771 | zoff99 | 30 | //dbg(0,"DO__DRAW:navit_draw_async call\n"); |
3772 | zoff99 | 27 | navit_draw_async(this_, 0); |
3773 | zoff99 | 2 | } |
3774 | } | ||
3775 | |||
3776 | zoff99 | 27 | void navit_zoom_to_route(struct navit *this_, int orientation) |
3777 | zoff99 | 2 | { |
3778 | struct map *map; | ||
3779 | zoff99 | 27 | struct map_rect *mr = NULL; |
3780 | zoff99 | 2 | struct item *item; |
3781 | struct coord c; | ||
3782 | struct coord_rect r; | ||
3783 | zoff99 | 27 | int count = 0; |
3784 | zoff99 | 40 | |
3785 | zoff99 | 27 | if (!this_->route) |
3786 | zoff99 | 40 | { |
3787 | zoff99 | 2 | return; |
3788 | zoff99 | 40 | } |
3789 | |||
3790 | zoff99 | 27 | map = route_get_map(this_->route); |
3791 | zoff99 | 40 | |
3792 | zoff99 | 2 | if (map) |
3793 | zoff99 | 40 | { |
3794 | zoff99 | 27 | mr = map_rect_new(map, NULL); |
3795 | zoff99 | 40 | } |
3796 | |||
3797 | zoff99 | 27 | if (mr) |
3798 | { | ||
3799 | while ((item = map_rect_get_item(mr))) | ||
3800 | { | ||
3801 | while (item_coord_get(item, &c, 1)) | ||
3802 | { | ||
3803 | if (!count) | ||
3804 | zoff99 | 40 | { |
3805 | zoff99 | 27 | r.lu = r.rl = c; |
3806 | zoff99 | 40 | } |
3807 | zoff99 | 2 | else |
3808 | zoff99 | 40 | { |
3809 | zoff99 | 27 | coord_rect_extend(&r, &c); |
3810 | zoff99 | 40 | } |
3811 | zoff99 | 2 | count++; |
3812 | } | ||
3813 | } | ||
3814 | map_rect_destroy(mr); | ||
3815 | } | ||
3816 | zoff99 | 40 | |
3817 | zoff99 | 27 | if (!count) |
3818 | zoff99 | 40 | { |
3819 | zoff99 | 2 | return; |
3820 | zoff99 | 40 | } |
3821 | |||
3822 | zoff99 | 2 | if (orientation != -1) |
3823 | zoff99 | 40 | { |
3824 | zoff99 | 2 | transform_set_yaw(this_->trans, orientation); |
3825 | zoff99 | 40 | } |
3826 | |||
3827 | zoff99 | 41 | // if overspill > 1 ? |
3828 | if (global_overspill_factor > 1.0f) | ||
3829 | { | ||
3830 | coord_rect_extend_by_percent(&r, (global_overspill_factor - 1.0f)); | ||
3831 | } | ||
3832 | |||
3833 | zoff99 | 2 | navit_zoom_to_rect(this_, &r); |
3834 | } | ||
3835 | |||
3836 | zoff99 | 27 | static void navit_cmd_zoom_to_route(struct navit *this) |
3837 | zoff99 | 2 | { |
3838 | zoff99 | 40 | |
3839 | |||
3840 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
3841 | zoff99 | 2 | navit_zoom_to_route(this, 0); |
3842 | } | ||
3843 | |||
3844 | /** | ||
3845 | * show point on map | ||
3846 | * | ||
3847 | * @param navit The navit instance | ||
3848 | * @param center The point where to center the map, including its projection | ||
3849 | * @returns nothing | ||
3850 | */ | ||
3851 | zoff99 | 27 | void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout) |
3852 | zoff99 | 2 | { |
3853 | zoff99 | 40 | |
3854 | |||
3855 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
3856 | struct coord *c = transform_center(this_->trans); | ||
3857 | struct coord c1, c2; | ||
3858 | zoff99 | 2 | enum projection pro = transform_get_projection(this_->trans); |
3859 | zoff99 | 34 | |
3860 | zoff99 | 27 | if (pro != center->pro) |
3861 | { | ||
3862 | zoff99 | 2 | c1.x = center->x; |
3863 | c1.y = center->y; | ||
3864 | transform_from_to(&c1, center->pro, &c2, pro); | ||
3865 | zoff99 | 27 | } |
3866 | else | ||
3867 | { | ||
3868 | zoff99 | 2 | c2.x = center->x; |
3869 | c2.y = center->y; | ||
3870 | } | ||
3871 | zoff99 | 34 | |
3872 | zoff99 | 27 | *c = c2; |
3873 | if (set_timeout) | ||
3874 | { | ||
3875 | zoff99 | 2 | navit_set_timeout(this_); |
3876 | zoff99 | 27 | } |
3877 | zoff99 | 34 | |
3878 | zoff99 | 2 | if (this_->ready == 3) |
3879 | zoff99 | 27 | { |
3880 | zoff99 | 2 | navit_draw(this_); |
3881 | zoff99 | 27 | } |
3882 | zoff99 | 2 | } |
3883 | |||
3884 | zoff99 | 41 | |
3885 | void navit_set_center_no_draw(struct navit *this_, struct pcoord *center, int set_timeout) | ||
3886 | { | ||
3887 | |||
3888 | |||
3889 | ////DBG dbg(0,"EEnter\n"); | ||
3890 | struct coord *c = transform_center(this_->trans); | ||
3891 | struct coord c1, c2; | ||
3892 | enum projection pro = transform_get_projection(this_->trans); | ||
3893 | |||
3894 | if (pro != center->pro) | ||
3895 | { | ||
3896 | c1.x = center->x; | ||
3897 | c1.y = center->y; | ||
3898 | transform_from_to(&c1, center->pro, &c2, pro); | ||
3899 | } | ||
3900 | else | ||
3901 | { | ||
3902 | c2.x = center->x; | ||
3903 | c2.y = center->y; | ||
3904 | } | ||
3905 | |||
3906 | *c = c2; | ||
3907 | if (set_timeout) | ||
3908 | { | ||
3909 | navit_set_timeout(this_); | ||
3910 | } | ||
3911 | } | ||
3912 | |||
3913 | zoff99 | 27 | static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout) |
3914 | zoff99 | 2 | { |
3915 | zoff99 | 40 | |
3916 | |||
3917 | zoff99 | 27 | ////DBG dbg(0,"EEnter\n"); |
3918 | zoff99 | 2 | int width, height; |
3919 | struct point po; | ||
3920 | transform_set_center(this_->trans, c); | ||
3921 | transform_get_size(this_->trans, &width, &height); | ||
3922 | zoff99 | 27 | po.x = width / 2; |
3923 | po.y = height / 2; | ||
3924 | zoff99 | 2 | update_transformation(this_->trans, &po, p, NULL); |
3925 | if (set_timeout) | ||
3926 | zoff99 | 27 | { |
3927 | zoff99 | 2 | navit_set_timeout(this_); |
3928 | zoff99 | 27 | } |
3929 | zoff99 | 2 | } |
3930 | |||
3931 | /** | ||
3932 | * Links all vehicles to a cursor depending on the current profile. | ||
3933 | * | ||
3934 | * @param this_ A navit instance | ||
3935 | * @author Ralph Sennhauser (10/2009) | ||
3936 | */ | ||
3937 | zoff99 | 27 | void navit_set_cursors(struct navit *this_) |
3938 | zoff99 | 2 | { |
3939 | zoff99 | 40 | |
3940 | |||
3941 | zoff99 | 2 | struct attr name; |
3942 | struct navit_vehicle *nv; | ||
3943 | struct cursor *c; | ||
3944 | GList *v; | ||
3945 | |||
3946 | zoff99 | 27 | //dbg(0, "Enter\n"); |
3947 | |||
3948 | v = g_list_first(this_->vehicles); // GList of navit_vehicles | ||
3949 | while (v) | ||
3950 | { | ||
3951 | dbg(0, "* found vehicle *\n"); | ||
3952 | nv = v->data; | ||
3953 | if (vehicle_get_attr(nv->vehicle, attr_cursorname, &name, NULL)) | ||
3954 | { | ||
3955 | if (!strcmp(name.u.str, "none")) | ||
3956 | { | ||
3957 | c = NULL; | ||
3958 | } | ||
3959 | zoff99 | 2 | else |
3960 | zoff99 | 27 | { |
3961 | c = layout_get_cursor(this_->layout_current, name.u.str); | ||
3962 | } | ||
3963 | } | ||
3964 | else | ||
3965 | { | ||
3966 | c = layout_get_cursor(this_->layout_current, "default"); | ||
3967 | } | ||
3968 | zoff99 | 2 | vehicle_set_cursor(nv->vehicle, c, 0); |
3969 | zoff99 | 27 | v = g_list_next(v); |
3970 | zoff99 | 2 | } |
3971 | return; | ||
3972 | } | ||
3973 | |||
3974 | zoff99 | 27 | void navit_remove_cursors(struct navit *this_) |
3975 | zoff99 | 2 | { |
3976 | zoff99 | 40 | |
3977 | |||
3978 | zoff99 | 27 | struct attr name; |
3979 | struct navit_vehicle *nv; | ||
3980 | struct cursor *c; | ||
3981 | GList *v; | ||
3982 | |||
3983 | //dbg(0, "Enter\n"); | ||
3984 | name.type = attr_cursor; | ||
3985 | |||
3986 | v = g_list_first(this_->vehicles); // GList of navit_vehicles | ||
3987 | while (v) | ||
3988 | { | ||
3989 | dbg(0, "* found vehicle *\n"); | ||
3990 | nv = v->data; | ||
3991 | vehicle_remove_attr(nv->vehicle, &name); | ||
3992 | v = g_list_next(v); | ||
3993 | } | ||
3994 | return; | ||
3995 | } | ||
3996 | |||
3997 | static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir) | ||
3998 | { | ||
3999 | zoff99 | 41 | //// dbg(0,"EEnter\n"); |
4000 | zoff99 | 40 | |
4001 | zoff99 | 2 | int width, height; |
4002 | zoff99 | 27 | struct navit_vehicle *nv = this_->vehicle; |
4003 | zoff99 | 2 | |
4004 | zoff99 | 41 | // valid values: 0 - 50 (0 -> center of screen, 50 -> bottom of screen) |
4005 | // float offset = this_->radius; // Cursor offset from the center of the screen (percent). // percent of what?? | ||
4006 | |||
4007 | float offset = 0; | ||
4008 | |||
4009 | |||
4010 | #if 0 | ||
4011 | |||
4012 | /* Better improve track.c to get that issue resolved or make it configurable with being off the default, the jumping back to the center is a bit annoying */ | ||
4013 | zoff99 | 27 | float min_offset = 0.; // Percent offset at min_offset_speed. |