Commit f392e911 authored by Bruno Guillaume's avatar Bruno Guillaume

Fix bug due to graphviz different output

parent 3f8a76fc
......@@ -309,8 +309,10 @@ module Grew_rew_display = struct
(* ------------------- Hack for bugfix ------------------- *)
(* see: https://gitlab.inria.fr/grew/grew/issues/3 *)
(* output of Graphviz changes in 2.40 and the next lines make it "like" 2.38 output ! *)
let re_match re s = (Str.string_match re s 0) && (Str.matched_string s = s) in
let fix_line =
if Str.string_match (Str.regexp "<g id=\".*\" class=\".*\">") line 0
if re_match (Str.regexp "<g id=\".*\" class=\".*\">") line
then line ^ (input_line in_ch)
else line in
......@@ -319,72 +321,91 @@ module Grew_rew_display = struct
|> (Str.global_replace (Str.regexp_string "#ffffff") "white") in
(* ---------------- end "Hack for bugfix" ---------------- *)
match !graph_line_counter with
| 0 -> (* matching de la premiere ligne pour un graphe (<!-- GXX -->) *)
(if false then printf "~~~~> 0 <~~~~ line=>>>%s<<<\n%!" line);
if (Str.string_match init line 0)
then
begin
then
begin
(if false then printf " .....> [0] init\n%!");
let id = Str.matched_group 1 line in
let classe = Str.matched_group 2 line
and transform = Str.matched_group 3 line in
if (show_bottom) then (
output_string out_ch ("<g id=\""^id^"\" onload=\"window.scrollBy(0,100000);\" class=\""^classe^"\" transform=\""^transform^"\">");
) else (
output_string out_ch line
if (show_bottom)
then (
output_string out_ch
("<g id=\""^id^"\" onload=\"window.scrollBy(0,100000);\" class=\""^classe^"\" transform=\""^transform^"\">");
)
else (output_string out_ch line)
end
else if (Str.string_match graph_comment_match line 0)
then
begin
else if (Str.string_match graph_comment_match line 0)
then
begin
(if false then printf " .....> [0] graph_comment_match\n%!");
graph_id_internal := Str.matched_group 1 line;
incr graph_line_counter;
output_string out_ch (line^"\n");
(* Log.fdebug "[Grew_rew_display]--> Graph found : %s" !graph_id_internal *)
(* Log.fdebug "[Grew_rew_display]--> Graph found : %s" !graph_id_internal *)
end
else if (Str.string_match edge_comment_match line 0)
then
begin
(* Log.fdebug "[Grew_rew_display]--> edge found : %s -> %s" (Str.matched_group 1 line) (Str.matched_group 3 line); *)
edge_from := (Str.matched_group 1 line);
edge_to := (Str.matched_group 3 line);
graph_line_counter := 4;
output_string out_ch (line^"\n");
end
else if (Str.string_match svg_match line 0)
then
begin
else if (Str.string_match edge_comment_match line 0)
then
begin
(if false then printf " .....> [0] edge_comment_match\n%!");
(* Log.fdebug "[Grew_rew_display]--> edge found : %s -> %s" (Str.matched_group 1 line) (Str.matched_group 3 line); *)
edge_from := (Str.matched_group 1 line);
edge_to := (Str.matched_group 3 line);
graph_line_counter := 4;
output_string out_ch (line^"\n");
end
else if (Str.string_match svg_match line 0)
then
begin
(if false then printf " .....> [0] svg_match\n%!");
graph_line_counter := 99;
output_string out_ch (line^"\n");
end
else if (Str.string_match module_match line 0)
then
begin
else if (Str.string_match module_match line 0)
then
begin
(if false then printf " .....> [0] module_match\n%!");
graph_line_counter := 59;
output_string out_ch (line^"\n");
end
else if (Str.string_match background_match line 0)
then
begin
else if (Str.string_match background_match line 0)
then
begin
(if false then printf " .....> [0] background_match\n%!");
let _1 = Str.matched_group 1 line
and _2 = Str.matched_group 2 line in
x_left := _1;
x_right := _2;
output_string out_ch (line^"\n");
end
else output_string out_ch (line^"\n")
else (
(if false then printf " .....> [0] XXX\n%!");
output_string out_ch (line^"\n")
)
| 1 -> (* deuxieme ligne du graphe (g) *)
(if false then printf "~~~~> 1 <~~~~ line=>>>%s<<<\n%!" line);
if (Str.string_match g_match line 0)
then (
then (
(if false then printf " .....> [1] g_match\n%!");
graph_id := Str.matched_group 1 line;
incr graph_line_counter;
output_string out_ch (Printf.sprintf "<g id=\"%s\" class=\"node\" >\n" !graph_id);
(* Log.fdebug "[Grew_rew_display] Graph id : %s" !graph_id *)
) else (
output_string out_ch (line^"\n");
(* Log.fdebug "[Grew_rew_display] Graph id : %s" !graph_id *)
)
else (
(if false then printf " .....> [1] XXX\n%!");
output_string out_ch (line^"\n")
)
| 2 ->
if (Str.string_match polygon_matchA line 0) || (Str.string_match polygon_matchB line 0) then (
(if false then printf "~~~~> 2 <~~~~ line=>>>%s<<<\n%!" line);
if (Str.string_match polygon_matchA line 0) || (Str.string_match polygon_matchB line 0)
then (
(if false then printf " .....> [2] polygon_matchA/B\n%!");
incr graph_line_counter;
let fill = Str.matched_group 1 line in
let _1 = Str.matched_group 2 line
......@@ -398,7 +419,7 @@ module Grew_rew_display = struct
and _9 = Str.matched_group 10 line
and _10 = Str.matched_group 11 line in
polygon_back_tmp := Printf.sprintf "<polygon id=\"polygon_%s_back\"
fill=\"%s\" fill-opacity=\"%d\" stroke=\"transparent\" points=\"%s,%s %s,%s %s,%s %s,%s %s,%s\"/>\n"
fill=\"%s\" fill-opacity=\"%d\" stroke=\"transparent\" points=\"%s,%s %s,%s %s,%s %s,%s %s,%s\"/>\n"
!graph_id_internal
fill
(if (fill<>"none") then 1 else 0)
......@@ -445,28 +466,40 @@ module Grew_rew_display = struct
(sof ((fos _8) -. 2.) ^ "0");
(* Log.fdebug "[Grew_rew_display] Polygon found : %s" _1 *)
) else (
(if false then printf " .....> [2] XXX\n%!");
output_string out_ch (line^"\n");
)
| 3 ->
(if false then printf "~~~~> 3 <~~~~ line=>>>%s<<<\n%!" line);
output_string out_ch !polygon_back_tmp;
output_string out_ch (line^"\n");
output_string out_ch !polygon_tmp;
graph_line_counter := 0;
| 4 -> (* recuperation des coordonnées utiles pour les aretes *)
if (Str.string_match edge_path_match line 0) then (
if (Str.matched_group 1 line) = "black" then (
incr graph_line_counter;
(* Log.fdebug "[Grew_rew_display] color: %s, x1:%s, y1:%s" (Str.matched_group 1 line) (Str.matched_group 2 line) (Str.matched_group 3 line); *)
edge_color := (Str.matched_group 1 line);
x1 := (Str.matched_group 2 line);
y1 := (Str.matched_group 3 line);
(if false then printf "~~~~> 4 <~~~~ line=>>>%s<<<\n%!" line);
if (Str.string_match edge_path_match line 0)
then (
(if false then printf " .....> [4] edge_path_match\n%!");
if (Str.matched_group 1 line) = "black"
then (
incr graph_line_counter;
(* Log.fdebug "[Grew_rew_display] color: %s, x1:%s, y1:%s" (Str.matched_group 1 line) (Str.matched_group 2 line) (Str.matched_group 3 line); *)
edge_color := (Str.matched_group 1 line);
x1 := (Str.matched_group 2 line);
y1 := (Str.matched_group 3 line);
) else (
graph_line_counter := 0;
graph_line_counter := 0;
)
);
output_string out_ch (line^"\n");
| 5 ->
if (Str.string_match edge_polygon_match line 0) then (
(if false then printf "~~~~> 5 <~~~~ line=>>>%s<<<\n%!" line);
if (Str.string_match edge_polygon_match line 0)
then (
(if false then printf " .....> [5] edge_polygon_match\n%!");
x2 := (Str.matched_group 1 line);
y2 := (Str.matched_group 2 line);
......@@ -495,10 +528,13 @@ module Grew_rew_display = struct
!x1 !y1);
incr edge_counter;
) else (
(if false then printf " .....> [5] XXX\n%!");
output_string out_ch (line^"\n");
);
graph_line_counter := 0;
| 99 ->
(if false then printf "~~~~> 99 <~~~~ line=>>>%s<<<\n%!" line);
let ecmascript = "<script type=\"text/ecmascript\">
<![CDATA[
var current_top = \"G0\";
......@@ -578,17 +614,22 @@ module Grew_rew_display = struct
output_string out_ch (ecmascript^"\n");
graph_line_counter := 0;
| 59 ->
if (Str.string_match module_text_match line 0) then (
Printf.fprintf out_ch "<text text-anchor=\"middle\" x=\"%s\" y=\"%s\" font-family=\"%s\"
font-size=\"%s\">%s</text>\n"
(Str.matched_group 1 line)
(Str.matched_group 2 line)
(Str.matched_group 3 line)
(Str.matched_group 4 line)
(Str.matched_group 5 line);
(if false then printf "~~~~> 59 <~~~~ line=>>>%s<<<\n%!" line);
if (Str.string_match module_text_match line 0)
then (
(if false then printf " .....> [59] module_text_match\n%!");
Printf.fprintf out_ch
"<text text-anchor=\"middle\" x=\"%s\" y=\"%s\" font-family=\"%s\" font-size=\"%s\">%s</text>\n"
(Str.matched_group 1 line)
(Str.matched_group 2 line)
(Str.matched_group 3 line)
(Str.matched_group 4 line)
(Str.matched_group 5 line);
graph_line_counter := 0;
)
| _ -> ()
| _ ->
(if false then printf "~~~~> ??? <~~~~ line=>>>%s<<<\n%!" line);
()
done;
with End_of_file ->
close_in in_ch;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment