Expose all multi-extruder settings to the GUI

This commit is contained in:
Alessandro Ranellucci 2012-08-07 20:14:28 +02:00
parent 793301d319
commit 2548d5b993
4 changed files with 35 additions and 18 deletions

View File

@ -88,7 +88,7 @@ sub OnInit {
$fileMenu->AppendSeparator();
$fileMenu->Append(wxID_EXIT, "&Quit", 'Quit Slic3r');
EVT_MENU($frame, MI_LOAD_CONF, sub { $self->{skeinpanel}->load_config_file });
EVT_MENU($frame, MI_EXPORT_CONF, sub { $self->{skeinpanel}->save_config });
EVT_MENU($frame, MI_EXPORT_CONF, sub { $self->{skeinpanel}->export_config });
EVT_MENU($frame, MI_QUICK_SLICE, sub { $self->{skeinpanel}->do_slice;
$repeat->Enable(defined $Slic3r::GUI::SkeinPanel::last_input_file) });
EVT_MENU($frame, MI_REPEAT_QUICK, sub { $self->{skeinpanel}->do_slice(reslice => 1) });

View File

@ -37,7 +37,7 @@ sub new {
my ($parent) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
$self->{config} = Slic3r::Config->new_from_defaults(qw(
bed_size print_center complete_objects extruder_clearance_radius skirts skirt_distance extruders_count
bed_size print_center complete_objects extruder_clearance_radius skirts skirt_distance
));
$self->{canvas} = Wx::Panel->new($self, -1, wxDefaultPosition, CANVAS_SIZE, wxTAB_TRAVERSAL);
@ -227,7 +227,7 @@ sub new {
$self->{preset_choosers}{$group} = [$choice];
EVT_CHOICE($choice, $choice, sub {
my $choice = shift; # avoid leaks
return if $group eq 'filament' && ($self->{config}->get('extruders_count') // 1) > 1; #/
return if $group eq 'filament' && @{$self->{preset_choosers}{filament}} > 1; #/
$self->skeinpanel->{options_tabs}{$group}->select_preset($choice->GetSelection);
});
@ -711,22 +711,21 @@ sub recenter {
sub on_config_change {
my $self = shift;
my ($opt_key, $value) = @_;
if (exists $self->{config}{$opt_key}) {
if ($opt_key eq 'extruders_count' && defined $value) {
my $choices = $self->{preset_choosers}{filament};
while (@$choices < $value) {
push @$choices, Wx::Choice->new($self, -1, wxDefaultPosition, [150, -1], [$choices->[0]->GetStrings]);
$self->{preset_choosers_sizers}{filament}->Add($choices->[-1], 0, wxEXPAND | wxBOTTOM, FILAMENT_CHOOSERS_SPACING);
}
while (@$choices > $value) {
$self->{preset_choosers_sizers}{filament}->Remove(-1);
$choices->[-1]->Destroy;
pop @$choices;
}
$self->Layout;
} elsif (exists $self->{config}{$opt_key}) {
$self->{config}->set($opt_key, $value);
$self->_update_bed_size if $opt_key eq 'bed_size';
if ($opt_key eq 'extruders_count' && defined $value) {
my $choices = $self->{preset_choosers}{filament};
while (@$choices < $value) {
push @$choices, Wx::Choice->new($self, -1, wxDefaultPosition, [150, -1], [$choices->[0]->GetStrings]);
$self->{preset_choosers_sizers}{filament}->Add($choices->[-1], 0, wxEXPAND | wxBOTTOM, FILAMENT_CHOOSERS_SPACING);
}
while (@$choices > $value) {
$self->{preset_choosers_sizers}{filament}->Remove(-1);
$choices->[-1]->Destroy;
pop @$choices;
}
$self->Layout;
}
}
}

View File

@ -164,7 +164,7 @@ sub do_slice {
Slic3r::GUI::catch_error($self, sub { $process_dialog->Destroy if $process_dialog });
}
sub save_config {
sub export_config {
my $self = shift;
my $config = $self->config;

View File

@ -454,6 +454,13 @@ sub build {
},
]);
$self->add_options_page('Multiple Extruders', 'funnel.png', optgroups => [
{
title => 'Extruders',
options => [qw(perimeter_extruder infill_extruder support_material_extruder)],
},
]);
$self->add_options_page('Advanced', 'wrench.png', optgroups => [
{
title => 'Extrusion width',
@ -643,6 +650,17 @@ sub on_preset_loaded {
}
}
sub load_external_config {
my $self = shift;
$self->SUPER::load_external_config(@_);
Slic3r::GUI::warning_catcher($self)->(
"Your configuration was imported. However, Slic3r is currently only able to import settings "
. "for the first defined filament. We recommend you don't use exported configuration files "
. "for multi-extruder setups and rely on the built-in preset management system instead.")
if @{ $self->{config}->nozzle_diameter } > 1;
}
package Slic3r::GUI::Tab::Page;
use Wx qw(:misc :panel :sizer);
use base 'Wx::ScrolledWindow';