Setting to put thumbnails at the end of the gcode file

Note that no firmware/printer support that right now.
This commit is contained in:
supermerill 2021-10-29 15:36:06 +02:00
parent 6ef7acab11
commit 08cd7ebe26
6 changed files with 36 additions and 9 deletions

View File

@ -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

View File

@ -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<ConfigOptionBool>("thumbnails_with_bed");
DoExport::export_thumbnails_to_file(thumbnail_cb,
print.full_print_config().option<ConfigOptionPoints>("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<ConfigOptionBool>("thumbnails_with_bed");
const ConfigOptionBool* thumbnails_end_file = print.full_print_config().option<ConfigOptionBool>("thumbnails_end_file");
if(!thumbnails_end_file || !thumbnails_end_file->value)
DoExport::export_thumbnails_to_file(thumbnail_cb,
print.full_print_config().option<ConfigOptionPoints>("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<ConfigOptionPoints>("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)

View File

@ -757,6 +757,7 @@ const std::vector<std::string>& Preset::printer_options()
"thumbnails",
"thumbnails_color",
"thumbnails_custom_color",
"thumbnails_end_file",
"thumbnails_with_bed",
"wipe_advanced",
"wipe_advanced_nozzle_melted_volume",

View File

@ -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<std::string> 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",

View File

@ -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);

View File

@ -856,6 +856,7 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
"thumbnails",
"thumbnails_color",
"thumbnails_custom_color",
"thumbnails_end_file",
"thumbnails_with_bed",
"thumbnails_with_support"
};