diff --git a/sw/ground_segment/cockpit/intruders.ml b/sw/ground_segment/cockpit/intruders.ml index 3b94a9e6b4..fe8ccd8ac7 100644 --- a/sw/ground_segment/cockpit/intruders.ml +++ b/sw/ground_segment/cockpit/intruders.ml @@ -30,15 +30,14 @@ type intruder = { let intruders = Hashtbl.create 1 let new_intruder = fun id name time geomap -> - let track = new MapTrack.track ~size:10 ~icon:"intruder" ~name id geomap in + let track = new MapTrack.track ~size:20 ~icon:"intruder" ~name ~show_carrot:false id geomap in let intruder = { intruder_track = track; last_update = time } in Hashtbl.add intruders id intruder let remove_intruder = fun id -> try let intruder = Hashtbl.find intruders id in - intruder.intruder_track#clear (); - (* TODO delete something more ? mapTrack object ? *) + intruder.intruder_track#destroy (); Hashtbl.remove intruders id with _ -> () (* no intruder *) diff --git a/sw/lib/ocaml/acIcon.ml b/sw/lib/ocaml/acIcon.ml index c6efd0fd63..d959924ac3 100644 --- a/sw/lib/ocaml/acIcon.ml +++ b/sw/lib/ocaml/acIcon.ml @@ -168,9 +168,12 @@ let icon_home_template = { } let icon_intruder_template = { - lines = []; + lines = [ + [| 0.; 0.; 0.; -24. |]; + [| 6.; -15.; 0.; -24.; -6.; -15.|]; (** Front Marker **) + ]; ellipse = [ - [| -10.; -10.; 10.; 10.|]; + [| -8.; -8.; 8.; 8.|]; ]; width = 1 } diff --git a/sw/lib/ocaml/mapTrack.ml b/sw/lib/ocaml/mapTrack.ml index 8e2a8173c2..4eacf9c52d 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") (ac_id:string) (geomap:MapCanvas.widget) -> +class track = fun ?(name="Noname") ?(icon="fixedwing") ?(size = 500) ?(color="red") ?(show_carrot=true) (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 @@ -78,7 +78,10 @@ class track = fun ?(name="Noname") ?(icon="fixedwing") ?(size = 500) ?(color="re let carrot = GnoCanvas.group group in let _ac_carrot = - ignore (GnoCanvas.polygon ~points:[|0.;0.;-5.;-10.;5.;-10.|] ~props:[`WIDTH_UNITS 1.;`FILL_COLOR "orange"; `OUTLINE_COLOR "orange"; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] carrot) in + if show_carrot then + ignore (GnoCanvas.polygon ~points:[|0.;0.;-5.;-10.;5.;-10.|] ~props:[`WIDTH_UNITS 1.;`FILL_COLOR "orange"; `OUTLINE_COLOR "orange"; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] carrot) + else () + in let cam = GnoCanvas.group group in @@ -126,6 +129,7 @@ object (self) 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 + val mutable destroyed = false method color = color method set_color c = color <- c method track = track @@ -361,9 +365,13 @@ object (self) 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)) + (* could not properly disconnect adjustment signal, so only calling zoom method if group is still displayed *) + ignore(geomap#zoom_adj#connect#value_changed (fun () -> if not destroyed then self#zoom geomap#zoom_adj#value)); + ignore(group#connect#destroy (fun () -> destroyed <- true)) + + (* destroy method *) + method destroy = fun () -> group#destroy () initializer - Gc.finalise (fun self -> group#destroy ()) self + Gc.finalise (fun self -> self#destroy ()) self end diff --git a/sw/lib/ocaml/mapTrack.mli b/sw/lib/ocaml/mapTrack.mli index d9fd4394bf..aed95ad31e 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 -> + ?show_carrot:bool -> string -> MapCanvas.widget -> object @@ -69,4 +70,5 @@ class track : method zoom : float -> unit method event : GnoCanvas.item_event -> bool method set_event_cb : (string -> unit) -> unit + method destroy : unit -> unit end