Skip to content

Commit

Permalink
Maybe fix BIQU / BTT_TFT thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Feb 2, 2024
1 parent 46bb95a commit 981b77e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
20 changes: 16 additions & 4 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,16 +1391,28 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene

std::string preamble_to_put_start_layer = "";


// if thumbnail type of BTT_TFT, insert above header
// if not, it is inserted under the header in its normal spot
const ConfigOptionEnum<GCodeThumbnailsFormat>* thumbnails_format = print.full_print_config().option<ConfigOptionEnum<GCodeThumbnailsFormat>>("thumbnails_format");
const ConfigOptionBool* thumbnails_with_bed = print.full_print_config().option<ConfigOptionBool>("thumbnails_with_bed");
if (thumbnails_format != nullptr && thumbnails_format->value == GCodeThumbnailsFormat::BIQU)
GCodeThumbnails::export_thumbnails_to_file(thumbnail_cb,
print.full_print_config().option<ConfigOptionPoints>("thumbnails")->values,
thumbnails_with_bed ? thumbnails_with_bed->value : false,
thumbnails_format->value,
true,
[&file](const char *sz) { file.write(sz); },
[&print]() { print.throw_if_canceled(); });

// Write information on the generator.
file.write_format("; %s\n\n", Slic3r::header_slic3r_generated().c_str());


//print thumbnails at the start unless requested at the end.
const ConfigOptionBool* thumbnails_end_file = print.full_print_config().option<ConfigOptionBool>("thumbnails_end_file");
if(!thumbnails_end_file || !thumbnails_end_file->value) {
const ConfigOptionBool* thumbnails_with_bed = print.full_print_config().option<ConfigOptionBool>("thumbnails_with_bed");
const ConfigOptionBool* thumbnails_tag_with_format = print.full_print_config().option<ConfigOptionBool>("thumbnails_tag_format");
const ConfigOptionEnum<GCodeThumbnailsFormat>* thumbnails_format = print.full_print_config().option<ConfigOptionEnum<GCodeThumbnailsFormat>>("thumbnails_format");
// Unit tests or command line slicing may not define "thumbnails" or "thumbnails_format".
// If "thumbnails_format" is not defined, export to PNG.
GCodeThumbnails::export_thumbnails_to_file(thumbnail_cb,
Expand Down Expand Up @@ -2092,8 +2104,8 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene
}
print.throw_if_canceled();

//print thumbnails at the end instead of the start if requested
if (thumbnails_end_file && thumbnails_end_file->value) {
//print thumbnails at the end instead of the start if requested (unless BTT / biqu thumbnail)
if (thumbnails_end_file && thumbnails_end_file->value && (thumbnails_format == nullptr || thumbnails_format->value != GCodeThumbnailsFormat::BIQU)) {
const ConfigOptionBool* thumbnails_with_bed = print.full_print_config().option<ConfigOptionBool>("thumbnails_with_bed");
const ConfigOptionBool* thumbnails_tag_with_format = print.full_print_config().option<ConfigOptionBool>("thumbnails_tag_format");
const ConfigOptionEnum<GCodeThumbnailsFormat>* thumbnails_format = print.full_print_config().option<ConfigOptionEnum<GCodeThumbnailsFormat>>("thumbnails_format");
Expand Down
7 changes: 4 additions & 3 deletions src/libslic3r/GCode/Thumbnails.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
auto compressed = compress_thumbnail(data, format);
if (compressed->data && compressed->size) {
if (format == GCodeThumbnailsFormat::BIQU) {
output((boost::format("\n;\n; %s begin %dx%d %d\n")
% (with_tag_format ? compressed->tag() : EMPTY_TAG)
% data.width % data.height % (compressed->size - 1)).str().c_str());
// BIQU firmware need to have nothing before the thumbnail
//output((boost::format("\n;\n; %s begin %dx%d %d\n")
// % (with_tag_format ? compressed->tag() : EMPTY_TAG)
// % data.width % data.height % (compressed->size - 1)).str().c_str());
//print size in hex
std::stringstream ss;
ss << std::setfill('0') << std::hex;
Expand Down
5 changes: 5 additions & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3500,6 +3500,11 @@ void TabPrinter::toggle_options()
bool custom_color = m_config->opt_bool("thumbnails_custom_color");
field = get_field("thumbnails_color");
if (field) field->toggle(custom_color);
const ConfigOptionEnum<GCodeThumbnailsFormat>* thumbnails_format = m_config->option<ConfigOptionEnum<GCodeThumbnailsFormat>>("thumbnails_format");
field = get_field("thumbnails_end_file");
if (thumbnails_format && field) field->toggle(thumbnails_format->value != (GCodeThumbnailsFormat::BIQU));
field = get_field("thumbnails_tag_format");
if (thumbnails_format && field) field->toggle(thumbnails_format->value != (GCodeThumbnailsFormat::BIQU));

//firmware
bool have_remaining_times = m_config->opt_bool("remaining_times");
Expand Down

0 comments on commit 981b77e

Please sign in to comment.