Skip to content

Commit

Permalink
Use "multiselect", not "sequential", in the code
Browse files Browse the repository at this point in the history
Sequential was a place holder.

Updates #600
  • Loading branch information
shawnlaffan committed Sep 12, 2016
1 parent 5aba21a commit fad2521
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
80 changes: 40 additions & 40 deletions lib/Biodiverse/GUI/Dendrogram.pm
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ sub do_colour_nodes_below {

if ($self->in_multiselect_mode) {
# we need a hash of the terminals
# (sequential only has one node)
# (multiselect only has one node)
$terminal_element_hash_ref = $colour_nodes[0]->get_terminal_elements;
}

Expand Down Expand Up @@ -900,7 +900,7 @@ sub recolour_cluster_elements {
#my $string_colour = eval {$colour_for_sequential->to_string} // '';
#say "RECOLOUR ELEMENTS: $string_colour";

# sets colours according to sequential palette
# sets colours according to multiselect palette
$colour_callback = sub {
my $elt = shift;

Expand Down Expand Up @@ -959,36 +959,36 @@ sub recolour_cluster_elements {

sub in_multiselect_mode {
my $self = shift;
return $self->{cluster_colour_mode} eq 'sequential';
return $self->{cluster_colour_mode} eq 'multiselect';
}

sub in_multiselect_clear_mode {
my $self = shift;
return ($self->{cluster_colour_mode} // '') eq 'sequential'
return ($self->{cluster_colour_mode} // '') eq 'multiselect'
&& eval {$self->{selector_toggle}->get_active};
}

sub enter_multiselect_clear_mode {
my ($self, $no_store) = @_;
eval {$self->{selector_toggle}->set_active (1)};
#$self->{sequential_select_no_store} = !!$no_store;
#$self->{multiselect_no_store} = !!$no_store;
}

sub leave_multiselect_clear_mode {
my $self = shift;
eval {$self->{selector_toggle}->set_active (0)};
#$self->{sequential_select_no_store} = 0;
#$self->{multiselect_no_store} = 0;
}

sub clear_sequential_colours_from_plot {
sub clear_multiselect_colours_from_plot {
my $self = shift;

return if !$self->in_multiselect_mode;

# temp override, as sequential colour mode has side effects
# temp override, as multiselect colour mode has side effects
local $self->{cluster_colour_mode} = 'palette';

my $colour_store = $self->get_sequential_colour_store;
my $colour_store = $self->get_multiselect_colour_store;
if (@$colour_store) {
my $tree = $self->get_tree_object;
my @coloured_nodes = map {$tree->get_node_ref (node => $_->[0])} @$colour_store;
Expand All @@ -1001,21 +1001,23 @@ sub clear_sequential_colours_from_plot {
}

# later we can get this from a cached value on the tree object
sub get_sequential_colour_store {
sub get_multiselect_colour_store {
my $self = shift;
my $tree = $self->get_tree_object;
my $store = $tree->get_cached_value_dor_set_default_aa ('GUI_MULTISELECT_COLOUR_STORE', []);
#my $store = ($self->{sequential_colour_store} //= []);
my $store
= $tree->get_cached_value_dor_set_default_aa (
GUI_MULTISELECT_COLOUR_STORE => [],
);
return $store;
}

sub store_sequential_colour {
my $self = shift;
my @pairs = @_; # usually get only one name/colour pair

return if $self->{sequential_select_no_store};
return if $self->{multiselect_no_store};

my $store = $self->get_sequential_colour_store;
my $store = $self->get_multiselect_colour_store;

PAIR:
foreach my $pair (pairs @pairs) {
Expand All @@ -1028,7 +1030,7 @@ sub store_sequential_colour {
$pair->[1] = $pair->[1]->to_string;
}

## Don't store sequential duplicates.
## Don't store duplicates.
## We get double triggers for some reason due to a
## higher sub being called twice for each colour event
next PAIR
Expand All @@ -1053,9 +1055,7 @@ sub get_current_sequential_colour {

my $colour;
eval {
#if (!$self->{selector_toggle}->get_active) {
$colour = $self->{selector_colorbutton}->get_color;
#}
$colour = $self->{selector_colorbutton}->get_color;
};

return $colour;
Expand All @@ -1082,15 +1082,15 @@ sub increment_sequential_selection_colour {
my $force_increment = shift;

return if !$force_increment
&& !$self->in_multiselect_mode;
&& !$self->in_multiselect_mode;

return if $self->in_multiselect_clear_mode;

my $colour = $self->get_current_sequential_colour;

my @colours = $self->get_gdk_colors_colorbrewer9;

if (my $last_colour = $self->{last_sequential_colour}) {
if (my $last_colour = $self->{last_multiselect_colour}) {
my $i = firstidx {$last_colour->equal($_)} @colours;
$i++;
$i %= scalar @colours;
Expand All @@ -1104,7 +1104,7 @@ sub increment_sequential_selection_colour {
$self->{selector_colorbutton}->set_color ($colour);
};

$self->{last_sequential_colour} = $colour;
$self->{last_multiselect_colour} = $colour;

return;
}
Expand Down Expand Up @@ -1141,7 +1141,7 @@ sub recolour_cluster_lines {
$colour_ref = $self->{node_palette_colours}{$node_name} || COLOUR_RED;
}
elsif ($self->in_multiselect_mode) {
$colour_ref = $self->get_current_sequential_colour; # || COLOUR_BLACK;
$colour_ref = $self->get_current_sequential_colour;
if ($colour_ref || $self->in_multiselect_clear_mode) {
$self->store_sequential_colour ($node_name => $colour_ref);
}
Expand Down Expand Up @@ -1306,10 +1306,10 @@ sub setup_map_list_model {
$model->set($iter, 0, $list);
}

# add the sequential selector
# add the multiselect selector
$iter = $model->insert(0);
$model->set($iter, 0, '<i>Cloister</i>');
$model->set($iter, 0, '<i>Multiselect</i>');

# Add & select, the "cluster" analysis (distinctive colour for every cluster)
$iter = $model->insert(0);
$model->set($iter, 0, '<i>Cluster</i>');
Expand Down Expand Up @@ -1419,7 +1419,7 @@ sub on_map_list_combo_changed {

if ($list eq '<i>Cluster</i>') {
# Selected cluster-palette-colouring mode
$self->clear_sequential_colours_from_plot;
$self->clear_multiselect_colours_from_plot;

$self->{cluster_colour_mode} = 'palette';

Expand All @@ -1431,13 +1431,13 @@ sub on_map_list_combo_changed {
# blank out the index combo
$self->setup_map_index_model(undef);
}
elsif ($list eq '<i>Cloister</i>') {
elsif ($list eq '<i>Multiselect</i>') {
if ($self->{slider}) {
$self->{slider}->hide;
$self->{graph_slider}->hide;
}

$self->{cluster_colour_mode} = 'sequential';
$self->{cluster_colour_mode} = 'multiselect';

$self->set_num_clusters (1, 'no_recolour');

Expand All @@ -1447,7 +1447,7 @@ sub on_map_list_combo_changed {
$self->setup_map_index_model(undef);
}
else {
$self->clear_sequential_colours_from_plot;
$self->clear_multiselect_colours_from_plot;

$self->get_parent_tab->on_clusters_changed;

Expand Down Expand Up @@ -1547,14 +1547,14 @@ sub get_plot_min_max_values {
sub reset_multiselect_undone_stack {
my $self = shift;
$self->get_tree_object->set_cached_value (
MULTI_SELECT_UNDONE_STACK => [],
GUI_MULTISELECT_UNDONE_STACK => [],
);
}

sub get_multiselect_undone_stack {
my $self = shift;
my $undone_stack = $self->get_tree_object->get_cached_value_dor_set_default_aa (
MULTI_SELECT_UNDONE_STACK => [],
GUI_MULTISELECT_UNDONE_STACK => [],
);
return $undone_stack;
}
Expand All @@ -1570,7 +1570,7 @@ sub undo_multiselect_click {
croak "offset value should not be negative (got $offset)\n"
if $offset < 0;

my $colour_store = $self->get_sequential_colour_store;
my $colour_store = $self->get_multiselect_colour_store;

# don't splice an empty array
return if !@$colour_store;
Expand Down Expand Up @@ -1603,7 +1603,7 @@ sub redo_multiselect_click {
# nothing to redo
return if !@$undone_stack;

my $colour_store = $self->get_sequential_colour_store;
my $colour_store = $self->get_multiselect_colour_store;

my @undone = splice @$undone_stack, 0, min ($offset, scalar @$undone_stack);

Expand All @@ -1626,26 +1626,26 @@ sub replay_multiselect_store {
$self->{recolour_nodes} = undef;
$self->set_processed_nodes (undef);
$self->recolour_cluster_elements;
$self->{cluster_colour_mode} = 'sequential';
$self->{cluster_colour_mode} = 'multiselect';

# The next bit of code probably does too much
# but getting it to work was not simple
my $tree = $self->get_tree_object;
my $node_ref_array = $tree->get_root_node_refs;

#my $was_in_clear_mode = $self->in_multiselect_clear_mode;
my $old_seq_sel_no_store = $self->{sequential_select_no_store};
$self->{sequential_select_no_store} = 1;
my $old_seq_sel_no_store = $self->{multiselect_no_store};
$self->{multiselect_no_store} = 1;
$self->enter_multiselect_clear_mode ('no_store');
$self->map_elements_to_clusters ($node_ref_array);
$self->recolour_cluster_lines ($node_ref_array);
#if (!$was_in_clear_mode) {
$self->leave_multiselect_clear_mode;
#}
$self->{sequential_select_no_store} = $old_seq_sel_no_store;
$self->{multiselect_no_store} = $old_seq_sel_no_store;


my $colour_store = $self->get_sequential_colour_store;
my $colour_store = $self->get_multiselect_colour_store;

return if !@$colour_store;

Expand All @@ -1659,7 +1659,7 @@ sub replay_multiselect_store {
);

foreach my $pair (@pairs) {
$self->{sequential_select_no_store} = 1;
$self->{multiselect_no_store} = 1;
my $was_in_clear_mode = 0;
my $node_ref = $tree->get_node_ref (node => $pair->[0]);
$self->set_current_sequential_colour ($pair->[1]);
Expand All @@ -1675,7 +1675,7 @@ sub replay_multiselect_store {
$self->leave_multiselect_clear_mode;
}
}
$self->{sequential_select_no_store} = $old_seq_sel_no_store;
$self->{multiselect_no_store} = $old_seq_sel_no_store;

}

Expand Down
6 changes: 3 additions & 3 deletions lib/Biodiverse/GUI/Tabs/Clustering.pm
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ sub on_combo_map_list_changed {
my $list = $model->get($iter, 0);

my $sensitive = 1;
if ($list eq '<i>Cluster</i>' || $list eq '<i>Cloister</i>') {
if ($list eq '<i>Cluster</i>' || $list eq '<i>Multiselect</i>') {
$sensitive = 0;
$self->hide_legend;
$self->{output_ref}->set_cached_value(LAST_SELECTED_LIST => undef);
Expand All @@ -684,8 +684,8 @@ sub on_combo_map_list_changed {
# show/hide some widgets
my @cluster_widgets = qw /label_cluster_spin_button spinClusters/;
my @cloister_widgets = qw /label_selector_colour selector_colorbutton selector_toggle/;
my $m1 = $list eq '<i>Cloister</i>' ? 'hide' : 'show';
my $m2 = $list eq '<i>Cloister</i>' ? 'show' : 'hide';
my $m1 = $list eq '<i>Multiselect</i>' ? 'hide' : 'show';
my $m2 = $list eq '<i>Multiselect</i>' ? 'show' : 'hide';
foreach my $widget_name (@cluster_widgets) {
my $widget = $self->{xmlPage}->get_object ($widget_name);
$widget->$m1;
Expand Down

0 comments on commit fad2521

Please sign in to comment.