From 08cd7ebe2680eec68a1cdad4d41a8c74c7dd8bc4 Mon Sep 17 00:00:00 2001 From: supermerill Date: Fri, 29 Oct 2021 15:36:06 +0200 Subject: [PATCH] Setting to put thumbnails at the end of the gcode file Note that no firmware/printer support that right now. --- resources/ui_layout/printer_fff.ui | 9 ++++++--- src/libslic3r/GCode.cpp | 24 ++++++++++++++++++------ src/libslic3r/Preset.cpp | 1 + src/libslic3r/PrintConfig.cpp | 8 ++++++++ src/libslic3r/PrintConfig.hpp | 2 ++ src/libslic3r/SLAPrint.cpp | 1 + 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/resources/ui_layout/printer_fff.ui b/resources/ui_layout/printer_fff.ui index 5ccc4da39..5c5b3cd22 100644 --- a/resources/ui_layout/printer_fff.ui +++ b/resources/ui_layout/printer_fff.ui @@ -28,8 +28,8 @@ group:silent_mode_event:Firmware end_line setting:gcode_filename_illegal_char group:Cooling fan - line:Speedup - setting:label$Speedup time:fan_speedup_time + line:Speedup time + setting:label$:fan_speedup_time setting:label$Only for overhangs:fan_speedup_overhangs end_line setting:label$Kickstart duration:fan_kickstart @@ -43,7 +43,10 @@ group:Thumbnails setting:label$:sidetext_width$1:thumbnails_custom_color setting:label$:label_width$1:thumbnails_color end_line - setting:thumbnails_with_bed + line:Thumbnail options + setting:thumbnails_with_bed + setting:thumbnails_end_file + end_line group:Advanced setting:use_relative_e_distances setting:use_firmware_retraction diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 492bbe558..8d961709f 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1169,12 +1169,15 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu _write_format(file, "; %s\n\n", Slic3r::header_slic3r_generated().c_str()); - const ConfigOptionBool *thumbnails_with_bed = print.full_print_config().option("thumbnails_with_bed"); - DoExport::export_thumbnails_to_file(thumbnail_cb, - print.full_print_config().option("thumbnails")->values, - thumbnails_with_bed==nullptr? false:thumbnails_with_bed->value, - [this, file](const char* sz) { this->_write(file, sz); }, - [&print]() { print.throw_if_canceled(); }); + //print thumbnails at the start unless requested at the end. + const ConfigOptionBool* thumbnails_with_bed = print.full_print_config().option("thumbnails_with_bed"); + const ConfigOptionBool* thumbnails_end_file = print.full_print_config().option("thumbnails_end_file"); + if(!thumbnails_end_file || !thumbnails_end_file->value) + DoExport::export_thumbnails_to_file(thumbnail_cb, + print.full_print_config().option("thumbnails")->values, + thumbnails_with_bed==nullptr? false:thumbnails_with_bed->value, + [this, file](const char* sz) { this->_write(file, sz); }, + [&print]() { print.throw_if_canceled(); }); // Write notes (content of the Print Settings tab -> Notes) { @@ -1676,6 +1679,15 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu _write(file, full_config, true); } print.throw_if_canceled(); + + //print thumbnails at the end instead of the start if requested + if (thumbnails_end_file && thumbnails_end_file->value) + DoExport::export_thumbnails_to_file(thumbnail_cb, + print.full_print_config().option("thumbnails")->values, + thumbnails_with_bed == nullptr ? false : thumbnails_with_bed->value, + [this, file](const char* sz) { this->_write(file, sz); }, + [&print]() { print.throw_if_canceled(); }); + print.throw_if_canceled(); } std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, uint16_t current_extruder_id, DynamicConfig *config_override) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index b311d722c..888a74d88 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -757,6 +757,7 @@ const std::vector& Preset::printer_options() "thumbnails", "thumbnails_color", "thumbnails_custom_color", + "thumbnails_end_file", "thumbnails_with_bed", "wipe_advanced", "wipe_advanced_nozzle_melted_volume", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 35a5e7a14..f11720425 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -97,6 +97,13 @@ void PrintConfigDef::init_common_params() def->mode = comExpert; def->set_default_value(new ConfigOptionBool(false)); + def = this->add("thumbnails_end_file", coBool); + def->label = L("Print at the end"); + def->tooltip = L("Print the thumbnail code at the end of the gcode file instead of the front." + "\nBe careful! Most firmwares expect it at the front, so be sure that your firmware support it."); + def->mode = comExpert; + def->set_default_value(new ConfigOptionBool(false)); + def = this->add("thumbnails_with_bed", coBool); def->label = L("Bed on thumbnail"); def->tooltip = L("Show the bed texture on the thumbnail picture."); @@ -5914,6 +5921,7 @@ std::unordered_set prusa_export_to_remove_keys = { "thin_walls_speed", "thumbnails_color", "thumbnails_custom_color", +"thumbnails_end_file", "thumbnails_with_bed", "thumbnails_with_support", "time_estimation_compensation", diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 592b576ab..f68073743 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1379,6 +1379,7 @@ public: ConfigOptionPoints thumbnails; ConfigOptionString thumbnails_color; ConfigOptionBool thumbnails_custom_color; + ConfigOptionBool thumbnails_end_file; ConfigOptionBool thumbnails_with_bed; ConfigOptionPercent time_estimation_compensation; ConfigOptionInts top_fan_speed; @@ -1482,6 +1483,7 @@ protected: OPT_PTR(thumbnails); OPT_PTR(thumbnails_color); OPT_PTR(thumbnails_custom_color); + OPT_PTR(thumbnails_end_file); OPT_PTR(thumbnails_with_bed); OPT_PTR(time_estimation_compensation); OPT_PTR(top_fan_speed); diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 66c7b2e7f..a24bdf8aa 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -856,6 +856,7 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector