# # # patch "agraph.ml" # from [c9152945a3b80583ed6fc6e8b8c45f69a75b62be] # to [6eecb1bfd0370d394ea4311512029a3d10676c52] # # patch "agraph.mli" # from [08e41b7cf67369cbf32876a38add40bfd2c09ba8] # to [6095dfc14ecc5804edac4d3cf1755af9382a6bb8] # # patch "app.ml" # from [44ab6019fec74978ba42fcdc4416d70b10eeb8d9] # to [ecdd153474516d486e2ad04862b65f537522a10e] # # patch "database.ml" # from [8c08bb817a74bf03d5b94175ea4db8fbe9a9d9ba] # to [ed9278cbb1ee9179bb761ae8e21ebf91b1f13811] # # patch "view.ml" # from [aef3e25bf8bb163d45dbd5bd8ddeef96950664ed] # to [71439d68e1176b98dcf968eb0e11cd706c7fd23d] # # patch "view.mli" # from [fc58aa1b7db2d23c654b7c407ee1da2a2503ddcc] # to [10a06ee77ef495e988563bffb5a58bc03e2cd6eb] # # patch "viz_types.ml" # from [2348af90556459bd15ea99ce8d5b45b2f2dbe82c] # to [fa26708f30ff98ccee703267a4d5567c9a0545c9] # # patch "viz_types.mli" # from [c3524724d488bbf3da18ba9de56ab98d9a08599f] # to [2f027d5caef8b2f45a32eea1e3e165894f4437b5] # ============================================================ --- agraph.ml c9152945a3b80583ed6fc6e8b8c45f69a75b62be +++ agraph.ml 6eecb1bfd0370d394ea4311512029a3d10676c52 @@ -1,10 +1,11 @@ open Viz_misc open Viz_types type layout = Viz_types.cgraph type layout_params = { - box_w : float ; - box_h : float ; + box_w : float ; + box_h : float ; + char_width : float ; lr_layout : bool ; dot_program : string ; } @@ -57,18 +58,31 @@ end ; begin + (* nodes with tags *) + NodeMap.iter + (fun id n -> + match n.kind with + | TAGGED tag -> + let w = + params.char_width *. float (String.length tag + 4) in + !+ " %S [width = %g] ;\n" id w + | _ -> ()) + agraph.nodes + end ; + + begin (* merge nodes *) let s = min params.box_w params.box_h in !+ " node [shape=circle, width = %f, height = %f] ;\n" s s ; do_nodes (fun n -> n.kind = MERGE) ; end ; - begin - (* disapproval nodes *) - let s = min params.box_w params.box_h in - !+ " node [shape=diamond, width = %f, height = %f] ;\n" s s ; - do_nodes (fun n -> n.kind = DISAPPROVE) ; - end ; +(* begin *) +(* (* disapproval nodes *) *) +(* let s = min params.box_w params.box_h in *) +(* !+ " node [shape=diamond, width = %f, height = %f] ;\n" s s ; *) +(* do_nodes (fun n -> n.kind = DISAPPROVE) ; *) +(* end ; *) let heads = find_heads agraph in begin @@ -261,6 +275,7 @@ query = query ; agraph = agraph ; layout_params = { layout_params with + char_width = layout_params.char_width /. ppi ; box_w = layout_params.box_w /. ppi ; box_h = layout_params.box_h /. ppi } ; layout = None ; ============================================================ --- agraph.mli 08e41b7cf67369cbf32876a38add40bfd2c09ba8 +++ agraph.mli 6095dfc14ecc5804edac4d3cf1755af9382a6bb8 @@ -1,9 +1,10 @@ open Viz_types type layout = Viz_types.cgraph type layout_params = { box_w : float ; box_h : float ; + char_width : float ; lr_layout : bool ; dot_program : string ; } ============================================================ --- app.ml 44ab6019fec74978ba42fcdc4416d70b10eeb8d9 +++ app.ml ecdd153474516d486e2ad04862b65f537522a10e @@ -196,8 +196,9 @@ db method private layout_params = - let (w, h) = View.Canvas.id_size view.View.canvas self in - { Agraph.box_w = float w ; + let (w, h, cw) = View.Canvas.id_size view.View.canvas self in + { Agraph.char_width = float cw ; + Agraph.box_w = float w ; Agraph.box_h = float h ; Agraph.lr_layout = prefs.Viz_style.lr_layout ; Agraph.dot_program = prefs.Viz_style.dot_path } ============================================================ --- database.ml 8c08bb817a74bf03d5b94175ea4db8fbe9a9d9ba +++ database.ml ed9278cbb1ee9179bb761ae8e21ebf91b1f13811 @@ -182,6 +182,23 @@ init stmt + +let collect_tags db nodes = + let stmt = Sqlite3.prepare_one db + "SELECT value FROM revision_certs WHERE id = ? AND name = 'tag'" in + NodeMap.fold + (fun id node m -> + Sqlite3.reset stmt ; + Sqlite3.bind stmt 1 (`TEXT id) ; + Sqlite3.fold_rows + (fun m stmt -> + let v = Sqlite3.column_text stmt 0 in + NodeMap.add id { node with kind = TAGGED v } m) + m + stmt) + nodes + nodes + let fetch_agraph_with_view db (query, query_limit) = let view_name_limit = if query_limit <> QUERY_NO_LIMIT @@ -212,6 +229,10 @@ let agraph = { agraph with nodes = find_merge_nodes agraph.nodes } in + (* get tags *) + let agraph = + { agraph with nodes = collect_tags db agraph.nodes } in + (* determine the branching edges *) let agraph = begin ============================================================ --- view.ml aef3e25bf8bb163d45dbd5bd8ddeef96950664ed +++ view.ml 71439d68e1176b98dcf968eb0e11cd706c7fd23d @@ -1096,11 +1096,12 @@ let char_width = GPango.to_pixels metrics#approx_char_width in let ascent = GPango.to_pixels metrics#ascent in let descent = GPango.to_pixels metrics#descent in - let (w, h) as s = + let (w, h, cw) as s = ((id_width + 4) * char_width, - (ascent + descent) * 2) in + (ascent + descent) * 2, + char_width) in if Viz_misc.debug "font" - then Printf.eprintf "### font: width = %d, height = %d\n%!" w h ; + then Printf.eprintf "### font: width = %d, height = %d, char_width = %d\n%!" w h cw ; s let scroll view view_width target target_width = @@ -1203,10 +1204,15 @@ GnoCanvas.rect ~x1:(~-. x) ~y1:(~-. y) ~x2:x ~y2:y ~props g in if node.c_kind = DISAPPROVE then rect#affine_relative [| 0.5 ; 0.5 ; 0.5 ; -0.5 ; 0. ; 0. |] ; - if node.c_kind = REGULAR || is_neighbor node then + let text = + match node.c_kind with + | TAGGED t -> t + | REGULAR -> String.sub id 0 id_width + | _ when is_neighbor node -> String.sub id 0 id_width + | _ -> "" in + if text <> "" then begin let scaled_font_size = font_size *. c.ppu in - let text = String.sub id 0 id_width in let t = GnoCanvas.text ~text ~font ~props:([ `SIZE_POINTS scaled_font_size ] @ text_props) g in ============================================================ --- view.mli fc58aa1b7db2d23c654b7c407ee1da2a2503ddcc +++ view.mli 10a06ee77ef495e988563bffb5a58bc03e2cd6eb @@ -19,7 +19,7 @@ sig type t val zoom : t -> #App.t -> [< `IN | `OUT ] -> unit -> unit - val id_size : t -> #App.t -> int * int + val id_size : t -> #App.t -> int * int * int val center_on : t -> #App.t -> string * Viz_types.c_node -> unit end ============================================================ --- viz_types.ml 2348af90556459bd15ea99ce8d5b45b2f2dbe82c +++ viz_types.ml fa26708f30ff98ccee703267a4d5567c9a0545c9 @@ -39,6 +39,7 @@ | NEIGHBOUR_OUT | MERGE | DISAPPROVE + | TAGGED of string type relation = PARENT | CHILD ============================================================ --- viz_types.mli c3524724d488bbf3da18ba9de56ab98d9a08599f +++ viz_types.mli 2f027d5caef8b2f45a32eea1e3e165894f4437b5 @@ -42,6 +42,7 @@ | NEIGHBOUR_OUT | MERGE | DISAPPROVE + | TAGGED of string type relation = PARENT | CHILD