support changing thumbnail size

This commit is contained in:
SoftFever 2022-10-23 23:00:46 +08:00
parent cd71a86d3f
commit e65ba104dd
13 changed files with 50 additions and 13 deletions

View file

@ -5895,6 +5895,9 @@ msgstr "如果机器有辅助部件冷却风扇,勾选该选项"
msgid "G-code flavor" msgid "G-code flavor"
msgstr "G-code风格" msgstr "G-code风格"
msgid "G-code thumbnails"
msgstr "G-code缩略图尺寸"
msgid "What kind of gcode the printer is compatible with" msgid "What kind of gcode the printer is compatible with"
msgstr "打印机兼容的G-code风格'" msgstr "打印机兼容的G-code风格'"

View file

@ -1391,8 +1391,18 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
.c_str()); .c_str());
// BBS: add plate id into thumbnail render logic // BBS: add plate id into thumbnail render logic
// if (const auto [thumbnails, thumbnails_format] = std::make_pair(
// print.full_print_config().option<ConfigOptionPoints>("thumbnails"),
// print.full_print_config().option<ConfigOptionEnum<GCodeThumbnailsFormat>>("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( 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<ConfigOptionPoints>("thumbnails")->values,
[&file](const char *sz) { file.write(sz); }, [&file](const char *sz) { file.write(sz); },
[&print]() { print.throw_if_canceled(); }); [&print]() { print.throw_if_canceled(); });
} }

View file

@ -774,7 +774,7 @@ static std::vector<std::string> s_Preset_printer_options {
"printhost_cafile","printhost_port","printhost_authorization_type", "printhost_cafile","printhost_port","printhost_authorization_type",
"printhost_user", "printhost_user",
"printhost_password", "printhost_password",
"printhost_ssl_ignore_revoke" "printhost_ssl_ignore_revoke", "thumbnails"
}; };
static std::vector<std::string> s_Preset_sla_print_options { static std::vector<std::string> 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) if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
{ {
//BBS: add bed_exclude_area //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, // 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. // thus the vector is presented to the user as a single input.
diff.emplace_back(opt_key); diff.emplace_back(opt_key);

View file

@ -90,7 +90,7 @@ PresetBundle::PresetBundle()
for (size_t i = 0; i < 1; ++i) { 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. // 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); 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) { //if (i == 0) {
preset.config.optptr("default_print_profile", true); preset.config.optptr("default_print_profile", true);
preset.config.option<ConfigOptionStrings>("default_filament_profile", true); preset.config.option<ConfigOptionStrings>("default_filament_profile", true);

View file

@ -134,7 +134,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"wipe_distance", "wipe_distance",
"curr_bed_type", "curr_bed_type",
"nozzle_volume", "nozzle_volume",
"chamber_temperature" "chamber_temperature",
"thumbnails"
}; };
static std::unordered_set<std::string> steps_ignore; static std::unordered_set<std::string> steps_ignore;

View file

@ -2978,6 +2978,13 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0)); 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. // Declare retract values for filament profile, overriding the printer's extruder profile.
for (const char *opt_key : { for (const char *opt_key : {
// floats // floats

View file

@ -802,6 +802,7 @@ PRINT_CONFIG_CLASS_DEFINE(
//BBS //BBS
((ConfigOptionEnum<NozzleType>, nozzle_type)) ((ConfigOptionEnum<NozzleType>, nozzle_type))
((ConfigOptionBool, auxiliary_fan)) ((ConfigOptionBool, auxiliary_fan))
) )
// This object is mapped to Perl as Slic3r::Config::Print. // This object is mapped to Perl as Slic3r::Config::Print.
@ -911,7 +912,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionBool, has_prime_tower)) ((ConfigOptionBool, has_prime_tower))
((ConfigOptionFloat, nozzle_volume)) ((ConfigOptionFloat, nozzle_volume))
((ConfigOptionEnum<TimelapseType>, timelapse_type)) ((ConfigOptionEnum<TimelapseType>, timelapse_type))
((ConfigOptionPoints, thumbnails))
) )
// This object is mapped to Perl as Slic3r::Config::Full. // This object is mapped to Perl as Slic3r::Config::Full.

View file

@ -2394,7 +2394,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
p->load_vendors(); p->load_vendors();
//BBS: add bed exclude areas //BBS: add bed exclude areas
p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({ 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); auto *vsizer = new wxBoxSizer(wxVERTICAL);

View file

@ -197,7 +197,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
} }
break; break;
case coPoints:{ 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<ConfigOptionPoints>(opt_key)->values = boost::any_cast<std::vector<Vec2d>>(value); config.option<ConfigOptionPoints>(opt_key)->values = boost::any_cast<std::vector<Vec2d>>(value);
break; break;
} }

