ENH: support filament_z_hop_types

Support override z top type in filament

This is handling for STUDIO-2082

Change-Id: I885d1d5e44d626e28b260ff569d0359e462a5f8d
This commit is contained in:
chunmao.guo 2023-02-09 17:02:41 +08:00 committed by Lane.Wei
parent 3a14acba99
commit cbb84d2fb6
22 changed files with 126 additions and 48 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "Anycubic", "name": "Anycubic",
"version": "01.05.00.01", "version": "01.05.00.02",
"force_update": "0", "force_update": "0",
"description": "Anycubic configurations", "description": "Anycubic configurations",
"machine_model_list": [ "machine_model_list": [

View File

@ -78,6 +78,9 @@
"filament_z_hop": [ "filament_z_hop": [
"nil" "nil"
], ],
"filament_z_hop_types": [
"nil"
],
"filament_retract_restart_extra": [ "filament_retract_restart_extra": [
"nil" "nil"
], ],

View File

@ -1,7 +1,7 @@
{ {
"name": "Bambulab", "name": "Bambulab",
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json", "url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
"version": "01.05.00.10", "version": "01.05.00.11",
"force_update": "0", "force_update": "0",
"description": "the initial version of BBL configurations", "description": "the initial version of BBL configurations",
"machine_model_list": [ "machine_model_list": [

View File

@ -87,6 +87,9 @@
"filament_z_hop": [ "filament_z_hop": [
"nil" "nil"
], ],
"filament_z_hop_types": [
"nil"
],
"filament_retract_restart_extra": [ "filament_retract_restart_extra": [
"nil" "nil"
], ],

View File

@ -151,7 +151,9 @@
"deretraction_speed": [ "deretraction_speed": [
"30" "30"
], ],
"z_hop_type": "Auto Lift", "z_hop_types": [
"Auto Lift"
],
"nozzle_type": "hardened_steel", "nozzle_type": "hardened_steel",
"silent_mode": "0", "silent_mode": "0",
"single_extruder_multi_material": "1", "single_extruder_multi_material": "1",

View File

@ -1,6 +1,6 @@
{ {
"name": "Creality", "name": "Creality",
"version": "01.05.00.01", "version": "01.05.00.02",
"force_update": "0", "force_update": "0",
"description": "Creality configurations", "description": "Creality configurations",
"machine_model_list": [ "machine_model_list": [

View File

@ -84,6 +84,9 @@
"filament_z_hop": [ "filament_z_hop": [
"nil" "nil"
], ],
"filament_z_hop_types": [
"nil"
],
"filament_retract_restart_extra": [ "filament_retract_restart_extra": [
"nil" "nil"
], ],

View File

@ -1,6 +1,6 @@
{ {
"name": "Voron", "name": "Voron",
"version": "01.05.00.01", "version": "01.05.00.02",
"force_update": "0", "force_update": "0",
"description": "Voron configurations", "description": "Voron configurations",
"machine_model_list": [ "machine_model_list": [

View File

@ -84,6 +84,9 @@
"filament_z_hop": [ "filament_z_hop": [
"nil" "nil"
], ],
"filament_z_hop_types": [
"nil"
],
"filament_retract_restart_extra": [ "filament_retract_restart_extra": [
"nil" "nil"
], ],

View File

@ -298,10 +298,17 @@ ConfigOption* ConfigOptionDef::create_default_option() const
return new ConfigOptionEnumGeneric(this->enum_keys_map, this->default_value->getInt()); return new ConfigOptionEnumGeneric(this->enum_keys_map, this->default_value->getInt());
if (type == coEnums) { if (type == coEnums) {
auto dft = this->default_value->clone();
if (dft->nullable()) {
ConfigOptionEnumsGenericNullable *opt = dynamic_cast<ConfigOptionEnumsGenericNullable *>(this->default_value->clone());
opt->keys_map = this->enum_keys_map;
return opt;
} else {
ConfigOptionEnumsGeneric *opt = dynamic_cast<ConfigOptionEnumsGeneric *>(this->default_value->clone()); ConfigOptionEnumsGeneric *opt = dynamic_cast<ConfigOptionEnumsGeneric *>(this->default_value->clone());
opt->keys_map = this->enum_keys_map; opt->keys_map = this->enum_keys_map;
return opt; return opt;
} }
}
return this->default_value->clone(); return this->default_value->clone();
} }

View File

@ -771,6 +771,8 @@ public:
ConfigOptionIntsTempl() : ConfigOptionVector<int>() {} ConfigOptionIntsTempl() : ConfigOptionVector<int>() {}
explicit ConfigOptionIntsTempl(size_t n, int value) : ConfigOptionVector<int>(n, value) {} explicit ConfigOptionIntsTempl(size_t n, int value) : ConfigOptionVector<int>(n, value) {}
explicit ConfigOptionIntsTempl(std::initializer_list<int> il) : ConfigOptionVector<int>(std::move(il)) {} explicit ConfigOptionIntsTempl(std::initializer_list<int> il) : ConfigOptionVector<int>(std::move(il)) {}
explicit ConfigOptionIntsTempl(const std::vector<int> &vec) : ConfigOptionVector<int>(vec) {}
explicit ConfigOptionIntsTempl(std::vector<int> &&vec) : ConfigOptionVector<int>(std::move(vec)) {}
static ConfigOptionType static_type() { return coInts; } static ConfigOptionType static_type() { return coInts; }
ConfigOptionType type() const override { return static_type(); } ConfigOptionType type() const override { return static_type(); }
@ -1640,33 +1642,37 @@ private:
}; };
// BBS // BBS
class ConfigOptionEnumsGeneric : public ConfigOptionInts template <bool NULLABLE>
class ConfigOptionEnumsGenericTempl : public ConfigOptionInts
{ {
public: public:
ConfigOptionEnumsGeneric(const t_config_enum_values* keys_map = nullptr) : keys_map(keys_map) {} ConfigOptionEnumsGenericTempl(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 ConfigOptionEnumsGenericTempl(const t_config_enum_values *keys_map, size_t size, int value) : ConfigOptionInts(size, value), keys_map(keys_map) {}
explicit ConfigOptionEnumsGeneric(std::initializer_list<int> il) : ConfigOptionInts(std::move(il)), keys_map(keys_map) {} explicit ConfigOptionEnumsGenericTempl(std::initializer_list<int> il) : ConfigOptionInts(std::move(il)), keys_map(keys_map) {}
explicit ConfigOptionEnumsGenericTempl(const std::vector<int> &vec) : ConfigOptionInts(vec) {}
explicit ConfigOptionEnumsGenericTempl(std::vector<int> &&vec) : ConfigOptionInts(std::move(vec)) {}
const t_config_enum_values* keys_map = nullptr; const t_config_enum_values* keys_map = nullptr;
static ConfigOptionType static_type() { return coEnums; } static ConfigOptionType static_type() { return coEnums; }
ConfigOptionType type() const override { return static_type(); } ConfigOptionType type() const override { return static_type(); }
ConfigOption* clone() const override { return new ConfigOptionEnumsGeneric(*this); } ConfigOption* clone() const override { return new ConfigOptionEnumsGenericTempl(*this); }
ConfigOptionEnumsGeneric& operator= (const ConfigOption* opt) { this->set(opt); return *this; } ConfigOptionEnumsGenericTempl& operator= (const ConfigOption* opt) { this->set(opt); return *this; }
bool operator< (const ConfigOptionIntsTempl& rhs) const throw() { return this->values < rhs.values; } 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()) if (rhs.type() != this->type())
throw ConfigurationError("ConfigOptionEnumsGeneric: Comparing incompatible types"); throw ConfigurationError("ConfigOptionEnumsGeneric: Comparing incompatible types");
return this->values == rhs.values; return this->values == rhs.values;
} }
bool nullable() const override { return NULLABLE; }
void set(const ConfigOption* rhs) override { void set(const ConfigOption* rhs) override {
if (rhs->type() != this->type()) if (rhs->type() != this->type())
throw ConfigurationError("ConfigOptionEnumGeneric: Assigning an incompatible type"); throw ConfigurationError("ConfigOptionEnumGeneric: Assigning an incompatible type");
// rhs could be of the following type: ConfigOptionEnumsGeneric // rhs could be of the following type: ConfigOptionEnumsGeneric
this->values = dynamic_cast<const ConfigOptionEnumsGeneric*>(rhs)->values; this->values = dynamic_cast<const ConfigOptionEnumsGenericTempl *>(rhs)->values;
} }
std::string serialize() const override std::string serialize() const override
@ -1701,7 +1707,10 @@ public:
while (std::getline(is, item_str, ',')) { while (std::getline(is, item_str, ',')) {
boost::trim(item_str); boost::trim(item_str);
if (item_str == "nil") { 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 { else {
auto it = this->keys_map->find(item_str); auto it = this->keys_map->find(item_str);
@ -1716,15 +1725,26 @@ public:
private: private:
void serialize_single_value(std::ostringstream& ss, const int v) const void serialize_single_value(std::ostringstream& ss, const int v) const
{ {
if (v == nil_value()) {
if (NULLABLE)
ss << "nil";
else
throw ConfigurationError("Serializing NaN");
}
else {
for (const auto& kvp : *this->keys_map) for (const auto& kvp : *this->keys_map)
if (kvp.second == v) if (kvp.second == v)
ss << kvp.first; ss << kvp.first;
} }
}
friend class cereal::access; friend class cereal::access;
template<class Archive> void serialize(Archive& ar) { ar(cereal::base_class<ConfigOptionVector<int>>(this)); } template<class Archive> void serialize(Archive& ar) { ar(cereal::base_class<ConfigOptionVector<int>>(this)); }
}; };
using ConfigOptionEnumsGeneric = ConfigOptionEnumsGenericTempl<false>;
using ConfigOptionEnumsGenericNullable = ConfigOptionEnumsGenericTempl<true>;
// Definition of a configuration value for the purpose of GUI presentation, editing, value mapping and config file handling. // Definition of a configuration value for the purpose of GUI presentation, editing, value mapping and config file handling.
class ConfigOptionDef class ConfigOptionDef
{ {

View File

@ -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 + m_config.z_offset.value; // in unscaled coordinates
coordf_t z = print_z; // in unscaled coordinates coordf_t z = print_z; // in unscaled coordinates
if (EXTRUDER_CONFIG(retract_when_changing_layer) && m_writer.will_move_z(z)) { 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 //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) { if (!lazy_raise) {
@ -3894,8 +3894,8 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
} }
//BBS //BBS
LiftType GCode::to_lift_type(ZHopType z_hop_type) { LiftType GCode::to_lift_type(ZHopType z_hop_types) {
switch (z_hop_type) switch (z_hop_types)
{ {
case ZHopType::zhtNormal: case ZHopType::zhtNormal:
return LiftType::NormalLift; 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 //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. //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 (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; lift_type = is_through_overhang(clipped_travel) ? LiftType::SpiralLift : LiftType::LazyLift;
} }
else { else {
lift_type = to_lift_type(m_config.z_hop_type); lift_type = to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types)));
} }
return true; return true;
} }
@ -3998,11 +3998,11 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp
return false; return false;
// retract if reduce_infill_retraction is disabled or doesn't apply when role is perimeter // 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; lift_type = is_through_overhang(clipped_travel) ? LiftType::SpiralLift : LiftType::LazyLift;
} }
else { else {
lift_type = to_lift_type(m_config.z_hop_type); lift_type = to_lift_type(ZHopType(EXTRUDER_CONFIG(z_hop_types)));
} }
return true; return true;
} }

View File

@ -396,7 +396,7 @@ private:
std::string travel_to(const Point &point, ExtrusionRole role, std::string comment); std::string travel_to(const Point &point, ExtrusionRole role, std::string comment);
// BBS // BBS
LiftType to_lift_type(ZHopType z_hop_type); LiftType to_lift_type(ZHopType z_hop_types);
// BBS: detect lift type in needs_retraction // BBS: detect lift type in needs_retraction
bool needs_retraction(const Polyline& travel, ExtrusionRole role, LiftType& lift_type); 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); std::string retract(bool toolchange = false, bool is_last_retraction = false, LiftType lift_type = LiftType::SpiralLift);

View File

@ -763,7 +763,7 @@ static std::vector<std::string> 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", "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", "filament_start_gcode", "filament_end_gcode",
// Retract overrides // 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", "filament_retract_when_changing_layer", "filament_wipe", "filament_retract_before_wipe",
// Profile compatibility // Profile compatibility
"filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits", "filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits",
@ -789,7 +789,7 @@ static std::vector<std::string> s_Preset_printer_options {
"silent_mode", "silent_mode",
// BBS // BBS
"scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time", "machine_pause_gcode", "template_custom_gcode", "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 //SoftFever
"host_type", "print_host", "printhost_apikey", "host_type", "print_host", "printhost_apikey",
"printhost_cafile","printhost_port","printhost_authorization_type", "printhost_cafile","printhost_port","printhost_authorization_type",

View File

@ -225,7 +225,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
osteps.emplace_back(posSimplifySupportPath); osteps.emplace_back(posSimplifySupportPath);
steps.emplace_back(psSkirtBrim); steps.emplace_back(psSkirtBrim);
} }
else if (opt_key == "z_hop_type") { else if (opt_key == "z_hop_types") {
osteps.emplace_back(posDetectOverhangsForLift); osteps.emplace_back(posDetectOverhangsForLift);
} else { } else {
// for legacy, if we can't handle this option let's invalidate all steps // for legacy, if we can't handle this option let's invalidate all steps

View File

@ -2147,7 +2147,7 @@ void PrintConfigDef::init_fff_params()
def->mode = comSimple; def->mode = comSimple;
def->set_default_value(new ConfigOptionFloats { 0.4 }); 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->label = L("Z Hop Type");
def->tooltip = L(""); def->tooltip = L("");
def->enum_keys_map = &ConfigOptionEnum<ZHopType>::get_enum_values(); def->enum_keys_map = &ConfigOptionEnum<ZHopType>::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("Slope"));
def->enum_labels.push_back(L("Spiral")); def->enum_labels.push_back(L("Spiral"));
def->mode = comAdvanced; 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 = this->add("retract_restart_extra", coFloats);
//def->label = L("Extra length on restart"); //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. // Declare retract values for filament profile, overriding the printer's extruder profile.
for (const char *opt_key : { for (const char *opt_key : {
// floats // 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 // BBS: floats
"wipe_distance", "wipe_distance",
// bools // bools
@ -3099,6 +3099,9 @@ void PrintConfigDef::init_fff_params()
def->full_label = it_opt->second.full_label; def->full_label = it_opt->second.full_label;
def->tooltip = it_opt->second.tooltip; def->tooltip = it_opt->second.tooltip;
def->sidetext = it_opt->second.sidetext; 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 //BBS: shown specific filament retract config because we hide the machine retract into comDevelop mode
if ((strcmp(opt_key, "retraction_length") == 0) || if ((strcmp(opt_key, "retraction_length") == 0) ||
(strcmp(opt_key, "z_hop") == 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<const ConfigOptionFloats* >(it_opt->second.default_value.get())->values)); break; case coFloats : def->set_default_value(new ConfigOptionFloatsNullable (static_cast<const ConfigOptionFloats* >(it_opt->second.default_value.get())->values)); break;
case coPercents : def->set_default_value(new ConfigOptionPercentsNullable(static_cast<const ConfigOptionPercents*>(it_opt->second.default_value.get())->values)); break; case coPercents : def->set_default_value(new ConfigOptionPercentsNullable(static_cast<const ConfigOptionPercents*>(it_opt->second.default_value.get())->values)); break;
case coBools : def->set_default_value(new ConfigOptionBoolsNullable (static_cast<const ConfigOptionBools* >(it_opt->second.default_value.get())->values)); break; case coBools : def->set_default_value(new ConfigOptionBoolsNullable (static_cast<const ConfigOptionBools* >(it_opt->second.default_value.get())->values)); break;
case coEnums : def->set_default_value(new ConfigOptionEnumsGenericNullable(static_cast<const ConfigOptionEnumsGeneric* >(it_opt->second.default_value.get())->values)); break;
default: assert(false); default: assert(false);
} }
} }
@ -3128,7 +3132,7 @@ void PrintConfigDef::init_extruder_option_keys()
// ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings // ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings
m_extruder_option_keys = { m_extruder_option_keys = {
"nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset", "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_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance",
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour",
"default_filament_profile" "default_filament_profile"
@ -3144,7 +3148,8 @@ void PrintConfigDef::init_extruder_option_keys()
"retraction_speed", "retraction_speed",
"wipe", "wipe",
"wipe_distance", "wipe_distance",
"z_hop" "z_hop",
"z_hop_types"
}; };
assert(std::is_sorted(m_extruder_retract_keys.begin(), m_extruder_retract_keys.end())); 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 = { m_filament_option_keys = {
"filament_diameter", "min_layer_height", "max_layer_height", "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_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance",
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour",
"default_filament_profile" "default_filament_profile"
@ -3169,7 +3174,8 @@ void PrintConfigDef::init_filament_option_keys()
"retraction_speed", "retraction_speed",
"wipe", "wipe",
"wipe_distance", "wipe_distance",
"z_hop" "z_hop",
"z_hop_types"
}; };
assert(std::is_sorted(m_filament_retract_keys.begin(), m_filament_retract_keys.end())); 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", "support_closing_radius",
"remove_freq_sweep", "remove_bed_leveling", "remove_extrusion_calibration", "remove_freq_sweep", "remove_bed_leveling", "remove_extrusion_calibration",
"support_transition_line_width", "support_transition_speed", "bed_temperature", "bed_temperature_initial_layer", "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()) { if (ignore.find(opt_key) != ignore.end()) {

View File

@ -823,7 +823,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloats, retract_length_toolchange)) ((ConfigOptionFloats, retract_length_toolchange))
((ConfigOptionFloats, z_hop)) ((ConfigOptionFloats, z_hop))
// BBS // BBS
((ConfigOptionEnum<ZHopType>, z_hop_type)) ((ConfigOptionEnumsGeneric, z_hop_types))
((ConfigOptionFloats, retract_restart_extra)) ((ConfigOptionFloats, retract_restart_extra))
((ConfigOptionFloats, retract_restart_extra_toolchange)) ((ConfigOptionFloats, retract_restart_extra_toolchange))
((ConfigOptionFloats, retraction_speed)) ((ConfigOptionFloats, retraction_speed))

View File

@ -431,9 +431,6 @@ void PrintObject::detect_overhangs_for_lift()
this->clear_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::spin_mutex layer_storage_mutex;
tbb::parallel_for(tbb::blocked_range<size_t>(num_raft_layers + 1, num_layers), tbb::parallel_for(tbb::blocked_range<size_t>(num_raft_layers + 1, num_layers),
[this, min_overlap](const tbb::blocked_range<size_t>& range) [this, min_overlap](const tbb::blocked_range<size_t>& range)

View File

@ -1021,6 +1021,9 @@ void Choice::BUILD()
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); 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.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
if (m_opt.nullable)
m_last_meaningful_value = dynamic_cast<ConfigOptionEnumsGenericNullable const *>(m_opt.default_value.get())->get_at(0);
choice_ctrl* temp; choice_ctrl* temp;
auto dynamic_list = dynamic_lists.find(m_opt.opt_key); auto dynamic_list = dynamic_lists.find(m_opt.opt_key);
if (dynamic_list != dynamic_lists.end()) if (dynamic_list != dynamic_lists.end())
@ -1305,6 +1308,12 @@ void Choice::set_value(const boost::any& value, bool change_event)
auto it = std::find(values.begin(), values.end(), key); auto it = std::find(values.begin(), values.end(), key);
val = it == values.end() ? 0 : it - values.begin(); 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); field->SetSelection(val);
break; break;
} }
@ -1370,7 +1379,9 @@ boost::any& Choice::get_value()
// BBS // BBS
if (m_opt.type == coEnum || m_opt.type == coEnums) 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()]; const std::string& key = m_opt.enum_values[field->GetSelection()];
m_value = int(m_opt.enum_keys_map->at(key)); m_value = int(m_opt.enum_keys_map->at(key));
} }
@ -1404,6 +1415,20 @@ boost::any& Choice::get_value()
return m_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<choice_ctrl *>(window)->SetSelection(-1);
on_change_field();
}
void Choice::enable() { dynamic_cast<choice_ctrl*>(window)->Enable(); } void Choice::enable() { dynamic_cast<choice_ctrl*>(window)->Enable(); }
void Choice::disable() { dynamic_cast<choice_ctrl*>(window)->Disable(); } void Choice::disable() { dynamic_cast<choice_ctrl*>(window)->Disable(); }

