From e65ba104dd90895bfb5dc7260900053ef1215d4c Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sun, 23 Oct 2022 23:00:46 +0800 Subject: [PATCH] support changing thumbnail size --- bbl/i18n/zh_cn/BambuStudio_zh_CN.po | 3 +++ src/libslic3r/GCode.cpp | 12 +++++++++++- src/libslic3r/Preset.cpp | 4 ++-- src/libslic3r/PresetBundle.cpp | 2 +- src/libslic3r/Print.cpp | 3 ++- src/libslic3r/PrintConfig.cpp | 7 +++++++ src/libslic3r/PrintConfig.hpp | 3 ++- src/slic3r/GUI/ConfigWizard.cpp | 2 +- src/slic3r/GUI/GUI.cpp | 2 +- src/slic3r/GUI/OptionsGroup.cpp | 14 +++++++++++++- src/slic3r/GUI/Tab.cpp | 7 +++++-- src/slic3r/GUI/UnsavedChangesDialog.cpp | 2 +- version.inc | 2 +- 13 files changed, 50 insertions(+), 13 deletions(-) diff --git a/bbl/i18n/zh_cn/BambuStudio_zh_CN.po b/bbl/i18n/zh_cn/BambuStudio_zh_CN.po index 5c09a7e478..8d76c1ac1d 100644 --- a/bbl/i18n/zh_cn/BambuStudio_zh_CN.po +++ b/bbl/i18n/zh_cn/BambuStudio_zh_CN.po @@ -5895,6 +5895,9 @@ msgstr "如果机器有辅助部件冷却风扇,勾选该选项" msgid "G-code flavor" msgstr "G-code风格" +msgid "G-code thumbnails" +msgstr "G-code缩略图尺寸" + msgid "What kind of gcode the printer is compatible with" msgstr "打印机兼容的G-code风格'" diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index a2de3148b1..38aafb727d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1391,8 +1391,18 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato .c_str()); // BBS: add plate id into thumbnail render logic + // if (const auto [thumbnails, thumbnails_format] = std::make_pair( + // print.full_print_config().option("thumbnails"), + // print.full_print_config().option>("thumbnails_format")); + // thumbnails) + // GCodeThumbnails::export_thumbnails_to_file( + // thumbnail_cb, thumbnails->values, thumbnails_format ? thumbnails_format->value : GCodeThumbnailsFormat::PNG, + // [&file](const char* sz) { file.write(sz); }, + // [&print]() { print.throw_if_canceled(); }); + + DoExport::export_thumbnails_to_file( - thumbnail_cb, print.get_plate_index(), {Vec2d(300, 300)}, + thumbnail_cb, print.get_plate_index(), print.full_print_config().option("thumbnails")->values, [&file](const char *sz) { file.write(sz); }, [&print]() { print.throw_if_canceled(); }); } diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index a07163fade..62e368ec4f 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -774,7 +774,7 @@ static std::vector s_Preset_printer_options { "printhost_cafile","printhost_port","printhost_authorization_type", "printhost_user", "printhost_password", - "printhost_ssl_ignore_revoke" + "printhost_ssl_ignore_revoke", "thumbnails" }; static std::vector s_Preset_sla_print_options { @@ -2269,7 +2269,7 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt) { //BBS: add bed_exclude_area - if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key == "compatible_prints" || opt_key == "compatible_printers") { + if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key == "compatible_prints" || opt_key == "compatible_printers" || opt_key == "thumbnails") { // Scalar variable, or a vector variable, which is independent from number of extruders, // thus the vector is presented to the user as a single input. diff.emplace_back(opt_key); diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index c48cfc7426..e2aa72b607 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -90,7 +90,7 @@ PresetBundle::PresetBundle() for (size_t i = 0; i < 1; ++i) { // The following ugly switch is to avoid printers.preset(0) to return the edited instance, as the 0th default is the current one. Preset &preset = this->printers.default_preset(i); - for (const char *key : {"printer_settings_id", "printer_model", "printer_variant"}) preset.config.optptr(key, true); + for (const char *key : {"printer_settings_id", "printer_model", "printer_variant", "thumbnails"}) preset.config.optptr(key, true); //if (i == 0) { preset.config.optptr("default_print_profile", true); preset.config.option("default_filament_profile", true); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index be3ac78096..6322d9b91b 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -134,7 +134,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "wipe_distance", "curr_bed_type", "nozzle_volume", - "chamber_temperature" + "chamber_temperature", + "thumbnails" }; static std::unordered_set steps_ignore; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 10863f421c..823f873c07 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2978,6 +2978,13 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("thumbnails", coPoints); + def->label = L("G-code thumbnails"); + def->tooltip = L("Picture sizes to be stored into a .gcode and .sl1 / .sl1s files, in the following format: \"XxY, XxY, ...\""); + def->mode = comAdvanced; + def->gui_type = ConfigOptionDef::GUIType::one_string; + def->set_default_value(new ConfigOptionPoints{Vec2d(300, 300)}); + // Declare retract values for filament profile, overriding the printer's extruder profile. for (const char *opt_key : { // floats diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index a469637b4e..18e3821c26 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -802,6 +802,7 @@ PRINT_CONFIG_CLASS_DEFINE( //BBS ((ConfigOptionEnum, nozzle_type)) ((ConfigOptionBool, auxiliary_fan)) + ) // This object is mapped to Perl as Slic3r::Config::Print. @@ -911,7 +912,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionBool, has_prime_tower)) ((ConfigOptionFloat, nozzle_volume)) ((ConfigOptionEnum, timelapse_type)) - + ((ConfigOptionPoints, thumbnails)) ) // This object is mapped to Perl as Slic3r::Config::Full. diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 568edd53e6..1b4c09136b 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -2394,7 +2394,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent) p->load_vendors(); //BBS: add bed exclude areas p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({ - "gcode_flavor", "printable_area", "bed_exclude_area", "filament_diameter", "nozzle_temperature", /*"bed_temperature",*/ + "gcode_flavor", "printable_area", "bed_exclude_area", "filament_diameter", "nozzle_temperature", "thumbnails"/*"bed_temperature",*/ })); auto *vsizer = new wxBoxSizer(wxVERTICAL); diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 4c302392b2..1d9fa035da 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -197,7 +197,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 == "thumbnails") { config.option(opt_key)->values = boost::any_cast>(value); break; } diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 8bd9a4d3b4..46f880c3ae 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -670,7 +670,7 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, else if (m_opt_map.find(opt_key) == m_opt_map.end() || // This option don't have corresponded field opt_key == "printable_area" || - opt_key == "compatible_printers" || opt_key == "compatible_prints" ) { + opt_key == "compatible_printers" || opt_key == "compatible_prints" || opt_key == "thumbnails" ) { value = get_config_value(config, opt_key); this->change_opt_value(opt_key, value); return; @@ -950,6 +950,14 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config case coInts: ret = config.option(opt_key)->get_at(idx); break; + case coPoints: + if (opt_key == "bed_shape") + ret = config.option(opt_key)->values; + else if (opt_key == "thumbnails") + ret = get_thumbnails_string(config.option(opt_key)->values); + else + ret = config.option(opt_key)->get_at(idx); + break; default: break; } @@ -1026,6 +1034,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config if (opt_key == "printable_area") ret = config.option(opt_key)->values; else if (opt_key == "bed_exclude_area") + ret = get_thumbnails_string(config.option(opt_key)->values); + else if (opt_key == "thumbnails") ret = get_thumbnails_string(config.option(opt_key)->values); else ret = config.option(opt_key)->get_at(idx); @@ -1137,6 +1147,8 @@ boost::any ConfigOptionsGroup::get_config_value2(const DynamicPrintConfig& confi ret = config.option(opt_key)->values; else if (opt_key == "bed_exclude_area") ret = get_thumbnails_string(config.option(opt_key)->values); + else if (opt_key == "thumbnails") + ret = get_thumbnails_string(config.option(opt_key)->values); else ret = config.option(opt_key)->get_at(idx); break; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index f9fcf2a548..03ce11fa9e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -855,7 +855,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 == "thumbnails") { m_options_list.emplace(opt_key, m_opt_status_value); continue; } @@ -2867,6 +2867,9 @@ void TabPrinter::build_fff() optgroup = page->new_optgroup(L("Advanced"), L"param_advanced"); optgroup->append_single_option_line("gcode_flavor"); + option = optgroup->get_option("thumbnails"); + option.opt.full_width = true; + optgroup->append_single_option_line(option); optgroup->append_single_option_line("scan_first_layer"); // optgroup->append_single_option_line("spaghetti_detector"); optgroup->append_single_option_line("machine_load_filament_time"); @@ -3479,7 +3482,7 @@ void TabPrinter::toggle_options() } auto gcf = m_config->option>("gcode_flavor")->value; - if (m_active_page->title() == "Motion ability") { + if (m_active_page->title() == "Motion ability") { assert(gcf == gcfMarlinLegacy || gcf == gcfMarlinFirmware || gcf == gcfKlipper); bool silent_mode = m_config->opt_bool("silent_mode"); int max_field = silent_mode ? 2 : 1; diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 9afc212a4e..b72591a3e8 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -1315,7 +1315,7 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& } case coPoints: { //BBS: add bed_exclude_area - if (opt_key == "printable_area") { + if (opt_key == "printable_area" || opt_key == "thumbnails") { ConfigOptionPoints points = *config.option(opt_key); //BuildVolume build_volume = {points.values, 0.}; return get_thumbnails_string(points.values); diff --git a/version.inc b/version.inc index 57c34f75e1..fe04c4d142 100644 --- a/version.inc +++ b/version.inc @@ -11,4 +11,4 @@ if(NOT DEFINED BBL_INTERNAL_TESTING) set(BBL_INTERNAL_TESTING "1") endif() set(SLIC3R_VERSION "01.03.00.12") -set(SoftFever_VERSION "1.3.1") +set(SoftFever_VERSION "1.3.2-beta")