FIX: update filament map of plate when switching preset

that has different nozzle nums
jira:none

Change-Id: If78571ddf4fa7ac17e7dcf47013075821b8567a6
(cherry picked from commit a6ad5c8be86313085922e3063eec2aba029a5a99)
This commit is contained in:
zhimin.zeng 2024-07-12 17:01:54 +08:00 committed by Noisyfox
parent 0135b251cd
commit d6864a161c
3 changed files with 19 additions and 1 deletions

View file

@ -3198,6 +3198,12 @@ void PartPlate::set_filament_maps(const std::vector<int>& f_maps)
filament_maps = f_maps;
}
void PartPlate::on_extruder_count_changed(int extruder_count)
{
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
std::fill(filament_maps.begin(), filament_maps.end(), 1);
}
void PartPlate::set_filament_count(int filament_count)
{
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
@ -3210,7 +3216,6 @@ void PartPlate::on_filament_added()
filament_maps.push_back(1);
}
void PartPlate::on_filament_deleted(int filament_count, int filament_id)
{
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
@ -5793,6 +5798,14 @@ void PartPlateList::load_cali_textures()
PartPlateList::is_load_cali_texture = true;
}
void PartPlateList::on_extruder_count_changed(int extruder_count)
{
for (unsigned int i = 0; i < (unsigned int) m_plate_list.size(); ++i) {
m_plate_list[i]->on_extruder_count_changed(extruder_count);
}
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: extruder_count=%2%")% __FUNCTION__ %extruder_count;
}
void PartPlateList::set_filament_count(int filament_count)
{
m_filament_count = filament_count;

View file

@ -487,6 +487,7 @@ public:
std::vector<int> get_filament_maps();
void set_filament_maps(const std::vector<int>& f_maps);
void on_extruder_count_changed(int extruder_count);
void set_filament_count(int filament_count);
void on_filament_added();
void on_filament_deleted(int filament_count, int filament_id);
@ -872,6 +873,8 @@ public:
void init_cali_texture_info();
void load_cali_textures();
void on_extruder_count_changed(int extruder_count);
void set_filament_count(int filament_count);
void on_filament_deleted(int filament_count, int filament_id);
void on_filament_added(int filament_count);

View file

@ -4273,6 +4273,8 @@ void TabPrinter::extruders_count_changed(size_t extruders_count)
m_preset_bundle->printers.get_edited_preset().set_num_extruders(extruders_count);
m_preset_bundle->update_multi_material_filament_presets();
is_count_changed = true;
wxGetApp().plater()->get_partplate_list().on_extruder_count_changed((int)m_extruders_count);
}
// Orca: support multi tool
else if (m_extruders_count == 1 &&