source: Deliverables/Dissemination/final-review/wp5/Pics/wrapper.ml @ 3282

Last change on this file since 3282 was 3282, checked in by regisgia, 7 years ago
  • WP5 slides for the final review.
File size: 3.6 KB
Line 
1
2open Mlpost
3
4
5(* Helpers *)
6
7let tex = Box.tex ~dx:(Num.cm 0.2) ~dy:(Num.cm 0.2)
8let box_color_tex color = tex ~stroke:(Some color)
9let box_tex = box_color_tex Color.black
10let box = Box.box ~dx:Num.zero ~dy:Num.zero ~stroke:None
11let box_to_box ?kind cells c1 c2 =
12  Box.pic (Arrow.box_to_box ?kind (Box.get c1 cells) (Box.get c2 cells))
13let pic = Box.pic ~dx:Num.zero ~dy:Num.zero
14let pathp = Path.pathp ~style:Path.jLine
15let pic_path path = pic (Path.draw (pathp path))
16
17let textcolor color text = "\\textcolor{" ^ color ^ "}{" ^ text ^ "}"
18
19let textgreen = textcolor "darkgreen"
20let textblue = textcolor "blue"
21
22let tex_color ?name color text = tex ?name (textcolor color text)
23
24let rel_place posa posb p_shift a b =
25  let b = Box.place posa ~pos:posb a b in
26  Box.shift p_shift b
27
28let pct_point pct p1 p2 =
29  let x1 = Point.xpart p1 in
30  let x2 = Point.xpart p2 in
31  let y1 = Point.ypart p1 in
32  let y2 = Point.ypart p2 in
33  Point.pt
34    (Num.addn x1 (Num.multf pct (Num.subn x2 x1)),
35     Num.addn y1 (Num.multf pct (Num.subn y2 y1)))
36let middle = pct_point 0.5
37
38let kind_colored color =
39  let head = Arrow.head_triangle_full ~color in
40  let kind = Arrow.add_head ~head Arrow.empty in
41  Arrow.add_line ~color kind
42
43let kind_blue = kind_colored Color.blue
44
45let box_to_box_color color = box_to_box ~kind:(kind_colored color)
46let box_to_box_green = box_to_box_color Color.green
47let box_to_box_blue = box_to_box_color Color.blue
48let box_to_box = box_to_box_color Color.black
49
50let color_of_string = function
51  | "blue" -> Color.blue
52  | "green" -> Color.green
53  | "black" -> Color.black
54  | s -> raise (Invalid_argument ("Framac.color_of_string " ^ s))
55
56let box_tex_color ?name color s =
57  box_color_tex ?name (color_of_string color) (textcolor color s)
58
59
60(* Wrapper *)
61
62let lustre =
63  tex ~name:"lustre"
64    "\\begin{tabular}{c}Lustre file\\\\+\\\\node name\\end{tabular}"
65
66let step = tex ~name:"step" "Step function WCET"
67
68let results = tex ~name:"results" "Intermediary files and results"
69
70let jessie = tex ~name:"jessie" "Jessie verification"
71
72let test = tex ~name:"test" "Test (instrumentation)"
73
74let boxes =
75  let right_side =
76    Box.vbox ~padding:(Num.cm 0.5) [step ; results ; jessie ; test] in
77  let right_side =
78    Box.box ~dx:Num.zero ~dy:Num.zero ~stroke:None ~name:"right" right_side in
79  Box.hbox ~padding:(Num.cm 5.) [lustre ; right_side]
80
81let arrows =
82  let p1 = Box.east (Box.get "lustre" boxes) in
83  let p2 = Box.west (Box.get "right" boxes) in
84  let p_join = pct_point 0.25 p1 p2 in
85  let common1 = pic_path [p1 ; p_join] in
86  let pget name = Box.west (Box.get name boxes) in
87  let pstep = pget "step" in
88  let presults = pget "results" in
89  let pjessie = pget "jessie" in
90  let ptest = pget "test" in
91  let px = Point.xpart p_join in
92  let py_step = Point.ypart pstep in
93  let py_results = Point.ypart presults in
94  let py_jessie = Point.ypart pjessie in
95  let py_test = Point.ypart ptest in
96  let p_with_x y = Point.pt (px, y) in
97  let p1 = p_with_x py_step in
98  let p2 = p_with_x py_test in
99  let common2 = pic_path [p1 ; p2] in
100  let arrow_step = pic (Arrow.draw (pathp [p1 ; pstep])) in
101  let p = p_with_x py_results in
102  let arrow_results = pic (Arrow.draw (pathp [p ; presults])) in
103  let p = p_with_x py_jessie in
104  let arrow_jessie =
105    pic (Arrow.draw ~tex:"optional" ~anchor:`Top (pathp [p ; pjessie])) in
106  let arrow_test =
107    pic (Arrow.draw ~tex:"optional" ~anchor:`Top (pathp [p2 ; ptest])) in
108  Box.group
109    [common1 ; common2 ; arrow_step ; arrow_results ; arrow_jessie ; arrow_test]
110
111let result = Box.group [boxes ; arrows]
112
113
114(* Main *)
115
116let result = Box.draw result
117
118
119(* Output picture *)
120
121let _ = Metapost.emit "wrapper" result
Note: See TracBrowser for help on using the repository browser.