ENH: support thumbnail in gcode for 3rd printers

Thanks @slynn1324
1. Add thumbnail size in printer params page
2. Optimize writing thumbnail data in gcode

jira:STUDIO-3942
Github: #2166
Github pull request: #2333

Change-Id: I6897cfddfa6a1b0c95decf67329a486d40ec0cc2
This commit is contained in:
slynn1324 2023-08-23 17:12:13 +08:00 committed by Lane.Wei
parent d01a94c9f7
commit 105eda5238
11 changed files with 41 additions and 20 deletions

View file

@ -274,7 +274,7 @@ void BackgroundSlicingProcess::process_sla()
//BBS: add plate id for thumbnail generation
ThumbnailsList thumbnails = this->render_thumbnails(
ThumbnailsParams{ THUMBNAIL_SIZE, true, true, true, true, 0 });
ThumbnailsParams{ current_print()->full_print_config().option<ConfigOptionPoints>("thumbnail_size")->values, true, true, true, true, 0 });
Zipper zipper(export_path);
m_sla_archive.export_print(zipper, *m_sla_print); // true, false, true, true); // renders also supports and pad
@ -859,7 +859,7 @@ void BackgroundSlicingProcess::prepare_upload()
} else {
m_upload_job.upload_data.upload_path = m_sla_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());
ThumbnailsList thumbnails = this->render_thumbnails(
ThumbnailsParams{current_print()->full_print_config().option<ConfigOptionPoints>("thumbnails")->values, true, true, true, true});
ThumbnailsParams{current_print()->full_print_config().option<ConfigOptionPoints>("thumbnail_size")->values, true, true, true, true});
// true, false, true, true); // renders also supports and pad
Zipper zipper{source_path.string()};
m_sla_archive.export_print(zipper, *m_sla_print, m_upload_job.upload_data.upload_path.string());

View file

@ -199,7 +199,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
}
break;
case coPoints:{
if (opt_key == "printable_area" || opt_key == "bed_exclude_area") {
if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key=="thumbnail_size") {
config.option<ConfigOptionPoints>(opt_key)->values = boost::any_cast<std::vector<Vec2d>>(value);
break;
}

View file

@ -1036,6 +1036,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
if (opt_key == "printable_area")
ret = config.option<ConfigOptionPoints>(opt_key)->values;
else if (opt_key == "bed_exclude_area")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else if (opt_key == "thumbnail_size")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
@ -1147,6 +1149,8 @@ boost::any ConfigOptionsGroup::get_config_value2(const DynamicPrintConfig& confi
ret = config.option<ConfigOptionPoints>(opt_key)->values;
else if (opt_key == "bed_exclude_area")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else if (opt_key == "thumbnail_size")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
break;

View file

@ -860,7 +860,7 @@ void TabPrinter::init_options_list()
for (const std::string& opt_key : m_config->keys())
{
if (opt_key == "printable_area" || opt_key == "bed_exclude_area") {
if (opt_key == "printable_area" || opt_key == "bed_exclude_area"|| opt_key=="thumbnail_size") {
m_options_list.emplace(opt_key, m_opt_status_value);
continue;
}
@ -3090,6 +3090,11 @@ void TabPrinter::build_fff()
optgroup = page->new_optgroup(L("Advanced"), L"param_advanced");
optgroup->append_single_option_line("printer_structure");
optgroup->append_single_option_line("gcode_flavor");
option =optgroup->get_option("thumbnail_size");
option.opt.full_width=true;
optgroup->append_single_option_line(option);
optgroup->append_single_option_line("scan_first_layer");
optgroup->append_single_option_line("use_relative_e_distances");
// optgroup->append_single_option_line("spaghetti_detector");
@ -3660,6 +3665,7 @@ void TabPrinter::toggle_options()
toggle_option("single_extruder_multi_material", have_multiple_extruders);
//BBS: gcode_flavore of BBL printer can't be edited and changed
toggle_option("gcode_flavor", !is_BBL_printer);
toggle_option("thumbnail_size",!is_BBL_printer);
toggle_option("printer_structure", !is_BBL_printer);
toggle_option("use_relative_e_distances", !is_BBL_printer);

View file

@ -1359,7 +1359,9 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
else if (opt_key == "bed_exclude_area") {
return get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
}
else if (opt_key == "thumbnail_size") {
return get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
}
Vec2d val = config.opt<ConfigOptionPoints>(opt_key)->get_at(opt_idx);
return from_u8((boost::format("[%1%]") % ConfigOptionPoint(val).serialize()).str());
}