Skip to content

Commit

Permalink
ENH: Support Child Folder of Filaments in Profiles
Browse files Browse the repository at this point in the history
Change-Id: Id89281d76efe42e7e8c407cce337fee1485e2cf0
(cherry picked from commit 634159a3ce43f3aaf9223b412e993d3355cb1682)
  • Loading branch information
zorro.zhang authored and lanewei120 committed Dec 15, 2022
1 parent 047e5c2 commit e4fa6d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
33 changes: 20 additions & 13 deletions src/slic3r/GUI/WebGuideDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ bool GuideFrame::run()
}
}

int GuideFrame::GetFilamentInfo(std::string filepath, std::string &sVendor, std::string &sType)
int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType)
{
//GetStardardFilePath(filepath);

Expand All @@ -881,21 +881,18 @@ int GuideFrame::GetFilamentInfo(std::string filepath, std::string &sVendor, std:
if (sVendor == "" || sType == "")
{
if (jLocal.contains("inherits")) {
boost::filesystem::path sf(filepath.c_str());
filepath = sf.string();

std::string strFile = filepath;
//wxString strFolder = strFile.BeforeLast(boost::filesystem::path::preferred_separator);
boost::filesystem::path file_path(filepath);

std::string FName = jLocal["inherits"];
FName += ".json";
//wxString strNewFile = wxString::Format("%s%c%s.json", strFolder.mb_str(), boost::filesystem::path::preferred_separator, FName.c_str());
boost::filesystem::path inherits_path = boost::filesystem::absolute(file_path.parent_path() / FName).make_preferred();

if (!pFilaList.contains(FName))
return -1;

std::string FPath = pFilaList[FName]["sub_path"];
wxString strNewFile = wxString::Format("%s%c%s", VendorDirectory, boost::filesystem::path::preferred_separator, FPath);
boost::filesystem::path inherits_path = boost::filesystem::absolute(w2s(strNewFile)).make_preferred();

//boost::filesystem::path nf(strNewFile.c_str());
if (boost::filesystem::exists(inherits_path))
return GetFilamentInfo(inherits_path.string(), sVendor, sType);
return GetFilamentInfo(VendorDirectory,pFilaList, inherits_path.string(), sVendor, sType);
else
return -1;
} else {
Expand Down Expand Up @@ -1379,8 +1376,18 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath

// BBS:Filament
json pFilament = jLocal["filament_list"];
json tFilaList = json::object();
nsize = pFilament.size();

for (int n = 0; n < nsize; n++) {
json OneFF = pFilament.at(n);

std::string s1 = OneFF["name"];
std::string s2 = OneFF["sub_path"];

tFilaList[s1] = OneFF;
}

int nFalse = 0;
int nModel = 0;
int nFinish = 0;
Expand All @@ -1403,7 +1410,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
std::string sV;
std::string sT;

int nRet = GetFilamentInfo(sub_file, sV, sT);
int nRet = GetFilamentInfo(vendor_dir.string(),tFilaList, sub_file, sV, sT);
if (nRet != 0) continue;

OneFF["vendor"] = sV;
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/WebGuideDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GuideFrame : public DPIDialog
int LoadProfile();
int LoadProfileFamily(std::string strVendor, std::string strFilePath);
int SaveProfile();
int GetFilamentInfo(std::string filepath, std::string &sVendor, std::string &sType);
int GetFilamentInfo( std::string VendorDirectory,json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType);


bool apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater, bool& apply_keeped_changes);
Expand Down

0 comments on commit e4fa6d8

Please sign in to comment.