diff --git a/conf/conf.xml b/conf/conf.xml index 0001fca954..d85f89f8a9 100644 --- a/conf/conf.xml +++ b/conf/conf.xml @@ -28,7 +28,7 @@ ac_id="1" airframe="airframes/twinstar1.xml" radio="radios/cockpitMM.xml" - flight_plan="flight_plans/muret_for.xml" + flight_plan="flight_plans/muret_mini.xml" /> - + @@ -97,9 +97,9 @@ - + - + diff --git a/conf/flight_plans/example.xml b/conf/flight_plans/example.xml new file mode 100644 index 0000000000..e558d3ec55 --- /dev/null +++ b/conf/flight_plans/example.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/flight_plans/mav05.xml b/conf/flight_plans/mav05.xml new file mode 100644 index 0000000000..2ee415d035 --- /dev/null +++ b/conf/flight_plans/mav05.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/flight_plans/muret_cam.xml b/conf/flight_plans/muret_cam.xml index 760a891977..7d3fd8ffbf 100644 --- a/conf/flight_plans/muret_cam.xml +++ b/conf/flight_plans/muret_cam.xml @@ -1,6 +1,6 @@ - + diff --git a/conf/flight_plans/muret_mini.xml b/conf/flight_plans/muret_mini.xml index 5efc87527d..200ea54088 100644 --- a/conf/flight_plans/muret_mini.xml +++ b/conf/flight_plans/muret_mini.xml @@ -17,6 +17,11 @@ + + + + + diff --git a/sw/airborne/autopilot/nav.c b/sw/airborne/autopilot/nav.c index 3d49dbacfe..83047ab338 100644 --- a/sw/airborne/autopilot/nav.c +++ b/sw/airborne/autopilot/nav.c @@ -252,12 +252,6 @@ static void route_to(uint8_t _last_wp, uint8_t wp) { /** carrot is computed in approaching() */ alpha += Max(carrot / leg, 0.); alpha = Min(1., alpha); - in_segment = TRUE; - segment_x_1 = last_wp_x; - segment_y_1 = last_wp_y; - segment_x_2 = waypoints[wp].x; - segment_y_2 = waypoints[wp].y; - in_segment = TRUE; segment_x_1 = last_wp_x; segment_y_1 = last_wp_y; diff --git a/sw/ground_segment/cockpit/map2d.ml b/sw/ground_segment/cockpit/map2d.ml index e8a3258cab..88105bcc76 100644 --- a/sw/ground_segment/cockpit/map2d.ml +++ b/sw/ground_segment/cockpit/map2d.ml @@ -107,6 +107,7 @@ let load_mission = fun color geomap url -> and lon0 = float_attr xml "lon0" in let utm0 = utm_of WGS84 {posn_lat = (Deg>>Rad)lat0; posn_long = (Deg>>Rad)lon0 } in let waypoints = ExtXml.child xml "waypoints" in + let max_dist_from_home = float_attr xml "MAX_DIST_FROM_HOME" in let utm_ref = match !map_ref with @@ -125,8 +126,10 @@ let load_mission = fun color geomap url -> (fun wp -> let en = en_of_xy (float_attr wp "x") (float_attr wp "y") in let alt = try Some (float_attr wp "alt") with _ -> None in - ignore (MapWaypoints.waypoint fp ~name:(ExtXml.attrib wp "name") ?alt en) - ) + ignore (MapWaypoints.waypoint fp ~name:(ExtXml.attrib wp "name") ?alt en); + if ExtXml.attrib wp "name" = "HOME" then + ignore (geomap#circle ~color en max_dist_from_home) + ) (Xml.children waypoints); fp @@ -183,7 +186,8 @@ let circle_status_msg = fun track utm_x utm_y radius -> track#draw_circle en radius let ap_status_msg = fun track horizontal_mode -> - track#update_ap_status horizontal_mode + () + let new_color = let colors = ref ["red"; "blue"; "green"] in @@ -233,7 +237,8 @@ let one_new_ac = fun (geomap:MapCanvas.widget) ac -> let track = new MapTrack.track ~name:ac ~color:color geomap in ignore (ac_menu_fact#add_item "Clear Track" ~callback:(fun () -> track#clear)); ignore (ac_menu_fact#add_item "Resize Track" ~callback:(fun () -> resize_track ac track)); - ignore (ac_menu_fact#add_item "Switch On-Off Cam Display" ~callback:(fun () -> track#switch_cam_state)); + let cam = ac_menu_fact#add_check_item "Cam Display" ~active:false in + ignore (cam#connect#toggled (fun () -> track#set_cam_state cam#active)); Hashtbl.add live_aircrafts ac { track = track; color = color; fp_group = None } end @@ -270,7 +275,7 @@ let listen_flight_params = fun () -> try let ac = Hashtbl.find live_aircrafts ac_id in let a = fun s -> Pprz.float_assoc s vs in - if (ac.track)#cam_state_on then cam_pos_msg ac.track (a "cam_east") (a "cam_north") (a "target_east") (a "target_north") + cam_pos_msg ac.track (a "cam_east") (a "cam_north") (a "target_east") (a "target_north") with Not_found -> () in ignore (Ground_Pprz.message_bind "CAM_STATUS" get_cam_status); @@ -279,7 +284,7 @@ let listen_flight_params = fun () -> try let ac = Hashtbl.find live_aircrafts ac_id in let a = fun s -> Pprz.float_assoc s vs in - circle_status_msg ac.track (a "circle_east") (a "circle_north") (int_of_string (Pprz.string_assoc "radius" vs)) + circle_status_msg ac.track (a "circle_east") (a "circle_north") (float_of_string (Pprz.string_assoc "radius" vs)) with Not_found -> () in ignore (Ground_Pprz.message_bind "CIRCLE_STATUS" get_circle_status); diff --git a/sw/ground_segment/tmtc/messages.ml b/sw/ground_segment/tmtc/messages.ml index 47a183d0ae..b954cc5e28 100644 --- a/sw/ground_segment/tmtc/messages.ml +++ b/sw/ground_segment/tmtc/messages.ml @@ -3,7 +3,7 @@ * * Multi aircrafts receiver, logger and broadcaster * - * Copyright (C) 2004 CENA/ENAC, Pascal Brisset, Antoine Drouin + * Copyright (C) 2005 CENA/ENAC, Pascal Brisset, Antoine Drouin * * This file is part of paparazzi. * @@ -70,88 +70,105 @@ let _ = let notebook = GPack.notebook ~packing:window#add ~tab_pos:`TOP () in -let one_page = fun (notebook:GPack.notebook) bind m -> - let id = (Xml.attrib m "name") in - let h = GPack.hbox () in - let v = GPack.vbox ~width:200 () in - let l = GMisc.label ~text:id ~packing:h#add () in - let eb = GBin.event_box ~packing:h#pack () in - let time = GMisc.label ~width:40 ~packing:eb#add () in - eb#coerce#misc#modify_bg [`SELECTED, `NAME "green"]; - notebook#append_page ~tab_label:h#coerce v#coerce; + let one_page = fun (notebook:GPack.notebook) bind m -> + let id = (Xml.attrib m "name") in + let h = GPack.hbox () in + let v = GPack.vbox ~width:200 () in + let l = GMisc.label ~text:id ~packing:h#add () in + let eb = GBin.event_box ~packing:h#pack () in + let time = GMisc.label ~width:40 ~packing:eb#add () in + eb#coerce#misc#modify_bg [`SELECTED, `NAME "green"]; + notebook#append_page ~tab_label:h#coerce v#coerce; let page_num = notebook#page_num v#coerce in - let fields = - List.fold_left - (fun rest f -> + let fields = + List.fold_left + (fun rest f -> + try + let unit = try "("^Xml.attrib f "unit"^")" with _ -> "" in + let name = Printf.sprintf "%s %s %s: " (ExtXml.attrib f "type") (Xml.attrib f "name") unit in + let h = GPack.hbox ~packing:v#pack () in + let _ = GMisc.label ~text:name ~packing:h#pack () in + let l = GMisc.label ~text:"XXXX" ~packing:h#pack () in + let update = fun (a, x) -> + if notebook#current_page = page_num then + let fx = Pprz.string_of_value x in + if l#label <> fx then l#set_text fx in + update::rest + with + _ -> + fprintf stderr "Warning: Ignoring '%s'\n%!" (Xml.to_string f); + rest + ) + [] + (Xml.children m) + in + let n = List.length fields in + let last_update = ref (Unix.gettimeofday ()) in + let time_since_last = ref 0 in + let update_time = fun () -> + incr time_since_last; + time#set_text (sprintf "%2d" !time_since_last); true in + ignore (GMain.Timeout.add 1000 update_time); + let display = fun sender values -> + time_since_last := 0; + let t = Unix.gettimeofday () in + if t > !last_update +. update_delay then begin + last_update := t; try - let unit = try "("^Xml.attrib f "unit"^")" with _ -> "" in - let name = Printf.sprintf "%s %s %s: " (ExtXml.attrib f "type") (Xml.attrib f "name") unit in - let h = GPack.hbox ~packing:v#pack () in - let _ = GMisc.label ~text:name ~packing:h#pack () in - let l = GMisc.label ~text:"XXXX" ~packing:h#pack () in - let update = fun (a, x) -> - if notebook#current_page = page_num then - let fx = Pprz.string_of_value x in - if l#label <> fx then l#set_text fx in - update::rest + List.iter2 (fun f x -> f x) fields (List.rev values); + + eb#coerce#misc#set_state `SELECTED; + ignore (GMain.Timeout.add led_delay (fun () -> eb#coerce#misc#set_state `NORMAL; false)) with - _ -> - fprintf stderr "Warning: Ignoring '%s'\n%!" (Xml.to_string f); - rest - ) - [] - (Xml.children m) - in - let n = List.length fields in - let last_update = ref (Unix.gettimeofday ()) in - let time_since_last = ref 0 in - let update_time = fun () -> - incr time_since_last; - time#set_text (sprintf "%2d" !time_since_last); true in - ignore (GMain.Timeout.add 1000 update_time); - let display = fun sender values -> - time_since_last := 0; - let t = Unix.gettimeofday () in - if t > !last_update +. update_delay then begin - last_update := t; - try - List.iter2 (fun f x -> f x) fields (List.rev values); - - eb#coerce#misc#set_state `SELECTED; - ignore (GMain.Timeout.add led_delay (fun () -> eb#coerce#misc#set_state `NORMAL; false)) - with - Invalid_argument "List.iter2" -> - Printf.fprintf stderr "%s: expected %d, got %d\n" id n (List.length values); flush stderr - end - in - ignore (bind id display); - (id, fields) in + Invalid_argument "List.iter2" -> + Printf.fprintf stderr "%s: expected %d, got %d\n" id n (List.length values); flush stderr + end + in + bind id display in let xml_classes = let class_of = fun n -> List.find (fun x -> ExtXml.attrib x "name" = n) (Xml.children xml) in List.map (fun x -> match Str.split (Str.regexp ":") x with - [cl; s] -> (x, class_of cl, Some s) + [cl; s] -> (cl, class_of cl, Some s) | [cl] -> (x, class_of cl, None) | _ -> failwith (sprintf "Wrong class '%s', class[:sender] expected" x)) !classes in - List.iter - (fun (ident, xml_class, sender) -> - let name = (Xml.attrib xml_class "name") in - let messages = Xml.children xml_class in - let class_notebook = GPack.notebook ~tab_pos:`LEFT () in - let label = GMisc.label ~text:ident () in - notebook#append_page ~tab_label:label#coerce class_notebook#coerce; - let module P = Pprz.Protocol (struct let name = name end) in - let bind = match sender with - None -> fun m cb -> P.message_bind m cb - | Some sender -> fun m cb -> P.message_bind ~sender m cb in - let pages = List.map (fun m -> one_page class_notebook bind m) messages in - ()) - xml_classes; - + let rec one_class = fun (ident, xml_class, sender) -> + let name = (Xml.attrib xml_class "name") in + let messages = Xml.children xml_class in + let module P = Pprz.Protocol (struct let name = name end) in + let senders = Hashtbl.create 5 in + match sender with + | Some "*" -> + (* Waiting for a new sender in this class *) + let get_one = fun sender vs -> + if not (Hashtbl.mem senders sender) then begin + Hashtbl.add senders sender (); + one_class (ident, xml_class, Some sender) + end in + List.iter + (fun m -> ignore (P.message_bind (Xml.attrib m "name") get_one)) + messages + | _ -> + let class_notebook = GPack.notebook ~tab_pos:`LEFT () in + let l = match sender with None -> "" | Some s -> ":"^s in + let label = GMisc.label ~text:(ident^l) () in +(*** let label = GButton.button ~label:(ident^l) () in ***) + notebook#append_page ~tab_label:label#coerce class_notebook#coerce; + let bind = match sender with + None -> fun m cb -> P.message_bind m cb + | Some sender -> fun m cb -> P.message_bind ~sender m cb in + let bindings = + (** Forall messages in the class *) + List.map (fun m -> one_page class_notebook bind m) messages in +(*** label#connect#clicked ~callback:(fun () -> prerr_endline "clicked"); ***) + () in + + List.iter one_class xml_classes; + window#show (); let loop = Glib.Main.create true in while Glib.Main.is_running loop do ignore (Glib.Main.iteration true) done diff --git a/sw/ground_segment/tmtc/receive.ml b/sw/ground_segment/tmtc/receive.ml index 208ccf6575..f6b24cd2c4 100644 --- a/sw/ground_segment/tmtc/receive.ml +++ b/sw/ground_segment/tmtc/receive.ml @@ -511,7 +511,7 @@ let send_config = fun _asker args -> try let conf = ExtXml.child conf_xml "aircraft" ~select:(fun x -> ExtXml.attrib x "ac_id" = ac_id) in let ac_name = ExtXml.attrib conf "name" in - let prefix = fun s -> sprintf "http://%s:8889/%s" "localhost" s in + let prefix = fun s -> sprintf "http://%s:8889/%s" (Unix.gethostname ()) s in (** Expanded flight plan has been compiled in var/ *) let fp = prefix ("var" // ac_name // "flight_plan.xml") and af = prefix ("conf" // ExtXml.attrib conf "airframe") diff --git a/sw/lib/ocaml/mapCanvas.ml b/sw/lib/ocaml/mapCanvas.ml index 97b1f2a68d..9bf0a4330c 100644 --- a/sw/lib/ocaml/mapCanvas.ml +++ b/sw/lib/ocaml/mapCanvas.ml @@ -37,7 +37,9 @@ class widget = fun ?(height=800) ?width ?wgs84_of_en () -> let srtm = menu_fact#add_check_item "SRTM" ~active:false in object (self) + initializer canvas#coerce#misc#modify_bg [`NORMAL, `NAME "black"] + initializer ignore (menu_fact#add_check_item "Background" ~active:true ~callback:self#switch_background) initializer ignore (menu_fact#add_item "Goto" ~callback:self#goto) initializer ignore (canvas#event#connect#motion_notify (self#mouse_motion)); initializer ignore (canvas#event#connect#button_press (self#button_press)); @@ -57,6 +59,9 @@ class widget = fun ?(height=800) ?width ?wgs84_of_en () -> val mutable rectangle = None val mutable world_unit = 1. val mutable wgs84_of_en = wgs84_of_en + val mutable background = GnoCanvas.pixbuf canvas#root + + method switch_background = fun x -> if x then background#show () else background#hide (); method set_wgs84_of_en = fun x -> wgs84_of_en <- Some x @@ -118,14 +123,14 @@ class widget = fun ?(height=800) ?width ?wgs84_of_en () -> method display_map = fun ?(scale = 1.) en image -> - let p = GnoCanvas.pixbuf ~pixbuf:image ~props:[`ANCHOR `NW] self#root in - p#lower_to_bottom (); + background <- GnoCanvas.pixbuf ~pixbuf:image ~props:[`ANCHOR `NW] self#root; + background#lower_to_bottom (); let wx, wy = self#world_of_en en in - p#move wx wy; - let a = p#i2w_affine in + background#move wx wy; + let a = background#i2w_affine in a.(0) <- scale; a.(3) <- scale; - p#affine_absolute a; - p + background#affine_absolute a; + background method zoom = fun value -> canvas#set_pixels_per_unit value; @@ -195,6 +200,8 @@ class widget = fun ?(height=800) ?width ?wgs84_of_en () -> | k when k = GdkKeysyms._Down -> canvas#scroll_to x (y+pan_step) ; true | k when k = GdkKeysyms._Left -> canvas#scroll_to (x-pan_step) y ; true | k when k = GdkKeysyms._Right -> canvas#scroll_to (x+pan_step) y ; true + | k when k = GdkKeysyms._Page_Up -> adj#set_value (adj#value+.adj#step_increment) ; true + | k when k = GdkKeysyms._Page_Down -> adj#set_value (adj#value-.adj#step_increment) ; true | _ -> false method any_event = fun ev -> @@ -216,5 +223,12 @@ class widget = fun ?(height=800) ?width ?wgs84_of_en () -> let l = GnoCanvas.line ?fill_color ~props:[`WIDTH_PIXELS width] ~points:[|x1;y1;x2;y2|] group in l#show (); l + + method circle = fun ?(group = canvas#root) ?(width=1) ?fill_color ?(color="black") en rad -> + let (x, y) = self#world_of_en en in + let rad = rad /. world_unit in + let l = GnoCanvas.ellipse ?fill_color ~props:[`WIDTH_PIXELS width; `OUTLINE_COLOR color] ~x1:(x-.rad) ~y1:(y -.rad) ~x2:(x +.rad) ~y2:(y+.rad) group in + l#show (); + l end diff --git a/sw/lib/ocaml/mapTrack.ml b/sw/lib/ocaml/mapTrack.ml index d36fe1b77c..321829ea5c 100644 --- a/sw/lib/ocaml/mapTrack.ml +++ b/sw/lib/ocaml/mapTrack.ml @@ -51,7 +51,7 @@ let cam_half_aperture = m_pi /. 4.0 let half_pi = m_pi /. 2.0 let sqrt_2_div_2 = sqrt 2.0 -class track = fun ?(name="coucou") ?(size = 50) ?(color="red") (geomap:MapCanvas.widget) -> +class track = fun ?(name="coucou") ?(size = 500) ?(color="red") (geomap:MapCanvas.widget) -> let group = GnoCanvas.group geomap#canvas#root in let empty = ({ G.east = 0.; north = 0. }, GnoCanvas.line group) in @@ -70,10 +70,8 @@ class track = fun ?(name="coucou") ?(size = 50) ?(color="red") (geomap:MapCanvas let cam = GnoCanvas.group group in (** rectangle representing the field covered by the cam *) - let ac_cam_cover = ref ( GnoCanvas.rect cam) in - let cam_targeted = GnoCanvas.group group in let _ac_cam_targeted = - ignore ( GnoCanvas.ellipse ~x1: (-. 2.5) ~y1: (-. 2.5) ~x2: 2.5 ~y2: 2.5 ~fill_color:color ~props:[`WIDTH_UNITS 1.; `OUTLINE_COLOR color; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] cam_targeted ) in + ignore ( GnoCanvas.ellipse ~x1: (-. 2.5) ~y1: (-. 2.5) ~x2: 2.5 ~y2: 2.5 ~fill_color:color ~props:[`WIDTH_UNITS 1.; `OUTLINE_COLOR color; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] cam) in let mission_target = GnoCanvas.group group in @@ -81,21 +79,11 @@ class track = fun ?(name="coucou") ?(size = 50) ?(color="red") (geomap:MapCanvas let ac_mission_target = ignore ( GnoCanvas.ellipse ~x1: (-5.) ~y1: (-5.) ~x2: 5. ~y2: 5. ~fill_color:"red" ~props:[`WIDTH_UNITS 1.; `OUTLINE_COLOR "red"; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] mission_target ) in - let circle_mode = GnoCanvas.group group in - -(** green circle: circle to be followed by the aircraft in circle mode *) - let circle_mode_icon = ref ( GnoCanvas.ellipse mission_target ) in - let segment_mode = GnoCanvas.group group in - -(** green segment: line to be followed by the aircraft between two waypoints *) - let segment_mode_icon = ref (GnoCanvas.line segment_mode) in - -(** data at map scale *) + (** data at map scale *) let max_cam_half_height = 10000.0 /. (geomap#get_world_unit ()) in let max_oblic_distance = 10000.0 /. (geomap#get_world_unit ()) in let min_distance = 10. /. (geomap#get_world_unit ()) in let min_height = 0.1 /. (geomap#get_world_unit ()) in - (***) let cpt = ref 0 in (***) object (self) val mutable segments = Array.create size empty @@ -106,10 +94,9 @@ class track = fun ?(name="coucou") ?(size = 50) ?(color="red") (geomap:MapCanvas val mutable last_height = 0.0 val mutable last_xw = 0.0 val mutable last_yw = 0.0 - val mutable cam_on = true - val mutable previous_cam_state_on = true - val mutable previous_horizontal_mode = "WAYPOINT" - val mutable current_horizontal_mode = "WAYPOINT" + val mutable cam_on = false + val mutable desired_track = ((GnoCanvas.ellipse group) :> GnoCanvas.base_item) + val mutable ac_cam_cover = GnoCanvas.rect cam method track = track method aircraft = aircraft method clear_one = fun i -> @@ -125,12 +112,7 @@ class track = fun ?(name="coucou") ?(size = 50) ?(color="red") (geomap:MapCanvas self#clear_one i done; top <- 0 - method switch_cam_state = - if cam_on then - (!ac_cam_cover)#destroy (); - previous_cam_state_on <- cam_on; - cam_on <- not cam_on - method cam_state_on = cam_on + method set_cam_state = fun b -> cam_on <- b method add_point = fun en -> self#clear_one top; begin @@ -153,47 +135,29 @@ class track = fun ?(name="coucou") ?(size = 50) ?(color="red") (geomap:MapCanvas ac_label#affine_absolute (affine_pos_and_angle geomap#zoom_adj#value xw yw 0.); method move_carrot = fun en -> let (xw,yw) = geomap#world_of_en en in - carrot#affine_absolute (affine_pos_and_angle geomap#zoom_adj#value xw yw 0.) - -(** updates the autopilot status *) - method update_ap_status = fun horizontal_mode -> - current_horizontal_mode <- horizontal_mode + carrot#affine_absolute (affine_pos_and_angle geomap#zoom_adj#value xw yw 0.); (** draws the circular path to be followed by the aircraft in circle mode *) method draw_circle = fun en radius -> - if ( current_horizontal_mode = "CIRCLE" || (***) current_horizontal_mode = "42" (***)) then - let fradius = (float_of_int radius) /. (geomap#get_world_unit ()) in - let (xw,yw) = geomap#world_of_en en in - begin - if previous_horizontal_mode ="CIRCLE" then (!circle_mode_icon)#destroy () - else - if previous_horizontal_mode ="SEGMENT" then (!segment_mode_icon)#destroy (); - circle_mode_icon := ( GnoCanvas.ellipse ~x1: ( -.fradius ) ~y1: (-. fradius) ~x2: (fradius ) ~y2: (fradius) ~props:[`WIDTH_UNITS 1.; `OUTLINE_COLOR "green"; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] circle_mode); - circle_mode#affine_absolute (affine_pos_and_angle geomap#zoom_adj#value xw yw 0.); - previous_horizontal_mode <- "CIRCLE"; - end + desired_track#destroy (); + desired_track <- ((geomap#circle ~color:"green" en radius) :> GnoCanvas.base_item) (** draws the linear path to be followed by the aircraft between two waypoints *) method draw_segment = fun en en2 -> - if ( current_horizontal_mode = "SEGMENT" || (***) current_horizontal_mode = "42" (***)) then - begin - if previous_horizontal_mode ="CIRCLE" then (!circle_mode_icon)#destroy () - else - if previous_horizontal_mode = "SEGMENT" then (!segment_mode_icon)#destroy (); - segment_mode_icon := geomap#segment ~group:segment_mode ~fill_color:"green" en en2; - previous_horizontal_mode <- "SEGMENT" - end + desired_track#destroy (); + desired_track <- ((geomap#segment ~fill_color:"green" en en2) :> GnoCanvas.base_item) (** moves the rectangle representing the field covered by the camera *) method move_cam = fun en mission_target_en -> - let (xw,yw) = geomap#world_of_en en in - let (mission_target_xw, mission_target_yw) = geomap#world_of_en mission_target_en in - + if not cam_on then + cam#hide () + else + let (xw,yw) = geomap#world_of_en en in + let (mission_target_xw, mission_target_yw) = geomap#world_of_en mission_target_en in + (** all data are at map scale *) - - begin - cpt := !cpt + 1; - if previous_cam_state_on then (!ac_cam_cover)#destroy (); + + begin let pt1 = { x2D = last_xw; y2D = last_yw} in let pt2 = { x2D = xw ; y2D = yw } in @@ -227,13 +191,13 @@ class track = fun ?(name="coucou") ?(size = 50) ?(color="red") (geomap:MapCanvas begin (*** Printf.printf "dist %.2f aoview %.2f oblic_distance %.2f cfh1 %.2f cfh2 %.2f cfhw %.2f last_xw %.2f last_yw %.2f cam_heading %.2f \n%!" (d *. (geomap#get_world_unit ()) ) angle_of_view (oblic_distance *. (geomap#get_world_unit ()) ) (cam_field_half_height_1 *. (geomap#get_world_unit ()) ) (cam_field_half_height_2 *. (geomap#get_world_unit ()) ) (cam_field_half_width *. (geomap#get_world_unit ()) ) last_xw last_yw cam_heading; ***) - ac_cam_cover := GnoCanvas.rect ~x1:(-. cam_field_half_width) ~y1:(-. cam_field_half_height_1) ~x2:(cam_field_half_width) ~y2:(cam_field_half_height_2) ~fill_color:"grey" ~props:[`WIDTH_PIXELS 1 ; `OUTLINE_COLOR color; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] cam; - previous_cam_state_on <- true + ac_cam_cover#destroy (); + ac_cam_cover <- GnoCanvas.rect ~x1:(-. cam_field_half_width) ~y1:(-. cam_field_half_height_1) ~x2:(cam_field_half_width) ~y2:(cam_field_half_height_2) ~fill_color:"grey" ~props:[`WIDTH_PIXELS 1 ; `OUTLINE_COLOR color; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] cam end end; cam#affine_absolute (affine_pos_and_angle 1.0 xw yw cam_heading); - cam_targeted#affine_absolute (affine_pos_and_angle geomap#zoom_adj#value xw yw 0.0); - mission_target#affine_absolute (affine_pos_and_angle geomap#zoom_adj#value mission_target_xw mission_target_yw 0.0) + mission_target#affine_absolute (affine_pos_and_angle geomap#zoom_adj#value mission_target_xw mission_target_yw 0.0); + cam#show () end; end diff --git a/sw/lib/ocaml/mapWaypoints.ml b/sw/lib/ocaml/mapWaypoints.ml index 1b91851936..444813c473 100644 --- a/sw/lib/ocaml/mapWaypoints.ml +++ b/sw/lib/ocaml/mapWaypoints.ml @@ -50,7 +50,7 @@ class waypoint = fun (group:group) (name :string) ?(alt=0.) en -> GnoCanvas.polygon group#group ~points:losange ~props:[`FILL_COLOR color; `OUTLINE_COLOR "midnightblue" ; `WIDTH_UNITS 1.; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] - val label = GnoCanvas.text group#group ~props:[`TEXT name; `X s; `Y 0.; `ANCHOR `SW] + val label = GnoCanvas.text group#group ~props:[`TEXT name; `X s; `Y 0.; `ANCHOR `SW; `FILL_COLOR "green"] val mutable name = name val mutable alt = alt initializer self#move xw yw