@@ -398,6 +398,8 @@ sub get_tree_menu_items {
398398 ( map {$self -> get_tree_menu_item($_ )}
399399 qw / plot_branches_by
400400 highlight_groups_on_map
401+ highlight_groups_on_map_convex_hull
402+ highlight_groups_on_map_circumcircle
401403 highlight_paths_on_tree
402404 separator
403405 background_colour
@@ -892,6 +894,133 @@ sub on_highlight_groups_on_map_changed {
892894 return ;
893895}
894896
897+ sub set_highlight_label_range_convex_hulls {
898+ my ($self , $value ) = @_ ;
899+
900+ $self -> {highlight_label_range_convex_hulls } = !!$value ;
901+
902+ return ;
903+ }
904+
905+ sub toggle_highlight_label_range_convex_hulls {
906+ my ($self , $value ) = @_ ;
907+
908+ $self -> {highlight_label_range_convex_hulls }
909+ = !$self -> {highlight_label_range_convex_hulls };
910+ }
911+
912+ sub get_highlight_label_range_convex_hulls {
913+ $_ [0]-> {highlight_label_range_convex_hulls };
914+ }
915+
916+ sub set_highlight_label_range_circumcircles {
917+ my ($self , $value ) = @_ ;
918+
919+ $self -> {highlight_label_range_circumcircles } = !!$value ;
920+
921+ return ;
922+ }
923+
924+ sub toggle_highlight_label_range_circumcircles {
925+ my ($self , $value ) = @_ ;
926+
927+ $self -> {highlight_label_range_circumcircles }
928+ = !$self -> {highlight_label_range_circumcircles };
929+ }
930+
931+ sub get_highlight_label_range_circumcircles {
932+ $_ [0]-> {highlight_label_range_circumcircles };
933+ }
934+
935+ sub highlight_label_range_convex_hulls {
936+ my ($self , $node ) = @_ ;
937+
938+ return if !$self -> get_highlight_label_range_convex_hulls;
939+
940+ my $terminal_elements = $node -> get_terminal_elements;
941+
942+ my $bd = $self -> get_base_ref;
943+ my $label_hash = $bd -> get_labels_ref-> get_element_hash;
944+
945+ # clear existing
946+ $self -> {grid }-> clear_range_convex_hulls;
947+
948+ my $cache = $bd -> get_cached_value_dor_set_default_href(' LABEL_RANGE_CONVEX_HULL_VERTICES' );
949+
950+ foreach my $label (keys %$terminal_elements ) {
951+ next LABEL if !exists $label_hash -> {$label };
952+ my $data
953+ = $cache -> {$label }
954+ / /= $bd ->get_label_range_convex_hull(label => $label )->GetPoints(0, 0);
955+ $self ->{grid}->set_overlay(
956+ type => 'polyline',
957+ cb_target => 'range_convex_hulls',
958+ plot_on_top => 1,
959+ data => $data ,
960+ colour => COLOUR_BLACK,
961+ alpha => 0.5,
962+ );
963+ }
964+ }
965+
966+ sub highlight_label_range_circumcircles {
967+ my ($self , $node ) = @_ ;
968+
969+ return if !$self ->get_highlight_label_range_circumcircles;
970+
971+ my $terminal_elements = $node ->get_terminal_elements;
972+
973+ my $bd = $self ->get_base_ref;
974+ my $label_hash = $bd ->get_labels_ref->get_element_hash;
975+
976+ # clear existing
977+ $self ->{grid}->clear_range_circumcircles;
978+
979+ foreach my $label (keys %$terminal_elements ) {
980+ next LABEL if !exists $label_hash ->{$label };
981+ my $data = $bd ->get_label_range_circumcircle(label => $label );
982+ $self ->{grid}->set_overlay(
983+ type => 'polyline',
984+ cb_target => 'range_circumcircles',
985+ plot_on_top => 1,
986+ data => $data ,
987+ colour => COLOUR_BLACK,
988+ alpha => 0.5,
989+ );
990+ }
991+ }
992+
993+ sub highlight_label_range_marks {
994+ my ($self , $node ) = @_ ;
995+
996+ my $terminal_elements = (defined $node ) ? $node ->get_terminal_elements : {};
997+
998+ # Hash of groups that have the selected labels
999+ my %groups ;
1000+
1001+ my $bd = $self ->get_base_ref;
1002+ my $label_hash = $bd ->get_labels_ref->get_element_hash;
1003+ my $max_groups = $bd ->get_group_count;
1004+
1005+ LABEL:
1006+ foreach my $label (keys %$terminal_elements ) {
1007+ next LABEL if !exists $label_hash ->{$label };
1008+
1009+ my $containing = eval {$bd ->get_groups_with_label_as_hash_aa($label )};
1010+ next LABEL if !$containing ;
1011+
1012+ @groups {keys %$containing } = ();
1013+
1014+ last LABEL if $max_groups == scalar keys %groups ;
1015+ }
1016+
1017+ $self ->{grid}->mark_with_circles ( [keys %groups ] );
1018+ $self ->{grid}->mark_with_dashes ( [] ); # clear any nbr_set2 highlights
1019+
1020+ return;
1021+ }
1022+
1023+
8951024sub on_selected_matrix_changed {
8961025 my ($self , %args ) = @_ ;
8971026
@@ -1438,6 +1567,8 @@ sub on_end_phylogeny_hover {
14381567
14391568 return if !$self -> do_canvas_hover_flag;
14401569
1570+ $self -> {grid }-> clear_range_convex_hulls;
1571+ $self -> {grid }-> clear_range_circumcircles;
14411572 $self -> {grid }-> mark_with_circles;
14421573}
14431574
@@ -1446,28 +1577,13 @@ sub on_end_phylogeny_hover {
14461577sub on_phylogeny_highlight {
14471578 my ($self , $node ) = @_ ;
14481579
1449- return if !$self -> do_canvas_hover_flag;
1450-
1451- my $terminal_elements = (defined $node ) ? $node -> get_terminal_elements : {};
1452-
1453- # Hash of groups that have the selected labels
1454- my %groups ;
1455- my ($iter , $label , $hash );
1580+ return if !$node ;
14561581
1457- my $bd = $self -> {base_ref };
1458- my $label_hash = $bd -> get_labels_ref-> get_element_hash;
1459-
1460- LABEL:
1461- foreach my $label (keys %$terminal_elements ) {
1462- next LABEL if !exists $label_hash -> {$label };
1463-
1464- my $containing = eval {$bd -> get_groups_with_label_as_hash(label => $label )};
1465- next LABEL if !$containing ;
1466-
1467- @groups {keys %$containing } = ();
1468- }
1582+ return if !$self -> do_canvas_hover_flag;
14691583
1470- $self -> {grid }-> mark_with_circles ( [keys %groups ] );
1584+ $self -> highlight_label_range_marks($node );
1585+ $self -> highlight_label_range_convex_hulls($node );
1586+ $self -> highlight_label_range_circumcircles($node );
14711587
14721588 if (defined $node ) {
14731589 my $text = ' Node: ' . $node -> get_name;
0 commit comments