~ubuntu-branches/ubuntu/maverick/ocamlgraph/maverick

« back to all changes in this revision

Viewing changes to dgraph/xDot.mli

  • Committer: Bazaar Package Importer
  • Author(s): Mehdi Dogguy
  • Date: 2010-01-10 14:42:40 UTC
  • mfrom: (1.1.9 upstream) (3.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100110144240-ftyalwf8mqb5le0u
Tags: 1.3+debian-1
* New upstream release
* Update README.source
* Fix include order in debian/rules
* Use new features of dh-ocaml 0.9
  - Generate documentation using dh_ocamldoc (Closes: #559330)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
open Graph
28
28
 
 
29
(** Simple layout types *)
 
30
 
 
31
(** 2D coordinates *)
 
32
type pos = float * float      
 
33
 
 
34
(** upper-left and bottom-right corners *)
 
35
type bounding_box = pos * pos
 
36
 
 
37
(**
 
38
   Layout informations are parsed from xdot files
 
39
   (dot files with graphviz layout).
 
40
 
 
41
   Each node or edge layout thus contains several lists of
 
42
   drawing operations.
 
43
 
 
44
   See http://www.graphviz.org/doc/info/output.html#d:xdot 
 
45
   to understand the details of the layout informations.
 
46
 
 
47
*)
 
48
 
 
49
(** Each node has at least a position and a bounding box. *)
 
50
type node_layout = {
 
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 *)
 
56
}
 
57
 
 
58
 
 
59
type cluster_layout = {
 
60
  c_pos : pos;                        
 
61
  c_bbox   : bounding_box;            
 
62
  c_draw   : XDotDraw.operation list;
 
63
  c_ldraw  : XDotDraw.operation list;
 
64
}
 
65
 
 
66
type edge_layout = {
 
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 *)
 
73
}
 
74
 
 
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;
 
80
  bbox : bounding_box;
 
81
 
82
 
 
83
(** Creates a node layout *)
 
84
val mk_node_layout :
 
85
  name:string ->
 
86
  pos:pos ->
 
87
  bbox:bounding_box ->
 
88
  draw:XDotDraw.operation list ->
 
89
  ldraw:XDotDraw.operation list ->
 
90
  node_layout
 
91
 
 
92
(** Creates a cluster layout *)
 
93
val mk_cluster_layout :
 
94
  pos:pos ->
 
95
  bbox:bounding_box ->
 
96
  draw:XDotDraw.operation list ->
 
97
  ldraw:XDotDraw.operation list ->
 
98
  cluster_layout
 
99
 
 
100
(** Creates an edge layout *)
 
101
val mk_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 ->
 
108
  edge_layout
 
109
 
 
110
(** Parsing and reading XDot *)
 
111
 
29
112
exception ParseError of string
30
113
 
31
 
(** Converts a coordinate from the dot file to a coordinate on
32
 
 the canvas *)
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
36
 
 
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
 
116
 
 
117
  open G
 
118
 
 
119
  exception DotError of string
 
120
 
 
121
  (** Extracts a layout of an xdot file *)
 
122
  val layout_of_xdot :
 
123
    xdot_file:string -> G.t -> (G.vertex, G.edge, string) graph_layout
 
124
 
 
125
  (** Using the dot file and graphviz, 
 
126
      create an xdot and extracts its layout. *) 
 
127
  val layout_of_dot :
 
128
    ?cmd:string ->
 
129
    dot_file:string -> G.t -> (G.vertex, G.edge, string) graph_layout
 
130
 
 
131
end
 
132
 
 
133
(** Converts and reads various layout informations *)
 
134
 
 
135
(** Converts a coordinate from a dot file to a coordinate on the canvas *)
 
136
val conv_coord : float * float -> float * float
 
137
 
 
138
val bounding_box : (float * float) -> float -> float -> bounding_box
 
139
val read_bounding_box : string -> bounding_box
 
140
 
 
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