FIX: wrong filament map in plate params

1.Always clear filament map when global map mode change if
plate filament map mode is default

jira:NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I38055b7c77668fdb211f6b459be1044d8d3c8f8c
(cherry picked from commit b492ab13a28b25599da9668d84447be260cbbc34)
This commit is contained in:
xun.zhang 2024-12-26 20:40:57 +08:00 committed by lane.wei
parent 3cd587d09e
commit 48c45e06a5
5 changed files with 32 additions and 7 deletions

View File

@ -1635,9 +1635,12 @@ wxBoxSizer* MainFrame::create_side_tools()
} }
if (slice) { if (slice) {
if (m_plater->get_global_filament_map_mode() != g_filament_map_mode)
m_plater->on_filament_map_mode_change();
m_plater->set_global_filament_map_mode(g_filament_map_mode); m_plater->set_global_filament_map_mode(g_filament_map_mode);
if (g_filament_map_mode == FilamentMapMode::fmmManual) if (g_filament_map_mode == FilamentMapMode::fmmManual)
m_plater->set_global_filament_map(g_filament_map); m_plater->set_global_filament_map(g_filament_map);
if (m_slice_select == eSliceAll) if (m_slice_select == eSliceAll)
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SLICE_ALL)); wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SLICE_ALL));
else else

View File

@ -2928,12 +2928,17 @@ void PartPlate::set_filament_maps(const std::vector<int>& f_maps)
m_config.option<ConfigOptionInts>("filament_map", true)->values = f_maps; m_config.option<ConfigOptionInts>("filament_map", true)->values = f_maps;
} }
void PartPlate::clear_filament_map_info() void PartPlate::clear_filament_map()
{ {
if (m_config.has("filament_map")) if (m_config.has("filament_map"))
m_config.erase("filament_map"); m_config.erase("filament_map");
}
void PartPlate::clear_filament_map_mode()
{
if (m_config.has("filament_map_mode")) if (m_config.has("filament_map_mode"))
m_config.erase("filament_map_mode"); m_config.erase("filament_map_mode");
} }
const std::vector<std::vector<int>>& PartPlate::get_unprintable_filament_ids() const std::vector<std::vector<int>>& PartPlate::get_unprintable_filament_ids()
@ -2952,7 +2957,8 @@ void PartPlate::on_extruder_count_changed(int extruder_count)
{ {
if (extruder_count < 2) { if (extruder_count < 2) {
// clear filament map and mode in single extruder mode // clear filament map and mode in single extruder mode
clear_filament_map_info(); clear_filament_map();
clear_filament_map_mode();
} }
} }

View File

@ -238,8 +238,8 @@ public:
std::vector<int> get_filament_maps() const; std::vector<int> get_filament_maps() const;
void set_filament_maps(const std::vector<int>& f_maps); void set_filament_maps(const std::vector<int>& f_maps);
// remove filament map and map mode in profiles void clear_filament_map();
void clear_filament_map_info(); void clear_filament_map_mode();
bool has_spiral_mode_config() const; bool has_spiral_mode_config() const;
bool get_spiral_vase_mode() const; bool get_spiral_vase_mode() const;

View File

@ -14578,6 +14578,17 @@ FilamentMapMode Plater::get_global_filament_map_mode() const
return project_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode")->value; return project_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode")->value;
} }
void Plater::on_filament_map_mode_change()
{
auto& plate_list = this->get_partplate_list();
int plate_count = plate_list.get_plate_count();
for (int idx = 0; idx < plate_count; ++idx) {
auto plate=plate_list.get_plate(idx);
auto plate_map_mode = plate->get_filament_map_mode();
if (plate_map_mode == fmmDefault)
plate->clear_filament_map();
}
}
wxWindow* Plater::get_select_machine_dialog() wxWindow* Plater::get_select_machine_dialog()
{ {
@ -15400,14 +15411,18 @@ void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt)
bool need_invalidate = (old_map_mode != new_map_mode || bool need_invalidate = (old_map_mode != new_map_mode ||
old_filament_maps != new_filament_maps); old_filament_maps != new_filament_maps);
if (old_map_mode != new_map_mode) if (old_map_mode != new_map_mode) {
curr_plate->set_filament_map_mode(new_map_mode); curr_plate->set_filament_map_mode(new_map_mode);
curr_plate->clear_filament_map();
}
if (old_filament_maps != new_filament_maps && new_map_mode==fmmManual) if (old_filament_maps != new_filament_maps && new_map_mode==fmmManual)
curr_plate->set_filament_maps(new_filament_maps); curr_plate->set_filament_maps(new_filament_maps);
if (new_map_mode == fmmDefault) if (new_map_mode == fmmDefault) {
curr_plate->clear_filament_map_info(); curr_plate->clear_filament_map();
curr_plate->clear_filament_map_mode();
}
if (need_invalidate) { if (need_invalidate) {
if (need_slice) { if (need_slice) {

View File

@ -461,6 +461,7 @@ public:
void set_global_filament_map(const std::vector<int>& filament_map); void set_global_filament_map(const std::vector<int>& filament_map);
std::vector<int> get_global_filament_map() const; std::vector<int> get_global_filament_map() const;
FilamentMapMode get_global_filament_map_mode() const; FilamentMapMode get_global_filament_map_mode() const;
void on_filament_map_mode_change();
void update_menus(); void update_menus();
// BBS // BBS