From 835089551396733567deadbcadc461a4d2876c4b Mon Sep 17 00:00:00 2001 From: SoftFever <103989404+SoftFever@users.noreply.github.com> Date: Sun, 15 Jan 2023 21:05:35 +0800 Subject: [PATCH] role_based_wipe_speed and wipe_speed Signed-off-by: SoftFever <103989404+SoftFever@users.noreply.github.com> --- src/libslic3r/GCode.cpp | 8 ++++++-- src/libslic3r/GCodeWriter.cpp | 5 +++-- src/libslic3r/GCodeWriter.hpp | 8 ++++++-- src/libslic3r/Preset.cpp | 2 +- src/libslic3r/Print.cpp | 4 +++- src/libslic3r/PrintConfig.cpp | 20 ++++++++++++++++++-- src/libslic3r/PrintConfig.hpp | 3 +++ src/libslic3r/PrintObject.cpp | 4 +++- src/slic3r/GUI/ConfigManipulation.cpp | 5 +++++ src/slic3r/GUI/Tab.cpp | 2 ++ 10 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 89ab139c25..165dc0b9c8 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -167,7 +167,11 @@ bool GCode::gcode_label_objects = true; /* Reduce feedrate a bit; travel speed is often too high to move on existing material. Too fast = ripping of existing material; too slow = short wipe path, thus more blob. */ - double wipe_speed = gcodegen.writer().config.travel_speed.value * 0.8; + double _wipe_speed = gcodegen.config().get_abs_value("wipe_speed");// gcodegen.writer().config.travel_speed.value * 0.8; + if(gcodegen.config().role_based_wipe_speed) + _wipe_speed = gcodegen.writer().get_current_speed() / 60.0; + if(_wipe_speed < 60) + _wipe_speed = 60; // get the retraction length double length = toolchange @@ -206,7 +210,7 @@ bool GCode::gcode_label_objects = true; // add tag for processor gcode += ";" + GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Wipe_Start) + "\n"; //BBS: don't need to enable cooling makers when this is the last wipe. Because no more cooling layer will clean this "_WIPE" - gcode += gcodegen.writer().set_speed(wipe_speed * 60, "", (gcodegen.enable_cooling_markers() && !is_last) ? ";_WIPE" : ""); + gcode += gcodegen.writer().set_speed(_wipe_speed * 60, "", (gcodegen.enable_cooling_markers() && !is_last) ? ";_WIPE" : ""); for (const Line& line : wipe_path.lines()) { double segment_length = line.length(); /* Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index 638108c2dc..0b58d9fbe7 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -301,11 +301,12 @@ std::string GCodeWriter::toolchange(unsigned int extruder_id) return gcode.str(); } -std::string GCodeWriter::set_speed(double F, const std::string &comment, const std::string &cooling_marker) const +std::string GCodeWriter::set_speed(double F, const std::string &comment, const std::string &cooling_marker) { assert(F > 0.); assert(F < 100000.); - + + m_current_speed = F; GCodeG1Formatter w; w.emit_f(F); //BBS diff --git a/src/libslic3r/GCodeWriter.hpp b/src/libslic3r/GCodeWriter.hpp index 4509f1a992..09d0e76843 100644 --- a/src/libslic3r/GCodeWriter.hpp +++ b/src/libslic3r/GCodeWriter.hpp @@ -24,7 +24,8 @@ public: /*m_last_bed_temperature(0), */m_last_bed_temperature_reached(true), m_lifted(0), m_to_lift(0), - m_to_lift_type(LiftType::NormalLift) + m_to_lift_type(LiftType::NormalLift), + m_current_speed(3600) {} Extruder* extruder() { return m_extruder; } const Extruder* extruder() const { return m_extruder; } @@ -58,7 +59,9 @@ public: // printed with the same extruder. std::string toolchange_prefix() const; std::string toolchange(unsigned int extruder_id); - std::string set_speed(double F, const std::string &comment = std::string(), const std::string &cooling_marker = std::string()) const; + std::string set_speed(double F, const std::string &comment = std::string(), const std::string &cooling_marker = std::string()); + // SoftFever NOTE: the returned speed is mm/minute + double get_current_speed() const { return m_current_speed;} std::string travel_to_xy(const Vec2d &point, const std::string &comment = std::string()); std::string travel_to_xyz(const Vec3d &point, const std::string &comment = std::string()); std::string travel_to_z(double z, const std::string &comment = std::string()); @@ -134,6 +137,7 @@ private: //SoftFever bool m_is_bbl_printers = false; + double m_current_speed; std::string _travel_to_z(double z, const std::string &comment); std::string _spiral_travel_to_z(double z, const Vec2d &ij_offset, const std::string &comment); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 202e89f97f..dffc2dc701 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -752,7 +752,7 @@ static std::vector s_Preset_print_options { "small_perimeter_speed", "small_perimeter_threshold","bridge_angle", "filter_out_gap_fill", "post_process", "travel_acceleration","inner_wall_acceleration", "default_jerk", "outer_wall_jerk", "inner_wall_jerk", "top_surface_jerk", "initial_layer_jerk","travel_jerk", "top_solid_infill_flow_ratio","bottom_solid_infill_flow_ratio","only_one_wall_first_layer", - "print_flow_ratio","seam_gap" + "print_flow_ratio","seam_gap","role_based_wipe_speed","wipe_speed" }; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index d8360de327..aa604ad0b8 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -150,7 +150,9 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "required_nozzle_HRC", "upward_compatible_machine", // SoftFever - "seam_gap" + "seam_gap", + "role_based_wipe_speed", + "wipe_speed" }; static std::unordered_set steps_ignore; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 35ed0e74e1..323f067939 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2371,7 +2371,6 @@ void PrintConfigDef::init_fff_params() def->mode = comSimple; def->set_default_value(new ConfigOptionEnum(spAligned)); - def = this->add("seam_gap", coFloatOrPercent); def->label = L("Seam gap"); def->tooltip = L("When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam." @@ -2381,7 +2380,24 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(15,true)); - + def = this->add("role_based_wipe_speed", coBool); + def->label = L("Role base wipe speed"); + def->tooltip = L("The wipe speed is same as the current extrusion role's speed.\n" + "e.g. if wipe action is followed by a outer wall extrusion, the outer wall speed will be used for this wipe action."); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionBool(false)); + + def = this->add("wipe_speed", coFloatOrPercent); + def->label = L("Wipe speed"); + def->tooltip = L("This setting will affect the speed of wipe." + " If expressed as percentage (for example: 80%) it will be calculated " + "on the travel speed setting above. Default value is 80%"); + def->sidetext = L("mm/s or %"); + def->ratio_over = "travel_speed"; + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloatOrPercent(80,true)); + def = this->add("skirt_distance", coFloat); def->label = L("Skirt distance"); def->tooltip = L("Distance from skirt to brim or object"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 2fc500dbc1..076d76e4a3 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -757,6 +757,9 @@ PRINT_CONFIG_CLASS_DEFINE( //SoftFever ((ConfigOptionFloat, print_flow_ratio)) ((ConfigOptionFloatOrPercent, seam_gap)) + ((ConfigOptionBool, role_based_wipe_speed)) + ((ConfigOptionFloatOrPercent, wipe_speed)) + ) PRINT_CONFIG_CLASS_DEFINE( diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index cc91839e95..8150b0d935 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -680,7 +680,9 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "initial_layer_line_width" || opt_key == "inner_wall_line_width" || opt_key == "infill_wall_overlap" - || opt_key == "seam_gap") { + || opt_key == "seam_gap" + || opt_key == "role_based_wipe_speed" + || opt_key == "wipe_speed") { steps.emplace_back(posPerimeters); } else if (opt_key == "gap_infill_speed" || opt_key == "filter_out_gap_fill" ) { diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index d249fa4c7c..73cafaef5d 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -655,6 +655,11 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co toggle_field("detect_thin_wall", !have_arachne); toggle_field("enable_overhang_speed", !have_arachne); toggle_field("only_one_wall_top", !have_arachne); + + // SoftFever + auto is_role_based_wipe_speed = config->opt_bool("role_based_wipe_speed"); + toggle_field("wipe_speed",!is_role_based_wipe_speed); + } void ConfigManipulation::update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config/* = false*/) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 9d7ff1bf0a..5fc34adde1 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1835,6 +1835,8 @@ void TabPrint::build() optgroup = page->new_optgroup(L("Seam"), L"param_seam"); optgroup->append_single_option_line("seam_position", "Seam"); optgroup->append_single_option_line("seam_gap","Seam"); + optgroup->append_single_option_line("role_based_wipe_speed","Seam"); + optgroup->append_single_option_line("wipe_speed","Seam"); optgroup = page->new_optgroup(L("Precision"), L"param_precision");