Checks to see if config option has been changed before going any further for several config options.

N of 1 testing indicates that it may help with latency.
This commit is contained in:
Joseph Lenox 2018-04-17 21:55:44 -05:00
parent 7457cfdac2
commit c206ae77a3

View File

@ -4,7 +4,7 @@ use warnings;
use utf8; use utf8;
use File::Basename qw(basename); use File::Basename qw(basename);
use List::Util qw(first); use List::Util qw(first any);
use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :treectrl :window use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :treectrl :window
:button wxTheApp); :button wxTheApp);
use Wx::Event qw(EVT_BUTTON EVT_CHOICE EVT_KEY_DOWN EVT_TREE_SEL_CHANGED EVT_CHECKBOX); use Wx::Event qw(EVT_BUTTON EVT_CHOICE EVT_KEY_DOWN EVT_TREE_SEL_CHANGED EVT_CHECKBOX);
@ -147,12 +147,11 @@ sub on_value_change {
# propagate event to the parent # propagate event to the parent
sub _on_value_change { sub _on_value_change {
my ($self, $opt_key) = @_; my ($self, $opt_key) = @_;
wxTheApp->CallAfter(sub { wxTheApp->CallAfter(sub {
$self->current_preset->_dirty_config->apply($self->config); $self->current_preset->_dirty_config->apply($self->config);
$self->{on_value_change}->($opt_key) if $self->{on_value_change}; $self->{on_value_change}->($opt_key) if $self->{on_value_change};
$self->load_presets; $self->load_presets;
$self->_update; $self->_update($opt_key);
}); });
} }
@ -794,10 +793,11 @@ sub reload_config {
} }
sub _update { sub _update {
my ($self) = @_; my ($self, $key) = @_;
my $opt_key = $key;
$opt_key = "all_keys" if (length($key // '') == 0);
my $config = $self->{config}; my $config = $self->{config};
if (any { /$opt_key/ } qw(all_keys spiral_vase perimeters top_solid_layers fill_density support_material)) {
if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0 && $config->support_material == 0)) { if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0 && $config->support_material == 0)) {
my $dialog = Wx::MessageDialog->new($self, my $dialog = Wx::MessageDialog->new($self,
"The Spiral Vase mode requires:\n" "The Spiral Vase mode requires:\n"
@ -820,7 +820,9 @@ sub _update {
$self->_load_config($new_conf); $self->_load_config($new_conf);
} }
} }
}
if (any { /$opt_key/ } qw(all_keys support_material)) {
if ($config->support_material) { if ($config->support_material) {
# Ask only once. # Ask only once.
if (! $self->{support_material_overhangs_queried}) { if (! $self->{support_material_overhangs_queried}) {
@ -849,7 +851,9 @@ sub _update {
} else { } else {
$self->{support_material_overhangs_queried} = 0; $self->{support_material_overhangs_queried} = 0;
} }
}
if (any { /$opt_key/ } qw(all_keys fill_density fill_pattern top_infill_pattern)) {
if ($config->fill_density == 100 if ($config->fill_density == 100
&& !first { $_ eq $config->fill_pattern } @{$Slic3r::Config::Options->{top_infill_pattern}{values}}) { && !first { $_ eq $config->fill_pattern } @{$Slic3r::Config::Options->{top_infill_pattern}{values}}) {
my $dialog = Wx::MessageDialog->new($self, my $dialog = Wx::MessageDialog->new($self,
@ -865,36 +869,50 @@ sub _update {
} }
$self->_load_config($new_conf); $self->_load_config($new_conf);
} }
}
my $have_perimeters = $config->perimeters > 0; my $have_perimeters = $config->perimeters > 0;
if (any { /$opt_key/ } qw(all_keys perimeters)) {
$self->get_field($_)->toggle($have_perimeters) $self->get_field($_)->toggle($have_perimeters)
for qw(extra_perimeters thin_walls overhangs seam_position external_perimeters_first for qw(extra_perimeters thin_walls overhangs seam_position external_perimeters_first
external_perimeter_extrusion_width external_perimeter_extrusion_width
perimeter_speed small_perimeter_speed external_perimeter_speed); perimeter_speed small_perimeter_speed external_perimeter_speed);
}
my $have_adaptive_slicing = $config->adaptive_slicing; my $have_adaptive_slicing = $config->adaptive_slicing;
if (any { /$opt_key/ } qw(all_keys adaptive_slicing)) {
$self->get_field($_)->toggle($have_adaptive_slicing) $self->get_field($_)->toggle($have_adaptive_slicing)
for qw(adaptive_slicing_quality match_horizontal_surfaces); for qw(adaptive_slicing_quality match_horizontal_surfaces);
$self->get_field($_)->toggle(!$have_adaptive_slicing) $self->get_field($_)->toggle(!$have_adaptive_slicing)
for qw(layer_height); for qw(layer_height);
}
my $have_infill = $config->fill_density > 0; my $have_infill = $config->fill_density > 0;
if (any { /$opt_key/ } qw(all_keys fill_density)) {
# infill_extruder uses the same logic as in Print::extruders() # infill_extruder uses the same logic as in Print::extruders()
$self->get_field($_)->toggle($have_infill) $self->get_field($_)->toggle($have_infill)
for qw(fill_pattern infill_every_layers infill_only_where_needed solid_infill_every_layers for qw(fill_pattern infill_every_layers infill_only_where_needed solid_infill_every_layers
solid_infill_below_area infill_extruder); solid_infill_below_area infill_extruder);
}
my $have_solid_infill = ($config->top_solid_layers > 0) || ($config->bottom_solid_layers > 0); my $have_solid_infill = ($config->top_solid_layers > 0) || ($config->bottom_solid_layers > 0);
if (any { /$opt_key/ } qw(all_keys top_solid_layers bottom_solid_layers)) {
# solid_infill_extruder uses the same logic as in Print::extruders() # solid_infill_extruder uses the same logic as in Print::extruders()
$self->get_field($_)->toggle($have_solid_infill) $self->get_field($_)->toggle($have_solid_infill)
for qw(top_infill_pattern bottom_infill_pattern infill_first solid_infill_extruder for qw(top_infill_pattern bottom_infill_pattern infill_first solid_infill_extruder
solid_infill_extrusion_width solid_infill_speed); solid_infill_extrusion_width solid_infill_speed);
}
if (any { /$opt_key/ } qw(all_keys top_solid_layers bottom_solid_layers fill_density)) {
$self->get_field($_)->toggle($have_infill || $have_solid_infill) $self->get_field($_)->toggle($have_infill || $have_solid_infill)
for qw(fill_angle infill_extrusion_width infill_speed bridge_speed); for qw(fill_angle infill_extrusion_width infill_speed bridge_speed);
}
if (any { /$opt_key/ } qw(all_keys fill_density perimeters)) {
$self->get_field('fill_gaps')->toggle($have_perimeters && $have_infill); $self->get_field('fill_gaps')->toggle($have_perimeters && $have_infill);
$self->get_field('gap_fill_speed')->toggle($have_perimeters && $have_infill && $config->fill_gaps); $self->get_field('gap_fill_speed')->toggle($have_perimeters && $have_infill && $config->fill_gaps);
}
my $have_top_solid_infill = $config->top_solid_layers > 0; my $have_top_solid_infill = $config->top_solid_layers > 0;
$self->get_field($_)->toggle($have_top_solid_infill) $self->get_field($_)->toggle($have_top_solid_infill)