mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
new interaction for waypoints
This commit is contained in:
@@ -104,12 +104,8 @@ let resize_track = fun ac track ->
|
||||
None -> ()
|
||||
| Some s -> track#resize (int_of_string s)
|
||||
|
||||
let commit_changes = fun ac ->
|
||||
let a = Hashtbl.find live_aircrafts ac in
|
||||
List.iter
|
||||
(fun w ->
|
||||
let (i, w) = a.fp_group#index w in
|
||||
if w#moved then
|
||||
|
||||
let send_move_waypoint_msg = fun ac i w ->
|
||||
let wgs84 = w#pos in
|
||||
let vs = ["ac_id", Pprz.String ac;
|
||||
"wp_id", Pprz.Int i;
|
||||
@@ -117,7 +113,15 @@ let commit_changes = fun ac ->
|
||||
"long", Pprz.Float ((Rad>>Deg)wgs84.posn_long);
|
||||
"alt", Pprz.Float w#alt
|
||||
] in
|
||||
Ground_Pprz.message_send "map2d" "MOVE_WAYPOINT" vs)
|
||||
Ground_Pprz.message_send "map2d" "MOVE_WAYPOINT" vs
|
||||
|
||||
let commit_changes = fun ac ->
|
||||
let a = Hashtbl.find live_aircrafts ac in
|
||||
List.iter
|
||||
(fun w ->
|
||||
let (i, w) = a.fp_group#index w in
|
||||
if w#moved then
|
||||
send_move_waypoint_msg ac i w)
|
||||
a.fp_group#waypoints
|
||||
|
||||
let center = fun geomap track () ->
|
||||
@@ -308,6 +312,13 @@ let create_ac = fun (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id:strin
|
||||
jump_to_block ac_id id);
|
||||
ignore (reset_wp_menu#connect#activate (reset_waypoints fp));
|
||||
|
||||
(** Monitor waypoints changes *)
|
||||
List.iter
|
||||
(fun w ->
|
||||
let (i, w) = fp#index w in
|
||||
w#set_commit_callback (fun () -> send_move_waypoint_msg ac_id i w))
|
||||
fp#waypoints;
|
||||
|
||||
(** Add the short cut buttons in the strip *)
|
||||
List.iter (fun b ->
|
||||
try
|
||||
|
||||
@@ -397,7 +397,7 @@ class basic_widget = fun ?(height=800) ?width ?(projection = Mercator) ?georef (
|
||||
let current_point = LL.utm_of LL.WGS84 (self#of_world (xw, yw)) in
|
||||
let (east, north) = LL.utm_sub current_point starting_point in
|
||||
region_rectangle#set [`X2 xw; `Y2 yw];
|
||||
self#display_group (sprintf "[%.1fkm %.1fkm]" (east/.1000.) (north/.1000.))
|
||||
self#display_group (sprintf "[%.0fm %.0fm]" east north)
|
||||
| Polygon ps ->
|
||||
let points = convex ((xw,yw)::ps) in
|
||||
drawing <- Polygon points;
|
||||
|
||||
@@ -73,11 +73,13 @@ class waypoint = fun (wpts_group:group) (name :string) ?(alt=0.) wgs84 ->
|
||||
val mutable alt = alt
|
||||
val mutable moved = None
|
||||
val mutable deleted = false
|
||||
val mutable commit_cb = None
|
||||
initializer
|
||||
item#affine_absolute rotation_45;
|
||||
self#move xw yw
|
||||
method connect = fun (cb:unit -> unit) ->
|
||||
Hashtbl.add callbacks cb ()
|
||||
method set_commit_callback = fun (cb:unit -> unit) -> commit_cb <- Some cb
|
||||
method name = name
|
||||
method set_name n =
|
||||
if n <> name then begin
|
||||
@@ -90,7 +92,7 @@ class waypoint = fun (wpts_group:group) (name :string) ?(alt=0.) wgs84 ->
|
||||
method move dx dy =
|
||||
wpt_group#move dx dy
|
||||
method edit =
|
||||
let dialog = GWindow.window ~border_width:10 ~title:"Waypoint Edit" () in
|
||||
let dialog = GWindow.window ~position:`MOUSE ~border_width:10 ~title:"Waypoint Edit" () in
|
||||
let dvbx = GPack.box `VERTICAL ~packing:dialog#add () in
|
||||
|
||||
let wgs84 = self#pos in
|
||||
@@ -114,12 +116,20 @@ class waypoint = fun (wpts_group:group) (name :string) ?(alt=0.) wgs84 ->
|
||||
updated ();
|
||||
if wpts_group#show_moved then
|
||||
moved <- anim moved;
|
||||
begin
|
||||
match commit_cb with
|
||||
Some cb -> cb ()
|
||||
| None -> ()
|
||||
end;
|
||||
dialog#destroy ()
|
||||
in
|
||||
let dhbx = GPack.box `HORIZONTAL ~packing: dvbx#add () in
|
||||
|
||||
let cancel = GButton.button ~stock:`CANCEL ~packing: dhbx#add () in
|
||||
ignore(cancel#connect#clicked ~callback:dialog#destroy);
|
||||
let destroy = fun () ->
|
||||
self#reset_moved ();
|
||||
dialog#destroy () in
|
||||
ignore(cancel#connect#clicked ~callback:destroy);
|
||||
|
||||
if editable then begin
|
||||
let delete = GButton.button ~stock:`DELETE ~packing: dhbx#add () in
|
||||
@@ -173,7 +183,6 @@ class waypoint = fun (wpts_group:group) (name :string) ?(alt=0.) wgs84 ->
|
||||
| `BUTTON_RELEASE ev ->
|
||||
if GdkEvent.Button.button ev = 1 then begin
|
||||
item#ungrab (GdkEvent.Button.time ev);
|
||||
if not motion then
|
||||
self#edit
|
||||
end
|
||||
| _ -> ()
|
||||
|
||||
@@ -60,6 +60,7 @@ class waypoint :
|
||||
method reset_moved : unit -> unit
|
||||
method deleted : bool
|
||||
method connect : (unit -> unit) -> unit
|
||||
method set_commit_callback : (unit -> unit) -> unit
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user