mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-24 00:28:38 -07:00
Merge 002fee2f57 into 506fde8f86
This commit is contained in:
commit
2c7f2efca0
2 changed files with 33 additions and 10 deletions
|
|
@ -919,16 +919,13 @@ bool GuideFrame::run()
|
|||
return false;
|
||||
}
|
||||
|
||||
int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType)
|
||||
int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList, const std::string& filepath, const json& content, std::string &sVendor, std::string &sType)
|
||||
{
|
||||
//GetStardardFilePath(filepath);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " GetFilamentInfo:VendorDirectory - " << VendorDirectory << ", Filepath - "<<filepath;
|
||||
|
||||
try {
|
||||
std::string contents;
|
||||
LoadFile(filepath, contents);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": Json Contents: " << contents;
|
||||
json jLocal = json::parse(contents);
|
||||
const json& jLocal = content;
|
||||
|
||||
if (sVendor == "") {
|
||||
if (jLocal.contains("filament_vendor"))
|
||||
|
|
@ -964,8 +961,14 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
|
|||
inherits_path = (boost::filesystem::path(m_OrcaFilaLibPath) / boost::filesystem::path(FPath)).make_preferred();
|
||||
|
||||
//boost::filesystem::path nf(strNewFile.c_str());
|
||||
if (boost::filesystem::exists(inherits_path))
|
||||
return GetFilamentInfo(VendorDirectory,pFilaList, inherits_path.string(), sVendor, sType);
|
||||
if (boost::filesystem::exists(inherits_path)) {
|
||||
std::string contents;
|
||||
LoadFile(inherits_path.string(), contents);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": Json Contents: " << contents;
|
||||
json j_inherits = json::parse(contents);
|
||||
|
||||
return GetFilamentInfo(VendorDirectory,pFilaList, inherits_path.string(), j_inherits, sVendor, sType);
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " inherits File Not Exist: " << inherits_path;
|
||||
return -1;
|
||||
|
|
@ -1149,10 +1152,25 @@ int GuideFrame::SaveProfileData()
|
|||
|
||||
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
|
||||
//json temp_filament = it.value();
|
||||
std::string filament_name = it.key();
|
||||
if (enabled_filaments.find(filament_name) != enabled_filaments.end())
|
||||
m_ProfileJson["filament"][filament_name]["selected"] = 1;
|
||||
else {
|
||||
// Orca: Support renamed filament
|
||||
json temp_filament = it.value();
|
||||
if (enabled_filaments.find(temp_filament["name"]) != enabled_filaments.end())
|
||||
m_ProfileJson["filament"][filament_name]["selected"] = 1;
|
||||
else if (temp_filament.contains("renamed_from")) {
|
||||
std::vector<std::string> renamed_from;
|
||||
if (unescape_strings_cstyle(temp_filament["renamed_from"], renamed_from)) {
|
||||
if (std::any_of(renamed_from.begin(), renamed_from.end(), [&enabled_filaments](const std::string& n) {
|
||||
return enabled_filaments.find(n) != enabled_filaments.end();
|
||||
})) {
|
||||
m_ProfileJson["filament"][filament_name]["selected"] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----region
|
||||
|
|
@ -1318,7 +1336,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
std::string sV;
|
||||
std::string sT;
|
||||
|
||||
int nRet = GetFilamentInfo(vendor_dir.string(),tFilaList, sub_file, sV, sT);
|
||||
int nRet = GetFilamentInfo(vendor_dir.string(),tFilaList, sub_file, pm, sV, sT);
|
||||
if (nRet != 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Load Filament:" << s1 << ",GetFilamentInfo Failed, Vendor:" << sV << ",Type:"<< sT;
|
||||
continue;
|
||||
|
|
@ -1345,6 +1363,11 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
}
|
||||
}
|
||||
|
||||
OneFF["name"] = pm["name"];
|
||||
if (pm.contains("renamed_from")) {
|
||||
OneFF["renamed_from"] = pm["renamed_from"];
|
||||
}
|
||||
|
||||
OneFF["models"] = ModelList;
|
||||
OneFF["selected"] = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public:
|
|||
int SaveProfileData();
|
||||
int LoadProfileFamily(std::string strVendor, std::string strFilePath);
|
||||
int SaveProfile();
|
||||
int GetFilamentInfo( std::string VendorDirectory,json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType);
|
||||
int GetFilamentInfo( std::string VendorDirectory,json & pFilaList, const std::string& filepath, const json& content, std::string &sVendor, std::string &sType);
|
||||
|
||||
|
||||
bool apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater, bool& apply_keeped_changes);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue