From 8ae1dfd4d0184e854a419b6eb218ddc2aac94f1b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 15 May 2019 10:23:02 +0200 Subject: [PATCH] File->Open Project allows to load .amf files --- src/slic3r/GUI/GUI_App.cpp | 19 ++++++++++--------- src/slic3r/GUI/GUI_App.hpp | 1 + src/slic3r/GUI/MainFrame.cpp | 2 +- src/slic3r/GUI/Plater.cpp | 12 +++++++++++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 3880f1d79..cb8a459af 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -58,13 +58,14 @@ namespace GUI { wxString file_wildcards(FileType file_type, const std::string &custom_extension) { static const std::string defaults[FT_SIZE] = { - /* FT_STL */ "STL files (*.stl)|*.stl;*.STL", - /* FT_OBJ */ "OBJ files (*.obj)|*.obj;*.OBJ", - /* FT_AMF */ "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML", - /* FT_3MF */ "3MF files (*.3mf)|*.3mf;*.3MF;", - /* 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_STL */ "STL files (*.stl)|*.stl;*.STL", + /* FT_OBJ */ "OBJ files (*.obj)|*.obj;*.OBJ", + /* FT_AMF */ "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML", + /* FT_3MF */ "3MF files (*.3mf)|*.3mf;*.3MF;", + /* 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_PROJECT */ "Project files (*.3mf, *.amf)|*.3mf;*.3MF;*.amf;*.AMF", /* FT_INI */ "INI files (*.ini)|*.ini;*.INI", /* FT_SVG */ "SVG files (*.svg)|*.svg;*.SVG", @@ -501,9 +502,9 @@ void GUI_App::load_project(wxWindow *parent, wxString& input_file) { input_file.Clear(); wxFileDialog dialog(parent ? parent : GetTopWindow(), - _(L("Choose one file (3MF):")), + _(L("Choose one file (3MF/AMF):")), app_config->get_last_dir(), "", - file_wildcards(FT_3MF), wxFD_OPEN | wxFD_FILE_MUST_EXIST); + file_wildcards(FT_PROJECT), wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (dialog.ShowModal() == wxID_OK) input_file = dialog.GetPath(); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 0d0634826..1c9a462c6 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -40,6 +40,7 @@ enum FileType FT_PRUSA, FT_GCODE, FT_MODEL, + FT_PROJECT, FT_INI, FT_SVG, diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 876a3d954..4b625a73a 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -145,7 +145,7 @@ void MainFrame::update_title() wxString title = wxEmptyString; if (m_plater != nullptr) { - wxString project = from_path(into_path(m_plater->get_project_filename()).filename()); + wxString project = from_path(into_path(m_plater->get_project_filename()).stem()); if (!project.empty()) title += (project + " - "); } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index c61d8a263..568c84fb5 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -2947,7 +2948,16 @@ const wxString& Plater::priv::get_project_filename() const void Plater::priv::set_project_filename(const wxString& filename) { - m_project_filename = filename; + wxString copy = filename; + if (boost::algorithm::iends_with(copy, ".zip.amf")) + // we remove the .zip part of the extension + copy = boost::ireplace_last_copy(copy, ".zip.", "."); + + // we force 3mf extension + boost::filesystem::path full_path = into_path(copy); + full_path.replace_extension("3mf"); + + m_project_filename = from_path(full_path); wxGetApp().mainframe->update_title(); }