View file

@ -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() || else if (m_opt_map.find(opt_key) == m_opt_map.end() ||
// This option don't have corresponded field // This option don't have corresponded field
opt_key == "printable_area" || 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); value = get_config_value(config, opt_key);
this->change_opt_value(opt_key, value); this->change_opt_value(opt_key, value);
return; return;
@ -950,6 +950,14 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
case coInts: case coInts:
ret = config.option<ConfigOptionIntsNullable>(opt_key)->get_at(idx); ret = config.option<ConfigOptionIntsNullable>(opt_key)->get_at(idx);
break; break;
case coPoints:
if (opt_key == "bed_shape")
ret = config.option<ConfigOptionPoints>(opt_key)->values;
else if (opt_key == "thumbnails")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
break;
default: default:
break; break;
} }
@ -1026,6 +1034,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
if (opt_key == "printable_area") if (opt_key == "printable_area")
ret = config.option<ConfigOptionPoints>(opt_key)->values; ret = config.option<ConfigOptionPoints>(opt_key)->values;
else if (opt_key == "bed_exclude_area") else if (opt_key == "bed_exclude_area")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else if (opt_key == "thumbnails")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else else
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx); ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
@ -1137,6 +1147,8 @@ boost::any ConfigOptionsGroup::get_config_value2(const DynamicPrintConfig& confi
ret = config.option<ConfigOptionPoints>(opt_key)->values; ret = config.option<ConfigOptionPoints>(opt_key)->values;
else if (opt_key == "bed_exclude_area") else if (opt_key == "bed_exclude_area")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else if (opt_key == "thumbnails")
ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values);
else else
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx); ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
break; break;

View file

@ -855,7 +855,7 @@ void TabPrinter::init_options_list()
for (const std::string& opt_key : m_config->keys()) 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); m_options_list.emplace(opt_key, m_opt_status_value);
continue; continue;
} }
@ -2867,6 +2867,9 @@ void TabPrinter::build_fff()
optgroup = page->new_optgroup(L("Advanced"), L"param_advanced"); optgroup = page->new_optgroup(L("Advanced"), L"param_advanced");
optgroup->append_single_option_line("gcode_flavor"); 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("scan_first_layer");
// optgroup->append_single_option_line("spaghetti_detector"); // optgroup->append_single_option_line("spaghetti_detector");
optgroup->append_single_option_line("machine_load_filament_time"); optgroup->append_single_option_line("machine_load_filament_time");
@ -3479,7 +3482,7 @@ void TabPrinter::toggle_options()
} }
auto gcf = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value; auto gcf = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value;
if (m_active_page->title() == "Motion ability") { if (m_active_page->title() == "Motion ability") {
assert(gcf == gcfMarlinLegacy || gcf == gcfMarlinFirmware || gcf == gcfKlipper); assert(gcf == gcfMarlinLegacy || gcf == gcfMarlinFirmware || gcf == gcfKlipper);
bool silent_mode = m_config->opt_bool("silent_mode"); bool silent_mode = m_config->opt_bool("silent_mode");
int max_field = silent_mode ? 2 : 1; int max_field = silent_mode ? 2 : 1;

View file

@ -1315,7 +1315,7 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
} }
case coPoints: { case coPoints: {
//BBS: add bed_exclude_area //BBS: add bed_exclude_area
if (opt_key == "printable_area") { if (opt_key == "printable_area" || opt_key == "thumbnails") {
ConfigOptionPoints points = *config.option<ConfigOptionPoints>(opt_key); ConfigOptionPoints points = *config.option<ConfigOptionPoints>(opt_key);
//BuildVolume build_volume = {points.values, 0.}; //BuildVolume build_volume = {points.values, 0.};
return get_thumbnails_string(points.values); return get_thumbnails_string(points.values);

View file

@ -11,4 +11,4 @@ if(NOT DEFINED BBL_INTERNAL_TESTING)
set(BBL_INTERNAL_TESTING "1") set(BBL_INTERNAL_TESTING "1")
endif() endif()
set(SLIC3R_VERSION "01.03.00.12") set(SLIC3R_VERSION "01.03.00.12")
set(SoftFever_VERSION "1.3.1") set(SoftFever_VERSION "1.3.2-beta")