Skip to content

Commit

Permalink
Can disabled 4 other settings (instead of -1 value):
Browse files Browse the repository at this point in the history
 * overhangs_bridge_threshold
 * overhangs_bridge_upper_layers
 * perimeters_hole
 * support_material_bottom_interface_layers
  • Loading branch information
supermerill committed Aug 4, 2024
1 parent ef7cf96 commit 787415d
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 60 deletions.
2 changes: 1 addition & 1 deletion resources/ui_layout/default/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
page:Perimeters & Shell:shell
group:Vertical shells
line:Perimeters
setting:label$Contour:width$6:perimeters
setting:label$Contour:width$6:sidetext_width$10:perimeters
setting:label$Holes:width$6:perimeters_hole
end_line
setting:tags$Simple$Expert$SuSi:script:float:depends$perimeter_spacing$external_perimeter_spacing:label$Wall Thickness:tooltip$Change the perimeter extrusion widths to ensure that there is an exact number of perimeters for this wall thickness value. It won't put the perimeter width below the nozzle diameter, and up to double.\nNote that the value displayed is just a view of the current perimeter thickness, like the info text below. The number of perimeters used to compute this value is one loop, or the custom variable 'wall_thickness_lines' (advanced mode) if defined.\nIf the value is too low, it will revert the widths to the saved value.\nIf the value is set to 0, it will show 0.:s_wall_thickness
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,7 @@ class ConfigBase : public ConfigOptionResolver
bool get_bool(const t_config_option_key &opt_key, size_t idx = 0) const {return this->option(opt_key)->get_bool(idx);}
int32_t get_int(const t_config_option_key &opt_key, size_t idx = 0) const {return this->option(opt_key)->get_int(idx);}
double get_float(const t_config_option_key &opt_key, size_t idx = 0) const {return this->option(opt_key)->get_float(idx);}
bool is_enabled(const t_config_option_key &opt_key, size_t idx = 0) const {return this->option(opt_key)->is_enabled(idx);}

// In ConfigManipulation::toggle_print_fff_options, it is called on option with type ConfigOptionEnumGeneric* and also ConfigOptionEnum*.
// Thus the virtual method getInt() is used to retrieve the enum value.
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/Format/BBConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ void very_complicated_convert(ConfigSubstitutionContext &unconverted_config, Con
double overhangs_max_slope = std::tan(make_overhang_printable_angle) * layer_height;
conf_to_read_and_update.set_deserialize("overhangs_max_slope",
Slic3r::to_string_nozero(overhangs_max_slope, 3));
conf_to_read_and_update.set_deserialize("overhangs_bridge_threshold", "-1");
conf_to_read_and_update.set_deserialize("overhangs_bridge_upper_layers", "-1");
conf_to_read_and_update.set_deserialize("overhangs_bridge_threshold", "!0");
conf_to_read_and_update.set_deserialize("overhangs_bridge_upper_layers", "!0");
unconverted_config.erase("make_overhang_printable");
unconverted_config.erase("make_overhang_printable_angle");
} else {
Expand Down
23 changes: 13 additions & 10 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2760,23 +2760,26 @@ void PerimeterGenerator::process(// Input:

// detect how many perimeters must be generated for this island
int nb_loop_contour = params.config.perimeters;
assert(nb_loop_contour >= 0);
assert(params.config.perimeters.is_enabled());
if (nb_loop_contour > 0)
nb_loop_contour += extra_odd_perimeter + surface.extra_perimeters;
int nb_loop_holes = params.config.perimeters_hole;
if (nb_loop_holes > 0)
assert(nb_loop_contour >= 0);
int nb_loop_holes = params.config.perimeters_hole.value;
assert(nb_loop_holes >= 0);
if (params.config.perimeters_hole.is_enabled() && nb_loop_holes > 0)
nb_loop_holes += extra_odd_perimeter + surface.extra_perimeters;
assert(nb_loop_holes >= 0);

if (nb_loop_contour < 0)
nb_loop_contour = std::max(0, nb_loop_holes);
if (nb_loop_holes < 0)
if (!params.config.perimeters_hole.is_enabled())
nb_loop_holes = std::max(0, nb_loop_contour);

if (params.print_config.spiral_vase) {
if (params.layer->id() >= params.config.bottom_solid_layers) {
nb_loop_contour = 1;
nb_loop_holes = 0;
}
if (params.print_config.spiral_vase) {
if (params.layer->id() >= params.config.bottom_solid_layers) {
nb_loop_contour = 1;
nb_loop_holes = 0;
}
}

if ((params.layer->id() == 0 && params.config.only_one_perimeter_first_layer) ||
(params.config.only_one_perimeter_top && this->upper_slices == NULL)) {
Expand Down
72 changes: 44 additions & 28 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ namespace {
const int max_temp = 1500;
};

ConfigOption *disable_defaultoption(ConfigOption *option) {
return option->set_can_be_disabled()->set_enabled(false);
}

ConfigOptionVectorBase *disable_defaultoption(ConfigOptionVectorBase *option) {
return (ConfigOptionVectorBase *)option->set_can_be_disabled()->set_enabled(false);
}

PrintConfigDef::PrintConfigDef()
{
this->init_common_params();
Expand Down Expand Up @@ -824,8 +832,6 @@ void PrintConfigDef::init_fff_params()
{ "height", L("Layer height") },
{ "flow", L("Keep current flow") },
});
def->min = -1;
def->max = 100;
def->mode = comAdvancedE | comSuSi;
def->set_default_value(new ConfigOptionEnum<BridgeType>{ BridgeType::btFromNozzle });

Expand Down Expand Up @@ -1362,7 +1368,7 @@ void PrintConfigDef::init_fff_params()
def->max = 100;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));
def->aliases = { "min_fan_speed" }; // only if "fan_always_on"

def = this->add("default_print_profile", coString);
Expand Down Expand Up @@ -1660,7 +1666,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvancedE | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("external_perimeter_overlap", coPercent);
def->label = L("external perimeter overlap");
Expand Down Expand Up @@ -2904,7 +2910,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("gap_fill_flow_match_perimeter", coPercent);
def->label = L("Cap with perimeter flow");
Expand Down Expand Up @@ -3338,7 +3344,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("infill_first", coBool);
def->label = L("Infill before perimeters");
Expand Down Expand Up @@ -3436,7 +3442,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvancedE | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));
def->aliases = { "bridge_internal_fan_speed" };

def = this->add("internal_bridge_speed", coFloatOrPercent);
Expand Down Expand Up @@ -4144,7 +4150,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvancedE | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("overhangs_max_slope", coFloatOrPercent);
def->label = L("Overhangs max slope");
Expand All @@ -4164,23 +4170,25 @@ void PrintConfigDef::init_fff_params()
def->label = L("Bridge max length");
def->category = OptionCategory::slicing;
def->tooltip = L("Maximum distance for bridges. If the distance is over that, it will be considered as overhangs for 'overhangs_max_slope'."
"\nSet to -1 to accept all distances."
"\nIf disabled, accept all distances."
"\nSet to 0 to ignore bridges.");
def->sidetext = L("mm");
def->min = -1;
def->min = 0;
def->can_be_disabled = true;
def->mode = comExpert | comSuSi;
def->set_default_value(new ConfigOptionFloat(-1));
def->set_default_value(disable_defaultoption(new ConfigOptionFloat(0)));

def = this->add("overhangs_bridge_upper_layers", coInt);
def->label = L("Consider upper bridges");
def->category = OptionCategory::slicing;
def->tooltip = L("Don't put overhangs if the area will filled in next layer by bridges."
"\nSet to -1 to accept all upper layers."
"\nIf disabled, accept all upper layers."
"\nSet to 0 to only consider our layer bridges.");
def->sidetext = L("layers");
def->min = -1;
def->min = 0;
def->can_be_disabled = true;
def->mode = comExpert | comSuSi;
def->set_default_value(new ConfigOptionInt(0));
def->set_default_value(new ConfigOptionInt(2));

def = this->add("overhangs_speed", coFloatOrPercent);
def->label = L("Overhangs");
Expand Down Expand Up @@ -4409,7 +4417,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("perimeter_loop", coBool);
def->label = L("Perimeters loop");
Expand Down Expand Up @@ -4499,15 +4507,16 @@ void PrintConfigDef::init_fff_params()
def->category = OptionCategory::perimeter;
def->tooltip = L("This option sets the number of perimeters to have over holes."
" Note that if a hole-perimeter fuse with the contour, then it will go around like a contour perimeter.."
"\nSet to -1 to deactivate, then holes will have the same number of perimeters as contour."
"\nIf disabled, holes will have the same number of perimeters as contour."
"\nNote that Slic3r may increase this number automatically when it detects "
"sloping surfaces which benefit from a higher number of perimeters "
"if the Extra Perimeters option is enabled.");
def->sidetext = L("(minimum).");
def->min = -1;
def->min = 0;
def->max = 10000;
def->can_be_disabled = true;
def->mode = comAdvancedE | comSuSi;
def->set_default_value(new ConfigOptionInt(-1));
def->set_default_value(disable_defaultoption(new ConfigOptionInt(0)));

def = this->add("post_process", coStrings);
def->label = L("Post-processing scripts");
Expand Down Expand Up @@ -5399,7 +5408,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("solid_infill_speed", coFloatOrPercent);
def->label = L("Solid");
Expand Down Expand Up @@ -5777,7 +5786,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("support_material_interface_angle", coFloat);
def->label = L("Pattern angle");
Expand Down Expand Up @@ -5813,7 +5822,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvancedE | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));


def = this->add("support_material_interface_contact_loops", coBool);
Expand Down Expand Up @@ -5850,20 +5859,20 @@ void PrintConfigDef::init_fff_params()
def = this->add("support_material_bottom_interface_layers", coInt);
def->label = L("Bottom interface layers");
def->category = OptionCategory::support;
def->tooltip = L("Number of interface layers to insert between the object(s) and support material. "
"Set to -1 to use support_material_interface_layers");
def->tooltip = L("Number of interface layers to insert between the object(s) and support material."
"\nIf disabled, support_material_interface_layers value is used");
def->sidetext = L("layers");
def->min = -1;
def->min = 0;
def->can_be_disabled = true;
def->set_enum_values(ConfigOptionDef::GUIType::i_enum_open, {
//TRN Print Settings: "Bottom interface layers". Have to be as short as possible
{ "-1", L("Same as top") },
{ "0", L("0 (off)") },
{ "1", L("1 (light)") },
{ "2", L("2 (default)") },
{ "3", L("3 (heavy)") }
});
def->mode = comAdvancedE | comPrusa;
def->set_default_value(new ConfigOptionInt(-1));
def->set_default_value(disable_defaultoption(new ConfigOptionInt(0)));

def = this->add("support_material_closing_radius", coFloat);
def->label = L("Closing radius");
Expand Down Expand Up @@ -6360,7 +6369,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvancedE | comSuSi;
def->is_vector_extruder = true;
def->can_be_disabled = true;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts({ 100 }))->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts({ 100 })));

def = this->add("top_infill_extrusion_width", coFloatOrPercent);
def->label = L("Top solid infill");
Expand Down Expand Up @@ -7680,7 +7689,7 @@ void PrintConfigDef::init_sla_params()
def->max = max_temp;
def->can_be_disabled = true;
def->mode = comSimpleAE | comPrusa;
def->set_default_value((ConfigOptionInts*)(new ConfigOptionInts{30})->set_can_be_disabled()->set_enabled(false));
def->set_default_value(disable_defaultoption(new ConfigOptionInts{30}));

def = this->add("bottle_volume", coFloat);
def->label = L("Bottle volume");
Expand Down Expand Up @@ -8407,6 +8416,13 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
}
}

if (value == "-1") {
if ("overhangs_bridge_threshold" == opt_key) {value = "!0";}
if ("overhangs_bridge_upper_layers" == opt_key) {value = "!2";}
if ("perimeters_hole" == opt_key) {value = "!0";}
if ("support_material_bottom_interface_layers" == opt_key) {value = "!0";}
}

