ENH: set layer range error to warning
1. If layer range exceeds maximum/minimum layer range in printer settings,pop up a window to warn jira:[NEW] Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I0304ee790e557ecf967f355c171993d1f51b5057
This commit is contained in:
parent
d5c12f9b9d
commit
75e8e96846
|
@ -1229,25 +1229,6 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
||||||
if (layer_height > min_nozzle_diameter)
|
if (layer_height > min_nozzle_diameter)
|
||||||
return {L("Layer height cannot exceed nozzle diameter"), object, "layer_height"};
|
return {L("Layer height cannot exceed nozzle diameter"), object, "layer_height"};
|
||||||
|
|
||||||
double min_layer_height_from_nozzle = 0.01;
|
|
||||||
double max_layer_height_from_nozzle = std::numeric_limits<double>::max();
|
|
||||||
for (unsigned int extruder_id : extruders) {
|
|
||||||
min_layer_height_from_nozzle = std::max(min_layer_height_from_nozzle, m_config.min_layer_height.get_at(extruder_id));
|
|
||||||
max_layer_height_from_nozzle = std::min(max_layer_height_from_nozzle, m_config.max_layer_height.get_at(extruder_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layer_height > max_layer_height_from_nozzle ||
|
|
||||||
layer_height < min_layer_height_from_nozzle) {
|
|
||||||
return { L("Layer height cannot exceed the limit in Printer Settings -> Extruder -> Layer height limits"), object, "layer_height", STRING_EXCEPT_LAYER_HEIGHT_EXCEEDS_LIMIT };
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto range : object->m_model_object->layer_config_ranges) {
|
|
||||||
double range_layer_height = range.second.opt_float("layer_height");
|
|
||||||
if (range_layer_height > max_layer_height_from_nozzle ||
|
|
||||||
range_layer_height < min_layer_height_from_nozzle)
|
|
||||||
return { L("Layer height cannot exceed the limit in Printer Settings -> Extruder -> Layer height limits"), nullptr, "layer_height", STRING_EXCEPT_LAYER_HEIGHT_EXCEEDS_LIMIT };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate extrusion widths.
|
// Validate extrusion widths.
|
||||||
std::string err_msg;
|
std::string err_msg;
|
||||||
if (!validate_extrusion_width(object->config(), "line_width", layer_height, err_msg))
|
if (!validate_extrusion_width(object->config(), "line_width", layer_height, err_msg))
|
||||||
|
|
|
@ -1508,6 +1508,33 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(opt_key=="layer_height"){
|
||||||
|
auto min_layer_height_from_nozzle=wxGetApp().preset_bundle->full_config().option<ConfigOptionFloats>("min_layer_height")->values;
|
||||||
|
auto max_layer_height_from_nozzle=wxGetApp().preset_bundle->full_config().option<ConfigOptionFloats>("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;
|
||||||
|
|
||||||
|
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, "Adjust");
|
||||||
|
dialog.SetButtonLabel(wxID_NO, "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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// BBS
|
// BBS
|
||||||
#if 0
|
#if 0
|
||||||
if (opt_key == "extruders_count")
|
if (opt_key == "extruders_count")
|
||||||
|
|
Loading…
Reference in New Issue