Restrict file types for model exports to what we are permitting (UX fix). Changed extension from .amf.xml -> .amf (common usage)

Fixes #3774
This commit is contained in:
Joseph Lenox 2017-03-19 00:31:14 -05:00
parent af8ae8d268
commit dddbe64b86
2 changed files with 12 additions and 3 deletions

View File

@ -53,6 +53,8 @@ use constant FILE_WILDCARDS => {
svg => 'SVG files *.svg|*.svg;*.SVG',
};
use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf)};
use constant STL_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(stl)};
use constant AMF_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(amf)};
our $datadir;
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.

View File

@ -1570,14 +1570,21 @@ sub _get_export_file {
my $self = shift;
my ($format) = @_;
my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml';
my $suffix = $format eq 'STL' ? '.stl' : '.amf';
my $output_file = $main::opt{output};
{
$output_file = $self->{print}->output_filepath($output_file // '');
$output_file =~ s/\.gcode$/$suffix/i;
my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
my $dlg;
$dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
basename($output_file), &Slic3r::GUI::STL_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT)
if $format eq 'STL';
$dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
basename($output_file), &Slic3r::GUI::AMF_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT)
if $format eq 'AMF';
if ($dlg->ShowModal != wxID_OK) {
$dlg->Destroy;
return undef;