From d9ed9149ae740218549187bc9aa488a1e667c490 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 21 Apr 2021 12:09:36 +0200 Subject: [PATCH] 1) Moved first_layer_heigth frrom PrintObjectConfig to PrintConfig. Thus the first_layer_height is no more object specific. That makes a lot of sense due to the brim calculation being performed over all layers at once and due to future merging of supports of different objects at first layer. 2) Because now first_layer_height is print specific, the relative first layer height derived from the object layer height was partially disabled: First the relative first layer height is converted to an absolute value when importing config, second the side text was changed from "mm or %" to "mm". Still the UI allows entering %. Both changes may be controversial, let's wait for user feedback. --- src/libslic3r/Config.cpp | 4 ++-- src/libslic3r/Flow.cpp | 7 ++++--- src/libslic3r/GCode.cpp | 2 +- src/libslic3r/Preset.cpp | 7 +++++++ src/libslic3r/PrintConfig.cpp | 8 +++----- src/libslic3r/PrintConfig.hpp | 4 ++-- src/libslic3r/Slicing.cpp | 4 ++-- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 6755a63781..5db1d8179b 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -471,8 +471,8 @@ bool ConfigBase::set_deserialize_nothrow(const t_config_option_key &opt_key_src, { t_config_option_key opt_key = opt_key_src; std::string value = value_src; - // Both opt_key and value may be modified by _handle_legacy(). - // If the opt_key is no more valid in this version of Slic3r, opt_key is cleared by _handle_legacy(). + // Both opt_key and value may be modified by handle_legacy(). + // If the opt_key is no more valid in this version of Slic3r, opt_key is cleared by handle_legacy(). this->handle_legacy(opt_key, value); if (opt_key.empty()) // Ignore the option. diff --git a/src/libslic3r/Flow.cpp b/src/libslic3r/Flow.cpp index 1645bf683a..56d537c398 100644 --- a/src/libslic3r/Flow.cpp +++ b/src/libslic3r/Flow.cpp @@ -238,13 +238,14 @@ Flow support_material_flow(const PrintObject *object, float layer_height) Flow support_material_1st_layer_flow(const PrintObject *object, float layer_height) { - const auto &width = (object->print()->config().first_layer_extrusion_width.value > 0) ? object->print()->config().first_layer_extrusion_width : object->config().support_material_extrusion_width; + const PrintConfig &print_config = object->print()->config(); + const auto &width = (print_config.first_layer_extrusion_width.value > 0) ? print_config.first_layer_extrusion_width : object->config().support_material_extrusion_width; return Flow::new_from_config_width( frSupportMaterial, // The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution. (width.value > 0) ? width : object->config().extrusion_width, - float(object->print()->config().nozzle_diameter.get_at(object->config().support_material_extruder-1)), - (layer_height > 0.f) ? layer_height : float(object->config().first_layer_height.get_abs_value(object->config().layer_height.value))); + float(print_config.nozzle_diameter.get_at(object->config().support_material_extruder-1)), + (layer_height > 0.f) ? layer_height : float(print_config.first_layer_height.get_abs_value(object->config().layer_height.value))); } Flow support_material_interface_flow(const PrintObject *object, float layer_height) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index a799408109..0d65b71247 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1111,7 +1111,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu // Write some terse information on the slicing parameters. const PrintObject *first_object = print.objects().front(); const double layer_height = first_object->config().layer_height.value; - const double first_layer_height = first_object->config().first_layer_height.get_abs_value(layer_height); + const double first_layer_height = print.config().first_layer_height.get_abs_value(layer_height); for (const PrintRegion* region : print.regions()) { _write_format(file, "; external perimeters extrusion width = %.2fmm\n", region->flow(*first_object, frExternalPerimeter, layer_height).width()); _write_format(file, "; perimeters extrusion width = %.2fmm\n", region->flow(*first_object, frPerimeter, layer_height).width()); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 7db61a20f1..c6a86b7193 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -296,6 +296,13 @@ void Preset::normalize(DynamicPrintConfig &config) if (auto *gap_fill_enabled = config.option("gap_fill_enabled", false); gap_fill_enabled) gap_fill_enabled->value = false; } + if (auto *first_layer_height = config.option("first_layer_height", false); first_layer_height && first_layer_height->percent) + if (const auto *layer_height = config.option("layer_height", false); layer_height) { + // Legacy conversion - first_layer_height moved from PrintObject setting to a Print setting, thus we are getting rid of the dependency + // of first_layer_height on PrintObject specific layer_height. Covert the first layer heigth to an absolute value. + first_layer_height->value = first_layer_height->get_abs_value(layer_height->value); + first_layer_height->percent = false; + } } std::string Preset::remove_invalid_keys(DynamicPrintConfig &config, const DynamicPrintConfig &default_config) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 5516b298d3..9f09bc9f34 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -995,10 +995,8 @@ void PrintConfigDef::init_fff_params() def->label = L("First layer height"); def->category = L("Layers and Perimeters"); def->tooltip = L("When printing with very low layer heights, you might still want to print a thicker " - "bottom layer to improve adhesion and tolerance for non perfect build plates. " - "This can be expressed as an absolute value or as a percentage (for example: 150%) " - "over the default layer height."); - def->sidetext = L("mm or %"); + "bottom layer to improve adhesion and tolerance for non perfect build plates."); + def->sidetext = L("mm"); def->ratio_over = "layer_height"; def->set_default_value(new ConfigOptionFloatOrPercent(0.35, false)); @@ -3628,7 +3626,7 @@ std::string FullPrintConfig::validate() return "--layer-height must be a multiple of print resolution"; // --first-layer-height - if (this->get_abs_value("first_layer_height") <= 0) + if (first_layer_height.value <= 0) return "Invalid value for --first-layer-height"; // --filament-diameter diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index aab5096624..74cb5c7748 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -496,7 +496,6 @@ public: ConfigOptionBool dont_support_bridges; ConfigOptionFloat elefant_foot_compensation; ConfigOptionFloatOrPercent extrusion_width; - ConfigOptionFloatOrPercent first_layer_height; ConfigOptionBool infill_only_where_needed; // Force the generation of solid shells between adjacent materials/volumes. ConfigOptionBool interface_shells; @@ -555,7 +554,6 @@ protected: OPT_PTR(dont_support_bridges); OPT_PTR(elefant_foot_compensation); OPT_PTR(extrusion_width); - OPT_PTR(first_layer_height); OPT_PTR(infill_only_where_needed); OPT_PTR(interface_shells); OPT_PTR(layer_height); @@ -950,6 +948,7 @@ public: ConfigOptionFloat first_layer_acceleration; ConfigOptionInts first_layer_bed_temperature; ConfigOptionFloatOrPercent first_layer_extrusion_width; + ConfigOptionFloatOrPercent first_layer_height; ConfigOptionFloatOrPercent first_layer_speed; ConfigOptionInts first_layer_temperature; ConfigOptionInts full_fan_speed_layer; @@ -1025,6 +1024,7 @@ protected: OPT_PTR(first_layer_acceleration); OPT_PTR(first_layer_bed_temperature); OPT_PTR(first_layer_extrusion_width); + OPT_PTR(first_layer_height); OPT_PTR(first_layer_speed); OPT_PTR(first_layer_temperature); OPT_PTR(full_fan_speed_layer); diff --git a/src/libslic3r/Slicing.cpp b/src/libslic3r/Slicing.cpp index d0b1e9ce26..98a5923aa0 100644 --- a/src/libslic3r/Slicing.cpp +++ b/src/libslic3r/Slicing.cpp @@ -64,9 +64,9 @@ SlicingParameters SlicingParameters::create_from_config( coordf_t object_height, const std::vector &object_extruders) { - coordf_t first_layer_height = (object_config.first_layer_height.value <= 0) ? + coordf_t first_layer_height = (print_config.first_layer_height.value <= 0) ? object_config.layer_height.value : - object_config.first_layer_height.get_abs_value(object_config.layer_height.value); + print_config.first_layer_height.get_abs_value(object_config.layer_height.value); // If object_config.support_material_extruder == 0 resp. object_config.support_material_interface_extruder == 0, // print_config.nozzle_diameter.get_at(size_t(-1)) returns the 0th nozzle diameter, // which is consistent with the requirement that if support_material_extruder == 0 resp. support_material_interface_extruder == 0,