diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 12796b435f..2ab55109c9 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -141,6 +141,9 @@ void AppConfig::set_defaults() if (get("auto_toolbar_size").empty()) set("auto_toolbar_size", "100"); + + if (get("use_binary_gcode_when_supported").empty()) + set("use_binary_gcode_when_supported", "1"); if (get("notify_release").empty()) set("notify_release", "all"); // or "none" or "release" @@ -686,25 +689,7 @@ bool AppConfig::update_skein_dir(const std::string &dir) return false; // do not save "shapes gallery" directory return this->set("recent", "skein_directory", dir); } -/* -std::string AppConfig::get_last_output_dir(const std::string &alt) const -{ - - const auto it = m_storage.find(""); - if (it != m_storage.end()) { - const auto it2 = it->second.find("last_output_path"); - const auto it3 = it->second.find("remember_output_path"); - if (it2 != it->second.end() && it3 != it->second.end() && ! it2->second.empty() && it3->second == "1") - return it2->second; - } - return alt; -} -void AppConfig::update_last_output_dir(const std::string &dir) -{ - this->set("", "last_output_path", dir); -} -*/ std::string AppConfig::get_last_output_dir(const std::string& alt, const bool removable) const { std::string s1 = (removable ? "last_output_path_removable" : "last_output_path"); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 67ed5a7e89..b16477cabc 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3343,6 +3343,10 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool // bitmap of enum UpdateBackgroundProcessReturnState unsigned int return_state = 0; + // Get the config ready. The binary gcode flag depends on Preferences, which the backend has no access to. + DynamicPrintConfig full_config = wxGetApp().preset_bundle->full_config(); + full_config.set("binary_gcode", bool(full_config.opt_bool("binary_gcode") & wxGetApp().app_config->get_bool("use_binary_gcode_when_supported"))); + // If the update_background_process() was not called by the timer, kill the timer, // so the update_restart_background_process() will not be called again in vain. background_process_timer.Stop(); @@ -3350,7 +3354,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool update_print_volume_state(); // Apply new config to the possibly running background task. bool was_running = background_process.running(); - Print::ApplyStatus invalidated = background_process.apply(q->model(), wxGetApp().preset_bundle->full_config()); + Print::ApplyStatus invalidated = background_process.apply(q->model(), full_config); // Just redraw the 3D canvas without reloading the scene to consume the update of the layer height profile. if (view3D->is_layers_editing_enabled()) @@ -6797,7 +6801,9 @@ void Plater::export_gcode(bool prefer_removable) _L("The following characters are not allowed by a FAT file system:") + " <>:/\\|?*\""; return true; } - err_out = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode")); + bool supports_binary = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode"); + bool uses_binary = wxGetApp().app_config->get_bool("use_binary_gcode_when_supported"); + err_out = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, supports_binary && uses_binary); return !err_out.IsEmpty(); }; @@ -6806,7 +6812,9 @@ void Plater::export_gcode(bool prefer_removable) ErrorDialog(this, error_str, [this](const std::string& key) -> void { sidebar().jump_to_option(key); }).ShowModal(); output_path.clear(); } else { - alert_when_exporting_binary_gcode(wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode"), + bool supports_binary = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode"); + bool uses_binary = wxGetApp().app_config->get_bool("use_binary_gcode_when_supported"); + alert_when_exporting_binary_gcode(supports_binary && uses_binary, wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_notes")); } } @@ -7358,7 +7366,8 @@ void Plater::send_gcode() { const std::string ext = boost::algorithm::to_lower_copy(dlg.filename().extension().string()); - const bool binary_output = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode"); + const bool binary_output = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode") && + wxGetApp().app_config->get_bool("use_binary_gcode_when_supported"); const wxString error_str = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, binary_output); if (! error_str.IsEmpty()) { ErrorDialog(this, error_str, t_kill_focus([](const std::string& key) -> void { wxGetApp().sidebar().jump_to_option(key); })).ShowModal(); @@ -7366,7 +7375,9 @@ void Plater::send_gcode() } } - alert_when_exporting_binary_gcode(wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode"), + bool supports_binary = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode"); + bool uses_binary = wxGetApp().app_config->get_bool("use_binary_gcode_when_supported"); + alert_when_exporting_binary_gcode(supports_binary && uses_binary, wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_notes")); upload_job.upload_data.upload_path = dlg.filename(); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index f3bfe59fb2..55e22f58c1 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -629,6 +629,11 @@ void PreferencesDialog::build() }; + append_bool_option(m_optgroup_other, "use_binary_gcode_when_supported", L("Use binary G-code when the printer supports it"), + L("When checked and the 'Supports binary G-code' option is checked in Printer Settings, " + "the G-code will be exported in binary format."), + app_config->get_bool("use_binary_gcode_when_supported")); + append_bool_option(m_optgroup_other, "suppress_hyperlinks", L("Suppress to open hyperlink in browser"), L("If enabled, PrusaSlicer will not open a hyperlinks in your browser."),