Merge branch 'main' into feat/plugin-pages

This commit is contained in:
peachismomo
2026-08-06 06:16:28 +08:00
408 changed files with 19559 additions and 4589 deletions
+7
View File
@@ -2,6 +2,13 @@
#define __I_PRINTER_AGENT_HPP__
#include "bambu_networking.hpp"
// why: these extend the BAMBU_NETWORK_* return space rather than opening a new one - the value
// flows through the same int domain callers already compare against BAMBU_NETWORK_SUCCESS.
// They live here and not in bambu_networking.hpp because that file is a vendor header replaced
// wholesale by header-sync commits (see c09252ce11), which would silently clobber them.
// -70xx is free: the vendor occupies -1..-25 and -10xx through -60xx.
#define ORCA_NETWORK_ERR_CMD_NOT_SUPPORTED -7010 // no translation exists for this command
#define ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE -7020 // a translation exists; this printer lacks the capability
#include <string>
#include <memory>
-20
View File
@@ -465,25 +465,5 @@ void NetworkAgentFactory::deregister_python_printer_agent(const std::string& plu
<< plugin_key << "' with agent ID '" << agent_id << "'";
}
bool NetworkAgentFactory::is_current_printer_agent_plugin()
{
auto* preset_bundle = GUI::wxGetApp().preset_bundle;
if (!preset_bundle)
return false;
std::string agent_key = ORCA_PRINTER_AGENT_ID;
if (preset_bundle->is_bbl_vendor())
agent_key = BBL_PRINTER_AGENT_ID;
const auto& cfg = preset_bundle->printers.get_edited_preset().config;
if (cfg.has("printer_agent")) {
const std::string& value = cfg.option<ConfigOptionString>("printer_agent")->value;
if (!value.empty())
agent_key = value;
}
const PrinterAgentInfo* info = get_printer_agent_info(agent_key);
return info && info->is_plugin();
}
} // namespace Slic3r
-2
View File
@@ -166,8 +166,6 @@ public:
static void register_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
static void deregister_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
static bool is_current_printer_agent_plugin();
private:
// Factory is not instantiable
NetworkAgentFactory() = delete;
+39 -57
View File
@@ -1,12 +1,14 @@
#include "PresetUpdater.hpp"
#include <algorithm>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/nowide/fstream.hpp>
#include <functional>
#include <atomic>
#include <mutex>
#include <set>
#include <string>
#include <thread>
#include <unordered_map>
#include <ostream>
@@ -19,6 +21,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/log/trivial.hpp>
#include <vector>
#include <wx/app.h>
#include <wx/msgdlg.h>
@@ -204,7 +207,6 @@ struct PresetUpdater::priv
// Per-vendor update checking
std::set<std::string> checked_vendors;
std::mutex vendor_check_mutex;
std::vector<std::thread> vendor_check_threads;
std::atomic<bool> vendor_check_cancel{false};
@@ -221,10 +223,10 @@ struct PresetUpdater::priv
priv();
void set_download_prefs(AppConfig *app_config);
bool get_file(const std::string &url, const fs::path &target_path) const;
//BBS: refine preset update logic
bool get_file(const std::string &url, const fs::path &target_path) const;
//BBS: refine preset update logic
bool extract_file(const fs::path &source_path, const fs::path &dest_path = {});
void prune_tmps() const;
void prune_tmp(const std::string& vendor_id) const;
void sync_version() const;
void parse_version_string(const std::string& body) const;
void sync_resources(std::string http_url, std::map<std::string, Resource> &resources, bool check_patch = false, std::string current_version="", std::string changelog_file="");
@@ -371,14 +373,14 @@ bool PresetUpdater::priv::extract_file(const fs::path &source_path, const fs::pa
return true;
}
// Remove leftover paritally downloaded files, if any.
void PresetUpdater::priv::prune_tmps() const
// Remove a leftover partial archive for the vendor about to be synchronized.
void PresetUpdater::priv::prune_tmp(const std::string& vendor_id) const
{
for (auto &dir_entry : boost::filesystem::directory_iterator(cache_path))
if (is_plain_file(dir_entry) && dir_entry.path().extension() == TMP_EXTENSION) {
BOOST_LOG_TRIVIAL(debug) << "[Orca Updater]remove old cached files: " << dir_entry.path().string();
fs::remove(dir_entry.path());
}
boost::system::error_code ec;
const fs::path tmp_path = cache_path / (vendor_id + TMP_EXTENSION);
fs::remove(tmp_path, ec);
if (ec)
BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]failed to remove " << tmp_path.string() << ": " << ec.message();
}
//BBS: refine the Preset Updater logic
@@ -1060,10 +1062,9 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
Semver resource_ver = get_version_from_json(file_path);
Semver vendor_ver = get_version_from_json(path_in_vendor.string());
bool version_match = ((resource_ver.maj() == vendor_ver.maj()) && (resource_ver.min() == vendor_ver.min()));
if (!version_match || (vendor_ver < resource_ver)) {
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:found vendor "<<vendor_name<<" newer version "<<resource_ver.to_string() <<" from resource, old version "<<vendor_ver.to_string();
if (vendor_ver < resource_ver) {
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:found vendor " << vendor_name << " newer version "
<< resource_ver.to_string() << " from resource, old version " << vendor_ver.to_string();
bundles.insert(vendor_name);
}
}
@@ -1305,49 +1306,29 @@ PresetUpdater::~PresetUpdater()
//BBS: change directories by design
//BBS: refine the preset updater logic
void PresetUpdater::sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle)
void PresetUpdater::sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle * /*preset_bundle*/)
{
//p->set_download_prefs(GUI::wxGetApp().app_config);
if (!p->enabled_version_check && !p->enabled_config_update) { return; }
// Copy the whole vendors data for use in the background thread
// Unfortunatelly as of C++11, it needs to be copied again
// into the closure (but perhaps the compiler can elide this).
VendorMap vendors = preset_bundle ? preset_bundle->vendors : VendorMap{};
// Determine active vendor before entering the thread
std::string active_vendor;
if (preset_bundle) {
const Preset& printer = preset_bundle->printers.get_edited_preset();
if (printer.vendor)
active_vendor = printer.vendor->id;
}
p->thread = std::thread([this, vendors, active_vendor, http_url, language, plugin_version]() {
this->p->prune_tmps();
if (p->cancel)
return;
this->p->sync_version();
if (p->cancel)
return;
// Per-vendor config check for the active vendor at startup
if (!active_vendor.empty() && !vendors.empty()) {
this->p->sync_vendor_config(active_vendor);
if (p->cancel)
return;
{
std::lock_guard<std::mutex> lock(this->p->vendor_check_mutex);
this->p->checked_vendors.insert(active_vendor);
}
}
if (p->cancel)
return;
this->p->sync_plugins(http_url, plugin_version);
this->p->sync_printer_config(http_url);
//if (p->cancel)
// return;
//remove the tooltip currently
//this->p->sync_tooltip(http_url, language);
p->thread = std::thread([this, http_url, language, plugin_version]() {
try {
this->p->sync_version();
if (p->cancel)
return;
// Vendor profile updates are triggered by check_vendor_update()
// after the startup printer preset has been restored.
this->p->sync_plugins(http_url, plugin_version);
this->p->sync_printer_config(http_url);
//if (p->cancel)
// return;
//remove the tooltip currently
//this->p->sync_tooltip(http_url, language);
} catch (const std::exception &e) {
BOOST_LOG_TRIVIAL(error) << "[Orca Updater] background sync failed: " << e.what();
} catch (...) {
BOOST_LOG_TRIVIAL(error) << "[Orca Updater] background sync failed with an unknown exception";
}
});
}
@@ -1356,16 +1337,17 @@ void PresetUpdater::check_vendor_update(const std::string& vendor_id)
if (!p->enabled_config_update) return;
if (vendor_id.empty()) return;
std::lock_guard<std::mutex> lock(p->vendor_check_mutex);
if (!p->checked_vendors.insert(vendor_id).second)
return;
p->vendor_check_threads.emplace_back([this, vendor_id]() {
try {
this->p->prune_tmp(vendor_id);
this->p->sync_vendor_config(vendor_id);
} catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "[Orca Updater] vendor update failed for " << vendor_id << ": " << e.what();
} catch (...) {
BOOST_LOG_TRIVIAL(error) << "[Orca Updater] vendor update failed for " << vendor_id << " with an unknown exception";
}
});
}
+1 -1
View File
@@ -107,7 +107,7 @@ std::optional<RaycastManager::Hit> RaycastManager::first_hit(const Vec3d& point,
const AABBMesh *hit_mesh = nullptr;
double hit_squared_distance = 0.;
int hit_face = -1;
Vec3d hit_world;
Vec3d hit_world { Vec3d::Zero() };
const Transform3d *hit_tramsformation = nullptr;
const TrKey *hit_key = nullptr;