Bugfix: changes in extruder count in GUI were not propagating to the rest of the GUI

This commit is contained in:
Alessandro Ranellucci 2014-09-21 15:29:52 +02:00
parent 16b6cdcd6e
commit 321b70115b
2 changed files with 32 additions and 9 deletions

View File

@ -85,8 +85,13 @@ sub _init_tabpanel {
my $tab;
$tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new($panel);
$tab->on_value_change(sub {
my ($opt_key, $value) = @_;
my $config = $tab->config;
$self->{plater}->on_config_change($config) if $self->{plater}; # propagate config change events to the plater
if ($self->{plater}) {
$self->{plater}->on_config_change($config); # propagate config change events to the plater
$self->{plater}->on_extruders_change($value) if $opt_key eq 'extruders_count';
}
if ($self->{loaded}) { # don't save while loading for the first time
if ($self->{mode} eq 'simple') {
# save config

View File

@ -405,6 +405,17 @@ sub get_field {
return undef;
}
sub set_value {
my $self = shift;
my ($opt_key, $value) = @_;
my $changed = 0;
foreach my $page (@{ $self->{pages} }) {
$changed = 1 if $page->set_value($opt_key, $value);
}
return $changed;
}
package Slic3r::GUI::Tab::Print;
use base 'Slic3r::GUI::Tab';
@ -948,9 +959,7 @@ sub build {
$optgroup->on_change(sub {
my ($opt_id) = @_;
if ($opt_id eq 'extruders_count') {
$self->{extruders_count} = $optgroup->get_value('extruders_count');
$self->_build_extruder_pages;
$self->_update;
$self->_extruders_count_changed($optgroup->get_value('extruders_count'));
}
});
}
@ -1004,6 +1013,16 @@ sub build {
$self->_build_extruder_pages;
}
sub _extruders_count_changed {
my ($self, $extruders_count) = @_;
$self->{extruders_count} = $extruders_count;
$self->_build_extruder_pages;
$self->_update;
$self->set_dirty(1);
$self->_on_value_change('extruders_count', $extruders_count);
}
sub _extruder_options { qw(nozzle_diameter extruder_offset retract_length retract_lift retract_speed retract_restart_extra retract_before_travel wipe
retract_layer_change retract_length_toolchange retract_restart_extra_toolchange) }
@ -1110,14 +1129,13 @@ sub _update {
# this gets executed after preset is loaded and before GUI fields are updated
sub on_preset_loaded {
my $self = shift;
return;
# update the extruders count field
{
# update the GUI field according to the number of nozzle diameters supplied
$self->set_value('extruders_count', scalar @{ $self->{config}->nozzle_diameter });
# update extruder page list
$self->_on_value_change('extruders_count');
my $extruders_count = scalar @{ $self->{config}->nozzle_diameter };
$self->set_value('extruders_count', $extruders_count);
$self->_extruders_count_changed($extruders_count);
}
}