[gcs] select an aircraft directly with a click on the map

This commit is contained in:
Gautier Hattenberger
2014-10-04 17:12:43 +02:00
parent e2181a69d7
commit 8c8fcb68d4
3 changed files with 28 additions and 2 deletions
+2 -1
View File
@@ -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
+23 -1
View File
@@ -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))
+3
View File
@@ -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