+ /* calculate widgets circle_x and circle_y */
+ /* split up lat,lon into lat and lon */
+ if ( 2 == sscanf ( gtk_entry_get_text ( GTK_ENTRY(widgets->center_entry) ), "%lf,%lf", &lat, &lon ) ) {
+ struct LatLon ll;
+ VikCoord c;
+ gint x, y;
+
+ ll.lat = lat; ll.lon = lon;
+ vik_coord_load_from_latlon ( &c, vik_viewport_get_coord_mode ( widgets->vvp ), &ll );
+ vik_viewport_coord_to_screen ( widgets->vvp, &c, &x, &y );
+ /* TODO: real calculation */
+ if ( x > -1000 && y > -1000 && x < (vik_viewport_get_width(widgets->vvp) + 1000) &&
+ y < (vik_viewport_get_width(widgets->vvp) + 1000) ) {
+ VikCoord c1, c2;
+ gdouble pixels_per_meter;
+
+ widgets->circle_x = x;
+ widgets->circle_y = y;
+
+ /* determine miles per pixel */
+ vik_viewport_screen_to_coord ( widgets->vvp, 0, vik_viewport_get_height(widgets->vvp)/2, &c1 );
+ vik_viewport_screen_to_coord ( widgets->vvp, vik_viewport_get_width(widgets->vvp), vik_viewport_get_height(widgets->vvp)/2, &c2 );
+ pixels_per_meter = ((gdouble)vik_viewport_get_width(widgets->vvp)) / vik_coord_diff(&c1, &c2);
+
+ /* this is approximate */
+ widgets->circle_width = gtk_spin_button_get_value_as_float ( GTK_SPIN_BUTTON(widgets->miles_radius_spin) )
+ * METERSPERMILE * pixels_per_meter * 2;
+
+ vik_viewport_draw_arc ( widgets->vvp, widgets->circle_gc, FALSE,
+ widgets->circle_x - widgets->circle_width/2,
+ widgets->circle_y - widgets->circle_width/2,
+ widgets->circle_width, widgets->circle_width, 0, 360*64 );
+
+ widgets->circle_onscreen = TRUE;
+ } else
+ widgets->circle_onscreen = FALSE;
+ }
+
+ /* see if onscreen */
+ /* okay */
+ vik_viewport_sync ( widgets->vvp );