Commit e3200113 authored by Benoit Barbot's avatar Benoit Barbot
Browse files

prog

parent ee7defb6
......@@ -50,7 +50,7 @@ let draw_state (s,at) p =
let get_state_attr (s, at) =
"Node", ((A,"content",`String s) ::
(List.mapi (fun i sv -> (B i),"attribute "^(string_of_int (i+1)), (`String sv )) at))
(List.mapi (fun i sv -> (B i),"Attribute", (`String sv )) at))
let update_state_attr (s,at) attr_id = function
| None -> begin match attr_id with
A -> Some ("",at)
......@@ -73,7 +73,7 @@ let update_state_attr (s,at) attr_id = function
| _ -> None
let get_new_state_attr (s,at) _ = [
"node attribute", fun (s,at) -> (s, at@[""]), B (List.length at)
"Attribute", fun (s,at) -> (s, at@[""]), B (List.length at)
]
......@@ -108,13 +108,13 @@ let draw_arc (at,cn) (source_sh,target_sh) =
let get_arc_attr (atlist,controllist) =
"Arc", (
(List.mapi (fun i sv -> (B i),"attribute "^(string_of_int (i+1)), (`String sv )) atlist)
(List.mapi (fun i sv -> (B i),"Attribute", (`String sv )) atlist)
@ (List.mapi (fun i sv -> (match sv with
`Text (_,s) -> C i,"node "^(string_of_int (i+1)),
`Text (_,s) -> C i,"Node",
(`String s)
| `Point p -> C i,"point "^(string_of_int (i+1)),
| `Point p -> C i,"Point",
(`ControlPoint p)
| `ControlPoint p -> C i,"control "^(string_of_int (i+1)),
| `ControlPoint p -> C i,"Control",
(`ControlPoint p)
)) controllist)
)
......
......@@ -143,4 +143,9 @@ let write_attribute b (_,s,a) =
add_char b 'T';
buff_string b s;
buff_attribute b a
let read_attribute b pos =
assert (b.[pos] = 'T');
let pos2,s = string_buff b (pos+1) in
let pos3,at = attribute_buff b pos2 in
pos3,(s,at)
......@@ -204,7 +204,7 @@ module GraphEditor (G: GRAPH ) = struct
buff_float buff f1;
buff_float buff f2;
let attr = snd @@ G.get_node_attribute graph node in
List.iter (write_attribute buff) attr
buff_list buff write_attribute attr
);
G.iter_arc graph (fun arc ->
let n1,n2 = G.nodes_of_arc graph arc in
......@@ -231,6 +231,8 @@ module GraphEditor (G: GRAPH ) = struct
Hashtbl.add map !i node;
incr i;
pos := !pos+8;
let npos,attr = list_buff str read_attribute !pos in
pos := npos
done;
while !pos+7 <= length && str.[!pos] = 'A' do
let n1 = Hashtbl.find map (int_buff str (!pos+1)) in
......
Supports Markdown
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