mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Fix renamed_from feature and others
This commit is contained in:
parent
8188963e20
commit
206c6228a5
6 changed files with 83 additions and 79 deletions
|
@ -1,9 +1,13 @@
|
|||
#include "WebGuideDialog.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/iostreams/detail/select.hpp>
|
||||
#include <string.h>
|
||||
#include "I18N.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "slic3r/GUI/wxExtensions.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "libslic3r_version.h"
|
||||
|
@ -1066,31 +1070,7 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
|
|||
int GuideFrame::LoadProfile()
|
||||
{
|
||||
try {
|
||||
//wxString ExePath = boost::dll::program_location().parent_path().string();
|
||||
//wxString TargetFolder = ExePath + "\\resources\\profiles\\";
|
||||
//wxString TargetFolderSearch = ExePath + "\\resources\\profiles\\*.json";
|
||||
|
||||
//intptr_t handle;
|
||||
//_finddata_t findData;
|
||||
|
||||
//handle = _findfirst(TargetFolderSearch.mb_str(), &findData); // ???????????
|
||||
//if (handle == -1) { return -1; }
|
||||
|
||||
//do {
|
||||
// if (findData.attrib & _A_SUBDIR && strcmp(findData.name, ".") == 0 && strcmp(findData.name, "..") == 0) // ??????????"."?".."
|
||||
// {
|
||||
// // cout << findData.name << "\t<dir>\n";
|
||||
// } else {
|
||||
// wxString strVendor = wxString(findData.name).BeforeLast('.');
|
||||
// LoadProfileFamily(strVendor, TargetFolder + findData.name);
|
||||
// }
|
||||
|
||||
//} while (_findnext(handle, &findData) == 0); // ???????????
|
||||
|
||||
// BBS: change directories by design
|
||||
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", will load config from %1%.") % bbl_bundle_path;
|
||||
m_ProfileJson = json::parse("{}");
|
||||
//m_ProfileJson["configpath"] = Slic3r::data_dir();
|
||||
m_ProfileJson["model"] = json::array();
|
||||
m_ProfileJson["machine"] = json::object();
|
||||
m_ProfileJson["filament"] = json::object();
|
||||
|
@ -1101,74 +1081,58 @@ int GuideFrame::LoadProfile()
|
|||
|
||||
// Orca: add custom as default
|
||||
// Orca: add json logic for vendor bundle
|
||||
auto orca_custom_bundle_path = vendor_dir;
|
||||
orca_bundle_rsrc = false;
|
||||
if (!boost::filesystem::exists((vendor_dir / PresetBundle::ORCA_DEFAULT_BUNDLE).replace_extension(".json"))) {
|
||||
orca_custom_bundle_path = rsrc_vendor_dir;
|
||||
orca_bundle_rsrc = true;
|
||||
orca_bundle_rsrc = true;
|
||||
|
||||
// search if there exists a .json file in vendor_dir folder, if exists, set orca_bundle_rsrc to false
|
||||
for (const auto& entry : boost::filesystem::directory_iterator(vendor_dir)) {
|
||||
if (!boost::filesystem::is_directory(entry) && boost::iequals(entry.path().extension().string(), ".json") && !boost::iequals(entry.path().stem().string(), PresetBundle::ORCA_FILAMENT_LIBRARY)) {
|
||||
orca_bundle_rsrc = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// intptr_t handle;
|
||||
//_finddata_t findData;
|
||||
|
||||
//handle = _findfirst((bbl_bundle_path / "*.json").make_preferred().string().c_str(), &findData); // ???????????
|
||||
// if (handle == -1) { return -1; }
|
||||
|
||||
// do {
|
||||
// if (findData.attrib & _A_SUBDIR && strcmp(findData.name, ".") == 0 && strcmp(findData.name, "..") == 0) // ??????????"."?".."
|
||||
// {
|
||||
// // cout << findData.name << "\t<dir>\n";
|
||||
// } else {
|
||||
// wxString strVendor = wxString(findData.name).BeforeLast('.');
|
||||
// LoadProfileFamily(w2s(strVendor), vendor_dir.make_preferred().string() + "\\"+ findData.name);
|
||||
// }
|
||||
|
||||
//} while (_findnext(handle, &findData) == 0); // ???????????
|
||||
|
||||
// load the default filament library first
|
||||
std::set<std::string> loaded_vendors;
|
||||
auto filament_library_name = boost::filesystem::path(PresetBundle::ORCA_FILAMENT_LIBRARY).replace_extension(".json");
|
||||
if (boost::filesystem::exists(vendor_dir / filament_library_name)) {
|
||||
LoadProfileFamily(PresetBundle::ORCA_FILAMENT_LIBRARY, (vendor_dir / filament_library_name).string());
|
||||
} else {
|
||||
LoadProfileFamily(PresetBundle::ORCA_FILAMENT_LIBRARY, (rsrc_vendor_dir / filament_library_name).string());
|
||||
}
|
||||
loaded_vendors.insert(PresetBundle::ORCA_FILAMENT_LIBRARY);
|
||||
|
||||
//load custom bundle from user data path
|
||||
string targetPath = orca_custom_bundle_path.make_preferred().string();
|
||||
boost::filesystem::path myPath(targetPath);
|
||||
boost::filesystem::directory_iterator endIter;
|
||||
for (boost::filesystem::directory_iterator iter(myPath); iter != endIter; iter++) {
|
||||
if (boost::filesystem::is_directory(*iter)) {
|
||||
//cout << "is dir" << endl;
|
||||
//cout << iter->path().string() << endl;
|
||||
} else {
|
||||
//cout << "is a file" << endl;
|
||||
//cout << iter->path().string() << endl;
|
||||
|
||||
for (boost::filesystem::directory_iterator iter(vendor_dir); iter != endIter; iter++) {
|
||||
if (!boost::filesystem::is_directory(*iter)) {
|
||||
wxString strVendor = from_u8(iter->path().string()).BeforeLast('.');
|
||||
strVendor = strVendor.AfterLast('\\');
|
||||
strVendor = strVendor.AfterLast('/');
|
||||
wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower();
|
||||
|
||||
if ((w2s(strVendor) == PresetBundle::ORCA_DEFAULT_BUNDLE || w2s(strVendor) == PresetBundle::ORCA_FILAMENT_LIBRARY) && strExtension.CmpNoCase("json") == 0)
|
||||
LoadProfileFamily(w2s(strVendor), iter->path().string());
|
||||
wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower();
|
||||
if(strExtension.CmpNoCase("json") != 0 || loaded_vendors.find(w2s(strVendor)) != loaded_vendors.end())
|
||||
continue;
|
||||
|
||||
LoadProfileFamily(w2s(strVendor), iter->path().string());
|
||||
loaded_vendors.insert(w2s(strVendor));
|
||||
}
|
||||
}
|
||||
|
||||
//string others_targetPath = rsrc_vendor_dir.string();
|
||||
boost::filesystem::directory_iterator others_endIter;
|
||||
for (boost::filesystem::directory_iterator iter(rsrc_vendor_dir); iter != others_endIter; iter++) {
|
||||
if (boost::filesystem::is_directory(*iter)) {
|
||||
//cout << "is dir" << endl;
|
||||
//cout << iter->path().string() << endl;
|
||||
} else {
|
||||
//cout << "is a file" << endl;
|
||||
//cout << iter->path().string() << endl;
|
||||
if (!boost::filesystem::is_directory(*iter)) {
|
||||
wxString strVendor = from_u8(iter->path().string()).BeforeLast('.');
|
||||
strVendor = strVendor.AfterLast('\\');
|
||||
strVendor = strVendor.AfterLast('/');
|
||||
wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower();
|
||||
if (strExtension.CmpNoCase("json") != 0 || loaded_vendors.find(w2s(strVendor)) != loaded_vendors.end())
|
||||
continue;
|
||||
|
||||
if (w2s(strVendor) != PresetBundle::ORCA_DEFAULT_BUNDLE && w2s(strVendor) != PresetBundle::ORCA_FILAMENT_LIBRARY && strExtension.CmpNoCase("json")==0)
|
||||
LoadProfileFamily(w2s(strVendor), iter->path().string());
|
||||
LoadProfileFamily(w2s(strVendor), iter->path().string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//LoadProfileFamily(PresetBundle::ORCA_DEFAULT_BUNDLE, bbl_bundle_path.string());
|
||||
|
||||
const auto enabled_filaments = wxGetApp().app_config->has_section(AppConfig::SECTION_FILAMENTS) ? wxGetApp().app_config->get_section(AppConfig::SECTION_FILAMENTS) : std::map<std::string, std::string>();
|
||||
m_appconfig_new.set_vendors(*wxGetApp().app_config);
|
||||
|
@ -1531,7 +1495,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
|
||||
// BBS:Filament
|
||||
json pFilament = jLocal["filament_list"];
|
||||
json tFilaList = json::object();
|
||||
json tFilaList = m_OrcaFilaList;
|
||||
nsize = pFilament.size();
|
||||
|
||||
for (int n = 0; n < nsize; n++) {
|
||||
|
@ -1604,6 +1568,8 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
|
||||
}
|
||||
}
|
||||
if(strVendor == PresetBundle::ORCA_FILAMENT_LIBRARY)
|
||||
m_OrcaFilaList = tFilaList;
|
||||
|
||||
// process
|
||||
json pProcess = jLocal["process_list"];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue