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:
parent
f403ea4f78
commit
461c7072f2
|
@ -90,7 +90,7 @@
|
||||||
"PPA-CF"
|
"PPA-CF"
|
||||||
],
|
],
|
||||||
"filament_vendor": [
|
"filament_vendor": [
|
||||||
"Bambu Lab"
|
"Generic"
|
||||||
],
|
],
|
||||||
"filament_wipe": [
|
"filament_wipe": [
|
||||||
"nil"
|
"nil"
|
||||||
|
|
|
@ -5104,7 +5104,7 @@ void Plater::priv::reload_from_disk()
|
||||||
#if ENABLE_RELOAD_FROM_DISK_REWORK
|
#if ENABLE_RELOAD_FROM_DISK_REWORK
|
||||||
// collect selected reloadable ModelVolumes
|
// collect selected reloadable ModelVolumes
|
||||||
std::vector<std::pair<int, int>> selected_volumes = reloadable_volumes(model, get_selection());
|
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
|
// nothing to reload, return
|
||||||
if (selected_volumes.empty())
|
if (selected_volumes.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -5501,6 +5501,8 @@ void Plater::priv::reload_from_disk()
|
||||||
for (size_t i = 0; i < model.objects.size(); ++i) {
|
for (size_t i = 0; i < model.objects.size(); ++i) {
|
||||||
view3D->get_canvas3d()->update_instance_printable_state_for_object(i);
|
view3D->get_canvas3d()->update_instance_printable_state_for_object(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " finish.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::reload_all_from_disk()
|
void Plater::priv::reload_all_from_disk()
|
||||||
|
|
|
@ -43,21 +43,29 @@ static wxString update_custom_filaments()
|
||||||
json m_CustomFilaments = json::array();
|
json m_CustomFilaments = json::array();
|
||||||
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
|
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();
|
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) {
|
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;
|
std::string filament_id = filament_id_to_presets.first;
|
||||||
if (filament_id.empty()) continue;
|
if (filament_id.empty()) continue;
|
||||||
for (const Preset *preset : filament_id_to_presets.second) {
|
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;
|
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;
|
std::string preset_name = preset->name;
|
||||||
size_t index_at = preset_name.find_last_of('@');
|
size_t index_at = preset_name.find(" @");
|
||||||
if (std::string::npos != index_at) { preset_name = preset_name.substr(0, index_at - 1); }
|
if (std::string::npos != index_at) { preset_name = preset_name.substr(0, index_at); }
|
||||||
temp_j["name"] = preset_name;
|
need_sort.push_back(std::make_pair(preset_name, preset->filament_id));
|
||||||
m_CustomFilaments.push_back(temp_j);
|
|
||||||
break;
|
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;
|
m_Res["data"] = m_CustomFilaments;
|
||||||
wxString strJS = wxString::Format("HandleStudio(%s)", wxString::FromUTF8(m_Res.dump(-1, ' ', false, json::error_handler_t::ignore)));
|
wxString strJS = wxString::Format("HandleStudio(%s)", wxString::FromUTF8(m_Res.dump(-1, ' ', false, json::error_handler_t::ignore)));
|
||||||
return strJS;
|
return strJS;
|
||||||
|
|
Loading…
Reference in New Issue