X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fhtml.ml;h=b35f17d1cc32e59cef0f01861d4f79a7a8daf712;hb=30675098fce9aaa56027adc42042ea70c986fe01;hp=f049195515f4bdcf626e2a3186dd49c2c748c0e9;hpb=a8f210b6229055c3c5101034d359c61476d8408a;p=tatoo.git diff --git a/src/html.ml b/src/html.ml index f049195..b35f17d 100644 --- a/src/html.ml +++ b/src/html.ml @@ -34,10 +34,10 @@ let trace ?(msg="") nid r t d = let finalize_node n r b = Hashtbl.replace final n (b,r) -module K = +module K = struct type t = int * StateSet.t * StateSet.t - let hash (a,b,c) = HASHINT3(a, (b.StateSet.id :> int), (c.StateSet.id :> int) ) + let hash (a,b,c) = HASHINT3(a, (b.StateSet.id :> int), (c.StateSet.id :> int)) let equal ((a1,b1,c1) as x) ((a2,b2,c2) as y) = x == y || (a1 == a2 && b1 == b2 && c1 == c2) end @@ -85,17 +85,35 @@ let gen_trace (type s) = fun auto t tree -> let marked, last_round = try Hashtbl.find final node_id with Not_found -> Printf.eprintf ">>> %i\n%!" node_id; false, !max_round; in - let pc = if !max_round == 0 then 1. else float_of_int last_round /. float_of_int !max_round in let scolor, tcolor = - let { sat ; todo; _ } = List.hd(M.find last_round m) in - let c = (last_round, sat, todo) in color c, text_color c + let { sat ; todo; _ } = + match M.find last_round m with + [] -> { sat = StateSet.empty; todo= StateSet.empty; msg = "ERROR" } + | [ e ] -> e + | l -> List.hd (List.tl (List.rev l)) + in + let c = (last_round, StateSet.union sat todo, StateSet.empty) in + color c, text_color c in let tag = QName.to_string (T.tag tree node) in let lbox = (String.length tag + 2) * 10 in let s_node = "node" ^ (string_of_int node_id) in - fprintf osvg "\n%!" - s_node s_node x y lbox scolor (if marked then ";stroke-width:4" else ";stroke-width:2;stroke-dasharray:2,2"); - fprintf osvg "%s\n" (x+10) (y+15) tcolor s_node tag; + fprintf osvg + "\n%!" + s_node + s_node + x y + lbox + scolor + (if marked + then ";stroke-width:4" + else ";stroke-width:2;stroke-dasharray:2,2"); + fprintf osvg "%s\n" + (x+10) + (y+15) + tcolor s_node tag; fprintf ohtml "data['%s'] = new Array();\n" s_node; M.iter (fun i l -> @@ -108,10 +126,12 @@ let gen_trace (type s) = fun auto t tree -> let x_next = max (x+lbox) (maxw1+10) in if node != root then begin if node == T.first_child tree parent then - fprintf osvg "\n" + fprintf osvg "\n" (x + lbox / 2) (y-20) (x + lbox / 2) (y); if next != T.nil then - fprintf osvg "\n" + fprintf osvg "\n" (x + lbox) (y+10) x_next (y+10); end; let maxw2, maxy2 = loop osvg ohtml next node x_next y in @@ -146,7 +166,8 @@ Ata.print auto; d.innerHTML = msg; return; };\n"; - fprintf ohtml "\n
\n" + fprintf ohtml "\n
\n" maxw maxh; let fi = open_in "tests/trace/trace.svg" in try @@ -160,5 +181,3 @@ Ata.print auto; pp_print_flush ohtml (); close_out ohtml_; close_in fi - -