source: Deliverables/Dissemination/final-review/wp5/Pics/cost.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: 2.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))
13
14let textcolor color text = "\\textcolor{" ^ color ^ "}{" ^ text ^ "}"
15
16let textgreen = textcolor "darkgreen"
17let textblue = textcolor "blue"
18
19let tex_color ?name color text = tex ?name (textcolor color text)
20
21let rel_place posa posb p_shift a b =
22  let b = Box.place posa ~pos:posb a b in
23  Box.shift p_shift b
24
25let middle p1 p2 = Point.mult (Num.of_float 0.5) (Point.add p1 p2)
26
27let kind_colored color =
28  let head = Arrow.head_triangle_full ~color in
29  let kind = Arrow.add_head ~head Arrow.empty in
30  Arrow.add_line ~color kind
31
32let kind_blue = kind_colored Color.blue
33
34let box_to_box_color color = box_to_box ~kind:(kind_colored color)
35let box_to_box_green = box_to_box_color Color.green
36let box_to_box_blue = box_to_box_color Color.blue
37let box_to_box = box_to_box_color Color.black
38
39let color_of_string = function
40  | "blue" -> Color.blue
41  | "darkgreen" -> Color.green
42  | "black" -> Color.black
43  | s -> raise (Invalid_argument ("Framac.color_of_string " ^ s))
44
45let box_tex_color ?name color s =
46  box_color_tex ?name (color_of_string color) (textcolor color s)
47
48
49(* Cost *)
50
51let c_source = tex ~name:"source" "$\\Clang$ source"
52
53let cost = box_tex_color ~name:"cost" "blue" "Cost plug-in"
54
55let c_annotated =
56  tex ~name:"annotated"
57    ("\\begin{tabular}{c}" ^
58     "$\\Clang$ source\\\\" ^
59     "+\\\\" ^
60     (textcolor "blue" "CerCo's annotations") ^ "\\\\" ^
61     "+\\\\" ^
62     (textcolor "blue" "ACSL specifications: WCETs") ^
63     "\\end{tabular}")
64
65let jessie = box_tex_color ~name:"jessie" "darkgreen" "Jessie"
66
67let wcets_correct = tex ~name:"wcets" "\\checked~WCETs correct"
68
69let result =
70  let boxes = Box.hbox ~padding:(Num.cm 1.5) [c_source ; cost ; c_annotated] in
71  let place a b = Box.place `South ~pos:`North ~padding:(Num.cm 1.) a b in
72  let jessie = place (Box.get "annotated" boxes) jessie in
73  let wcets_correct = place jessie wcets_correct in
74  let boxes = Box.group [boxes ; jessie ; wcets_correct] in
75  let arrow = box_to_box boxes in
76  let arrow1 = arrow "source" "cost" in
77  let arrow2 = arrow "cost" "annotated" in
78  let arrow3 = arrow "annotated" "jessie" in
79  let arrow4 = arrow "jessie" "wcets" in
80  Box.group [boxes ; arrow1 ; arrow2 ; arrow3 ; arrow4]
81
82
83(* Main *)
84
85let result = Box.draw result
86
87
88(* Output picture *)
89
90let _ = Metapost.emit "cost" result
Note: See TracBrowser for help on using the repository browser.