if (!print_config_def.has(opt_key)) {
//check the aliases
for(const auto& entry : print_config_def.options) {
Expand Down
21 changes: 16 additions & 5 deletions src/libslic3r/PrintObjectSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ void PrintObject::_min_overhang_threshold() {
// get bridgeable area
for (size_t region_idx = 0; region_idx < my_layer->m_regions.size(); ++region_idx) {
LayerRegion* lregion = my_layer->get_region(region_idx);
if (lregion->region().config().overhangs_bridge_threshold.value != 0) {
if (lregion->region().config().overhangs_bridge_threshold.value != 0 ||
!lregion->region().config().overhangs_bridge_threshold.is_enabled()) {
Surfaces & my_surfaces = lregion->m_slices.surfaces;
ExPolygons unsupported = to_expolygons(my_surfaces);
unsupported = diff_ex(unsupported, lower_layer->lslices, ApplySafetyOffset::Yes);
Expand All @@ -678,13 +679,17 @@ void PrintObject::_min_overhang_threshold() {
bridgeFlow.scaled_spacing(),
scale_t(this->print()->config().bridge_precision.get_abs_value(bridgeFlow.spacing())),
layer_idx);
detector.max_bridge_length = scale_d(std::max(0., lregion->region().config().overhangs_bridge_threshold.value));
if (lregion->region().config().overhangs_bridge_threshold.is_enabled()) {
detector.max_bridge_length = scale_d(std::max(0., lregion->region().config().overhangs_bridge_threshold.value));
} else {
detector.max_bridge_length = -1;
}
if (detector.detect_angle(0))
append(bridged_area, union_ex(detector.coverage()));
}
// then, check other layers
size_t max_layer_idx = lregion->region().config().overhangs_bridge_upper_layers.value;
if (max_layer_idx < 0) // -1 -> all layers
if (!lregion->region().config().overhangs_bridge_upper_layers.is_enabled()) // disabled -> all layers
max_layer_idx = this->layers().size();
if (max_layer_idx > 0) { // 0 -> don't check other layers
max_layer_idx += layer_idx;
Expand All @@ -703,7 +708,9 @@ void PrintObject::_min_overhang_threshold() {
ExPolygons new_bridged_area;
for (size_t other_region_idx = 0; other_region_idx < my_layer->m_regions.size(); ++other_region_idx) {
LayerRegion *other_lregion = my_layer->get_region(other_region_idx);
if (other_lregion->region().config().overhangs_bridge_threshold.value != 0 && other_lregion->region().config().overhangs_max_slope > 0) {
if ( (other_lregion->region().config().overhangs_bridge_threshold.value != 0 ||
!lregion->region().config().overhangs_bridge_threshold.is_enabled())
&& other_lregion->region().config().overhangs_max_slope > 0) {
coord_t enlargement = scale_t(my_layer->get_region(region_idx)->region().config().overhangs_max_slope.get_abs_value(unscaled(max_nz_diam)));
enlargement = std::max(enlargement, max_nz_diam);
Surfaces &my_surfaces = other_lregion->m_slices.surfaces;
Expand All @@ -716,7 +723,11 @@ void PrintObject::_min_overhang_threshold() {
scale_t(this->print()->config().bridge_precision.get_abs_value(bridgeFlow.spacing())),
other_layer_bridge_idx);
detector.layer_id = other_layer_bridge_idx;
detector.max_bridge_length = scale_d(std::max(0., other_lregion->region().config().overhangs_bridge_threshold.value));
if (lregion->region().config().overhangs_bridge_threshold.is_enabled()) {
detector.max_bridge_length = scale_d(std::max(0., other_lregion->region().config().overhangs_bridge_threshold.value));
} else {
detector.max_bridge_length = -1;
}
if (detector.detect_angle(0)) {
append(new_bridged_area, union_ex(detector.coverage()));
}
Expand Down
Loading

0 comments on commit 787415d

Please sign in to comment.