diff --git a/lib/Slic3r/Format/AMF.pm b/lib/Slic3r/Format/AMF.pm
index d881148f..4a2c1a61 100644
--- a/lib/Slic3r/Format/AMF.pm
+++ b/lib/Slic3r/Format/AMF.pm
@@ -37,10 +37,14 @@ sub write_file {
printf $fh qq{ Slic3r %s\n}, $Slic3r::VERSION;
for my $material_id (sort keys %{ $model->materials }) {
my $material = $model->materials->{$material_id};
- printf $fh qq{ \n}, $material_id;
+ printf $fh qq{ \n}, $material_id;
for (keys %{$material->attributes}) {
printf $fh qq{ %s\n}, $_, $material->attributes->{$_};
}
+ my $config = $material->config;
+ foreach my $opt_key (@{$config->get_keys}) {
+ printf $fh qq{ %s\n}, $opt_key, $config->serialize($opt_key);
+ }
printf $fh qq{ \n};
}
my $instances = '';
diff --git a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
index a79ef3a8..8f39b2b1 100644
--- a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
+++ b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
@@ -17,7 +17,6 @@ sub new {
$self->{tabpanel}->AddPage($self->{settings} = Slic3r::GUI::Plater::ObjectDialog::SettingsTab->new($self->{tabpanel}), "Settings");
$self->{tabpanel}->AddPage($self->{layers} = Slic3r::GUI::Plater::ObjectDialog::LayersTab->new($self->{tabpanel}), "Layers");
$self->{tabpanel}->AddPage($self->{parts} = Slic3r::GUI::Plater::ObjectPartsPanel->new($self->{tabpanel}, model_object => $params{model_object}), "Parts");
- $self->{tabpanel}->AddPage($self->{materials} = Slic3r::GUI::Plater::ObjectDialog::MaterialsTab->new($self->{tabpanel}), "Materials");
my $buttons = $self->CreateStdDialogButtonSizer(wxOK);
EVT_BUTTON($self, wxID_OK, sub {
@@ -27,7 +26,6 @@ sub new {
# notify tabs
$self->{layers}->Closing;
- $self->{materials}->Closing;
$self->EndModal(wxID_OK);
$self->Destroy;
@@ -206,87 +204,4 @@ sub _get_ranges {
return sort { $a->[0] <=> $b->[0] } @ranges;
}
-package Slic3r::GUI::Plater::ObjectDialog::MaterialsTab;
-use Wx qw(:dialog :id :misc :sizer :systemsettings :button :icon);
-use Wx::Grid;
-use Wx::Event qw(EVT_BUTTON);
-use base 'Slic3r::GUI::Plater::ObjectDialog::BaseTab';
-
-sub new {
- my $class = shift;
- my ($parent, %params) = @_;
- my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize);
- $self->{object} = $params{object};
-
- $self->{sizer} = Wx::BoxSizer->new(wxVERTICAL);
-
- # descriptive text
- {
- my $label = Wx::StaticText->new($self, -1, "In this section you can assign object materials to your extruders.",
- wxDefaultPosition, [-1, 25]);
- $label->SetFont(Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- $self->{sizer}->Add($label, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10);
- }
-
- # get unique materials used in this object
- $self->{materials} = [ $self->model_object->unique_materials ];
-
- # get the current mapping
- $self->{mapping} = {};
- foreach my $material_id (@{ $self->{materials}}) {
- my $config = $self->model_object->model->materials->{ $material_id }->config;
- $self->{mapping}{$material_id} = ($config->perimeter_extruder // 0) + 1;
- }
-
- if (@{$self->{materials}} > 0) {
- # build an OptionsGroup
- my $optgroup = Slic3r::GUI::OptionsGroup->new(
- parent => $self,
- title => 'Extruders',
- label_width => 300,
- options => [
- map {
- my $i = $_;
- my $material_id = $self->{materials}[$i];
- {
- opt_key => "material_extruder_$_",
- type => 'i',
- label => $self->model_object->model->get_material_name($material_id),
- min => 1,
- default => $self->{mapping}{$material_id} // 1,
- on_change => sub { $self->{mapping}{$material_id} = $_[0] },
- }
- } 0..$#{ $self->{materials} }
- ],
- );
- $self->{sizer}->Add($optgroup->sizer, 0, wxEXPAND | wxALL, 10);
- } else {
- my $label = Wx::StaticText->new($self, -1, "This object does not contain named materials.",
- wxDefaultPosition, [-1, 25]);
- $label->SetFont(Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- $self->{sizer}->Add($label, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10);
- }
-
- $self->SetSizer($self->{sizer});
- $self->{sizer}->SetSizeHints($self);
-
- return $self;
-}
-
-sub Closing {
- my $self = shift;
-
- # save mappings into the plater object
- foreach my $volume (@{$self->model_object->volumes}) {
- if (defined $volume->material_id) {
- my $config = $self->model_object->model->materials->{ $volume->material_id }->config;
-
- # temporary hack for handling volumes added after the window was launched
- $self->{mapping}{ $volume->material_id } //= 0;
-
- $config->set('extruder', $self->{mapping}{ $volume->material_id }-1);
- }
- }
-}
-
1;
diff --git a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm
index dd6ece42..5bbe0519 100644
--- a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm
+++ b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm
@@ -58,6 +58,7 @@ sub new {
sub set_config {
my ($self, $config) = @_;
$self->{config} = $config;
+ $self->update_optgroup;
}
sub update_optgroup {