FIX: seprate filament_type and display_filament_type
special case for "Support G" and "Support W" Change-Id: I26f873083d6afb58fb10ebc9beef54fbf5e18320 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
b4c7d5b65b
commit
ea7aaf7a8d
|
@ -637,9 +637,9 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
|
|||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": name %1%, is_visible set to %2%")%name % is_visible;
|
||||
}
|
||||
|
||||
std::string Preset::get_filament_type()
|
||||
std::string Preset::get_filament_type(std::string &display_filament_type)
|
||||
{
|
||||
return config.get_filament_type();
|
||||
return config.get_filament_type(display_filament_type);
|
||||
}
|
||||
|
||||
static std::vector<std::string> s_Preset_print_options {
|
||||
|
|
|
@ -295,7 +295,7 @@ public:
|
|||
bool operator<(const Preset &other) const { return this->name < other.name; }
|
||||
|
||||
// special for upport G and Support W
|
||||
std::string get_filament_type();
|
||||
std::string get_filament_type(std::string &display_filament_type);
|
||||
|
||||
static const std::vector<std::string>& print_options();
|
||||
static const std::vector<std::string>& filament_options();
|
||||
|
|
|
@ -3587,7 +3587,7 @@ std::string DynamicPrintConfig::validate()
|
|||
}
|
||||
}
|
||||
|
||||
std::string DynamicPrintConfig::get_filament_type(int id)
|
||||
std::string DynamicPrintConfig::get_filament_type(std::string &displayed_filament_type, int id)
|
||||
{
|
||||
auto* filament_id = dynamic_cast<const ConfigOptionStrings*>(this->option("filament_id"));
|
||||
auto* filament_type = dynamic_cast<const ConfigOptionStrings*>(this->option("filament_type"));
|
||||
|
@ -3598,9 +3598,11 @@ std::string DynamicPrintConfig::get_filament_type(int id)
|
|||
|
||||
if (!filament_is_support) {
|
||||
if (filament_type) {
|
||||
displayed_filament_type = filament_type->get_at(id);
|
||||
return filament_type->get_at(id);
|
||||
}
|
||||
else {
|
||||
displayed_filament_type = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -3609,25 +3611,33 @@ std::string DynamicPrintConfig::get_filament_type(int id)
|
|||
if (is_support) {
|
||||
if (filament_id) {
|
||||
if (filament_id->get_at(id) == "GFS00") {
|
||||
return "Support W";
|
||||
displayed_filament_type = "Support W";
|
||||
return "PLA-S";
|
||||
}
|
||||
else if (filament_id->get_at(id) == "GFS01") {
|
||||
return "Support G";
|
||||
displayed_filament_type = "Support G";
|
||||
return "PA-S";
|
||||
}
|
||||
else {
|
||||
displayed_filament_type = filament_type->get_at(id);
|
||||
return filament_type->get_at(id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (filament_type->get_at(id) == "PLA")
|
||||
return "Support W";
|
||||
else if (filament_type->get_at(id) == "PA")
|
||||
return "Support G";
|
||||
else
|
||||
if (filament_type->get_at(id) == "PLA") {
|
||||
displayed_filament_type = "Support W";
|
||||
return "PLA-S";
|
||||
} else if (filament_type->get_at(id) == "PA") {
|
||||
displayed_filament_type = "Support G";
|
||||
return "PA-S";
|
||||
} else {
|
||||
displayed_filament_type = filament_type->get_at(id);
|
||||
return filament_type->get_at(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
displayed_filament_type = filament_type->get_at(id);
|
||||
return filament_type->get_at(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,7 +325,7 @@ public:
|
|||
{ PrintConfigDef::handle_legacy(opt_key, value); }
|
||||
|
||||
//BBS special case Support G/ Support W
|
||||
std::string get_filament_type(int id = 0);
|
||||
std::string get_filament_type(std::string &displayed_filament_type, int id = 0);
|
||||
};
|
||||
|
||||
void handle_legacy_sla(DynamicPrintConfig &config);
|
||||
|
|
|
@ -508,7 +508,8 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||
if (opt_type_strs) {
|
||||
found_filament_type = true;
|
||||
//m_filament_type = opt_type_strs->get_at(0);
|
||||
m_filament_type = it->config.get_filament_type();
|
||||
std::string display_filament_type;
|
||||
m_filament_type = it->config.get_filament_type(display_filament_type);
|
||||
}
|
||||
}
|
||||
if (!found_filament_type)
|
||||
|
|
|
@ -275,7 +275,7 @@ void AmsMapingPopup::on_left_down(wxMouseEvent &evt)
|
|||
auto left = item->GetSize();
|
||||
|
||||
if (pos.x > p_rect.x && pos.y > p_rect.y && pos.x < (p_rect.x + item->GetSize().x) && pos.y < (p_rect.y + item->GetSize().y)) {
|
||||
if (item->m_tray_data.type == TrayType::NORMAL && !is_match_material(item->m_tray_data.name)) return;
|
||||
if (item->m_tray_data.type == TrayType::NORMAL && !is_match_material(item->m_tray_data.filament_type)) return;
|
||||
item->send_event(m_current_filament_id);
|
||||
Dismiss();
|
||||
}
|
||||
|
@ -318,7 +318,8 @@ void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList)
|
|||
} else {
|
||||
td.type = NORMAL;
|
||||
td.colour = AmsTray::decode_color(tray_data->color);
|
||||
td.name = tray_data->type;
|
||||
td.name = tray_data->get_display_filament_type();
|
||||
td.filament_type = tray_data->get_filament_type();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,7 +357,7 @@ void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data)
|
|||
m_mapping_item_list.push_back(m_filament_name);
|
||||
|
||||
if (tray_data[i].type == NORMAL) {
|
||||
if (is_match_material(tray_data[i].name)) {
|
||||
if (is_match_material(tray_data[i].filament_type)) {
|
||||
m_filament_name->set_data(tray_data[i].colour, tray_data[i].name, tray_data[i]);
|
||||
} else {
|
||||
m_filament_name->set_data(wxColour(0xEE,0xEE,0xEE), tray_data[i].name, tray_data[i], true);
|
||||
|
@ -364,7 +365,7 @@ void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data)
|
|||
}
|
||||
|
||||
m_filament_name->Bind(wxEVT_LEFT_DOWN, [this, tray_data, i, m_filament_name](wxMouseEvent &e) {
|
||||
if (!is_match_material(tray_data[i].name)) return;
|
||||
if (!is_match_material(tray_data[i].filament_type)) return;
|
||||
m_filament_name->send_event(m_current_filament_id);
|
||||
Dismiss();
|
||||
});
|
||||
|
|
|
@ -54,6 +54,7 @@ struct TrayData
|
|||
TrayType type;
|
||||
int id;
|
||||
std::string name;
|
||||
std::string filament_type;
|
||||
wxColour colour;
|
||||
};
|
||||
|
||||
|
|
|
@ -158,6 +158,29 @@ bool AmsTray::is_unset_third_filament()
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string AmsTray::get_display_filament_type()
|
||||
{
|
||||
if (type == "PLA-S")
|
||||
return "Support W";
|
||||
else if (type == "PA-S")
|
||||
return "Support G";
|
||||
else
|
||||
return type;
|
||||
return type;
|
||||
}
|
||||
|
||||
std::string AmsTray::get_filament_type()
|
||||
{
|
||||
if (type == "Support W") {
|
||||
return "PLA-S";
|
||||
} else if (type == "Support G") {
|
||||
return "PA-S";
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
bool HMSItem::parse_hms_info(unsigned attr, unsigned code)
|
||||
{
|
||||
bool result = true;
|
||||
|
@ -632,7 +655,7 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
if (tray->second->is_tray_info_ready()) {
|
||||
FilamentInfo info;
|
||||
info.color = tray->second->color;
|
||||
info.type = tray->second->type;
|
||||
info.type = tray->second->get_filament_type();
|
||||
info.id = tray_index;
|
||||
tray_filaments.emplace(std::make_pair(tray_index, info));
|
||||
}
|
||||
|
@ -649,7 +672,7 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
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->type;
|
||||
info.type = tray_it->second->get_filament_type();
|
||||
}
|
||||
else {
|
||||
info.id = -1;
|
||||
|
@ -678,9 +701,9 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
if (!tray_it->second->is_exists || tray_it->second->is_unset_third_filament()) {
|
||||
;
|
||||
} else {
|
||||
if (filaments[i].type == tray_it->second->type) {
|
||||
if (filaments[i].type == tray_it->second->get_filament_type()) {
|
||||
info.color = tray_it->second->color;
|
||||
info.type = tray_it->second->type;
|
||||
info.type = tray_it->second->get_filament_type();
|
||||
} else {
|
||||
info.tray_id = -1;
|
||||
info.mapping_result = (int)MappingResult::MAPPING_RESULT_TYPE_MISMATCH;
|
||||
|
@ -2228,13 +2251,7 @@ int MachineObject::parse_json(std::string payload)
|
|||
if (tray_it->contains("tray_info_idx") && tray_it->contains("tray_type")) {
|
||||
curr_tray->setting_id = (*tray_it)["tray_info_idx"].get<std::string>();
|
||||
std::string type = (*tray_it)["tray_type"].get<std::string>();
|
||||
if (curr_tray->setting_id == "GFS00") {
|
||||
curr_tray->type = "Support W";
|
||||
} else if (curr_tray->setting_id == "GFS01") {
|
||||
curr_tray->type = "Support G";
|
||||
} else {
|
||||
curr_tray->type = type;
|
||||
}
|
||||
curr_tray->type = type;
|
||||
} else {
|
||||
curr_tray->setting_id = "";
|
||||
curr_tray->type = "";
|
||||
|
|
|
@ -167,6 +167,8 @@ public:
|
|||
|
||||
bool is_tray_info_ready();
|
||||
bool is_unset_third_filament();
|
||||
std::string get_display_filament_type();
|
||||
std::string get_filament_type();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -6454,7 +6454,9 @@ void GLCanvas3D::_render_paint_toolbar() const
|
|||
for (auto filament_name : preset_bundle->filament_presets) {
|
||||
for (auto iter = preset_bundle->filaments.lbegin(); iter != preset_bundle->filaments.end(); iter++) {
|
||||
if (filament_name.compare(iter->name) == 0) {
|
||||
filament_types.push_back(iter->config.get_filament_type());
|
||||
std::string display_filament_type;
|
||||
iter->config.get_filament_type(display_filament_type);
|
||||
filament_types.push_back(display_filament_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8205,7 +8205,8 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
|
|||
for (int i = 0; i < plate_data_list.size(); i++) {
|
||||
PlateData *plate_data = plate_data_list[i];
|
||||
for (auto it = plate_data->slice_filaments_info.begin(); it != plate_data->slice_filaments_info.end(); it++) {
|
||||
it->type = cfg.get_filament_type(it->id);
|
||||
std::string display_filament_type;
|
||||
it->type = cfg.get_filament_type(display_filament_type, it->id);
|
||||
it->color = filament_color ? filament_color->get_at(it->id) : "#FFFFFF";
|
||||
// save filament info used in curr plate
|
||||
int index = p->partplate_list.get_curr_plate_index();
|
||||
|
|
|
@ -1994,12 +1994,16 @@ void SelectMachineDialog::set_default()
|
|||
//sizer_thumbnail->Layout();
|
||||
|
||||
std::vector<std::string> materials;
|
||||
std::vector<std::string> display_materials;
|
||||
{
|
||||
auto preset_bundle = wxGetApp().preset_bundle;
|
||||
for (auto filament_name : preset_bundle->filament_presets) {
|
||||
for (auto iter = preset_bundle->filaments.lbegin(); iter != preset_bundle->filaments.end(); iter++) {
|
||||
if (filament_name.compare(iter->name) == 0) {
|
||||
materials.push_back(iter->config.get_filament_type());
|
||||
std::string display_filament_type;
|
||||
std::string filament_type = iter->config.get_filament_type(display_filament_type);
|
||||
display_materials.push_back(display_filament_type);
|
||||
materials.push_back(filament_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2030,9 +2034,9 @@ void SelectMachineDialog::set_default()
|
|||
bmcache.parse_color(colour, rgb);
|
||||
|
||||
auto colour_rgb = wxColour((int) rgb[0], (int) rgb[1], (int) rgb[2]);
|
||||
if (extruder >= materials.size() || extruder < 0)
|
||||
if (extruder >= materials.size() || extruder < 0 || extruder >= display_materials.size())
|
||||
continue;
|
||||
MaterialItem *item = new MaterialItem(this, colour_rgb, _L(materials[extruder]));
|
||||
MaterialItem *item = new MaterialItem(this, colour_rgb, _L(display_materials[extruder]));
|
||||
m_sizer_material->Add(item, 0, wxALL, FromDIP(4));
|
||||
|
||||
item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) {
|
||||
|
|
|
@ -64,7 +64,7 @@ bool AMSinfo::parse_ams_info(Ams *ams)
|
|||
if (it != ams->trayList.end() && it->second->is_exists) {
|
||||
if (it->second->is_tray_info_ready()) {
|
||||
info.can_id = it->second->id;
|
||||
info.material_name = it->second->type;
|
||||
info.material_name = it->second->get_display_filament_type();
|
||||
if (!it->second->color.empty()) {
|
||||
info.material_colour = AmsTray::decode_color(it->second->color);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue