diff --git a/sw/ground_segment/cockpit/live.ml b/sw/ground_segment/cockpit/live.ml index 8ae93142d9..814027b7ef 100644 --- a/sw/ground_segment/cockpit/live.ml +++ b/sw/ground_segment/cockpit/live.ml @@ -443,7 +443,8 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id ignore (fp_show#connect#toggled (fun () -> show_mission ac_id fp_show#active)); let (icon, size) = get_icon_and_track_size af_xml in - let track = new MapTrack.track ~size ~icon ~name ~color:color geomap in + let track = new MapTrack.track ~size ~icon ~name ~color:color ac_id geomap in + track#set_event_cb (select_ac acs_notebook); geomap#register_to_fit (track:>MapCanvas.geographic); let center_ac = center geomap track in diff --git a/sw/lib/ocaml/mapTrack.ml b/sw/lib/ocaml/mapTrack.ml index 1e5675f7a3..61a9121ba7 100644 --- a/sw/lib/ocaml/mapTrack.ml +++ b/sw/lib/ocaml/mapTrack.ml @@ -53,7 +53,7 @@ type desired = | DesiredCircle of LL.geographic*float*GnoCanvas.ellipse | DesiredSegment of LL.geographic*LL.geographic*GnoCanvas.line -class track = fun ?(name="Noname") ?(icon="fixedwing") ?(size = 500) ?(color="red") (geomap:MapCanvas.widget) -> +class track = fun ?(name="Noname") ?(icon="fixedwing") ?(size = 500) ?(color="red") (ac_id:string) (geomap:MapCanvas.widget) -> let group = GnoCanvas.group geomap#canvas#root in let empty = ({LL.posn_lat=0.; LL.posn_long=0.}, GnoCanvas.line group) in let v_empty = ({LL.posn_lat=0.; LL.posn_long=0.}, 0.0) in @@ -118,6 +118,7 @@ object (self) val mutable desired_track = NoDesired val zone = GnoCanvas.rect group val mutable ac_cam_cover = GnoCanvas.rect ~fill_color:"grey" ~props:[`WIDTH_PIXELS 1 ; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] cam + val mutable event_cb = None method color = color method set_color c = color <- c method track = track @@ -329,6 +330,27 @@ object (self) method size = Array.length segments + method event (ev : GnoCanvas.item_event) = + begin + match ev with + | `BUTTON_PRESS ev -> + begin + match GdkEvent.Button.button ev with + | 1 -> + begin + match event_cb with + | Some cb -> cb ac_id + | None -> () + end + | _ -> () + end + | _ -> () + end; + true + initializer ignore(aircraft#connect#event self#event) + + method set_event_cb = fun (cb: string -> unit) -> event_cb <- Some cb + initializer ignore(geomap#zoom_adj#connect#value_changed (fun () -> self#zoom geomap#zoom_adj#value)) diff --git a/sw/lib/ocaml/mapTrack.mli b/sw/lib/ocaml/mapTrack.mli index 807f2f31ed..7ced8b47b9 100644 --- a/sw/lib/ocaml/mapTrack.mli +++ b/sw/lib/ocaml/mapTrack.mli @@ -27,6 +27,7 @@ class track : ?icon:string -> ?size:int -> ?color:string -> + string -> MapCanvas.widget -> object method add_point : Latlong.geographic -> float -> unit @@ -64,4 +65,6 @@ class track : method v_incr : (Latlong.geographic * float) array -> unit method v_path : (Latlong.geographic * float) array method zoom : float -> unit + method event : GnoCanvas.item_event -> bool + method set_event_cb : (string -> unit) -> unit end