Change layer height checking logic.

max min layer height should be compared against `Layer height limits` parameter instead of hardcoded value
This commit is contained in:
SoftFever 2022-12-17 16:05:49 +08:00
parent bafd7356d6
commit c08fc0c5dc

View file

@ -173,27 +173,30 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
return; return;
// layer_height shouldn't be equal to zero // layer_height shouldn't be equal to zero
if (config->opt_float("layer_height") < EPSILON) auto gpreset = GUI::wxGetApp().preset_bundle->printers.get_edited_preset();
auto min_lh = gpreset.config.opt_float("min_layer_height",0);
if (config->opt_float("layer_height") < min_lh)
{ {
const wxString msg_text = _(L("Too small layer height.\nReset to 0.2")); wxString msg_text = wxString::Format(L"Too small layer height.\nReset to %0.3f", min_lh);
MessageDialog dialog(m_msg_dlg_parent, msg_text,"", wxICON_WARNING | wxOK); MessageDialog dialog(m_msg_dlg_parent, msg_text,"", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config; DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true; is_msg_dlg_already_exist = true;
dialog.ShowModal(); dialog.ShowModal();
new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.2)); new_conf.set_key_value("layer_height", new ConfigOptionFloat(min_lh));
apply(config, &new_conf); apply(config, &new_conf);
is_msg_dlg_already_exist = false; is_msg_dlg_already_exist = false;
} }
//BBS: limite the max layer_herght //BBS: limite the max layer_herght
if (config->opt_float("layer_height") > 0.6 + EPSILON) auto max_lh = gpreset.config.opt_float("max_layer_height",0);
if (config->opt_float("layer_height") > max_lh+ EPSILON)
{ {
const wxString msg_text = _(L("Too large layer height.\nReset to 0.2")); const wxString msg_text = wxString::Format(L"Too large layer height.\nReset to %0.3f", max_lh);
MessageDialog dialog(nullptr, msg_text, "", wxICON_WARNING | wxOK); MessageDialog dialog(nullptr, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config; DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true; is_msg_dlg_already_exist = true;
dialog.ShowModal(); dialog.ShowModal();
new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.2)); new_conf.set_key_value("layer_height", new ConfigOptionFloat(max_lh));
apply(config, &new_conf); apply(config, &new_conf);
is_msg_dlg_already_exist = false; is_msg_dlg_already_exist = false;
} }