From cbb84d2fb6dfe1206fa373155e6b29ee83f14449 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Thu, 9 Feb 2023 17:02:41 +0800 Subject: [PATCH] ENH: support filament_z_hop_types Support override z top type in filament This is handling for STUDIO-2082 Change-Id: I885d1d5e44d626e28b260ff569d0359e462a5f8d --- resources/profiles/Anycubic.json | 2 +- .../filament/fdm_filament_common.json | 3 ++ resources/profiles/BBL.json | 2 +- .../BBL/filament/fdm_filament_common.json | 3 ++ .../BBL/machine/fdm_bbl_3dp_001_common.json | 4 +- resources/profiles/Creality.json | 2 +- .../filament/fdm_filament_common.json | 3 ++ resources/profiles/Voron.json | 2 +- .../Voron/filament/fdm_filament_common.json | 3 ++ src/libslic3r/Config.cpp | 13 ++++-- src/libslic3r/Config.hpp | 46 +++++++++++++------ src/libslic3r/GCode.cpp | 16 +++---- src/libslic3r/GCode.hpp | 2 +- src/libslic3r/Preset.cpp | 4 +- src/libslic3r/Print.cpp | 2 +- src/libslic3r/PrintConfig.cpp | 23 ++++++---- src/libslic3r/PrintConfig.hpp | 2 +- src/libslic3r/PrintObject.cpp | 3 -- src/slic3r/GUI/Field.cpp | 29 +++++++++++- src/slic3r/GUI/Field.hpp | 3 ++ src/slic3r/GUI/OptionsGroup.cpp | 3 ++ src/slic3r/GUI/Tab.cpp | 4 +- 22 files changed, 126 insertions(+), 48 deletions(-) diff --git a/resources/profiles/Anycubic.json b/resources/profiles/Anycubic.json index 90520abd1..3ff3ba3f3 100644 --- a/resources/profiles/Anycubic.json +++ b/resources/profiles/Anycubic.json @@ -1,6 +1,6 @@ { "name": "Anycubic", - "version": "01.05.00.01", + "version": "01.05.00.02", "force_update": "0", "description": "Anycubic configurations", "machine_model_list": [ diff --git a/resources/profiles/Anycubic/filament/fdm_filament_common.json b/resources/profiles/Anycubic/filament/fdm_filament_common.json index 5212d445a..f1e09f49d 100644 --- a/resources/profiles/Anycubic/filament/fdm_filament_common.json +++ b/resources/profiles/Anycubic/filament/fdm_filament_common.json @@ -78,6 +78,9 @@ "filament_z_hop": [ "nil" ], + "filament_z_hop_types": [ + "nil" + ], "filament_retract_restart_extra": [ "nil" ], diff --git a/resources/profiles/BBL.json b/resources/profiles/BBL.json index 2b9153478..11d9bcf48 100644 --- a/resources/profiles/BBL.json +++ b/resources/profiles/BBL.json @@ -1,7 +1,7 @@ { "name": "Bambulab", "url": "http://www.bambulab.com/Parameters/vendor/BBL.json", - "version": "01.05.00.10", + "version": "01.05.00.11", "force_update": "0", "description": "the initial version of BBL configurations", "machine_model_list": [ diff --git a/resources/profiles/BBL/filament/fdm_filament_common.json b/resources/profiles/BBL/filament/fdm_filament_common.json index 17813e617..361fd9a9a 100644 --- a/resources/profiles/BBL/filament/fdm_filament_common.json +++ b/resources/profiles/BBL/filament/fdm_filament_common.json @@ -87,6 +87,9 @@ "filament_z_hop": [ "nil" ], + "filament_z_hop_types": [ + "nil" + ], "filament_retract_restart_extra": [ "nil" ], diff --git a/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json b/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json index 9b8b916d5..1fbd09513 100644 --- a/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json +++ b/resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json @@ -151,7 +151,9 @@ "deretraction_speed": [ "30" ], - "z_hop_type": "Auto Lift", + "z_hop_types": [ + "Auto Lift" + ], "nozzle_type": "hardened_steel", "silent_mode": "0", "single_extruder_multi_material": "1", diff --git a/resources/profiles/Creality.json b/resources/profiles/Creality.json index 380a91a0f..ade8fd434 100644 --- a/resources/profiles/Creality.json +++ b/resources/profiles/Creality.json @@ -1,6 +1,6 @@ { "name": "Creality", - "version": "01.05.00.01", + "version": "01.05.00.02", "force_update": "0", "description": "Creality configurations", "machine_model_list": [ diff --git a/resources/profiles/Creality/filament/fdm_filament_common.json b/resources/profiles/Creality/filament/fdm_filament_common.json index 22c32f8ca..9f7797511 100644 --- a/resources/profiles/Creality/filament/fdm_filament_common.json +++ b/resources/profiles/Creality/filament/fdm_filament_common.json @@ -84,6 +84,9 @@ "filament_z_hop": [ "nil" ], + "filament_z_hop_types": [ + "nil" + ], "filament_retract_restart_extra": [ "nil" ], diff --git a/resources/profiles/Voron.json b/resources/profiles/Voron.json index ba08b348c..7e4e4975d 100644 --- a/resources/profiles/Voron.json +++ b/resources/profiles/Voron.json @@ -1,6 +1,6 @@ { "name": "Voron", - "version": "01.05.00.01", + "version": "01.05.00.02", "force_update": "0", "description": "Voron configurations", "machine_model_list": [ diff --git a/resources/profiles/Voron/filament/fdm_filament_common.json b/resources/profiles/Voron/filament/fdm_filament_common.json index 22c32f8ca..9f7797511 100644 --- a/resources/profiles/Voron/filament/fdm_filament_common.json +++ b/resources/profiles/Voron/filament/fdm_filament_common.json @@ -84,6 +84,9 @@ "filament_z_hop": [ "nil" ], + "filament_z_hop_types": [ + "nil" + ], "filament_retract_restart_extra": [ "nil" ], diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index a20fdf80c..382cfcc86 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -298,9 +298,16 @@ ConfigOption* ConfigOptionDef::create_default_option() const return new ConfigOptionEnumGeneric(this->enum_keys_map, this->default_value->getInt()); if (type == coEnums) { - ConfigOptionEnumsGeneric* opt = dynamic_cast(this->default_value->clone()); - opt->keys_map = this->enum_keys_map; - return opt; + auto dft = this->default_value->clone(); + if (dft->nullable()) { + ConfigOptionEnumsGenericNullable *opt = dynamic_cast(this->default_value->clone()); + opt->keys_map = this->enum_keys_map; + return opt; + } else { + ConfigOptionEnumsGeneric *opt = dynamic_cast(this->default_value->clone()); + opt->keys_map = this->enum_keys_map; + return opt; + } } return this->default_value->clone(); diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 3c7f13092..f3ab945ce 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -771,6 +771,8 @@ public: ConfigOptionIntsTempl() : ConfigOptionVector() {} explicit ConfigOptionIntsTempl(size_t n, int value) : ConfigOptionVector(n, value) {} explicit ConfigOptionIntsTempl(std::initializer_list il) : ConfigOptionVector(std::move(il)) {} + explicit ConfigOptionIntsTempl(const std::vector &vec) : ConfigOptionVector(vec) {} + explicit ConfigOptionIntsTempl(std::vector &&vec) : ConfigOptionVector(std::move(vec)) {} static ConfigOptionType static_type() { return coInts; } ConfigOptionType type() const override { return static_type(); } @@ -1640,33 +1642,37 @@ private: }; // BBS -class ConfigOptionEnumsGeneric : public ConfigOptionInts +template +class ConfigOptionEnumsGenericTempl : public ConfigOptionInts { public: - ConfigOptionEnumsGeneric(const t_config_enum_values* keys_map = nullptr) : keys_map(keys_map) {} - explicit ConfigOptionEnumsGeneric(const t_config_enum_values* keys_map, size_t size, int value) : ConfigOptionInts(size, value), keys_map(keys_map) {} - explicit ConfigOptionEnumsGeneric(std::initializer_list il) : ConfigOptionInts(std::move(il)), keys_map(keys_map) {} + ConfigOptionEnumsGenericTempl(const t_config_enum_values *keys_map = nullptr) : keys_map(keys_map) {} + explicit ConfigOptionEnumsGenericTempl(const t_config_enum_values *keys_map, size_t size, int value) : ConfigOptionInts(size, value), keys_map(keys_map) {} + explicit ConfigOptionEnumsGenericTempl(std::initializer_list il) : ConfigOptionInts(std::move(il)), keys_map(keys_map) {} + explicit ConfigOptionEnumsGenericTempl(const std::vector &vec) : ConfigOptionInts(vec) {} + explicit ConfigOptionEnumsGenericTempl(std::vector &&vec) : ConfigOptionInts(std::move(vec)) {} const t_config_enum_values* keys_map = nullptr; static ConfigOptionType static_type() { return coEnums; } ConfigOptionType type() const override { return static_type(); } - ConfigOption* clone() const override { return new ConfigOptionEnumsGeneric(*this); } - ConfigOptionEnumsGeneric& operator= (const ConfigOption* opt) { this->set(opt); return *this; } - bool operator< (const ConfigOptionIntsTempl& rhs) const throw() { return this->values < rhs.values; } + ConfigOption* clone() const override { return new ConfigOptionEnumsGenericTempl(*this); } + ConfigOptionEnumsGenericTempl& operator= (const ConfigOption* opt) { this->set(opt); return *this; } + bool operator< (const ConfigOptionInts& rhs) const throw() { return this->values < rhs.values; } - bool operator==(const ConfigOptionIntsTempl& rhs) const throw() + bool operator==(const ConfigOptionInts& rhs) const throw() { if (rhs.type() != this->type()) throw ConfigurationError("ConfigOptionEnumsGeneric: Comparing incompatible types"); return this->values == rhs.values; } + bool nullable() const override { return NULLABLE; } void set(const ConfigOption* rhs) override { if (rhs->type() != this->type()) throw ConfigurationError("ConfigOptionEnumGeneric: Assigning an incompatible type"); // rhs could be of the following type: ConfigOptionEnumsGeneric - this->values = dynamic_cast(rhs)->values; + this->values = dynamic_cast(rhs)->values; } std::string serialize() const override @@ -1701,7 +1707,10 @@ public: while (std::getline(is, item_str, ',')) { boost::trim(item_str); if (item_str == "nil") { - return false; + if (NULLABLE) + this->values.push_back(nil_value()); + else + throw ConfigurationError("Deserializing nil into a non-nullable object"); } else { auto it = this->keys_map->find(item_str); @@ -1716,15 +1725,26 @@ public: private: void serialize_single_value(std::ostringstream& ss, const int v) const { - for (const auto& kvp : *this->keys_map) - if (kvp.second == v) - ss << kvp.first; + if (v == nil_value()) { + if (NULLABLE) + ss << "nil"; + else + throw ConfigurationError("Serializing NaN"); + } + else { + for (const auto& kvp : *this->keys_map) + if (kvp.second == v) + ss << kvp.first; + } } friend class cereal::access; template void serialize(Archive& ar) { ar(cereal::base_class>(this)); } }; +using ConfigOptionEnumsGeneric = ConfigOptionEnumsGenericTempl; +using ConfigOptionEnumsGenericNullable = ConfigOptionEnumsGenericTempl; + // Definition of a configuration value for the purpose of GUI presentation, editing, value mapping and config file handling. class ConfigOptionDef { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index f223fd007..96e589407 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -3178,9 +3178,9 @@ std::string GCode::change_layer(coordf_t print_z, bool lazy_raise) //coordf_t z = print_z + m_config.z_offset.value; // in unscaled coordinates coordf_t z = print_z; // in unscaled coordinates if (EXTRUDER_CONFIG(retract_when_changing_layer) && m_writer.will_move_z(z)) { - LiftType lift_type = this->to_lift_type(m_config.z_hop_type); + LiftType lift_type = this->to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types))); //BBS: force to use SpiralLift when change layer if lift type is auto - gcode += this->retract(false, false, m_config.z_hop_type == ZHopType::zhtAuto? LiftType::SpiralLift : lift_type); + gcode += this->retract(false, false, ZHopType(EXTRUDER_CONFIG(z_hop_types)) == ZHopType::zhtAuto ? LiftType::SpiralLift : lift_type); } if (!lazy_raise) { @@ -3894,8 +3894,8 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string } //BBS -LiftType GCode::to_lift_type(ZHopType z_hop_type) { - switch (z_hop_type) +LiftType GCode::to_lift_type(ZHopType z_hop_types) { + switch (z_hop_types) { case ZHopType::zhtNormal: return LiftType::NormalLift; @@ -3966,11 +3966,11 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp //BBS: force to retract when leave from external perimeter for a long travel //Better way is judging whether the travel move direction is same with last extrusion move. if (is_perimeter(m_last_processor_extrusion_role) && m_last_processor_extrusion_role != erPerimeter) { - if (m_config.z_hop_type == ZHopType::zhtAuto) { + if (ZHopType(EXTRUDER_CONFIG(z_hop_types)) == ZHopType::zhtAuto) { lift_type = is_through_overhang(clipped_travel) ? LiftType::SpiralLift : LiftType::LazyLift; } else { - lift_type = to_lift_type(m_config.z_hop_type); + lift_type = to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types))); } return true; } @@ -3998,11 +3998,11 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp return false; // retract if reduce_infill_retraction is disabled or doesn't apply when role is perimeter - if (m_config.z_hop_type == ZHopType::zhtAuto) { + if (ZHopType(EXTRUDER_CONFIG(z_hop_types)) == ZHopType::zhtAuto) { lift_type = is_through_overhang(clipped_travel) ? LiftType::SpiralLift : LiftType::LazyLift; } else { - lift_type = to_lift_type(m_config.z_hop_type); + lift_type = to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types))); } return true; } diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 58f744a91..b7132bbc3 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -396,7 +396,7 @@ private: std::string travel_to(const Point &point, ExtrusionRole role, std::string comment); // BBS - LiftType to_lift_type(ZHopType z_hop_type); + LiftType to_lift_type(ZHopType z_hop_types); // BBS: detect lift type in needs_retraction bool needs_retraction(const Polyline& travel, ExtrusionRole role, LiftType& lift_type); std::string retract(bool toolchange = false, bool is_last_retraction = false, LiftType lift_type = LiftType::SpiralLift); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 1666572f9..69a20ba8a 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -763,7 +763,7 @@ static std::vector s_Preset_filament_options { "fan_max_speed", "enable_overhang_bridge_fan", "overhang_fan_speed", "overhang_fan_threshold", "close_fan_the_first_x_layers", "full_fan_speed_layer", "fan_cooling_layer_time", "slow_down_layer_time", "slow_down_min_speed", "filament_start_gcode", "filament_end_gcode", // Retract overrides - "filament_retraction_length", "filament_z_hop", "filament_retraction_speed", "filament_deretraction_speed", "filament_retract_restart_extra", "filament_retraction_minimum_travel", + "filament_retraction_length", "filament_z_hop", "filament_z_hop_types", "filament_retraction_speed", "filament_deretraction_speed", "filament_retract_restart_extra", "filament_retraction_minimum_travel", "filament_retract_when_changing_layer", "filament_wipe", "filament_retract_before_wipe", // Profile compatibility "filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits", @@ -789,7 +789,7 @@ static std::vector s_Preset_printer_options { "silent_mode", // BBS "scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time", "machine_pause_gcode", "template_custom_gcode", - "nozzle_type", "nozzle_hrc","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_type", + "nozzle_type", "nozzle_hrc","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types", //SoftFever "host_type", "print_host", "printhost_apikey", "printhost_cafile","printhost_port","printhost_authorization_type", diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 5beba7d5b..a09f0a9c5 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -225,7 +225,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n osteps.emplace_back(posSimplifySupportPath); steps.emplace_back(psSkirtBrim); } - else if (opt_key == "z_hop_type") { + else if (opt_key == "z_hop_types") { osteps.emplace_back(posDetectOverhangsForLift); } else { // for legacy, if we can't handle this option let's invalidate all steps diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index a3ed0a940..4145c5af6 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2147,7 +2147,7 @@ void PrintConfigDef::init_fff_params() def->mode = comSimple; def->set_default_value(new ConfigOptionFloats { 0.4 }); - def = this->add("z_hop_type", coEnum); + def = this->add("z_hop_types", coEnums); def->label = L("Z Hop Type"); def->tooltip = L(""); def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); @@ -2160,7 +2160,7 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Slope")); def->enum_labels.push_back(L("Spiral")); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionEnum{ ZHopType::zhtSpiral }); + def->set_default_value(new ConfigOptionEnumsGeneric{ ZHopType::zhtSpiral }); def = this->add("retract_restart_extra", coFloats); //def->label = L("Extra length on restart"); @@ -3085,7 +3085,7 @@ void PrintConfigDef::init_fff_params() // Declare retract values for filament profile, overriding the printer's extruder profile. for (const char *opt_key : { // floats - "retraction_length", "z_hop", "retraction_speed", "deretraction_speed", "retract_restart_extra", "retraction_minimum_travel", + "retraction_length", "z_hop", "z_hop_types", "retraction_speed", "deretraction_speed", "retract_restart_extra", "retraction_minimum_travel", // BBS: floats "wipe_distance", // bools @@ -3099,6 +3099,9 @@ void PrintConfigDef::init_fff_params() def->full_label = it_opt->second.full_label; def->tooltip = it_opt->second.tooltip; def->sidetext = it_opt->second.sidetext; + def->enum_keys_map = it_opt->second.enum_keys_map; + def->enum_labels = it_opt->second.enum_labels; + def->enum_values = it_opt->second.enum_values; //BBS: shown specific filament retract config because we hide the machine retract into comDevelop mode if ((strcmp(opt_key, "retraction_length") == 0) || (strcmp(opt_key, "z_hop") == 0)) @@ -3109,6 +3112,7 @@ void PrintConfigDef::init_fff_params() case coFloats : def->set_default_value(new ConfigOptionFloatsNullable (static_cast(it_opt->second.default_value.get())->values)); break; case coPercents : def->set_default_value(new ConfigOptionPercentsNullable(static_cast(it_opt->second.default_value.get())->values)); break; case coBools : def->set_default_value(new ConfigOptionBoolsNullable (static_cast(it_opt->second.default_value.get())->values)); break; + case coEnums : def->set_default_value(new ConfigOptionEnumsGenericNullable(static_cast(it_opt->second.default_value.get())->values)); break; default: assert(false); } } @@ -3128,7 +3132,7 @@ void PrintConfigDef::init_extruder_option_keys() // ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings m_extruder_option_keys = { "nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset", - "retraction_length", "z_hop", "retraction_speed", "deretraction_speed", + "retraction_length", "z_hop", "z_hop_types", "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", "default_filament_profile" @@ -3144,7 +3148,8 @@ void PrintConfigDef::init_extruder_option_keys() "retraction_speed", "wipe", "wipe_distance", - "z_hop" + "z_hop", + "z_hop_types" }; assert(std::is_sorted(m_extruder_retract_keys.begin(), m_extruder_retract_keys.end())); } @@ -3153,7 +3158,7 @@ void PrintConfigDef::init_filament_option_keys() { m_filament_option_keys = { "filament_diameter", "min_layer_height", "max_layer_height", - "retraction_length", "z_hop", "retraction_speed", "deretraction_speed", + "retraction_length", "z_hop", "z_hop_types", "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", "default_filament_profile" @@ -3169,7 +3174,8 @@ void PrintConfigDef::init_filament_option_keys() "retraction_speed", "wipe", "wipe_distance", - "z_hop" + "z_hop", + "z_hop_types" }; assert(std::is_sorted(m_filament_retract_keys.begin(), m_filament_retract_keys.end())); } @@ -3895,7 +3901,8 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va "support_closing_radius", "remove_freq_sweep", "remove_bed_leveling", "remove_extrusion_calibration", "support_transition_line_width", "support_transition_speed", "bed_temperature", "bed_temperature_initial_layer", - "can_switch_nozzle_type", "can_add_auxiliary_fan", "extra_flush_volume", "spaghetti_detector", "adaptive_layer_height" + "can_switch_nozzle_type", "can_add_auxiliary_fan", "extra_flush_volume", "spaghetti_detector", "adaptive_layer_height", + "z_hop_type" }; if (ignore.find(opt_key) != ignore.end()) { diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 31730987b..8708e1c67 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -823,7 +823,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloats, retract_length_toolchange)) ((ConfigOptionFloats, z_hop)) // BBS - ((ConfigOptionEnum, z_hop_type)) + ((ConfigOptionEnumsGeneric, z_hop_types)) ((ConfigOptionFloats, retract_restart_extra)) ((ConfigOptionFloats, retract_restart_extra_toolchange)) ((ConfigOptionFloats, retraction_speed)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index b0705873d..6e9431801 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -431,9 +431,6 @@ void PrintObject::detect_overhangs_for_lift() this->clear_overhangs_for_lift(); - if (m_print->config().z_hop_type != ZHopType::zhtAuto) - return; - tbb::spin_mutex layer_storage_mutex; tbb::parallel_for(tbb::blocked_range(num_raft_layers + 1, num_layers), [this, min_overlap](const tbb::blocked_range& range) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 3bc19396c..3882892b1 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1021,6 +1021,9 @@ void Choice::BUILD() if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); + if (m_opt.nullable) + m_last_meaningful_value = dynamic_cast(m_opt.default_value.get())->get_at(0); + choice_ctrl* temp; auto dynamic_list = dynamic_lists.find(m_opt.opt_key); if (dynamic_list != dynamic_lists.end()) @@ -1209,7 +1212,7 @@ void Choice::set_selection() void Choice::set_value(const std::string& value, bool change_event) //! Redundant? { - m_disable_change_event = !change_event; + m_disable_change_event = !change_event; size_t idx=0; for (auto el : m_opt.enum_values) @@ -1305,6 +1308,12 @@ void Choice::set_value(const boost::any& value, bool change_event) auto it = std::find(values.begin(), values.end(), key); val = it == values.end() ? 0 : it - values.begin(); } + if (m_opt.nullable) { + if (val != ConfigOptionEnumsGenericNullable::nil_value()) + m_last_meaningful_value = value; + else + val = -1; + } field->SetSelection(val); break; } @@ -1370,7 +1379,9 @@ boost::any& Choice::get_value() // BBS if (m_opt.type == coEnum || m_opt.type == coEnums) { - if (m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" || m_opt_id == "sparse_infill_pattern" || m_opt_id == "support_style") { + if (m_opt.nullable && field->GetSelection() == -1) + m_value = ConfigOptionEnumsGenericNullable::nil_value(); + else if (m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" || m_opt_id == "sparse_infill_pattern" || m_opt_id == "support_style") { const std::string& key = m_opt.enum_values[field->GetSelection()]; m_value = int(m_opt.enum_keys_map->at(key)); } @@ -1404,6 +1415,20 @@ boost::any& Choice::get_value() return m_value; } +void Choice::set_last_meaningful_value() +{ + if (m_opt.nullable) { + set_value(m_last_meaningful_value, false); + on_change_field(); + } +} + +void Choice::set_na_value() +{ + dynamic_cast(window)->SetSelection(-1); + on_change_field(); +} + void Choice::enable() { dynamic_cast(window)->Enable(); } void Choice::disable() { dynamic_cast(window)->Disable(); } diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index 879cbdb46..1a997a8eb 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -386,6 +386,9 @@ public: void set_values(const wxArrayString &values); boost::any& get_value() override; + void set_last_meaningful_value() override; + void set_na_value() override; + void msw_rescale() override; void enable() override ;//{ dynamic_cast(window)->Enable(); }; diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 11f043d5e..3a4787e2e 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -951,6 +951,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config case coInts: ret = config.option(opt_key)->get_at(idx); break; + case coEnums: + ret = config.option(opt_key)->get_at(idx); + break; default: break; } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 0450d9854..b52eb1a50 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2461,6 +2461,7 @@ void TabFilament::add_filament_overrides_page() for (const std::string opt_key : { "filament_retraction_length", "filament_z_hop", + "filament_z_hop_types", "filament_retraction_speed", "filament_deretraction_speed", //"filament_retract_restart_extra", @@ -2492,6 +2493,7 @@ void TabFilament::update_filament_overrides_page() std::vector opt_keys = { "filament_retraction_length", "filament_z_hop", + "filament_z_hop_types", "filament_retraction_speed", "filament_deretraction_speed", //"filament_retract_restart_extra", @@ -3350,7 +3352,7 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/) optgroup = page->new_optgroup(L("Retraction"), L"param_retraction"); optgroup->append_single_option_line("retraction_length", "", extruder_idx); optgroup->append_single_option_line("z_hop", "", extruder_idx); - optgroup->append_single_option_line("z_hop_type", ""); + optgroup->append_single_option_line("z_hop_types", ""); optgroup->append_single_option_line("retraction_speed", "", extruder_idx); optgroup->append_single_option_line("deretraction_speed", "", extruder_idx); //optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);