ENH: template filament don't be show in filament list and sort

Jira: 5160 5179

Change-Id: I56a7e1897e1ef3c061dc66d318896413ca25b76b
Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com>
This commit is contained in:
maosheng.wei 2023-11-09 14:30:39 +08:00 committed by Lane.Wei
parent f403ea4f78
commit 461c7072f2
3 changed files with 18 additions and 8 deletions

View File

@ -90,7 +90,7 @@
"PPA-CF"
],
"filament_vendor": [
"Bambu Lab"
"Generic"
],
"filament_wipe": [
"nil"

View File

@ -5104,7 +5104,7 @@ void Plater::priv::reload_from_disk()
#if ENABLE_RELOAD_FROM_DISK_REWORK
// collect selected reloadable ModelVolumes
std::vector<std::pair<int, int>> selected_volumes = reloadable_volumes(model, get_selection());
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " entry, and reloadable volumes number is: " << selected_volumes.size();
// nothing to reload, return
if (selected_volumes.empty())
return;
@ -5501,6 +5501,8 @@ void Plater::priv::reload_from_disk()
for (size_t i = 0; i < model.objects.size(); ++i) {
view3D->get_canvas3d()->update_instance_printable_state_for_object(i);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " finish.";
}
void Plater::priv::reload_all_from_disk()

View File

@ -43,21 +43,29 @@ static wxString update_custom_filaments()
json m_CustomFilaments = json::array();
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
std::map<std::string, std::vector<Preset const *>> temp_filament_id_to_presets = preset_bundle->filaments.get_filament_presets();
json temp_j;
std::vector<std::pair<std::string, std::string>> need_sort;
for (std::pair<std::string, std::vector<Preset const *>> filament_id_to_presets : temp_filament_id_to_presets) {
std::string filament_id = filament_id_to_presets.first;
if (filament_id.empty()) continue;
for (const Preset *preset : filament_id_to_presets.second) {
if (preset->is_system || filament_id.empty() || "null" == filament_id || filament_id.size() != 8 || filament_id[0] != 'P') break;
temp_j["id"] = preset->filament_id;
auto filament_vendor = dynamic_cast<ConfigOptionStrings *> (const_cast<Preset*>(preset)->config.option("filament_vendor",false));
if(filament_vendor&&filament_vendor->values.size()&&filament_vendor->values[0] == "Generic") break;
std::string preset_name = preset->name;
size_t index_at = preset_name.find_last_of('@');
if (std::string::npos != index_at) { preset_name = preset_name.substr(0, index_at - 1); }
temp_j["name"] = preset_name;
m_CustomFilaments.push_back(temp_j);
size_t index_at = preset_name.find(" @");
if (std::string::npos != index_at) { preset_name = preset_name.substr(0, index_at); }
need_sort.push_back(std::make_pair(preset_name, preset->filament_id));
break;
}
}
std::sort(need_sort.begin(), need_sort.end(), [](const std::pair<std::string, std::string> &a, const std::pair<std::string, std::string> &b) { return a.first < b.first; });
json temp_j;
for (std::pair<std::string, std::string> &filament_name_to_id : need_sort) {
temp_j["name"] = filament_name_to_id.first;
temp_j["id"] = filament_name_to_id.second;
m_CustomFilaments.push_back(temp_j);
}
m_Res["data"] = m_CustomFilaments;
wxString strJS = wxString::Format("HandleStudio(%s)", wxString::FromUTF8(m_Res.dump(-1, ' ', false, json::error_handler_t::ignore)));
return strJS;