View File

@ -386,6 +386,9 @@ public:
void set_values(const wxArrayString &values); void set_values(const wxArrayString &values);
boost::any& get_value() override; boost::any& get_value() override;
void set_last_meaningful_value() override;
void set_na_value() override;
void msw_rescale() override; void msw_rescale() override;
void enable() override ;//{ dynamic_cast<wxBitmapComboBox*>(window)->Enable(); }; void enable() override ;//{ dynamic_cast<wxBitmapComboBox*>(window)->Enable(); };

View File

@ -951,6 +951,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
case coInts: case coInts:
ret = config.option<ConfigOptionIntsNullable>(opt_key)->get_at(idx); ret = config.option<ConfigOptionIntsNullable>(opt_key)->get_at(idx);
break; break;
case coEnums:
ret = config.option<ConfigOptionEnumsGenericNullable>(opt_key)->get_at(idx);
break;
default: default:
break; break;
} }

View File

@ -2461,6 +2461,7 @@ void TabFilament::add_filament_overrides_page()
for (const std::string opt_key : { "filament_retraction_length", for (const std::string opt_key : { "filament_retraction_length",
"filament_z_hop", "filament_z_hop",
"filament_z_hop_types",
"filament_retraction_speed", "filament_retraction_speed",
"filament_deretraction_speed", "filament_deretraction_speed",
//"filament_retract_restart_extra", //"filament_retract_restart_extra",
@ -2492,6 +2493,7 @@ void TabFilament::update_filament_overrides_page()
std::vector<std::string> opt_keys = { "filament_retraction_length", std::vector<std::string> opt_keys = { "filament_retraction_length",
"filament_z_hop", "filament_z_hop",
"filament_z_hop_types",
"filament_retraction_speed", "filament_retraction_speed",
"filament_deretraction_speed", "filament_deretraction_speed",
//"filament_retract_restart_extra", //"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 = page->new_optgroup(L("Retraction"), L"param_retraction");
optgroup->append_single_option_line("retraction_length", "", extruder_idx); 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", "", 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("retraction_speed", "", extruder_idx);
optgroup->append_single_option_line("deretraction_speed", "", extruder_idx); optgroup->append_single_option_line("deretraction_speed", "", extruder_idx);
//optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx); //optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);