FIX: fix the label switch incorrect issue when print_sequence change

1. only turn on label while switch from by_layer to by_object
2. don't crash when filament_colours mismatch between project_config and PresetBundle

Change-Id: Icac9d0d7f88e17fcad3b042ea19cda3ac23ae62c
This commit is contained in:
lane.wei 2022-10-31 21:22:03 +08:00 committed by Lane.Wei
parent 082c695db1
commit 8df60acc61
2 changed files with 9 additions and 2 deletions

View file

@ -1333,7 +1333,7 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
menu->Destroy(item_id); menu->Destroy(item_id);
} }
const int filaments_cnt = filaments_count(); int filaments_cnt = filaments_count();
if (filaments_cnt <= 1) if (filaments_cnt <= 1)
return; return;
@ -1345,6 +1345,10 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
std::vector<wxBitmap*> icons = get_extruder_color_icons(true); std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
if (icons.size() < filaments_cnt) { if (icons.size() < filaments_cnt) {
BOOST_LOG_TRIVIAL(warning) << boost::format("Warning: icons size %1%, filaments_cnt=%2%")%icons.size()%filaments_cnt; BOOST_LOG_TRIVIAL(warning) << boost::format("Warning: icons size %1%, filaments_cnt=%2%")%icons.size()%filaments_cnt;
if (icons.size() <= 1)
return;
else
filaments_cnt = icons.size();
} }
wxMenu* extruder_selection_menu = new wxMenu(); wxMenu* extruder_selection_menu = new wxMenu();
const wxString& name = sels.Count() == 1 ? names[0] : names[1]; const wxString& name = sels.Count() == 1 ? names[0] : names[1];

View file

@ -9296,6 +9296,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
{ {
bool update_scheduled = false; bool update_scheduled = false;
bool bed_shape_changed = false; bool bed_shape_changed = false;
bool print_sequence_changed = false;
t_config_option_keys diff_keys = p->config->diff(config); t_config_option_keys diff_keys = p->config->diff(config);
for (auto opt_key : diff_keys) { for (auto opt_key : diff_keys) {
if (opt_key == "filament_colour") { if (opt_key == "filament_colour") {
@ -9346,6 +9347,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
} }
else if (opt_key == "print_sequence") { else if (opt_key == "print_sequence") {
update_scheduled = true; update_scheduled = true;
print_sequence_changed = true;
} }
else if (opt_key == "printer_model") { else if (opt_key == "printer_model") {
p->reset_gcode_toolpaths(); p->reset_gcode_toolpaths();
@ -9371,6 +9373,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
std::string info_text = L("Print By Object: \nSuggest to use auto-arrange to avoid collisions when printing."); std::string info_text = L("Print By Object: \nSuggest to use auto-arrange to avoid collisions when printing.");
notify_manager->bbl_show_seqprintinfo_notification(info_text); notify_manager->bbl_show_seqprintinfo_notification(info_text);
//always show label when switch to sequence print //always show label when switch to sequence print
if (print_sequence_changed)
this->show_view3D_labels(true); this->show_view3D_labels(true);
} }
else else