ENH: extruder switch for 'Motion ability'

Change-Id: Ib327b3f4362cafa8f2425785b7184acf27df89a2
Jira: none
This commit is contained in:
chunmao.guo 2024-07-22 16:41:53 +08:00 committed by lane.wei
parent 7280429583
commit f722334f3b
2 changed files with 38 additions and 23 deletions

View File

@ -340,7 +340,7 @@ struct Sidebar::priv
StaticBox* m_panel_filament_title;
wxStaticText* m_staticText_filament_settings;
ScalableButton * m_bpButton_add_filament;
ScalableButton * m_bpButton_del_filament;
//ScalableButton * m_bpButton_del_filament;
ScalableButton * m_bpButton_ams_filament;
ScalableButton * m_bpButton_set_filament;
int m_menu_filament_id = -1;
@ -1656,7 +1656,7 @@ void Sidebar::msw_rescale()
p->m_printer_setting->msw_rescale();
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
//p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();

View File

@ -492,7 +492,7 @@ void Tab::create_preset_tab()
m_main_sizer->Add(m_tabctrl, 0, wxEXPAND | wxALL, 0 );
if (dynamic_cast<TabPrint *>(this)) {
if (dynamic_cast<TabPrinter *>(this) || dynamic_cast<TabPrint *>(this)) {
m_extruder_switch = new SwitchButton(panel);
m_extruder_switch->SetMaxSize({em_unit(this) * 24, -1});
m_extruder_switch->SetLabels(_L("Left"), _L("Right"));
@ -3923,7 +3923,7 @@ PageShp TabPrinter::build_kinematics_page()
}
const std::vector<std::string> axes{ "x", "y", "z", "e" };
optgroup = page->new_optgroup(L("Acceleration limitation"), "param_acceleration");
optgroup = page->new_optgroup(L("Acceleration limitation"), "param_acceleration");
for (const std::string &axis : axes) {
append_option_line(optgroup, "machine_max_acceleration_" + axis);
}
@ -4235,6 +4235,14 @@ void TabPrinter::toggle_options()
if (!m_active_page || m_presets->get_edited_preset().printer_technology() == ptSLA)
return;
auto nozzle_volumes = m_config->option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
auto extruders = m_config->option<ConfigOptionEnumsGeneric>("extruder_type");
auto get_index_for_extruder =
[this, &extruders, &nozzle_volumes](int extruder_id, int stride = 1) {
return m_config->get_index_for_extruder(extruder_id + 1, "printer_extruder_id",
ExtruderType(extruders->values[extruder_id]), NozzleVolumeType(nozzle_volumes->values[extruder_id]), "printer_extruder_variant", stride);
};
auto config_mode = wxGetApp().get_mode();
//BBS: whether the preset is Bambu Lab printer
bool is_BBL_printer = false;
@ -4276,7 +4284,8 @@ void TabPrinter::toggle_options()
val > 0 && (size_t)val <= m_extruders_count))
{
size_t i = size_t(val - 1);
bool have_retract_length = m_config->opt_float("retraction_length", i) > 0;
int variant_index = get_index_for_extruder(i);
bool have_retract_length = m_config->opt_float("retraction_length", variant_index) > 0;
//BBS
for (auto el : { "extruder_type" , "nozzle_diameter"}) {
@ -4336,12 +4345,11 @@ void TabPrinter::toggle_options()
toggle_option("retract_length_toolchange", have_multiple_extruders, i);
bool toolchange_retraction = m_config->opt_float("retract_length_toolchange", i) > 0;
bool toolchange_retraction = m_config->opt_float("retract_length_toolchange", variant_index) > 0;
toggle_option("retract_restart_extra_toolchange", have_multiple_extruders && toolchange_retraction, i);
toggle_option("long_retractions_when_cut", !use_firmware_retraction && m_config->opt_int("enable_long_retraction_when_cut"),i);
toggle_line("retraction_distances_when_cut#0", m_config->opt_bool("long_retractions_when_cut", i));
//toggle_option("retraction_distances_when_cut", m_config->opt_bool("long_retractions_when_cut",i),i);
toggle_option("long_retractions_when_cut", !use_firmware_retraction && m_config->opt_int("enable_long_retraction_when_cut"), i);
toggle_line("retraction_distances_when_cut", m_config->opt_bool("long_retractions_when_cut", variant_index), i);
}
if (m_active_page->title() == "Motion ability") {
@ -5161,7 +5169,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event)
m_parent->set_active_tab(this);
if (m_variant_sizer) {
wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo;
m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty());
m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder "));
GetParent()->Layout();
}
@ -5176,7 +5184,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event)
m_active_page = page;
if (m_variant_sizer) {
wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo;
m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty());
m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder "));
GetParent()->Layout();
}
@ -5847,7 +5855,7 @@ void Tab::update_extruder_variants(int extruder_id, bool reload)
switch_excluder(extruder_id, reload);
if (m_variant_sizer) {
wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo;
m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && m_active_page && !m_active_page->m_opt_id_map.empty());
m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && m_active_page && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder "));
GetParent()->Layout();
}
}
@ -5862,7 +5870,7 @@ void Tab::switch_excluder(int extruder_id, bool reload)
{}, {"", "filament_extruder_variant"}, // Preset::TYPE_FILAMENT filament don't use id anymore
{}, {"printer_extruder_id", "printer_extruder_variant"}, // Preset::TYPE_PRINTER
};
if (m_extruder_switch) {
if (m_extruder_switch && m_type != Preset::TYPE_PRINTER) {
int current_extruder = m_extruder_switch->IsThisEnabled() && m_extruder_switch->GetValue() ? 1 : 0;
m_variant_sizer->Show(2, m_extruder_switch->IsThisEnabled() && extruders->values[0] == extruders->values[1] &&
nozzle_volumes->values[0] == extruders->values[1]);
@ -5879,24 +5887,28 @@ void Tab::switch_excluder(int extruder_id, bool reload)
return;
}
auto get_index_for_extruder =
[this, &extruders, &nozzle_volumes, variant_keys = variant_keys[m_type >= Preset::TYPE_COUNT ? Preset::TYPE_PRINT : m_type]](int extruder_id) {
[this, &extruders, &nozzle_volumes, variant_keys = variant_keys[m_type >= Preset::TYPE_COUNT ? Preset::TYPE_PRINT : m_type]](int extruder_id, int stride = 1) {
return m_config->get_index_for_extruder(extruder_id + 1, variant_keys.first,
ExtruderType(extruders->values[extruder_id]), NozzleVolumeType(nozzle_volumes->values[extruder_id]), variant_keys.second);
ExtruderType(extruders->values[extruder_id]), NozzleVolumeType(nozzle_volumes->values[extruder_id]), variant_keys.second, stride);
};
auto index = m_variant_combo ? extruder_id : get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id);
if (m_extruder_switch) m_extruder_switch->SetClientData((void *) (index));
if (m_variant_combo) m_variant_combo->SetClientData((void *) (index));
for (auto page : m_pages) {
bool is_extruder = false;
page->m_opt_id_map.clear();
if (m_extruder_switch == nullptr && m_variant_combo == nullptr && page->title().StartsWith("Extruder ")) {
int extruder_id2 = std::atoi(page->title().Mid(9).ToUTF8()) - 1;
if (extruder_id >= 0 && extruder_id2 != extruder_id)
continue;
if (extruder_id2 > 0)
index = get_index_for_extruder(extruder_id2);
is_extruder = true;
if (m_type == Preset::TYPE_PRINTER) {
if (page->title().StartsWith("Extruder")) {
int extruder_id2 = std::atoi(page->title().Mid(9).ToUTF8()) - 1;
if (extruder_id >= 0 && extruder_id2 != extruder_id)
continue;
if (extruder_id2 > 0)
index = get_index_for_extruder(extruder_id2);
is_extruder = true;
} else if (page->title().StartsWith("Speed limitation")) {
index = get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id, 2);
}
}
page->m_opt_id_map.clear();
for (auto group : page->m_optgroups) {
if (is_extruder && group->title == "Type") {
for (auto &opt : group->opt_map())
@ -6156,6 +6168,9 @@ Line *Page::get_line(const t_config_option_key &opt_key, int opt_index)
auto iter = m_opt_id_map.find(opt_key + '#' + std::to_string(opt_index - 256));
if (iter != m_opt_id_map.end())
opt_key2 = iter->second;
} else if (opt_index >= 0) {
assert(opt_key.find('#') == std::string::npos);
opt_key2 = opt_key + '#' + std::to_string(opt_index);
}
for (auto opt : m_optgroups) {
line = opt->get_line(opt_key2);