diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 842d49f24..98576f965 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1732,29 +1732,55 @@ static bool custom_gcode_sets_temperature(const std::string &gcode, const int mc // Do not process this piece of G-code by the time estimator, it already knows the values through another sources. void GCode::print_machine_envelope(FILE *file, Print &print) { - if (print.config().gcode_flavor.value == gcfMarlin || print.config().gcode_flavor.value == gcfLerdge) { - fprintf(file, "M201 X%d Y%d Z%d E%d ; sets maximum accelerations, mm/sec^2\n", - int(print.config().machine_max_acceleration_x.values.front() + 0.5), - int(print.config().machine_max_acceleration_y.values.front() + 0.5), - int(print.config().machine_max_acceleration_z.values.front() + 0.5), - int(print.config().machine_max_acceleration_e.values.front() + 0.5)); - fprintf(file, "M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/sec\n", - int(print.config().machine_max_feedrate_x.values.front() + 0.5), - int(print.config().machine_max_feedrate_y.values.front() + 0.5), - int(print.config().machine_max_feedrate_z.values.front() + 0.5), - int(print.config().machine_max_feedrate_e.values.front() + 0.5)); - fprintf(file, "M204 P%d R%d T%d ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2\n", - int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), - int(print.config().machine_max_acceleration_retracting.values.front() + 0.5), - int(print.config().machine_max_acceleration_extruding.values.front() + 0.5)); - fprintf(file, "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n", - print.config().machine_max_jerk_x.values.front(), - print.config().machine_max_jerk_y.values.front(), - print.config().machine_max_jerk_z.values.front(), - print.config().machine_max_jerk_e.values.front()); - fprintf(file, "M205 S%d T%d ; sets the minimum extruding and travel feed rate, mm/sec\n", - int(print.config().machine_min_extruding_rate.values.front() + 0.5), - int(print.config().machine_min_travel_rate.values.front() + 0.5)); + // gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfKlipper, gcfSailfish, gcfMach3, gcfMachinekit, + /// gcfSmoothie, gcfNoExtrusion, gcfLerdge, + if (print.config().print_machine_envelope) { + if (std::set{gcfMarlin, gcfLerdge, gcfRepetier, gcfRepRap}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M201 X%d Y%d Z%d E%d ; sets maximum accelerations, mm/sec^2\n", + int(print.config().machine_max_acceleration_x.values.front() + 0.5), + int(print.config().machine_max_acceleration_y.values.front() + 0.5), + int(print.config().machine_max_acceleration_z.values.front() + 0.5), + int(print.config().machine_max_acceleration_e.values.front() + 0.5)); + if (std::set{gcfRepetier}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M202 X%d Y%d ; sets maximum travel speed\n", + int(print.config().travel_speed.value), + int(print.config().travel_speed.value)); + if (std::set{gcfMarlin, gcfLerdge, gcfRepetier, gcfRepRap, gcfSmoothie}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M203 X%d Y%d Z%d E%d ; sets maximum feedrates, mm/sec\n", + int(print.config().machine_max_feedrate_x.values.front() + 0.5), + int(print.config().machine_max_feedrate_y.values.front() + 0.5), + int(print.config().machine_max_feedrate_z.values.front() + 0.5), + int(print.config().machine_max_feedrate_e.values.front() + 0.5)); + if (std::set{gcfMarlin, gcfLerdge}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M204 P%d R%d T%d ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2\n", + int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), + int(print.config().machine_max_acceleration_retracting.values.front() + 0.5), + int(print.config().machine_max_acceleration_extruding.values.front() + 0.5)); + if (std::set{gcfRepRap, gcfKlipper}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M204 P%d T%d ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2\n", + int(print.config().machine_max_acceleration_extruding.values.front() + 0.5), + int(print.config().machine_max_acceleration_retracting.values.front() + 0.5)); + if (std::set{gcfMarlin, gcfLerdge, gcfRepetier}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M566 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n", + print.config().machine_max_jerk_x.values.front(), + print.config().machine_max_jerk_y.values.front(), + print.config().machine_max_jerk_z.values.front(), + print.config().machine_max_jerk_e.values.front()); + if (std::set{gcfRepRap}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n", + print.config().machine_max_jerk_x.values.front(), + print.config().machine_max_jerk_y.values.front(), + print.config().machine_max_jerk_z.values.front(), + print.config().machine_max_jerk_e.values.front()); + if (std::set{gcfSmoothie}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M205 X%.2lf Z%.2lf ; sets the jerk limits, mm/sec\n", + std::min(print.config().machine_max_jerk_x.values.front(), + print.config().machine_max_jerk_y.values.front()), + print.config().machine_max_jerk_z.values.front()); + if (std::set{gcfMarlin, gcfLerdge, gcfRepetier}.count(print.config().gcode_flavor.value) > 0) + fprintf(file, "M205 S%d T%d ; sets the minimum extruding and travel feed rate, mm/sec\n", + int(print.config().machine_min_extruding_rate.values.front() + 0.5), + int(print.config().machine_min_travel_rate.values.front() + 0.5)); } } diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 1b01238c1..9c2f5cca5 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -131,6 +131,7 @@ bool Print::invalidate_state_by_config_options(const std::vectortooltip = L("If expressed as absolute value in mm/s, this speed will be applied to all the print moves " "but infill of the first layer, it can be overwrite by the 'default' (default depends of the type of the path) " "speed if it's lower than that. If expressed as a percentage " - "(for example: 40%) it will scale the 'default' speeds."); + "it will scale the current speed." + "\nSet it at 100% to remove any first layer speed modification (with first_layer_infill_speed)."); def->sidetext = L("mm/s or %"); def->ratio_over = "depends"; def->min = 0; @@ -1481,7 +1482,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("If expressed as absolute value in mm/s, this speed will be applied to infill moves " "of the first layer, it can be overwrite by the 'default' (solid infill or infill if not bottom) " "speed if it's lower than that. If expressed as a percentage " - "(for example: 40%) it will scale the 'default' speed."); + "(for example: 40%) it will scale the current infill speed."); def->sidetext = L("mm/s or %"); def->ratio_over = "depends"; def->min = 0; @@ -2066,10 +2067,20 @@ void PrintConfigDef::init_fff_params() def->label = L("Hostname, IP or URL"); def->category = OptionCategory::general; def->tooltip = L("Slic3r can upload G-code files to a printer host. This field should contain " - "the hostname, IP address or URL of the printer host instance."); + "the hostname, IP address or URL of the printer host instance."); def->mode = comAdvanced; def->set_default_value(new ConfigOptionString("")); + def = this->add("print_machine_envelope", coBool); + def->label = L("Print machine envelope in gcode"); + def->category = OptionCategory::limits; + def->tooltip = L("Slic3r can add M201 M203 M202 M204 and M205 gcodes to pass the machine limits defined here to the firmware." + "Gcodes printed will depends of the firmware selected (please Report an issue if you found something wrong)." + "\nIf you want only a selection, you can write your gcode with these value, example: " + "\nM204 P[machine_max_acceleration_extruding] T[machine_max_acceleration_retracting]"); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionBool(false)); + def = this->add("only_retract_when_crossing_perimeters", coBool); def->label = L("Only retract when crossing perimeters"); def->category = OptionCategory::extruders; @@ -2129,7 +2140,7 @@ void PrintConfigDef::init_fff_params() def->label = L("Reverse threshold"); def->full_label = L("Overhang reversal threshold"); def->category = OptionCategory::perimeter; - def->tooltip = L("Number of mm the overhang need to be for the reversal to be considered useful. Can be a % of the periemter width."); + def->tooltip = L("Number of mm the overhang need to be for the reversal to be considered useful. Can be a % of the perimeter width."); def->ratio_over = "perimeter_extrusion_width"; def->min = 0; def->mode = comAdvanced; diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index d660de996..7ccab613e 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -47,7 +47,7 @@ enum WipeAlgo { waHyper, }; -enum GCodeFlavor : unsigned char { +enum GCodeFlavor : uint8_t { gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfKlipper, gcfSailfish, gcfMach3, gcfMachinekit, gcfSmoothie, gcfNoExtrusion, gcfLerdge, }; @@ -1069,6 +1069,7 @@ public: ConfigOptionString output_filename_format; ConfigOptionFloat perimeter_acceleration; ConfigOptionStrings post_process; + ConfigOptionBool print_machine_envelope; ConfigOptionString printer_model; ConfigOptionString printer_notes; ConfigOptionFloat resolution; @@ -1155,6 +1156,7 @@ protected: OPT_PTR(output_filename_format); OPT_PTR(perimeter_acceleration); OPT_PTR(post_process); + OPT_PTR(print_machine_envelope); OPT_PTR(printer_model); OPT_PTR(printer_notes); OPT_PTR(resolution); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 8ca5c473d..5f5241ee8 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -600,6 +600,7 @@ const std::vector& Preset::printer_options() "machine_min_extruding_rate", "machine_min_travel_rate", "machine_max_jerk_x", "machine_max_jerk_y", "machine_max_jerk_z", "machine_max_jerk_e", "time_estimation_compensation", + "print_machine_envelope", "fan_speedup_time" }; s_opts.insert(s_opts.end(), Preset::nozzle_options().begin(), Preset::nozzle_options().end()); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 7847128ab..f9424b67e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2165,6 +2165,17 @@ PageShp TabPrinter::build_kinematics_page() optgroup = page->new_optgroup(_(L("not-marlin/lerdge firmware compensation"))); optgroup->append_single_option_line("time_estimation_compensation"); } + optgroup = page->new_optgroup(_(L("Usage"))); + Line current_line = Line{ "", "" }; + current_line.full_width = 1; + current_line.widget = [this](wxWindow* parent) { + ogStaticText* text; + auto result = description_line_widget(parent, &text); + text->SetText(_(L("This tab is used to calculate the time estimation. SuperSlicer can also write these limits in the beginning of the gcode file, if the setting below is checked. It's not used by anything else."))); + return result; + }; + optgroup->append_line(current_line); + optgroup->append_single_option_line("print_machine_envelope"); if (m_use_silent_mode) { // Legend for OptionsGroups diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 123a7899a..0f3935ba3 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -353,6 +353,7 @@ class TabFilament : public Tab public: ogStaticText* m_volumetric_speed_description_line; ogStaticText* m_cooling_description_line; + ogStaticText* m_machine_limits_descr; void add_filament_overrides_page(); protected: void update_filament_overrides_page();