FIX: wrong filament map when switch printer preset

1. Clear filament map info in plate when switch to single extruder
profile
2. Use real filament map when check tpu validality

jira:NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I45a3e8c91dd52e7300a563eda3ffb167c19b7074
This commit is contained in:
xun.zhang 2024-12-23 11:33:09 +08:00 committed by lane.wei
parent 5d7f8b1267
commit d27304e5ef
3 changed files with 11 additions and 9 deletions

View File

@ -2950,7 +2950,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
// _set_warning_notification(EWarning::SlaSupportsOutside, false);
PartPlate* cur_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
bool tpu_valid = cur_plate->check_tpu_printable_status(m_config, wxGetApp().preset_bundle->get_used_tpu_filaments(cur_plate->get_extruders(true)));
bool tpu_valid = cur_plate->check_tpu_printable_status(wxGetApp().preset_bundle->full_config(), wxGetApp().preset_bundle->get_used_tpu_filaments(cur_plate->get_extruders(true)));
_set_warning_notification(EWarning::TPUPrintableError, !tpu_valid);
bool model_fits = contained_min_one && !m_model->objects.empty() && !partlyOut && object_results.filaments.empty() && tpu_valid;

View File

@ -1278,20 +1278,20 @@ std::vector<int> PartPlate::get_used_extruders()
return std::vector(used_extruders_set.begin(), used_extruders_set.end());
}
bool PartPlate::check_tpu_printable_status(const DynamicPrintConfig *config, const std::vector<int> &tpu_filaments)
bool PartPlate::check_tpu_printable_status(const DynamicPrintConfig & config, const std::vector<int> &tpu_filaments)
{
bool tpu_valid = true;
if (!tpu_filaments.empty()) {
if (tpu_filaments.size() > 1)
tpu_valid = false;
else if (get_filament_map_mode() == FilamentMapMode::fmmManual) {
if (config->has("master_extruder_id")) {
else if (get_real_filament_map_mode(config) == FilamentMapMode::fmmManual) {
if (config.has("master_extruder_id")) {
int tpu_filament_id = *tpu_filaments.begin();
std::vector<int> filament_map = get_filament_maps();
std::vector<int> filament_map = get_real_filament_maps(config);
int extruder_id = filament_map[tpu_filament_id];
int master_extruder_id = config->opt_int("master_extruder_id"); // base 1
int master_extruder_id = config.opt_int("master_extruder_id"); // base 1
if (master_extruder_id != extruder_id)
tpu_valid = false;
}
@ -2950,8 +2950,10 @@ void PartPlate::set_unprintable_filament_ids(const std::vector<std::vector<int>>
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);
if (extruder_count < 2) {
// clear filament map and mode in single extruder mode
clear_filament_map_info();
}
}
void PartPlate::set_filament_count(int filament_count)

View File

@ -310,7 +310,7 @@ public:
std::vector<int> get_extruders_without_support(bool conside_custom_gcode = false) const;
// get used filaments, 1 based idx
std::vector<int> get_used_extruders();
bool check_tpu_printable_status(const DynamicPrintConfig *config, const std::vector<int> &tpu_filaments);
bool check_tpu_printable_status(const DynamicPrintConfig & config, const std::vector<int> &tpu_filaments);
/* instance related operations*/
//judge whether instance is bound in plate or not