feat(v2.4): KX-Linie auf Upstream 2.4.0 konsolidieren (2.4.0-kx1)
Some checks failed
Shellcheck / Shellcheck (push) Has been cancelled
Some checks failed
Shellcheck / Shellcheck (push) Has been cancelled
Neue 2.4-stable-Linie auf frischem orca-upstream/release/v2.4 (2.4.0): - KX-Moonraker-Bridge (MoonrakerPrinterAgent.cpp/.hpp) übernommen - Preset.cpp: KX-filament_id-Patches per 3way auf neuen Upstream appliziert (Upstream-Fixes 10.-21.06. erhalten) - Issue #52: Vendor-Filter bei User-Presets überspringen - AMS-Leerslot-Fix (DevFilaSystem.cpp + AMSItem.cpp): leerer Slot zeigt kein altes Filament mehr - About-Hinweis, verify_build.sh, Filament-Bridge-Doku, README - Version 2.4.0-kx1
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/uuid/detail/md5.hpp>
|
||||
#include <boost/algorithm/hex.hpp>
|
||||
|
||||
#include "libslic3r.h"
|
||||
#include "Utils.hpp"
|
||||
@@ -636,6 +638,31 @@ void Preset::save(DynamicPrintConfig* parent_config)
|
||||
//BBS: add project embedded preset logic
|
||||
if (this->is_project_embedded)
|
||||
return;
|
||||
|
||||
// Generate a unique filament_id for user filament presets that don't have one yet.
|
||||
// Inherited presets (e.g. "My PLA" inheriting "Generic PLA @System") previously had
|
||||
// no filament_id which caused AMS sync to fall back to the parent's Generic ID.
|
||||
// Also generate a new ID if filament_id is inherited from the parent (== base_id).
|
||||
// This happens when a user preset is saved for the first time without having its own ID.
|
||||
// A user preset needs its own filament_id if:
|
||||
// - it has no filament_id at all, OR
|
||||
// - its filament_id does not start with "P" (user preset IDs start with "P",
|
||||
// system IDs start with GFL/OGFL/GFA/etc.)
|
||||
bool needs_unique_filament_id = this->is_user() && !this->name.empty() &&
|
||||
this->type == Preset::TYPE_FILAMENT &&
|
||||
(this->filament_id.empty() || this->filament_id.front() != 'P');
|
||||
if (needs_unique_filament_id) {
|
||||
boost::uuids::detail::md5 hash;
|
||||
boost::uuids::detail::md5::digest_type digest;
|
||||
hash.process_bytes(this->name.data(), this->name.size());
|
||||
hash.get_digest(digest);
|
||||
const auto char_digest = reinterpret_cast<const char *>(&digest);
|
||||
std::string result;
|
||||
boost::algorithm::hex(char_digest, char_digest + sizeof(boost::uuids::detail::md5::digest_type), std::back_inserter(result));
|
||||
this->filament_id = "P" + result.substr(0, 7);
|
||||
BOOST_LOG_TRIVIAL(info) << "Preset::save: generated filament_id='" << this->filament_id << "' for user preset '" << this->name << "'";
|
||||
}
|
||||
|
||||
//BBS: change to json format
|
||||
//this->config.save(this->file);
|
||||
std::string from_str;
|
||||
@@ -691,6 +718,8 @@ void Preset::save(DynamicPrintConfig* parent_config)
|
||||
opt_dst->set(opt_src);
|
||||
}
|
||||
}
|
||||
if (!filament_id.empty())
|
||||
temp_config.set_key_value(BBL_JSON_KEY_FILAMENT_ID, new ConfigOptionString(filament_id));
|
||||
temp_config.save_to_json(this->file, bare_name, from_str, this->version.to_string());
|
||||
} else if (!filament_id.empty() && inherits().empty()) {
|
||||
DynamicPrintConfig temp_config = config;
|
||||
@@ -1005,9 +1034,6 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"lateral_lattice_angle_1",
|
||||
"lateral_lattice_angle_2",
|
||||
"infill_overhang_angle",
|
||||
"lightning_overhang_angle",
|
||||
"lightning_prune_angle",
|
||||
"lightning_straightening_angle",
|
||||
"top_surface_pattern",
|
||||
"bottom_surface_pattern",
|
||||
"infill_direction",
|
||||
@@ -1072,13 +1098,10 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"print_order",
|
||||
"support_remove_small_overhang",
|
||||
"filename_format",
|
||||
"outer_wall_filament_id",
|
||||
"inner_wall_filament_id",
|
||||
"wall_filament",
|
||||
"support_bottom_z_distance",
|
||||
"sparse_infill_filament_id",
|
||||
"internal_solid_filament_id",
|
||||
"top_surface_filament_id",
|
||||
"bottom_surface_filament_id",
|
||||
"sparse_infill_filament",
|
||||
"solid_infill_filament",
|
||||
"support_filament",
|
||||
"support_interface_filament",
|
||||
"support_interface_not_for_body",
|
||||
@@ -1100,7 +1123,6 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"infill_wall_overlap",
|
||||
"top_bottom_infill_wall_overlap",
|
||||
"bridge_flow",
|
||||
"bridge_line_width",
|
||||
"internal_bridge_flow",
|
||||
"elefant_foot_compensation",
|
||||
"elefant_foot_compensation_layers",
|
||||
@@ -1165,7 +1187,6 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"small_perimeter_threshold",
|
||||
"bridge_angle",
|
||||
"internal_bridge_angle",
|
||||
"relative_bridge_angle",
|
||||
"filter_out_gap_fill",
|
||||
"travel_acceleration",
|
||||
"inner_wall_acceleration",
|
||||
@@ -1326,7 +1347,7 @@ static std::vector<std::string> s_Preset_machine_limits_options {
|
||||
|
||||
static std::vector<std::string> s_Preset_printer_options {
|
||||
"printer_technology",
|
||||
"printable_area", "extruder_printable_area", "support_parallel_printheads", "parallel_printheads_count", "parallel_printheads_bed_exclude_areas", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor",
|
||||
"printable_area", "extruder_printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor",
|
||||
"fan_kickstart", "part_cooling_fan_min_pwm", "fan_speedup_time", "fan_speedup_overhangs",
|
||||
"single_extruder_multi_material", "manual_filament_change", "file_start_gcode", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "printing_by_object_gcode", "layer_change_gcode", "time_lapse_gcode", "wrapping_detection_gcode", "change_filament_gcode", "change_extrusion_role_gcode",
|
||||
"printer_model", "printer_variant", "printer_extruder_id", "printer_extruder_variant", "extruder_variant_list", "default_nozzle_volume_type",
|
||||
@@ -1337,7 +1358,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
||||
"scan_first_layer", "enable_power_loss_recovery", "wrapping_detection_layers", "wrapping_exclude_area", "machine_load_filament_time", "machine_unload_filament_time", "machine_tool_change_time", "time_cost", "machine_pause_gcode", "template_custom_gcode",
|
||||
"nozzle_type", "nozzle_hrc","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types", "travel_slope", "retract_lift_enforce","support_chamber_temp_control","support_air_filtration","printer_structure",
|
||||
"best_object_pos", "head_wrap_detect_zone",
|
||||
"host_type", "print_host", "printhost_apikey", "flashforge_serial_number", "bbl_use_printhost", "printer_agent",
|
||||
"host_type", "print_host", "printhost_apikey", "bbl_use_printhost", "printer_agent",
|
||||
"print_host_webui",
|
||||
"printhost_cafile","printhost_port","printhost_authorization_type",
|
||||
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke", "thumbnails", "thumbnails_format",
|
||||
@@ -1643,7 +1664,10 @@ void PresetCollection::load_presets(
|
||||
const Preset& default_preset = this->default_preset_for(config);
|
||||
if (inherit_preset) {
|
||||
preset.config = inherit_preset->config;
|
||||
preset.filament_id = inherit_preset->filament_id;
|
||||
// Only inherit filament_id from parent if this preset has no own ID in JSON.
|
||||
// User presets with a P-prefix ID (generated by Preset::save) must keep their own ID.
|
||||
if (preset.filament_id.empty())
|
||||
preset.filament_id = inherit_preset->filament_id;
|
||||
extend_default_config_length(config, false, {});
|
||||
preset.config.update_diff_values_to_child_config(config, extruder_id_name, extruder_variant_name, *key_set1, *key_set2);
|
||||
}
|
||||
@@ -2833,8 +2857,20 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
|
||||
|
||||
if (m_type == Preset::TYPE_PRINT)
|
||||
preset.config.option<ConfigOptionString>("print_settings_id", true)->value = new_name;
|
||||
else if (m_type == Preset::TYPE_FILAMENT)
|
||||
else if (m_type == Preset::TYPE_FILAMENT) {
|
||||
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0] = new_name;
|
||||
// Generate a unique filament_id for user presets that don't have one yet (PR #13315).
|
||||
if (preset.filament_id.empty() || preset.filament_id.front() != 'P') {
|
||||
boost::uuids::detail::md5 hash;
|
||||
boost::uuids::detail::md5::digest_type digest;
|
||||
hash.process_bytes(new_name.data(), new_name.size());
|
||||
hash.get_digest(digest);
|
||||
const auto char_digest = reinterpret_cast<const char *>(&digest);
|
||||
std::string result;
|
||||
boost::algorithm::hex(char_digest, char_digest + sizeof(boost::uuids::detail::md5::digest_type), std::back_inserter(result));
|
||||
preset.filament_id = "P" + result.substr(0, 7);
|
||||
}
|
||||
}
|
||||
else if (m_type == Preset::TYPE_PRINTER)
|
||||
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value = new_name;
|
||||
final_inherits = preset.inherits();
|
||||
@@ -3855,7 +3891,6 @@ static std::vector<std::string> s_PhysicalPrinter_opts {
|
||||
"print_host",
|
||||
"print_host_webui",
|
||||
"printhost_apikey",
|
||||
"flashforge_serial_number",
|
||||
"printhost_cafile",
|
||||
"printhost_port",
|
||||
"printhost_authorization_type",
|
||||
|
||||
Reference in New Issue
Block a user