@@ -399,6 +399,7 @@ sub get_tree_menu_items {
399399 qw / plot_branches_by
400400 highlight_groups_on_map
401401 highlight_groups_on_map_convex_hull
402+ highlight_groups_on_map_convex_hull_union
402403 highlight_groups_on_map_circumcircle
403404 highlight_paths_on_tree
404405 separator
@@ -913,6 +914,25 @@ sub get_highlight_label_range_convex_hulls {
913914 $_ [0]-> {highlight_label_range_convex_hulls };
914915}
915916
917+ sub set_highlight_label_range_convex_hull_union {
918+ my ($self , $value ) = @_ ;
919+
920+ $self -> {highlight_label_range_convex_hull_union } = !!$value ;
921+
922+ return ;
923+ }
924+
925+ sub toggle_highlight_label_range_convex_hull_union {
926+ my ($self , $value ) = @_ ;
927+
928+ $self -> {highlight_label_range_convex_hull_union }
929+ = !$self -> {highlight_label_range_convex_hull_union };
930+ }
931+
932+ sub get_highlight_label_range_convex_hull_union {
933+ $_ [0]-> {highlight_label_range_convex_hull_union };
934+ }
935+
916936sub set_highlight_label_range_circumcircles {
917937 my ($self , $value ) = @_ ;
918938
@@ -963,6 +983,45 @@ sub highlight_label_range_convex_hulls {
963983 }
964984}
965985
986+ sub highlight_label_range_convex_hull_union {
987+ my ($self , $node ) = @_ ;
988+
989+ return if !$self ->get_highlight_label_range_convex_hull_union;
990+
991+ my $terminal_elements = $node ->get_terminal_elements;
992+
993+ my $bd = $self ->get_base_ref;
994+ my $label_hash = $bd ->get_labels_ref->get_element_hash;
995+
996+ # clear existing
997+ $self ->{grid}->clear_range_convex_hulls;
998+
999+ my $cache = $bd ->get_cached_value_dor_set_default_href('LABEL_RANGE_CONVEX_HULL_VERTICES');
1000+
1001+ my $hull_union = $cache ->{$node ->get_name};
1002+ if (!$hull_union ) {
1003+ # could climb up the tree if this takes too long
1004+ foreach my $label (keys %$terminal_elements ) {
1005+ next LABEL if !exists $label_hash ->{$label };
1006+ my $hull = $bd ->get_label_range_convex_hull(label => $label );
1007+ $hull_union = $hull_union ? $hull_union ->Union ($hull ) : $hull ;
1008+ }
1009+ $cache ->{$node ->get_name} = $hull_union ;
1010+ }
1011+
1012+ # avoid plotting empties
1013+ if (defined $hull_union ) {
1014+ $self ->{grid}->set_overlay(
1015+ type => 'polyline',
1016+ cb_target => 'range_convex_hulls',
1017+ plot_on_top => 1,
1018+ data => scalar $hull_union ->GetPoints(0, 0),
1019+ colour => COLOUR_BLACK,
1020+ alpha => 0.5,
1021+ );
1022+ }
1023+ }
1024+
9661025sub highlight_label_range_circumcircles {
9671026 my ($self , $node ) = @_ ;
9681027
@@ -1583,6 +1642,7 @@ sub on_phylogeny_highlight {
15831642
15841643 $self -> highlight_label_range_marks($node );
15851644 $self -> highlight_label_range_convex_hulls($node );
1645+ $self -> highlight_label_range_convex_hull_union($node );
15861646 $self -> highlight_label_range_circumcircles($node );
15871647
15881648 if (defined $node ) {
0 commit comments