mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Some fixes and improvements to controller
This commit is contained in:
		
							parent
							
								
									3c43fb8081
								
							
						
					
					
						commit
						80620a5e94
					
				
					 3 changed files with 35 additions and 7 deletions
				
			
		|  | @ -5,7 +5,11 @@ use utf8; | |||
| 
 | ||||
| use Wx qw(wxTheApp :frame :id :misc :sizer :bitmap :button :icon :dialog); | ||||
| use Wx::Event qw(EVT_CLOSE EVT_LEFT_DOWN EVT_MENU); | ||||
| use base 'Wx::ScrolledWindow'; | ||||
| use base qw(Wx::ScrolledWindow Class::Accessor); | ||||
| 
 | ||||
| __PACKAGE__->mk_accessors(qw(_selected_printer_preset)); | ||||
| 
 | ||||
| our @ConfigOptions = qw(bed_shape serial_port serial_speed); | ||||
| 
 | ||||
| sub new { | ||||
|     my ($class, $parent) = @_; | ||||
|  | @ -105,17 +109,23 @@ sub OnActivate { | |||
|         grep { $_->is_connected || @{$_->jobs} > 0 } | ||||
|         $self->print_panels; | ||||
|      | ||||
|     # if there are no active panels, use sensible defaults | ||||
|     if (!%active) { | ||||
|         if (keys %presets <= 2) { | ||||
|     if (%presets) { | ||||
|         # if there are no active panels, use sensible defaults | ||||
|         if (!%active && keys %presets <= 2) { | ||||
|             # if only one or two presets exist, load them | ||||
|             $active{$_} = 1 for keys %presets; | ||||
|         } else { | ||||
|         } | ||||
|         if (!%active) { | ||||
|             # enable printers whose port is available | ||||
|             my %ports = map { $_ => 1 } wxTheApp->scan_serial_ports; | ||||
|             $active{$_} = 1 | ||||
|                 for grep exists $ports{$presets{$_}->serial_port}, keys %presets; | ||||
|         } | ||||
|         if (!%active && $self->_selected_printer_preset) { | ||||
|             # enable currently selected printer if it is configured | ||||
|             $active{$self->_selected_printer_preset} = 1 | ||||
|                 if $presets{$self->_selected_printer_preset}; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     # apply changes | ||||
|  | @ -163,4 +173,21 @@ sub print_panels { | |||
|         map $_->GetWindow, $self->{sizer}->GetChildren; | ||||
| } | ||||
| 
 | ||||
| sub update_presets { | ||||
|     my $self = shift; | ||||
|     my ($group, $presets, $selected, $is_dirty) = @_; | ||||
|      | ||||
|     # update configs of currently loaded print panels | ||||
|     foreach my $panel ($self->print_panels) { | ||||
|         foreach my $preset (@$presets) { | ||||
|             if ($panel->printer_name eq $preset->name) { | ||||
|                 my $config = $preset->config(\@ConfigOptions); | ||||
|                 $panel->config->apply($config); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     $self->_selected_printer_preset($presets->[$selected]->name); | ||||
| } | ||||
| 
 | ||||
| 1; | ||||
|  |  | |||
|  | @ -564,7 +564,7 @@ sub new { | |||
|     } | ||||
|     { | ||||
|         my $filament_stats = join "\n", | ||||
|             map "$_ (" . sprintf("%.2f", $job->filament_stats->{$_}/100) . "m)", | ||||
|             map "$_ (" . sprintf("%.2f", $job->filament_stats->{$_}/1000) . "m)", | ||||
|             sort keys %{$job->filament_stats}; | ||||
|         my $text = Wx::StaticText->new($self, -1, $filament_stats, wxDefaultPosition, wxDefaultSize); | ||||
|         $text->SetFont($Slic3r::GUI::small_font); | ||||
|  |  | |||
|  | @ -136,6 +136,7 @@ sub _init_tabpanel { | |||
|             if ($self->{plater}) { | ||||
|                 $self->{plater}->update_presets($tab_name, @_); | ||||
|                 $self->{plater}->on_config_change($tab->config); | ||||
|                 $self->{controller}->update_presets($tab_name, @_); | ||||
|             } | ||||
|         }); | ||||
|         $tab->load_presets; | ||||
|  | @ -735,7 +736,7 @@ sub check_unsaved_changes { | |||
| 
 | ||||
| sub select_tab { | ||||
|     my ($self, $tab) = @_; | ||||
|     $self->{tabpanel}->ChangeSelection($tab); | ||||
|     $self->{tabpanel}->SetSelection($tab); | ||||
| } | ||||
| 
 | ||||
| sub _append_menu_item { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci