From 321b70115b60df786fe74d376c3f67b1f7076fc0 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 21 Sep 2014 15:29:52 +0200 Subject: [PATCH] Bugfix: changes in extruder count in GUI were not propagating to the rest of the GUI --- lib/Slic3r/GUI/MainFrame.pm | 7 ++++++- lib/Slic3r/GUI/Tab.pm | 34 ++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 5f0a8496b..39dcb2097 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -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 diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 65d7dad6f..b5bd4e068 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -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); } }