Fixed the "Export SVG..." menu item. #399

This commit is contained in:
Alessandro Ranellucci 2012-05-30 12:06:01 +02:00
parent 5eae22f8b0
commit 8aa20cd784
2 changed files with 6 additions and 8 deletions

View File

@ -169,6 +169,7 @@ sub new {
our $model_wildcard = "STL files (*.stl)|*.stl;*.STL|OBJ files (*.obj)|*.obj;*.OBJ|AMF files (*.amf)|*.amf;*.AMF;*.xml;*.XML"; our $model_wildcard = "STL files (*.stl)|*.stl;*.STL|OBJ files (*.obj)|*.obj;*.OBJ|AMF files (*.amf)|*.amf;*.AMF;*.xml;*.XML";
our $ini_wildcard = "INI files *.ini|*.ini;*.INI"; our $ini_wildcard = "INI files *.ini|*.ini;*.INI";
our $gcode_wildcard = "G-code files *.gcode|*.gcode;*.GCODE"; our $gcode_wildcard = "G-code files *.gcode|*.gcode;*.GCODE";
our $svg_wildcard = "SVG files *.svg|*.svg;*.SVG";
sub do_slice { sub do_slice {
my $self = shift; my $self = shift;
@ -229,7 +230,7 @@ sub do_slice {
$output_file = $print->expanded_output_filepath($output_file); $output_file = $print->expanded_output_filepath($output_file);
$output_file =~ s/\.gcode$/.svg/i if $params{export_svg}; $output_file =~ s/\.gcode$/.svg/i if $params{export_svg};
my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:', dirname($output_file), my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:', dirname($output_file),
basename($output_file), $gcode_wildcard, wxFD_SAVE); basename($output_file), $params{export_svg} ? $svg_wildcard : $gcode_wildcard, wxFD_SAVE);
if ($dlg->ShowModal != wxID_OK) { if ($dlg->ShowModal != wxID_OK) {
$dlg->Destroy; $dlg->Destroy;
return; return;
@ -246,7 +247,7 @@ sub do_slice {
{ {
my @warnings = (); my @warnings = ();
local $SIG{__WARN__} = sub { push @warnings, $_[0] }; local $SIG{__WARN__} = sub { push @warnings, $_[0] };
my %params = ( my %export_params = (
output_file => $output_file, output_file => $output_file,
status_cb => sub { status_cb => sub {
my ($percent, $message) = @_; my ($percent, $message) = @_;
@ -256,9 +257,9 @@ sub do_slice {
}, },
); );
if ($params{export_svg}) { if ($params{export_svg}) {
$print->export_svg(%params); $print->export_svg(%export_params);
} else { } else {
$print->export_gcode(%params); $print->export_gcode(%export_params);
} }
Slic3r::GUI::warning_catcher($self)->($_) for @warnings; Slic3r::GUI::warning_catcher($self)->($_) for @warnings;
} }

View File

@ -332,10 +332,7 @@ sub export_svg {
my $self = shift; my $self = shift;
my %params = @_; my %params = @_;
$_->slice for @{$self->objects}; $_->slice(keep_meshes => $params{keep_meshes}) for @{$self->objects};
unless ($params{keep_meshes}) {
$_->mesh(undef) for @{$self->objects}; # free memory
}
$self->arrange_objects; $self->arrange_objects;
my $output_file = $self->expanded_output_filepath($params{output_file}); my $output_file = $self->expanded_output_filepath($params{output_file});