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
(cherry picked from commit d27304e5ef2f43424046b1a1fabc8d999508be4e)
This commit is contained in:
xun.zhang
2024-12-23 11:33:09 +08:00
committed by Noisyfox
parent daad39949f
commit 52d18ab03a
3 changed files with 11 additions and 9 deletions

View File

@@ -2883,7 +2883,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
// _set_warning_notification(EWarning::SlaSupportsOutside, false); // _set_warning_notification(EWarning::SlaSupportsOutside, false);
PartPlate* cur_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate(); 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); _set_warning_notification(EWarning::TPUPrintableError, !tpu_valid);
bool model_fits = contained_min_one && !m_model->objects.empty() && !partlyOut && object_results.filaments.empty() && tpu_valid; bool model_fits = contained_min_one && !m_model->objects.empty() && !partlyOut && object_results.filaments.empty() && tpu_valid;

View File

@@ -1699,20 +1699,20 @@ std::vector<int> PartPlate::get_used_extruders()
return std::vector(used_extruders_set.begin(), used_extruders_set.end()); 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; bool tpu_valid = true;
if (!tpu_filaments.empty()) { if (!tpu_filaments.empty()) {
if (tpu_filaments.size() > 1) if (tpu_filaments.size() > 1)
tpu_valid = false; tpu_valid = false;
else if (get_filament_map_mode() == FilamentMapMode::fmmManual) { else if (get_real_filament_map_mode(config) == FilamentMapMode::fmmManual) {
if (config->has("master_extruder_id")) { if (config.has("master_extruder_id")) {
int tpu_filament_id = *tpu_filaments.begin(); 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 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) if (master_extruder_id != extruder_id)
tpu_valid = false; tpu_valid = false;
} }
@@ -3293,8 +3293,10 @@ void PartPlate::set_unprintable_filament_ids(const std::vector<std::vector<int>>
void PartPlate::on_extruder_count_changed(int extruder_count) void PartPlate::on_extruder_count_changed(int extruder_count)
{ {
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values; if (extruder_count < 2) {
std::fill(filament_maps.begin(), filament_maps.end(), 1); // clear filament map and mode in single extruder mode
clear_filament_map_info();
}
} }
void PartPlate::set_filament_count(int filament_count) void PartPlate::set_filament_count(int filament_count)

View File

@@ -325,7 +325,7 @@ public:
std::vector<int> get_extruders_without_support(bool conside_custom_gcode = false) const; std::vector<int> get_extruders_without_support(bool conside_custom_gcode = false) const;
// get used filaments, 1 based idx // get used filaments, 1 based idx
std::vector<int> get_used_extruders(); 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*/ /* instance related operations*/
//judge whether instance is bound in plate or not //judge whether instance is bound in plate or not