mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 05:22:04 +08:00
Added a binary G-code switch into Preferences
This commit is contained in:
parent
2d130c71b6
commit
d50ecd80d1
@ -142,6 +142,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");
|
||||
|
@ -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();
|
||||
|
@ -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."),
|
||||
|
Loading…
x
Reference in New Issue
Block a user