From 6e1d10bd0602f89172e82f1af7b3e7be19b30fbb Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 11 Sep 2016 11:02:19 -0500 Subject: [PATCH] Added a reslice now option to main menu, bound it to ctrl+s. Reslicing stops the background process before starting a new one. --- lib/Slic3r/GUI/MainFrame.pm | 10 ++++++++++ lib/Slic3r/GUI/Plater.pm | 12 ++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index d97ad22efc..9aefb7b6cc 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -87,6 +87,13 @@ sub new { return $self; } +sub reslice_now { + my ($self) = @_; + + if ($self->{plater}) { + $self->{plater}->reslice; + } +} sub _init_tabpanel { my ($self) = @_; @@ -205,6 +212,9 @@ sub _init_menubar { $self->_append_menu_item($fileMenu, "Slice to SV&G…\tCtrl+G", 'Slice file to SVG', sub { $self->quick_slice(save_as => 1, export_svg => 1); }, undef, 'shape_handles.png'); + $self->_append_menu_item($fileMenu, "(&Re)Slice Now\tCtrl+S", 'Start new slicing process', sub { + $self->reslice_now; + }, undef, 'shape_handles.png'); $fileMenu->AppendSeparator(); $self->_append_menu_item($fileMenu, "Repair STL file…", 'Automatically repair an STL file', sub { $self->repair_stl; diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index bbc817f881..648fd3b1e7 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -231,7 +231,7 @@ sub new { $self->export_gcode; }); EVT_BUTTON($self, $self->{btn_reslice}, sub { - $self->start_background_process; + $self->reslice; }); EVT_BUTTON($self, $self->{btn_print}, sub { $self->{print_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir()); @@ -634,6 +634,13 @@ sub bed_centerf { return Slic3r::Pointf->new(unscale($bed_center->x), unscale($bed_center->y)); #) } +sub reslice { + # explicitly cancel a previous thread and start a new one. + my ($self) = @_; + + $self->stop_background_process; + $self->start_background_process; +} sub remove { my $self = shift; my ($obj_idx) = @_; @@ -1610,12 +1617,13 @@ sub object_list_changed { my $have_objects = @{$self->{objects}} ? 1 : 0; my $method = $have_objects ? 'Enable' : 'Disable'; $self->{"btn_$_"}->$method - for grep $self->{"btn_$_"}, qw(reset arrange export_gcode export_stl print send_gcode); + for grep $self->{"btn_$_"}, qw(reslice reset arrange export_gcode export_stl print send_gcode); if ($self->{export_gcode_output_file} || $self->{send_gcode_file}) { $self->{btn_export_gcode}->Disable; $self->{btn_print}->Disable; $self->{btn_send_gcode}->Disable; + $self->{btn_reslice}->Disable; } if ($self->{htoolbar}) {