diff --git a/sw/ground_segment/cockpit/gcs.ml b/sw/ground_segment/cockpit/gcs.ml index caadac35d0..08bc053387 100644 --- a/sw/ground_segment/cockpit/gcs.ml +++ b/sw/ground_segment/cockpit/gcs.ml @@ -609,7 +609,7 @@ let save_layout = fun filename contents -> let listen_dropped_papgets = fun (geomap:G.widget) -> let dnd_targets = [ { Gtk.target = "STRING"; flags = []; info = 0 } ] in geomap#canvas#drag#dest_set dnd_targets ~actions:[`COPY]; - ignore (geomap#canvas#drag#connect#data_received ~callback:(Papgets.dnd_data_received geomap#still)) + ignore (geomap#canvas#drag#connect#data_received ~callback:(Papgets.dnd_data_received geomap#still geomap#zoom_adj)) @@ -716,7 +716,7 @@ let () = (** packing papgets *) let papgets = try find_widget_children "map2d" the_layout with Not_found -> [] in - List.iter (Papgets.create geomap#still) papgets; + List.iter (Papgets.create geomap#still geomap#zoom_adj) papgets; listen_dropped_papgets geomap; let save_layout = fun () -> diff --git a/sw/ground_segment/cockpit/papgets.ml b/sw/ground_segment/cockpit/papgets.ml index 7ab9945deb..2a520e274f 100644 --- a/sw/ground_segment/cockpit/papgets.ml +++ b/sw/ground_segment/cockpit/papgets.ml @@ -117,7 +117,7 @@ let ac_id_prop = fun config -> [PC.property "ac_id" (PC.get_property "ac_id" config)] with _ -> [] -let create = fun canvas_group papget -> +let create = fun canvas_group zoom_adj papget -> try let type_ = ExtXml.attrib papget "type" and display = ExtXml.attrib papget "display" @@ -203,7 +203,7 @@ let create = fun canvas_group papget -> | _ -> failwith (sprintf "Unexpected papget display: %s" display) in let properties = locked papget in - let p = new Papget.canvas_video_plugin_item properties renderer in + let p = new Papget.canvas_video_plugin_item properties renderer zoom_adj in let p = (p :> Papget.item) in register_papget p @@ -220,7 +220,7 @@ let parse_message_dnd = match Str.split sep s with [s; c; m; f;scale] -> (s, c, m, f,scale) | _ -> raise (Parse_message_dnd (Printf.sprintf "parse_dnd: %s" s)) -let dnd_data_received = fun canvas_group _context ~x ~y data ~info ~time -> +let dnd_data_received = fun canvas_group zoom_adj _context ~x ~y data ~info ~time -> try (* With the format sent by Messages *) let (sender, _class_name, msg_name, field_name,scale) = parse_message_dnd data#data in let attrs = @@ -232,7 +232,7 @@ let dnd_data_received = fun canvas_group _context ~x ~y data ~info ~time -> Papget_common.property "ac_id" sender; Papget_common.property "scale" scale ] in let papget_xml = Xml.Element ("papget", attrs, props) in - create canvas_group papget_xml + create canvas_group zoom_adj papget_xml with Parse_message_dnd _ -> try (* XML spec *) @@ -240,6 +240,6 @@ let dnd_data_received = fun canvas_group _context ~x ~y data ~info ~time -> (* Add x and y attributes *) let attrs = Xml.attribs xml @ ["x", string_of_int x; "y", string_of_int y] in let papget_xml = Xml.Element (Xml.tag xml,attrs,Xml.children xml) in - create canvas_group papget_xml + create canvas_group zoom_adj papget_xml with exc -> prerr_endline (Printexc.to_string exc) diff --git a/sw/ground_segment/cockpit/papgets.mli b/sw/ground_segment/cockpit/papgets.mli index 9f64c18590..4640181b52 100644 --- a/sw/ground_segment/cockpit/papgets.mli +++ b/sw/ground_segment/cockpit/papgets.mli @@ -24,7 +24,7 @@ val dump_store : bool -> Xml.xml list val has_papgets : unit -> bool -val create : #GnoCanvas.group -> Xml.xml -> unit +val create : #GnoCanvas.group -> GData.adjustment -> Xml.xml -> unit val dnd_data_received : - #GnoCanvas.group -> + #GnoCanvas.group -> GData.adjustment -> 'a -> x:int -> y:int -> < data : string; .. > -> info:'b -> time:'c -> unit diff --git a/sw/lib/ocaml/papget.ml b/sw/lib/ocaml/papget.ml index 8bb305485e..0a038a4bb0 100644 --- a/sw/lib/ocaml/papget.ml +++ b/sw/lib/ocaml/papget.ml @@ -405,9 +405,11 @@ end (****************************************************************************) -class canvas_video_plugin_item = fun properties (canvas_renderer:PR.t) -> -object +class canvas_video_plugin_item = fun properties (canvas_renderer:PR.t) (adj:GData.adjustment) -> +object (self) inherit canvas_item ~config:properties canvas_renderer as item + method update_zoom = fun zoom -> + item#update zoom method config = fun () -> let props = renderer#config () in let (x, y) = item#xy in @@ -416,5 +418,6 @@ object "display", String.lowercase item#renderer#tag; "x", sprintf "%.0f" x; "y", sprintf "%.0f" y ] in Xml.Element ("papget", attrs, properties@props) + initializer ignore(adj#connect#value_changed (fun () -> self#update_zoom (string_of_float adj#value))) end diff --git a/sw/lib/ocaml/papget.mli b/sw/lib/ocaml/papget.mli index 1ea06e8c1a..7ea1192c67 100644 --- a/sw/lib/ocaml/papget.mli +++ b/sw/lib/ocaml/papget.mli @@ -105,9 +105,11 @@ class canvas_variable_setting_item : class canvas_video_plugin_item : Xml.xml list -> Papget_renderer.t -> + GData.adjustment -> object inherit canvas_item_type method config : unit -> Xml.xml + method update_zoom : string -> unit (* method connect : unit -> unit @@ -115,7 +117,6 @@ class canvas_video_plugin_item : method edit : unit -> unit method event : GnoCanvas.item_event -> bool method renderer : Papget_renderer.t - method update : string -> unit method xy : float * float *) end diff --git a/sw/lib/ocaml/papget_renderer.ml b/sw/lib/ocaml/papget_renderer.ml index 6bc949e25f..876a16cea5 100644 --- a/sw/lib/ocaml/papget_renderer.ml +++ b/sw/lib/ocaml/papget_renderer.ml @@ -325,13 +325,15 @@ class canvas_mplayer = fun ?(config=[]) canvas_group x y -> and height = float_of_string (PC.get_prop "height" config "240.") in let socket = GWindow.socket () in let group = GnoCanvas.group ~x ~y canvas_group in - let _item = GnoCanvas.widget ~width ~height ~widget:socket group in + let item = GnoCanvas.widget ~width ~height ~widget:socket group in object method tag = "Mplayer" method item = (group :> movable_item) method edit = fun (pack:GObj.widget -> unit) -> () - method update = fun (value:string) -> () + method update = fun (value:string) -> + let zoom = try float_of_string value with _ -> 1. in + item#set [`WIDTH (width /. zoom); `HEIGHT (height /. zoom)] method config = fun () -> [ PC.property "video_feed" video_feed; PC.float_property "width" width; @@ -351,13 +353,15 @@ class canvas_plugin = fun ?(config=[]) canvas_group x y -> and height = float_of_string (PC.get_prop "height" config "240.") in let socket = GWindow.socket () in let group = GnoCanvas.group ~x ~y canvas_group in - let _item = GnoCanvas.widget ~width ~height ~widget:socket group in + let item = GnoCanvas.widget ~width ~height ~widget:socket group in object method tag = "Plugin" method item = (group :> movable_item) method edit = fun (pack:GObj.widget -> unit) -> () - method update = fun (value:string) -> () + method update = fun (value:string) -> + let zoom = try float_of_string value with _ -> 1. in + item#set [`WIDTH (width /. zoom); `HEIGHT (height /. zoom) ] method config = fun () -> [ PC.property "command" command; PC.float_property "width" width;