Add Orca Filament Library

This commit is contained in:
SoftFever
2025-01-15 22:40:27 +08:00
parent 70579f9159
commit 727a3887c5
30 changed files with 1283 additions and 97 deletions
+16 -17
View File
@@ -123,18 +123,18 @@ BundleMap BundleMap::load()
const auto vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / PRESET_SYSTEM_DIR).make_preferred();
const auto rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
//BBS: add BBL as default
//BBS: add json logic for vendor bundle
auto bbl_bundle_path = (vendor_dir / PresetBundle::BBL_BUNDLE).replace_extension(".json");
auto bbl_bundle_rsrc = false;
if (!boost::filesystem::exists(bbl_bundle_path)) {
bbl_bundle_path = (rsrc_vendor_dir / PresetBundle::BBL_BUNDLE).replace_extension(".json");
bbl_bundle_rsrc = true;
//Orca: add custom as default
//Orca: add json logic for vendor bundle
auto orca_bundle_path = (vendor_dir / PresetBundle::ORCA_DEFAULT_BUNDLE).replace_extension(".json");
auto orca_bundle_rsrc = false;
if (!boost::filesystem::exists(orca_bundle_path)) {
orca_bundle_path = (rsrc_vendor_dir / PresetBundle::ORCA_DEFAULT_BUNDLE).replace_extension(".json");
orca_bundle_rsrc = true;
}
{
Bundle bbl_bundle;
if (bbl_bundle.load(std::move(bbl_bundle_path), bbl_bundle_rsrc, true))
res.emplace(PresetBundle::BBL_BUNDLE, std::move(bbl_bundle));
if (bbl_bundle.load(std::move(orca_bundle_path), orca_bundle_rsrc, true))
res.emplace(PresetBundle::ORCA_DEFAULT_BUNDLE, std::move(bbl_bundle));
}
// Load the other bundles in the datadir/vendor directory
@@ -163,10 +163,10 @@ BundleMap BundleMap::load()
Bundle& BundleMap::bbl_bundle()
{
//BBS: add BBL as default
auto it = find(PresetBundle::BBL_BUNDLE);
//Orca: add custom as default
auto it = find(PresetBundle::ORCA_DEFAULT_BUNDLE);
if (it == end()) {
throw Slic3r::RuntimeError("ConfigWizard: Internal error in BundleMap: BBL_BUNDLE not loaded");
throw Slic3r::RuntimeError("ConfigWizard: Internal error in BundleMap: ORCA_DEFAULT_BUNDLE not loaded");
}
return it->second;
@@ -625,12 +625,11 @@ std::set<std::string> PagePrinters::get_selected_models()
void PagePrinters::set_run_reason(ConfigWizard::RunReason run_reason)
{
//BBS: add BBL as default
//Orca: add custom as default
if (is_primary_printer_page
&& (run_reason == ConfigWizard::RR_DATA_EMPTY || run_reason == ConfigWizard::RR_DATA_LEGACY)
&& printer_pickers.size() > 0
&& printer_pickers[0]->vendor_id == PresetBundle::BBL_BUNDLE) {
//BBS: select alll bbs machine by default
&& printer_pickers[0]->vendor_id == PresetBundle::ORCA_DEFAULT_BUNDLE) {
//printer_pickers[0]->select_one(0, true);
printer_pickers[0]->select_all(true);
}
@@ -1941,8 +1940,8 @@ void ConfigWizard::priv::create_3rdparty_pages()
{
for (const auto &pair : bundles) {
const VendorProfile *vendor = pair.second.vendor_profile;
//BBS: add BBL as default
if (vendor->id == PresetBundle::BBL_BUNDLE) { continue; }
//Orca: add custom as default
if (vendor->id == PresetBundle::ORCA_DEFAULT_BUNDLE) { continue; }
bool is_fff_technology = false;
bool is_sla_technology = false;
+1 -1
View File
@@ -845,7 +845,7 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
}
if (filename.empty()) {
filename = preset_bundle->get_hotend_model_for_printer_model(PresetBundle::BBL_DEFAULT_PRINTER_MODEL);
filename = preset_bundle->get_hotend_model_for_printer_model(PresetBundle::ORCA_DEFAULT_PRINTER_MODEL);
}
}
}
+1 -1
View File
@@ -4736,7 +4736,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
m_sync_update_thread = Slic3r::create_thread(
[this, progressFn, cancelFn, finishFn, t = std::weak_ptr<int>(m_user_sync_token)] {
// get setting list, update setting list
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::BBL_BUNDLE).to_string();
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::ORCA_DEFAULT_BUNDLE).to_string();
int ret = m_agent->get_setting_list2(version, [this](auto info) {
auto type = info[BBL_JSON_KEY_TYPE];
auto name = info[BBL_JSON_KEY_NAME];
+19 -19
View File
@@ -592,7 +592,7 @@ bool GuideFrame::IsFirstUse()
if (strVal == "1")
return false;
if (bbl_bundle_rsrc == true)
if (orca_bundle_rsrc == true)
return true;
return true;
@@ -881,11 +881,11 @@ bool GuideFrame::apply_config(AppConfig *app_config, PresetBundle *preset_bundle
variant.clear();
return std::string();
};
// Prusa printers are considered first, then 3rd party.
if (preferred_model = get_preferred_printer_model(PresetBundle::BBL_BUNDLE, preferred_variant);
// Orca "custom" printers are considered first, then 3rd party.
if (preferred_model = get_preferred_printer_model(PresetBundle::ORCA_DEFAULT_BUNDLE, preferred_variant);
preferred_model.empty()) {
for (const auto& bundle : enabled_vendors) {
if (bundle.first == PresetBundle::BBL_BUNDLE) { continue; }
if (bundle.first == PresetBundle::ORCA_DEFAULT_BUNDLE) { continue; }
if (preferred_model = get_preferred_printer_model(bundle.first, preferred_variant);
!preferred_model.empty())
break;
@@ -962,10 +962,10 @@ bool GuideFrame::run()
//we install the default here
bool apply_keeped_changes = false;
//clear filament section and use default materials
app.app_config->set_variant(PresetBundle::BBL_BUNDLE,
PresetBundle::BBL_DEFAULT_PRINTER_MODEL, PresetBundle::BBL_DEFAULT_PRINTER_VARIANT, "true");
app.app_config->set_variant(PresetBundle::ORCA_DEFAULT_BUNDLE,
PresetBundle::ORCA_DEFAULT_PRINTER_MODEL, PresetBundle::ORCA_DEFAULT_PRINTER_VARIANT, "true");
app.app_config->clear_section(AppConfig::SECTION_FILAMENTS);
app.preset_bundle->load_selections(*app.app_config, {PresetBundle::BBL_DEFAULT_PRINTER_MODEL, PresetBundle::BBL_DEFAULT_PRINTER_VARIANT, PresetBundle::BBL_DEFAULT_FILAMENT, std::string()});
app.preset_bundle->load_selections(*app.app_config, {PresetBundle::ORCA_DEFAULT_PRINTER_MODEL, PresetBundle::ORCA_DEFAULT_PRINTER_VARIANT, PresetBundle::ORCA_DEFAULT_FILAMENT, std::string()});
app.app_config->set_legacy_datadir(false);
app.update_mode();
@@ -1099,13 +1099,13 @@ int GuideFrame::LoadProfile()
vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / PRESET_SYSTEM_DIR ).make_preferred();
rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
// BBS: add BBL as default
// BBS: add json logic for vendor bundle
auto bbl_bundle_path = vendor_dir;
bbl_bundle_rsrc = false;
if (!boost::filesystem::exists((vendor_dir / PresetBundle::BBL_BUNDLE).replace_extension(".json"))) {
bbl_bundle_path = rsrc_vendor_dir;
bbl_bundle_rsrc = true;
// 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;
}
// intptr_t handle;
@@ -1126,8 +1126,8 @@ int GuideFrame::LoadProfile()
//} while (_findnext(handle, &findData) == 0); // ???????????
//load BBL bundle from user data path
string targetPath = bbl_bundle_path.make_preferred().string();
//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++) {
@@ -1143,7 +1143,7 @@ int GuideFrame::LoadProfile()
strVendor = strVendor.AfterLast('/');
wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower();
if (w2s(strVendor) == PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json") == 0)
if ((w2s(strVendor) == PresetBundle::ORCA_DEFAULT_BUNDLE || w2s(strVendor) == PresetBundle::ORCA_FILAMENT_LIBRARY) && strExtension.CmpNoCase("json") == 0)
LoadProfileFamily(w2s(strVendor), iter->path().string());
}
}
@@ -1162,13 +1162,13 @@ int GuideFrame::LoadProfile()
strVendor = strVendor.AfterLast('/');
wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower();
if (w2s(strVendor) != PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json")==0)
if (w2s(strVendor) != PresetBundle::ORCA_DEFAULT_BUNDLE && w2s(strVendor) != PresetBundle::ORCA_FILAMENT_LIBRARY && strExtension.CmpNoCase("json")==0)
LoadProfileFamily(w2s(strVendor), iter->path().string());
}
}
//LoadProfileFamily(PresetBundle::BBL_BUNDLE, bbl_bundle_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);
+1 -1
View File
@@ -103,7 +103,7 @@ private:
wxString m_SectionName;
bool bbl_bundle_rsrc;
bool orca_bundle_rsrc;
boost::filesystem::path vendor_dir;
boost::filesystem::path rsrc_vendor_dir;
+5 -5
View File
@@ -1071,8 +1071,7 @@ bool PresetUpdater::priv::install_bundles_rsrc(std::vector<std::string> bundles,
}
//BBS: refine preset update logic
// Install indicies from resources. Only installs those that are either missing or older than in resources.
// Orca: copy/update the vendor profiles from resource to system folder
void PresetUpdater::priv::check_installed_vendor_profiles() const
{
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:Checking whether the profile from resource is newer";
@@ -1080,8 +1079,9 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
AppConfig *app_config = GUI::wxGetApp().app_config;
const auto enabled_vendors = app_config->vendors();
//BBS: refine the init check logic
std::vector<std::string> bundles;
// Orca: always install filament library
bundles.push_back(PresetBundle::ORCA_FILAMENT_LIBRARY);
for (auto &dir_entry : boost::filesystem::directory_iterator(rsrc_path)) {
const auto &path = dir_entry.path();
std::string file_path = path.string();
@@ -1111,11 +1111,11 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
fs::remove_all(path_of_vendor);
}
}
else if ((vendor_name == PresetBundle::BBL_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) {//if vendor has no file, copy it from resource for BBL
else if ((vendor_name == PresetBundle::ORCA_DEFAULT_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) {//if vendor has no file, copy it from resource for ORCA_DEFAULT_BUNDLE
bundles.push_back(vendor_name);
}
}
else if ((vendor_name == PresetBundle::BBL_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) { //always update configs from resource to vendor for BBL
else if ((vendor_name == PresetBundle::ORCA_DEFAULT_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) { //always update configs from resource to vendor for ORCA_DEFAULT_BUNDLE
bundles.push_back(vendor_name);
}
}