From 39d20ba5ea47de1898ed7237fff7f6eba1306421 Mon Sep 17 00:00:00 2001 From: Morton Jonuschat Date: Mon, 19 Feb 2024 21:11:52 -0800 Subject: [PATCH] [FEATURE] Klipper accel to decel support --- src/libslic3r/GCode.cpp | 61 +++-- src/libslic3r/GCode/GCodeWriter.cpp | 37 ++- src/libslic3r/GCode/GCodeWriter.hpp | 13 +- src/libslic3r/GCode/WipeTowerIntegration.cpp | 16 +- src/libslic3r/Preset.cpp | 41 +-- src/libslic3r/Print.cpp | 13 +- src/libslic3r/PrintConfig.cpp | 248 +++++++++++++------ src/libslic3r/PrintConfig.hpp | 14 ++ src/slic3r/GUI/ConfigManipulation.cpp | 18 +- src/slic3r/GUI/Tab.cpp | 21 +- src/slic3r/GUI/Tab.hpp | 5 +- 11 files changed, 356 insertions(+), 131 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index e4f026bc7c0..6bbef64e4db 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2990,9 +2990,13 @@ std::string GCodeGenerator::extrude_loop(const ExtrusionLoop &loop_src, const GC gcode += this->_extrude(el.path_attributes, el.path, description, speed); // reset acceleration - gcode += m_writer.set_print_acceleration(fast_round_up(m_config.default_acceleration.value)); + gcode += m_writer.set_print_acceleration( + fast_round_up(m_config.default_acceleration.value), + fast_round_up(m_config.default_accel_to_decel.value), + "Default" + ); //reset jerk - gcode += m_writer.set_jerk(fast_round_up(m_config.default_jerk.value)); + gcode += m_writer.set_jerk(fast_round_up(m_config.default_jerk.value), "Default"); if (m_wipe.enabled()) { // Wipe will hide the seam. @@ -3040,9 +3044,13 @@ std::string GCodeGenerator::extrude_skirt( } // reset acceleration - gcode += m_writer.set_print_acceleration(fast_round_up(m_config.default_acceleration.value)); + gcode += m_writer.set_print_acceleration( + fast_round_up(m_config.default_acceleration.value), + fast_round_up(m_config.default_accel_to_decel.value), + "Default" + ); // reset jerk - gcode += m_writer.set_jerk(fast_round_up(m_config.default_jerk.value)); + gcode += m_writer.set_jerk(fast_round_up(m_config.default_jerk.value), "Default"); if (m_wipe.enabled()) // Wipe will hide the seam. @@ -3070,9 +3078,13 @@ std::string GCodeGenerator::extrude_multi_path(const ExtrusionMultiPath &multipa m_wipe.set_path(std::move(smooth_path)); // reset acceleration - gcode += m_writer.set_print_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5)); + gcode += m_writer.set_print_acceleration( + fast_round_up(m_config.default_acceleration.value), + fast_round_up(m_config.default_accel_to_decel.value), + "Default" + ); // reset jerk - gcode += m_writer.set_jerk(m_config.default_jerk.value); + gcode += m_writer.set_jerk(m_config.default_jerk.value, "Default"); return gcode; } @@ -3096,9 +3108,13 @@ std::string GCodeGenerator::extrude_path(const ExtrusionPath &path, bool reverse Geometry::ArcWelder::reverse(smooth_path); m_wipe.set_path(std::move(smooth_path)); // reset acceleration - gcode += m_writer.set_print_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5)); + gcode += m_writer.set_print_acceleration( + fast_round_up(m_config.default_acceleration.value), + fast_round_up(m_config.default_accel_to_decel.value), + "Default" + ); // reset jerk - gcode += m_writer.set_jerk(m_config.default_jerk.value); + gcode += m_writer.set_jerk(m_config.default_jerk.value, "Default"); return gcode; } @@ -3333,26 +3349,40 @@ std::string GCodeGenerator::_extrude( // adjust acceleration if (m_config.default_acceleration.value > 0) { double acceleration; + double accel_to_decel; if (this->on_first_layer() && m_config.first_layer_acceleration.value > 0) { acceleration = m_config.first_layer_acceleration.value; + accel_to_decel = m_config.first_layer_accel_to_decel.value; } else if (this->object_layer_over_raft() && m_config.first_layer_acceleration_over_raft.value > 0) { acceleration = m_config.first_layer_acceleration_over_raft.value; + accel_to_decel = m_config.first_layer_accel_to_decel_over_raft.value; } else if (m_config.bridge_acceleration.value > 0 && path_attr.role.is_bridge()) { acceleration = m_config.bridge_acceleration.value; + accel_to_decel = m_config.bridge_accel_to_decel.value; } else if (m_config.top_solid_infill_acceleration > 0 && path_attr.role == ExtrusionRole::TopSolidInfill) { acceleration = m_config.top_solid_infill_acceleration.value; + accel_to_decel = m_config.top_solid_infill_accel_to_decel.value; } else if (m_config.solid_infill_acceleration > 0 && path_attr.role.is_solid_infill()) { acceleration = m_config.solid_infill_acceleration.value; + accel_to_decel = m_config.solid_infill_accel_to_decel.value; } else if (m_config.infill_acceleration.value > 0 && path_attr.role.is_infill()) { acceleration = m_config.infill_acceleration.value; + accel_to_decel = m_config.infill_accel_to_decel.value; } else if (m_config.external_perimeter_acceleration > 0 && path_attr.role.is_external_perimeter()) { acceleration = m_config.external_perimeter_acceleration.value; + accel_to_decel = m_config.external_perimeter_accel_to_decel.value; } else if (m_config.perimeter_acceleration.value > 0 && path_attr.role.is_perimeter()) { acceleration = m_config.perimeter_acceleration.value; + accel_to_decel = m_config.perimeter_accel_to_decel.value; } else { acceleration = m_config.default_acceleration.value; + accel_to_decel = m_config.default_accel_to_decel.value; } - gcode += m_writer.set_print_acceleration((unsigned int)floor(acceleration + 0.5)); + gcode += m_writer.set_print_acceleration( + fast_round_up(acceleration), + fast_round_up(accel_to_decel), + gcode_extrusion_role_to_string(extrusion_role_to_gcode_extrusion_role(path_attr.role)) + ); } // adjust jerk @@ -3377,7 +3407,7 @@ std::string GCodeGenerator::_extrude( } else { jerk = m_config.default_jerk.value; } - gcode += m_writer.set_jerk(jerk); + gcode += m_writer.set_jerk(jerk, gcode_extrusion_role_to_string(extrusion_role_to_gcode_extrusion_role(path_attr.role))); } // calculate extrusion length per distance unit @@ -3586,7 +3616,8 @@ std::string GCodeGenerator::generate_travel_gcode( ) { std::string gcode; - const unsigned acceleration =(unsigned)(m_config.travel_acceleration.value + 0.5); + const unsigned acceleration = fast_round_up(m_config.travel_acceleration.value); + const unsigned accel_to_decel = fast_round_up(m_config.travel_accel_to_decel.value); if (travel.empty()) { return ""; @@ -3594,9 +3625,9 @@ std::string GCodeGenerator::generate_travel_gcode( // generate G-code for the travel move // use G1 because we rely on paths being straight (G0 may make round paths) - gcode += this->m_writer.set_travel_acceleration(acceleration); + gcode += this->m_writer.set_travel_acceleration(acceleration, accel_to_decel); if (m_config.default_jerk > 0 && m_config.travel_jerk > 0) - gcode += this->m_writer.set_jerk(m_config.travel_jerk); + gcode += this->m_writer.set_jerk(m_config.travel_jerk, "Travel"); Vec3d previous_point{this->point_to_gcode(travel.front())}; bool already_inserted{false}; @@ -3617,11 +3648,11 @@ std::string GCodeGenerator::generate_travel_gcode( if (! GCodeWriter::supports_separate_travel_acceleration(config().gcode_flavor)) { // In case that this flavor does not support separate print and travel acceleration, // reset acceleration to default. - gcode += this->m_writer.set_travel_acceleration(acceleration); + gcode += this->m_writer.set_print_acceleration(m_config.default_acceleration, m_config.default_accel_to_decel, "Default"); } if (m_config.default_jerk > 0 && m_config.travel_jerk > 0) - gcode += this->m_writer.set_jerk(m_config.default_jerk); + gcode += this->m_writer.set_jerk(m_config.default_jerk, "Default"); return gcode; } diff --git a/src/libslic3r/GCode/GCodeWriter.cpp b/src/libslic3r/GCode/GCodeWriter.cpp index 632a91e4790..d4342ef54bf 100644 --- a/src/libslic3r/GCode/GCodeWriter.cpp +++ b/src/libslic3r/GCode/GCodeWriter.cpp @@ -56,6 +56,9 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config) print_config.machine_max_jerk_x.values.front() : 0)); m_max_jerk_y = static_cast(std::round((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? print_config.machine_max_jerk_y.values.front() : 0)); + + m_max_accel_to_decel = static_cast(std::round((use_mach_limits && print_config.machine_limits_usage.value == MachineLimitsUsage::EmitToGCode) ? + print_config.machine_max_acceleration_extruding.values.front() : 0)); } void GCodeWriter::set_extruders(std::vector extruder_ids) @@ -186,7 +189,7 @@ std::string GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait return gcode.str(); } -std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned int acceleration) +std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned int acceleration, unsigned int accel_to_decel, const std::string_view comment) { // Clamp the acceleration to the allowed maximum. if (type == Acceleration::Print && m_max_acceleration > 0 && acceleration > m_max_acceleration) @@ -194,30 +197,42 @@ std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned i if (type == Acceleration::Travel && m_max_travel_acceleration > 0 && acceleration > m_max_travel_acceleration) acceleration = m_max_travel_acceleration; + // Clamp the accel_to_decel to the allowed maximum. + if (m_max_accel_to_decel > 0 && accel_to_decel > m_max_accel_to_decel) + accel_to_decel = m_max_accel_to_decel; + // Are we setting travel acceleration for a flavour that supports separate travel and print acc? bool separate_travel = (type == Acceleration::Travel && supports_separate_travel_acceleration(this->config.gcode_flavor)); - auto& last_value = separate_travel ? m_last_travel_acceleration : m_last_acceleration ; - if (acceleration == 0 || acceleration == last_value) + auto& last_acceleration_value = separate_travel ? m_last_travel_acceleration : m_last_acceleration ; + auto& last_accel_to_decel_value = m_last_accel_to_decel; + if ((acceleration == 0 || acceleration == last_acceleration_value) && (accel_to_decel == 0 || accel_to_decel == last_accel_to_decel_value)) return {}; - last_value = acceleration; + last_acceleration_value = acceleration; + last_accel_to_decel_value = accel_to_decel; std::ostringstream gcode; - if (FLAVOR_IS(gcfRepetier)) + if (FLAVOR_IS(gcfKlipper)) { + gcode << "SET_VELOCITY_LIMIT ACCEL=" << acceleration; + if (accel_to_decel > 0) + gcode << " ACCEL_TO_DECEL=" << accel_to_decel; + } else if (FLAVOR_IS(gcfRepetier)) gcode << (separate_travel ? "M202 X" : "M201 X") << acceleration << " Y" << acceleration; else if (FLAVOR_IS(gcfRepRapFirmware) || FLAVOR_IS(gcfMarlinFirmware)) gcode << (separate_travel ? "M204 T" : "M204 P") << acceleration; else gcode << "M204 S" << acceleration; - if (this->config.gcode_comments) gcode << " ; adjust acceleration"; + if (this->config.gcode_comments) + gcode << " ; adjust acceleration (" << comment << ")"; + gcode << "\n"; return gcode.str(); } -std::string GCodeWriter::set_jerk(unsigned int jerk) +std::string GCodeWriter::set_jerk(unsigned int jerk, const std::string_view comment) { if (jerk == 0 || jerk == m_last_jerk) return {}; @@ -232,12 +247,16 @@ std::string GCodeWriter::set_jerk(unsigned int jerk) m_last_jerk = jerk; std::ostringstream gcode; - if (FLAVOR_IS(gcfRepRapFirmware)) + if (FLAVOR_IS(gcfKlipper)) + gcode << "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=" << jerk; + else if (FLAVOR_IS(gcfRepRapFirmware)) gcode << "M566 X" << jerk_x << " Y" << jerk_y; else gcode << "M205 X" << jerk_x << " Y" << jerk_y; - if (this->config.gcode_comments) gcode << " ; adjust jerk"; + if (this->config.gcode_comments) + gcode << " ; adjust jerk (" << comment << ")"; + gcode << "\n"; return gcode.str(); diff --git a/src/libslic3r/GCode/GCodeWriter.hpp b/src/libslic3r/GCode/GCodeWriter.hpp index c9117e818ae..6fb4074bbcd 100644 --- a/src/libslic3r/GCode/GCodeWriter.hpp +++ b/src/libslic3r/GCode/GCodeWriter.hpp @@ -14,6 +14,7 @@ #include "../Point.hpp" #include "../PrintConfig.hpp" #include "CoolingBuffer.hpp" +#include "libslic3r/ExtrusionRole.hpp" #include #include @@ -29,7 +30,7 @@ class GCodeWriter { GCodeWriter() : multiple_extruders(false), m_extrusion_axis("E"), m_extruder(nullptr), m_single_extruder_multi_material(false), - m_last_acceleration(0), m_max_acceleration(0), m_last_jerk(0), + m_last_acceleration(0), m_max_acceleration(0), m_max_accel_to_decel(0), m_last_jerk(0), m_last_bed_temperature(0), m_last_bed_temperature_reached(true) {} Extruder* extruder() { return m_extruder; } @@ -52,9 +53,9 @@ class GCodeWriter { std::string postamble() const; std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1) const; std::string set_bed_temperature(unsigned int temperature, bool wait = false); - std::string set_print_acceleration(unsigned int acceleration) { return set_acceleration_internal(Acceleration::Print, acceleration); } - std::string set_travel_acceleration(unsigned int acceleration) { return set_acceleration_internal(Acceleration::Travel, acceleration); } - std::string set_jerk(unsigned int jerk); + std::string set_print_acceleration(unsigned int acceleration, unsigned int accel_to_decel, const std::string_view comment) { return set_acceleration_internal(Acceleration::Print, acceleration, accel_to_decel, comment); } + std::string set_travel_acceleration(unsigned int acceleration, unsigned int accel_to_decel) { return set_acceleration_internal(Acceleration::Travel, acceleration, accel_to_decel, "Travel"); } + std::string set_jerk(unsigned int jerk, const std::string_view comment); std::string reset_e(bool force = false); std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const; // return false if this extruder was already selected @@ -120,11 +121,13 @@ class GCodeWriter { bool m_single_extruder_multi_material; Extruder* m_extruder; unsigned int m_last_acceleration = (unsigned int)(-1); + unsigned int m_last_accel_to_decel = (unsigned int)(-1); unsigned int m_last_travel_acceleration = (unsigned int)(-1); // only used for flavors supporting separate print/travel acc // Limit for setting the acceleration, to respect the machine limits set for the Marlin firmware. // If set to zero, the limit is not in action. unsigned int m_max_acceleration; unsigned int m_max_travel_acceleration; + unsigned int m_max_accel_to_decel; unsigned int m_last_jerk = (unsigned int)(-1); unsigned int m_max_jerk_x; @@ -140,7 +143,7 @@ class GCodeWriter { }; std::string _retract(double length, double restart_extra, const std::string_view comment); - std::string set_acceleration_internal(Acceleration type, unsigned int acceleration); + std::string set_acceleration_internal(Acceleration type, unsigned int acceleration, unsigned int accel_to_decel, const std::string_view comment); }; class GCodeFormatter { diff --git a/src/libslic3r/GCode/WipeTowerIntegration.cpp b/src/libslic3r/GCode/WipeTowerIntegration.cpp index d39896b2be4..32c4aa443df 100644 --- a/src/libslic3r/GCode/WipeTowerIntegration.cpp +++ b/src/libslic3r/GCode/WipeTowerIntegration.cpp @@ -111,12 +111,20 @@ std::string WipeTowerIntegration::append_tcr(GCodeGenerator &gcodegen, const Wip unescape_string_cstyle(tcr_rotated_gcode, tcr_gcode); if (gcodegen.config().default_acceleration > 0) { - gcode += gcodegen.writer().set_print_acceleration(fast_round_up(gcodegen.config().wipe_tower_acceleration.value)); - gcode += gcodegen.writer().set_jerk(fast_round_up(gcodegen.config().wipe_tower_jerk.value)); + gcode += gcodegen.writer().set_print_acceleration( + fast_round_up(gcodegen.config().wipe_tower_acceleration.value), + fast_round_up(gcodegen.config().wipe_tower_accel_to_decel.value), + "Wipe Tower" + ); + gcode += gcodegen.writer().set_jerk(fast_round_up(gcodegen.config().wipe_tower_jerk.value), "Wipe Tower"); } gcode += tcr_gcode; - gcode += gcodegen.writer().set_print_acceleration(fast_round_up(gcodegen.config().default_acceleration.value)); - gcode += gcodegen.writer().set_jerk(fast_round_up(gcodegen.config().default_jerk.value)); + gcode += gcodegen.writer().set_print_acceleration( + fast_round_up(gcodegen.config().default_acceleration.value), + fast_round_up(gcodegen.config().default_accel_to_decel.value), + "Default" + ); + gcode += gcodegen.writer().set_jerk(fast_round_up(gcodegen.config().default_jerk.value), "Default"); // A phony move to the end position at the wipe tower. gcodegen.writer().travel_to_xy(end_pos.cast()); gcodegen.last_position = wipe_tower_point_to_object_point(gcodegen, end_pos); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 7290beb459b..bc290dd93f6 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -430,7 +430,7 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config) for (auto it = this->renamed_from.begin(); ! is_visible && it != this->renamed_from.end(); ++ it) is_visible = has(*it); } - else + else is_visible = false; } } @@ -449,20 +449,21 @@ static std::vector s_Preset_print_options { "perimeter_speed", "small_perimeter_speed", "external_perimeter_speed", "infill_speed", "solid_infill_speed", "enable_dynamic_overhang_speeds", "overhang_speed_0", "overhang_speed_1", "overhang_speed_2", "overhang_speed_3", "top_solid_infill_speed", "support_material_speed", "support_material_xy_spacing", "support_material_interface_speed", - "bridge_speed", "gap_fill_speed", "gap_fill_enabled", "travel_speed", "travel_speed_z", "first_layer_speed", "first_layer_speed_over_raft", "perimeter_acceleration", "infill_acceleration", - "external_perimeter_acceleration", "top_solid_infill_acceleration", "solid_infill_acceleration", "travel_acceleration", "wipe_tower_acceleration", - "bridge_acceleration", "first_layer_acceleration", "first_layer_acceleration_over_raft", "default_acceleration", "skirts", "skirt_distance", "skirt_height", "draft_shield", - "perimeter_jerk", "infill_jerk", + "bridge_speed", "gap_fill_speed", "gap_fill_enabled", "travel_speed", "travel_speed_z", "first_layer_speed", "first_layer_speed_over_raft", "perimeter_acceleration", "perimeter_accel_to_decel", + "infill_acceleration", "infill_accel_to_decel", "external_perimeter_acceleration", "external_perimeter_accel_to_decel", "top_solid_infill_acceleration", "top_solid_infill_accel_to_decel", + "solid_infill_acceleration", "solid_infill_accel_to_decel", "travel_acceleration", "travel_accel_to_decel", "bridge_acceleration", "bridge_accel_to_decel", "first_layer_acceleration", + "first_layer_accel_to_decel", "first_layer_acceleration_over_raft", "first_layer_accel_to_decel_over_raft", "default_acceleration", "default_accel_to_decel", "wipe_tower_acceleration", "wipe_tower_accel_to_decel", + "skirts", "skirt_distance", "skirt_height", "draft_shield", "perimeter_jerk", "infill_jerk", "external_perimeter_jerk", "top_solid_infill_jerk", "solid_infill_jerk", "travel_jerk", "wipe_tower_jerk", "bridge_jerk", "first_layer_jerk", "first_layer_jerk_over_raft", "default_jerk", "min_skirt_length", "brim_width", "brim_separation", "brim_type", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers", "raft_layers", "raft_first_layer_density", "raft_first_layer_expansion", "raft_contact_distance", "raft_expansion", "support_material_pattern", "support_material_with_sheath", "support_material_spacing", "support_material_closing_radius", "support_material_style", "support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers", "support_material_bottom_interface_layers", - "support_material_interface_pattern", "support_material_interface_spacing", "support_material_interface_contact_loops", + "support_material_interface_pattern", "support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance", "support_material_bottom_contact_distance", - "support_material_buildplate_only", - "support_tree_angle", "support_tree_angle_slow", "support_tree_branch_diameter", "support_tree_branch_diameter_angle", "support_tree_branch_diameter_double_wall", + "support_material_buildplate_only", + "support_tree_angle", "support_tree_angle_slow", "support_tree_branch_diameter", "support_tree_branch_diameter_angle", "support_tree_branch_diameter_double_wall", "support_tree_top_rate", "support_tree_branch_distance", "support_tree_tip_diameter", "dont_support_bridges", "thick_bridges", "notes", "complete_objects", "extruder_clearance_radius", "extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "gcode_substitutions", "perimeter_extruder", @@ -492,7 +493,7 @@ static std::vector s_Preset_filament_options { "extrusion_multiplier", "filament_density", "filament_cost", "filament_spool_weight", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time", "filament_unloading_speed", "filament_unloading_speed_start", "filament_unload_time", "filament_toolchange_delay", "filament_cooling_moves", "filament_stamping_loading_speed", "filament_stamping_distance", "filament_cooling_initial_speed", "filament_purge_multiplier", "filament_cooling_final_speed", "filament_ramming_parameters", "filament_minimal_purge_on_wipe_tower", - "filament_multitool_ramming", "filament_multitool_ramming_volume", "filament_multitool_ramming_flow", + "filament_multitool_ramming", "filament_multitool_ramming_volume", "filament_multitool_ramming_flow", "temperature", "idle_temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers", "full_fan_speed_layer", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode", "enable_dynamic_fan_speeds", @@ -508,7 +509,7 @@ static std::vector s_Preset_filament_options { }; static std::vector s_Preset_machine_limits_options { - "machine_max_acceleration_extruding", "machine_max_acceleration_retracting", "machine_max_acceleration_travel", + "machine_max_acceleration_extruding", "machine_max_acceleration_retracting", "machine_max_acceleration_travel", "machine_max_accel_to_decel", "machine_max_acceleration_x", "machine_max_acceleration_y", "machine_max_acceleration_z", "machine_max_acceleration_e", "machine_max_feedrate_x", "machine_max_feedrate_y", "machine_max_feedrate_z", "machine_max_feedrate_e", "machine_min_extruding_rate", "machine_min_travel_rate", @@ -728,7 +729,7 @@ void PresetCollection::add_default_preset(const std::vector &keys, // Load all presets found in dir_path. // Throws an exception on error. void PresetCollection::load_presets( - const std::string &dir_path, const std::string &subdir, + const std::string &dir_path, const std::string &subdir, PresetsConfigSubstitutions& substitutions, ForwardCompatibilitySubstitutionRule substitution_rule) { // Don't use boost::filesystem::canonical() on Windows, it is broken in regard to reparse points, @@ -883,9 +884,9 @@ ExternalPreset PresetCollection::load_external_preset( if (!profile_print_params_same(it->config, cfg)) { // The source config may contain keys from many possible preset types. Just copy those that relate to this preset. - // Following keys are not used neither by the UI nor by the slicing core, therefore they are not important + // Following keys are not used neither by the UI nor by the slicing core, therefore they are not important // Erase them from config apply to avoid redundant "dirty" parameter in loaded preset. - for (const char* key : { "print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id", "filament_vendor", + for (const char* key : { "print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id", "filament_vendor", "printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile" }) keys.erase(std::remove(keys.begin(), keys.end(), key), keys.end()); @@ -1303,7 +1304,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil } } } - + // Update visibility of the default profiles here if the defaults are suppressed, the current profile is not compatible and we don't want to select another compatible profile. if (m_idx_selected >= m_num_default_presets && m_default_suppressed) for (size_t i = 0; i < m_num_default_presets; ++ i) @@ -1391,7 +1392,7 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi // "nozzle_diameter" is a vector option which contain info about diameter for each nozzle // But in the same time size of this vector indicates about count of extruders, // So, we need to add it to the diff if its size is changed. - if (opt_key == "nozzle_diameter" && + if (opt_key == "nozzle_diameter" && static_cast(this_opt)->size() != static_cast(other_opt)->size()) diff.emplace_back(opt_key); } @@ -1861,7 +1862,7 @@ static void update_preset_names_if_were_renamed(std::set& preset_na // Load all printers found in dir_path. // Throws an exception on error. void PhysicalPrinterCollection::load_printers( - const std::string& dir_path, const std::string& subdir, + const std::string& dir_path, const std::string& subdir, PresetsConfigSubstitutions& substitutions, ForwardCompatibilitySubstitutionRule substitution_rule) { // Don't use boost::filesystem::canonical() on Windows, it is broken in regard to reparse points, @@ -2251,12 +2252,12 @@ const std::string& ExtruderFilaments::get_preset_name_by_alias(const std::string return alias; } -void ExtruderFilaments::select_filament(size_t idx) -{ +void ExtruderFilaments::select_filament(size_t idx) +{ assert(idx == size_t(-1) || idx < m_extr_filaments.size()); // Check idx befor saving it's value to m_idx_selected. // Invalidate m_idx_selected, if idx is out of range m_extr_filaments - m_idx_selected = (idx == size_t(-1) || idx < m_extr_filaments.size()) ? idx : size_t(-1); + m_idx_selected = (idx == size_t(-1) || idx < m_extr_filaments.size()) ? idx : size_t(-1); } bool ExtruderFilaments::select_filament(const std::string &name_w_suffix, bool force/*= false*/) @@ -2296,7 +2297,7 @@ size_t ExtruderFilaments::update_compatible_internal(const PresetWithVendorProfi if (opt) config.set_key_value("num_extruders", new ConfigOptionInt((int)static_cast(opt)->values.size())); - // Adjust printer preset config to the first extruder from m_extruder_id + // Adjust printer preset config to the first extruder from m_extruder_id Preset printer_preset_adjusted = active_printer.preset; if (m_extruder_id > 0 && !printer_preset_adjusted.config.opt_bool("single_extruder_multi_material")) { DynamicPrintConfig& active_printer_config = printer_preset_adjusted.config; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index dd94bf2271b..2488b46fa6b 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -88,6 +88,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "between_objects_gcode", "binary_gcode", "bridge_acceleration", + "bridge_accel_to_decel", "bridge_jerk", "bridge_fan_speed", "enable_dynamic_fan_speeds", @@ -99,6 +100,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "colorprint_heights", "cooling", "default_acceleration", + "default_accel_to_decel", "default_jerk", "deretract_speed", "disable_fan_first_layers", @@ -106,6 +108,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "end_gcode", "end_filament_gcode", "external_perimeter_acceleration", + "external_perimeter_accel_to_decel", "external_perimeter_jerk", "extrusion_axis", "extruder_clearance_height", @@ -123,14 +126,17 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "filament_cost", "filament_spool_weight", "first_layer_acceleration", - "first_layer_acceleration_over_raft", + "first_layer_accel_to_decel", "first_layer_jerk", + "first_layer_acceleration_over_raft", + "first_layer_accel_to_decel_over_raft", "first_layer_jerk_over_raft", "first_layer_bed_temperature", "first_layer_speed_over_raft", "gcode_comments", "gcode_label_objects", "infill_acceleration", + "infill_accel_to_decel", "infill_jerk", "layer_gcode", "min_fan_speed", @@ -145,6 +151,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "only_retract_when_crossing_perimeters", "output_filename_format", "perimeter_acceleration", + "perimeter_accel_to_decel", "perimeter_jerk", "post_process", "gcode_substitutions", @@ -168,14 +175,17 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "single_extruder_multi_material_priming", "slowdown_below_layer_time", "solid_infill_acceleration", + "solid_infill_accel_to_decel", "solid_infill_jerk", "standby_temperature_delta", "start_gcode", "start_filament_gcode", "toolchange_gcode", "top_solid_infill_acceleration", + "top_solid_infill_accel_to_decel", "top_solid_infill_jerk", "travel_acceleration", + "travel_accel_to_decel", "travel_jerk", "thumbnails", "thumbnails_format", @@ -185,6 +195,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "variable_layer_height", "wipe", "wipe_tower_acceleration", + "wipe_tower_accel_to_decel", "wipe_tower_jerk" }; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 0555459d01d..b485624889c 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -364,7 +364,7 @@ void PrintConfigDef::init_common_params() def->mode = comAdvanced; def->cli = ConfigOptionDef::nocli; def->set_default_value(new ConfigOptionString("")); - + def = this->add("printhost_port", coString); def->label = L("Printer"); def->tooltip = L("Name of the printer"); @@ -372,7 +372,7 @@ void PrintConfigDef::init_common_params() def->mode = comAdvanced; def->cli = ConfigOptionDef::nocli; def->set_default_value(new ConfigOptionString("")); - + def = this->add("printhost_cafile", coString); def->label = L("HTTPS CA File"); def->tooltip = L("Custom CA certificate file can be specified for HTTPS OctoPrint connections, in crt/pem format. " @@ -380,16 +380,16 @@ void PrintConfigDef::init_common_params() def->mode = comAdvanced; def->cli = ConfigOptionDef::nocli; def->set_default_value(new ConfigOptionString("")); - + // Options used by physical printers - + def = this->add("printhost_user", coString); def->label = L("User"); // def->tooltip = L(""); def->mode = comAdvanced; def->cli = ConfigOptionDef::nocli; def->set_default_value(new ConfigOptionString("")); - + def = this->add("printhost_password", coString); def->label = L("Password"); // def->tooltip = L(""); @@ -405,7 +405,7 @@ void PrintConfigDef::init_common_params() def->mode = comAdvanced; def->cli = ConfigOptionDef::nocli; def->set_default_value(new ConfigOptionBool(false)); - + def = this->add("preset_names", coStrings); def->label = L("Printer preset names"); def->tooltip = L("Names of presets related to the physical printer"); @@ -544,6 +544,15 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("bridge_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for bridges."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("bridge_jerk", coInt); def->label = L("Jerk"); def->tooltip = L("This is the jerk your printer will use for bridges. " @@ -747,7 +756,7 @@ void PrintConfigDef::init_fff_params() { "no_brim", L("No brim") }, { "outer_only", L("Outer brim only") }, { "inner_only", L("Inner brim only") }, - { "outer_and_inner", L("Outer and inner brim") } + { "outer_and_inner", L("Outer and inner brim") } }); def->mode = comSimple; def->set_default_value(new ConfigOptionEnum(btOuterOnly)); @@ -846,6 +855,15 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("default_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable all accel to decel controls."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("default_jerk", coInt); def->label = L("Jerk"); def->tooltip = L("This is the jerk your printer will be reset to after " @@ -1012,7 +1030,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("The extruder to use (unless more specific extruder settings are specified). " "This value overrides perimeter and infill extruders, but not the support extruders."); def->min = 0; // 0 = inherit defaults - def->set_enum_labels(ConfigOptionDef::GUIType::i_enum_open, + def->set_enum_labels(ConfigOptionDef::GUIType::i_enum_open, { L("default"), "1", "2", "3", "4", "5" }); // override label for item 0 def = this->add("extruder_clearance_height", coFloat); @@ -1300,11 +1318,11 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("The filament material type for use in custom G-codes."); def->gui_flags = "show_value"; def->set_enum_values(ConfigOptionDef::GUIType::select_open, { - "PLA", + "PLA", "PET", "ABS", "ASA", - "FLEX", + "FLEX", "HIPS", "EDGE", "NGEN", @@ -1412,7 +1430,7 @@ void PrintConfigDef::init_fff_params() def->set_enum({ { "rectilinear", L("Rectilinear") }, { "alignedrectilinear", L("Aligned Rectilinear") }, - { "grid", L("Grid") }, + { "grid", L("Grid") }, { "triangles", L("Triangles")}, { "stars", L("Stars")}, { "cubic", L("Cubic")}, @@ -1439,10 +1457,10 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("first_layer_acceleration_over_raft", coFloat); - def->label = L("Acceleration"); - def->tooltip = L("This is the acceleration your printer will use for first layer of object above raft interface. Set zero " - "to disable acceleration control for first layer of object above raft interface."); + def = this->add("first_layer_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for first_layer."); def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; @@ -1457,6 +1475,24 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionInt(0)); + def = this->add("first_layer_acceleration_over_raft", coFloat); + def->label = L("Acceleration"); + def->tooltip = L("This is the acceleration your printer will use for first layer of object above raft interface. Set zero " + "to disable acceleration control for first layer of object above raft interface."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + + def = this->add("first_layer_accel_to_decel_over_raft", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for first layer of object above raft interface."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("first_layer_jerk_over_raft", coInt); def->label = L("Jerk"); def->tooltip = L("This is the jerk your printer will use for first layer of object above raft interface. Set zero " @@ -1660,6 +1696,24 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("infill_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for infill."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + + def = this->add("infill_jerk", coInt); + def->label = L("Jerk"); + def->tooltip = L("This is the jerk your printer will use for infill. Set zero to disable " + "jerk control for infill."); + def->sidetext = L("mm/s"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionInt(0)); + def = this->add("solid_infill_acceleration", coFloat); def->label = L("Acceleration"); def->tooltip = L("This is the acceleration your printer will use for solid infill. Set zero to use " @@ -1669,59 +1723,68 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("top_solid_infill_acceleration", coFloat); - def->label = L("Acceleration"); - def->tooltip = L("This is the acceleration your printer will use for top solid infill. Set zero to use " - "the value for solid infill."); + def = this->add("solid_infill_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for solid infill."); def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("wipe_tower_acceleration", coFloat); - def->label = L("Wipe tower"); - def->tooltip = L("This is the acceleration your printer will use for wipe tower. Set zero to disable " - "acceleration control for the wipe tower."); + def = this->add("solid_infill_jerk", coInt); + def->label = L("Jerk"); + def->tooltip = L("This is the jerk your printer will use for solid infill. Set zero to use " + "the value for solid infill."); + def->sidetext = L("mm/s"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionInt(0)); + + def = this->add("top_solid_infill_acceleration", coFloat); + def->label = L("Acceleration"); + def->tooltip = L("This is the acceleration your printer will use for top solid infill. Set zero to use " + "the value for top solid infill."); def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("travel_acceleration", coFloat); - def->label = L("Acceleration"); - def->tooltip = L("This is the acceleration your printer will use for travel moves. Set zero to disable " - "acceleration control for travel."); + def = this->add("top_solid_infill_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for top solid infill."); def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("infill_jerk", coInt); + def = this->add("top_solid_infill_jerk", coInt); def->label = L("Jerk"); - def->tooltip = L("This is the jerk your printer will use for infill. Set zero to disable " - "jerk control for infill."); + def->tooltip = L("This is the jerk your printer will use for top solid infill. Set zero to use " + "the value for top solid infill."); def->sidetext = L("mm/s"); def->min = 0; def->mode = comExpert; def->set_default_value(new ConfigOptionInt(0)); - def = this->add("solid_infill_jerk", coInt); - def->label = L("Jerk"); - def->tooltip = L("This is the jerk your printer will use for solid infill. Set zero to use " - "the value for infill."); - def->sidetext = L("mm/s"); + def = this->add("wipe_tower_acceleration", coFloat); + def->label = L("Wipe tower"); + def->tooltip = L("This is the acceleration your printer will use for wipe tower. Set zero to disable " + "acceleration control for the wipe tower."); + def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; - def->set_default_value(new ConfigOptionInt(0)); + def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("top_solid_infill_jerk", coInt); - def->label = L("Jerk"); - def->tooltip = L("This is the jerk your printer will use for top solid infill. Set zero to use " - "the value for solid infill."); - def->sidetext = L("mm/s"); + def = this->add("wipe_tower_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for the wipe tower."); + def->sidetext = L("mm/s²"); def->min = 0; def->mode = comExpert; - def->set_default_value(new ConfigOptionInt(0)); + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("wipe_tower_jerk", coInt); def->label = L("Jerk"); @@ -1732,6 +1795,24 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionInt(0)); + def = this->add("travel_acceleration", coFloat); + def->label = L("Acceleration"); + def->tooltip = L("This is the acceleration your printer will use for travel moves. Set zero to disable " + "acceleration control for travel."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + + def = this->add("travel_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for travel."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("travel_jerk", coInt); def->label = L("Jerk"); def->tooltip = L("This is the jerk your printer will use for travel moves. Set zero to disable " @@ -2092,6 +2173,15 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloats{ 1500., 1250. }); + // Klipper: SET_VELOCITY_LIMIT ACCEL_TO_DECEL=... [mm/sec^2] + def = this->add("machine_max_accel_to_decel", coFloats); + def->full_label = L("Maximum acceleration to deceleration."); + def->category = L("Machine limits"); + def->tooltip = L("Maximum pseudo acceleration when transitioning from acceleration to deceleration."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloats{ 750., 625. }); // M204 R... [mm/sec^2] def = this->add("machine_max_acceleration_retracting", coFloats); @@ -2490,11 +2580,12 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); - def = this->add("external_perimeter_acceleration", coFloat); - def->label = L("Acceleration"); - def->tooltip = L("This is the acceleration your printer will use for external perimeters. " - "Set zero to use the value for perimeters."); + def = this->add("perimeter_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for perimeters."); def->sidetext = L("mm/s²"); + def->min = 0; def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0)); @@ -2506,6 +2597,23 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionInt(0)); + def = this->add("external_perimeter_acceleration", coFloat); + def->label = L("Acceleration"); + def->tooltip = L("This is the acceleration your printer will use for external perimeters. " + "Set zero to use the value for perimeters."); + def->sidetext = L("mm/s²"); + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + + def = this->add("external_perimeter_accel_to_decel", coFloat); + def->label = L("Accel to Decel"); + def->tooltip = L("This is how fast the toolhead may go from acceleration to deceleration. " + "Set zero to disable control for bridges."); + def->sidetext = L("mm/s²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("external_perimeter_jerk", coInt); def->label = L("Jerk"); def->tooltip = L("This is the acceleration your printer will use for external perimeters. " @@ -3358,7 +3466,7 @@ void PrintConfigDef::init_fff_params() "will create more stable supports, while snug support towers will save material and reduce " "object scarring."); def->set_enum({ - { "grid", L("Grid") }, + { "grid", L("Grid") }, { "snug", L("Snug") }, { "organic", L("Organic") } }); @@ -3445,7 +3553,7 @@ void PrintConfigDef::init_fff_params() def->set_default_value(new ConfigOptionFloat(2)); def = this->add("support_tree_branch_diameter_angle", coFloat); - // TRN PrintSettings: #lmFIXME + // TRN PrintSettings: #lmFIXME def->label = L("Branch Diameter Angle"); def->category = L("Support material"); // TRN PrintSettings: "Organic supports" > "Branch Diameter Angle" @@ -3471,10 +3579,10 @@ void PrintConfigDef::init_fff_params() def->set_default_value(new ConfigOptionFloat(3)); // Tree Support Branch Distance - // How far apart the branches need to be when they touch the model. Making this distance small will cause + // How far apart the branches need to be when they touch the model. Making this distance small will cause // the tree support to touch the model at more points, causing better overhang but making support harder to remove. def = this->add("support_tree_branch_distance", coFloat); - // TRN PrintSettings: #lmFIXME + // TRN PrintSettings: #lmFIXME def->label = L("Branch Distance"); def->category = L("Support material"); // TRN PrintSettings: "Organic supports" > "Branch Distance" @@ -4044,7 +4152,7 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix) def->label = L("Pillar widening factor"); def->category = L("Supports"); - def->tooltip = + def->tooltip = L("Merging bridges or pillars into another pillars can " "increase the radius. Zero means no increase, one means " "full increase. The exact amount of increase is unspecified and can " @@ -4264,7 +4372,7 @@ void PrintConfigDef::init_sla_params() "to the sign of the correction."); def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0.0)); - + def = this->add("elefant_foot_min_width", coFloat); def->label = L("Elephant foot minimum width"); def->category = L("Advanced"); @@ -4436,7 +4544,7 @@ void PrintConfigDef::init_sla_params() def->full_width = true; def->height = 13; // TODO currently notes are the only way to pass data - // for non-PrusaResearch printers. We therefore need to always show them + // for non-PrusaResearch printers. We therefore need to always show them def->mode = comSimple; def->set_default_value(new ConfigOptionString("")); @@ -4541,7 +4649,7 @@ void PrintConfigDef::init_sla_params() def->max = 30; def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0.)); - + def = this->add("pad_brim_size", coFloat); def->label = L("Pad brim size"); def->tooltip = L("How far should the pad extend around the contained geometry"); @@ -4592,7 +4700,7 @@ void PrintConfigDef::init_sla_params() def->tooltip = L("Create pad around object and ignore the support elevation"); def->mode = comSimple; def->set_default_value(new ConfigOptionBool(false)); - + def = this->add("pad_around_object_everywhere", coBool); def->label = L("Pad around object everywhere"); def->category = L("Pad"); @@ -4638,14 +4746,14 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0.3)); - + def = this->add("hollowing_enable", coBool); def->label = L("Enable hollowing"); def->category = L("Hollowing"); def->tooltip = L("Hollow out a model to have an empty interior"); def->mode = comSimple; def->set_default_value(new ConfigOptionBool(false)); - + def = this->add("hollowing_min_thickness", coFloat); def->label = L("Wall thickness"); def->category = L("Hollowing"); @@ -4655,7 +4763,7 @@ void PrintConfigDef::init_sla_params() def->max = 10; def->mode = comSimple; def->set_default_value(new ConfigOptionFloat(3.)); - + def = this->add("hollowing_quality", coFloat); def->label = L("Accuracy"); def->category = L("Hollowing"); @@ -4664,7 +4772,7 @@ void PrintConfigDef::init_sla_params() def->max = 1; def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0.5)); - + def = this->add("hollowing_closing_distance", coFloat); def->label = L("Closing distance"); def->category = L("Hollowing"); @@ -4709,11 +4817,11 @@ void PrintConfigDef::init_sla_params() // Declare retract values for material profile, overriding the print and printer profiles. for (const char* opt_key : { // float - "support_head_front_diameter", "branchingsupport_head_front_diameter", - "support_head_penetration", "branchingsupport_head_penetration", + "support_head_front_diameter", "branchingsupport_head_front_diameter", + "support_head_penetration", "branchingsupport_head_penetration", "support_head_width", "branchingsupport_head_width", "support_pillar_diameter", "branchingsupport_pillar_diameter", - "relative_correction_x", "relative_correction_y", "relative_correction_z", + "relative_correction_x", "relative_correction_y", "relative_correction_z", "elefant_foot_compensation", // int "support_points_density_relative" @@ -4928,7 +5036,7 @@ DynamicPrintConfig* DynamicPrintConfig::new_from_defaults_keys(const std::vector } double min_object_distance(const ConfigBase &cfg) -{ +{ const ConfigOptionEnum *opt_printer_technology = cfg.option>("printer_technology"); auto printer_technology = opt_printer_technology ? opt_printer_technology->value : ptUnknown; @@ -4941,7 +5049,7 @@ double min_object_distance(const ConfigBase &cfg) auto dd_opt = cfg.option("duplicate_distance"); auto co_opt = cfg.option("complete_objects"); - if (!ecr_opt || !dd_opt || !co_opt) + if (!ecr_opt || !dd_opt || !co_opt) ret = 0.; else { // min object distance is max(duplicate_distance, clearance_radius) @@ -5286,7 +5394,7 @@ std::string validate(const FullPrintConfig &cfg) return ret; \ } PRINT_CONFIG_CACHE_INITIALIZE(( - PrintObjectConfig, PrintRegionConfig, MachineEnvelopeConfig, GCodeConfig, PrintConfig, FullPrintConfig, + PrintObjectConfig, PrintRegionConfig, MachineEnvelopeConfig, GCodeConfig, PrintConfig, FullPrintConfig, SLAMaterialConfig, SLAPrintConfig, SLAPrintObjectConfig, SLAPrinterConfig, SLAFullPrintConfig)) static int print_config_static_initialized = print_config_static_initializer(); @@ -5647,7 +5755,7 @@ PrintStatisticsConfigDef::PrintStatisticsConfigDef() def = this->add("normal_print_time", coString); def->label = L("Print time (normal mode)"); def->tooltip = L("Estimated print time when printed in normal mode (i.e. not in silent mode). Same as print_time."); - + def = this->add("num_printing_extruders", coInt); def->label = L("Number of printing extruders"); def->tooltip = L("Number of extruders used during the print."); @@ -5882,22 +5990,22 @@ static Points to_points(const std::vector &dpts) Points pts; pts.reserve(dpts.size()); for (auto &v : dpts) pts.emplace_back( coord_t(scale_(v.x())), coord_t(scale_(v.y())) ); - return pts; + return pts; } Points get_bed_shape(const DynamicPrintConfig &config) { const auto *bed_shape_opt = config.opt("bed_shape"); if (!bed_shape_opt) { - + // Here, it is certain that the bed shape is missing, so an infinite one // has to be used, but still, the center of bed can be queried if (auto center_opt = config.opt("center")) return { scaled(center_opt->value) }; - + return {}; } - + return to_points(bed_shape_opt->values); } diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 67afb6471bf..76651304d8f 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -530,6 +530,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloat, elefant_foot_compensation)) ((ConfigOptionFloatOrPercent, extrusion_width)) ((ConfigOptionFloat, first_layer_acceleration_over_raft)) + ((ConfigOptionFloat, first_layer_accel_to_decel_over_raft)) ((ConfigOptionInt, first_layer_jerk_over_raft)) ((ConfigOptionFloatOrPercent, first_layer_speed_over_raft)) // ((ConfigOptionBool, infill_only_where_needed)) @@ -692,6 +693,9 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloats, machine_max_acceleration_retracting)) ((ConfigOptionFloats, machine_max_acceleration_travel)) + // Klipper: SET_VELOCITY_LIMIT ACCEL_TO_DECEL=... [mm/sec^2] + ((ConfigOptionFloats, machine_max_accel_to_decel)) + // M205 X... Y... Z... E... [mm/sec] ((ConfigOptionFloats, machine_max_jerk_x)) ((ConfigOptionFloats, machine_max_jerk_y)) @@ -832,6 +836,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionPoints, bed_shape)) ((ConfigOptionInts, bed_temperature)) ((ConfigOptionFloat, bridge_acceleration)) + ((ConfigOptionFloat, bridge_accel_to_decel)) ((ConfigOptionInt, bridge_jerk)) ((ConfigOptionInts, bridge_fan_speed)) ((ConfigOptionBools, enable_dynamic_fan_speeds)) @@ -843,11 +848,13 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionFloats, colorprint_heights)) ((ConfigOptionBools, cooling)) ((ConfigOptionFloat, default_acceleration)) + ((ConfigOptionFloat, default_accel_to_decel)) ((ConfigOptionInt, default_jerk)) ((ConfigOptionInts, disable_fan_first_layers)) ((ConfigOptionEnum, draft_shield)) ((ConfigOptionFloat, duplicate_distance)) ((ConfigOptionFloat, external_perimeter_acceleration)) + ((ConfigOptionFloat, external_perimeter_accel_to_decel)) ((ConfigOptionInt, external_perimeter_jerk)) ((ConfigOptionFloat, extruder_clearance_height)) ((ConfigOptionFloat, extruder_clearance_radius)) @@ -859,6 +866,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionStrings, filament_notes)) ((ConfigOptionPercents, filament_shrink)) ((ConfigOptionFloat, first_layer_acceleration)) + ((ConfigOptionFloat, first_layer_accel_to_decel)) ((ConfigOptionInt, first_layer_jerk)) ((ConfigOptionInts, first_layer_bed_temperature)) ((ConfigOptionFloatOrPercent, first_layer_extrusion_width)) @@ -868,6 +876,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionIntsNullable, idle_temperature)) ((ConfigOptionInts, full_fan_speed_layer)) ((ConfigOptionFloat, infill_acceleration)) + ((ConfigOptionFloat, infill_accel_to_decel)) ((ConfigOptionInt, infill_jerk)) ((ConfigOptionBool, infill_first)) ((ConfigOptionInts, max_fan_speed)) @@ -883,6 +892,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionBool, ooze_prevention)) ((ConfigOptionString, output_filename_format)) ((ConfigOptionFloat, perimeter_acceleration)) + ((ConfigOptionFloat, perimeter_accel_to_decel)) ((ConfigOptionInt, perimeter_jerk)) ((ConfigOptionStrings, post_process)) ((ConfigOptionString, printer_model)) @@ -896,6 +906,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionInt, skirts)) ((ConfigOptionInts, slowdown_below_layer_time)) ((ConfigOptionFloat, solid_infill_acceleration)) + ((ConfigOptionFloat, solid_infill_accel_to_decel)) ((ConfigOptionInt, solid_infill_jerk)) ((ConfigOptionBool, spiral_vase)) ((ConfigOptionInt, standby_temperature_delta)) @@ -904,12 +915,15 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionString, thumbnails)) ((ConfigOptionEnum, thumbnails_format)) ((ConfigOptionFloat, top_solid_infill_acceleration)) + ((ConfigOptionFloat, top_solid_infill_accel_to_decel)) ((ConfigOptionInt, top_solid_infill_jerk)) ((ConfigOptionFloat, travel_acceleration)) + ((ConfigOptionFloat, travel_accel_to_decel)) ((ConfigOptionInt, travel_jerk)) ((ConfigOptionBools, wipe)) ((ConfigOptionBool, wipe_tower)) ((ConfigOptionFloat, wipe_tower_acceleration)) + ((ConfigOptionFloat, wipe_tower_accel_to_decel)) ((ConfigOptionInt, wipe_tower_jerk)) ((ConfigOptionFloat, wipe_tower_x)) ((ConfigOptionFloat, wipe_tower_y)) diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 5fa73ce58ce..2221fba5e0b 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -9,6 +9,7 @@ #include "format.hpp" #include "libslic3r/Model.hpp" #include "libslic3r/PresetBundle.hpp" +#include "libslic3r/PrintConfig.hpp" #include "MsgDialog.hpp" #include @@ -223,6 +224,10 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) { + PresetBundle *preset_bundle = wxGetApp().preset_bundle; + + auto gcflavor = preset_bundle->printers.get_selected_preset().config.option>("gcode_flavor")->value; + bool have_perimeters = config->opt_int("perimeters") > 0; for (auto el : { "extra_perimeters","extra_perimeters_on_overhangs", "thin_walls", "overhangs", "seam_position","staggered_inner_seams", "external_perimeters_first", "external_perimeter_extrusion_width", @@ -273,10 +278,17 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) bool have_default_jerk = config->opt_int("default_jerk") > 0; for (auto el : { "perimeter_jerk", "infill_jerk", "top_solid_infill_jerk", - "solid_infill_jerk", "external_perimeter_jerk", "external_perimeter_jerk", - "bridge_jerk", "first_layer_jerk", "travel_jerk", "wipe_tower_jerk" }) + "solid_infill_jerk", "external_perimeter_jerk", "bridge_jerk", + "first_layer_jerk", "first_layer_jerk_over_raft", "wipe_tower_jerk", "travel_jerk" }) toggle_field(el, have_default_jerk); + bool have_accel_to_decel = config->opt_float("default_accel_to_decel") > 0 && gcflavor == gcfKlipper; + for (auto el : { "perimeter_accel_to_decel", "infill_accel_to_decel", "top_solid_infill_accel_to_decel", + "solid_infill_accel_to_decel", "external_perimeter_accel_to_decel", "bridge_accel_to_decel", + "first_layer_accel_to_decel", "first_layer_accel_to_decel_over_raft", "travel_accel_to_decel", + "wipe_tower_accel_to_decel" }) + toggle_field(el, have_accel_to_decel); + bool have_skirt = config->opt_int("skirts") > 0; toggle_field("skirt_height", have_skirt && config->opt_enum("draft_shield") != dsEnabled); for (auto el : { "skirt_distance", "draft_shield", "min_skirt_length" }) @@ -322,7 +334,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) toggle_field("support_material_speed", have_support_material || have_brim || have_skirt); toggle_field("raft_contact_distance", have_raft && !have_support_soluble); - for (auto el : { "raft_expansion", "first_layer_acceleration_over_raft", "first_layer_jerk_over_raft", "first_layer_speed_over_raft" }) + for (auto el : { "raft_expansion", "first_layer_speed_over_raft" }) toggle_field(el, have_raft); bool has_ironing = config->opt_bool("ironing"); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 314e961f274..c2fef46dc01 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1685,56 +1685,67 @@ void TabPrint::build() optgroup = page->new_optgroup(L("Acceleration/jerk control (advanced)")); line = { L("External perimeters"), "" }; line.append_option(optgroup->get_option("external_perimeter_acceleration")); + line.append_option(optgroup->get_option("external_perimeter_accel_to_decel")); line.append_option(optgroup->get_option("external_perimeter_jerk")); optgroup->append_line(line); line = { L("Perimeters"), "" }; line.append_option(optgroup->get_option("perimeter_acceleration")); + line.append_option(optgroup->get_option("perimeter_accel_to_decel")); line.append_option(optgroup->get_option("perimeter_jerk")); optgroup->append_line(line); line = { L("Top solid infill"), "" }; line.append_option(optgroup->get_option("top_solid_infill_acceleration")); + line.append_option(optgroup->get_option("top_solid_infill_accel_to_decel")); line.append_option(optgroup->get_option("top_solid_infill_jerk")); optgroup->append_line(line); line = { L("Solid infill"), "" }; line.append_option(optgroup->get_option("solid_infill_acceleration")); + line.append_option(optgroup->get_option("solid_infill_accel_to_decel")); line.append_option(optgroup->get_option("solid_infill_jerk")); optgroup->append_line(line); line = { L("Infill"), "" }; line.append_option(optgroup->get_option("infill_acceleration")); + line.append_option(optgroup->get_option("infill_accel_to_decel")); line.append_option(optgroup->get_option("infill_jerk")); optgroup->append_line(line); line = { L("Bridge"), "" }; line.append_option(optgroup->get_option("bridge_acceleration")); + line.append_option(optgroup->get_option("bridge_accel_to_decel")); line.append_option(optgroup->get_option("bridge_jerk")); optgroup->append_line(line); line = { L("First layer"), "" }; line.append_option(optgroup->get_option("first_layer_acceleration")); + line.append_option(optgroup->get_option("first_layer_accel_to_decel")); line.append_option(optgroup->get_option("first_layer_jerk")); optgroup->append_line(line); line = { L("First object layer over raft interface"), "" }; line.append_option(optgroup->get_option("first_layer_acceleration_over_raft")); + line.append_option(optgroup->get_option("first_layer_accel_to_decel_over_raft")); line.append_option(optgroup->get_option("first_layer_jerk_over_raft")); optgroup->append_line(line); line = { L("Wipe Tower"), "" }; line.append_option(optgroup->get_option("wipe_tower_acceleration")); + line.append_option(optgroup->get_option("wipe_tower_accel_to_decel")); line.append_option(optgroup->get_option("wipe_tower_jerk")); optgroup->append_line(line); line = { L("Travel"), "" }; line.append_option(optgroup->get_option("travel_acceleration")); + line.append_option(optgroup->get_option("travel_accel_to_decel")); line.append_option(optgroup->get_option("travel_jerk")); optgroup->append_line(line); line = { L("Default"), "" }; line.append_option(optgroup->get_option("default_acceleration")); + line.append_option(optgroup->get_option("default_accel_to_decel")); line.append_option(optgroup->get_option("default_jerk")); optgroup->append_line(line); @@ -2874,10 +2885,12 @@ void TabPrinter::build_fff() const GCodeFlavor flavor = static_cast(boost::any_cast(value)); bool supports_travel_acceleration = GCodeWriter::supports_separate_travel_acceleration(flavor); bool supports_min_feedrates = (flavor == gcfMarlinFirmware || flavor == gcfMarlinLegacy); - if (supports_travel_acceleration != m_supports_travel_acceleration || supports_min_feedrates != m_supports_min_feedrates) { + bool supports_accel_to_decel = (flavor == gcfKlipper); + if (supports_travel_acceleration != m_supports_travel_acceleration || supports_min_feedrates != m_supports_min_feedrates || m_supports_accel_to_decel != supports_accel_to_decel) { m_rebuild_kinematics_page = true; m_supports_travel_acceleration = supports_travel_acceleration; m_supports_min_feedrates = supports_min_feedrates; + m_supports_accel_to_decel = supports_accel_to_decel; } const bool is_emit_to_gcode = m_config->option("machine_limits_usage")->getInt() == static_cast(MachineLimitsUsage::EmitToGCode); @@ -3229,6 +3242,8 @@ PageShp TabPrinter::build_kinematics_page() append_option_line(optgroup, "machine_max_acceleration_retracting"); if (m_supports_travel_acceleration) append_option_line(optgroup, "machine_max_acceleration_travel"); + if (m_supports_accel_to_decel) + append_option_line(optgroup, "machine_max_accel_to_decel"); optgroup = page->new_optgroup(L("Jerk limits")); for (const std::string &axis : axes) { @@ -3730,10 +3745,12 @@ void TabPrinter::update_fff() const auto flavor = m_config->option>("gcode_flavor")->value; bool supports_travel_acceleration = (flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware); bool supports_min_feedrates = (flavor == gcfMarlinFirmware || flavor == gcfMarlinLegacy); - if (m_supports_travel_acceleration != supports_travel_acceleration || m_supports_min_feedrates != supports_min_feedrates) { + bool supports_accel_to_decel = (flavor == gcfKlipper); + if (m_supports_travel_acceleration != supports_travel_acceleration || m_supports_min_feedrates != supports_min_feedrates || m_supports_accel_to_decel != supports_accel_to_decel) { m_rebuild_kinematics_page = true; m_supports_travel_acceleration = supports_travel_acceleration; m_supports_min_feedrates = supports_min_feedrates; + m_supports_accel_to_decel = supports_accel_to_decel; } toggle_options(); diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 505c47b199d..7e477e78bb5 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -513,8 +513,9 @@ class TabPrinter : public Tab private: bool m_has_single_extruder_MM_page = false; bool m_use_silent_mode = false; - bool m_supports_travel_acceleration = false; - bool m_supports_min_feedrates = false; + bool m_supports_travel_acceleration = false; + bool m_supports_accel_to_decel = false; + bool m_supports_min_feedrates = false; void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key); bool m_rebuild_kinematics_page = false; ogStaticText* m_machine_limits_description_line {nullptr};