Refactor infill rotation (#10587)

* refactor Infill rotation template

* clean up comments

* set default solid_infill_rotate_template to empty

* Fix an issue that infill_direction solid_infill_direction not working as expected

* update based on feedback
This commit is contained in:
SoftFever
2025-09-02 22:53:56 +08:00
committed by GitHub
parent c0a69793d8
commit d7b9e65da0
8 changed files with 300 additions and 253 deletions

View File

@@ -1633,6 +1633,35 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
}
}
if (opt_key == "sparse_infill_rotate_template") {
// Orca: show warning dialog if rotate template for solid infill if not support
const auto _sparse_infill_pattern = m_config->option<ConfigOptionEnum<InfillPattern>>("sparse_infill_pattern")->value;
bool is_safe_to_rotate = _sparse_infill_pattern == ipRectilinear || _sparse_infill_pattern == ipLine ||
_sparse_infill_pattern == ipZigZag || _sparse_infill_pattern == ipCrossZag ||
_sparse_infill_pattern == ipLockedZag;
auto new_value = boost::any_cast<std::string>(value);
is_safe_to_rotate = is_safe_to_rotate || new_value.empty();
if (!is_safe_to_rotate) {
wxString msg_text = _(
L("Infill patterns are typically designed to handle rotation automatically to ensure proper printing and achieve their "
"intended effects (e.g., Gyroid, Cubic). Rotating the current sparse infill pattern may lead to insufficient support. "
"Please proceed with caution and thoroughly check for any potential printing issues."
"Are you sure you want to enable this option?"));
msg_text += "\n\n" + _(L("Are you sure you want to enable this option?"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO);
dialog.SetButtonLabel(wxID_YES, _L("Enable"));
dialog.SetButtonLabel(wxID_NO, _L("Cancel"));
if (dialog.ShowModal() == wxID_NO) {
DynamicPrintConfig new_conf = *m_config;
new_conf.set_key_value("sparse_infill_rotate_template", new ConfigOptionString(""));
m_config_manipulation.apply(m_config, &new_conf);
wxGetApp().plater()->update();
}
}
}
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;
@@ -2211,7 +2240,7 @@ void TabPrint::build()
optgroup->append_single_option_line("fill_multiline", "strength_settings_infill#fill-multiline");
optgroup->append_single_option_line("sparse_infill_pattern", "strength_settings_infill#sparse-infill-pattern");
optgroup->append_single_option_line("infill_direction", "strength_settings_infill#direction");
optgroup->append_single_option_line("sparse_infill_rotate_template", "strength_settings_infill#rotation");
optgroup->append_single_option_line("sparse_infill_rotate_template", "strength_settings_infill_rotation_template_metalanguage");
optgroup->append_single_option_line("skin_infill_density", "strength_settings_patterns#locked-zag");
optgroup->append_single_option_line("skeleton_infill_density", "strength_settings_patterns#locked-zag");
optgroup->append_single_option_line("infill_lock_depth", "strength_settings_patterns#locked-zag");
@@ -2227,7 +2256,7 @@ void TabPrint::build()
optgroup->append_single_option_line("infill_anchor", "strength_settings_infill#anchor");
optgroup->append_single_option_line("internal_solid_infill_pattern", "strength_settings_infill#internal-solid-infill");
optgroup->append_single_option_line("solid_infill_direction", "strength_settings_infill#direction");
optgroup->append_single_option_line("solid_infill_rotate_template", "strength_settings_infill#rotation");
optgroup->append_single_option_line("solid_infill_rotate_template", "strength_settings_infill_rotation_template_metalanguage");
optgroup->append_single_option_line("gap_fill_target", "strength_settings_infill#apply-gap-fill");
optgroup->append_single_option_line("filter_out_gap_fill", "strength_settings_infill#filter-out-tiny-gaps");
optgroup->append_single_option_line("infill_wall_overlap", "strength_settings_infill#infill-wall-overlap");