Add safety check for seam_slope_start_height

This commit is contained in:
SoftFever 2024-03-16 17:39:14 +08:00
parent 1943259ac3
commit 550c4d6ca1
3 changed files with 18 additions and 4 deletions

View file

@ -4679,6 +4679,8 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
double h = paths.front().height; double h = paths.front().height;
start_slope_ratio = m_config.seam_slope_start_height.value / h; start_slope_ratio = m_config.seam_slope_start_height.value / h;
} }
if (start_slope_ratio >= 1)
start_slope_ratio = 0.99;
double loop_length = 0.; double loop_length = 0.;
for (const auto & path : paths) { for (const auto & path : paths) {

View file

@ -3601,6 +3601,7 @@ def = this->add("filament_loading_speed", coFloats);
def->tooltip = L("Start height of the scarf.\n" def->tooltip = L("Start height of the scarf.\n"
"This amount can be specified in millimeters or as a percentage of the current layer height. The default value for this parameter is 0."); "This amount can be specified in millimeters or as a percentage of the current layer height. The default value for this parameter is 0.");
def->sidetext = L("mm or %"); def->sidetext = L("mm or %");
def->ratio_over = "layer_height";
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); def->set_default_value(new ConfigOptionFloatOrPercent(0, false));

View file

@ -172,8 +172,9 @@ 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
auto layer_height = config->opt_float("layer_height");
auto gpreset = GUI::wxGetApp().preset_bundle->printers.get_edited_preset(); auto gpreset = GUI::wxGetApp().preset_bundle->printers.get_edited_preset();
if (config->opt_float("layer_height") < EPSILON) if (layer_height < EPSILON)
{ {
const wxString msg_text = _(L("Too small layer height.\nReset to 0.2")); const wxString msg_text = _(L("Too small layer height.\nReset to 0.2"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK); MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
@ -187,7 +188,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
//BBS: limite the max layer_herght //BBS: limite the max layer_herght
auto max_lh = gpreset.config.opt_float("max_layer_height",0); auto max_lh = gpreset.config.opt_float("max_layer_height",0);
if (max_lh > 0.2 && config->opt_float("layer_height") > max_lh+ EPSILON) if (max_lh > 0.2 && layer_height > max_lh+ EPSILON)
{ {
const wxString msg_text = wxString::Format(L"Too large layer height.\nReset to %0.3f", max_lh); 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);
@ -398,7 +399,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
// BBS // BBS
if (has_wipe_tower && config->opt_bool("enable_support") && !config->opt_bool("independent_support_layer_height")) { if (has_wipe_tower && config->opt_bool("enable_support") && !config->opt_bool("independent_support_layer_height")) {
double layer_height = config->opt_float("layer_height");
double top_gap_raw = config->opt_float("support_top_z_distance"); double top_gap_raw = config->opt_float("support_top_z_distance");
//double bottom_gap_raw = config->opt_float("support_bottom_z_distance"); //double bottom_gap_raw = config->opt_float("support_bottom_z_distance");
double top_gap = std::round(top_gap_raw / layer_height) * layer_height; double top_gap = std::round(top_gap_raw / layer_height) * layer_height;
@ -469,6 +469,17 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
is_msg_dlg_already_exist = false; is_msg_dlg_already_exist = false;
} }
if (config->opt_enum<SeamScarfType>("seam_slope_type") != SeamScarfType::None &&
config->get_abs_value("seam_slope_start_height") >= layer_height) {
const wxString msg_text = _(L("seam_slope_start_height need to be smaller than layer_height.\nReset to 0."));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
new_conf.set_key_value("seam_slope_start_height", new ConfigOptionFloatOrPercent(0, false));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
} }
void ConfigManipulation::apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase *, ModelConfig *> const &configs) void ConfigManipulation::apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase *, ModelConfig *> const &configs)