File wildcards now include an extension of a file provided
as a default. This is useful for the G-code or SLA export, as one may chose his own file extension for the export file.
This commit is contained in:
parent
ce6937c725
commit
fbbfcf70d3
5 changed files with 38 additions and 26 deletions
|
@ -296,7 +296,7 @@ void BedShapePanel::update_shape()
|
||||||
void BedShapePanel::load_stl()
|
void BedShapePanel::load_stl()
|
||||||
{
|
{
|
||||||
auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "",
|
auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "",
|
||||||
file_wildcards[FT_MODEL], wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
file_wildcards(FT_MODEL), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
if (dialog->ShowModal() != wxID_OK) {
|
if (dialog->ShowModal() != wxID_OK) {
|
||||||
dialog->Destroy();
|
dialog->Destroy();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,20 +39,30 @@ namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
const wxString file_wildcards[FT_SIZE] = {
|
wxString file_wildcards(FileType file_type, const std::string &custom_extension)
|
||||||
/* FT_STL */ "STL files (*.stl)|*.stl;*.STL",
|
{
|
||||||
/* FT_OBJ */ "OBJ files (*.obj)|*.obj;*.OBJ",
|
static const wxString defaults[FT_SIZE] = {
|
||||||
/* FT_AMF */ "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML",
|
/* FT_STL */ "STL files (*.stl)|*.stl;*.STL",
|
||||||
/* FT_3MF */ "3MF files (*.3mf)|*.3mf;*.3MF;",
|
/* FT_OBJ */ "OBJ files (*.obj)|*.obj;*.OBJ",
|
||||||
/* FT_PRUSA */ "Prusa Control files (*.prusa)|*.prusa;*.PRUSA",
|
/* FT_AMF */ "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML",
|
||||||
/* FT_GCODE */ "G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC",
|
/* FT_3MF */ "3MF files (*.3mf)|*.3mf;*.3MF;",
|
||||||
/* FT_MODEL */ "Known files (*.stl, *.obj, *.amf, *.xml, *.3mf, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.3mf;*.3MF;*.prusa;*.PRUSA",
|
/* FT_PRUSA */ "Prusa Control files (*.prusa)|*.prusa;*.PRUSA",
|
||||||
|
/* FT_GCODE */ "G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC",
|
||||||
|
/* FT_MODEL */ "Known files (*.stl, *.obj, *.amf, *.xml, *.3mf, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.3mf;*.3MF;*.prusa;*.PRUSA",
|
||||||
|
|
||||||
/* FT_INI */ "INI files *.ini|*.ini;*.INI",
|
/* FT_INI */ "INI files (*.ini)|*.ini;*.INI",
|
||||||
/* FT_SVG */ "SVG files *.svg|*.svg;*.SVG",
|
/* FT_SVG */ "SVG files (*.svg)|*.svg;*.SVG",
|
||||||
/* FT_PNGZIP */"Zipped PNG files *.zip|*.zip;*.ZIP", // This is lame, but that's what we use for SLA
|
/* FT_PNGZIP */"Zipped PNG files (*.zip)|*.zip;*.ZIP", // This is lame, but that's what we use for SLA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxString out = defaults[file_type];
|
||||||
|
if (! custom_extension.empty()) {
|
||||||
|
// Append the custom extension to the wildcards, so that the file dialog would not add the default extension to it.
|
||||||
|
out += ";*";
|
||||||
|
out += from_u8(custom_extension);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
|
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
|
||||||
|
|
||||||
|
@ -324,7 +334,7 @@ void GUI_App::load_project(wxWindow *parent, wxString& input_file)
|
||||||
wxFileDialog dialog(parent ? parent : GetTopWindow(),
|
wxFileDialog dialog(parent ? parent : GetTopWindow(),
|
||||||
_(L("Choose one file (3MF):")),
|
_(L("Choose one file (3MF):")),
|
||||||
app_config->get_last_dir(), "",
|
app_config->get_last_dir(), "",
|
||||||
file_wildcards[FT_3MF], wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
file_wildcards(FT_3MF), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
|
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
input_file = dialog.GetPath();
|
input_file = dialog.GetPath();
|
||||||
|
@ -336,7 +346,7 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files)
|
||||||
wxFileDialog dialog(parent ? parent : GetTopWindow(),
|
wxFileDialog dialog(parent ? parent : GetTopWindow(),
|
||||||
_(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")),
|
_(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")),
|
||||||
app_config->get_last_dir(), "",
|
app_config->get_last_dir(), "",
|
||||||
file_wildcards[FT_MODEL], wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
|
file_wildcards(FT_MODEL), wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
|
||||||
|
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
dialog.GetPaths(input_files);
|
dialog.GetPaths(input_files);
|
||||||
|
|
|
@ -48,7 +48,7 @@ enum FileType
|
||||||
FT_SIZE,
|
FT_SIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const wxString file_wildcards[FT_SIZE];
|
extern wxString file_wildcards(FileType file_type, const std::string &custom_extension = std::string());
|
||||||
|
|
||||||
enum ConfigMenuIDs {
|
enum ConfigMenuIDs {
|
||||||
ConfigMenuWizard,
|
ConfigMenuWizard,
|
||||||
|
|
|
@ -446,7 +446,7 @@ void MainFrame::quick_slice(const int qs)
|
||||||
if (!(qs & qsReslice)) {
|
if (!(qs & qsReslice)) {
|
||||||
auto dlg = new wxFileDialog(this, _(L("Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):")),
|
auto dlg = new wxFileDialog(this, _(L("Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):")),
|
||||||
wxGetApp().app_config->get_last_dir(), "",
|
wxGetApp().app_config->get_last_dir(), "",
|
||||||
file_wildcards[FT_MODEL], wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
file_wildcards(FT_MODEL), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
if (dlg->ShowModal() != wxID_OK) {
|
if (dlg->ShowModal() != wxID_OK) {
|
||||||
dlg->Destroy();
|
dlg->Destroy();
|
||||||
return;
|
return;
|
||||||
|
@ -505,7 +505,7 @@ void MainFrame::quick_slice(const int qs)
|
||||||
// output_file = ~s / \.[gG][cC][oO][dD][eE]$ / .svg /;
|
// output_file = ~s / \.[gG][cC][oO][dD][eE]$ / .svg /;
|
||||||
auto dlg = new wxFileDialog(this, _(L("Save ")) + (qs & qsExportSVG ? _(L("SVG")) : _(L("G-code"))) + _(L(" file as:")),
|
auto dlg = new wxFileDialog(this, _(L("Save ")) + (qs & qsExportSVG ? _(L("SVG")) : _(L("G-code"))) + _(L(" file as:")),
|
||||||
wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)), get_base_name(input_file),
|
wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)), get_base_name(input_file),
|
||||||
qs & qsExportSVG ? file_wildcards[FT_SVG] : file_wildcards[FT_GCODE],
|
qs & qsExportSVG ? file_wildcards(FT_SVG) : file_wildcards(FT_GCODE),
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
if (dlg->ShowModal() != wxID_OK) {
|
if (dlg->ShowModal() != wxID_OK) {
|
||||||
dlg->Destroy();
|
dlg->Destroy();
|
||||||
|
@ -574,7 +574,7 @@ void MainFrame::repair_stl()
|
||||||
{
|
{
|
||||||
auto dlg = new wxFileDialog(this, _(L("Select the STL file to repair:")),
|
auto dlg = new wxFileDialog(this, _(L("Select the STL file to repair:")),
|
||||||
wxGetApp().app_config->get_last_dir(), "",
|
wxGetApp().app_config->get_last_dir(), "",
|
||||||
file_wildcards[FT_STL], wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
file_wildcards(FT_STL), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
if (dlg->ShowModal() != wxID_OK) {
|
if (dlg->ShowModal() != wxID_OK) {
|
||||||
dlg->Destroy();
|
dlg->Destroy();
|
||||||
return;
|
return;
|
||||||
|
@ -588,7 +588,7 @@ void MainFrame::repair_stl()
|
||||||
// output_file = ~s / \.[sS][tT][lL]$ / _fixed.obj / ;
|
// output_file = ~s / \.[sS][tT][lL]$ / _fixed.obj / ;
|
||||||
auto dlg = new wxFileDialog( this, L("Save OBJ file (less prone to coordinate errors than STL) as:"),
|
auto dlg = new wxFileDialog( this, L("Save OBJ file (less prone to coordinate errors than STL) as:"),
|
||||||
get_dir_name(output_file), get_base_name(output_file),
|
get_dir_name(output_file), get_base_name(output_file),
|
||||||
file_wildcards[FT_OBJ], wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
file_wildcards(FT_OBJ), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
if (dlg->ShowModal() != wxID_OK) {
|
if (dlg->ShowModal() != wxID_OK) {
|
||||||
dlg->Destroy();
|
dlg->Destroy();
|
||||||
return /*undef*/;
|
return /*undef*/;
|
||||||
|
@ -618,7 +618,7 @@ void MainFrame::export_config()
|
||||||
auto dlg = new wxFileDialog(this, _(L("Save configuration as:")),
|
auto dlg = new wxFileDialog(this, _(L("Save configuration as:")),
|
||||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
||||||
!m_last_config.IsEmpty() ? get_base_name(m_last_config) : "config.ini",
|
!m_last_config.IsEmpty() ? get_base_name(m_last_config) : "config.ini",
|
||||||
file_wildcards[FT_INI], wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
file_wildcards(FT_INI), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
wxString file;
|
wxString file;
|
||||||
if (dlg->ShowModal() == wxID_OK)
|
if (dlg->ShowModal() == wxID_OK)
|
||||||
file = dlg->GetPath();
|
file = dlg->GetPath();
|
||||||
|
@ -669,7 +669,7 @@ void MainFrame::export_configbundle()
|
||||||
auto dlg = new wxFileDialog(this, _(L("Save presets bundle as:")),
|
auto dlg = new wxFileDialog(this, _(L("Save presets bundle as:")),
|
||||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
||||||
"Slic3r_config_bundle.ini",
|
"Slic3r_config_bundle.ini",
|
||||||
file_wildcards[FT_INI], wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
file_wildcards(FT_INI), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
wxString file;
|
wxString file;
|
||||||
if (dlg->ShowModal() == wxID_OK)
|
if (dlg->ShowModal() == wxID_OK)
|
||||||
file = dlg->GetPath();
|
file = dlg->GetPath();
|
||||||
|
@ -695,7 +695,7 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
|
||||||
if (file.IsEmpty()) {
|
if (file.IsEmpty()) {
|
||||||
auto dlg = new wxFileDialog(this, _(L("Select configuration to load:")),
|
auto dlg = new wxFileDialog(this, _(L("Select configuration to load:")),
|
||||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
||||||
"config.ini", file_wildcards[FT_INI], wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
"config.ini", file_wildcards(FT_INI), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
if (dlg->ShowModal() != wxID_OK)
|
if (dlg->ShowModal() != wxID_OK)
|
||||||
return;
|
return;
|
||||||
file = dlg->GetPath();
|
file = dlg->GetPath();
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
@ -1563,10 +1565,10 @@ std::unique_ptr<CheckboxFileDialog> Plater::priv::get_export_file(GUI::FileType
|
||||||
case FT_AMF:
|
case FT_AMF:
|
||||||
case FT_3MF:
|
case FT_3MF:
|
||||||
case FT_GCODE:
|
case FT_GCODE:
|
||||||
wildcard = file_wildcards[file_type];
|
wildcard = file_wildcards(file_type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wildcard = file_wildcards[FT_MODEL];
|
wildcard = file_wildcards(FT_MODEL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2812,7 +2814,7 @@ void Plater::export_gcode(fs::path output_path)
|
||||||
wxFileDialog dlg(this, (printer_technology() == ptFFF) ? _(L("Save G-code file as:")) : _(L("Save Zip file as:")),
|
wxFileDialog dlg(this, (printer_technology() == ptFFF) ? _(L("Save G-code file as:")) : _(L("Save Zip file as:")),
|
||||||
start_dir,
|
start_dir,
|
||||||
default_output_file.filename().string(),
|
default_output_file.filename().string(),
|
||||||
GUI::file_wildcards[(printer_technology() == ptFFF) ? FT_GCODE : FT_PNGZIP],
|
GUI::file_wildcards((printer_technology() == ptFFF) ? FT_GCODE : FT_PNGZIP, default_output_file.extension().string()),
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue