Update of /cvsroot/roadmap/roadmap/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21334 Modified Files: roadgps_screen.c roadgps_start.c roadmap_download.c roadmap_preferences.c roadmap_screen.c roadmap_start.c roadmap_start.h Log Message: separate "manual" screen updates from "automatic" updates, so that GPS updates don't continuously cause the current update to be interrupted. roadgps_screen.c also contains sun/moon position changes. Index: roadmap_download.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_download.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** roadmap_download.c 15 May 2008 00:12:02 -0000 1.20 --- roadmap_download.c 17 Jun 2008 01:30:13 -0000 1.21 *************** *** 701,705 **** roadmap_file_remove (NULL, path); ! roadmap_start_request_repaint_map (); roadmap_download_delete_populate (); --- 701,705 ---- roadmap_file_remove (NULL, path); ! roadmap_start_request_repaint_map (REPAINT_NOW); roadmap_download_delete_populate (); Index: roadgps_screen.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadgps_screen.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** roadgps_screen.c 15 May 2008 00:46:39 -0000 1.22 --- roadgps_screen.c 17 Jun 2008 01:30:13 -0000 1.23 *************** *** 41,44 **** --- 41,45 ---- #include "roadmap_canvas.h" #include "roadgps_screen.h" + #include "roadmap_sunrise.h" static RoadMapConfigDescriptor RoadMapConfigGPSBackground = *************** *** 140,143 **** --- 141,146 ---- RoadMapPen RoadGpsLabels; RoadMapPen RoadGpsValues; + RoadMapPen RoadGpsMoonPen; + RoadMapPen RoadGpsSunPen; int RoadMapGPSFontSize; *************** *** 167,170 **** --- 170,214 ---- } + static void roadgps_screen_draw_sunmoon_position () + { + double scale = 0.0; + double azimuth, elevation; + + RoadMapGuiPoint centers[1]; + int radius[1]; + + roadmap_sunposition(&RoadGpsPosition, &azimuth, &elevation); + if (elevation > 0.0) + { + + scale = RoadGpsFrame.position_scale * (90 - elevation) / 90; + + azimuth *= DEGRE2RADIAN; + + centers[0].x = RoadGpsFrame.centers[0].x + (short) (sin(azimuth) * scale); + centers[0].y = RoadGpsFrame.centers[0].y - (short) (cos(azimuth) * scale); + + radius[0]=10; + roadmap_canvas_select_pen (RoadGpsSunPen); + roadmap_canvas_draw_multiple_circles (1, centers, radius, 1, 0); + + } + + roadmap_moonposition(&RoadGpsPosition, &azimuth, &elevation); + if (elevation > 0.0) + { + scale = RoadGpsFrame.position_scale * (90 - elevation) / 90; + + azimuth *= DEGRE2RADIAN; + + centers[0].x = RoadGpsFrame.centers[0].x + (short) (sin(azimuth) * scale); + centers[0].y = RoadGpsFrame.centers[0].y - (short) (cos(azimuth) * scale); + + radius[0]=10; + roadmap_canvas_select_pen (RoadGpsMoonPen); + roadmap_canvas_draw_multiple_circles (1, centers, radius, 1, 0); + } + } + static void roadgps_screen_draw_satellite_position *************** *** 483,486 **** --- 527,533 ---- } + if (RoadMapGpsReceivedTime != 0) { + roadgps_screen_draw_sunmoon_position(); + } roadgps_screen_draw_position(); roadmap_canvas_refresh (); *************** *** 489,493 **** void roadgps_screen_request_repaint(void) { ! roadmap_start_request_repaint(ROADMAP_GPS); } --- 536,540 ---- void roadgps_screen_request_repaint(void) { ! roadmap_start_request_repaint(ROADMAP_GPS, 1); } *************** *** 678,681 **** --- 725,738 ---- (roadmap_config_get (&RoadMapConfigGPSInactiveFill)); + RoadGpsSunPen = roadmap_canvas_create_pen ("gps/sun"); + roadmap_canvas_set_thickness (2); + roadmap_canvas_set_foreground + ("yellow"); + + RoadGpsMoonPen = roadmap_canvas_create_pen ("gps/moon"); + roadmap_canvas_set_thickness (2); + roadmap_canvas_set_foreground + ("LightYellow"); + RoadGpsActiveLabels = roadmap_canvas_create_pen ("gps/activelabels"); roadmap_canvas_set_thickness (2); *************** *** 736,739 **** --- 793,797 ---- roadmap_gps_register_listener (roadgps_screen_listener); + RoadMapGpsReceivedTime = time(NULL); } Index: roadmap_start.h =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_start.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** roadmap_start.h 27 Apr 2008 00:08:55 -0000 1.7 --- roadmap_start.h 17 Jun 2008 01:30:13 -0000 1.8 *************** *** 46,53 **** int roadmap_start_return_to_map(void); void roadmap_start_do_callback(RoadMapCallback cb); int roadmap_start_repaint_scheduled(void); ! void roadmap_start_request_repaint_map (void); ! void roadmap_start_request_repaint (int screen); #define ROADMAP_MAP 1 #define ROADMAP_GPS 2 --- 46,59 ---- int roadmap_start_return_to_map(void); void roadmap_start_do_callback(RoadMapCallback cb); + + enum { + REPAINT_NOT_NEEDED = 0, + REPAINT_MAYBE, + REPAINT_NOW + }; int roadmap_start_repaint_scheduled(void); ! void roadmap_start_request_repaint_map (int interrupt); ! void roadmap_start_request_repaint (int screen, int priority); #define ROADMAP_MAP 1 #define ROADMAP_GPS 2 Index: roadgps_start.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadgps_start.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** roadgps_start.c 14 Jun 2008 06:02:01 -0000 1.24 --- roadgps_start.c 17 Jun 2008 01:30:13 -0000 1.25 *************** *** 234,238 **** } ! void roadmap_start_request_repaint (int screen) { roadgps_screen_draw(); --- 234,238 ---- } ! void roadmap_start_request_repaint (int screen, int priority) { roadgps_screen_draw(); Index: roadmap_start.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_start.c,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** roadmap_start.c 30 May 2008 16:23:25 -0000 1.142 --- roadmap_start.c 17 Jun 2008 01:30:13 -0000 1.143 *************** *** 248,251 **** --- 248,255 ---- } + void roadmap_start_download_done_callback(void) { + roadmap_start_request_repaint_map (REPAINT_NOW); + } + static void roadmap_start_toggle_download (void) { *************** *** 272,281 **** } ! roadmap_download_subscribe_when_done (roadmap_start_request_repaint_map); roadmap_locator_declare_downloader (roadmap_download_get_county); roadmap_download_unblock_all (); } ! roadmap_start_request_repaint_map (); } --- 276,286 ---- } ! roadmap_download_subscribe_when_done ! (roadmap_start_download_done_callback); roadmap_locator_declare_downloader (roadmap_download_get_county); roadmap_download_unblock_all (); } ! roadmap_start_request_repaint_map (REPAINT_NOW); } *************** *** 298,302 **** if (RoadMapStartScreenActive != ROADMAP_MAP) { RoadMapStartScreenActive = ROADMAP_MAP; ! roadmap_start_request_repaint(ROADMAP_MAP); return 1; } --- 303,307 ---- if (RoadMapStartScreenActive != ROADMAP_MAP) { RoadMapStartScreenActive = ROADMAP_MAP; ! roadmap_start_request_repaint(ROADMAP_MAP, 1); return 1; } *************** *** 306,310 **** void roadmap_start_gps_console(void) { RoadMapStartScreenActive = ROADMAP_GPS; ! roadmap_start_request_repaint(ROADMAP_GPS); } --- 311,315 ---- void roadmap_start_gps_console(void) { RoadMapStartScreenActive = ROADMAP_GPS; ! roadmap_start_request_repaint(ROADMAP_GPS, 1); } *************** *** 347,351 **** ! static int RoadMapStartRepaintNeeded; static int RoadMapStartIdleInstalled; --- 352,356 ---- ! static int RoadMapStartRepaintNeeded = REPAINT_NOT_NEEDED; static int RoadMapStartIdleInstalled; *************** *** 357,364 **** static void roadmap_start_repaint_if_requested(void) { ! // fprintf(stderr, "start_repaint_if_requested: req is %d\n", RoadMapStartRepaintNeeded); ! while (RoadMapStartRepaintNeeded) { ! RoadMapStartRepaintNeeded = 0; if (RoadMapStartScreenActive == ROADMAP_MAP) { --- 362,368 ---- static void roadmap_start_repaint_if_requested(void) { ! while (RoadMapStartRepaintNeeded != REPAINT_NOT_NEEDED) { ! RoadMapStartRepaintNeeded = REPAINT_NOT_NEEDED; if (RoadMapStartScreenActive == ROADMAP_MAP) { *************** *** 373,385 **** } ! void roadmap_start_request_repaint (int which_screen) { ! /* the repaint is actually invoked via the gui's mainloop ! * idle routine. we need to install and remove this routine * on an as-needed basis, because otherwise installing something * in the gui's idle loop causes it to eat CPU (i.e., it can't * sleep -- it has to spin.) */ - // fprintf(stderr, "requesting repaint was %d", RoadMapStartRepaintNeeded); if (RoadMapStartScreenActive == which_screen) { if (!RoadMapStartIdleInstalled) { --- 377,400 ---- } ! /* The "which_screen" parameter tells us whether we're being ! * asked to upgrade the regular map screen or the gps console ! * screen. There's no point in rendering a hidden screen. The ! * "priority" parameter tells us (usually) whether the requested ! * repaint was user-initiated or not. The difference is in ! * whether we interrupt a repaint already in progress or not: we ! * assume the user wants instant gratification, and so we'll ! * interrupt an in-progress repaint. A repaint requested because ! * the GPS moved, or because the time changed, is lower priority, ! * and won't happen unless there's nothing else to do. That's ! * the theory anyway. ! */ ! void roadmap_start_request_repaint (int which_screen, int priority) { ! /* The repaint is actually invoked via the gui's mainloop ! * idle routine. We need to install and remove this routine * on an as-needed basis, because otherwise installing something * in the gui's idle loop causes it to eat CPU (i.e., it can't * sleep -- it has to spin.) */ if (RoadMapStartScreenActive == which_screen) { if (!RoadMapStartIdleInstalled) { *************** *** 387,399 **** RoadMapStartIdleInstalled = 1; } ! RoadMapStartRepaintNeeded = 1; } - - // fprintf(stderr, ".. is %d\n", RoadMapStartRepaintNeeded); } ! void roadmap_start_request_repaint_map (void) { ! roadmap_start_request_repaint (ROADMAP_MAP); } --- 402,412 ---- RoadMapStartIdleInstalled = 1; } ! RoadMapStartRepaintNeeded = priority ? REPAINT_NOW : REPAINT_MAYBE; } } ! void roadmap_start_request_repaint_map (int priority) { ! roadmap_start_request_repaint (ROADMAP_MAP, priority); } *************** *** 1437,1441 **** roadmap_main_set_periodic (period, roadmap_start_periodic); ! roadmap_start_request_repaint_map (); } --- 1450,1454 ---- roadmap_main_set_periodic (period, roadmap_start_periodic); ! roadmap_start_request_repaint_map (REPAINT_NOW); } Index: roadmap_screen.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_screen.c,v retrieving revision 1.128 retrieving revision 1.129 diff -C2 -d -r1.128 -r1.129 *** roadmap_screen.c 15 Jun 2008 16:09:58 -0000 1.128 --- roadmap_screen.c 17 Jun 2008 01:30:13 -0000 1.129 *************** *** 774,779 **** * them in a temporary buffer, and reverse them below. */ ! shape_points = realloc(shape_points, ! (last_shape - first_shape + 1) * sizeof (*shape_points)); shape_ptr = shape_points; } else { --- 774,780 ---- * them in a temporary buffer, and reverse them below. */ ! int shape_points_size = ! (last_shape - first_shape + 1) * sizeof(*shape_points); ! shape_points = realloc(shape_points, shape_points_size); shape_ptr = shape_points; } else { *************** *** 1368,1372 **** if (!RoadMapScreenDragging && roadmap_screen_busy_check(total, progress)) { ! if (roadmap_start_repaint_scheduled()) { if (progress < (3 * total) / 4) { return 1; --- 1369,1373 ---- if (!RoadMapScreenDragging && roadmap_screen_busy_check(total, progress)) { ! if (roadmap_start_repaint_scheduled() == REPAINT_NOW) { if (progress < (3 * total) / 4) { return 1; *************** *** 1599,1603 **** if (RoadMapScreenInitialized) { ! roadmap_start_request_repaint_map(); } --- 1600,1604 ---- if (RoadMapScreenInitialized) { ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1625,1629 **** roadmap_display_activate ("Selected Street", &line, &position, &street); ! roadmap_start_request_repaint_map(); } --- 1626,1630 ---- roadmap_display_activate ("Selected Street", &line, &position, &street); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1753,1761 **** /* debug support: set to 'printf' to be told why a refresh occurred */ // #define REPORT_REFRESH(x) fprintf(stderr, "%s\n", x) ! #define REPORT_REFRESH(x) 1 void roadmap_screen_refresh (void) { int refresh = 0; roadmap_log_push ("roadmap_screen_refresh"); --- 1754,1763 ---- /* debug support: set to 'printf' to be told why a refresh occurred */ // #define REPORT_REFRESH(x) fprintf(stderr, "%s\n", x) ! #define REPORT_REFRESH(x) void roadmap_screen_refresh (void) { int refresh = 0; + int force_refresh = REPAINT_MAYBE; roadmap_log_push ("roadmap_screen_refresh"); *************** *** 1765,1769 **** roadmap_screen_reset_delta (); roadmap_math_set_center (roadmap_trip_get_focus_position ()); ! refresh = 1 && REPORT_REFRESH ("focus changed"); if (RoadMapScreenOrientationDynamic) { --- 1767,1772 ---- roadmap_screen_reset_delta (); roadmap_math_set_center (roadmap_trip_get_focus_position ()); ! force_refresh = REPAINT_NOW; ! REPORT_REFRESH ("focus changed"); if (RoadMapScreenOrientationDynamic) { *************** *** 1775,1779 **** roadmap_math_set_center (roadmap_trip_get_focus_position ()); ! refresh |= 1 && REPORT_REFRESH("focus moved"); if (!RoadMapScreenOrientationDynamic) --- 1778,1783 ---- roadmap_math_set_center (roadmap_trip_get_focus_position ()); ! refresh = 1; ! REPORT_REFRESH("focus moved"); if (!RoadMapScreenOrientationDynamic) *************** *** 1801,1817 **** * probably use a callback registration system for this.) */ ! refresh |= roadmap_config_match (&RoadMapConfigMapRefresh, "forced") && REPORT_REFRESH( "forced\n" ); ! refresh |= roadmap_trip_is_refresh_needed() && REPORT_REFRESH( "trip\n" ); ! refresh |= roadmap_landmark_is_refresh_needed() && REPORT_REFRESH( "landmark\n" ); ! refresh |= roadmap_track_is_refresh_needed() && REPORT_REFRESH( "track\n" ); ! refresh |= roadmap_display_is_refresh_needed() && REPORT_REFRESH( "display\n" ); ! if (refresh) roadmap_start_request_repaint_map(); roadmap_log_pop (); --- 1805,1832 ---- * probably use a callback registration system for this.) */ ! if (roadmap_config_match (&RoadMapConfigMapRefresh, "forced")) { ! force_refresh = REPAINT_NOW; REPORT_REFRESH( "forced\n" ); ! } ! if (roadmap_trip_is_refresh_needed()) { ! force_refresh = REPAINT_NOW; REPORT_REFRESH( "trip\n" ); ! } ! if (roadmap_landmark_is_refresh_needed()) { ! force_refresh = REPAINT_NOW; REPORT_REFRESH( "landmark\n" ); ! } ! if (roadmap_track_is_refresh_needed()) { ! refresh = 1; REPORT_REFRESH( "track\n" ); ! } ! if (roadmap_display_is_refresh_needed()) { ! refresh = 1; REPORT_REFRESH( "display\n" ); + } ! if (refresh || force_refresh != REPAINT_NOT_NEEDED) ! roadmap_start_request_repaint_map(force_refresh); roadmap_log_pop (); *************** *** 1829,1833 **** RoadMapScreenFrozen = 0; ! roadmap_start_request_repaint_map(); } --- 1844,1848 ---- RoadMapScreenFrozen = 0; ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1862,1866 **** roadmap_math_set_orientation (calculated_rotation); RoadMapScreenRotation = rotation; ! roadmap_start_request_repaint_map(); } --- 1877,1881 ---- roadmap_math_set_orientation (calculated_rotation); RoadMapScreenRotation = rotation; ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1882,1886 **** VIEW_MODE_3D : VIEW_MODE_2D; roadmap_screen_set_horizon(); ! roadmap_start_request_repaint_map(); } --- 1897,1901 ---- VIEW_MODE_3D : VIEW_MODE_2D; roadmap_screen_set_horizon(); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1888,1892 **** RoadMapScreenLabels = ! RoadMapScreenLabels; ! roadmap_start_request_repaint_map(); } --- 1903,1907 ---- RoadMapScreenLabels = ! RoadMapScreenLabels; ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1909,1913 **** RoadMapScreen3dHorizon += 100; roadmap_math_set_horizon (RoadMapScreen3dHorizon); ! roadmap_start_request_repaint_map(); } --- 1924,1928 ---- RoadMapScreen3dHorizon += 100; roadmap_math_set_horizon (RoadMapScreen3dHorizon); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1919,1923 **** RoadMapScreen3dHorizon -= 100; roadmap_math_set_horizon (RoadMapScreen3dHorizon); ! roadmap_start_request_repaint_map(); } --- 1934,1938 ---- RoadMapScreen3dHorizon -= 100; roadmap_math_set_horizon (RoadMapScreen3dHorizon); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1928,1932 **** roadmap_screen_record_move (0, 0 - (RoadMapScreenHeight / FRACMOVE)); ! roadmap_start_request_repaint_map(); } --- 1943,1947 ---- roadmap_screen_record_move (0, 0 - (RoadMapScreenHeight / FRACMOVE)); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1935,1939 **** roadmap_screen_record_move (0, RoadMapScreenHeight / FRACMOVE); ! roadmap_start_request_repaint_map(); } --- 1950,1954 ---- roadmap_screen_record_move (0, RoadMapScreenHeight / FRACMOVE); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1942,1946 **** roadmap_screen_record_move (RoadMapScreenHeight / FRACMOVE, 0); ! roadmap_start_request_repaint_map(); } --- 1957,1961 ---- roadmap_screen_record_move (RoadMapScreenHeight / FRACMOVE, 0); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1949,1953 **** roadmap_screen_record_move (0 - (RoadMapScreenHeight / FRACMOVE), 0); ! roadmap_start_request_repaint_map(); } --- 1964,1968 ---- roadmap_screen_record_move (0 - (RoadMapScreenHeight / FRACMOVE), 0); ! roadmap_start_request_repaint_map(REPAINT_NOW); } *************** *** 1958,1962 **** roadmap_layer_adjust (); roadmap_math_compute_scale (); ! roadmap_start_request_repaint_map(); roadmap_screen_refresh(); } --- 1973,1977 ---- roadmap_layer_adjust (); roadmap_math_compute_scale (); ! roadmap_start_request_repaint_map(REPAINT_NOW); roadmap_screen_refresh(); } *************** *** 1970,1974 **** roadmap_layer_adjust (); roadmap_math_compute_scale (); ! roadmap_start_request_repaint_map(); roadmap_screen_refresh(); } --- 1985,1989 ---- roadmap_layer_adjust (); roadmap_math_compute_scale (); ! roadmap_start_request_repaint_map(REPAINT_NOW); roadmap_screen_refresh(); } *************** *** 1982,1986 **** roadmap_layer_adjust (); roadmap_math_compute_scale (); ! roadmap_start_request_repaint_map(); roadmap_screen_refresh(); } --- 1997,2001 ---- roadmap_layer_adjust (); roadmap_math_compute_scale (); ! roadmap_start_request_repaint_map(REPAINT_NOW); roadmap_screen_refresh(); } *************** *** 2019,2022 **** --- 2034,2040 ---- } + void roadmap_screen_state_refresh(void) { + roadmap_start_request_repaint_map(REPAINT_MAYBE); + } void roadmap_screen_initialize (void) { *************** *** 2087,2091 **** roadmap_state_add ("get_orientation", &roadmap_screen_get_orientation_mode); ! roadmap_state_monitor (&roadmap_start_request_repaint_map); } --- 2105,2110 ---- roadmap_state_add ("get_orientation", &roadmap_screen_get_orientation_mode); ! roadmap_state_monitor (&roadmap_screen_state_refresh); ! } Index: roadmap_preferences.c =================================================================== RCS file: /cvsroot/roadmap/roadmap/src/roadmap_preferences.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** roadmap_preferences.c 27 Apr 2008 00:08:55 -0000 1.14 --- roadmap_preferences.c 17 Jun 2008 01:30:13 -0000 1.15 *************** *** 75,79 **** roadmap_dialog_hide (name); ! roadmap_start_request_repaint_map (); } --- 75,79 ---- roadmap_dialog_hide (name); ! roadmap_start_request_repaint_map (REPAINT_NOW); } |