From baeefc0ff55d7d47216fa8600d085e661bbdc2ec Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Thu, 19 Sep 2024 16:26:51 +0800 Subject: [PATCH] ENH: limit min layer height When set layer height smaller than episilon=0.0001, we will adjust the layer height to min_layer_height jira:NONE Signed-off-by: xun.zhang Change-Id: Ic39c24527942c77845b94c874924ebd142d74ea4 --- src/slic3r/GUI/Tab.cpp | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 04dab7a58..160e64ea6 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1478,25 +1478,37 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) auto max_layer_height_from_nozzle=wxGetApp().preset_bundle->full_config().option("max_layer_height")->values; auto layer_height_floor = *std::min_element(min_layer_height_from_nozzle.begin(), min_layer_height_from_nozzle.end()); auto layer_height_ceil = *std::max_element(max_layer_height_from_nozzle.begin(), max_layer_height_from_nozzle.end()); - bool exceed_minimum_flag = m_config->opt_float("layer_height") < layer_height_floor; - bool exceed_maximum_flag = m_config->opt_float("layer_height") > layer_height_ceil; + float layer_height = m_config->opt_float("layer_height"); + bool exceed_minimum_flag = layer_height < layer_height_floor; + bool exceed_maximum_flag = layer_height > layer_height_ceil; if (exceed_maximum_flag || exceed_minimum_flag) { - wxString msg_text = _(L("Layer height exceeds the limit in Printer Settings -> Extruder -> Layer height limits ,this may cause printing quality issues.")); - msg_text += "\n\n" + _(L("Adjust to the set range automatically? \n")); - MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO); - dialog.SetButtonLabel(wxID_YES, _L("Adjust")); - dialog.SetButtonLabel(wxID_NO, _L("Ignore")); - auto answer = dialog.ShowModal(); - auto new_conf = *m_config; - if (answer == wxID_YES) { - if (exceed_maximum_flag) - new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_ceil)); - if (exceed_minimum_flag) - new_conf.set_key_value("layer_height",new ConfigOptionFloat(layer_height_floor)); + if(layer_height < EPSILON){ + wxString msg_text = _(L("Layer height is too small.\nIt will set to min_layer_height\n")); + MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxOK); + dialog.SetButtonLabel(wxID_OK, _L("OK")); + dialog.ShowModal(); + auto new_conf = *m_config; + new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_floor)); m_config_manipulation.apply(m_config, &new_conf); } - wxGetApp().plater()->update(); + else{ + wxString msg_text = _(L("Layer height exceeds the limit in Printer Settings -> Extruder -> Layer height limits ,this may cause printing quality issues.")); + msg_text += "\n\n" + _(L("Adjust to the set range automatically? \n")); + MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO); + dialog.SetButtonLabel(wxID_YES, _L("Adjust")); + dialog.SetButtonLabel(wxID_NO, _L("Ignore")); + auto answer = dialog.ShowModal(); + auto new_conf = *m_config; + if (answer == wxID_YES) { + if (exceed_maximum_flag) + new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_ceil)); + if (exceed_minimum_flag) + new_conf.set_key_value("layer_height",new ConfigOptionFloat(layer_height_floor)); + m_config_manipulation.apply(m_config, &new_conf); + } + wxGetApp().plater()->update(); + } } }