paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [4376] Fix bug in ruler papget saving


From: Pascal Brisset
Subject: [paparazzi-commits] [4376] Fix bug in ruler papget saving
Date: Wed, 16 Dec 2009 17:39:39 +0000

Revision: 4376
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4376
Author:   hecto
Date:     2009-12-16 17:39:39 +0000 (Wed, 16 Dec 2009)
Log Message:
-----------
 Fix bug in ruler papget saving

Modified Paths:
--------------
    paparazzi3/trunk/sw/lib/ocaml/papget_renderer.ml

Modified: paparazzi3/trunk/sw/lib/ocaml/papget_renderer.ml
===================================================================
--- paparazzi3/trunk/sw/lib/ocaml/papget_renderer.ml    2009-12-15 16:57:00 UTC 
(rev 4375)
+++ paparazzi3/trunk/sw/lib/ocaml/papget_renderer.ml    2009-12-16 17:39:39 UTC 
(rev 4376)
@@ -3,7 +3,7 @@
  *
  * Paparazzi widget renderers
  *  
- * Copyright (C) 2008 ENAC
+ * Copyright (C) 2008-2009 ENAC, Pascal Brisset
  *
  * This file is part of paparazzi.
  *
@@ -94,7 +94,7 @@
 class canvas_ruler = fun ?(config=[]) canvas_group x y ->
   let h = float_of_string (PC.get_prop "height" config "100.")
   and index_on_right = bool_of_string (PC.get_prop "index_on_right" config 
"false")
-  and scale = float_of_string (PC.get_prop "scale" config "2.")
+  and point_per_unit = float_of_string (PC.get_prop "point_per_unit" config 
"2.")
   and w = float_of_string (PC.get_prop "width" config "32.")
   and step = int_of_string (PC.get_prop "step" config "10") in
   let text_props=[`ANCHOR `CENTER; `FILL_COLOR "white"]
@@ -108,13 +108,13 @@
   (* One step drawer *)
   let draw = fun i value ->
     let i = i * step in
-    let y = -. scale *. (float i -. value) in
+    let y = -. point_per_unit *. (float i -. value) in
     if y >= -. h && y <= h then begin
       let text = Printf.sprintf "%d" i in
       ignore (GnoCanvas.text ~text ~props ~y ~x:(w*.0.75) r);
-      ignore(GnoCanvas.line ~points:[|w*.0.8;y;w-.1.;y|] ~fill_color:"white" r)
+      ignore (GnoCanvas.line ~points:[|w*.0.8;y;w-.1.;y|] ~fill_color:"white" 
r)
     end;
-    let y = y -. float step /. 2. *. scale in
+    let y = y -. float step /. 2. *. point_per_unit in
     if y >= -. h && y <= h then
       ignore(GnoCanvas.line ~points:[|w*.0.8;y;w-.1.;y|] ~fill_color:"white" r)
   in
@@ -123,10 +123,11 @@
     (* Remove previous items *)
     List.iter (fun i -> i#destroy ()) r#get_items;
     let v = truncate value / step in
-    let k = truncate (h /. scale) / step in
+    let k = truncate (h /. point_per_unit) / step in
     for i = Pervasives.max 0 (v - k) to (v + k) do
       draw i value
-    done in
+    done
+  in
   
   (** Yellow index *)
   let _ = GnoCanvas.line ~points:[|0.;0.;w-.1.;0.|] ~fill_color:"yellow" root 
in
@@ -145,10 +146,10 @@
     method item = (root :> movable_item)
     method config = fun () ->
       [ PC.float_property "height" h;
-       PC.property "index_of_right" (sprintf "%b" index_on_right);
-       PC.float_property "scale" scale;
+       PC.property "index_on_right" (sprintf "%b" index_on_right);
        PC.float_property "width" w;
-       PC.property "scale" (sprintf "%d" step) ]
+       PC.float_property "point_per_unit" point_per_unit;
+       PC.property "step" (sprintf "%d" step) ]
   end
 
 (*************************** Gauge ***********************************)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]