29
(** Simple layout types *)
32
type pos = float * float
34
(** upper-left and bottom-right corners *)
35
type bounding_box = pos * pos
38
Layout informations are parsed from xdot files
39
(dot files with graphviz layout).
41
Each node or edge layout thus contains several lists of
44
See http://www.graphviz.org/doc/info/output.html#d:xdot
45
to understand the details of the layout informations.
49
(** Each node has at least a position and a bounding box. *)
51
n_name : string; (** Dot label *)
52
n_pos : pos; (** Center position *)
53
n_bbox : bounding_box; (** Bounding box *)
54
n_draw : XDotDraw.operation list; (** Shape drawing *)
55
n_ldraw : XDotDraw.operation list; (** Label drawing *)
59
type cluster_layout = {
61
c_bbox : bounding_box;
62
c_draw : XDotDraw.operation list;
63
c_ldraw : XDotDraw.operation list;
67
e_draw : XDotDraw.operation list; (** Shapes and curves *)
68
e_ldraw : XDotDraw.operation list; (** Label drawing *)
69
e_hdraw : XDotDraw.operation list; (** Head arrowhead drawing *)
70
e_tdraw : XDotDraw.operation list; (** Tail arrowhead drawing *)
71
e_hldraw : XDotDraw.operation list; (** Head label drawing *)
72
e_tldraw : XDotDraw.operation list; (** Tail label drawing *)
75
(** Main layout type *)
76
type ('vertex, 'edge, 'cluster) graph_layout = {
77
vertex_layouts : ('vertex, node_layout) Hashtbl.t;
78
edge_layouts : ('edge, edge_layout) Hashtbl.t;
79
cluster_layouts : ('cluster, cluster_layout) Hashtbl.t;
83
(** Creates a node layout *)
88
draw:XDotDraw.operation list ->
89
ldraw:XDotDraw.operation list ->
92
(** Creates a cluster layout *)
93
val mk_cluster_layout :
96
draw:XDotDraw.operation list ->
97
ldraw:XDotDraw.operation list ->
100
(** Creates an edge layout *)
102
draw:XDotDraw.operation list ->
103
ldraw:XDotDraw.operation list ->
104
hdraw:XDotDraw.operation list ->
105
tdraw:XDotDraw.operation list ->
106
hldraw:XDotDraw.operation list ->
107
tldraw:XDotDraw.operation list ->
110
(** Parsing and reading XDot *)
29
112
exception ParseError of string
31
(** Converts a coordinate from the dot file to a coordinate on
33
val conv_coord : int * int -> float * float
34
val bounding_box : (int * int) -> float -> float -> DGraphModel.bounding_box
35
val read_bounding_box : string -> DGraphModel.bounding_box
37
val read_node_layout : Dot_ast.attr list -> DGraphModel.node_layout
38
val read_edge_layout : Dot_ast.attr list -> DGraphModel.edge_layout
39
val read_cluster_layout : Dot_ast.attr list -> DGraphModel.cluster_layout
114
(** Instantiates a module which creates graph layouts from xdot files *)
115
module Make(G : Graph.Graphviz.GraphWithDotAttrs) : sig
119
exception DotError of string
121
(** Extracts a layout of an xdot file *)
123
xdot_file:string -> G.t -> (G.vertex, G.edge, string) graph_layout
125
(** Using the dot file and graphviz,
126
create an xdot and extracts its layout. *)
129
dot_file:string -> G.t -> (G.vertex, G.edge, string) graph_layout
133
(** Converts and reads various layout informations *)
135
(** Converts a coordinate from a dot file to a coordinate on the canvas *)
136
val conv_coord : float * float -> float * float
138
val bounding_box : (float * float) -> float -> float -> bounding_box
139
val read_bounding_box : string -> bounding_box
141
(** Reads xdot layouts from the dot ast *)
142
val read_node_layout : Dot_ast.node_id -> Dot_ast.attr list -> node_layout
143
val read_edge_layout : Dot_ast.attr list -> edge_layout
144
val read_cluster_layout : Dot_ast.attr list -> cluster_layout