Merge branch 'main' into dev/extruder-toggle

This commit is contained in:
Noisyfox
2026-05-22 19:26:48 +08:00
committed by GitHub
105 changed files with 9977 additions and 3818 deletions

View File

@@ -864,10 +864,10 @@ std::string GCodeWriter::_spiral_travel_to_z(double z, const Vec2d &ij_offset, c
// Determine number of segments based on Resolution
// --------------------------------------------------------------------
const double ref_resolution = 0.01; // reference resolution in mm
const double ref_segments = 16.0; // reference number of segments at reference resolution
const double ref_segments = 8.0; // reference number of segments at reference resolution
// number of linear segments to use for approximating the arc, clamp between 4 and 24
const int segments = std::clamp(int(std::round(ref_segments * (ref_resolution / m_resolution))), 4, 24);
// number of linear segments to use for approximating the arc, clamp between 4 and 16
const int segments = std::clamp(int(std::round(ref_segments * (ref_resolution / m_resolution))), 4, 16);
// --------------------------------------------------------------------
const double px = m_pos(0) - m_x_offset; // take plate offset into consideration

View File

@@ -581,14 +581,6 @@ void Preset::load_info(const std::string& file)
catch (...) {
return;
}
//TODO: workaround for current info file convert, will remove it later
if (this->updated_time == 0) {
this->updated_time = (long long)Slic3r::Utils::get_current_time_utc();
//this->sync_info = "update";
BOOST_LOG_TRIVIAL(info) << boost::format("old info file, updated time to %1%") % this->updated_time;
save_info();
}
}
void Preset::save_info(std::string file)
@@ -2186,19 +2178,29 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
}
}
// base_id
if (preset_values.find(BBL_JSON_KEY_BASE_ID) == preset_values.end()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format("can not find base_id, not loading for user preset %1%") % canonical_name;
unlock();
return false;
// base_id is only required for presets inheriting from a parent. Root presets
// with an empty "inherits" field intentionally have no base_id.
std::string based_id;
const auto base_id = preset_values.find(BBL_JSON_KEY_BASE_ID);
if (base_id != preset_values.end()) {
based_id = base_id->second;
} else {
const auto inherits_iter = preset_values.find(BBL_JSON_KEY_INHERITS);
const bool preset_inherits_from_parent = inherits_iter != preset_values.end() && !inherits_iter->second.empty();
if (preset_inherits_from_parent) {
// This indicates that there is inherits exists but there is no base_id
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__
<< boost::format("can not find base_id, not loading for user preset %1%") % canonical_name;
unlock();
return false;
}
}
std::string cloud_base_id = preset_values[BBL_JSON_KEY_BASE_ID];
//filament_id
std::string cloud_filament_id;
if ((m_type == Preset::TYPE_FILAMENT) && preset_values.find(BBL_JSON_KEY_FILAMENT_ID) != preset_values.end()) {
cloud_filament_id = preset_values[BBL_JSON_KEY_FILAMENT_ID];
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << canonical_name << " filament_id: " << cloud_filament_id << " base_id: " << cloud_base_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << canonical_name << " filament_id: " << cloud_filament_id << " base_id: " << based_id;
}
DynamicPrintConfig new_config, cloud_config;
@@ -2271,7 +2273,7 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
iter->version = cloud_version.value();
iter->user_id = cloud_user_id;
iter->setting_id = cloud_setting_id;
iter->base_id = cloud_base_id;
iter->base_id = based_id;
iter->filament_id = cloud_filament_id;
update_alias(*iter);
//presets_loaded.emplace_back(*it->second);
@@ -2290,7 +2292,7 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
preset.version = cloud_version.value();
preset.user_id = cloud_user_id;
preset.setting_id = cloud_setting_id;
preset.base_id = cloud_base_id;
preset.base_id = based_id;
preset.filament_id = cloud_filament_id;
update_alias(preset);
@@ -3651,20 +3653,22 @@ void PresetCollection::set_custom_preset_alias(Preset &preset)
// For printers, there is nothing to remove
// For prints AKA processes, the postfix should be kept
// Alias should be set here, as the preset name may be augmented further later (i.e., prefixing relative path for bundles)
std::string alias_name;
std::string preset_name = get_preset_bare_name(preset.name);
if (m_type == Preset::Type::TYPE_FILAMENT && preset.config.has(BBL_JSON_KEY_INHERITS) && preset.config.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS)->value.empty()) {
if (alias_name.empty()) {
size_t end_pos = preset_name.find_first_of("@");
if (end_pos != std::string::npos) {
alias_name = preset_name.substr(0, end_pos);
boost::trim_right(alias_name);
}
std::string bare_preset_name = get_preset_bare_name(preset.name);
std::string alias_name = bare_preset_name;
const bool is_root_filament_preset =
m_type == Preset::Type::TYPE_FILAMENT &&
preset.config.has(BBL_JSON_KEY_INHERITS) &&
preset.config.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS)->value.empty();
if (is_root_filament_preset) {
const size_t suffix_separator_pos = bare_preset_name.find_first_of("@");
if (suffix_separator_pos != std::string::npos) {
alias_name = bare_preset_name.substr(0, suffix_separator_pos);
boost::trim_right(alias_name);
if (alias_name.empty())
alias_name = bare_preset_name;
}
}
else {
alias_name = preset_name;
}
preset.alias = std::move(alias_name);
m_map_alias_to_profile_name[preset.alias].push_back(preset.name);

View File

@@ -606,13 +606,24 @@ VendorType PresetBundle::get_current_vendor_type()
{
auto t = VendorType::Unknown;
auto config = &printers.get_edited_preset().config;
const auto* printer_model = config->opt<ConfigOptionString>("printer_model");
if (printer_model == nullptr) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": printer_model is "
<< (config->has("printer_model") ? "not a string" : "missing")
<< ", vendor type is Unknown";
return t;
}
std::string vendor_name;
for (auto vendor_profile : vendors) {
for (auto vendor_model : vendor_profile.second.models)
if (vendor_model.name == config->opt_string("printer_model")) {
for (const auto& vendor_profile : vendors) {
for (const auto& vendor_model : vendor_profile.second.models) {
if (vendor_model.name == printer_model->value) {
vendor_name = vendor_profile.first;
break;
}
}
if (!vendor_name.empty())
break;
}
if (!vendor_name.empty())
{
@@ -3779,7 +3790,17 @@ int PresetBundle::get_printer_extruder_count() const
{
const Preset& printer_preset = this->printers.get_edited_preset();
int count = printer_preset.config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
const auto* nozzle_diameter = printer_preset.config.option<ConfigOptionFloats>("nozzle_diameter");
if (nozzle_diameter == nullptr) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": nozzle_diameter is missing, using 1 extruder";
return 1;
}
if (nozzle_diameter->values.empty()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": nozzle_diameter is empty, using 1 extruder";
return 1;
}
int count = int(nozzle_diameter->values.size());
return count;
}

View File

@@ -46,11 +46,23 @@ void name_tbb_thread_pool_threads_set_locale();
template<class Fn>
inline boost::thread create_thread(boost::thread::attributes &attrs, Fn &&fn)
{
// Duplicating the stack allocation size of Thread Building Block worker
// threads of the thread pool: allocate 4MB on a 64bit system, allocate 2MB
// on a 32bit system by default.
attrs.set_stack_size((sizeof(void*) == 4) ? (2048 * 1024) : (4096 * 1024));
// Stack size for our worker threads. Originally duplicated TBB's pool
// default (4 MB), but the Emboss text-cut path calls into CGAL's
// Polygon_mesh_processing::corefine, which falls back from filtered
// interval arithmetic to exact rational arithmetic (mpq_class) on
// near-degenerate input, and the constrained 2D triangulation walker
// (Triangulation_2::march_locate_2D) can recurse deeply enough to
// exceed 4 MB on real models -- producing a SIGBUS at the next thread's
// stack guard page on macOS / Linux.
//
// 16 MB chosen as 4x defensive headroom over the observed crash
// threshold (n=1 reproducer at exactly 4 MB on macOS arm64). All three
// platforms defer-commit reserved stack pages: macOS / Linux mmap the
// stack and only fault in pages on touch; Boost.Thread on Win32 passes
// STACK_SIZE_PARAM_IS_A_RESERVATION to _beginthreadex, so the value is
// a reserve, not the initial commit. Resident memory therefore stays
// proportional to actual stack depth on every target.
attrs.set_stack_size(16 * 1024 * 1024);
return boost::thread{attrs, std::forward<Fn>(fn)};
}