From 2548d5b993918b2652345c6fef592a0991992ae1 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 7 Aug 2012 20:14:28 +0200 Subject: [PATCH] Expose all multi-extruder settings to the GUI --- lib/Slic3r/GUI.pm | 2 +- lib/Slic3r/GUI/Plater.pm | 31 +++++++++++++++---------------- lib/Slic3r/GUI/SkeinPanel.pm | 2 +- lib/Slic3r/GUI/Tab.pm | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 5ed0a6d0e..8bd7fa684 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -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) }); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index e7eceb8ca..c10a62342 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -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; - } } } diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 7ac2dde01..4bf87e7d3 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -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; diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 797961e7d..93fe8eba1 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -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';