mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Removed the GCodePreviewData from the Print class, it does not belong here,
as the GCode is generated outside of the Print class. Exported the GCodePreviewData as GCode::PreviewData to Perl. When exporting the G-code with a command line Slic3r, the GCodeAnalyzer is now supressed for performance reasons. Removed obsolete Perl module Slic3r::GUI::Plater::3DToolpaths.
This commit is contained in:
		
							parent
							
								
									3a6436f6f0
								
							
						
					
					
						commit
						b1f5e7e8fa
					
				
					 20 changed files with 166 additions and 401 deletions
				
			
		|  | @ -8,11 +8,11 @@ use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxCB_READONLY); | |||
| use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN EVT_CHECKBOX EVT_CHOICE EVT_CHECKLISTBOX); | ||||
| use base qw(Wx::Panel Class::Accessor); | ||||
| 
 | ||||
| __PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider_low slider_high single_layer auto_zoom)); | ||||
| __PACKAGE__->mk_accessors(qw(print gcode_preview_data enabled _loaded canvas slider_low slider_high single_layer auto_zoom)); | ||||
| 
 | ||||
| sub new { | ||||
|     my $class = shift; | ||||
|     my ($parent, $print, $config) = @_; | ||||
|     my ($parent, $print, $gcode_preview_data, $config) = @_; | ||||
|      | ||||
|     my $self = $class->SUPER::new($parent, -1, wxDefaultPosition); | ||||
|     $self->{config} = $config; | ||||
|  | @ -192,7 +192,7 @@ sub new { | |||
|     }); | ||||
|     EVT_CHOICE($self, $choice_view_type, sub { | ||||
|         my $selection = $choice_view_type->GetCurrentSelection(); | ||||
|         $self->print->set_gcode_preview_type($selection); | ||||
|         $self->gcode_preview_data->set_type($selection); | ||||
|         $self->auto_zoom(0); | ||||
|         $self->reload_print; | ||||
|         $self->auto_zoom(1); | ||||
|  | @ -200,31 +200,31 @@ sub new { | |||
|     EVT_CHECKLISTBOX($self, $combochecklist_features, sub { | ||||
|         my $flags = Slic3r::GUI::combochecklist_get_flags($combochecklist_features); | ||||
|          | ||||
|         $self->print->set_gcode_preview_extrusion_flags($flags); | ||||
|         $self->gcode_preview_data->set_extrusion_flags($flags); | ||||
|         $self->auto_zoom(0); | ||||
|         $self->refresh_print; | ||||
|         $self->auto_zoom(1); | ||||
|     });     | ||||
|     EVT_CHECKBOX($self, $checkbox_travel, sub { | ||||
|         $self->print->set_gcode_preview_travel_visible($checkbox_travel->IsChecked()); | ||||
|         $self->gcode_preview_data->set_travel_visible($checkbox_travel->IsChecked()); | ||||
|         $self->auto_zoom(0); | ||||
|         $self->refresh_print; | ||||
|         $self->auto_zoom(1); | ||||
|     });     | ||||
|     EVT_CHECKBOX($self, $checkbox_retractions, sub { | ||||
|         $self->print->set_gcode_preview_retractions_visible($checkbox_retractions->IsChecked()); | ||||
|         $self->gcode_preview_data->set_retractions_visible($checkbox_retractions->IsChecked()); | ||||
|         $self->auto_zoom(0); | ||||
|         $self->refresh_print; | ||||
|         $self->auto_zoom(1); | ||||
|     }); | ||||
|     EVT_CHECKBOX($self, $checkbox_unretractions, sub { | ||||
|         $self->print->set_gcode_preview_unretractions_visible($checkbox_unretractions->IsChecked()); | ||||
|         $self->gcode_preview_data->set_unretractions_visible($checkbox_unretractions->IsChecked()); | ||||
|         $self->auto_zoom(0); | ||||
|         $self->refresh_print; | ||||
|         $self->auto_zoom(1); | ||||
|     }); | ||||
|     EVT_CHECKBOX($self, $checkbox_shells, sub { | ||||
|         $self->print->set_gcode_preview_shells_visible($checkbox_shells->IsChecked()); | ||||
|         $self->gcode_preview_data->set_shells_visible($checkbox_shells->IsChecked()); | ||||
|         $self->auto_zoom(0); | ||||
|         $self->refresh_print; | ||||
|         $self->auto_zoom(1); | ||||
|  | @ -236,6 +236,7 @@ sub new { | |||
|      | ||||
|     # init canvas | ||||
|     $self->print($print); | ||||
|     $self->gcode_preview_data($gcode_preview_data); | ||||
|      | ||||
|     # sets colors for gcode preview extrusion roles | ||||
|     my @extrusion_roles_colors = ( | ||||
|  | @ -252,7 +253,7 @@ sub new { | |||
|                                     'Support material interface' => '00007F', | ||||
|                                     'Wipe tower'                 => 'B3E3AB', | ||||
|                                  ); | ||||
|     $self->print->set_gcode_extrusion_paths_colors(\@extrusion_roles_colors); | ||||
|     $self->gcode_preview_data->set_extrusion_paths_colors(\@extrusion_roles_colors); | ||||
|      | ||||
|     $self->reload_print; | ||||
|      | ||||
|  | @ -354,7 +355,7 @@ sub load_print { | |||
|     } | ||||
| 
 | ||||
|     if ($self->IsShown) { | ||||
|         $self->canvas->load_gcode_preview($self->print, \@colors); | ||||
|         $self->canvas->load_gcode_preview($self->print, $self->gcode_preview_data, \@colors); | ||||
| 
 | ||||
| #        # load skirt and brim | ||||
| #        $self->canvas->load_print_toolpaths($self->print, \@colors); | ||||
|  |  | |||
|  | @ -1,159 +0,0 @@ | |||
| package Slic3r::GUI::Plater::3DToolpaths; | ||||
| use strict; | ||||
| use warnings; | ||||
| use utf8; | ||||
| 
 | ||||
| use Slic3r::Print::State ':steps'; | ||||
| use Wx qw(:misc :sizer :slider :statictext wxWHITE); | ||||
| use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN); | ||||
| use base qw(Wx::Panel Class::Accessor); | ||||
| 
 | ||||
| __PACKAGE__->mk_accessors(qw(print enabled _loaded canvas slider)); | ||||
| 
 | ||||
| sub new { | ||||
|     my $class = shift; | ||||
|     my ($parent, $print) = @_; | ||||
|      | ||||
|     my $self = $class->SUPER::new($parent, -1, wxDefaultPosition); | ||||
|      | ||||
|     # init GUI elements | ||||
|     my $canvas = Slic3r::GUI::3DScene->new($self); | ||||
|     $self->canvas($canvas); | ||||
|     my $slider = Wx::Slider->new( | ||||
|         $self, -1, | ||||
|         0,                              # default | ||||
|         0,                              # min | ||||
|         # we set max to a bogus non-zero value because the MSW implementation of wxSlider | ||||
|         # will skip drawing the slider if max <= min: | ||||
|         1,                              # max | ||||
|         wxDefaultPosition, | ||||
|         wxDefaultSize, | ||||
|         wxVERTICAL | wxSL_INVERSE, | ||||
|     ); | ||||
|     $self->slider($slider); | ||||
|      | ||||
|     my $z_label = $self->{z_label} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, | ||||
|         [40,-1], wxALIGN_CENTRE_HORIZONTAL); | ||||
|     $z_label->SetFont($Slic3r::GUI::small_font); | ||||
|      | ||||
|     my $vsizer = Wx::BoxSizer->new(wxVERTICAL); | ||||
|     $vsizer->Add($slider, 1, wxALL | wxEXPAND | wxALIGN_CENTER, 3); | ||||
|     $vsizer->Add($z_label, 0, wxALL | wxEXPAND | wxALIGN_CENTER, 3); | ||||
|      | ||||
|     my $sizer = Wx::BoxSizer->new(wxHORIZONTAL); | ||||
|     $sizer->Add($canvas, 1, wxALL | wxEXPAND, 0); | ||||
|     $sizer->Add($vsizer, 0, wxTOP | wxBOTTOM | wxEXPAND, 5); | ||||
|      | ||||
|     EVT_SLIDER($self, $slider, sub { | ||||
|         $self->set_z($self->{layers_z}[$slider->GetValue]) | ||||
|             if $self->enabled; | ||||
|     }); | ||||
|     EVT_KEY_DOWN($canvas, sub { | ||||
|         my ($s, $event) = @_; | ||||
|         if ($event->HasModifiers) { | ||||
|             $event->Skip; | ||||
|         } else { | ||||
|             my $key = $event->GetKeyCode; | ||||
|             if ($key == 85 || $key == 315) { | ||||
|                 $slider->SetValue($slider->GetValue + 1); | ||||
|                 $self->set_z($self->{layers_z}[$slider->GetValue]); | ||||
|             } elsif ($key == 68 || $key == 317) { | ||||
|                 $slider->SetValue($slider->GetValue - 1); | ||||
|                 $self->set_z($self->{layers_z}[$slider->GetValue]); | ||||
|             } else { | ||||
|                 $event->Skip; | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
|      | ||||
|     $self->SetSizer($sizer); | ||||
|     $self->SetMinSize($self->GetSize); | ||||
|     $sizer->SetSizeHints($self); | ||||
|      | ||||
|     # init canvas | ||||
|     $self->print($print); | ||||
|     $self->reload_print; | ||||
|      | ||||
|     return $self; | ||||
| } | ||||
| 
 | ||||
| sub reload_print { | ||||
|     my ($self) = @_; | ||||
|      | ||||
|     $self->canvas->reset_objects; | ||||
|     $self->_loaded(0); | ||||
|     $self->load_print; | ||||
| } | ||||
| 
 | ||||
| sub load_print { | ||||
|     my ($self) = @_; | ||||
|      | ||||
|     return if $self->_loaded; | ||||
|      | ||||
|     # we require that there's at least one object and the posSlice step | ||||
|     # is performed on all of them (this ensures that _shifted_copies was | ||||
|     # populated and we know the number of layers) | ||||
|     if (!$self->print->object_step_done(STEP_SLICE)) { | ||||
|         $self->enabled(0); | ||||
|         $self->slider->Hide; | ||||
|         $self->canvas->Refresh;  # clears canvas | ||||
|         return; | ||||
|     } | ||||
|      | ||||
|     my $z_idx; | ||||
|     { | ||||
|         my %z = ();  # z => 1 | ||||
|         foreach my $object (@{$self->{print}->objects}) { | ||||
|             foreach my $layer (@{$object->layers}, @{$object->support_layers}) { | ||||
|                 $z{$layer->print_z} = 1; | ||||
|             } | ||||
|         } | ||||
|         $self->enabled(1); | ||||
|         $self->{layers_z} = [ sort { $a <=> $b } keys %z ]; | ||||
|         $self->slider->SetRange(0, scalar(@{$self->{layers_z}})-1); | ||||
|         if (($z_idx = $self->slider->GetValue) <= $#{$self->{layers_z}} && $self->slider->GetValue != 0) { | ||||
|             # use $z_idx | ||||
|         } else { | ||||
|             $self->slider->SetValue(scalar(@{$self->{layers_z}})-1); | ||||
|             $z_idx = @{$self->{layers_z}} ? -1 : undef; | ||||
|         } | ||||
|         $self->slider->Show; | ||||
|         $self->Layout; | ||||
|     } | ||||
|      | ||||
|     if ($self->IsShown) { | ||||
|         $self->canvas->load_gcode_preview($self->print); | ||||
| 
 | ||||
| #        # load skirt and brim | ||||
| #        $self->canvas->load_print_toolpaths($self->print); | ||||
| #         | ||||
| #        foreach my $object (@{$self->print->objects}) { | ||||
| #            $self->canvas->load_print_object_toolpaths($object); | ||||
| #             | ||||
| #            # Show the objects in very transparent color. | ||||
| #            #my @volume_ids = $self->canvas->load_object($object->model_object); | ||||
| #            #$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids; | ||||
| #        } | ||||
| 
 | ||||
|         $self->canvas->zoom_to_volumes; | ||||
|         $self->_loaded(1); | ||||
|     } | ||||
|      | ||||
|     $self->set_z($self->{layers_z}[$z_idx]); | ||||
| } | ||||
| 
 | ||||
| sub set_z { | ||||
|     my ($self, $z) = @_; | ||||
|      | ||||
|     return if !$self->enabled; | ||||
|     $self->{z_label}->SetLabel(sprintf '%.2f', $z); | ||||
|     $self->canvas->set_toolpaths_range(0, $z); | ||||
|     $self->canvas->Refresh if $self->IsShown; | ||||
| } | ||||
| 
 | ||||
| sub set_bed_shape { | ||||
|     my ($self, $bed_shape) = @_; | ||||
|     $self->canvas->set_bed_shape($bed_shape); | ||||
| } | ||||
| 
 | ||||
| 1; | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv