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

Diff of /navit/navit/navit.c

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

Revision 27 Revision 28
129int global_speak_streetnames = 1; 129int global_speak_streetnames = 1;
130int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now 130int allow_large_mapfiles = 1; // allow the use of large (>2GB) mapfiles // -> value unused for now
131int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB) 131int cache_size_file = 1024 * 1024 * 10; // default value was: 20971520 (~20 MB)
132int draw_polylines_fast = 0; // default: 0 132int draw_polylines_fast = 0; // default: 0
133int limit_order_corrected = 4; // remain at this order level for drawing streets etc. 133int limit_order_corrected = 4; // remain at this order level for drawing streets etc.
134int shift_order = 0; // shift order level (for displaying objects) by this values (should only be bigger than zero!!)
134int global_search_street_size_factor = 1; // make search radius for streets bigger 135int global_search_street_size_factor = 1; // make search radius for streets bigger
136int disable_map_drawing = 0; // dont draw the map and dont read data from file (hopefully saving resources)
137int enable_water_from_relations = 1; // do you want to draw water where the "tags" come from osm-"relations"
138int hold_drawing = 0; // 0 -> draw normal , 1 -> dont do any drawing
139
140long long draw_lines_count_2 = 0;
141long long draw_lines_count_3 = 0;
142long long draw_lines_count_4 = 0;
143
144int 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]
145int cur_mapdraw_time_index = 0;
135 146
136void navit_add_mapset(struct navit *this_, struct mapset *ms) 147void navit_add_mapset(struct navit *this_, struct mapset *ms)
137{ 148{
149#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
150 dbg(0,"+#+:enter\n");
151#endif
138 ////DBG dbg(0,"EEnter\n"); 152 ////DBG dbg(0,"EEnter\n");
139 this_->mapsets = g_list_append(this_->mapsets, ms); 153 this_->mapsets = g_list_append(this_->mapsets, ms);
154#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
155 dbg(0,"+#+:leave\n");
156#endif
140} 157}
141 158
142struct mapset * 159struct mapset *
143navit_get_mapset(struct navit *this_) 160navit_get_mapset(struct navit *this_)
144{ 161{
162#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
163 dbg(0,"+#+:enter\n");
164#endif
145 ////DBG dbg(0,"EEnter\n"); 165 ////DBG dbg(0,"EEnter\n");
146 if (this_->mapsets) 166 if (this_->mapsets)
147 { 167 {
148 return this_->mapsets->data; 168 return this_->mapsets->data;
149 } 169 }
155} 175}
156 176
157struct tracking * 177struct tracking *
158navit_get_tracking(struct navit *this_) 178navit_get_tracking(struct navit *this_)
159{ 179{
180#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
181 dbg(0,"+#+:enter\n");
182#endif
160 ////DBG dbg(0,"EEnter\n"); 183 ////DBG dbg(0,"EEnter\n");
161 return this_->tracking; 184 return this_->tracking;
162} 185}
163 186
164/** 187/**
172 * 195 *
173 */ 196 */
174char* 197char*
175navit_get_user_data_directory(int create) 198navit_get_user_data_directory(int create)
176{ 199{
200#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
201 dbg(0,"+#+:enter\n");
202#endif
177 ////DBG dbg(0,"EEnter\n"); 203 ////DBG dbg(0,"EEnter\n");
178 char *dir; 204 char *dir;
179 dir = getenv("NAVIT_USER_DATADIR"); 205 dir = getenv("NAVIT_USER_DATADIR");
180 if (create && !file_exists(dir)) 206 if (create && !file_exists(dir))
181 { 207 {
189 return dir; 215 return dir;
190} /* end: navit_get_user_data_directory(gboolean create) */ 216} /* end: navit_get_user_data_directory(gboolean create) */
191 217
192void navit_draw_async(struct navit *this_, int async) 218void navit_draw_async(struct navit *this_, int async)
193{ 219{
220#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
221 dbg(0,"+#+:enter\n");
222#endif
194 //DBG dbg(0,"EEnter this_->blocked=%d\n",this_->blocked); 223 //dbg(0,"EEnter this_->blocked=%d\n",this_->blocked);
195 if (this_->blocked) 224 if (this_->blocked)
196 { 225 {
197 this_->blocked |= 2; 226 this_->blocked |= 2;
198 ////DBG dbg(0,"set this_->blocked=%d\n",this_->blocked); 227 //dbg(0,"set this_->blocked=%d\n",this_->blocked);
199 return; 228 return;
200 } 229 }
201 transform_setup_source_rect(this_->trans); 230 transform_setup_source_rect(this_->trans);
231 //dbg(0,"call graphics_draw\n");
202 graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1); 232 graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags | 1);
203} 233}
204 234
205void navit_draw(struct navit *this_) 235void navit_draw(struct navit *this_)
206{ 236{
237#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
238 dbg(0,"+#+:enter\n");
239#endif
240
207 ////DBG dbg(0,"EEnter this_->ready=%d\n",this_->ready); 241 //dbg(0,"EEnter this_->ready=%d\n",this_->ready);
208 if (this_->ready == 3) 242 if (this_->ready == 3)
209 { 243 {
210 ////DBG dbg(0,"navit_draw_async_001\n"); 244 //dbg(0,"navit_draw_async_001\n");
211 navit_draw_async(this_, 0); 245 navit_draw_async(this_, 0);
212 } 246 }
213} 247}
214 248
215int navit_get_ready(struct navit *this_) 249int navit_get_ready(struct navit *this_)
216{ 250{
251#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
252 dbg(0,"+#+:enter\n");
253#endif
217 ////DBG dbg(0,"EEnter\n"); 254 ////DBG dbg(0,"EEnter\n");
218 return this_->ready; 255 return this_->ready;
219} 256}
220 257
221void navit_draw_displaylist(struct navit *this_) 258void navit_draw_displaylist(struct navit *this_)
222{ 259{
260#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
261 dbg(0,"+#+:enter\n");
262#endif
223 ////DBG dbg(0,"EEnter\n"); 263 ////DBG dbg(0,"EEnter\n");
224 if (this_->ready == 3) 264 if (this_->ready == 3)
225 { 265 {
226 // //DBG dbg(0,"call graphics_displaylist_draw 2") 266 // //DBG dbg(0,"call graphics_displaylist_draw 2")
227 graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags | 1); 267 graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags | 1);
228 } 268 }
229} 269}
230 270
231static void navit_map_progress(struct navit *this_) 271static void navit_map_progress(struct navit *this_)
232{ 272{
273#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
274 dbg(0,"+#+:enter\n");
275#endif
233 ////DBG dbg(0,"EEnter\n"); 276 ////DBG dbg(0,"EEnter\n");
234 struct map *map; 277 struct map *map;
235 struct mapset *ms; 278 struct mapset *ms;
236 struct mapset_handle *msh; 279 struct mapset_handle *msh;
237 struct attr attr; 280 struct attr attr;
258 mapset_close(msh); 301 mapset_close(msh);
259} 302}
260 303
261static void navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr) 304static void navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr)
262{ 305{
306#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
307 dbg(0,"+#+:enter\n");
308#endif
309
263 ////DBG dbg(0,"EEnter\n"); 310 ////DBG dbg(0,"EEnter\n");
264 int updated; 311 int updated;
265 312
266 if ((this_->route) && (this_->route->route_status_was_updated == 1)) 313 if ((this_->route) && (this_->route->route_status_was_updated == 1))
267 { 314 {
307 ////DBG dbg(0,"draw e*\n"); 354 ////DBG dbg(0,"draw e*\n");
308} 355}
309 356
310void navit_handle_resize(struct navit *this_, int w, int h) 357void navit_handle_resize(struct navit *this_, int w, int h)
311{ 358{
359#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
360 dbg(0,"+#+:enter\n");
361#endif
362
312 //DBG dbg(0,"EEnter\n"); 363 dbg(0,"EEnter\n");
313 struct map_selection sel; 364 struct map_selection sel;
314 int callback = (this_->ready == 1); 365 int callback = (this_->ready == 1);
315 ////DBG dbg(0,"pre this_->ready=%d\n",this_->ready); 366 dbg(0,"pre this_->ready=%d\n",this_->ready);
316 this_->ready |= 2; 367 this_->ready = this_->ready | 2;
317 ////DBG dbg(0,"set this_->ready=%d\n",this_->ready); 368 dbg(0,"set this_->ready=%d\n",this_->ready);
318 memset(&sel, 0, sizeof(sel)); 369 memset(&sel, 0, sizeof(sel));
319 this_->w = w; 370 this_->w = w;
320 this_->h = h; 371 this_->h = h;
321 sel.u.p_rect.rl.x = w; 372 sel.u.p_rect.rl.x = w;
322 sel.u.p_rect.rl.y = h; 373 sel.u.p_rect.rl.y = h;
328 //DBG dbg(0,"callback do\n"); 379 //DBG dbg(0,"callback do\n");
329 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); 380 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
330 } 381 }
331 if (this_->ready == 3) 382 if (this_->ready == 3)
332 { 383 {
333 //DBG dbg(0,"navit_draw_async_002\n"); 384 dbg(0,"navit_draw_async_002\n");
385 // navit_draw_async(this_, 1);
334 navit_draw_async(this_, 1); 386 navit_draw_async(this_, 0);
335 } 387 }
336} 388}
337 389
338void navit_resize(void *data, int w, int h) 390void navit_resize(void *data, int w, int h)
339{ 391{
392#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
393 dbg(0,"+#+:enter\n");
394#endif
395
340 //DBG dbg(0,"EEnter %p\n", data); 396 //DBG dbg(0,"EEnter %p\n", data);
341 struct navit *this = data; 397 struct navit *this = data;
342 if (!this->ignore_graphics_events) 398 if (!this->ignore_graphics_events)
343 { 399 {
344 //DBG dbg(0,"11\n"); 400 //DBG dbg(0,"11\n");
346 } 402 }
347} 403}
348 404
349int navit_get_width(struct navit *this_) 405int navit_get_width(struct navit *this_)
350{ 406{
407#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
408 dbg(0,"+#+:enter\n");
409#endif
351 ////DBG dbg(0,"EEnter\n"); 410 ////DBG dbg(0,"EEnter\n");
352 return this_->w; 411 return this_->w;
353} 412}
354 413
355int navit_get_height(struct navit *this_) 414int navit_get_height(struct navit *this_)
356{ 415{
416#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
417 dbg(0,"+#+:enter\n");
418#endif
357 ////DBG dbg(0,"EEnter\n"); 419 ////DBG dbg(0,"EEnter\n");
358 return this_->h; 420 return this_->h;
359} 421}
360 422
361static void navit_popup(void *data) 423static void navit_popup(void *data)
362{ 424{
425#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
426 dbg(0,"+#+:enter\n");
427#endif
363 ////DBG dbg(0,"EEnter\n"); 428 ////DBG dbg(0,"EEnter\n");
364 struct navit *this_ = data; 429 struct navit *this_ = data;
365 popup(this_, 1, &this_->pressed); 430 popup(this_, 1, &this_->pressed);
366 this_->button_timeout = NULL; 431 this_->button_timeout = NULL;
367 this_->popped = 1; 432 this_->popped = 1;
368} 433}
369 434
370int navit_ignore_button(struct navit *this_) 435int navit_ignore_button(struct navit *this_)
371{ 436{
437#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
438 dbg(0,"+#+:enter\n");
439#endif
372 ////DBG dbg(0,"EEnter\n"); 440 ////DBG dbg(0,"EEnter\n");
373 if (this_->ignore_button) 441 if (this_->ignore_button)
374 return 1; 442 return 1;
375 this_->ignore_button = 1; 443 this_->ignore_button = 1;
376 return 0; 444 return 0;
377} 445}
378 446
379void navit_ignore_graphics_events(struct navit *this_, int ignore) 447void navit_ignore_graphics_events(struct navit *this_, int ignore)
380{ 448{
449#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
450 dbg(0,"+#+:enter\n");
451#endif
381 ////DBG dbg(0,"EEnter\n"); 452 ////DBG dbg(0,"EEnter\n");
382 this_->ignore_graphics_events = ignore; 453 this_->ignore_graphics_events = ignore;
383} 454}
384 455
385static void update_transformation(struct transformation *tr, struct point *old, struct point *new, struct point *rot) 456void update_transformation(struct transformation *tr, struct point *old, struct point *new, struct point *rot)
386{ 457{
458#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
459 dbg(0,"+#+:enter\n");
460#endif
387 ////DBG dbg(0,"EEnter\n"); 461 ////DBG dbg(0,"EEnter\n");
388 struct coord co, cn; 462 struct coord co, cn;
389 struct coord c, *cp; 463 struct coord c, *cp;
390 int yaw; 464 int yaw;
391 double angleo, anglen; 465 double angleo, anglen;
408 transform_set_center(tr, &c); 482 transform_set_center(tr, &c);
409} 483}
410 484
411void navit_set_timeout(struct navit *this_) 485void navit_set_timeout(struct navit *this_)
412{ 486{
487#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
488 dbg(0,"+#+:enter\n");
489#endif
490
491 // --------- DISABLE -----------
492 // --------- DISABLE -----------
493 // --------- DISABLE -----------
494 // --------- DISABLE -----------
495 return;
496 // --------- DISABLE -----------
497 // --------- DISABLE -----------
498 // --------- DISABLE -----------
499 // --------- DISABLE -----------
500
501
413 ////DBG dbg(0,"EEnter\n"); 502 ////DBG dbg(0,"EEnter\n");
414 struct attr follow; 503 struct attr follow;
415 follow.type = attr_follow; 504 follow.type = attr_follow;
416 follow.u.num = this_->center_timeout; 505 follow.u.num = this_->center_timeout;
417 navit_set_attr(this_, &follow); 506 navit_set_attr(this_, &follow);
418} 507}
419 508
420int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback) 509int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback)
421{ 510{
511#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
512 dbg(0,"+#+:enter\n");
513#endif
422 ////DBG dbg(0,"EEnter\n"); 514 ////DBG dbg(0,"EEnter\n");
423 int border = 16; 515 int border = 16;
424 516
425 // dbg(1, "enter %d %d (ignore %d)\n", pressed, button, this_->ignore_button); 517 // dbg(1, "enter %d %d (ignore %d)\n", pressed, button, this_->ignore_button);
426 callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p); 518 callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p);
437 if (button == 1) 529 if (button == 1)
438 { 530 {
439 this_->button_pressed = 1; 531 this_->button_pressed = 1;
440 this_->moved = 0; 532 this_->moved = 0;
441 this_->popped = 0; 533 this_->popped = 0;
534 // ---- DISBALED --------
535 /*
442 if (popup_callback) 536 if (popup_callback)
443 this_->button_timeout = event_add_timeout(500, 0, popup_callback); 537 this_->button_timeout = event_add_timeout(500, 0, popup_callback);
538 */
444 } 539 }
445 if (button == 2) 540 if (button == 2)
446 navit_set_center_screen(this_, p, 1); 541 navit_set_center_screen(this_, p, 1);
447 if (button == 3) 542 if (button == 3)
448 popup(this_, button, p); 543 popup(this_, button, p);
498 return 0; 593 return 0;
499} 594}
500 595
501static void navit_button(void *data, int pressed, int button, struct point *p) 596static void navit_button(void *data, int pressed, int button, struct point *p)
502{ 597{
598#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
599 dbg(0,"+#+:enter\n");
600#endif
503 ////DBG dbg(0,"EEnter\n"); 601 ////DBG dbg(0,"EEnter\n");
504 struct navit *this = data; 602 struct navit *this = data;
505 // dbg(1, "enter %d %d ignore %d\n", pressed, button, this->ignore_graphics_events); 603 // dbg(1, "enter %d %d ignore %d\n", pressed, button, this->ignore_graphics_events);
506 if (!this->ignore_graphics_events) 604 if (!this->ignore_graphics_events)
507 { 605 {
508 if (!this->popup_callback) 606 if (!this->popup_callback)
607 {
509 this->popup_callback = callback_new_1(callback_cast(navit_popup), this); 608 this->popup_callback = callback_new_1(callback_cast(navit_popup), this);
609 }
510 navit_handle_button(this, pressed, button, p, this->popup_callback); 610 navit_handle_button(this, pressed, button, p, this->popup_callback);
511 } 611 }
512} 612}
513 613
514static void navit_motion_timeout(struct navit *this_) 614static void navit_motion_timeout(struct navit *this_)
515{ 615{
616#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
617 dbg(0,"+#+:enter\n");
618#endif
516 ////DBG dbg(0,"EEnter\n"); 619 ////DBG dbg(0,"EEnter\n");
517 int dx, dy; 620 int dx, dy;
518 621
519 if (this_->drag_bitmap) 622 if (this_->drag_bitmap)
520 { 623 {
559 return; 662 return;
560} 663}
561 664
562void navit_handle_motion(struct navit *this_, struct point *p) 665void navit_handle_motion(struct navit *this_, struct point *p)
563{ 666{
667#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
668 dbg(0,"+#+:enter\n");
669#endif
564 ////DBG dbg(0,"EEnter\n"); 670 ////DBG dbg(0,"EEnter\n");
565 int dx, dy; 671 int dx, dy;
566 672
567 if (this_->button_pressed && !this_->popped) 673 if (this_->button_pressed && !this_->popped)
568 { 674 {
575 { 681 {
576 event_remove_timeout(this_->button_timeout); 682 event_remove_timeout(this_->button_timeout);
577 this_->button_timeout = NULL; 683 this_->button_timeout = NULL;
578 } 684 }
579 this_->current = *p; 685 this_->current = *p;
686
687 // -------- DISABLE -------
688 // -------- DISABLE -------
689 // -------- DISABLE -------
690 /*
580 if (!this_->motion_timeout_callback) 691 if (!this_->motion_timeout_callback)
581 this_->motion_timeout_callback = callback_new_1(callback_cast(navit_motion_timeout), this_); 692 this_->motion_timeout_callback = callback_new_1(callback_cast(navit_motion_timeout), this_);
582 if (!this_->motion_timeout) 693 if (!this_->motion_timeout)
583 this_->motion_timeout = event_add_timeout(100, 0, this_->motion_timeout_callback); 694 this_->motion_timeout = event_add_timeout(100, 0, this_->motion_timeout_callback);
584 } 695 */
696 // -------- DISABLE -------
697 // -------- DISABLE -------
698 // -------- DISABLE -------
585 } 699 }
700 }
586} 701}
587 702
588static void navit_motion(void *data, struct point *p) 703void navit_motion(void *data, struct point *p)
589{ 704{
705#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
706 dbg(0,"+#+:enter\n");
707#endif
590 ////DBG dbg(0,"EEnter\n"); 708 ////DBG dbg(0,"EEnter\n");
591 struct navit *this = data; 709 struct navit *this = data;
592 if (!this->ignore_graphics_events) 710 if (!this->ignore_graphics_events)
711 {
593 navit_handle_motion(this, p); 712 navit_handle_motion(this, p);
713 }
594} 714}
595 715
596static void navit_predraw(struct navit *this_) 716static void navit_predraw(struct navit *this_)
597{ 717{
718#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
719 dbg(0,"+#+:enter\n");
720#endif
598 ////DBG dbg(0,"EEnter\n"); 721 ////DBG dbg(0,"EEnter\n");
599 GList *l; 722 GList *l;
600 struct navit_vehicle *nv; 723 struct navit_vehicle *nv;
601 transform_copy(this_->trans, this_->trans_cursor); 724 transform_copy(this_->trans, this_->trans_cursor);
602 l = this_->vehicles; 725 l = this_->vehicles;
610 } 733 }
611} 734}
612 735
613static void navit_scale(struct navit *this_, long scale, struct point *p, int draw) 736static void navit_scale(struct navit *this_, long scale, struct point *p, int draw)
614{ 737{
738#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
739 dbg(0,"+#+:enter\n");
740#endif
615 //DBG dbg(0,"EEnter\n"); 741 //DBG dbg(0,"EEnter\n");
616 struct coord c1, c2, *center; 742 struct coord c1, c2, *center;
617 743
618 if (scale < this_->zoom_min) 744 if (scale < this_->zoom_min)
619 { 745 {
666 * @param speed The vehicles speed in meters per second 792 * @param speed The vehicles speed in meters per second
667 * @param dir The direction into which the vehicle moves 793 * @param dir The direction into which the vehicle moves
668 */ 794 */
669static void navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw) 795static void navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw)
670{ 796{
797#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
798 dbg(0,"+#+:enter\n");
799#endif
671 struct point pc; 800 struct point pc;
672 int distance, w, h; 801 int distance, w, h;
673 double new_scale; 802 double new_scale;
674 long scale; 803 long scale;
675 804
724 * @param p The invariant point (if set to NULL, default to center) 853 * @param p The invariant point (if set to NULL, default to center)
725 * @returns nothing 854 * @returns nothing
726 */ 855 */
727void navit_zoom_in(struct navit *this_, int factor, struct point *p) 856void navit_zoom_in(struct navit *this_, int factor, struct point *p)
728{ 857{
858#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
859 dbg(0,"+#+:enter\n");
860#endif
729 ////DBG dbg(0,"EEnter\n"); 861 ////DBG dbg(0,"EEnter\n");
730 long scale = transform_get_scale(this_->trans) / factor; 862 long scale = transform_get_scale(this_->trans) / factor;
731 if (scale < 1) 863 if (scale < 1)
732 scale = 1; 864 scale = 1;
733 ////DBG dbg(0,"zoom in -> scale=%d",scale); 865 ////DBG dbg(0,"zoom in -> scale=%d",scale);
742 * @param p The invariant point (if set to NULL, default to center) 874 * @param p The invariant point (if set to NULL, default to center)
743 * @returns nothing 875 * @returns nothing
744 */ 876 */
745void navit_zoom_out(struct navit *this_, int factor, struct point *p) 877void navit_zoom_out(struct navit *this_, int factor, struct point *p)
746{ 878{
879#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
880 dbg(0,"+#+:enter\n");
881#endif
747 ////DBG dbg(0,"EEnter\n"); 882 ////DBG dbg(0,"EEnter\n");
748 long scale = transform_get_scale(this_->trans) * factor; 883 long scale = transform_get_scale(this_->trans) * factor;
749 ////DBG dbg(0,"zoom out -> scale=%d",scale); 884 ////DBG dbg(0,"zoom out -> scale=%d",scale);
750 navit_scale(this_, scale, p, 1); 885 navit_scale(this_, scale, p, 1);
751} 886}
752 887
753int navit_get_cur_pnt(struct navit *this_, struct point *p) 888int navit_get_cur_pnt(struct navit *this_, struct point *p)
754{ 889{
890#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
891 dbg(0,"+#+:enter\n");
892#endif
755 ////DBG dbg(0,"EEnter\n"); 893 ////DBG dbg(0,"EEnter\n");
756 return navit_get_cursor_pnt(this_, p, 0, NULL); 894 return navit_get_cursor_pnt(this_, p, 0, NULL);
757} 895}
758 896
759void navit_zoom_in_cursor(struct navit *this_, int factor) 897void navit_zoom_in_cursor(struct navit *this_, int factor)
760{ 898{
899#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
900 dbg(0,"+#+:enter\n");
901#endif
761 ////DBG dbg(0,"EEnter\n"); 902 ////DBG dbg(0,"EEnter\n");
762 struct point p; 903 struct point p;
763 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) 904 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL))
764 { 905 {
765 navit_zoom_in(this_, factor, &p); 906 navit_zoom_in(this_, factor, &p);
769 navit_zoom_in(this_, factor, NULL); 910 navit_zoom_in(this_, factor, NULL);
770} 911}
771 912
772void navit_zoom_to_scale(struct navit *this_, int new_scale) 913void navit_zoom_to_scale(struct navit *this_, int new_scale)
773{ 914{
915#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
916 dbg(0,"+#+:enter\n");
917#endif
774 //DBG dbg(0,"EEnter\n"); 918 //DBG dbg(0,"EEnter\n");
775 long scale = transform_get_scale(this_->trans); 919 long scale = transform_get_scale(this_->trans);
776 long new_scale_long = new_scale; 920 long new_scale_long = new_scale;
777 //DBG dbg(0,"zoom to scale -> old scale=%d",scale); 921 //DBG dbg(0,"zoom to scale -> old scale=%d",scale);
778 //DBG dbg(0,"zoom to scale -> want scale=%d",new_scale_long); 922 //DBG dbg(0,"zoom to scale -> want scale=%d",new_scale_long);
780 // only do something if scale changed! 924 // only do something if scale changed!
781 if (scale != new_scale_long) 925 if (scale != new_scale_long)
782 { 926 {
783 navit_scale(this_, new_scale_long, NULL, 1); 927 navit_scale(this_, new_scale_long, NULL, 1);
784 } 928 }
929#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
930 dbg(0,"+#+:leave\n");
931#endif
932}
933
934void navit_zoom_to_scale_with_center_point(struct navit *this_, int new_scale, struct point *p)
935{
936#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
937 dbg(0,"+#+:enter\n");
938#endif
939 //DBG dbg(0,"EEnter\n");
940 long scale = transform_get_scale(this_->trans);
941 long new_scale_long = new_scale;
942 dbg(0, "zoom to scale -> old scale=%d", scale);
943 dbg(0, "zoom to scale -> want scale=%d", new_scale_long);
944
945 // only do something if scale changed!
946 if (scale != new_scale_long)
947 {
948 navit_scale(this_, new_scale_long, p, 1);
949 }
785} 950}
786 951
787void navit_zoom_out_cursor(struct navit *this_, int factor) 952void navit_zoom_out_cursor(struct navit *this_, int factor)
788{ 953{
954#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
955 dbg(0,"+#+:enter\n");
956#endif
789 ////DBG dbg(0,"EEnter\n"); 957 ////DBG dbg(0,"EEnter\n");
790 struct point p; 958 struct point p;
791 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) 959 if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL))
792 { 960 {
793 navit_zoom_out(this_, 2, &p); 961 navit_zoom_out(this_, 2, &p);
797 navit_zoom_out(this_, 2, NULL); 965 navit_zoom_out(this_, 2, NULL);
798} 966}
799 967
800static int navit_cmd_zoom_in(struct navit *this_) 968static int navit_cmd_zoom_in(struct navit *this_)
801{ 969{
970#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
971 dbg(0,"+#+:enter\n");
972#endif
802 ////DBG dbg(0,"EEnter\n"); 973 ////DBG dbg(0,"EEnter\n");
803 navit_zoom_in_cursor(this_, 2); 974 navit_zoom_in_cursor(this_, 2);
804 return 0; 975 return 0;
805} 976}
806 977
807static int navit_cmd_zoom_out(struct navit *this_) 978static int navit_cmd_zoom_out(struct navit *this_)
808{ 979{
980#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
981 dbg(0,"+#+:enter\n");
982#endif
809 ////DBG dbg(0,"EEnter\n"); 983 ////DBG dbg(0,"EEnter\n");
810 navit_zoom_out_cursor(this_, 2); 984 navit_zoom_out_cursor(this_, 2);
811 return 0; 985 return 0;
812} 986}
813 987
814static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 988static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
815{ 989{
990#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
991 dbg(0,"+#+:enter\n");
992#endif
816 ////DBG dbg(0,"EEnter\n"); 993 ////DBG dbg(0,"EEnter\n");
817 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) 994 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str)
818 { 995 {
819 navit_say(this, in[0]->u.str); 996 navit_say(this, in[0]->u.str);
820 } 997 }
833 * @param valid unused 1010 * @param valid unused
834 * @returns nothing 1011 * @returns nothing
835 */ 1012 */
836static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1013static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
837{ 1014{
1015#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1016 dbg(0,"+#+:enter\n");
1017#endif
838 ////DBG dbg(0,"EEnter\n"); 1018 ////DBG dbg(0,"EEnter\n");
839 char*key; 1019 char*key;
840 struct attr*val; 1020 struct attr*val;
841 if (!cmd_int_var_hash) 1021 if (!cmd_int_var_hash)
842 { 1022 {
863 * @returns nothing 1043 * @returns nothing
864 */ 1044 */
865//TODO free stored attributes on navit_destroy 1045//TODO free stored attributes on navit_destroy
866static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1046static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
867{ 1047{
1048#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1049 dbg(0,"+#+:enter\n");
1050#endif
868 ////DBG dbg(0,"EEnter\n"); 1051 ////DBG dbg(0,"EEnter\n");
869 char*key; 1052 char*key;
870 struct attr*val; 1053 struct attr*val;
871 if (!cmd_attr_var_hash) 1054 if (!cmd_attr_var_hash)
872 { 1055 {
892 * @param valid unused 1075 * @param valid unused
893 * @returns nothing 1076 * @returns nothing
894 */ 1077 */
895static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1078static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
896{ 1079{
1080#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1081 dbg(0,"+#+:enter\n");
1082#endif
897 ////DBG dbg(0,"EEnter\n"); 1083 ////DBG dbg(0,"EEnter\n");
898 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) 1084 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str)
899 { 1085 {
900 if (this->layout_current && this->layout_current->layers) 1086 if (this->layout_current && this->layout_current->layers)
901 { 1087 {
905 struct layer*l = layers->data; 1091 struct layer*l = layers->data;
906 if (l && !strcmp(l->name, in[0]->u.str)) 1092 if (l && !strcmp(l->name, in[0]->u.str))
907 { 1093 {
908 l->active ^= 1; 1094 l->active ^= 1;
909 navit_draw(this); 1095 navit_draw(this);
1096 return;
1097 }
1098 layers = g_list_next(layers);
1099 }
1100 }
1101 }
1102}
1103
1104/**
1105 * command to set the active state of a named layer of the current layout
1106 *
1107 * @param navit The navit instance
1108 * @param name name of the layer
1109 * @param active 0 -> inactive, 1 -> active
1110 * @param draw 0 -> dont redraw, 1 -> redraw
1111 * @returns nothing
1112 */
1113void navit_layer_set_active(struct navit *this, char *name, int active, int draw)
1114{
1115#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1116 dbg(0,"+#+:enter\n");
1117#endif
1118 //dbg(0,"EEnter\n");
1119 if (name)
1120 {
1121 if (this->layout_current && this->layout_current->layers)
1122 {
1123 GList* layers = this->layout_current->layers;
1124 while (layers)
1125 {
1126 struct layer *l = layers->data;
1127 if (l && !strcmp(l->name, name))
1128 {
1129 l->active = active;
1130 if (draw == 1)
1131 {
1132 navit_draw(this);
1133 }
910 return; 1134 return;
911 } 1135 }
912 layers = g_list_next(layers); 1136 layers = g_list_next(layers);
913 } 1137 }
914 } 1138 }
925 * @param valid unused 1149 * @param valid unused
926 * @returns nothing 1150 * @returns nothing
927 */ 1151 */
928static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1152static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
929{ 1153{
1154#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1155 dbg(0,"+#+:enter\n");
1156#endif
930 ////DBG dbg(0,"EEnter\n"); 1157 ////DBG dbg(0,"EEnter\n");
931 struct attr **list = g_new0(struct attr *,2); 1158 struct attr **list = g_new0(struct attr *,2);
932 struct attr*val = g_new0(struct attr,1); 1159 struct attr*val = g_new0(struct attr,1);
933 struct mapset* ms; 1160 struct mapset* ms;
934 struct map_selection sel; 1161 struct map_selection sel;
1014 * @param valid unused 1241 * @param valid unused
1015 * @returns nothing 1242 * @returns nothing
1016 */ 1243 */
1017static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1244static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1018{ 1245{
1246#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1247 dbg(0,"+#+:enter\n");
1248#endif
1019 ////DBG dbg(0,"EEnter\n"); 1249 ////DBG dbg(0,"EEnter\n");
1020 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name 1250 if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name
1021 in[1] && ATTR_IS_ITEM(in[1]->type) && //item 1251 in[1] && ATTR_IS_ITEM(in[1]->type) && //item
1022 in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str 1252 in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str
1023 in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str 1253 in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str
1084 * @param valid unused 1314 * @param valid unused
1085 * @returns nothing 1315 * @returns nothing
1086 */ 1316 */
1087static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1317static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1088{ 1318{
1319#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1320 dbg(0,"+#+:enter\n");
1321#endif
1089 ////DBG dbg(0,"EEnter\n"); 1322 ////DBG dbg(0,"EEnter\n");
1090 struct attr **list = g_new0(struct attr *,2); 1323 struct attr **list = g_new0(struct attr *,2);
1091 if (!cmd_int_var_hash) 1324 if (!cmd_int_var_hash)
1092 { 1325 {
1093 struct attr*val = g_new0(struct attr,1); 1326 struct attr*val = g_new0(struct attr,1);
1124 * @param valid unused 1357 * @param valid unused
1125 * @returns nothing 1358 * @returns nothing
1126 */ 1359 */
1127static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1360static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1128{ 1361{
1362#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1363 dbg(0,"+#+:enter\n");
1364#endif
1129 ////DBG dbg(0,"EEnter\n"); 1365 ////DBG dbg(0,"EEnter\n");
1130 struct attr **list = g_new0(struct attr *,2); 1366 struct attr **list = g_new0(struct attr *,2);
1131 if (!cmd_int_var_hash) 1367 if (!cmd_int_var_hash)
1132 { 1368 {
1133 struct attr*val = g_new0(struct attr,1); 1369 struct attr*val = g_new0(struct attr,1);
1166 * @param valid unused 1402 * @param valid unused
1167 * @returns nothing 1403 * @returns nothing
1168 */ 1404 */
1169static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1405static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1170{ 1406{
1407#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1408 dbg(0,"+#+:enter\n");
1409#endif
1171 ////DBG dbg(0,"EEnter\n"); 1410 ////DBG dbg(0,"EEnter\n");
1172 if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type)) 1411 if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type))
1173 { 1412 {
1174 struct attr*val = g_new(struct attr,1); 1413 struct attr*val = g_new(struct attr,1);
1175 attr_dup_content(in[0], val); 1414 attr_dup_content(in[0], val);
1187 * @param valid unused 1426 * @param valid unused
1188 * @returns nothing 1427 * @returns nothing
1189 */ 1428 */
1190static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1429static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1191{ 1430{
1431#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1432 dbg(0,"+#+:enter\n");
1433#endif
1192 ////DBG dbg(0,"EEnter\n"); 1434 ////DBG dbg(0,"EEnter\n");
1193 struct attr **list = g_new0(struct attr *,2); 1435 struct attr **list = g_new0(struct attr *,2);
1194 if (!cmd_int_var_stack) 1436 if (!cmd_int_var_stack)
1195 { 1437 {
1196 struct attr*val = g_new0(struct attr,1); 1438 struct attr*val = g_new0(struct attr,1);
1217 * @param valid unused 1459 * @param valid unused
1218 * @returns nothing 1460 * @returns nothing
1219 */ 1461 */
1220static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1462static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1221{ 1463{
1464#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1465 dbg(0,"+#+:enter\n");
1466#endif
1222 ////DBG dbg(0,"EEnter\n"); 1467 ////DBG dbg(0,"EEnter\n");
1223 struct attr **list; 1468 struct attr **list;
1224 struct attr *attr = g_new0(struct attr ,1); 1469 struct attr *attr = g_new0(struct attr ,1);
1225 attr->type = attr_type_int_begin; 1470 attr->type = attr_type_int_begin;
1226 if (!cmd_int_var_stack) 1471 if (!cmd_int_var_stack)
1237 cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack); 1482 cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack, cmd_int_var_stack);
1238} 1483}
1239 1484
1240static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1485static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1241{ 1486{
1487#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1488 dbg(0,"+#+:enter\n");
1489#endif
1242 ////DBG dbg(0,"EEnter\n"); 1490 ////DBG dbg(0,"EEnter\n");
1243 struct pcoord pc; 1491 struct pcoord pc;
1244 char *description = NULL; 1492 char *description = NULL;
1245 if (!in) 1493 if (!in)
1246 return; 1494 return;
1282 navit_set_destination(this, &pc, description, 1); 1530 navit_set_destination(this, &pc, description, 1);
1283} 1531}
1284 1532
1285static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1533static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1286{ 1534{
1535#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1536 dbg(0,"+#+:enter\n");
1537#endif
1287 ////DBG dbg(0,"EEnter\n"); 1538 ////DBG dbg(0,"EEnter\n");
1288 struct attr attr; 1539 struct attr attr;
1289 attr.type = attr_type_string_begin; 1540 attr.type = attr_type_string_begin;
1290 attr.u.str = "Fix me"; 1541 attr.u.str = "Fix me";
1291 if (out) 1542 if (out)
1304 * @param valid unused 1555 * @param valid unused
1305 * @returns nothing 1556 * @returns nothing
1306 */ 1557 */
1307static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1558static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1308{ 1559{
1560#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1561 dbg(0,"+#+:enter\n");
1562#endif
1309 ////DBG dbg(0,"EEnter\n"); 1563 ////DBG dbg(0,"EEnter\n");
1310 struct attr attr; 1564 struct attr attr;
1311 gchar *ret, *sep; 1565 gchar *ret, *sep;
1312 int i; 1566 int i;
1313 attr.type = attr_type_string_begin; 1567 attr.type = attr_type_string_begin;
1344 * @param valid unused 1598 * @param valid unused
1345 * @returns nothing 1599 * @returns nothing
1346 */ 1600 */
1347static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) 1601static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
1348{ 1602{
1603#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1604 dbg(0,"+#+:enter\n");
1605#endif
1349 ////DBG dbg(0,"EEnter\n"); 1606 ////DBG dbg(0,"EEnter\n");
1350 int i, j, nparms, nvalid; 1607 int i, j, nparms, nvalid;
1351 const char ** argv = NULL; 1608 const char ** argv = NULL;
1352 struct spawn_process_info *pi; 1609 struct spawn_process_info *pi;
1353 1610
1424{ "set_attr_var", command_cast(navit_cmd_set_attr_var) }, 1681{ "set_attr_var", command_cast(navit_cmd_set_attr_var) },
1425{ "get_attr_var", command_cast(navit_cmd_get_attr_var) }, }; 1682{ "get_attr_var", command_cast(navit_cmd_get_attr_var) }, };
1426 1683
1427void navit_command_add_table(struct navit*this_, struct command_table *commands, int count) 1684void navit_command_add_table(struct navit*this_, struct command_table *commands, int count)
1428{ 1685{
1686#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1687 dbg(0,"+#+:enter\n");
1688#endif
1429 ////DBG dbg(0,"EEnter\n"); 1689 ////DBG dbg(0,"EEnter\n");
1430 command_add_table(this_->attr_cbl, commands, count, this_); 1690 command_add_table(this_->attr_cbl, commands, count, this_);
1431} 1691}
1432 1692
1433struct navit * 1693struct navit *
1434navit_new(struct attr *parent, struct attr **attrs) 1694navit_new(struct attr *parent, struct attr **attrs)
1435{ 1695{
1696#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1697 dbg(0,"+#+:enter\n");
1698#endif
1436 ////DBG dbg(0,"EEnter\n"); 1699 ////DBG dbg(0,"EEnter\n");
1437 struct navit *this_=g_new0(struct navit, 1); 1700 struct navit *this_=g_new0(struct navit, 1);
1438 struct pcoord center; 1701 struct pcoord center;
1439 struct coord co; 1702 struct coord co;
1440 struct coord_geo g; 1703 struct coord_geo g;
1496 return this_; 1759 return this_;
1497} 1760}
1498 1761
1499static int navit_set_gui(struct navit *this_, struct gui *gui) 1762static int navit_set_gui(struct navit *this_, struct gui *gui)
1500{ 1763{
1764#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1765 dbg(0,"+#+:enter\n");
1766#endif
1501 ////DBG dbg(0,"EEnter\n"); 1767 ////DBG dbg(0,"EEnter\n");
1502 if (this_->gui) 1768 if (this_->gui)
1503 return 0; 1769 return 0;
1504 this_->gui = gui; 1770 this_->gui = gui;
1505 if (gui_has_main_loop(this_->gui)) 1771 if (gui_has_main_loop(this_->gui))
1517 return 1; 1783 return 1;
1518} 1784}
1519 1785
1520void navit_add_message(struct navit *this_, char *message) 1786void navit_add_message(struct navit *this_, char *message)
1521{ 1787{
1788#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1789 dbg(0,"+#+:enter\n");
1790#endif
1522 ////DBG dbg(0,"EEnter\n"); 1791 ////DBG dbg(0,"EEnter\n");
1523 // message_new(this_->messages, message); 1792 // message_new(this_->messages, message);
1524} 1793}
1525 1794
1526struct message *navit_get_messages(struct navit *this_) 1795struct message *navit_get_messages(struct navit *this_)
1527{ 1796{
1797#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1798 dbg(0,"+#+:enter\n");
1799#endif
1528 ////DBG dbg(0,"EEnter\n"); 1800 ////DBG dbg(0,"EEnter\n");
1529 // return message_get(this_->messages); 1801 // return message_get(this_->messages);
1530} 1802}
1531 1803
1532static int navit_set_graphics(struct navit *this_, struct graphics *gra) 1804static int navit_set_graphics(struct navit *this_, struct graphics *gra)
1533{ 1805{
1806#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1807 dbg(0,"+#+:enter\n");
1808#endif
1534 ////DBG dbg(0,"EEnter\n"); 1809 ////DBG dbg(0,"EEnter\n");
1535 if (this_->gra) 1810 if (this_->gra)
1536 return 0; 1811 return 0;
1537 this_->gra = gra; 1812 this_->gra = gra;
1813
1814 /*
1538 this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_); 1815 this_->resize_callback = callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_);
1539 graphics_add_callback(gra, this_->resize_callback); 1816 graphics_add_callback(gra, this_->resize_callback);
1540 this_->button_callback = callback_new_attr_1(callback_cast(navit_button), attr_button, this_); 1817 this_->button_callback = callback_new_attr_1(callback_cast(navit_button), attr_button, this_);
1541 graphics_add_callback(gra, this_->button_callback); 1818 graphics_add_callback(gra, this_->button_callback);
1542 this_->motion_callback = callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_); 1819 this_->motion_callback = callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_);
1543 graphics_add_callback(gra, this_->motion_callback); 1820 graphics_add_callback(gra, this_->motion_callback);
1821 */
1822
1823 // this draw the vehicle // very stupid
1544 this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_); 1824 this_->predraw_callback = callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_);
1545 graphics_add_callback(gra, this_->predraw_callback); 1825 graphics_add_callback(gra, this_->predraw_callback);
1826
1546 ////DBG dbg(0,"111111111\n"); 1827 ////DBG dbg(0,"111111111\n");
1547 return 1; 1828 return 1;
1548} 1829}
1549 1830
1550struct graphics * 1831struct graphics *
1551navit_get_graphics(struct navit *this_) 1832navit_get_graphics(struct navit *this_)
1552{ 1833{
1834#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1835 dbg(0,"+#+:enter\n");
1836#endif
1553 ////DBG dbg(0,"EEnter\n"); 1837 ////DBG dbg(0,"EEnter\n");
1554 return this_->gra; 1838 return this_->gra;
1555} 1839}
1556 1840
1557struct vehicleprofile * 1841struct vehicleprofile *
1558navit_get_vehicleprofile(struct navit *this_) 1842navit_get_vehicleprofile(struct navit *this_)
1559{ 1843{
1844#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1845 dbg(0,"+#+:enter\n");
1846#endif
1560 ////DBG dbg(0,"EEnter\n"); 1847 ////DBG dbg(0,"EEnter\n");
1561 return this_->vehicleprofile; 1848 return this_->vehicleprofile;
1562} 1849}
1563 1850
1564GList * 1851GList *
1565navit_get_vehicleprofiles(struct navit *this_) 1852navit_get_vehicleprofiles(struct navit *this_)
1566{ 1853{
1854#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1855 dbg(0,"+#+:enter\n");
1856#endif
1567 ////DBG dbg(0,"EEnter\n"); 1857 ////DBG dbg(0,"EEnter\n");
1568 return this_->vehicleprofiles; 1858 return this_->vehicleprofiles;
1569} 1859}
1570 1860
1571static void navit_projection_set(struct navit *this_, enum projection pro, int draw) 1861static void navit_projection_set(struct navit *this_, enum projection pro, int draw)
1572{ 1862{
1863#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1864 dbg(0,"+#+:enter\n");
1865#endif
1573 ////DBG dbg(0,"EEnter\n"); 1866 ////DBG dbg(0,"EEnter\n");
1574 struct coord_geo g; 1867 struct coord_geo g;
1575 struct coord *c; 1868 struct coord *c;
1576 1869
1577 c = transform_center(this_->trans); 1870 c = transform_center(this_->trans);
1578 transform_to_geo(transform_get_projection(this_->trans), c, &g); 1871 transform_to_geo(transform_get_projection(this_->trans), c, &g);
1579 transform_set_projection(this_->trans, pro); 1872 transform_set_projection(this_->trans, pro);
1580 transform_from_geo(pro, &g, c); 1873 transform_from_geo(pro, &g, c);
1581 if (draw) 1874 if (draw)
1875 {
1582 navit_draw(this_); 1876 navit_draw(this_);
1877 }
1583} 1878}
1584 1879
1585/** 1880/**
1586 * Start the route computing to a given set of coordinates 1881 * Start the route computing to a given set of coordinates
1587 * 1882 *
1590 * @param description A label which allows the user to later identify this destination in the former destinations selection 1885 * @param description A label which allows the user to later identify this destination in the former destinations selection
1591 * @returns nothing 1886 * @returns nothing
1592 */ 1887 */
1593void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async) 1888void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async)
1594{ 1889{
1890#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1891 dbg(0,"+#+:enter\n");
1892#endif
1595 ////DBG dbg(0,"EEnter\n"); 1893 ////DBG dbg(0,"EEnter\n");
1596 char *destination_file; 1894 char *destination_file;
1597 if (c) 1895 if (c)
1598 { 1896 {
1599 this_->destination = *c; 1897 this_->destination = *c;
1629 * @param description A dummy string 1927 * @param description A dummy string
1630 * @returns nothing 1928 * @returns nothing
1631 */ 1929 */
1632void navit_add_waypoint_to_route(struct navit *this_, struct pcoord *c, const char *description, int async) 1930void navit_add_waypoint_to_route(struct navit *this_, struct pcoord *c, const char *description, int async)
1633{ 1931{
1932#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1933 dbg(0,"+#+:enter\n");
1934#endif
1634 if (this_->destination_valid == 1) 1935 if (this_->destination_valid == 1)
1635 { 1936 {
1636 //int count = 0; 1937 //int count = 0;
1637 //count = g_list_length(this_->route->destinations); 1938 //count = g_list_length(this_->route->destinations);
1638 //DBG dbg(0, "count=%d\n", count); 1939 //DBG dbg(0, "count=%d\n", count);
1659 * @param description A label which allows the user to later identify this destination in the former destinations selection 1960 * @param description A label which allows the user to later identify this destination in the former destinations selection
1660 * @returns nothing 1961 * @returns nothing
1661 */ 1962 */
1662void navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async) 1963void navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async)
1663{ 1964{
1965#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
1966 dbg(0,"+#+:enter\n");
1967#endif
1664 ////DBG dbg(0,"EEnter\n"); 1968 ////DBG dbg(0,"EEnter\n");
1665 char *destination_file; 1969 char *destination_file;
1666 if (c && count) 1970 if (c && count)
1667 { 1971 {
1668 this_->destination = c[count - 1]; 1972 this_->destination = c[count - 1];
1695 * @param this_ The navit struct whose route should be checked. 1999 * @param this_ The navit struct whose route should be checked.
1696 * @return True if the route is set, false otherwise. 2000 * @return True if the route is set, false otherwise.
1697 */ 2001 */
1698int navit_check_route(struct navit *this_) 2002int navit_check_route(struct navit *this_)
1699{ 2003{
2004#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2005 dbg(0,"+#+:enter\n");
2006#endif
1700 ////DBG dbg(0,"EEnter\n"); 2007 ////DBG dbg(0,"EEnter\n");
1701 if (this_->route) 2008 if (this_->route)
1702 { 2009 {
1703 return route_get_path_set(this_->route); 2010 return route_get_path_set(this_->route);
1704 } 2011 }
1706 return 0; 2013 return 0;
1707} 2014}
1708 2015
1709static int navit_former_destinations_active(struct navit *this_) 2016static int navit_former_destinations_active(struct navit *this_)
1710{ 2017{
2018#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2019 dbg(0,"+#+:enter\n");
2020#endif
1711 ////DBG dbg(0,"EEnter\n"); 2021 ////DBG dbg(0,"EEnter\n");
1712 2022
1713 return 0; 2023 return 0;
1714 // disable this function!! 2024 // disable this function!!
1715 2025
1732 return active; 2042 return active;
1733} 2043}
1734 2044
1735static void navit_add_former_destinations_from_file(struct navit *this_) 2045static void navit_add_former_destinations_from_file(struct navit *this_)
1736{ 2046{
2047#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2048 dbg(0,"+#+:enter\n");
2049#endif
1737 ////DBG dbg(0,"EEnter\n"); 2050 ////DBG dbg(0,"EEnter\n");
1738 char *destination_file = bookmarks_get_destination_file(FALSE); 2051 char *destination_file = bookmarks_get_destination_file(FALSE);
1739 struct attr *attrs[4]; 2052 struct attr *attrs[4];
1740 struct map_rect *mr; 2053 struct map_rect *mr;
1741 struct item *item; 2054 struct item *item;
1796 } 2109 }
1797} 2110}
1798 2111
1799void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...) 2112void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...)
1800{ 2113{
2114#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2115 dbg(0,"+#+:enter\n");
2116#endif
1801 ////DBG dbg(0,"EEnter\n"); 2117 ////DBG dbg(0,"EEnter\n");
1802 va_list ap; 2118 va_list ap;
1803 char *str1, *str2; 2119 char *str1, *str2;
1804 va_start(ap, fmt); 2120 va_start(ap, fmt);
1805 if (this_->textfile_debug_log && this_->vehicle) 2121 if (this_->textfile_debug_log && this_->vehicle)
1813 va_end(ap); 2129 va_end(ap);
1814} 2130}
1815 2131
1816void navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...) 2132void navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...)
1817{ 2133{
2134#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2135 dbg(0,"+#+:enter\n");
2136#endif
1818 ////DBG dbg(0,"EEnter\n"); 2137 ////DBG dbg(0,"EEnter\n");
1819 va_list ap; 2138 va_list ap;
1820 char *str1, *str2; 2139 char *str1, *str2;
1821 va_start(ap, fmt); 2140 va_start(ap, fmt);
1822 if (this_->textfile_debug_log && this_->vehicle) 2141 if (this_->textfile_debug_log && this_->vehicle)
1830 va_end(ap); 2149 va_end(ap);
1831} 2150}
1832 2151
1833void navit_say(struct navit *this_, char *text) 2152void navit_say(struct navit *this_, char *text)
1834{ 2153{
2154#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2155 dbg(0,"+#+:enter\n");
2156#endif
1835 ////DBG dbg(0,"EEnter\n"); 2157 ////DBG dbg(0,"EEnter\n");
1836 if (this_->speech) 2158 if (this_->speech)
1837 { 2159 {
1838 speech_say(this_->speech, text); 2160 speech_say(this_->speech, text);
1839 } 2161 }
1843 * @brief Toggles the navigation announcer for navit 2165 * @brief Toggles the navigation announcer for navit
1844 * @param this_ The navit object 2166 * @param this_ The navit object
1845 */ 2167 */
1846static void navit_cmd_announcer_toggle(struct navit *this_) 2168static void navit_cmd_announcer_toggle(struct navit *this_)
1847{ 2169{
2170#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2171 dbg(0,"+#+:enter\n");
2172#endif
1848 struct attr attr, speechattr; 2173 struct attr attr, speechattr;
1849 2174
1850 // search for the speech attribute 2175 // search for the speech attribute
1851 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) 2176 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL))
1852 return; 2177 return;
1871 callback_list_call_attr_0(this_->attr_cbl, attr_speech); 2196 callback_list_call_attr_0(this_->attr_cbl, attr_speech);
1872} 2197}
1873 2198
1874void navit_cmd_announcer_on(struct navit *this_) 2199void navit_cmd_announcer_on(struct navit *this_)
1875{ 2200{
2201#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2202 dbg(0,"+#+:enter\n");
2203#endif
1876 struct attr attr, speechattr; 2204 struct attr attr, speechattr;
1877 2205
1878 // search for the speech attribute 2206 // search for the speech attribute
1879 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) 2207 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL))
1880 return; 2208 return;
1890 callback_list_call_attr_0(this_->attr_cbl, attr_speech); 2218 callback_list_call_attr_0(this_->attr_cbl, attr_speech);
1891} 2219}
1892 2220
1893void navit_cmd_announcer_off(struct navit *this_) 2221void navit_cmd_announcer_off(struct navit *this_)
1894{ 2222{
2223#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2224 dbg(0,"+#+:enter\n");
2225#endif
1895 struct attr attr, speechattr; 2226 struct attr attr, speechattr;
1896 2227
1897 // search for the speech attribute 2228 // search for the speech attribute
1898 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL)) 2229 if (!navit_get_attr(this_, attr_speech, &speechattr, NULL))
1899 return; 2230 return;
1909 callback_list_call_attr_0(this_->attr_cbl, attr_speech); 2240 callback_list_call_attr_0(this_->attr_cbl, attr_speech);
1910} 2241}
1911 2242
1912void navit_speak(struct navit *this_) 2243void navit_speak(struct navit *this_)
1913{ 2244{
2245#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2246 dbg(0,"+#+:enter\n");
2247#endif
1914 ////DBG dbg(0,"EEnter\n"); 2248 ////DBG dbg(0,"EEnter\n");
1915 struct navigation *nav = this_->navigation; 2249 struct navigation *nav = this_->navigation;
1916 struct map *map = NULL; 2250 struct map *map = NULL;
1917 struct map_rect *mr = NULL; 2251 struct map_rect *mr = NULL;
1918 struct item *item; 2252 struct item *item;
1942 } 2276 }
1943} 2277}
1944 2278
1945static void navit_window_roadbook_update(struct navit *this_) 2279static void navit_window_roadbook_update(struct navit *this_)
1946{ 2280{
2281#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2282 dbg(0,"+#+:enter\n");
2283#endif
1947 ////DBG dbg(0,"EEnter\n"); 2284 ////DBG dbg(0,"EEnter\n");
1948 struct navigation *nav = this_->navigation; 2285 struct navigation *nav = this_->navigation;
1949 struct map *map = NULL; 2286 struct map *map = NULL;
1950 struct map_rect *mr = NULL; 2287 struct map_rect *mr = NULL;
1951 struct item *item; 2288 struct item *item;
2038 datawindow_mode(this_->roadbook_window, 0); 2375 datawindow_mode(this_->roadbook_window, 0);
2039} 2376}
2040 2377
2041void navit_window_roadbook_destroy(struct navit *this_) 2378void navit_window_roadbook_destroy(struct navit *this_)
2042{ 2379{
2380#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2381 dbg(0,"+#+:enter\n");
2382#endif
2043 ////DBG dbg(0, "enter\n"); 2383 ////DBG dbg(0, "enter\n");
2044 navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback); 2384 navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
2045 this_->roadbook_window = NULL; 2385 this_->roadbook_window = NULL;
2046 this_->roadbook_callback = NULL; 2386 this_->roadbook_callback = NULL;
2047} 2387}
2388
2048void navit_window_roadbook_new(struct navit *this_) 2389void navit_window_roadbook_new(struct navit *this_)
2049{ 2390{
2391#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2392 dbg(0,"+#+:enter\n");
2393#endif
2050 if (!this_->gui || this_->roadbook_callback || this_->roadbook_window) 2394 if (!this_->gui || this_->roadbook_callback || this_->roadbook_window)
2051 { 2395 {
2052 return; 2396 return;
2053 } 2397 }
2054 2398
2058 navit_window_roadbook_update(this_); 2402 navit_window_roadbook_update(this_);
2059} 2403}
2060 2404
2061void navit_remove_all_maps(struct navit *this_) 2405void navit_remove_all_maps(struct navit *this_)
2062{ 2406{
2407#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2408 dbg(0,"+#+:enter\n");
2409#endif
2063 struct mapset *ms; 2410 struct mapset *ms;
2064 struct map *map3; 2411 struct map *map3;
2412
2413 // hold map drawing
2414 // this_->ready = 1;
2065 2415
2066 // first: stop navigation! 2416 // first: stop navigation!
2067 //if (global_navit->destination_valid != 0) 2417 //if (global_navit->destination_valid != 0)
2068 //{ 2418 //{
2069 navit_set_destination(global_navit, NULL, NULL, 0); 2419 navit_set_destination(global_navit, NULL, NULL, 0);
2070 //} 2420 //}
2071 2421
2072 2422
2073 if (this_->route) 2423 if (this_->route)
2074 { 2424 {
2075 struct attr callback; 2425 struct attr callback;
2076 // this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); 2426 // this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
2077 callback.type=attr_callback; 2427 callback.type = attr_callback;
2078 callback.u.callback=this_->route_cb; 2428 callback.u.callback = this_->route_cb;
2079 route_remove_attr(this_->route, &callback); 2429 route_remove_attr(this_->route, &callback);
2080 2430
2081 this_->route->ms = NULL; 2431 this_->route->ms = NULL;
2082 // route_set_mapset(this_->route, ms); 2432 // route_set_mapset(this_->route, ms);
2083 // route_set_projection(this_->route, transform_get_projection(this_->trans)); 2433 // route_set_projection(this_->route, transform_get_projection(this_->trans));
2084 2434
2085 //*********route_destroy(this_->route); 2435 //*********route_destroy(this_->route);
2086 2436
2087 //route_path_destroy(this_->route->path2,1); 2437 //route_path_destroy(this_->route->path2,1);
2088 //this_->route->path2 = NULL; 2438 //this_->route->path2 = NULL;
2089 //route_graph_destroy(this_->route->graph); 2439 //route_graph_destroy(this_->route->graph);
2090 //this_->route->graph=NULL; 2440 //this_->route->graph=NULL;
2091 } 2441 }
2092 2442
2093 /* 2443 /*
2094 map_rect_destroy(displaylist->mr); 2444 map_rect_destroy(displaylist->mr);
2095 if (!route_selection) 2445 if (!route_selection)
2096 map_selection_destroy(displaylist->sel); 2446 map_selection_destroy(displaylist->sel);
2120 if (map_get_attr(map3, attr_name, &map_name_attr, NULL)) 2470 if (map_get_attr(map3, attr_name, &map_name_attr, NULL))
2121 { 2471 {
2122 //DBG dbg(0, "map name=%s", map_name_attr.u.str); 2472 //DBG dbg(0, "map name=%s", map_name_attr.u.str);
2123 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) 2473 if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0)
2124 { 2474 {
2475 dbg(0, "removing map name=%s", map_name_attr.u.str);
2125 //DBG dbg(0, "removing map a0\n"); 2476 //DBG dbg(0, "removing map a0\n");
2126 struct attr active; 2477 struct attr active;
2127 active.type = attr_active; 2478 active.type = attr_active;
2128 active.u.num = 0; 2479 active.u.num = 0;
2129 //map_set_attr(map3, &active); 2480 //map_set_attr(map3, &active);
2138 map3->refcount = 1; 2489 map3->refcount = 1;
2139 map_destroy(map3); 2490 map_destroy(map3);
2140 //DBG dbg(0, "removing map a3\n"); 2491 //DBG dbg(0, "removing map a3\n");
2141 map3 = NULL; 2492 map3 = NULL;
2142 } 2493 }
2494 else if (strncmp("-special-:", map_name_attr.u.str, 10) == 0)
2495 {
2496 dbg(0, "removing (special) map name=%s", map_name_attr.u.str);
2497 struct attr active;
2498 active.type = attr_active;
2499 active.u.num = 0;
2500
2501 struct attr map_attr;
2502 map_attr.u.map = map3;
2503 map_attr.type = attr_map;
2504 mapset_remove_attr(ms, &map_attr);
2505
2506 map3->refcount = 1;
2507 map_destroy(map3);
2508 map3 = NULL;
2509 }
2143 } 2510 }
2144 } 2511 }
2145 mapset_close(msh); 2512 mapset_close(msh);
2146 //DBG dbg(0, "removing map bb4\n"); 2513 //DBG dbg(0, "removing map bb4\n");
2147 } 2514 }
2153 // graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1); 2520 // graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1);
2154 //this_->displaylist->ms=this_->mapsets->data; 2521 //this_->displaylist->ms=this_->mapsets->data;
2155 2522
2156} 2523}
2157 2524
2525void navit_map_active_flag(struct navit *this_, int activate, const char *mapname)
2526{
2527 // activate = 0 -> deactivate
2528 // activate = 1 -> activate
2529
2530#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2531 dbg(0,"+#+:enter\n");
2532#endif
2533 struct mapset *ms;
2534 struct map *map3;
2535
2536 if (this_->mapsets)
2537 {
2538 struct mapset_handle *msh;
2539 ms = this_->mapsets->data;
2540 msh = mapset_open(ms);
2541 while (msh && (map3 = mapset_next(msh, 0)))
2542 {
2543 struct attr map_name_attr;
2544 if (map_get_attr(map3, attr_name, &map_name_attr, NULL))
2545 {
2546 dbg(0, "map name=%s\n", map_name_attr.u.str);
2547 if (strcmp(mapname, map_name_attr.u.str) == 0)
2548 {
2549 dbg(0, "setting active flag on map:%s\n", map_name_attr.u.str);
2550
2551 struct attr active;
2552 active.type = attr_active;
2553 active.u.num = activate;
2554 map_set_attr(map3, &active);
2555 }
2556 }
2557 }
2558 mapset_close(msh);
2559 }
2560
2561}
2562
2158void navit_add_all_maps(struct navit *this_) 2563void navit_add_all_maps(struct navit *this_)
2159{ 2564{
2565#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2566 dbg(0,"+#+:enter\n");
2567#endif
2160 struct map *map3; 2568 struct map *map3;
2161 2569
2162 if (this_->mapsets) 2570 if (this_->mapsets)
2163 { 2571 {
2164 //DBG dbg(0, "xADDx all maps - start\n"); 2572 //DBG dbg(0, "xADDx all maps - start\n");
2232 active.type = attr_active; 2640 active.type = attr_active;
2233 active.u.num = 0; 2641 active.u.num = 0;
2234 //map_set_attr(map2, &active); 2642 //map_set_attr(map2, &active);
2235 } 2643 }
2236 g_free(map_file); 2644 g_free(map_file);
2645
2646
2647
2648
2649
2650
2651 // gpx tracks map --------------------
2652 parent.type = attr_navit;
2653 parent.u.navit = this_;
2654 type.type = attr_type;
2655 type.u.str = "textfile";
2656 data.type = attr_data;
2657 map_file = g_strdup_printf("%sgpxtracks.txt", navit_maps_dir);
2658 data.u.str = map_file;
2659
2660 flags.type = attr_flags;
2661 flags.u.num = 0;
2662 attrs[0] = &type;
2663 attrs[1] = &data;
2664 attrs[2] = &flags;
2665 attrs[3] = NULL;
2666 map2 = map_new(&parent, attrs);
2667 if (map2)
2668 {
2669 map2_attr.u.data = map2;
2670 map2_attr.type = attr_map;
2671 mapset_add_attr_name_str(ms, &map2_attr, "-special-:gpxtracks.txt");
2672 struct attr active;
2673 active.type = attr_active;
2674 active.u.num = 0;
2675 //map_set_attr(map2, &active);
2676 }
2677 g_free(map_file);
2678 // gpx tracks map --------------------
2679
2680
2681 // traffic map --------------------
2682 parent.type = attr_navit;
2683 parent.u.navit = this_;
2684 type.type = attr_type;
2685 type.u.str = "textfile";
2686 data.type = attr_data;
2687 map_file = g_strdup_printf("%straffic.txt", navit_maps_dir);
2688 data.u.str = map_file;
2689
2690 flags.type = attr_flags;
2691 flags.u.num = 0;
2692 attrs[0] = &type;
2693 attrs[1] = &data;
2694 attrs[2] = &flags;
2695 attrs[3] = NULL;
2696 map2 = map_new(&parent, attrs);
2697 if (map2)
2698 {
2699 map2_attr.u.data = map2;
2700 map2_attr.type = attr_map;
2701 mapset_add_attr_name_str(ms, &map2_attr, "-special-:traffic.txt");
2702 struct attr active;
2703 active.type = attr_active;
2704 active.u.num = 0;
2705 //map_set_attr(map2, &active);
2706 }
2707 g_free(map_file);
2708 // traffic map --------------------
2709
2710
2711
2712
2713
2714
2237 2715
2238 int i = 1; 2716 int i = 1;
2239 for (i = 1; i < 10; i++) 2717 for (i = 1; i < 10; i++)
2240 { 2718 {
2241 struct map *map22; 2719 struct map *map22;
2328 } 2806 }
2329 mapset_close(msh); 2807 mapset_close(msh);
2330 } 2808 }
2331 */ 2809 */
2332 2810
2811 /*
2333 struct attr parent; 2812 struct attr parent;
2334 parent.type = attr_navit; 2813 parent.type = attr_navit;
2335 parent.u.navit = global_navit; 2814 parent.u.navit = global_navit;
2336 2815
2337 struct attr *attrs_r[2]; 2816 struct attr *attrs_r[2];
2338 attrs_r[0] = NULL; 2817 attrs_r[0] = NULL;
2339 attrs_r[1] = NULL; 2818 attrs_r[1] = NULL;
2819 */
2340 2820
2341 //***this_->route = route_new(&parent, attrs_r); 2821 //***this_->route = route_new(&parent, attrs_r);
2342 2822
2343 2823
2344 //int async = 0; 2824 //int async = 0;
2355 struct mapset *ms; 2835 struct mapset *ms;
2356 ms = this_->mapsets->data; 2836 ms = this_->mapsets->data;
2357 route_set_mapset(this_->route, ms); 2837 route_set_mapset(this_->route, ms);
2358 2838
2359 struct attr callback; 2839 struct attr callback;
2360 this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_); 2840 this_->route_cb = callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
2361 callback.type=attr_callback; 2841 callback.type = attr_callback;
2362 callback.u.callback=this_->route_cb; 2842 callback.u.callback = this_->route_cb;
2363 route_add_attr(this_->route, &callback); 2843 route_add_attr(this_->route, &callback);
2364 // ***** route_set_projection(this_->route, transform_get_projection(this_->trans)); 2844 // ***** route_set_projection(this_->route, transform_get_projection(this_->trans));
2365 } 2845 }
2366 2846
2367 if (this_->tracking) 2847 if (this_->tracking)
2374 { 2854 {
2375 tracking_set_route(this_->tracking, this_->route); 2855 tracking_set_route(this_->tracking, this_->route);
2376 } 2856 }
2377 } 2857 }
2378 2858
2859 // ready for drawing map
2860 // this_->ready = 3;
2379 2861
2862 // draw map
2863 // navit_draw(this_);
2380} 2864}
2381 2865
2382void navit_reload_maps(struct navit *this_) 2866void navit_reload_maps(struct navit *this_)
2383{ 2867{
2868#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2869 dbg(0,"+#+:enter\n");
2870#endif
2384 navit_remove_all_maps(this_); 2871 navit_remove_all_maps(this_);
2385 navit_add_all_maps(this_); 2872 navit_add_all_maps(this_);
2386} 2873}
2387 2874
2388void navit_init(struct navit *this_) 2875void navit_init(struct navit *this_)
2389{ 2876{
2877#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
2878 dbg(0,"+#+:enter\n");
2879#endif
2390 ////DBG dbg(0,"EEnter\n"); 2880 ////DBG dbg(0,"EEnter\n");
2391 struct mapset *ms; 2881 struct mapset *ms;
2392 struct map *map; 2882 struct map *map;
2393 int callback; 2883 int callback;
2394 char *center_file; 2884 char *center_file;
2423 graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL); 2913 graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL);
2424 //DBG dbg(0, "failed to connect graphics '%s' to gui '%s'\n", attr_type_graphics.u.str, attr_type_gui.u.str); 2914 //DBG dbg(0, "failed to connect graphics '%s' to gui '%s'\n", attr_type_graphics.u.str, attr_type_gui.u.str);
2425 // //DBG dbg(0," Please see http://wiki.navit-project.org/index.php/Failed_to_connect_graphics_to_gui\n"); 2915 // //DBG dbg(0," Please see http://wiki.navit-project.org/index.php/Failed_to_connect_graphics_to_gui\n");
2426 // //DBG dbg(0," for explanations and solutions\n"); 2916 // //DBG dbg(0," for explanations and solutions\n");
2427 2917
2428 dbg(0,"failed to connect to graphics\n"); 2918 dbg(0, "failed to connect to graphics\n");
2429 navit_destroy(this_); 2919 navit_destroy(this_);
2430 return; 2920 return;
2431 } 2921 }
2432 2922
2433 if (this_->speech && this_->navigation) 2923 if (this_->speech && this_->navigation)
2439 } 2929 }
2440 2930
2441 //DBG dbg(0, "Initializing graphics\n"); 2931 //DBG dbg(0, "Initializing graphics\n");
2442 //DBG dbg(0, "Setting Vehicle\n"); 2932 //DBG dbg(0, "Setting Vehicle\n");
2443 navit_set_vehicle(this_, this_->vehicle); 2933 navit_set_vehicle(this_, this_->vehicle);
2934
2444 //DBG dbg(0, "Adding dynamic maps to mapset %p\n", this_->mapsets); 2935 //DBG dbg(0, "Adding dynamic maps to mapset %p\n", this_->mapsets);
2445
2446 if (this_->mapsets) 2936 if (this_->mapsets)
2447 { 2937 {
2448 struct mapset_handle *msh; 2938 struct mapset_handle *msh;
2449 ms = this_->mapsets->data; 2939 ms = this_->mapsets->data;
2450 // **D** // this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_); 2940 // **D** // this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_);
2582 //dbg(0, "g2\n"); 3072 //dbg(0, "g2\n");
2583 navit_set_cursors(this_); 3073 navit_set_cursors(this_);
2584 3074
2585 callback_list_call_attr_1(this_->attr_cbl, attr_navit, this_); 3075 callback_list_call_attr_1(this_->attr_cbl, attr_navit, this_);
2586 callback = (this_->ready == 2); 3076 callback = (this_->ready == 2);
2587 //DBG dbg(0, "pre this_->ready=%d\n", this_->ready); 3077 dbg(0, "pre this_->ready=%d\n", this_->ready);
2588 this_->ready |= 1; 3078 this_->ready = this_->ready | 1;
2589 //DBG dbg(0, "set this_->ready=%d\n", this_->ready); 3079 dbg(0, "set this_->ready=%d\n", this_->ready);
2590 ////DBG dbg(0,"ready=%d\n",this_->ready); 3080 ////DBG dbg(0,"ready=%d\n",this_->ready);
3081
3082
2591 if (this_->ready == 3) 3083 //if (this_->ready == 3)
2592 { 3084 //{
2593 ////DBG dbg(0,"navit_draw_async_003\n"); 3085 // ////DBG dbg(0,"navit_draw_async_003\n");
2594 navit_draw_async(this_, 1); 3086 // navit_draw_async(this_, 1);
2595 } 3087 //}
3088
3089 dbg(0,"init ready=%d\n", this_->ready);
3090
3091 // draw???????
3092 // dbg(0,"init DRAW 11\n");
3093 // ready to draw map
3094 // navit_draw(this_);
3095 // dbg(0,"init DRAW 22\n");
3096 // draw???????
2596 3097
2597 if (callback) 3098 if (callback)
2598 { 3099 {
2599 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_); 3100 callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
2600 } 3101 }
2604 //dbg(0, "1111111111\n"); 3105 //dbg(0, "1111111111\n");
2605} 3106}
2606 3107
2607void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r) 3108void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r)
2608{ 3109{
3110#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3111 dbg(0,"+#+:enter\n");
3112#endif
2609 ////DBG dbg(0,"EEnter\n"); 3113 ////DBG dbg(0,"EEnter\n");
2610 struct coord c; 3114 struct coord c;
2611 int scale = 16; 3115 int scale = 16;
2612 3116
2613 c.x = (r->rl.x + r->lu.x) / 2; 3117 c.x = (r->rl.x + r->lu.x) / 2;
2635 } 3139 }
2636} 3140}
2637 3141
2638void navit_zoom_to_route(struct navit *this_, int orientation) 3142void navit_zoom_to_route(struct navit *this_, int orientation)
2639{ 3143{
3144#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3145 dbg(0,"+#+:enter\n");
3146#endif
2640 ////DBG dbg(0,"EEnter\n"); 3147 ////DBG dbg(0,"EEnter\n");
2641 struct map *map; 3148 struct map *map;
2642 struct map_rect *mr = NULL; 3149 struct map_rect *mr = NULL;
2643 struct item *item; 3150 struct item *item;
2644 struct coord c; 3151 struct coord c;
2676 navit_zoom_to_rect(this_, &r); 3183 navit_zoom_to_rect(this_, &r);
2677} 3184}
2678 3185
2679static void navit_cmd_zoom_to_route(struct navit *this) 3186static void navit_cmd_zoom_to_route(struct navit *this)
2680{ 3187{
3188#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3189 dbg(0,"+#+:enter\n");
3190#endif
2681 ////DBG dbg(0,"EEnter\n"); 3191 ////DBG dbg(0,"EEnter\n");
2682 navit_zoom_to_route(this, 0); 3192 navit_zoom_to_route(this, 0);
2683} 3193}
2684 3194
2685/** 3195/**
2689 * @param center The point where to center the map, including its projection 3199 * @param center The point where to center the map, including its projection
2690 * @returns nothing 3200 * @returns nothing
2691 */ 3201 */
2692void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout) 3202void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout)
2693{ 3203{
3204#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3205 dbg(0,"+#+:enter\n");
3206#endif
2694 ////DBG dbg(0,"EEnter\n"); 3207 ////DBG dbg(0,"EEnter\n");
2695 struct coord *c = transform_center(this_->trans); 3208 struct coord *c = transform_center(this_->trans);
2696 struct coord c1, c2; 3209 struct coord c1, c2;
2697 enum projection pro = transform_get_projection(this_->trans); 3210 enum projection pro = transform_get_projection(this_->trans);
2698 if (pro != center->pro) 3211 if (pro != center->pro)
2717 } 3230 }
2718} 3231}
2719 3232
2720static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout) 3233static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout)
2721{ 3234{
3235#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3236 dbg(0,"+#+:enter\n");
3237#endif
2722 ////DBG dbg(0,"EEnter\n"); 3238 ////DBG dbg(0,"EEnter\n");
2723 int width, height; 3239 int width, height;
2724 struct point po; 3240 struct point po;
2725 transform_set_center(this_->trans, c); 3241 transform_set_center(this_->trans, c);
2726 transform_get_size(this_->trans, &width, &height); 3242 transform_get_size(this_->trans, &width, &height);
2739 * @param this_ A navit instance 3255 * @param this_ A navit instance
2740 * @author Ralph Sennhauser (10/2009) 3256 * @author Ralph Sennhauser (10/2009)
2741 */ 3257 */
2742void navit_set_cursors(struct navit *this_) 3258void navit_set_cursors(struct navit *this_)
2743{ 3259{
3260#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3261 dbg(0,"+#+:enter\n");
3262#endif
2744 struct attr name; 3263 struct attr name;
2745 struct navit_vehicle *nv; 3264 struct navit_vehicle *nv;
2746 struct cursor *c; 3265 struct cursor *c;
2747 GList *v; 3266 GList *v;
2748 3267
2774 return; 3293 return;
2775} 3294}
2776 3295
2777void navit_remove_cursors(struct navit *this_) 3296void navit_remove_cursors(struct navit *this_)
2778{ 3297{
3298#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3299 dbg(0,"+#+:enter\n");
3300#endif
2779 struct attr name; 3301 struct attr name;
2780 struct navit_vehicle *nv; 3302 struct navit_vehicle *nv;
2781 struct cursor *c; 3303 struct cursor *c;
2782 GList *v; 3304 GList *v;
2783 3305
2795 return; 3317 return;
2796} 3318}
2797 3319
2798static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir) 3320static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir)
2799{ 3321{
3322#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3323 dbg(0,"+#+:enter\n");
3324#endif
2800 ////DBG dbg(0,"EEnter\n"); 3325 ////DBG dbg(0,"EEnter\n");
2801 int width, height; 3326 int width, height;
2802 struct navit_vehicle *nv = this_->vehicle; 3327 struct navit_vehicle *nv = this_->vehicle;
2803 3328
2804 float offset = this_->radius; // Cursor offset from the center of the screen (percent). 3329 float offset = this_->radius; // Cursor offset from the center of the screen (percent).
2850 return 1; 3375 return 1;
2851} 3376}
2852 3377
2853void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) 3378void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation)
2854{ 3379{
3380#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3381 dbg(0,"+#+:enter\n");
3382#endif
2855 ////DBG dbg(0,"EEnter\n"); 3383 ////DBG dbg(0,"EEnter\n");
2856 int dir; 3384 int dir;
2857 struct point pn; 3385 struct point pn;
2858 struct navit_vehicle *nv = this_->vehicle; 3386 struct navit_vehicle *nv = this_->vehicle;
2859 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); 3387 navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir);
2863 navit_autozoom(this_, &nv->coord, nv->speed, 0); 3391 navit_autozoom(this_, &nv->coord, nv->speed, 0);
2864} 3392}
2865 3393
2866static void navit_set_center_cursor_draw(struct navit *this_) 3394static void navit_set_center_cursor_draw(struct navit *this_)
2867{ 3395{
3396#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3397 dbg(0,"+#+:enter\n");
3398#endif
2868 ////DBG dbg(0,"EEnter\n"); 3399 //dbg(0,"EEnter\n");
2869 navit_set_center_cursor(this_, 1, 0); 3400 navit_set_center_cursor(this_, 1, 0);
2870 if (this_->ready == 3) 3401 if (this_->ready == 3)
2871 { 3402 {
2872 ////DBG dbg(0,"navit_draw_async_005\n"); 3403 //dbg(0,"navit_draw_async_005\n");
2873 navit_draw_async(this_, 1); 3404 navit_draw_async(this_, 1);
2874 } 3405 }
2875} 3406}
2876 3407
2877static void navit_cmd_set_center_cursor(struct navit *this_) 3408static void navit_cmd_set_center_cursor(struct navit *this_)
2878{ 3409{
3410#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3411 dbg(0,"+#+:enter\n");
3412#endif
2879 ////DBG dbg(0,"EEnter\n"); 3413 ////DBG dbg(0,"EEnter\n");
2880 navit_set_center_cursor_draw(this_); 3414 navit_set_center_cursor_draw(this_);
2881} 3415}
2882 3416
2883void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout) 3417void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout)
2884{ 3418{
3419#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3420 dbg(0,"+#+:enter\n");
3421#endif
2885 ////DBG dbg(0,"EEnter\n"); 3422 ////DBG dbg(0,"EEnter\n");
2886 struct coord c; 3423 struct coord c;
2887 struct pcoord pc; 3424 struct pcoord pc;
2888 transform_reverse(this_->trans, p, &c); 3425 transform_reverse(this_->trans, p, &c);
2889 pc.x = c.x; 3426 pc.x = c.x;
2903 break; 3440 break;
2904#endif 3441#endif
2905 3442
2906static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) 3443static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init)
2907{ 3444{
3445#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3446 dbg(0,"+#+:enter\n");
3447#endif
2908 ////DBG dbg(0,"EEnter\n"); 3448 ////DBG dbg(0,"EEnter\n");
2909 int dir = 0, orient_old = 0, attr_updated = 0; 3449 int dir = 0, orient_old = 0, attr_updated = 0;
2910 struct coord co; 3450 struct coord co;
2911 long zoom; 3451 long zoom;
2912 GList *l; 3452 GList *l;
3066 if (nv->vehicle == attr->u.vehicle) 3606 if (nv->vehicle == attr->u.vehicle)
3067 { 3607 {
3068 if (!this_->vehicle || this_->vehicle->vehicle != attr->u.vehicle) 3608 if (!this_->vehicle || this_->vehicle->vehicle != attr->u.vehicle)
3069 { 3609 {
3070 if (this_->vehicle) 3610 if (this_->vehicle)
3611 {
3071 vehicle_set_attr(this_->vehicle->vehicle, &active); 3612 vehicle_set_attr(this_->vehicle->vehicle, &active);
3613 }
3072 active.u.num = 1; 3614 active.u.num = 1;
3073 vehicle_set_attr(nv->vehicle, &active); 3615 vehicle_set_attr(nv->vehicle, &active);
3074 attr_updated = 1; 3616 attr_updated = 1;
3075 } 3617 }
3076 navit_set_vehicle(this_, nv); 3618 navit_set_vehicle(this_, nv);
3109 } 3651 }
3110 if (attr_updated && !init) 3652 if (attr_updated && !init)
3111 { 3653 {
3112 callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); 3654 callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
3113 if (attr->type == attr_osd_configuration) 3655 if (attr->type == attr_osd_configuration)
3656 {
3114 graphics_draw_mode(this_->gra, draw_mode_end); 3657 graphics_draw_mode(this_->gra, draw_mode_end);
3115 } 3658 }
3659 }
3660
3661#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3662 dbg(0,"+#+:leave\n");
3663#endif
3664
3116 return 1; 3665 return 1;
3117} 3666}
3118 3667
3119int navit_set_attr(struct navit *this_, struct attr *attr) 3668int navit_set_attr(struct navit *this_, struct attr *attr)
3120{ 3669{
3670#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3671 dbg(0,"+#+:enter\n");
3672#endif
3121 ////DBG dbg(0,"EEnter\n"); 3673 ////DBG dbg(0,"EEnter\n");
3122 return navit_set_attr_do(this_, attr, 0); 3674 return navit_set_attr_do(this_, attr, 0);
3123} 3675}
3124 3676
3125int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) 3677int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
3126{ 3678{
3679#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3680 dbg(0,"+#+:enter\n");
3681#endif
3127 ////DBG dbg(0,"EEnter\n"); 3682 ////DBG dbg(0,"EEnter\n");
3128 struct message *msg; 3683 struct message *msg;
3129 int len, offset; 3684 int len, offset;
3130 int ret = 1; 3685 int ret = 1;
3131 3686
3323 break; 3878 break;
3324 default: 3879 default:
3325 return 0; 3880 return 0;
3326 } 3881 }
3327 attr->type = type; 3882 attr->type = type;
3883
3884#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3885 dbg(0,"+#+:leave\n");
3886#endif
3887
3328 return ret; 3888 return ret;
3329} 3889}
3330 3890
3331static int navit_add_log(struct navit *this_, struct log *log) 3891static int navit_add_log(struct navit *this_, struct log *log)
3332{ 3892{
3893#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3894 dbg(0,"+#+:enter\n");
3895#endif
3333 struct attr type_attr; 3896 struct attr type_attr;
3334 if (!log_get_attr(log, attr_type, &type_attr, NULL)) 3897 if (!log_get_attr(log, attr_type, &type_attr, NULL))
3335 return 0; 3898 return 0;
3336 if (!strcmp(type_attr.u.str, "textfile_debug")) 3899 if (!strcmp(type_attr.u.str, "textfile_debug"))
3337 { 3900 {
3345 return 0; 3908 return 0;
3346} 3909}
3347 3910
3348static int navit_add_layout(struct navit *this_, struct layout *layout) 3911static int navit_add_layout(struct navit *this_, struct layout *layout)
3349{ 3912{
3913#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3914 dbg(0,"+#+:enter\n");
3915#endif
3350 ////DBG dbg(0,"EEnter\n"); 3916 ////DBG dbg(0,"EEnter\n");
3351 struct attr active; 3917 struct attr active;
3352 this_->layouts = g_list_append(this_->layouts, layout); 3918 this_->layouts = g_list_append(this_->layouts, layout);
3353 layout_get_attr(layout, attr_active, &active, NULL); 3919 layout_get_attr(layout, attr_active, &active, NULL);
3354 if (active.u.num || !this_->layout_current) 3920 if (active.u.num || !this_->layout_current)
3359 return 0; 3925 return 0;
3360} 3926}
3361 3927
3362int navit_add_attr(struct navit *this_, struct attr *attr) 3928int navit_add_attr(struct navit *this_, struct attr *attr)
3363{ 3929{
3930#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3931 dbg(0,"+#+:enter\n");
3932#endif
3364 ////DBG dbg(0,"EEnter\n"); 3933 ////DBG dbg(0,"EEnter\n");
3365 3934
3366 int ret = 1; 3935 int ret = 1;
3367 switch (attr->type) 3936 switch (attr->type)
3368 { 3937 {
3410 break; 3979 break;
3411 default: 3980 default:
3412 return 0; 3981 return 0;
3413 } 3982 }
3414 callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); 3983 callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
3984
3985#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3986 dbg(0,"+#+:leave\n");
3987#endif
3988
3415 return ret; 3989 return ret;
3416} 3990}
3417 3991
3418int navit_remove_attr(struct navit *this_, struct attr *attr) 3992int navit_remove_attr(struct navit *this_, struct attr *attr)
3419{ 3993{
3994#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
3995 dbg(0,"+#+:enter\n");
3996#endif
3420 int ret = 1; 3997 int ret = 1;
3421 switch (attr->type) 3998 switch (attr->type)
3422 { 3999 {
3423 case attr_callback: 4000 case attr_callback:
3424 navit_remove_callback(this_, attr->u.callback); 4001 navit_remove_callback(this_, attr->u.callback);
3425 break; 4002 break;
3426 default: 4003 default:
3427 return 0; 4004 return 0;
3428 } 4005 }
4006
4007#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4008 dbg(0,"+#+:leave\n");
4009#endif
4010
3429 return ret; 4011 return ret;
3430} 4012}
3431 4013
3432struct attr_iter * 4014struct attr_iter *
3433navit_attr_iter_new(void) 4015navit_attr_iter_new(void)
3434{ 4016{
4017#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4018 dbg(0,"+#+:enter\n");
4019#endif
3435return g_new0(struct attr_iter, 1); 4020return g_new0(struct attr_iter, 1);
3436} 4021}
3437 4022
3438void navit_attr_iter_destroy(struct attr_iter *iter) 4023void navit_attr_iter_destroy(struct attr_iter *iter)
3439{ 4024{
4025#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4026 dbg(0,"+#+:enter\n");
4027#endif
3440 g_free(iter); 4028 g_free(iter);
3441} 4029}
3442 4030
3443void navit_add_callback(struct navit *this_, struct callback *cb) 4031void navit_add_callback(struct navit *this_, struct callback *cb)
3444{ 4032{
4033#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4034 dbg(0,"+#+:enter\n");
4035#endif
3445 ////DBG dbg(0,"EEnter\n"); 4036 ////DBG dbg(0,"EEnter\n");
3446 4037
3447 callback_list_add(this_->attr_cbl, cb); 4038 callback_list_add(this_->attr_cbl, cb);
3448} 4039}
3449 4040
3450void navit_remove_callback(struct navit *this_, struct callback *cb) 4041void navit_remove_callback(struct navit *this_, struct callback *cb)
3451{ 4042{
4043#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4044 dbg(0,"+#+:enter\n");
4045#endif
3452 ////DBG dbg(0,"EEnter\n"); 4046 ////DBG dbg(0,"EEnter\n");
3453 4047
3454 callback_list_remove(this_->attr_cbl, cb); 4048 callback_list_remove(this_->attr_cbl, cb);
3455} 4049}
3456 4050
3461 * @returns nothing 4055 * @returns nothing
3462 */ 4056 */
3463 4057
3464static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt) 4058static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt)
3465{ 4059{
4060#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4061 dbg(0,"+#+:enter\n");
4062#endif
3466 ////DBG dbg(0,"EEnter\n"); 4063 ////DBG dbg(0,"EEnter\n");
3467 4064
3468 struct point cursor_pnt; 4065 struct point cursor_pnt;
3469 enum projection pro; 4066 enum projection pro;
3470 4067
3507#endif 4104#endif
3508} 4105}
3509 4106
3510static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv) 4107static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
3511{ 4108{
3512 //DBG dbg(0,"EEnter\n"); 4109#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4110 dbg(0,"+#+:enter\n");
4111#endif
4112
4113#ifdef NAVIT_MEASURE_TIME_DEBUG
4114 clock_t s_ = debug_measure_start();
4115#endif
3513 4116
3514 struct attr attr_valid, attr_dir, attr_speed, attr_pos; 4117 struct attr attr_valid, attr_dir, attr_speed, attr_pos;
3515 struct pcoord cursor_pc; 4118 struct pcoord cursor_pc;
3516 struct point cursor_pnt, *pnt = &cursor_pnt; 4119 struct point cursor_pnt, *pnt = &cursor_pnt;
3517 struct tracking *tracking = NULL; 4120 struct tracking *tracking = NULL;
3520 int count; 4123 int count;
3521 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *); 4124 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
3522 void *attr_object; 4125 void *attr_object;
3523 char *destination_file; 4126 char *destination_file;
3524 4127
3525 // //DBG dbg(0,"navit_vehicle_update_001 %d\n",pro);
3526 //profile(0,NULL);
3527 if (this_->ready != 3) 4128 if (this_->ready != 3)
3528 { 4129 {
3529 //profile(0,"return 1\n"); 4130 //profile(0,"return 1\n");
3530 return; 4131 return;
3531 } 4132 }
4133
3532 navit_layout_switch(this_); 4134 navit_layout_switch(this_);
3533 if (this_->vehicle == nv && this_->tracking_flag) 4135 if (this_->vehicle == nv && this_->tracking_flag)
4136 {
3534 tracking = this_->tracking; 4137 tracking = this_->tracking;
4138 }
4139
3535 if (tracking) 4140 if (tracking)
3536 { 4141 {
3537 tracking_update(tracking, nv->vehicle, this_->vehicleprofile, pro); 4142 tracking_update(tracking, nv->vehicle, this_->vehicleprofile, pro);
3538 attr_object = tracking; 4143 attr_object = tracking;
3539 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) tracking_get_attr; 4144 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) tracking_get_attr;
3541 else 4146 else
3542 { 4147 {
3543 attr_object = nv->vehicle; 4148 attr_object = nv->vehicle;
3544 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) vehicle_get_attr; 4149 get_attr = (int(*)(void *, enum attr_type, struct attr *, struct attr_iter *)) vehicle_get_attr;
3545 } 4150 }
4151
3546 if (get_attr(attr_object, attr_position_valid, &attr_valid, NULL)) 4152 if (get_attr(attr_object, attr_position_valid, &attr_valid, NULL))
4153 {
3547 if (!attr_valid.u.num != attr_position_valid_invalid) 4154 if (!attr_valid.u.num != attr_position_valid_invalid)
4155 {
3548 return; 4156 return;
4157 }
4158 }
4159
3549 if (!get_attr(attr_object, attr_position_direction, &attr_dir, NULL) || !get_attr(attr_object, attr_position_speed, &attr_speed, NULL) || !get_attr(attr_object, attr_position_coord_geo, &attr_pos, NULL)) 4160 if (!get_attr(attr_object, attr_position_direction, &attr_dir, NULL) || !get_attr(attr_object, attr_position_speed, &attr_speed, NULL) || !get_attr(attr_object, attr_position_coord_geo, &attr_pos, NULL))
3550 { 4161 {
3551 // profile(0,"return 2\n");
3552 return; 4162 return;
3553 } 4163 }
4164
3554 nv->dir = *attr_dir.u.numd; 4165 nv->dir = *attr_dir.u.numd;
3555 nv->speed = *attr_speed.u.numd; 4166 nv->speed = *attr_speed.u.numd;
3556 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord); 4167 transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord);
3557 if (nv != this_->vehicle) 4168 if (nv != this_->vehicle)
3558 { 4169 {
3559 ////DBG dbg(0,"---> 2 x=%d\n", nv->coord.x); 4170 if (hold_drawing == 0)
3560 ////DBG dbg(0,"---> 2 y=%d\n", nv->coord.y); 4171 {
3561 // //DBG dbg(0,"vehicle_draw_002\n");
3562 navit_vehicle_draw(this_, nv, NULL); 4172 navit_vehicle_draw(this_, nv, NULL);
3563 // profile(0,"return 3\n"); 4173 }
3564 return; 4174 return;
3565 } 4175 }
3566 cursor_pc.x = nv->coord.x; 4176 cursor_pc.x = nv->coord.x;
3567 cursor_pc.y = nv->coord.y; 4177 cursor_pc.y = nv->coord.y;
3568 cursor_pc.pro = pro; 4178 cursor_pc.pro = pro;
3569 if (this_->route) 4179 if (this_->route)
3570 { 4180 {
3571 if (tracking) 4181 if (tracking)
4182 {
3572 route_set_position_from_tracking(this_->route, tracking, pro); 4183 route_set_position_from_tracking(this_->route, tracking, pro);
4184 }
3573 else 4185 else
4186 {
3574 route_set_position(this_->route, &cursor_pc); 4187 route_set_position(this_->route, &cursor_pc);
3575 } 4188 }
4189 }
4190
3576 callback_list_call_attr_0(this_->attr_cbl, attr_position); 4191 callback_list_call_attr_0(this_->attr_cbl, attr_position);
4192
3577 // navit_textfile_debug_log(this_, "type=trackpoint_tracked"); 4193 // navit_textfile_debug_log(this_, "type=trackpoint_tracked");
4194 /*
3578 if (this_->gui && nv->speed > MYSTERY_SPEED) 4195 if (this_->gui && nv->speed > MYSTERY_SPEED)
4196 {
4197 // stupid!!!! this gets called every second!!! fixme!!!!!!
3579 navit_disable_suspend(); 4198 navit_disable_suspend();
4199 // stupid!!!! this gets called every second!!! fixme!!!!!!
4200 }
4201 */
4202
3580 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL); 4203 transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
3581 if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border))) 4204 if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow && (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border)))
3582 { 4205 {
4206 if (hold_drawing == 0)
4207 {
4208 //dbg(0,"call:navit_set_center_cursor_draw:start\n");
3583 navit_set_center_cursor_draw(this_); 4209 navit_set_center_cursor_draw(this_);
3584 ////DBG dbg(0,"---> xxCENTER\n"); 4210 //dbg(0,"call:navit_set_center_cursor_draw:end\n");
3585 ////DBG dbg(0,"---> 3 x=%d\n", nv->coord.x); 4211 }
3586 ////DBG dbg(0,"---> 3 y=%d\n", nv->coord.y);
3587
3588 ////DBG dbg(0,"---> 4 x=%d\n", cursor_pnt.x);
3589 ////DBG dbg(0,"---> 4 y=%d\n", cursor_pnt.y);
3590
3591 //global_vehicle_pos_onscreen.x=cursor_pnt.x;
3592 //global_vehicle_pos_onscreen.y=cursor_pnt.y;
3593
3594 } 4212 }
3595 else 4213 else
3596 { 4214 {
3597 ////DBG dbg(0,"vehicle_draw_003\n"); 4215 if (hold_drawing == 0)
4216 {
3598 navit_vehicle_draw(this_, nv, pnt); 4217 navit_vehicle_draw(this_, nv, pnt);
3599 //global_vehicle_pos_onscreen.x=pnt->x; 4218 }
3600 //global_vehicle_pos_onscreen.y=pnt->y;
3601 ////DBG dbg(0,"---> x=%d\n", pnt->x);
3602 ////DBG dbg(0,"---> y=%d\n", pnt->y);
3603 } 4219 }
3604 4220
3605 if (nv->follow_curr > 1) 4221 if (nv->follow_curr > 1)
4222 {
3606 nv->follow_curr--; 4223 nv->follow_curr--;
4224 }
3607 else 4225 else
4226 {
3608 nv->follow_curr = nv->follow; 4227 nv->follow_curr = nv->follow;
4228 }
4229
3609 callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle); 4230 callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle);
3610 4231
3611 /* Finally, if we reached our destination, stop navigation. */ 4232 /* Finally, if we reached our destination, stop navigation. */
3612 if (this_->route) 4233 if (this_->route)
3613 { 4234 {
3621 // bookmarks_append_coord(this_->bookmarks, destination_file, pc, count, "former_itinerary_part", NULL, NULL, this_->recentdest_count); 4242 // bookmarks_append_coord(this_->bookmarks, destination_file, pc, count, "former_itinerary_part", NULL, NULL, this_->recentdest_count);
3622 4243
3623#ifdef HAVE_API_ANDROID 4244#ifdef HAVE_API_ANDROID
3624 // waypoint reached 4245 // waypoint reached
3625 android_return_generic_int(5, 1); 4246 android_return_generic_int(5, 1);
4247#ifdef NAVIT_SAY_DEBUG_PRINT
3626 android_send_generic_text(1,"+*#O:Waypoint reached\n"); 4248 android_send_generic_text(1,"+*#O:Waypoint reached\n");
4249#endif
3627 // say it 4250 // say it
3628 navit_say(this_, _("Waypoint reached")); 4251 navit_say(this_, _("Waypoint reached"));
3629#endif 4252#endif
3630 break; 4253 break;
3631 case 2: 4254 case 2:
3632 navit_set_destination(this_, NULL, NULL, 0); 4255 navit_set_destination(this_, NULL, NULL, 0);
3633 // ** inform java that we reached our destination ** 4256 // ** inform java that we reached our destination **
3634#ifdef HAVE_API_ANDROID 4257#ifdef HAVE_API_ANDROID
3635 android_return_generic_int(4, 1); 4258 android_return_generic_int(4, 1);
4259#ifdef NAVIT_SAY_DEBUG_PRINT
3636 android_send_generic_text(1,"+*#O:You have reached your destination\n"); 4260 android_send_generic_text(1,"+*#O:You have reached your destination\n");
4261#endif
3637 // say it 4262 // say it
3638 navit_say(this_, _("You have reached your destination")); 4263 navit_say(this_, _("You have reached your destination"));
3639#endif 4264#endif
3640 break; 4265 break;
3641 } 4266 }
3642 } 4267 }
3643 //profile(0,"return 5\n"); 4268
4269 if (hold_drawing == 0)
4270 {
4271 // draw???????
4272 // navit_draw(this_);
4273 if (this_->ready == 3)
4274 {
4275 //dbg(0,"location update:draw:start\n");
4276 //navit_draw_async(this_, 1);
4277 //dbg(0,"location update:draw:end\n");
4278 }
4279 // draw???????
4280 }
4281
3644 // //DBG dbg(0,"navit_vehicle_update_999\n"); 4282 //dbg(0,"navit_vehicle_update_999\n");
4283
4284#ifdef NAVIT_MEASURE_TIME_DEBUG
4285 debug_mrp("navit_vehicle_update:", debug_measure_end(s_));
4286#endif
4287
4288#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4289 dbg(0,"+#+:leave\n");
4290#endif
3645} 4291}
3646 4292
3647/** 4293/**
3648 * Set the position of the vehicle 4294 * Set the position of the vehicle
3649 * 4295 *
3652 * @returns nothing 4298 * @returns nothing
3653 */ 4299 */
3654 4300
3655void navit_set_position(struct navit *this_, struct pcoord *c) 4301void navit_set_position(struct navit *this_, struct pcoord *c)
3656{ 4302{
4303#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4304 dbg(0,"+#+:enter\n");
4305#endif
3657 //DBG dbg(0,"EEnter\n"); 4306 //DBG dbg(0,"EEnter\n");
3658 4307
3659 if (this_->route) 4308 if (this_->route)
3660 { 4309 {
3661 route_set_position(this_->route, c); 4310 route_set_position(this_->route, c);
3662 callback_list_call_attr_0(this_->attr_cbl, attr_position); 4311 callback_list_call_attr_0(this_->attr_cbl, attr_position);
3663 } 4312 }
4313
3664 if (this_->ready == 3) 4314 if (this_->ready == 3)
4315 {
3665 navit_draw(this_); 4316 navit_draw(this_);
4317 }
3666} 4318}
3667 4319
3668static int navit_set_vehicleprofile(struct navit *this_, char *name) 4320static int navit_set_vehicleprofile(struct navit *this_, char *name)
3669{ 4321{
4322#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4323 dbg(0,"+#+:enter\n");
4324#endif
3670 ////DBG dbg(0,"EEnter\n"); 4325 ////DBG dbg(0,"EEnter\n");
3671 4326
3672 struct attr attr; 4327 struct attr attr;
3673 GList *l; 4328 GList *l;
3674 l = this_->vehicleprofiles; 4329 l = this_->vehicleprofiles;
3689 return 0; 4344 return 0;
3690} 4345}
3691 4346
3692static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv) 4347static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv)
3693{ 4348{
4349#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4350 dbg(0,"+#+:enter\n");
4351#endif
3694 ////DBG dbg(0,"EEnter\n"); 4352 ////DBG dbg(0,"EEnter\n");
3695 4353
3696 struct attr attr; 4354 struct attr attr;
3697 this_->vehicle = nv; 4355 this_->vehicle = nv;
4356
3698 if (nv && vehicle_get_attr(nv->vehicle, attr_profilename, &attr, NULL)) 4357 if (nv && vehicle_get_attr(nv->vehicle, attr_profilename, &attr, NULL))
3699 { 4358 {
3700 if (navit_set_vehicleprofile(this_, attr.u.str)) 4359 if (navit_set_vehicleprofile(this_, attr.u.str))
3701 { 4360 {
3702 return; 4361 return;
3703 } 4362 }
3704 } 4363 }
4364
3705 if (!navit_set_vehicleprofile(this_, "car")) 4365 if (!navit_set_vehicleprofile(this_, "car"))
3706 { 4366 {
3707 /* We do not have a fallback "car" profile 4367 /* We do not have a fallback "car" profile
3708 * so lets set any profile */ 4368 * so lets set any profile */
3709 GList *l; 4369 GList *l;
3726 * @param v The vehicle instance 4386 * @param v The vehicle instance
3727 * @returns 1 for success 4387 * @returns 1 for success
3728 */ 4388 */
3729int navit_add_vehicle(struct navit *this_, struct vehicle *v) 4389int navit_add_vehicle(struct navit *this_, struct vehicle *v)
3730{ 4390{
3731 ////DBG dbg(0,"EEnter\n"); 4391#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4392 dbg(0,"+#+:enter\n");
4393#endif
3732 4394
3733 struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1); 4395 struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1);
3734 struct attr follow, active, animate; 4396 struct attr follow, active, animate;
3735 nv->vehicle = v; 4397 nv->vehicle = v;
3736 nv->follow = 0; 4398 nv->follow = 0;
3744 if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num) 4406 if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num)
3745 navit_set_vehicle(this_, nv); 4407 navit_set_vehicle(this_, nv);
3746 if ((vehicle_get_attr(v, attr_animate, &animate, NULL))) 4408 if ((vehicle_get_attr(v, attr_animate, &animate, NULL)))
3747 nv->animate_cursor = animate.u.num; 4409 nv->animate_cursor = animate.u.num;
3748 nv->callback.type = attr_callback; 4410 nv->callback.type = attr_callback;
4411
4412 // gets called via this callback in vehicle_android.c [in function: vehicle_android_callback]
3749 nv->callback.u.callback = callback_new_attr_2(callback_cast(navit_vehicle_update), attr_position_coord_geo, this_, nv); 4413 nv->callback.u.callback = callback_new_attr_2(callback_cast(navit_vehicle_update), attr_position_coord_geo, this_, nv);
4414
4415 //dbg(0,"EEnter 11\n");
3750 vehicle_add_attr(nv->vehicle, &nv->callback); 4416 vehicle_add_attr(nv->vehicle, &nv->callback);
4417 //dbg(0,"EEnter 22\n");
3751 vehicle_set_attr(nv->vehicle, &this_->self); 4418 vehicle_set_attr(nv->vehicle, &this_->self);
4419 //dbg(0,"EEnter 33\n");
4420
4421#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4422 dbg(0,"+#+:leave\n");
4423#endif
4424
3752 return 1; 4425 return 1;
3753} 4426}
3754 4427
3755struct gui * 4428struct gui *
3756navit_get_gui(struct navit *this_) 4429navit_get_gui(struct navit *this_)
3757{ 4430{
4431#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4432 dbg(0,"+#+:enter\n");
4433#endif
3758 return this_->gui; 4434 return this_->gui;
3759} 4435}
3760 4436
3761struct transformation * 4437struct transformation *
3762navit_get_trans(struct navit *this_) 4438navit_get_trans(struct navit *this_)
3763{ 4439{
4440#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4441 dbg(0,"+#+:enter\n");
4442#endif
3764 return this_->trans; 4443 return this_->trans;
3765} 4444}
3766 4445
3767struct route * 4446struct route *
3768navit_get_route(struct navit *this_) 4447navit_get_route(struct navit *this_)
3769{ 4448{
4449#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4450 dbg(0,"+#+:enter\n");
4451#endif
3770 return this_->route; 4452 return this_->route;
3771} 4453}
3772 4454
3773struct navigation * 4455struct navigation *
3774navit_get_navigation(struct navit *this_) 4456navit_get_navigation(struct navit *this_)
3775{ 4457{
4458#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4459 dbg(0,"+#+:enter\n");
4460#endif
3776 return this_->navigation; 4461 return this_->navigation;
3777} 4462}
3778 4463
3779struct displaylist * 4464struct displaylist *
3780navit_get_displaylist(struct navit *this_) 4465navit_get_displaylist(struct navit *this_)
3781{ 4466{
4467#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4468 dbg(0,"+#+:enter\n");
4469#endif
3782 return this_->displaylist; 4470 return this_->displaylist;
3783} 4471}
3784 4472
3785void navit_layout_switch(struct navit *n) 4473void navit_layout_switch(struct navit *n)
3786{ 4474{
4475#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4476 dbg(0,"+#+:enter\n");
4477#endif
3787 ////DBG dbg(0,"EEnter\n"); 4478 ////DBG dbg(0,"EEnter\n");
3788 4479
3789 int currTs = 0; 4480 int currTs = 0;
3790 struct attr iso8601_attr, geo_attr, valid_attr, layout_attr; 4481 struct attr iso8601_attr, geo_attr, valid_attr, layout_attr;
3791 double trise, tset, trise_actual; 4482 double trise, tset, trise_actual;
3874 } 4565 }
3875} 4566}
3876 4567
3877int navit_set_vehicle_by_name(struct navit *n, const char *name) 4568int navit_set_vehicle_by_name(struct navit *n, const char *name)
3878{ 4569{
4570#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4571 dbg(0,"+#+:enter\n");
4572#endif
3879 ////DBG dbg(0,"EEnter\n"); 4573 ////DBG dbg(0,"EEnter\n");
3880 4574
3881 struct vehicle *v; 4575 struct vehicle *v;
3882 struct attr_iter *iter; 4576 struct attr_iter *iter;
3883 struct attr vehicle_attr, name_attr; 4577 struct attr vehicle_attr, name_attr;
3902 return 0; 4596 return 0;
3903} 4597}
3904 4598
3905int navit_set_layout_by_name(struct navit *n, const char *name) 4599int navit_set_layout_by_name(struct navit *n, const char *name)
3906{ 4600{
4601#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4602 dbg(0,"+#+:enter\n");
4603#endif
3907 ////DBG dbg(0,"EEnter\n"); 4604 ////DBG dbg(0,"EEnter\n");
3908 4605
3909 struct layout *l; 4606 struct layout *l;
3910 struct attr_iter iter; 4607 struct attr_iter iter;
3911 struct attr layout_attr; 4608 struct attr layout_attr;
3941 return 0; 4638 return 0;
3942} 4639}
3943 4640
3944void navit_disable_suspend() 4641void navit_disable_suspend()
3945{ 4642{
4643#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4644 dbg(0,"+#+:enter\n");
4645#endif
3946 ////DBG dbg(0,"EEnter\n"); 4646 ////DBG dbg(0,"EEnter\n");
3947 4647
3948 gui_disable_suspend(global_navit->gui); 4648 gui_disable_suspend(global_navit->gui);
3949 callback_list_call_attr_0(global_navit->attr_cbl, attr_unsuspend); 4649 callback_list_call_attr_0(global_navit->attr_cbl, attr_unsuspend);
3950} 4650}
3951 4651
4652
4653/**
4654 * @brief Finds the nearest street to a given coordinate
4655 *
4656 * @param ms The mapset to search in for the street
4657 * @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ]
4658 * @return The nearest street
4659 */
4660char*
4661navit_find_nearest_street(struct mapset *ms, struct pcoord *pc)
4662{
4663 int max_dist = 1; // smallest rectangle possible
4664 int dist, mindist = 0, pos;
4665 struct mapset_handle *h;
4666 struct map *m;
4667 struct map_rect *mr;
4668 struct item *item;
4669 struct coord lp;
4670 struct street_data *sd;
4671 struct coord c;
4672 struct coord_geo g;
4673 struct map_selection sel;
4674 struct attr street_name_attr;
4675 char *street_name = NULL;
4676
4677#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4678 dbg(0,"+#+:enter\n");
4679#endif
4680
4681 mindist = 10000; // start with small radius at the beginning!
4682 street_name = g_strdup_printf(" ");
4683
4684 h = mapset_open(ms);
4685
4686 if (!h)
4687 {
4688 return street_name;
4689 }
4690
4691 while ((m = mapset_next(h, 0)))
4692 {
4693 c.x = pc->x;
4694 c.y = pc->y;
4695 if (map_projection(m) != pc->pro)
4696 {
4697 transform_to_geo(pc->pro, &c, &g);
4698 transform_from_geo(map_projection(m), &g, &c);
4699 }
4700
4701 sel.next = NULL;
4702 sel.order = 18;
4703 sel.range.min = type_line;
4704 sel.range.max = type_area;
4705 sel.u.c_rect.lu.x = c.x - max_dist;
4706 sel.u.c_rect.lu.y = c.y + max_dist;
4707 sel.u.c_rect.rl.x = c.x + max_dist;
4708 sel.u.c_rect.rl.y = c.y - max_dist;
4709
4710 mr = map_rect_new(m, &sel);
4711 if (!mr)
4712 {
4713 continue;
4714 }
4715
4716 while ((item = map_rect_get_item(mr)))
4717 {
4718 if (item_get_default_flags(item->type))
4719 {
4720 sd = street_get_data(item);
4721 if (!sd)
4722 {
4723 continue;
4724 }
4725 //dbg(0,"6 sd x:%d sd y:%d count:%d\n", sd->c->x, sd->c->y, sd->count);
4726 //dbg(0,"6 c x:%d c y:%d\n", c.x, c.y);
4727 dist = transform_distance_polyline_sq(sd->c, sd->count, &c, &lp, &pos);
4728 //dbg(0,"mindist:%d dist:%d\n", mindist, dist);
4729 if (dist < mindist)
4730 {
4731 //dbg(0,"6.a\n");
4732 mindist = dist;
4733
4734 if (item_attr_get(item, attr_label, &street_name_attr))
4735 {
4736 if (street_name)
4737 {
4738 g_free(street_name);
4739 street_name = NULL;
4740 }
4741 street_name = g_strdup_printf("%s", street_name_attr.u.str);
4742 //dbg(0,"r1 %s\n", street_name);
4743 }
4744 /*
4745 else if (item_attr_get(&sd->item, attr_street_name, &street_name_attr))
4746 {
4747 if (street_name)
4748 {
4749 dbg(0,"6.b\n");
4750 g_free(street_name);
4751 street_name = NULL;
4752 dbg(0,"6.c\n");
4753 }
4754 street_name = g_strdup_printf("%s", street_name_attr.u.str);
4755 dbg(0,"r2 %s\n", street_name);
4756 }
4757 */
4758 else if (item_attr_get(item, attr_street_name, &street_name_attr))
4759 {
4760 if (street_name)
4761 {
4762 g_free(street_name);
4763 street_name = NULL;
4764 }
4765 street_name = g_strdup_printf("%s", street_name_attr.u.str);
4766 //dbg(0,"r3 %s\n", street_name);
4767 }
4768 else if (item_attr_get(item, attr_street_name_systematic, &street_name_attr))
4769 {
4770 if (street_name)
4771 {
4772 g_free(street_name);
4773 street_name = NULL;
4774 }
4775 street_name = g_strdup_printf("%s", street_name_attr.u.str);
4776 //dbg(0,"r4 %s\n", street_name);
4777 }
4778 else
4779 {
4780 //if (street_name)
4781 //{
4782 // g_free(street_name);
4783 // street_name = NULL;
4784 //}
4785 //street_name = g_strdup_printf("---");
4786 }
4787 }
4788 street_data_free(sd);
4789 }
4790 }
4791
4792 if (mr)
4793 {
4794 map_rect_destroy(mr);
4795 }
4796 }
4797 mapset_close(h);
4798 return street_name;
4799}
4800
4801
4802/**
4803 * @brief Finds the nearest street to a given coordinate
4804 *
4805 * @param ms The mapset to search in for the street
4806 * @param pc The coordinate to find a street nearby [ input in pcoord(x,y) ]
4807 * @return The nearest street (as a string of coords "0xFFF 0xFFF\n..." seperated by "\n")
4808 */
4809char*
4810navit_find_nearest_street_coords(struct mapset *ms, struct pcoord *pc)
4811{
4812 int max_dist = 1; // smallest rectangle possible
4813 int dist, mindist = 0, pos;
4814 struct mapset_handle *h;
4815 struct map *m;
4816 struct map_rect *mr;
4817 struct item *item;
4818 struct coord lp;
4819 struct street_data *sd = NULL;
4820 struct street_data *sd_copy = NULL;
4821 struct coord c;
4822 struct coord_geo g;
4823 struct map_selection sel;
4824 int i;
4825 int found_good = 0;
4826 struct attr street_name_attr;
4827 char *street_coords = NULL;
4828 char *street_coords_tmp = NULL;
4829
4830#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4831 dbg(0,"+#+:enter\n");
4832#endif
4833
4834 mindist = 10000; // start with small radius at the beginning!
4835 street_coords = g_strdup_printf("");
4836
4837 h = mapset_open(ms);
4838
4839 if (!h)
4840 {
4841 return street_coords;
4842 }
4843
4844 while ((m = mapset_next(h, 0)))
4845 {
4846 c.x = pc->x;
4847 c.y = pc->y;
4848 if (map_projection(m) != pc->pro)
4849 {
4850 transform_to_geo(pc->pro, &c, &g);
4851 transform_from_geo(map_projection(m), &g, &c);
4852 }
4853
4854 sel.next = NULL;
4855 sel.order = 18;
4856 sel.range.min = type_line;
4857 sel.range.max = type_area;
4858 sel.u.c_rect.lu.x = c.x - max_dist;
4859 sel.u.c_rect.lu.y = c.y + max_dist;
4860 sel.u.c_rect.rl.x = c.x + max_dist;
4861 sel.u.c_rect.rl.y = c.y - max_dist;
4862
4863 mr = map_rect_new(m, &sel);
4864 if (!mr)
4865 {
4866 continue;
4867 }
4868
4869 while ((item = map_rect_get_item(mr)))
4870 {
4871 if (item_get_default_flags(item->type))
4872 {
4873 sd = street_get_data(item);
4874 if (!sd)
4875 {
4876 continue;
4877 }
4878 found_good = 0;
4879 dist = transform_distance_polyline_sq(sd->c, sd->count, &c, &lp, &pos);
4880 if (dist < mindist)
4881 {
4882 mindist = dist;
4883
4884 /*
4885 if (item_attr_get(item, attr_label, &street_name_attr))
4886 {
4887 found_good = 1;
4888 }
4889 else if (item_attr_get(item, attr_street_name, &street_name_attr))
4890 {
4891 found_good = 1;
4892 }
4893 else if (item_attr_get(item, attr_street_name_systematic, &street_name_attr))
4894 {
4895 found_good = 1;
4896 }
4897 */
4898
4899 // allow any street/line, so you can select streets without name also!
4900 found_good = 1;
4901 }
4902
4903 if (found_good == 1)
4904 {
4905 if (sd_copy)
4906 {
4907 street_data_free(sd_copy);
4908 }
4909 sd_copy = street_data_dup(sd);
4910 }
4911 street_data_free(sd);
4912 }
4913 }
4914
4915 if (mr)
4916 {
4917 map_rect_destroy(mr);
4918 }
4919 }
4920 mapset_close(h);
4921
4922 if (sd_copy)
4923 {
4924 //struct coord ca[sd_copy->count];
4925 //item_coord_get(&sd_copy->item, ca, sd_copy->count);
4926
4927 // dbg(0,"sd_copy->count=%d\n", sd_copy->count);
4928
4929 for (i = 0; i < sd_copy->count; i++)
4930 {
4931 /*
4932 unsigned int x;
4933 unsigned int y;
4934 char *sign_x = "";
4935 char *sign_y = "";
4936
4937 if ( c->x < 0 ) {
4938 x = -c->x;
4939 sign_x = "-";
4940 } else {
4941 x = c->x;
4942 }
4943 if ( c->y < 0 ) {
4944 y = -c->y;
4945 sign_y = "-";
4946 } else {
4947 y = c->y;
4948 }
4949 */
4950
4951 street_coords_tmp = street_coords;
4952 if (street_coords == NULL)
4953 {
4954 street_coords = g_strdup_printf("0x%x 0x%x\n", sd_copy->c[i].x, sd_copy->c[i].y);
4955 }
4956 else
4957 {
4958 char *tmp2 = g_strdup_printf("0x%x 0x%x\n", sd_copy->c[i].x, sd_copy->c[i].y);
4959 street_coords = g_strconcat(street_coords_tmp, tmp2, NULL);
4960 g_free(street_coords_tmp);
4961 g_free(tmp2);
4962 }
4963 }
4964
4965 street_data_free(sd_copy);
4966 }
4967
4968 return street_coords;
4969}
4970
4971
3952int navit_block(struct navit *this_, int block) 4972int navit_block(struct navit *this_, int block)
3953{ 4973{
4974#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4975 dbg(0,"+#+:enter\n");
4976#endif
3954 ////DBG dbg(0,"EEnter\n"); 4977 ////DBG dbg(0,"EEnter\n");
3955 4978
3956 if (block > 0) 4979 if (block > 0)
3957 { 4980 {
3958 this_->blocked |= 1; 4981 this_->blocked |= 1;
3970 return 0; 4993 return 0;
3971} 4994}
3972 4995
3973void navit_destroy(struct navit *this_) 4996void navit_destroy(struct navit *this_)
3974{ 4997{
4998#ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT
4999 dbg(0,"+#+:enter\n");
5000#endif
3975 dbg(0,"EEnter\n"); 5001 dbg(0, "EEnter\n");
3976 5002
3977 struct mapset*ms; 5003 struct mapset*ms;
3978 callback_list_call_attr_1(this_->attr_cbl, attr_destroy, this_); 5004 callback_list_call_attr_1(this_->attr_cbl, attr_destroy, this_);
3979 5005
3980 // //DBG dbg(0,"enter"); 5006 // //DBG dbg(0,"enter");
3981 5007
3982 /* TODO: destroy objects contained in this_ */ 5008 /* TODO: destroy objects contained in this_ */
3983 if (this_->vehicle) 5009 if (this_->vehicle)
5010 {
3984 vehicle_destroy(this_->vehicle->vehicle); 5011 vehicle_destroy(this_->vehicle->vehicle);
5012 }
5013
5014 /*
3985 if (this_->bookmarks) 5015 if (this_->bookmarks)
3986 { 5016 {
3987 dbg(0, "save position to file\n"); 5017 dbg(0, "save position to file\n");
3988 char *center_file = bookmarks_get_center_file(TRUE); 5018 char *center_file = bookmarks_get_center_file(TRUE);
3989 bookmarks_write_center_to_file(this_->bookmarks, center_file); 5019 bookmarks_write_center_to_file(this_->bookmarks, center_file);
3990 g_free(center_file); 5020 g_free(center_file);
3991 bookmarks_destroy(this_->bookmarks); 5021 bookmarks_destroy(this_->bookmarks);
3992 dbg(0, "save position to file -> ready\n"); 5022 dbg(0, "save position to file -> ready\n");
3993 } 5023 }
5024 */
5025
3994 dbg(0,"ex 001\n"); 5026 dbg(0, "ex 001\n");
3995 callback_destroy(this_->nav_speech_cb); 5027 callback_destroy(this_->nav_speech_cb);
3996 dbg(0,"ex 002\n"); 5028 dbg(0, "ex 002\n");
3997 callback_destroy(this_->roadbook_callback); 5029 callback_destroy(this_->roadbook_callback);
3998 dbg(0,"ex 003\n"); 5030 dbg(0, "ex 003\n");
3999 callback_destroy(this_->popup_callback); 5031 callback_destroy(this_->popup_callback);
4000 dbg(0,"ex 004\n"); 5032 dbg(0, "ex 004\n");
4001 callback_destroy(this_->motion_timeout_callback); 5033 callback_destroy(this_->motion_timeout_callback);
4002 dbg(0,"ex 005\n"); 5034 dbg(0, "ex 005\n");
4003 callback_destroy(this_->progress_cb); 5035 callback_destroy(this_->progress_cb);
4004 dbg(0,"ex 006\n"); 5036 dbg(0, "ex 006\n");
5037 /*
4005 if (this_->gra) 5038 if (this_->gra)
4006 graphics_remove_callback(this_->gra, this_->resize_callback); 5039 graphics_remove_callback(this_->gra, this_->resize_callback);
4007 callback_destroy(this_->resize_callback); 5040 callback_destroy(this_->resize_callback);
5041 */
4008 dbg(0,"ex 007\n"); 5042 dbg(0, "ex 007\n");
5043 /*
4009 if (this_->gra) 5044 if (this_->gra)
4010 graphics_remove_callback(this_->gra, this_->button_callback); 5045 graphics_remove_callback(this_->gra, this_->button_callback);
4011 callback_destroy(this_->button_callback); 5046 callback_destroy(this_->button_callback);
5047 */
4012 dbg(0,"ex 008\n"); 5048 dbg(0, "ex 008\n");
5049 /*
4013 if (this_->gra) 5050 if (this_->gra)
4014 graphics_remove_callback(this_->gra, this_->motion_callback); 5051 graphics_remove_callback(this_->gra, this_->motion_callback);
4015 callback_destroy(this_->motion_callback); 5052 callback_destroy(this_->motion_callback);
5053 */
4016 dbg(0,"ex 009\n"); 5054 dbg(0, "ex 009\n");
4017 if (this_->gra) 5055 if (this_->gra)
5056 {
4018 graphics_remove_callback(this_->gra, this_->predraw_callback); 5057 graphics_remove_callback(this_->gra, this_->predraw_callback);
5058 }
4019 callback_destroy(this_->predraw_callback); 5059 callback_destroy(this_->predraw_callback);
4020 dbg(0,"ex 010\n"); 5060 dbg(0, "ex 010\n");
4021 route_destroy(this_->route); 5061 route_destroy(this_->route);
4022 dbg(0,"ex 011\n"); 5062 dbg(0, "ex 011\n");
4023 ms = navit_get_mapset(this_); 5063 ms = navit_get_mapset(this_);
4024 dbg(0,"ex 012\n"); 5064 dbg(0, "ex 012\n");
4025 if (ms) 5065 if (ms)
5066 {
4026 mapset_destroy(ms); 5067 mapset_destroy(ms);
5068 }
4027 dbg(0,"ex 013\n"); 5069 dbg(0, "ex 013\n");
4028 graphics_free(this_->gra); 5070 graphics_free(this_->gra);
4029 dbg(0,"ex 014\n"); 5071 dbg(0, "ex 014\n");
4030 g_free(this_); 5072 g_free(this_);
4031 dbg(0,"ex 015\n"); 5073 dbg(0, "ex 015\n");
4032} 5074}
4033 5075
4034/** @} */ 5076/** @} */

Legend:
Removed from v.27  
changed lines
  Added in v.28

   
Visit the ZANavi Wiki