Merge branch 'main' into pr/Noisyfox/13712

This commit is contained in:
SoftFever
2026-06-22 10:56:11 +08:00
2782 changed files with 331956 additions and 215963 deletions

View File

@@ -6,6 +6,7 @@
#include "libslic3r.h"
#include "I18N.hpp"
#include "Utils.hpp"
#include "LocalesUtils.hpp"
#include "Model.hpp"
#include "libslic3r_version.h"
@@ -2231,6 +2232,7 @@ std::pair<PresetsConfigSubstitutions, std::string> PresetBundle::load_system_pre
[&](const tbb::blocked_range<size_t>& range) {
for (size_t i = range.begin(); i < range.end(); ++i) {
auto bundle = std::make_unique<PresetBundle>();
bundle->set_is_validation_mode(validation_mode);
try {
auto result = bundle->load_vendor_configs_from_json(
dir.string(), other_vendors[i], PresetBundle::LoadSystem,
@@ -2871,6 +2873,14 @@ void PresetBundle::load_selections(AppConfig &config, const PresetPreferences& p
if (use_default_nozzle_volume_type) {
project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values = current_printer.config.option<ConfigOptionEnumsGeneric>("default_nozzle_volume_type")->values;
} else {
// Orca: make sure `nozzle_volume_type` not shorter than `default_nozzle_volume_type`, otherwise we got array out of bound access
// later in `Tab::switch_excluder`
auto& opt = project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values;
const auto& opt_default = current_printer.config.option<ConfigOptionEnumsGeneric>("default_nozzle_volume_type")->values;
while (opt.size() < opt_default.size()) {
opt.emplace_back(opt_default[opt.size()]);
}
}
// Parse the initial physical printer name.
@@ -4095,13 +4105,16 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio
opt->value = boost::algorithm::clamp<int>(opt->value, 0, int(num_filaments));
}
static const char* keys_1based[] = {"wall_filament", "sparse_infill_filament", "solid_infill_filament"};
for (size_t i = 0; i < sizeof(keys_1based) / sizeof(keys_1based[0]); ++ i) {
std::string key = std::string(keys_1based[i]);
static const char* keys_with_default[] = {
"outer_wall_filament_id", "inner_wall_filament_id", "sparse_infill_filament_id",
"internal_solid_filament_id", "top_surface_filament_id", "bottom_surface_filament_id"
};
for (size_t i = 0; i < sizeof(keys_with_default) / sizeof(keys_with_default[0]); ++ i) {
std::string key = std::string(keys_with_default[i]);
auto *opt = dynamic_cast<ConfigOptionInt*>(out.option(key, false));
assert(opt != nullptr);
if(opt->value < 1 || opt->value > int(num_filaments))
opt->value = 1;
if(opt->value < 0 || opt->value > int(num_filaments))
opt->value = 0;
}
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset_name();
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = this->filament_presets;
@@ -4971,6 +4984,39 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_vendor_configs_
reason = std::string("can not find printer_variant in vendor profile");
return reason;
}
// An instantiation printer profile's nozzle_diameter must match the numeric (diameter)
// prefix of its printer_variant: "0.4" -> {0.4}, "0.8HF" -> {0.8} (a trailing
// non-numeric suffix such as "HF"/"HS" distinguishes a hardware sub-variant and is
// ignored here), and for multi-nozzle printers "0.4+0.6" -> {0.4, 0.6}.
// Note: a variant may legitimately repeat across presets of the same model (e.g. speed
// modes, IDEX copy/mirror, or different control boards), so only the diameter is
// validated, not variant uniqueness. Validation-only so the app keeps loading existing
// profiles unchanged.
if (validation_mode && instantiation == "true") {
const auto *nd = config.option<ConfigOptionFloats>("nozzle_diameter");
std::set<double> nozzles, variant_nozzles;
if (nd != nullptr)
nozzles.insert(nd->values.begin(), nd->values.end());
std::vector<std::string> variant_tokens;
boost::algorithm::split(variant_tokens, printer_variant, boost::algorithm::is_any_of("+"));
bool variant_ok = true; // printer_variant is already guaranteed non-empty above
for (const std::string &tok : variant_tokens) {
size_t consumed = 0;
double d = string_to_double_decimal_point(tok, &consumed);
// Require a leading numeric diameter; a trailing suffix (e.g. "HF") is allowed.
if (consumed == 0) { variant_ok = false; break; }
variant_nozzles.insert(d);
}
if (!variant_ok || variant_nozzles != nozzles) {
++m_errors;
BOOST_LOG_TRIVIAL(error) << "Error in a Vendor Config Bundle \"" << path << "\": The printer preset \"" <<
preset_name << "\" has printer_variant \"" << printer_variant <<
"\" that does not match its nozzle_diameter \"" << (nd ? nd->serialize() : std::string()) << "\". "
"printer_variant must begin with the nozzle diameter, optionally followed by a non-numeric suffix "
"(e.g. \"0.4\", \"0.8HF\"); for multi-nozzle printers, join the per-nozzle diameters with \"+\" in "
"nozzle order (e.g. \"0.4+0.6\").";
}
}
}
const Preset *preset_existing = presets_collection->find_preset(preset_name, false);
if (preset_existing != nullptr) {