mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 02:41:17 +00:00
fix(GUI): honor "Ignore" when layer height exceeds the configured maximum (#14369)
* fix(GUI): honor "Ignore" when layer height exceeds the configured maximum Entering a layer height above the printer's max_layer_height on the Print Settings tab fired two guards in sequence. Tab::on_value_change prompts "...Adjust to the set range automatically?" with an Adjust/Ignore choice, and ConfigManipulation::update_print_fff_config then showed an OK-only "Too large layer height. Reset to X" dialog whose result was never checked, so it always reset the value. The second guard overrode the user's "Ignore", resetting the layer height regardless. Changes: - Extract the shared Adjust/Ignore dialog into ConfigManipulation::layer_height_out_of_range_dialog, reused by the tab (Tab::on_value_change) and the per-object/part settings panels. The dialog now names the value it will clamp to and reads correctly for too-low as well as too-high. - The tab/plate path is already covered by Tab::on_value_change, so the duplicate reset is dropped from update_print_fff_config. - The per-object/part panels have no on_value_change hook, so add ConfigManipulation::check_object_layer_height and call it from the object settings update paths, gated on the edited option (changed_opt_key == "layer_height"). It prompts once per layer-height edit and does not re-prompt when unrelated object settings change after the user chose "Ignore". Fixes #14214 * refactor(GUI): unify the layer-height range check across tab and object panels Copilot review of #14369 noted that the per-object check only guarded the max at extruder 0 and skipped the too-low case, diverging from the tab. Move the whole range check into ConfigManipulation::check_layer_height, used by both Tab::on_value_change and the per-object/part panels. It takes the widest [min, max] window across the printer's extruders, offers Adjust/Ignore in both directions, and resets a near-zero value. The tab's inline block collapses to one call, dropping the duplicated limit logic. * fix(GUI): only enforce layer-height limits that are actually set max_layer_height defaults to 0 (unset), so the unconditional range check offered to clamp any layer height to 0 on presets that don't define it. Guard each branch (near-zero, too-high, too-low) so an unset limit disables that direction; the slice-time nozzle-diameter check still applies. Also run check_layer_height before update_print_fff_config in the object panels so a near-zero per-object value prompts the same way the tab does, with update_print_fff_config's fallback still covering the no-minimum case.
This commit is contained in:
+2
-36
@@ -2136,43 +2136,9 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
m_last_sparse_infill_rotate_template_value = m_config->opt_string("sparse_infill_rotate_template");
|
||||
}
|
||||
|
||||
if(opt_key=="layer_height"){
|
||||
auto min_layer_height_from_nozzle=m_preset_bundle->full_config().option<ConfigOptionFloats>("min_layer_height")->values;
|
||||
auto max_layer_height_from_nozzle=m_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());
|
||||
const auto lh = m_config->opt_float("layer_height");
|
||||
bool exceed_minimum_flag = lh < layer_height_floor;
|
||||
bool exceed_maximum_flag = lh > layer_height_ceil;
|
||||
|
||||
if (exceed_maximum_flag || exceed_minimum_flag) {
|
||||
if (lh < EPSILON) {
|
||||
auto 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);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
if (opt_key == "layer_height") {
|
||||
if (m_config_manipulation.check_layer_height(m_config))
|
||||
wxGetApp().plater()->update();
|
||||
}
|
||||
}
|
||||
|
||||
string opt_key_without_idx = opt_key.substr(0, opt_key.find('#'));
|
||||
|
||||
Reference in New Issue
Block a user