X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=src%2Fhtml_trace.ml;h=58c1f68a41ad26c7c30e966c14f358631d68fd57;hp=f5aa8b21ff5d5e6cbded32a1cf92e06bd89940d3;hb=c6a89f390d6171f99d98f794427c1cce42fbf40c;hpb=fee64144491afab22d71f6e2de72a9f18f35cd55 diff --git a/src/html_trace.ml b/src/html_trace.ml index f5aa8b2..58c1f68 100644 --- a/src/html_trace.ml +++ b/src/html_trace.ml @@ -87,7 +87,7 @@ let gen_trace (type s) = fun auto sat_arrays t tree -> let module T = (val (t) : Tree.S with type t = s) in let root = T.root tree in let sel = Ata.get_selecting_states auto in - let rec loop output node parent x y = + let rec loop output node parent prevsib x y = if node != T.nil then begin let node_id = T.preorder tree node in let marked, conf = get_conf sel sat_arrays node_id in @@ -95,9 +95,11 @@ let gen_trace (type s) = fun auto sat_arrays t tree -> 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 + let first = T.first_child tree node in + let next = T.next_sibling tree node in fprintf output "\n%!" + width=\"%i\" height=\"22\" style=\"fill:%s;stroke:rgb(0,0,0)%s\">%!" s_node s_node x y @@ -106,26 +108,28 @@ let gen_trace (type s) = fun auto sat_arrays t tree -> (if marked then ";stroke-width:4" else ";stroke-width:2;stroke-dasharray:2,2"); + fprintf output "node%inode%inode%inode%i\n%!" +s_node (T.preorder tree first) s_node (T.preorder tree next) +s_node (T.preorder tree parent) s_node (T.preorder tree prevsib) +; fprintf output "%s\n" (x+10) (y+15) tcolor s_node tag; - let first = T.first_child tree node in - let maxw1, maxy1 = loop output first node x (y + 40) in - let next = T.next_sibling tree node in + let maxw1, maxy1 = loop output first node T.nil x (y + 40) in let x_next = max (x+lbox) (maxw1+10) in if node != root then begin - if node == T.first_child tree parent then + if prevsib == T.nil then fprintf output "\n" - (x + lbox / 2) (y-20) (x + lbox / 2) (y); + (x + lbox / 2) (y-18) (x + lbox / 2) (y); if next != T.nil then fprintf output "\n" - (x + lbox) (y+10) x_next (y+10); + (x + lbox) (y+11) x_next (y+11); end; - let maxw2, maxy2 = loop output next node x_next y in + let maxw2, maxy2 = loop output next parent node x_next y in maxw2, max maxy1 maxy2 end else x, y @@ -133,69 +137,47 @@ style=\"stroke:rgb(0,0,0);stroke-width:2\"/>\n" ignore (Sys.command "mkdir -p tests/trace"); let ohtml_ = open_out "tests/trace/trace.html" in let ohtml = formatter_of_out_channel ohtml_ in - fprintf ohtml "\ - -\ -\ -\ -\ -
%a -
+ fprintf ohtml "\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +
%a
\n\
\n\ \n
\n"; - let maxw, maxh = loop ohtml (T.root tree) T.nil 50 50 in - fprintf ohtml "\n\ -
\n%!" + List.iteri (fun i _ -> + fprintf ohtml "data[%i] = new Array();\n" i) sat_arrays; + for node_id = 0 to (Array.length (List.hd sat_arrays)) - 1 do + let _,_ = List.fold_left (fun (pass, diff_set) a -> + let cur_set = a.(node_id) in + fprintf ohtml "data[%i]['node%i'] = \"new states %a
full states = %a\";\n" + pass node_id StateSet.print (StateSet.diff cur_set diff_set) StateSet.print cur_set; + (pass+1, StateSet.union diff_set cur_set)) + (0, StateSet.empty) (List.rev sat_arrays) + in () + done; + fprintf ohtml "%s\n" Trace_js.content; + fprintf ohtml "%s" + "\n\ +
\n + \n"; + let maxw, maxh = loop ohtml (T.root tree) T.nil T.nil 50 50 in + fprintf ohtml "\n
\n%!" maxw maxh; pp_print_flush ohtml (); close_out ohtml_