From 464421cfe4768d782e05ee25d5240292d522a509 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 18 Dec 2016 14:01:57 +0100 Subject: [PATCH] If background slicing is disabled, reslice automatically when selecting the preview tabs. When making changes, go back to the plater view. #2979 --- lib/Slic3r/GUI/Plater.pm | 25 ++++++++++++++++++++++--- lib/Slic3r/GUI/Plater/3DPreview.pm | 1 - 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index e496e1233..626564436 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -114,6 +114,7 @@ sub new { $self->{canvas}->on_instances_moved($on_instances_moved); # Initialize 3D toolpaths preview + $self->{preview3D_page_idx} = -1; if ($Slic3r::GUI::have_OpenGL) { $self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}); $self->{preview3D}->canvas->on_viewport_changed(sub { @@ -124,15 +125,29 @@ sub new { } # Initialize toolpaths preview + $self->{toolpaths2D_page_idx} = -1; if ($Slic3r::GUI::have_OpenGL) { $self->{toolpaths2D} = Slic3r::GUI::Plater::2DToolpaths->new($self->{preview_notebook}, $self->{print}); $self->{preview_notebook}->AddPage($self->{toolpaths2D}, 'Layers'); + $self->{toolpaths2D_page_idx} = $self->{preview_notebook}->GetPageCount-1; } EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{preview_notebook}, sub { - if ($self->{preview_notebook}->GetSelection == $self->{preview3D_page_idx}) { - $self->{preview3D}->load_print; - } + wxTheApp->CallAfter(sub { + my $sel = $self->{preview_notebook}->GetSelection; + if ($sel == $self->{preview3D_page_idx} || $sel == $self->{toolpaths2D_page_idx}) { + $self->{preview3D}->load_print; + + if (!$Slic3r::GUI::Settings->{_}{background_processing}) { + $self->statusbar->SetCancelCallback(sub { + $self->stop_background_process; + $self->statusbar->SetStatusText("Slicing cancelled"); + $self->{preview_notebook}->SetSelection(0); + }); + $self->start_background_process; + } + } + }); }); # toolbar for object manipulation @@ -1035,6 +1050,10 @@ sub split_object { sub schedule_background_process { my ($self) = @_; + if (!$Slic3r::GUI::Settings->{_}{background_processing}) { + $self->{preview_notebook}->SetSelection(0); + } + if (defined $self->{apply_config_timer}) { $self->{apply_config_timer}->Start(PROCESS_DELAY, 1); # 1 = one shot } diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index fa71fcb1d..c1d1cf57e 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -126,7 +126,6 @@ sub load_print { #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); }