From 11c1c17245c495ce78a62351603a8b820463a88d Mon Sep 17 00:00:00 2001 From: SoftFever <103989404+SoftFever@users.noreply.github.com> Date: Sun, 12 Mar 2023 21:05:59 +0800 Subject: [PATCH] Added brim width setting for tree support --- src/libslic3r/Preset.cpp | 4 ++-- src/libslic3r/PrintConfig.cpp | 13 +++++++++++++ src/libslic3r/PrintConfig.hpp | 2 ++ src/libslic3r/PrintObject.cpp | 2 ++ src/libslic3r/TreeSupport.cpp | 6 +++++- src/slic3r/GUI/ConfigManipulation.cpp | 5 +++-- src/slic3r/GUI/Tab.cpp | 2 ++ 7 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 130332eb43..9af8077670 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -754,8 +754,8 @@ static std::vector s_Preset_print_options { "top_solid_infill_flow_ratio","bottom_solid_infill_flow_ratio","only_one_wall_first_layer", "print_flow_ratio", "seam_gap", "role_based_wipe_speed", "wipe_speed", "accel_to_decel_enable", "accel_to_decel_factor", "wipe_on_loops", "bridge_density", "precise_outer_wall", "overhang_speed_classic", "bridge_acceleration", - "sparse_infill_acceleration", "internal_solid_infill_acceleration", "tree_support_adaptive_layer_height", - "gcode_comments", "gcode_label_objects" + "sparse_infill_acceleration", "internal_solid_infill_acceleration", "tree_support_adaptive_layer_height", "tree_support_auto_brim", + "tree_support_brim_width", "gcode_comments", "gcode_label_objects" }; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index bfae8ce9de..c77db57239 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3049,6 +3049,19 @@ void PrintConfigDef::init_fff_params() def->category = L("Quality"); def->tooltip = L("Enabling this option means the height of tree support layer except the first will be automatically calculated "); def->set_default_value(new ConfigOptionBool(1)); + + def = this->add("tree_support_auto_brim", coBool); + def->label = L("Auto brim width"); + def->category = L("Quality"); + def->tooltip = L("Enabling this option means the width of the brim for tree support will be automatically calculated"); + def->set_default_value(new ConfigOptionBool(1)); + + def = this->add("tree_support_brim_width", coFloat); + def->label = L("Tree support brim width"); + def->category = L("Quality"); + def->min = 0.0; + def->tooltip = L("Distance from tree branch to the outermost brim line"); + def->set_default_value(new ConfigOptionFloat(3)); def = this->add("tree_support_branch_diameter", coFloat); def->label = L("Tree support branch diameter"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 24fb73b65a..47f95483e2 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -691,6 +691,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloat, tree_support_branch_angle)) ((ConfigOptionInt, tree_support_wall_count)) ((ConfigOptionBool, tree_support_adaptive_layer_height)) + ((ConfigOptionBool, tree_support_auto_brim)) + ((ConfigOptionFloat, tree_support_brim_width)) ((ConfigOptionBool, detect_narrow_internal_solid_infill)) // ((ConfigOptionBool, adaptive_layer_height)) ((ConfigOptionFloat, support_bottom_interface_spacing)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 49ddaa98af..63ad41dd64 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -775,6 +775,8 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "max_bridge_length" || opt_key == "initial_layer_line_width" || opt_key == "tree_support_adaptive_layer_height" + || opt_key == "tree_support_auto_brim" + || opt_key == "tree_support_brim_width" || opt_key == "tree_support_branch_distance" || opt_key == "tree_support_branch_diameter" || opt_key == "tree_support_branch_angle" diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index 44068c2e39..8ecae4069e 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -2161,7 +2161,11 @@ void TreeSupport::draw_circles(const std::vector>& contact_no } } if (layer_nr == 0 && m_raft_layers == 0) { - double brim_width = layers_to_top * layer_height / (scale * branch_radius) * 0.5; + double brim_width = + config.tree_support_auto_brim + ? layers_to_top * layer_height / + (scale * branch_radius) * 0.5 + : config.tree_support_brim_width; circle = offset(circle, scale_(brim_width))[0]; } area.emplace_back(ExPolygon(circle)); diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index fe36cd16d7..a970357337 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -613,14 +613,15 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co bool support_is_tree = config->opt_bool("enable_support") && is_tree(support_type); for (auto el : {"tree_support_branch_angle", "tree_support_wall_count", "tree_support_branch_distance", - "tree_support_branch_diameter", "tree_support_adaptive_layer_height"}) + "tree_support_branch_diameter", "tree_support_adaptive_layer_height", "tree_support_auto_brim", "tree_support_brim_width"}) toggle_field(el, support_is_tree); // hide tree support settings when normal is selected for (auto el : {"tree_support_branch_angle", "tree_support_wall_count", "tree_support_branch_distance", - "tree_support_branch_diameter", "max_bridge_length", "tree_support_adaptive_layer_height"}) + "tree_support_branch_diameter", "max_bridge_length", "tree_support_adaptive_layer_height", "tree_support_auto_brim", "tree_support_brim_width"}) toggle_line(el, support_is_tree); + toggle_field("tree_support_brim_width", support_is_tree && !config->opt_bool("tree_support_auto_brim")); // tree support use max_bridge_length instead of bridge_no_support toggle_line("bridge_no_support", !support_is_tree); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 07db8b82e9..fa19972f97 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2000,6 +2000,8 @@ void TabPrint::build() optgroup->append_single_option_line("tree_support_branch_angle", "support#tree-support-only-options"); optgroup->append_single_option_line("tree_support_wall_count"); optgroup->append_single_option_line("tree_support_adaptive_layer_height"); + optgroup->append_single_option_line("tree_support_auto_brim"); + optgroup->append_single_option_line("tree_support_brim_width"); optgroup->append_single_option_line("support_top_z_distance", "support#top-z-distance"); optgroup->append_single_option_line("support_bottom_z_distance", "support#bottom-z-distance"); optgroup->append_single_option_line("support_base_pattern", "support#base-pattern");