1:- module(zdd_gv, [arrows/1]). 2:- use_module(library(lists)). 3:- use_module(util(misc)). 4:- use_module(zdd('emacs-handler')). 5:- use_module(util(file)). 6
9
10arrows(Arrows):-arrowviz_jpg(arrows2dot, Arrows).
12arrowviz(Pred, Aut):-
13 absolute_file_name(pac_tmp('DOTTEMP.dot'), DOT),
14 absolute_file_name(pac_tmp('DOTTEMP.'), M),
15 file(DOT, write, call(Pred, Aut)),
16 eh:sh(dot(-'T'(ps2), -o(M+ps), M+dot);
17 ps2pdf(M+ps, M+pdf);
18 open(-a('Preview'), M+pdf)).
20arrowviz_jpg(Pred, Aut):-
21 absolute_file_name(pac_tmp('DOTTEMP.dot'), DOT),
22 absolute_file_name(pac_tmp('DOTTEMP.'), M),
23 file(DOT, write, call(Pred, Aut)),
24 eh:sh(dot(-'T'(jpg), -o(M+jpg), M+dot)
25 ; open(-a('Preview'), M+jpg)).
26
28arrows2dot(Arrows):-
29 format("digraph g {~n",[]),
30 format("rankdir=LR;~n",[]),
31 format("dummy [shape = none, label = \"\"];~n",[]),
32 move_in_dot(Arrows),
33 format("}~n",[]).
35move_in_dot([]).
36move_in_dot([(X,A,Y)|Z]):-edge_in_dot(X,A,Y), move_in_dot(Z).
38edge_in_dot(X,A,Y):-
39 format("\"~w\" -> \"~w\" [label = \"~w\"];~n",
40 [X,Y,A])