Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pfff_visual: support for layer display at macrolevel!

  • Loading branch information...
commit fd6f37e7262062807bd2dc20cc603dfb4b8de3ba 1 parent 3c37503
pad authored
View
2  main_sgrep.ml
@@ -105,7 +105,7 @@ let gen_layer ~root file =
let lines = Common.uniq lines in
(file, { Layer_code.
micro_level = (lines +> List.map (fun l -> l, "m"));
- macro_level = [];
+ macro_level = if null lines then [] else ["m", 1.];
})
);
}
View
29 visual/draw_macrolevel.ml
@@ -55,6 +55,7 @@ let draw_treemap_rectangle2 ~cr ?(color=None) ?(alpha=1.) rect =
Cairo.line_to cr r.q.x r.p.y;
Cairo.line_to cr r.q.x r.q.y;
Cairo.line_to cr r.p.x r.q.y;
+
Cairo.fill cr;
()
@@ -65,6 +66,34 @@ let draw_treemap_rectangle ~cr ?color ?alpha a =
(*****************************************************************************)
+(* Layers macrolevel *)
+(*****************************************************************************)
+
+let draw_trect_using_layers ~cr layers_with_index rect =
+ let _r = rect.T.tr_rect in
+
+ let is_file = not rect.T.tr_is_node in
+ let color = if is_file then "white" else "black" in
+
+ draw_treemap_rectangle ~cr ~color:(Some color) rect;
+
+ if is_file then begin
+ let file = rect.T.tr_label in
+
+ let color_info =
+ try Hashtbl.find layers_with_index.Layer_code.macro_index file
+ with Not_found -> []
+ in
+ (* TODO what to draw ? a splitted rectangle ?
+ * For now the last win ...
+ *)
+ color_info +> List.iter (fun (float, color) ->
+ draw_treemap_rectangle ~cr ~color:(Some color) rect;
+ );
+ end
+
+
+(*****************************************************************************)
(* File Summary *)
(*****************************************************************************)
View
6 visual/draw_macrolevel.mli
@@ -9,4 +9,10 @@ val draw_treemap_rectangle :
unit
(*e: draw_treemap_rectangle sig *)
+val draw_trect_using_layers:
+ cr:Cairo.t ->
+ Layer_code.layers_with_index ->
+ Treemap.treemap_rectangle ->
+ unit
+
(*e: draw_macrolevel.mli *)
View
14 visual/draw_microlevel.ml
@@ -238,11 +238,15 @@ let draw_content2 ~cr ~layout ~context ~file rect =
| n when n <= 10 -> 0.6
| _ -> 0.3
in
- Draw_macrolevel.draw_treemap_rectangle ~cr ~color:(Some "DarkSlateGray")
- ~alpha rect;
- (* draw a thin rectangle with aspect color *)
- CairoH.draw_rectangle_bis ~cr ~color:(rect.T.tr_color)
- ~line_width:(font_size / 2.) rect.T.tr_rect;
+ (* unset when used when debugging the layering display *)
+ if Hashtbl.length context.layers_microlevel = 0 || true
+ then begin
+ Draw_macrolevel.draw_treemap_rectangle ~cr ~color:(Some "DarkSlateGray")
+ ~alpha rect;
+ (* draw a thin rectangle with aspect color *)
+ CairoH.draw_rectangle_bis ~cr ~color:(rect.T.tr_color)
+ ~line_width:(font_size / 2.) rect.T.tr_rect;
+ end;
end;
(* highlighting layers (and grep-like queries) *)
View
40 visual/view_mainmap.ml
@@ -30,7 +30,7 @@ module CairoH = Cairo_helpers
module Flag = Flag_visual
open Model2
-module Controller = Controller2
+module Ctl = Controller2
(*****************************************************************************)
(* Prelude *)
@@ -119,25 +119,23 @@ let lazy_paint ~user_rect dw () =
pr2 "Lazy Paint";
let start = Unix.gettimeofday () in
while Unix.gettimeofday () - start < 0.3 do
- match !Controller.current_rects_to_draw with
+ match !Ctl.current_rects_to_draw with
| [] -> ()
| x::xs ->
- Controller.current_rects_to_draw := xs;
+ Ctl.current_rects_to_draw := xs;
pr2 (spf "Drawing: %s" (x.T.tr_label));
paint_content_maybe_rect ~user_rect dw x;
done;
- !Controller._refresh_da ();
- if !Controller.current_rects_to_draw = []
+ !Ctl._refresh_da ();
+ if !Ctl.current_rects_to_draw = []
then false
else true
let paint2 dw =
- !Controller.paint_content_maybe_refresher +> Common.do_option (fun x ->
- GMain.Idle.remove x;
- );
- Controller.current_rects_to_draw := [];
+ !Ctl.paint_content_maybe_refresher +> Common.do_option GMain.Idle.remove;
+ Ctl.current_rects_to_draw := [];
let cr = Cairo_lablgtk.create dw.pm#pixmap in
dw.pm#rectangle
@@ -155,21 +153,25 @@ let paint2 dw =
let rects = dw.treemap in
let nb_rects = dw.nb_rects in
- (* phase 1, draw the rectangles *)
- rects +> List.iter (Draw_macrolevel.draw_treemap_rectangle ~cr);
+ (if null dw.layers.Layer_code.layers
+ then
+ (* phase 1, draw the rectangles *)
+ rects +> List.iter (Draw_macrolevel.draw_treemap_rectangle ~cr)
+ else
+ rects +> List.iter (Draw_macrolevel.draw_trect_using_layers ~cr dw.layers)
+ );
(* phase 2, draw the labels, if have enough space *)
- rects +> List.iter
- (Draw_labels.draw_treemap_rectangle_label_maybe
- ~cr ~zoom:dw.zoom ~color:None);
+ rects +> List.iter (Draw_labels.draw_treemap_rectangle_label_maybe
+ ~cr ~zoom:dw.zoom ~color:None);
(* phase 3, draw the content, if have enough space *)
if not dw.in_dragging && nb_rects < !Flag.threshold_nb_rects_draw_content
(* draw_content_maybe calls nblines which is quite expensive so
* want to limit it *)
then begin
- Controller.current_rects_to_draw := rects;
- Controller.paint_content_maybe_refresher :=
+ Ctl.current_rects_to_draw := rects;
+ Ctl.paint_content_maybe_refresher :=
Some (Gui.gmain_idle_add ~prio:3000 (lazy_paint ~user_rect dw));
end;
@@ -242,7 +244,7 @@ let key_pressed (da, da2) dw_ref ev =
true
| k when k = K._b ->
- !Controller._go_back dw_ref;
+ !Ctl._go_back dw_ref;
true
| k when k = K._e ->
@@ -355,7 +357,7 @@ let button_action da dw_ref ev =
r_opt +> Common.do_option (fun (r, _, _r_englobing) ->
let path = r.T.tr_label in
- !Controller._go_dirs_or_file dw_ref [path];
+ !Ctl._go_dirs_or_file dw_ref [path];
);
true
| _ -> false
@@ -379,7 +381,7 @@ let button_action da dw_ref ev =
r_opt +> Common.do_option (fun (_r, _, r_englobing) ->
let path = r_englobing.T.tr_label in
- !Controller._go_dirs_or_file dw_ref [path];
+ !Ctl._go_dirs_or_file dw_ref [path];
);
true
Please sign in to comment.
Something went wrong with that request. Please try again.