ENH: Add parameters for extruder page of printer preset

jira: none
Change-Id: I8eb37e41bdc4b2b1f2328acee324c6fad30e391c
This commit is contained in:
zhimin.zeng 2025-02-08 16:13:45 +08:00 committed by lane.wei
parent 1aad582e08
commit d0f89eb862
3 changed files with 47 additions and 18 deletions

View File

@ -557,13 +557,13 @@ void PrintConfigDef::init_common_params()
def->set_default_value(new ConfigOptionFloat(100.0));
def = this->add("extruder_printable_height", coFloats);
def->label = L("Printable height");
def->tooltip = L("Maximum printable height which is limited by mechanism of printer");
def->label = L("Extruder printable height");
def->tooltip = L("Maximum printable height of the extruder");
def->sidetext = L("mm");
def->min = 0;
def->max = 1000;
def->mode = comSimple;
def->set_default_value(new ConfigOptionFloatsNullable{});
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatsNullable{0});
def = this->add("unprintable_filament_types", coStrings);
def->label = L("Unprintable filament type");
@ -5482,6 +5482,7 @@ std::set<std::string> printer_extruder_options = {
};
std::set<std::string> printer_options_with_variant_1 = {
"nozzle_volume",
"retraction_length",
"z_hop",
"retract_lift_above",

View File

@ -1030,6 +1030,14 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
case coPercents:
case coFloats:
case coFloat: {
if (opt_key == "extruder_printable_height") {
auto opt_values = dynamic_cast<const ConfigOptionFloatsNullable *>(config.option(opt_key))->values;
if (!opt_values.empty()) {
double val = opt_values[idx];
ret = double_to_string(val);
}
}
else {
double val = opt->type == coFloats ?
config.opt_float(opt_key, idx) :
opt->type == coFloat ? config.opt_float(opt_key) :
@ -1037,6 +1045,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
ret = double_to_string(val);
}
break;
}
case coString:
ret = from_u8(config.opt_string(opt_key));
break;
@ -1105,6 +1114,15 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
else
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
break;
case coPointsGroups:
if (opt_key == "extruder_printable_area") {
auto values = config.option<ConfigOptionPointsGroups>(opt_key)->values;
if (!values.empty())
ret = get_thumbnails_string(config.option<ConfigOptionPointsGroups>(opt_key)->get_at(idx));
}
else
ret = config.option<ConfigOptionPointsGroups>(opt_key)->get_at(idx);
break;
case coNone:
default:
break;

View File

@ -3596,7 +3596,6 @@ void TabPrinter::build_fff()
option.opt.full_width = true;
optgroup->append_single_option_line(option);
optgroup->append_single_option_line("printable_height");
optgroup->append_single_option_line("nozzle_volume");
optgroup->append_single_option_line("best_object_pos");
// todo: for multi_extruder test
// BBS
@ -4078,11 +4077,17 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
auto page = add_options_page(page_name, "empty", true);
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
auto optgroup = page->new_optgroup(L("Type"), L"param_type", -1, true);
auto optgroup = page->new_optgroup(L("Basic information"), L"param_type", -1, true);
optgroup->append_single_option_line("extruder_type", "", extruder_idx);
optgroup->append_single_option_line("nozzle_diameter", "", extruder_idx);
//optgroup->append_single_option_line("default_nozzle_volume_type", "", extruder_idx);
optgroup->append_single_option_line("nozzle_volume", "", extruder_idx);
optgroup->append_single_option_line("extruder_printable_height", "", extruder_idx);
Option option = optgroup->get_option("extruder_printable_area", extruder_idx);
option.opt.full_width = true;
optgroup->append_single_option_line(option);
optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value)
{
//if (m_config->opt_bool("single_extruder_multi_material") && m_extruders_count > 1 && opt_key.find("nozzle_diameter") != std::string::npos)
@ -4373,6 +4378,11 @@ void TabPrinter::toggle_options()
toggle_option("nozzle_diameter", !is_BBL_printer || config_mode == ConfigOptionMode::comDevelop, i);
toggle_option("extruder_offset", !is_BBL_printer || config_mode == ConfigOptionMode::comDevelop, i);
toggle_option("extruder_printable_area", false, i); // disable
toggle_line("extruder_printable_area", m_preset_bundle->get_printer_extruder_count() == 2, i); //hide
toggle_option("extruder_printable_height", false, i);
toggle_line("extruder_printable_height", m_preset_bundle->get_printer_extruder_count() == 2, i);
bool use_firmware_retraction = m_config->opt_bool("use_firmware_retraction");
toggle_option("retract_length",!use_firmware_retraction, i);
@ -6111,13 +6121,13 @@ void Tab::switch_excluder(int extruder_id, bool reload)
}
page->m_opt_id_map.clear();
for (auto group : page->m_optgroups) {
if (is_extruder && (group->title == "Type" || group->title == "Layer height limits" || group->title == "Position")) {
for (auto &opt : group->opt_map())
for (auto &opt : group->opt_map()) {
auto iter = std::find(printer_extruder_options.begin(), printer_extruder_options.end(), opt.second.first);
if (iter != printer_extruder_options.end()) {
page->m_opt_id_map.insert({opt.first, opt.first});
continue;
}
group->draw_multi_extruder = false;
for (auto &opt : group->opt_map()) {
if (opt.second.second >= 0) {
const_cast<int &>(opt.second.second) = index;
page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(index), opt.first});