mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 20:38:27 +08:00
[gcs] remove intruders when they no longer exist
This commit is contained in:
@@ -30,15 +30,14 @@ type intruder = {
|
|||||||
let intruders = Hashtbl.create 1
|
let intruders = Hashtbl.create 1
|
||||||
|
|
||||||
let new_intruder = fun id name time geomap ->
|
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
|
let intruder = { intruder_track = track; last_update = time } in
|
||||||
Hashtbl.add intruders id intruder
|
Hashtbl.add intruders id intruder
|
||||||
|
|
||||||
let remove_intruder = fun id ->
|
let remove_intruder = fun id ->
|
||||||
try
|
try
|
||||||
let intruder = Hashtbl.find intruders id in
|
let intruder = Hashtbl.find intruders id in
|
||||||
intruder.intruder_track#clear ();
|
intruder.intruder_track#destroy ();
|
||||||
(* TODO delete something more ? mapTrack object ? *)
|
|
||||||
Hashtbl.remove intruders id
|
Hashtbl.remove intruders id
|
||||||
with _ -> () (* no intruder *)
|
with _ -> () (* no intruder *)
|
||||||
|
|
||||||
|
|||||||
@@ -168,9 +168,12 @@ let icon_home_template = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let icon_intruder_template = {
|
let icon_intruder_template = {
|
||||||
lines = [];
|
lines = [
|
||||||
|
[| 0.; 0.; 0.; -24. |];
|
||||||
|
[| 6.; -15.; 0.; -24.; -6.; -15.|]; (** Front Marker **)
|
||||||
|
];
|
||||||
ellipse = [
|
ellipse = [
|
||||||
[| -10.; -10.; 10.; 10.|];
|
[| -8.; -8.; 8.; 8.|];
|
||||||
];
|
];
|
||||||
width = 1
|
width = 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ type desired =
|
|||||||
| DesiredCircle of LL.geographic*float*GnoCanvas.ellipse
|
| DesiredCircle of LL.geographic*float*GnoCanvas.ellipse
|
||||||
| DesiredSegment of LL.geographic*LL.geographic*GnoCanvas.line
|
| 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 group = GnoCanvas.group geomap#canvas#root in
|
||||||
let empty = ({LL.posn_lat=0.; LL.posn_long=0.}, GnoCanvas.line group) 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
|
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 carrot = GnoCanvas.group group in
|
||||||
let _ac_carrot =
|
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
|
let cam = GnoCanvas.group group in
|
||||||
|
|
||||||
@@ -126,6 +129,7 @@ object (self)
|
|||||||
val zone = GnoCanvas.rect group
|
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 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 event_cb = None
|
||||||
|
val mutable destroyed = false
|
||||||
method color = color
|
method color = color
|
||||||
method set_color c = color <- c
|
method set_color c = color <- c
|
||||||
method track = track
|
method track = track
|
||||||
@@ -361,9 +365,13 @@ object (self)
|
|||||||
method set_event_cb = fun (cb: string -> unit) -> event_cb <- Some cb
|
method set_event_cb = fun (cb: string -> unit) -> event_cb <- Some cb
|
||||||
|
|
||||||
initializer
|
initializer
|
||||||
ignore(geomap#zoom_adj#connect#value_changed
|
(* could not properly disconnect adjustment signal, so only calling zoom method if group is still displayed *)
|
||||||
(fun () -> self#zoom geomap#zoom_adj#value))
|
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
|
initializer
|
||||||
Gc.finalise (fun self -> group#destroy ()) self
|
Gc.finalise (fun self -> self#destroy ()) self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class track :
|
|||||||
?icon:string ->
|
?icon:string ->
|
||||||
?size:int ->
|
?size:int ->
|
||||||
?color:string ->
|
?color:string ->
|
||||||
|
?show_carrot:bool ->
|
||||||
string ->
|
string ->
|
||||||
MapCanvas.widget ->
|
MapCanvas.widget ->
|
||||||
object
|
object
|
||||||
@@ -69,4 +70,5 @@ class track :
|
|||||||
method zoom : float -> unit
|
method zoom : float -> unit
|
||||||
method event : GnoCanvas.item_event -> bool
|
method event : GnoCanvas.item_event -> bool
|
||||||
method set_event_cb : (string -> unit) -> unit
|
method set_event_cb : (string -> unit) -> unit
|
||||||
|
method destroy : unit -> unit
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user