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