mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Write material config to AMF files. Remove the old Materials tab. Update custom settings when a part is selected
This commit is contained in:
		
							parent
							
								
									691db31da0
								
							
						
					
					
						commit
						878deb8183
					
				
					 3 changed files with 6 additions and 86 deletions
				
			
		|  | @ -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; | ||||
|  |  | |||
|  | @ -58,6 +58,7 @@ sub new { | |||
| sub set_config { | ||||
|     my ($self, $config) = @_; | ||||
|     $self->{config} = $config; | ||||
|     $self->update_optgroup; | ||||
| } | ||||
| 
 | ||||
| sub update_optgroup { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci