From 0ca757739255410ea94245c2d04ff05bdee94b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Mon, 12 Mar 2012 19:52:23 +0200 Subject: [PATCH] Added a Reslicing-function to the File menu. --- lib/Slic3r/GUI.pm | 6 ++++-- lib/Slic3r/GUI/SkeinPanel.pm | 32 ++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 6ac2472b..39d3344c 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -35,12 +35,14 @@ sub OnInit { $fileMenu->Append(2, "Open Config…"); $fileMenu->AppendSeparator(); $fileMenu->Append(3, "Slice…"); - $fileMenu->Append(4, "Slice and Save As…"); + $fileMenu->Append(4, "Reslice"); + $fileMenu->Append(5, "Slice and Save As…"); $menubar->Append($fileMenu, "&File"); EVT_MENU($frame, 1, sub { $panel->save_config }); EVT_MENU($frame, 2, sub { $panel->load_config }); EVT_MENU($frame, 3, sub { $panel->do_slice }); - EVT_MENU($frame, 4, sub { $panel->do_slice(save_as => 1) }); + EVT_MENU($frame, 4, sub { $panel->do_slice(reslice => 1) }); + EVT_MENU($frame, 5, sub { $panel->do_slice(save_as => 1) }); $box->SetSizeHints($frame); $frame->SetSizer($box); diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 573c4602..526495d6 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -11,6 +11,8 @@ use base 'Wx::Panel'; my $last_skein_dir; my $last_config_dir; +my $last_input_file; +my $last_output_file; our $last_config; sub new { @@ -179,9 +181,26 @@ sub do_slice { # select input file my $dir = $last_skein_dir || $last_config_dir || ""; - my $dialog = Wx::FileDialog->new($self, 'Choose a STL or AMF file to slice:', $dir, "", $model_wildcard, wxFD_OPEN); - return unless $dialog->ShowModal == wxID_OK; - my ($input_file) = $dialog->GetPaths; + + my $input_file; + if (!$params{reslice}) { + my $dialog = Wx::FileDialog->new($self, 'Choose a STL or AMF file to slice:', $dir, "", $model_wildcard, wxFD_OPEN); + return unless $dialog->ShowModal == wxID_OK; + $input_file = $dialog->GetPaths; + $last_input_file = $input_file; + } else { + if (!defined $last_input_file) { + Wx::MessageDialog->new($self, "No previously sliced file", + 'Confirm', wxICON_ERROR | wxOK)->ShowModal(); + return; + } + if (! -e $last_input_file) { + Wx::MessageDialog->new($self, "Cannot find previously sliced file!", + 'Confirm', wxICON_ERROR | wxOK)->ShowModal(); + return; + } + $input_file = $last_input_file; + } my $input_file_basename = basename($input_file); $last_skein_dir = dirname($input_file); @@ -197,12 +216,17 @@ sub do_slice { ); # select output file - if ($params{save_as}) { + if ($params{reslice}) { + if (defined $last_output_file) { + $skein->output_file($last_output_file); + } + } elsif ($params{save_as}) { my $output_file = $skein->expanded_output_filepath; my $dlg = Wx::FileDialog->new($self, 'Save gcode file as:', dirname($output_file), basename($output_file), $gcode_wildcard, wxFD_SAVE); return if $dlg->ShowModal != wxID_OK; $skein->output_file($dlg->GetPath); + $last_output_file = $dlg->GetPath; } # show processbar dialog