source: Deliverables/Dissemination/final-review/wp5/Pics/cerco_present.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: 4.3 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_tex = tex ~stroke:(Some Color.black)
9let box = Box.box ~dx:Num.zero ~dy:Num.zero ~stroke:None
10
11let rel_place posa posb p_shift a b =
12  let b = Box.place posa ~pos:posb a b in
13  Box.shift p_shift b
14
15let middle p1 p2 = Point.mult (Num.of_float 0.5) (Point.add p1 p2)
16
17
18(* Boxes *)
19
20let c_program_text = "$\\Clang$ program"
21let c_program = box_tex c_program_text
22let executable = box_tex "Executable"
23let c_annot =
24  box_tex
25    ("\\begin{tabular}{c}" ^ c_program_text ^ "\\\\+\\\\Cost annotations" ^
26     "\\end{tabular}")
27
28let analyzer_text i = "analyzer" ^ (string_of_int i)
29let analyzer i =
30  let name = analyzer_text i in
31  box_tex ~name ("Analyzer " ^ (string_of_int i))
32
33let analyzers =
34  Box.vbox ~padding:(Num.cm 0.5) [analyzer 1 ; analyzer 2 ; analyzer 3]
35
36
37(* Placement *)
38
39let prog = "c_program"
40let exec = "executable"
41let annot = "c_annot"
42let analyzer = analyzer_text
43let wcet = "wcet"
44let not_found = "not_found"
45let better = "better"
46
47let right_side =
48  Box.vbox ~pos:`Center ~padding:(Num.cm 1.)
49    [box ~name:exec executable ; box ~name:annot c_annot]
50
51let boxes =
52  let x = Point.xpart (Box.west right_side) in
53  let p_exec = Box.south (Box.get exec right_side) in
54  let annot = Box.get annot right_side in
55  let p_annot = Box.north annot in
56  let y = Point.ypart (middle p_exec p_annot) in
57  let p_target = Point.pt (x, y) in
58  let target = Box.center p_target (Box.empty ()) in
59  let p_shift = Point.pt (Num.cm (-.3.), Num.zero) in
60  let c_program = rel_place `West `East p_shift target c_program in
61  let analyzers = Box.place `Southeast ~pos:`Southwest annot analyzers in
62  let analyzers = Box.shift (Point.pt (Num.cm 1., Num.zero)) analyzers in
63  let to_right i =
64    Box.place `East ~pos:`West ~padding:(Num.cm 0.5)
65      (Box.get (analyzer i) analyzers) in
66  let wcet = to_right 1 (Box.tex ~name:wcet "WCET") in
67  let not_found = to_right 2 (Box.tex ~name:not_found "?") in
68  let better = to_right 3 (Box.tex ~name:better "better WCET") in
69  Box.group [box ~name:prog c_program ; right_side ; analyzers ;
70             wcet ; not_found ; better]
71
72let cerco = tex "\\textcolor{blue}{CerCo}"
73
74
75(* Arrows *)
76
77let color = Color.blue
78
79let p1 = Box.east (Box.get prog boxes)
80let p2 =
81  let p_shift = Point.pt (Num.cm 2., Num.zero) in
82  Point.shift p_shift p1
83let p3 = Box.west (Box.get exec boxes)
84let p4 = Box.west (Box.get annot boxes)
85
86let common =
87  let p = Path.pathp ~style:Path.jLine [p1 ; p2] in
88  Box.pic (Path.draw ~color p)
89
90let to_exec =
91  let p_int = Point.pt (Point.xpart p2, Point.ypart p3) in
92  let p = Path.pathp ~style:Path.jLine [p2 ; p_int ; p3] in
93  Box.pic (Arrow.simple ~color p)
94
95let to_annot =
96  let p_int = Point.pt (Point.xpart p2, Point.ypart p4) in
97  let p = Path.pathp ~style:Path.jLine [p2 ; p_int ; p4] in
98  Box.pic (Arrow.simple ~color p)
99
100let to_analyzers =
101  let p_annot = Box.east (Box.get annot boxes) in
102  let p1 = Box.west (Box.get (analyzer 1) boxes) in
103  let p2 = Box.west (Box.get (analyzer 2) boxes) in
104  let p3 = Box.west (Box.get (analyzer 3) boxes) in
105  let x = Point.xpart (middle p_annot p1) in
106  let p_annot' = Point.pt (x, Point.ypart p_annot) in
107  let p1' = Point.pt (x, Point.ypart p1) in
108  let p2' = Point.pt (x, Point.ypart p2) in
109  let p3' = Point.pt (x, Point.ypart p3) in
110  let pannot =
111    Box.pic (Path.draw (Path.pathp ~style:Path.jLine [p_annot ; p_annot'])) in
112  let pcommon =
113    Box.pic (Path.draw (Path.pathp ~style:Path.jLine [p1' ; p3'])) in
114  let arrow p p' =
115    Box.pic (Arrow.simple (Path.pathp ~style:Path.jLine [p ; p'])) in
116  Box.group [pannot ; pcommon ; arrow p1' p1 ; arrow p2' p2 ; arrow p3' p3]
117
118let from_analyzer i b =
119  let p1 = Box.east (Box.get (analyzer i) boxes) in
120  let p2 = Box.west (Box.get b boxes) in
121  Box.pic (Arrow.simple (Path.pathp ~style:Path.jLine [p1 ; p2]))
122
123let from_analyzers =
124  Box.group
125    [from_analyzer 1 "wcet" ;
126     from_analyzer 2 "not_found" ;
127     from_analyzer 3 "better"]
128
129
130(* CerCo *)
131
132let result =
133  let p = middle p1 p2 in
134  let target = Box.center p (Box.empty ()) in
135  let cerco = Box.place `Center ~pos:`South target cerco in
136  Box.group
137    [boxes ; common ; to_exec ; to_annot ; cerco ; to_analyzers ;
138     from_analyzers]
139
140
141(* Main *)
142
143let result = Box.draw result
144
145
146(* Output picture *)
147
148let _ = Metapost.emit "cerco_present" result
Note: See TracBrowser for help on using the repository browser.