From 8d0c989e02ae3b313884a23e6a7f3b88592ed7d6 Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 16:03:57 +1100 Subject: [PATCH 1/9] Test that a basedata can be trimmed using another basedata --- t/11-BaseData.t | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/t/11-BaseData.t b/t/11-BaseData.t index 5037c0c73..f72f35dce 100644 --- a/t/11-BaseData.t +++ b/t/11-BaseData.t @@ -1908,6 +1908,36 @@ sub _test_rename_labels_or_groups { } +sub test_trim_with_basedata { + my $bd = Biodiverse::BaseData->new ( + NAME => 'trim_base', CELL_SIZES => [2, 2], + ); + my $bd2 = Biodiverse::BaseData->new ( + NAME => 'trim2', CELL_SIZES => [2, 2], + ); + + foreach my $label ('a' .. 'z') { + $bd->add_element (label => $label, group => '1:1'); + } + foreach my $label ('a' .. 'k') { + $bd2->add_element (label => $label, group => '1:1'); + } + + { + my $bd_trim1 = $bd->clone; + $bd_trim1->trim(trim => $bd2); + my @expected = ('l' .. 'z'); + my @labels = sort $bd_trim1->get_labels; + is \@labels, \@expected, 'Expected labels after trimming with trim option'; + } + { + my $bd_trim2 = $bd->clone; + $bd_trim2->trim(keep => $bd2); + my @expected = ('a' .. 'k'); + my @labels = sort $bd_trim2->get_labels; + is \@labels, \@expected, 'Expected labels after trimming with keep option'; + } +} # reordering of axes sub test_reorder_axes { From 7427a2e9ed6b0d74f036933f6d35e588c643f7aa Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 17:53:58 +1100 Subject: [PATCH 2/9] GUI: Support trimming a basedata using a second basedata --- bin/ui/wndMain.ui | 9 ++++ lib/Biodiverse/GUI/Callbacks.pm | 4 ++ lib/Biodiverse/GUI/GUIManager.pm | 85 ++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/bin/ui/wndMain.ui b/bin/ui/wndMain.ui index 83f06fbe0..8dbc13de4 100644 --- a/bin/ui/wndMain.ui +++ b/bin/ui/wndMain.ui @@ -310,6 +310,14 @@ Skips any matrices already in the project. + + + menu_trim_basedata_to_match_basedata + Remove BaseData labels not in a selected basedata + Trim to match basedata + + + menu_trim_basedata_to_match_tree @@ -783,6 +791,7 @@ This cannot be undone. + diff --git a/lib/Biodiverse/GUI/Callbacks.pm b/lib/Biodiverse/GUI/Callbacks.pm index d1159bf14..d1d1cefeb 100644 --- a/lib/Biodiverse/GUI/Callbacks.pm +++ b/lib/Biodiverse/GUI/Callbacks.pm @@ -267,6 +267,10 @@ my %data_funcs = ( on_basedata_extract_embedded_matrices => { METHOD => 'do_basedata_extract_embedded_matrices', }, + on_basedata_trim_to_match_basedata => { + METHOD => 'do_basedata_trim_to_basedata', + ARGS => { option => 'keep' }, + }, on_basedata_trim_to_match_tree => { METHOD => 'do_basedata_trim_to_tree', ARGS => { option => 'keep' }, diff --git a/lib/Biodiverse/GUI/GUIManager.pm b/lib/Biodiverse/GUI/GUIManager.pm index bf5fd0b90..228ac38a9 100644 --- a/lib/Biodiverse/GUI/GUIManager.pm +++ b/lib/Biodiverse/GUI/GUIManager.pm @@ -1740,6 +1740,91 @@ sub do_range_weight_tree { ); } +sub do_basedata_trim_to_basedata { + my $self = shift; + my %args = @_; + + my $project = $self->get_project; + + my $bd = $project->get_selected_base_data || return 0; + + my @trim_sources + = grep {$_ != $bd} (@{ $project->get_base_data_list }); + + my $trim_combo = Gtk2::ComboBox->new_text; + my $controller_combo = Gtk2::ComboBox->new_text; + + my $source_tooltip = 'Choose a data source to trim from'; + foreach my $object (@trim_sources) { + $trim_combo->append_text($object->get_name); + } + $trim_combo->set_active(0); + $trim_combo->show_all; + $trim_combo->set_tooltip_text ($source_tooltip); + + my $label = Gtk2::Label->new('Source basedata: '); + $label->set_tooltip_text ($source_tooltip); + my $select_hbox = Gtk2::HBox->new; + $select_hbox->pack_start($label, 0, 0, 0); + $select_hbox->pack_start($trim_combo, 0, 0, 0); + $select_hbox->show_all; + + my $chk_tooltip = 'Delete any matching labels (inverts the default)'; + my $chk_label = Gtk2::Label->new('Delete matching?'); + my $chk = Gtk2::CheckButton->new; + my $chk_hbox = Gtk2::HBox->new; + $chk_hbox->pack_start($chk_label, 0, 0, 0); + $chk_hbox->pack_start($chk, 0, 0, 0); + $chk->set_tooltip_text($chk_tooltip); + $chk_label->set_tooltip_text($chk_tooltip); + $chk_hbox->show_all; + + # Show the Get Name dialog + my ( $dlgxml, $dlg ) = $self->get_dlg_duplicate(); + $dlg->set_transient_for( $self->get_object('wndMain') ); + + my $vbox = $dlg->get_content_area; + $vbox->pack_start( $select_hbox, 0, 0, 0 ); + $vbox->pack_start( $chk_hbox, 0, 0, 0 ); + + my $suffix = $args{suffix} || 'TRIMMED'; + + my $txt_name = $dlgxml->get_object('txtName'); + my $name = $bd->get_name; + # If ends with _TRIMMED followed by a number then increment it + if ( $name =~ /(.*_$suffix)([0-9]+)$/ ) { + $name = $1 . ( $2 + 1 ); + } + else { + $name .= "_${suffix}1"; + } + $txt_name->set_text($name); + + my $response = $dlg->run(); + my $chosen_name = $txt_name->get_text; + my $other_bd_iter = $trim_combo->get_active; + my $delete_matching = $chk->get_active; + + $dlg->destroy; + + return if $response ne 'ok'; # they chickened out + + my $other_bd =$trim_sources[$other_bd_iter]; + + my $new_bd = $bd->clone (no_outputs => 1); + my $arg_key = $delete_matching ? 'trim' : 'keep'; + say STDERR "arg_key is $arg_key"; + $new_bd->trim ($arg_key => $other_bd); + + $new_bd->delete_cached_values; + + $new_bd->set_param( NAME => $chosen_name ); + + $project->add_base_data( $new_bd, 0 ); + + return; +} + # Should probably rename this sub as it is being used for more purposes, # some of which do not involve trimming. sub do_trim_tree_to_basedata { From 0d1c7cb62206a18831235d2ea940d692b0a39139 Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 18:11:50 +1100 Subject: [PATCH 3/9] GUI Basedata trimming: use unified call --- lib/Biodiverse/GUI/GUIManager.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Biodiverse/GUI/GUIManager.pm b/lib/Biodiverse/GUI/GUIManager.pm index 228ac38a9..eaf001dd5 100644 --- a/lib/Biodiverse/GUI/GUIManager.pm +++ b/lib/Biodiverse/GUI/GUIManager.pm @@ -1812,9 +1812,8 @@ sub do_basedata_trim_to_basedata { my $other_bd =$trim_sources[$other_bd_iter]; my $new_bd = $bd->clone (no_outputs => 1); - my $arg_key = $delete_matching ? 'trim' : 'keep'; - say STDERR "arg_key is $arg_key"; - $new_bd->trim ($arg_key => $other_bd); + my $option = $delete_matching ? 'trim' : 'keep'; + $self->do_trim_basedata ($new_bd, $other_bd, option => $option); $new_bd->delete_cached_values; From 756c9e4ecb212cad9a6e94fc885ebfcb57949abf Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 18:13:24 +1100 Subject: [PATCH 4/9] GUI Basedata trimming: relocate method --- lib/Biodiverse/GUI/GUIManager.pm | 83 ------------------------ lib/Biodiverse/GUI/Manager/BaseDatas.pm | 84 +++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 83 deletions(-) diff --git a/lib/Biodiverse/GUI/GUIManager.pm b/lib/Biodiverse/GUI/GUIManager.pm index eaf001dd5..f7fa949f8 100644 --- a/lib/Biodiverse/GUI/GUIManager.pm +++ b/lib/Biodiverse/GUI/GUIManager.pm @@ -1740,89 +1740,6 @@ sub do_range_weight_tree { ); } -sub do_basedata_trim_to_basedata { - my $self = shift; - my %args = @_; - - my $project = $self->get_project; - - my $bd = $project->get_selected_base_data || return 0; - - my @trim_sources - = grep {$_ != $bd} (@{ $project->get_base_data_list }); - - my $trim_combo = Gtk2::ComboBox->new_text; - my $controller_combo = Gtk2::ComboBox->new_text; - - my $source_tooltip = 'Choose a data source to trim from'; - foreach my $object (@trim_sources) { - $trim_combo->append_text($object->get_name); - } - $trim_combo->set_active(0); - $trim_combo->show_all; - $trim_combo->set_tooltip_text ($source_tooltip); - - my $label = Gtk2::Label->new('Source basedata: '); - $label->set_tooltip_text ($source_tooltip); - my $select_hbox = Gtk2::HBox->new; - $select_hbox->pack_start($label, 0, 0, 0); - $select_hbox->pack_start($trim_combo, 0, 0, 0); - $select_hbox->show_all; - - my $chk_tooltip = 'Delete any matching labels (inverts the default)'; - my $chk_label = Gtk2::Label->new('Delete matching?'); - my $chk = Gtk2::CheckButton->new; - my $chk_hbox = Gtk2::HBox->new; - $chk_hbox->pack_start($chk_label, 0, 0, 0); - $chk_hbox->pack_start($chk, 0, 0, 0); - $chk->set_tooltip_text($chk_tooltip); - $chk_label->set_tooltip_text($chk_tooltip); - $chk_hbox->show_all; - - # Show the Get Name dialog - my ( $dlgxml, $dlg ) = $self->get_dlg_duplicate(); - $dlg->set_transient_for( $self->get_object('wndMain') ); - - my $vbox = $dlg->get_content_area; - $vbox->pack_start( $select_hbox, 0, 0, 0 ); - $vbox->pack_start( $chk_hbox, 0, 0, 0 ); - - my $suffix = $args{suffix} || 'TRIMMED'; - - my $txt_name = $dlgxml->get_object('txtName'); - my $name = $bd->get_name; - # If ends with _TRIMMED followed by a number then increment it - if ( $name =~ /(.*_$suffix)([0-9]+)$/ ) { - $name = $1 . ( $2 + 1 ); - } - else { - $name .= "_${suffix}1"; - } - $txt_name->set_text($name); - - my $response = $dlg->run(); - my $chosen_name = $txt_name->get_text; - my $other_bd_iter = $trim_combo->get_active; - my $delete_matching = $chk->get_active; - - $dlg->destroy; - - return if $response ne 'ok'; # they chickened out - - my $other_bd =$trim_sources[$other_bd_iter]; - - my $new_bd = $bd->clone (no_outputs => 1); - my $option = $delete_matching ? 'trim' : 'keep'; - $self->do_trim_basedata ($new_bd, $other_bd, option => $option); - - $new_bd->delete_cached_values; - - $new_bd->set_param( NAME => $chosen_name ); - - $project->add_base_data( $new_bd, 0 ); - - return; -} # Should probably rename this sub as it is being used for more purposes, # some of which do not involve trimming. diff --git a/lib/Biodiverse/GUI/Manager/BaseDatas.pm b/lib/Biodiverse/GUI/Manager/BaseDatas.pm index c10a35b0b..1ed21e5ce 100644 --- a/lib/Biodiverse/GUI/Manager/BaseDatas.pm +++ b/lib/Biodiverse/GUI/Manager/BaseDatas.pm @@ -1182,6 +1182,90 @@ sub do_basedata_trim_to_matrix { return; } +sub do_basedata_trim_to_basedata { + my $self = shift; + my %args = @_; + + my $project = $self->get_project; + + my $bd = $project->get_selected_base_data || return 0; + + my @trim_sources + = grep {$_ != $bd} (@{ $project->get_base_data_list }); + + my $trim_combo = Gtk2::ComboBox->new_text; + my $controller_combo = Gtk2::ComboBox->new_text; + + my $source_tooltip = 'Choose a data source to trim from'; + foreach my $object (@trim_sources) { + $trim_combo->append_text($object->get_name); + } + $trim_combo->set_active(0); + $trim_combo->show_all; + $trim_combo->set_tooltip_text ($source_tooltip); + + my $label = Gtk2::Label->new('Source basedata: '); + $label->set_tooltip_text ($source_tooltip); + my $select_hbox = Gtk2::HBox->new; + $select_hbox->pack_start($label, 0, 0, 0); + $select_hbox->pack_start($trim_combo, 0, 0, 0); + $select_hbox->show_all; + + my $chk_tooltip = 'Delete any matching labels (inverts the default)'; + my $chk_label = Gtk2::Label->new('Delete matching?'); + my $chk = Gtk2::CheckButton->new; + my $chk_hbox = Gtk2::HBox->new; + $chk_hbox->pack_start($chk_label, 0, 0, 0); + $chk_hbox->pack_start($chk, 0, 0, 0); + $chk->set_tooltip_text($chk_tooltip); + $chk_label->set_tooltip_text($chk_tooltip); + $chk_hbox->show_all; + + # Show the Get Name dialog + my ( $dlgxml, $dlg ) = $self->get_dlg_duplicate(); + $dlg->set_transient_for( $self->get_object('wndMain') ); + + my $vbox = $dlg->get_content_area; + $vbox->pack_start( $select_hbox, 0, 0, 0 ); + $vbox->pack_start( $chk_hbox, 0, 0, 0 ); + + my $suffix = $args{suffix} || 'TRIMMED'; + + my $txt_name = $dlgxml->get_object('txtName'); + my $name = $bd->get_name; + # If ends with _TRIMMED followed by a number then increment it + if ( $name =~ /(.*_$suffix)([0-9]+)$/ ) { + $name = $1 . ( $2 + 1 ); + } + else { + $name .= "_${suffix}1"; + } + $txt_name->set_text($name); + + my $response = $dlg->run(); + my $chosen_name = $txt_name->get_text; + my $other_bd_iter = $trim_combo->get_active; + my $delete_matching = $chk->get_active; + + $dlg->destroy; + + return if $response ne 'ok'; # they chickened out + + my $other_bd =$trim_sources[$other_bd_iter]; + + my $new_bd = $bd->clone (no_outputs => 1); + my $option = $delete_matching ? 'trim' : 'keep'; + $self->do_trim_basedata ($new_bd, $other_bd, option => $option); + + $new_bd->delete_cached_values; + + $new_bd->set_param( NAME => $chosen_name ); + + $project->add_base_data( $new_bd, 0 ); + + return; +} + sub do_trim_basedata { my $self = shift; my $bd = shift; From a46b0ce714bd44caa853f825ccaa36a2b3a94cad Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 18:15:03 +1100 Subject: [PATCH 5/9] GUI basedata trimming: UI details --- bin/ui/wndMain.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ui/wndMain.ui b/bin/ui/wndMain.ui index 8dbc13de4..705c502ec 100644 --- a/bin/ui/wndMain.ui +++ b/bin/ui/wndMain.ui @@ -313,8 +313,8 @@ Skips any matrices already in the project. menu_trim_basedata_to_match_basedata - Remove BaseData labels not in a selected basedata - Trim to match basedata + Remove labels from the selected basedata using a second basedata + Trim using other basedata From 74ed7892b8bf3d8f830d149c02a302c1f91d9031 Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 18:49:19 +1100 Subject: [PATCH 6/9] GUI basedata trimming: Unify basedata, tree and matrix sources This generalises the interface. A future commit will remove the other options. --- bin/ui/wndMain.ui | 12 +++---- lib/Biodiverse/GUI/Callbacks.pm | 4 +-- lib/Biodiverse/GUI/Manager/BaseDatas.pm | 45 +++++++++++++++++++------ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/bin/ui/wndMain.ui b/bin/ui/wndMain.ui index 705c502ec..71fa1d02d 100644 --- a/bin/ui/wndMain.ui +++ b/bin/ui/wndMain.ui @@ -311,11 +311,11 @@ Skips any matrices already in the project. - - menu_trim_basedata_to_match_basedata - Remove labels from the selected basedata using a second basedata - Trim using other basedata - + + menu_trim_basedata_using_object + Remove labels from the selected basedata using a second basedata, tree or matrix + Trim using other object + @@ -791,7 +791,7 @@ This cannot be undone. - + diff --git a/lib/Biodiverse/GUI/Callbacks.pm b/lib/Biodiverse/GUI/Callbacks.pm index d1d1cefeb..8664f4ed4 100644 --- a/lib/Biodiverse/GUI/Callbacks.pm +++ b/lib/Biodiverse/GUI/Callbacks.pm @@ -267,8 +267,8 @@ my %data_funcs = ( on_basedata_extract_embedded_matrices => { METHOD => 'do_basedata_extract_embedded_matrices', }, - on_basedata_trim_to_match_basedata => { - METHOD => 'do_basedata_trim_to_basedata', + on_basedata_trim_using_object => { + METHOD => 'do_basedata_trim_using_object', ARGS => { option => 'keep' }, }, on_basedata_trim_to_match_tree => { diff --git a/lib/Biodiverse/GUI/Manager/BaseDatas.pm b/lib/Biodiverse/GUI/Manager/BaseDatas.pm index 1ed21e5ce..6a8c17a1d 100644 --- a/lib/Biodiverse/GUI/Manager/BaseDatas.pm +++ b/lib/Biodiverse/GUI/Manager/BaseDatas.pm @@ -1182,7 +1182,7 @@ sub do_basedata_trim_to_matrix { return; } -sub do_basedata_trim_to_basedata { +sub do_basedata_trim_using_object { my $self = shift; my %args = @_; @@ -1190,21 +1190,30 @@ sub do_basedata_trim_to_basedata { my $bd = $project->get_selected_base_data || return 0; - my @trim_sources + my @bd_sources = grep {$_ != $bd} (@{ $project->get_base_data_list }); + my @matrix_sources = @{ $project->get_matrix_list }; + my @tree_sources = @{ $project->get_phylogeny_list }; + my @trim_sources = (@bd_sources, @matrix_sources, @tree_sources); my $trim_combo = Gtk2::ComboBox->new_text; my $controller_combo = Gtk2::ComboBox->new_text; - my $source_tooltip = 'Choose a data source to trim from'; - foreach my $object (@trim_sources) { - $trim_combo->append_text($object->get_name); + my $source_tooltip = 'Choose a data source to trim with'; + foreach my $object (@bd_sources) { + $trim_combo->append_text("Basedata: " . $object->get_name); + } + foreach my $object (@matrix_sources) { + $trim_combo->append_text("Matrix: " . $object->get_name); + } + foreach my $object (@tree_sources) { + $trim_combo->append_text("Tree: " . $object->get_name); } $trim_combo->set_active(0); $trim_combo->show_all; $trim_combo->set_tooltip_text ($source_tooltip); - my $label = Gtk2::Label->new('Source basedata: '); + my $label = Gtk2::Label->new('Label source: '); $label->set_tooltip_text ($source_tooltip); my $select_hbox = Gtk2::HBox->new; $select_hbox->pack_start($label, 0, 0, 0); @@ -1221,11 +1230,25 @@ sub do_basedata_trim_to_basedata { $chk_label->set_tooltip_text($chk_tooltip); $chk_hbox->show_all; + my $tooltip_clone + = "Clone basedata first (required if basedata contains outputs).\n" + . 'New name is ignored if this is off.'; + my $label_clone = Gtk2::Label->new('Trim a clone'); + my $chk_clone = Gtk2::CheckButton->new; + $chk_clone->set_active(1); + my $hbox_clone = Gtk2::HBox->new; + $hbox_clone->pack_start($label_clone, 0, 0, 0); + $hbox_clone->pack_start($chk_clone, 0, 0, 0); + $chk_clone->set_tooltip_text($tooltip_clone); + $label_clone->set_tooltip_text($tooltip_clone); + $hbox_clone->show_all; + # Show the Get Name dialog my ( $dlgxml, $dlg ) = $self->get_dlg_duplicate(); $dlg->set_transient_for( $self->get_object('wndMain') ); my $vbox = $dlg->get_content_area; + $vbox->pack_start( $hbox_clone, 0, 0, 0 ); $vbox->pack_start( $select_hbox, 0, 0, 0 ); $vbox->pack_start( $chk_hbox, 0, 0, 0 ); @@ -1246,6 +1269,7 @@ sub do_basedata_trim_to_basedata { my $chosen_name = $txt_name->get_text; my $other_bd_iter = $trim_combo->get_active; my $delete_matching = $chk->get_active; + my $clone_first = $chk_clone->get_active; $dlg->destroy; @@ -1253,15 +1277,16 @@ sub do_basedata_trim_to_basedata { my $other_bd =$trim_sources[$other_bd_iter]; - my $new_bd = $bd->clone (no_outputs => 1); + my $new_bd = $clone_first ? $bd->clone (no_outputs => 1) : $bd; my $option = $delete_matching ? 'trim' : 'keep'; $self->do_trim_basedata ($new_bd, $other_bd, option => $option); $new_bd->delete_cached_values; - $new_bd->set_param( NAME => $chosen_name ); - - $project->add_base_data( $new_bd, 0 ); + if ($clone_first) { + $new_bd->set_param(NAME => $chosen_name); + $project->add_base_data( $new_bd, 0 ); + } return; } From 6816c532e6fac7070fd0b738bcedab2f06834119 Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 18:52:50 +1100 Subject: [PATCH 7/9] GUI basedata trimming: remove redundant options from interface We still need to clean up the methods. --- bin/ui/wndMain.ui | 38 +-------------------------------- lib/Biodiverse/GUI/Callbacks.pm | 32 +++++++++++++-------------- lib/Biodiverse/GUI/Project.pm | 5 +---- 3 files changed, 18 insertions(+), 57 deletions(-) diff --git a/bin/ui/wndMain.ui b/bin/ui/wndMain.ui index 71fa1d02d..7cd405433 100644 --- a/bin/ui/wndMain.ui +++ b/bin/ui/wndMain.ui @@ -314,42 +314,10 @@ Skips any matrices already in the project. menu_trim_basedata_using_object Remove labels from the selected basedata using a second basedata, tree or matrix - Trim using other object + Trim using other basedata, matrix or tree - - - menu_trim_basedata_to_match_tree - Remove BaseData labels not in the selected tree - Trim to match tree nodes - - - - - - menu_trim_basedata_to_match_matrix - Remove BaseData labels not in the selected matrix - Trim to match matrix elements - - - - - - menu_trim_basedata_using_tree - Trim BaseData labels that occur as nodes in the tree - Trim using tree nodes - - - - - - menu_trim_basedata_using_matrix - Trim BaseData labels that occur as elements in the matrix - Trim using matrix elements - - - menu_basedata_export_groups @@ -787,10 +755,6 @@ This cannot be undone. - - - - diff --git a/lib/Biodiverse/GUI/Callbacks.pm b/lib/Biodiverse/GUI/Callbacks.pm index 8664f4ed4..58587c5a8 100644 --- a/lib/Biodiverse/GUI/Callbacks.pm +++ b/lib/Biodiverse/GUI/Callbacks.pm @@ -271,22 +271,22 @@ my %data_funcs = ( METHOD => 'do_basedata_trim_using_object', ARGS => { option => 'keep' }, }, - on_basedata_trim_to_match_tree => { - METHOD => 'do_basedata_trim_to_tree', - ARGS => { option => 'keep' }, - }, - on_basedata_trim_to_match_matrix => { - METHOD => 'do_basedata_trim_to_matrix', - ARGS => { option => 'keep' }, - }, - on_basedata_trim_using_tree => { - METHOD => 'do_basedata_trim_to_tree', - ARGS => { option => 'trim' }, - }, - on_basedata_trim_using_matrix => { - METHOD => 'do_basedata_trim_to_matrix', - ARGS => { option => 'trim' }, - }, + # on_basedata_trim_to_match_tree => { + # METHOD => 'do_basedata_trim_to_tree', + # ARGS => { option => 'keep' }, + # }, + # on_basedata_trim_to_match_matrix => { + # METHOD => 'do_basedata_trim_to_matrix', + # ARGS => { option => 'keep' }, + # }, + # on_basedata_trim_using_tree => { + # METHOD => 'do_basedata_trim_to_tree', + # ARGS => { option => 'trim' }, + # }, + # on_basedata_trim_using_matrix => { + # METHOD => 'do_basedata_trim_to_matrix', + # ARGS => { option => 'trim' }, + # }, on_basedata_attach_properties => { METHOD => 'do_basedata_attach_properties', }, diff --git a/lib/Biodiverse/GUI/Project.pm b/lib/Biodiverse/GUI/Project.pm index bb2c44113..b287e13b6 100644 --- a/lib/Biodiverse/GUI/Project.pm +++ b/lib/Biodiverse/GUI/Project.pm @@ -1293,10 +1293,7 @@ sub manage_empty_basedatas { menu_delete_index menu_extract_embedded_trees menu_extract_embedded_matrices - menu_trim_basedata_to_match_tree - menu_trim_basedata_to_match_matrix - menu_trim_basedata_using_tree - menu_trim_basedata_using_matrix + menu_trim_basedata_using_object menu_rename_basedata_labels menu_rename_basedata_groups menu_attach_basedata_properties From 216ab23384c2795b0401e2ede787579d23f69b4a Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Mon, 23 Oct 2023 20:19:31 +1100 Subject: [PATCH 8/9] GUI basedata trimming: reinstate stand alone tree trimming This is relatively commonly used so is worth keeping as a distinct option. --- bin/ui/wndMain.ui | 9 +++++++++ lib/Biodiverse/GUI/Callbacks.pm | 8 ++++---- lib/Biodiverse/GUI/Manager/BaseDatas.pm | 26 ++++++++++++------------- lib/Biodiverse/GUI/Project.pm | 1 + 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/bin/ui/wndMain.ui b/bin/ui/wndMain.ui index 7cd405433..639a4a78c 100644 --- a/bin/ui/wndMain.ui +++ b/bin/ui/wndMain.ui @@ -318,6 +318,14 @@ Skips any matrices already in the project. + + + menu_trim_basedata_to_match_tree + Remove BaseData labels not in the selected tree + Trim to match tree nodes + + + menu_basedata_export_groups @@ -755,6 +763,7 @@ This cannot be undone. + diff --git a/lib/Biodiverse/GUI/Callbacks.pm b/lib/Biodiverse/GUI/Callbacks.pm index 58587c5a8..2aa4579cf 100644 --- a/lib/Biodiverse/GUI/Callbacks.pm +++ b/lib/Biodiverse/GUI/Callbacks.pm @@ -271,10 +271,10 @@ my %data_funcs = ( METHOD => 'do_basedata_trim_using_object', ARGS => { option => 'keep' }, }, - # on_basedata_trim_to_match_tree => { - # METHOD => 'do_basedata_trim_to_tree', - # ARGS => { option => 'keep' }, - # }, + on_basedata_trim_to_match_tree => { + METHOD => 'do_basedata_trim_to_tree', + ARGS => { option => 'keep' }, + }, # on_basedata_trim_to_match_matrix => { # METHOD => 'do_basedata_trim_to_matrix', # ARGS => { option => 'keep' }, diff --git a/lib/Biodiverse/GUI/Manager/BaseDatas.pm b/lib/Biodiverse/GUI/Manager/BaseDatas.pm index 6a8c17a1d..2b074c42e 100644 --- a/lib/Biodiverse/GUI/Manager/BaseDatas.pm +++ b/lib/Biodiverse/GUI/Manager/BaseDatas.pm @@ -1168,19 +1168,19 @@ sub do_basedata_trim_to_tree { return; } -sub do_basedata_trim_to_matrix { - my $self = shift; - my %args = @_; # keep or trim flag - - my $bd = $self->{project}->get_selected_base_data; - my $mx = $self->{project}->get_selected_matrix; - - return if !defined $bd || !defined $mx; - - $self->do_trim_basedata( $bd, $mx, %args ); - - return; -} +# sub do_basedata_trim_to_matrix { +# my $self = shift; +# my %args = @_; # keep or trim flag +# +# my $bd = $self->{project}->get_selected_base_data; +# my $mx = $self->{project}->get_selected_matrix; +# +# return if !defined $bd || !defined $mx; +# +# $self->do_trim_basedata( $bd, $mx, %args ); +# +# return; +# } sub do_basedata_trim_using_object { my $self = shift; diff --git a/lib/Biodiverse/GUI/Project.pm b/lib/Biodiverse/GUI/Project.pm index b287e13b6..db05e49e9 100644 --- a/lib/Biodiverse/GUI/Project.pm +++ b/lib/Biodiverse/GUI/Project.pm @@ -1293,6 +1293,7 @@ sub manage_empty_basedatas { menu_delete_index menu_extract_embedded_trees menu_extract_embedded_matrices + menu_trim_basedata_using_tree menu_trim_basedata_using_object menu_rename_basedata_labels menu_rename_basedata_groups From 8f5c7994bb279f42c45defc3389b9a925fd6dad1 Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Tue, 24 Oct 2023 18:27:12 +1100 Subject: [PATCH 9/9] Reinstate inactive basedata menu hide label --- lib/Biodiverse/GUI/Project.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Biodiverse/GUI/Project.pm b/lib/Biodiverse/GUI/Project.pm index db05e49e9..22fa6a5f0 100644 --- a/lib/Biodiverse/GUI/Project.pm +++ b/lib/Biodiverse/GUI/Project.pm @@ -1293,7 +1293,7 @@ sub manage_empty_basedatas { menu_delete_index menu_extract_embedded_trees menu_extract_embedded_matrices - menu_trim_basedata_using_tree + menu_trim_basedata_to_match_tree menu_trim_basedata_using_object menu_rename_basedata_labels menu_rename_basedata_groups