diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 46cbd9891c..1fe4816ad3 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -728,39 +728,6 @@ ConfigSubstitutions ConfigBase::load(const boost::property_tree::ptree &tree, Fo return std::move(substitutions_ctxt.substitutions); } -// Load the config keys from the tail of a G-code file. -ConfigSubstitutions ConfigBase::load_from_gcode_file(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule) -{ - try { - // Read a 64k block from the end of the G-code. - boost::nowide::ifstream ifs(file); - { - const char slic3r_gcode_header[] = "; generated by Slic3r "; - const char prusaslicer_gcode_header[] = "; generated by PrusaSlicer "; - std::string firstline; - std::getline(ifs, firstline); - if (strncmp(slic3r_gcode_header, firstline.c_str(), strlen(slic3r_gcode_header)) != 0 && - strncmp(prusaslicer_gcode_header, firstline.c_str(), strlen(prusaslicer_gcode_header)) != 0) - throw ConfigurationError("Not a PrusaSlicer / Slic3r PE generated g-code."); - } - ifs.seekg(0, ifs.end); - auto file_length = ifs.tellg(); - auto data_length = std::min(65535, file_length); - ifs.seekg(file_length - data_length, ifs.beg); - std::vector data(size_t(data_length) + 1, 0); - ifs.read(data.data(), data_length); - ifs.close(); - - ConfigSubstitutionContext substitutions_ctxt(compatibility_rule); - size_t key_value_pairs = load_from_gcode_string(data.data(), substitutions_ctxt); - if (key_value_pairs < 80) - throw ConfigurationError(format("Suspiciously low number of configuration values extracted from %1%: %2%", file, key_value_pairs)); - return std::move(substitutions_ctxt.substitutions); - } catch (const ConfigurationError &e) { - throw ConfigurationError(format("Failed loading configuration from G-code \"%1%\": %2%", file, e.what())); - } -} - // Load the config keys from the given string. static inline size_t load_from_gcode_string_legacy(ConfigBase &config, const char *str, ConfigSubstitutionContext &substitutions) { diff --git a/src/slic3r/GUI/Jobs/SLAImportJob.cpp b/src/slic3r/GUI/Jobs/SLAImportJob.cpp index 45b432b5c7..027bf68492 100644 --- a/src/slic3r/GUI/Jobs/SLAImportJob.cpp +++ b/src/slic3r/GUI/Jobs/SLAImportJob.cpp @@ -119,6 +119,7 @@ public: wxString path; Vec2i win = {2, 2}; std::string err; + ConfigSubstitutions config_substitutions; priv(Plater *plt) : plater{plt} {} }; diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index ac4fa44e6f..77617fea1b 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -114,6 +114,22 @@ public: #endif +// Generic info dialog, used for displaying exceptions +class InfoDialog : public MsgDialog +{ +public: + InfoDialog(wxWindow *parent, const wxString &title, const wxString &msg); + InfoDialog(InfoDialog&&) = delete; + InfoDialog(const InfoDialog&) = delete; + InfoDialog&operator=(InfoDialog&&) = delete; + InfoDialog&operator=(const InfoDialog&) = delete; + virtual ~InfoDialog() = default; + +private: + wxString msg; +}; + + } }