From 88d7620c068a777e639f77a38bad69519468e564 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 9 May 2023 13:42:45 +0200 Subject: [PATCH] Allow to set specific extruder for the wipe tower (first part) --- src/libslic3r/GCode/ToolOrdering.cpp | 26 ++++++++++++++++++++++++++ src/libslic3r/GCode/ToolOrdering.hpp | 1 + src/libslic3r/GCode/WipeTower.cpp | 2 +- src/libslic3r/Preset.cpp | 2 +- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 21 +++++++++++++++++++++ src/libslic3r/PrintConfig.hpp | 1 + src/slic3r/GUI/Plater.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 1 + 9 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 6a8a7a812..acddb137e 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -168,6 +168,11 @@ ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool this->fill_wipe_tower_partitions(print.config(), object_bottom_z, max_layer_height); + if (this->insert_wipe_tower_extruder()) { + this->reorder_extruders(first_extruder); + this->fill_wipe_tower_partitions(print.config(), object_bottom_z, max_layer_height); + } + this->collect_extruder_statistics(prime_multi_material); this->mark_skirt_layers(print.config(), max_layer_height); @@ -462,6 +467,27 @@ void ToolOrdering::fill_wipe_tower_partitions(const PrintConfig &config, coordf_ } } +bool ToolOrdering::insert_wipe_tower_extruder() +{ + // In case that wipe_tower_extruder is set to non-zero, we must make sure that the extruder will be in the list. + bool changed = false; + if (m_print_config_ptr->wipe_tower_extruder != 0) { + for (LayerTools& lt : m_layer_tools) { + if (lt.wipe_tower_partitions > 0) { + lt.extruders.emplace_back(m_print_config_ptr->wipe_tower_extruder - 1); + sort_remove_duplicates(lt.extruders); + changed = true; + } + } + // Now convert the 0-based list to 1-based again. + for (LayerTools& lt : m_layer_tools) { + for (auto& extruder : lt.extruders) + ++extruder; + } + } + return changed; +} + void ToolOrdering::collect_extruder_statistics(bool prime_multi_material) { m_first_printing_extruder = (unsigned int)-1; diff --git a/src/libslic3r/GCode/ToolOrdering.hpp b/src/libslic3r/GCode/ToolOrdering.hpp index 4fb6e56c0..f4685eb9b 100644 --- a/src/libslic3r/GCode/ToolOrdering.hpp +++ b/src/libslic3r/GCode/ToolOrdering.hpp @@ -167,6 +167,7 @@ private: void collect_extruders(const PrintObject &object, const std::vector> &per_layer_extruder_switches); void reorder_extruders(unsigned int last_extruder_id); void fill_wipe_tower_partitions(const PrintConfig &config, coordf_t object_bottom_z, coordf_t max_layer_height); + bool insert_wipe_tower_extruder(); void mark_skirt_layers(const PrintConfig &config, coordf_t max_layer_height); void collect_extruder_statistics(bool prime_multi_material); diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 0853951db..5ce5353db 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -581,7 +581,7 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config) m_filpar.push_back(FilamentParameters()); m_filpar[idx].material = config.filament_type.get_at(idx); - m_filpar[idx].is_soluble = config.filament_soluble.get_at(idx); + m_filpar[idx].is_soluble = config.wipe_tower_extruder == 0 ? config.filament_soluble.get_at(idx) : (idx != config.wipe_tower_extruder - 1); m_filpar[idx].temperature = config.temperature.get_at(idx); m_filpar[idx].first_layer_temperature = config.first_layer_temperature.get_at(idx); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index b63576a0d..13625748a 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -456,7 +456,7 @@ static std::vector s_Preset_print_options { "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "infill_anchor", "infill_anchor_max", "bridge_flow_ratio", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "gcode_resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_cone_angle", "wipe_tower_rotation_angle", "wipe_tower_brim_width", "wipe_tower_bridging", "single_extruder_multi_material_priming", "mmu_segmented_region_max_width", - "wipe_tower_no_sparse_layers", "wipe_tower_extra_spacing", "compatible_printers", "compatible_printers_condition", "inherits", + "wipe_tower_extruder", "wipe_tower_no_sparse_layers", "wipe_tower_extra_spacing", "compatible_printers", "compatible_printers_condition", "inherits", "perimeter_generator", "wall_transition_length", "wall_transition_filter_deviation", "wall_transition_angle", "wall_distribution_count", "min_feature_size", "min_bead_width" }; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 0ec88c44f..2487b68e2 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -208,6 +208,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n || opt_key == "wipe_tower_bridging" || opt_key == "wipe_tower_extra_spacing" || opt_key == "wipe_tower_no_sparse_layers" + || opt_key == "wipe_tower_extruder" || opt_key == "wiping_volumes_matrix" || opt_key == "parking_pos_retraction" || opt_key == "cooling_tube_retraction" diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 77120bfdf..fa4e885f1 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3235,6 +3235,27 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(10.)); + def = this->add("wipe_tower_extruder", coInt); + def->label = L("Wipe tower extruder"); + def->category = L("Extruders"); + def->tooltip = L("The extruder to use when printing perimeter of the wipe tower. " + "Set to 0 to use the one that is available (non-soluble would be preferred)."); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionInt(0)); + + def = this->add("solid_infill_every_layers", coInt); + def->label = L("Solid infill every"); + def->category = L("Infill"); + def->tooltip = L("This feature allows to force a solid layer every given number of layers. " + "Zero to disable. You can set this to any value (for example 9999); " + "Slic3r will automatically choose the maximum possible number of layers " + "to combine according to nozzle diameter and layer height."); + def->sidetext = L("layers"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionInt(0)); + def = this->add("xy_size_compensation", coFloat); def->label = L("XY Size Compensation"); def->category = L("Advanced"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 2a4b3258d..36a63d33d 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -829,6 +829,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionFloat, wipe_tower_cone_angle)) ((ConfigOptionPercent, wipe_tower_extra_spacing)) ((ConfigOptionFloat, wipe_tower_bridging)) + ((ConfigOptionInt, wipe_tower_extruder)) ((ConfigOptionFloats, wiping_volumes_matrix)) ((ConfigOptionFloats, wiping_volumes_extruders)) ((ConfigOptionFloat, z_offset)) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6e6b72f9a..84582f895 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2007,7 +2007,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) , config(Slic3r::DynamicPrintConfig::new_from_defaults_keys({ "bed_shape", "bed_custom_texture", "bed_custom_model", "complete_objects", "duplicate_distance", "extruder_clearance_radius", "skirts", "skirt_distance", "brim_width", "brim_separation", "brim_type", "variable_layer_height", "nozzle_diameter", "single_extruder_multi_material", - "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_brim_width", "wipe_tower_cone_angle", "wipe_tower_extra_spacing", + "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_brim_width", "wipe_tower_cone_angle", "wipe_tower_extra_spacing", "wipe_tower_extruder", "extruder_colour", "filament_colour", "material_colour", "max_print_height", "printer_model", "printer_technology", // These values are necessary to construct SlicingParameters by the Canvas3D variable layer height editor. "layer_height", "first_layer_height", "min_layer_height", "max_layer_height", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 51b01a5e5..93017714e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1598,6 +1598,7 @@ void TabPrint::build() optgroup->append_single_option_line("solid_infill_extruder"); optgroup->append_single_option_line("support_material_extruder"); optgroup->append_single_option_line("support_material_interface_extruder"); + optgroup->append_single_option_line("wipe_tower_extruder"); optgroup = page->new_optgroup(L("Ooze prevention")); optgroup->append_single_option_line("ooze_prevention");