From d0f89eb8628b4225fc2c6a7b9f2a2eb49bb4f05a Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Sat, 8 Feb 2025 16:13:45 +0800 Subject: [PATCH] ENH: Add parameters for extruder page of printer preset jira: none Change-Id: I8eb37e41bdc4b2b1f2328acee324c6fad30e391c --- src/libslic3r/PrintConfig.cpp | 9 +++++---- src/slic3r/GUI/OptionsGroup.cpp | 30 ++++++++++++++++++++++++------ src/slic3r/GUI/Tab.cpp | 26 ++++++++++++++++++-------- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b9c6533b8..018872c94 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -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 printer_extruder_options = { }; std::set printer_options_with_variant_1 = { + "nozzle_volume", "retraction_length", "z_hop", "retract_lift_above", diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 8bd4a2318..973903784 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -1030,13 +1030,22 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config case coPercents: case coFloats: case coFloat: { - double val = opt->type == coFloats ? - config.opt_float(opt_key, idx) : - opt->type == coFloat ? config.opt_float(opt_key) : - config.option(opt_key)->get_at(idx); - ret = double_to_string(val); + if (opt_key == "extruder_printable_height") { + auto opt_values = dynamic_cast(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) : + config.option(opt_key)->get_at(idx); + ret = double_to_string(val); + } + break; } - 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(opt_key)->get_at(idx); break; + case coPointsGroups: + if (opt_key == "extruder_printable_area") { + auto values = config.option(opt_key)->values; + if (!values.empty()) + ret = get_thumbnails_string(config.option(opt_key)->get_at(idx)); + } + else + ret = config.option(opt_key)->get_at(idx); + break; case coNone: default: break; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 1d9974be8..1b73bd872 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -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()) - page->m_opt_id_map.insert({opt.first, opt.first}); - continue; - } - group->draw_multi_extruder = false; 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; + } + if (opt.second.second >= 0) { const_cast(opt.second.second) = index; page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(index), opt.first});