ENH:add "nozzle_has_ams_then_ignore_ext" deal
jira: STUDIO-10245 Change-Id: I77e49dcbdfc3acd9473ca3885c6cc7eebdd0d3fa
This commit is contained in:
parent
7a55808ad1
commit
288b1eddc5
|
@ -174,6 +174,8 @@ void AppConfig::set_defaults()
|
|||
set_bool("enable_append_color_by_sync_ams", false);
|
||||
if (get("enable_merge_color_by_sync_ams").empty())
|
||||
set_bool("enable_merge_color_by_sync_ams", true);
|
||||
if (get("ams_sync_match_full_use_color_dist").empty())
|
||||
set_bool("ams_sync_match_full_use_color_dist", false);
|
||||
|
||||
if (get("zoom_to_mouse").empty())
|
||||
set_bool("zoom_to_mouse", false);
|
||||
|
|
|
@ -966,17 +966,17 @@ void MachineObject::parse_tray_info(int ams_id, int slot_id, AmsTray tray, Filam
|
|||
|
||||
}
|
||||
|
||||
int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<bool> map_opt, std::vector<int> exclude_id)
|
||||
int MachineObject::ams_filament_mapping(
|
||||
std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<bool> map_opt, std::vector<int> exclude_id, bool nozzle_has_ams_then_ignore_ext)
|
||||
{
|
||||
if (filaments.empty())
|
||||
return -1;
|
||||
|
||||
// tray_index : tray_color
|
||||
std::map<int, FilamentInfo> tray_filaments;
|
||||
|
||||
bool left_nozzle_has_ams = false, right_nozzle_has_ams = false;
|
||||
for (auto ams = amsList.begin(); ams != amsList.end(); ams++) {
|
||||
std::string ams_id = ams->second->id;
|
||||
FilamentInfo info;
|
||||
for (auto tray = ams->second->trayList.begin(); tray != ams->second->trayList.end(); tray++) {
|
||||
int ams_id = atoi(ams->first.c_str());
|
||||
int tray_id = atoi(tray->first.c_str());
|
||||
|
@ -987,19 +987,38 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
continue;
|
||||
}
|
||||
// push
|
||||
FilamentInfo info;
|
||||
if (tray->second->is_tray_info_ready())
|
||||
parse_tray_info(ams_id, tray_id, *(tray->second), info);
|
||||
|
||||
//first: left,nozzle=1,map=1 second: right,nozzle=0,map=2
|
||||
if ((ams->second->nozzle == 0 && map_opt[MappingOption::USE_RIGHT_AMS]) || (ams->second->nozzle == 1 && map_opt[MappingOption::USE_LEFT_AMS]))
|
||||
bool right_ams_valid = ams->second->nozzle == 0 && map_opt[MappingOption::USE_RIGHT_AMS];
|
||||
bool left_ams_valid = ams->second->nozzle == 1 && map_opt[MappingOption::USE_LEFT_AMS];
|
||||
if (right_ams_valid || left_ams_valid) {
|
||||
tray_filaments.emplace(std::make_pair(tray_index, info));
|
||||
if (right_ams_valid) {
|
||||
right_nozzle_has_ams = true;
|
||||
}
|
||||
if (left_ams_valid) {
|
||||
left_nozzle_has_ams = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (map_opt[MappingOption::USE_RIGHT_EXT] || map_opt[MappingOption::USE_LEFT_EXT]){
|
||||
for (auto tray : vt_slot){
|
||||
if ((tray.id == std::to_string(VIRTUAL_TRAY_MAIN_ID) && map_opt[MappingOption::USE_RIGHT_EXT])
|
||||
|| (tray.id == std::to_string(VIRTUAL_TRAY_DEPUTY_ID) && map_opt[MappingOption::USE_LEFT_EXT])){
|
||||
bool right_ext_valid = (tray.id == std::to_string(VIRTUAL_TRAY_MAIN_ID) && map_opt[MappingOption::USE_RIGHT_EXT]);
|
||||
bool left_ext_valid = (tray.id == std::to_string(VIRTUAL_TRAY_DEPUTY_ID) && map_opt[MappingOption::USE_LEFT_EXT]);
|
||||
if (right_ext_valid || left_ext_valid) {
|
||||
if (nozzle_has_ams_then_ignore_ext) {
|
||||
if (right_ext_valid && right_nozzle_has_ams) {
|
||||
continue;
|
||||
}
|
||||
if (left_ext_valid && left_nozzle_has_ams) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
FilamentInfo info;
|
||||
parse_tray_info(atoi(tray.id.c_str()), 0, tray, info);
|
||||
tray_filaments.emplace(std::make_pair(info.tray_id, info));
|
||||
|
|
|
@ -714,7 +714,7 @@ public:
|
|||
|
||||
void get_ams_colors(std::vector<wxColour>& ams_colors);
|
||||
void parse_tray_info(int ams_id, int sot_id, AmsTray tray, FilamentInfo& result);
|
||||
int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<bool> map_opt, std::vector<int> exclude_id = std::vector<int>());
|
||||
int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<bool> map_opt, std::vector<int> exclude_id = std::vector<int>(),bool nozzle_has_ams_then_ignore_ext =false);
|
||||
bool is_valid_mapping_result(std::vector<FilamentInfo>& result, bool check_empty_slot = false);
|
||||
// exceed index start with 0
|
||||
bool is_mapping_exceed_filament(std::vector<FilamentInfo>& result, int &exceed_index);
|
||||
|
|
|
@ -1585,66 +1585,16 @@ bool SyncAmsInfoDialog::do_ams_mapping(MachineObject *obj_)
|
|||
int filament_result = 0;
|
||||
std::vector<bool> map_opt; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
|
||||
if (nozzle_nums > 1) {
|
||||
// get nozzle property, the extders are same?
|
||||
if (false) {
|
||||
std::vector<FilamentInfo> m_ams_mapping_result_left, m_ams_mapping_result_right;
|
||||
std::vector<FilamentInfo> m_filament_left, m_filament_right;
|
||||
for (auto it = m_filaments.begin(); it != m_filaments.end(); it++) {
|
||||
if (it->id < 0 || it->id > m_filaments_map.size()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "error: do_ams_mapping: m_filaments[].it" << it->id;
|
||||
BOOST_LOG_TRIVIAL(info) << "m_filaments_map.size()" << m_filaments_map.size();
|
||||
return false;
|
||||
}
|
||||
if (m_filaments_map[it->id] == 1)
|
||||
m_filament_left.push_back(*it);
|
||||
else if (m_filaments_map[it->id] == 2)
|
||||
m_filament_right.push_back(*it);
|
||||
}
|
||||
|
||||
bool has_left_ams = false, has_right_ams = false;
|
||||
for (auto ams_item : obj_->amsList) {
|
||||
if (ams_item.second->nozzle == 0) {
|
||||
if (obj_->is_main_extruder_on_left())
|
||||
has_left_ams = true;
|
||||
else
|
||||
has_right_ams = true;
|
||||
} else if (ams_item.second->nozzle == 1) {
|
||||
if (obj_->is_main_extruder_on_left())
|
||||
has_right_ams = true;
|
||||
else
|
||||
has_left_ams = true;
|
||||
}
|
||||
|
||||
if (has_left_ams && has_right_ams) break;
|
||||
}
|
||||
|
||||
map_opt = {true, false, !has_left_ams, false}; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
|
||||
int result_first = obj_->ams_filament_mapping(m_filament_left, m_ams_mapping_result_left, map_opt);
|
||||
map_opt = {false, true, false, !has_right_ams};
|
||||
int result_second = obj_->ams_filament_mapping(m_filament_right, m_ams_mapping_result_right, map_opt);
|
||||
|
||||
// m_ams_mapping_result.clear();
|
||||
m_ams_mapping_result.resize(m_ams_mapping_result_left.size() + m_ams_mapping_result_right.size());
|
||||
std::merge(m_ams_mapping_result_left.begin(), m_ams_mapping_result_left.end(), m_ams_mapping_result_right.begin(), m_ams_mapping_result_right.end(),
|
||||
m_ams_mapping_result.begin(), [](const FilamentInfo &f1, const FilamentInfo &f2) {
|
||||
return f1.id < f2.id; // Merge based on age
|
||||
});
|
||||
filament_result = (result_first && result_second);
|
||||
}
|
||||
// can hybrid mapping
|
||||
else {
|
||||
map_opt = {true, true, true, true}; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
|
||||
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt);
|
||||
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt, std::vector<int>(),
|
||||
wxGetApp().app_config->get_bool("ams_sync_match_full_use_color_dist") ? false : true);
|
||||
}
|
||||
// When filaments cannot be matched automatically, whether to use ext for automatic supply
|
||||
// auto_supply_with_ext(obj_->vt_slot);
|
||||
}
|
||||
|
||||
// single nozzle
|
||||
else {
|
||||
if (obj_->is_support_amx_ext_mix_mapping()) {
|
||||
map_opt = {false, true, false, true}; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
|
||||
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt);
|
||||
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt, std::vector<int>(),
|
||||
wxGetApp().app_config->get_bool("ams_sync_match_full_use_color_dist") ? false : true);
|
||||
// auto_supply_with_ext(obj_->vt_slot);
|
||||
} else {
|
||||
map_opt = {false, true, false, false};
|
||||
|
|
Loading…
Reference in New Issue