diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index bfb8859ab..37df24e55 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1046,6 +1046,13 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(0.3); + def = this->add("exact_last_layer_height", coBool); + def->label = L("Exact last layer height"); + def->category = L("Layers and Perimeters"); + def->tooltip = L("This setting controls the height of last object layers to put the last layer at the exact highest height possible. Experimental."); + def->cli = "exact_last-layer-height=f"; + def->default_value = new ConfigOptionBool(false); + def = this->add("remaining_times", coBool); def->label = L("Supports remaining times"); def->tooltip = L("Emit M73 P[percent printed] R[remaining time in minutes] at 1 minute" @@ -2364,9 +2371,13 @@ void DynamicPrintConfig::normalize() opt->values.assign(opt->values.size(), false); // set all values to false } { - this->opt("perimeters", true)->value = 1; + this->opt("perimeters", true)->value = 1; this->opt("top_solid_layers", true)->value = 0; - this->opt("fill_density", true)->value = 0; + this->opt("fill_density", true)->value = 0; + this->opt("support_material", true)->value = false; + this->opt("support_material_enforce_layers")->value = 0; + this->opt("exact_last_layer_height", true)->value = false; + this->opt("ensure_vertical_shell_thickness", true)->value = false; } } } diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 837c4f682..31d8c6c6c 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -330,6 +330,7 @@ public: ConfigOptionBool infill_only_where_needed; ConfigOptionBool interface_shells; ConfigOptionFloat layer_height; + ConfigOptionBool exact_last_layer_height; ConfigOptionInt raft_layers; ConfigOptionEnum seam_position; // ConfigOptionFloat seam_preferred_direction; @@ -368,6 +369,7 @@ protected: OPT_PTR(infill_only_where_needed); OPT_PTR(interface_shells); OPT_PTR(layer_height); + OPT_PTR(exact_last_layer_height); OPT_PTR(raft_layers); OPT_PTR(seam_position); // OPT_PTR(seam_preferred_direction); diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index 1884590ae..2fb68c301 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -163,6 +163,7 @@ bool PrintObject::invalidate_state_by_config_options(const std::vectorreset_layer_height_profile(); diff --git a/xs/src/libslic3r/Slicing.cpp b/xs/src/libslic3r/Slicing.cpp index ca3b4f931..24043c824 100644 --- a/xs/src/libslic3r/Slicing.cpp +++ b/xs/src/libslic3r/Slicing.cpp @@ -71,6 +71,7 @@ SlicingParameters SlicingParameters::create_from_config( // Miniumum/maximum of the minimum layer height over all extruders. params.min_layer_height = MIN_LAYER_HEIGHT; params.max_layer_height = std::numeric_limits::max(); + params.exact_last_layer_height = object_config.exact_last_layer_height.value; if (object_config.support_material.value || params.base_raft_layers > 0) { // Has some form of support. Add the support layers to the minimum / maximum layer height limits. params.min_layer_height = std::max( @@ -553,7 +554,7 @@ std::vector generate_object_layers( } // Adjust the last layer to align with the top object layer exactly - if (out.size() > 0 && slicing_params.object_print_z_height() != out[out.size()-1]){ + if (out.size() > 0 && slicing_params.object_print_z_height() != out[out.size() - 1] && slicing_params.exact_last_layer_height) { float neededPrintZ = slicing_params.object_print_z_height(); int idx_layer = out.size() / 2 - 1; float diffZ = neededPrintZ - out[idx_layer * 2 + 1]; diff --git a/xs/src/libslic3r/Slicing.hpp b/xs/src/libslic3r/Slicing.hpp index b4a074bb5..249ae0063 100644 --- a/xs/src/libslic3r/Slicing.hpp +++ b/xs/src/libslic3r/Slicing.hpp @@ -57,6 +57,7 @@ struct SlicingParameters coordf_t min_layer_height; coordf_t max_layer_height; coordf_t max_suport_layer_height; + bool exact_last_layer_height; // First layer height of the print, this may be used for the first layer of the raft // or for the first layer of the print. diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index b68223b38..cbddff959 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -306,7 +306,7 @@ const std::vector& Preset::print_options() "elefant_foot_compensation", "xy_size_compensation", "hole_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", "only_one_perimeter_top", "single_extruder_multi_material_priming", "compatible_printers", "compatible_printers_condition", "inherits", - "infill_dense", "no_perimeter_unsupported", "min_perimeter_unsupported", "noperi_bridge_only" + "infill_dense", "no_perimeter_unsupported", "min_perimeter_unsupported", "noperi_bridge_only", "exact_last_layer_height" }; return s_opts; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 0150ca3b6..ab3efb7bc 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -786,7 +786,8 @@ void TabPrint::build() auto page = add_options_page(_(L("Layers and perimeters")), "layers.png"); auto optgroup = page->new_optgroup(_(L("Layer height"))); optgroup->append_single_option_line("layer_height"); - optgroup->append_single_option_line("first_layer_height"); + optgroup->append_single_option_line("first_layer_height"); + optgroup->append_single_option_line("exact_last_layer_height"); optgroup = page->new_optgroup(_(L("Vertical shells"))); optgroup->append_single_option_line("perimeters"); @@ -1042,15 +1043,22 @@ void TabPrint::update() double fill_density = m_config->option("fill_density")->value; - if (m_config->opt_bool("spiral_vase") && - !(m_config->opt_int("perimeters") == 1 && m_config->opt_int("top_solid_layers") == 0 && - fill_density == 0)) { + if (m_config->opt_bool("spiral_vase") && !( + m_config->opt_int("perimeters") == 1 + && m_config->opt_int("top_solid_layers") == 0 + && fill_density == 0 + && m_config->opt_bool("support_material") == false + && m_config->opt_int("support_material_enforce_layers") == 0 + && m_config->opt_bool("exact_last_layer_height") == false + && m_config->opt_bool("ensure_vertical_shell_thickness") == false + )) { wxString msg_text = _(L("The Spiral Vase mode requires:\n" "- one perimeter\n" "- no top solid layers\n" "- 0% fill density\n" "- no support material\n" "- no ensure_vertical_shell_thickness\n" + "- unchecked 'exact last layer height'\n" "\nShall I adjust those settings in order to enable Spiral Vase?")); auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Spiral Vase")), wxICON_WARNING | wxYES | wxNO); DynamicPrintConfig new_conf = *m_config; @@ -1059,7 +1067,8 @@ void TabPrint::update() new_conf.set_key_value("top_solid_layers", new ConfigOptionInt(0)); new_conf.set_key_value("fill_density", new ConfigOptionPercent(0)); new_conf.set_key_value("support_material", new ConfigOptionBool(false)); - new_conf.set_key_value("support_material_enforce_layers", new ConfigOptionInt(0)); + new_conf.set_key_value("support_material_enforce_layers", new ConfigOptionInt(0)); + new_conf.set_key_value("exact_last_layer_height", new ConfigOptionBool(false)); new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(false)); fill_density = 0; }