mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-01-06 06:47:41 -07:00
ENH:support new amsmapping data
jira:[for 2 extruder] Change-Id: Ie03eae17d600bc68451511a0179f20d1919ff6ea (cherry picked from commit 0848c26da97c7b74e98645b9a0873fe928fdf631)
This commit is contained in:
parent
12d5ffb8e5
commit
7fe421b1b3
6 changed files with 74 additions and 24 deletions
|
|
@ -49,6 +49,10 @@ struct FilamentInfo
|
|||
int ctype = 0;
|
||||
std::vector<std::string> colors = std::vector<std::string>();
|
||||
int mapping_result = 0;
|
||||
|
||||
/*for new ams mapping*/
|
||||
std::string ams_id;
|
||||
std::string slot_id;
|
||||
};
|
||||
|
||||
class BBLSliceInfo {
|
||||
|
|
|
|||
|
|
@ -810,6 +810,9 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
// tray_index : tray_color
|
||||
std::map<int, FilamentInfo> tray_filaments;
|
||||
for (auto ams = amsList.begin(); ams != amsList.end(); ams++) {
|
||||
|
||||
std::string ams_id = ams->second->id;
|
||||
|
||||
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());
|
||||
|
|
@ -828,6 +831,11 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
info.filament_id = tray->second->setting_id;
|
||||
info.ctype = tray->second->ctype;
|
||||
info.colors = tray->second->cols;
|
||||
|
||||
/*for new ams mapping*/
|
||||
info.ams_id = ams->first.c_str();
|
||||
info.slot_id = tray->first.c_str();
|
||||
|
||||
tray_filaments.emplace(std::make_pair(tray_index, info));
|
||||
}
|
||||
}
|
||||
|
|
@ -835,27 +843,28 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
|
||||
// tray info list
|
||||
std::vector<FilamentInfo> tray_info_list;
|
||||
for (auto it = amsList.begin(); it != amsList.end(); it++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int flament_index_id = 0;
|
||||
for (auto ams = amsList.begin(); ams != amsList.end(); ams++) {
|
||||
for (auto tray = ams->second->trayList.begin(); tray != ams->second->trayList.end(); tray++) {
|
||||
|
||||
FilamentInfo info;
|
||||
auto tray_it = it->second->trayList.find(std::to_string(i));
|
||||
if (tray_it != it->second->trayList.end()) {
|
||||
info.id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4;
|
||||
info.tray_id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4;
|
||||
info.color = tray_it->second->color;
|
||||
info.type = tray_it->second->get_filament_type();
|
||||
info.ctype = tray_it->second->ctype;
|
||||
info.colors = tray_it->second->cols;
|
||||
}
|
||||
else {
|
||||
info.id = -1;
|
||||
info.tray_id = -1;
|
||||
}
|
||||
info.id = flament_index_id;
|
||||
info.tray_id = flament_index_id;
|
||||
info.color = tray->second->color;
|
||||
info.type = tray->second->get_filament_type();
|
||||
info.ctype = tray->second->ctype;
|
||||
info.colors = tray->second->cols;
|
||||
|
||||
|
||||
/*for new ams mapping*/
|
||||
info.ams_id = ams->second->id;
|
||||
info.slot_id = tray->second->id;
|
||||
|
||||
tray_info_list.push_back(info);
|
||||
flament_index_id++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// is_support_ams_mapping
|
||||
if (!is_support_ams_mapping()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "ams_mapping: do not support, use order mapping";
|
||||
|
|
@ -987,6 +996,11 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
result[picked_src_idx].filament_id = tray->second.filament_id;
|
||||
result[picked_src_idx].ctype = tray->second.ctype;
|
||||
result[picked_src_idx].colors = tray->second.colors;
|
||||
|
||||
|
||||
/*for new ams mapping*/
|
||||
result[picked_src_idx].ams_id = tray->second.ams_id;
|
||||
result[picked_src_idx].slot_id = tray->second.slot_id;
|
||||
}
|
||||
else {
|
||||
FilamentInfo info;
|
||||
|
|
@ -1028,6 +1042,10 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
result[i].type = tray_info_list[i].type;
|
||||
result[i].ctype = tray_info_list[i].ctype;
|
||||
result[i].colors = tray_info_list[i].colors;
|
||||
|
||||
/*for new ams mapping*/
|
||||
result[i].ams_id = tray_info_list[i].ams_id;
|
||||
result[i].slot_id = tray_info_list[i].slot_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ void PrintJob::process(Ctl &ctl)
|
|||
params.task_layer_inspect = this->task_layer_inspect;
|
||||
params.task_record_timelapse= this->task_record_timelapse;
|
||||
params.ams_mapping = this->task_ams_mapping;
|
||||
params.ams_mapping2 = this->task_ams_mapping2;
|
||||
params.ams_mapping_info = this->task_ams_mapping_info;
|
||||
params.connection_type = this->connection_type;
|
||||
params.task_use_ams = this->task_use_ams;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public:
|
|||
std::string m_access_code;
|
||||
std::string task_bed_type;
|
||||
std::string task_ams_mapping;
|
||||
std::string task_ams_mapping2;
|
||||
std::string task_ams_mapping_info;
|
||||
std::string connection_type;
|
||||
std::string m_print_type;
|
||||
|
|
|
|||
|
|
@ -1840,8 +1840,9 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_)
|
|||
if (result == 0) {
|
||||
print_ams_mapping_result(m_ams_mapping_result);
|
||||
std::string ams_array;
|
||||
std::string ams_array2;
|
||||
std::string mapping_info;
|
||||
get_ams_mapping_result(ams_array, mapping_info);
|
||||
get_ams_mapping_result(ams_array, ams_array2, mapping_info);
|
||||
if (ams_array.empty()) {
|
||||
reset_ams_material();
|
||||
BOOST_LOG_TRIVIAL(info) << "ams_mapping_array=[]";
|
||||
|
|
@ -1867,7 +1868,7 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str, std::string &ams_mapping_info)
|
||||
bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str, std::string& mapping_array_str2, std::string &ams_mapping_info)
|
||||
{
|
||||
if (m_ams_mapping_result.empty())
|
||||
return false;
|
||||
|
|
@ -1884,17 +1885,28 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str,
|
|||
if (invalid_count == m_ams_mapping_result.size()) {
|
||||
return false;
|
||||
} else {
|
||||
json j = json::array();
|
||||
json mapping_info_json = json::array();
|
||||
|
||||
json mapping_v0_json = json::array();
|
||||
json mapping_v1_json = json::array();
|
||||
|
||||
json mapping_info_json = json::array();
|
||||
|
||||
for (int i = 0; i < wxGetApp().preset_bundle->filament_presets.size(); i++) {
|
||||
|
||||
int tray_id = -1;
|
||||
|
||||
json mapping_item_v1;
|
||||
mapping_item_v1["ams_id"] = 0xff;
|
||||
mapping_item_v1["slot_id"] = 0xff;
|
||||
|
||||
json mapping_item;
|
||||
mapping_item["ams"] = tray_id;
|
||||
mapping_item["targetColor"] = "";
|
||||
mapping_item["filamentId"] = "";
|
||||
mapping_item["filamentType"] = "";
|
||||
|
||||
|
||||
|
||||
for (int k = 0; k < m_ams_mapping_result.size(); k++) {
|
||||
if (m_ams_mapping_result[k].id == i) {
|
||||
tray_id = m_ams_mapping_result[k].tray_id;
|
||||
|
|
@ -1907,12 +1919,23 @@ bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str,
|
|||
//convert #RRGGBB to RRGGBBAA
|
||||
mapping_item["sourceColor"] = m_filaments[k].color;
|
||||
mapping_item["targetColor"] = m_ams_mapping_result[k].color;
|
||||
|
||||
|
||||
/*new ams mapping data*/
|
||||
|
||||
mapping_item_v1["ams_id"] = m_ams_mapping_result[k].ams_id;
|
||||
mapping_item_v1["slot_id"] = m_ams_mapping_result[k].slot_id;
|
||||
}
|
||||
}
|
||||
j.push_back(tray_id);
|
||||
mapping_v0_json.push_back(tray_id);
|
||||
mapping_v1_json.push_back(mapping_item_v1);
|
||||
mapping_info_json.push_back(mapping_item);
|
||||
}
|
||||
mapping_array_str = j.dump();
|
||||
|
||||
|
||||
mapping_array_str = mapping_v0_json.dump();
|
||||
mapping_array_str2 = mapping_v1_json.dump();
|
||||
|
||||
ams_mapping_info = mapping_info_json.dump();
|
||||
return valid_mapping_result;
|
||||
}
|
||||
|
|
@ -2745,9 +2768,10 @@ void SelectMachineDialog::on_send_print()
|
|||
|
||||
// get ams_mapping_result
|
||||
std::string ams_mapping_array;
|
||||
std::string ams_mapping_array2;
|
||||
std::string ams_mapping_info;
|
||||
if (m_checkbox_list["use_ams"]->GetValue())
|
||||
get_ams_mapping_result(ams_mapping_array, ams_mapping_info);
|
||||
get_ams_mapping_result(ams_mapping_array,ams_mapping_array2, ams_mapping_info);
|
||||
else {
|
||||
json mapping_info_json = json::array();
|
||||
json item;
|
||||
|
|
@ -2840,9 +2864,11 @@ void SelectMachineDialog::on_send_print()
|
|||
|
||||
if (obj_->is_support_ams_mapping()) {
|
||||
m_print_job->task_ams_mapping = ams_mapping_array;
|
||||
m_print_job->task_ams_mapping2= ams_mapping_array2;
|
||||
m_print_job->task_ams_mapping_info = ams_mapping_info;
|
||||
} else {
|
||||
m_print_job->task_ams_mapping = "";
|
||||
m_print_job->task_ams_mapping2 = "";
|
||||
m_print_job->task_ams_mapping_info = "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ public:
|
|||
void set_print_type(PrintFromType type) {m_print_type = type;};
|
||||
bool Show(bool show);
|
||||
bool do_ams_mapping(MachineObject* obj_);
|
||||
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& ams_mapping_info);
|
||||
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& mapping_array_str2, std::string& ams_mapping_info);
|
||||
|
||||
PrintFromType get_print_type() {return m_print_type;};
|
||||
wxString format_steel_name(std::string name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue