diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 2675d1996..9e93783e9 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -474,8 +474,8 @@ t_config_option_keys ConfigBase::diff(const ConfigBase &other) const const ConfigOption *this_opt = this->option(opt_key); const ConfigOption *other_opt = other.option(opt_key); //dirty if both exist, they aren't both phony and value is different - if (this_opt != nullptr && other_opt != nullptr && !(this_opt->phony && other_opt->phony) - && ((*this_opt != *other_opt) || (this_opt->phony != other_opt->phony))) + if (this_opt != nullptr && other_opt != nullptr && !(this_opt->is_phony() && other_opt->is_phony()) + && ((*this_opt != *other_opt) || (this_opt->is_phony() != other_opt->is_phony()))) diff.emplace_back(opt_key); } return diff; @@ -497,7 +497,7 @@ std::string ConfigBase::opt_serialize(const t_config_option_key &opt_key) const { const ConfigOption* opt = this->option(opt_key); assert(opt != nullptr); - if (opt->phony) + if (opt->is_phony()) return ""; return opt->serialize(); } @@ -595,11 +595,11 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con //set phony status if (optdef->can_phony) if(value.empty()) - opt->phony = true; + opt->set_phony(true); else - opt->phony = false; + opt->set_phony(false); else - opt->phony = false; + opt->set_phony(false); return ok; } diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 8dada869b..470ea3eb0 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -215,10 +215,12 @@ inline OutputFormat operator&=(OutputFormat& a, OutputFormat b) { class ConfigOption { public: // if true, this option doesn't need to be saved, it's a computed value from an other configOption. - bool phony; + // uint32_t because macos crash if it's a bool. and it doesn't change the size of the object because of alignment. + uint32_t phony; + ConfigOption() : phony(false) {} - ConfigOption(bool phony) : phony(phony) {} + ConfigOption(bool phony) : phony(uint32_t(phony)) {} virtual ~ConfigOption() {} @@ -240,6 +242,8 @@ public: virtual bool nullable() const { return false; } // A scalar is nil, or all values of a vector are nil. virtual bool is_nil() const { return false; } + bool is_phony() const { return phony != 0; } + void set_phony(bool phony) { this->phony = phony ? 1 : 0; } // Is this option overridden by another option? // An option overrides another option if it is not nil and not equal. virtual bool overriden_by(const ConfigOption *rhs) const { diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index b3c3b3156..6b62f3186 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -1394,8 +1394,8 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi const ConfigOption *this_opt = config_this.option(opt_key); const ConfigOption *other_opt = config_other.option(opt_key); //dirty if both exist, they aren't both phony and value is different - if (this_opt != nullptr && other_opt != nullptr && !(this_opt->phony && other_opt->phony) - && ((*this_opt != *other_opt) || (this_opt->phony != other_opt->phony))) + if (this_opt != nullptr && other_opt != nullptr && !(this_opt->is_phony() && other_opt->is_phony()) + && ((*this_opt != *other_opt) || (this_opt->is_phony() != other_opt->is_phony()))) { if (opt_key == "bed_shape" || opt_key == "thumbnails" || opt_key == "compatible_prints" || opt_key == "compatible_printers") { // Scalar variable, or a vector variable, which is independent from number of extruders, diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 206122361..b9462967a 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -5518,7 +5518,7 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value, if (std::set{"extrusion_width", "first_layer_extrusion_width", "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width"}.count(opt_key) > 0) { const ConfigOptionFloatOrPercent* opt = all_conf.option(opt_key); - if (opt->phony) { + if (opt->is_phony()) { //bypass the phony kill switch from Config::opt_serialize value = opt->serialize(); } @@ -5790,7 +5790,7 @@ bool DynamicPrintConfig::update_phony(const std::vectoroption(key_width); ConfigOptionFloatOrPercent* spacing_option = this->option(key_spacing); if (width_option && spacing_option) - if (!spacing_option->phony && width_option->phony) + if (!spacing_option->is_phony() && width_option->is_phony()) something_changed |= value_changed(key_spacing, config_collection); else something_changed |= value_changed(key_width, config_collection); @@ -5820,8 +5820,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "extrusion_spacing") { ConfigOptionFloatOrPercent* width_option = this->option("extrusion_width"); if (width_option) { - width_option->phony = true; - spacing_option->phony = false; + width_option->set_phony(true); + spacing_option->set_phony(false); width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; @@ -5830,8 +5830,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "first_layer_extrusion_spacing") { ConfigOptionFloatOrPercent* width_option = this->option("first_layer_extrusion_width"); if (width_option) { - width_option->phony = true; - spacing_option->phony = false; + width_option->set_phony(true); + spacing_option->set_phony(false); width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; @@ -5841,8 +5841,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const const ConfigOptionPercent* perimeter_overlap_option = find_option("perimeter_overlap", this, config_collection); ConfigOptionFloatOrPercent* width_option = this->option("perimeter_extrusion_width"); if (width_option && perimeter_overlap_option) { - width_option->phony = true; - spacing_option->phony = false; + width_option->set_phony(true); + spacing_option->set_phony(false); flow.spacing_ratio = perimeter_overlap_option->get_abs_value(1); flow.width = spacing_option->get_abs_value(max_nozzle_diameter) + layer_height_option->value * (1. - 0.25 * PI) * flow.spacing_ratio; width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); @@ -5854,8 +5854,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const const ConfigOptionPercent* external_perimeter_overlap_option = find_option("external_perimeter_overlap", this, config_collection); ConfigOptionFloatOrPercent* width_option = this->option("external_perimeter_extrusion_width"); if (width_option && external_perimeter_overlap_option) { - width_option->phony = true; - spacing_option->phony = false; + width_option->set_phony(true); + spacing_option->set_phony(false); flow.spacing_ratio = external_perimeter_overlap_option->get_abs_value(0.5); flow.width = spacing_option->get_abs_value(max_nozzle_diameter) + layer_height_option->value * (1. - 0.25 * PI) * flow.spacing_ratio; width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); @@ -5866,8 +5866,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "infill_extrusion_spacing") { ConfigOptionFloatOrPercent* width_option = this->option("infill_extrusion_width"); if (width_option) { - width_option->phony = true; - spacing_option->phony = false; + width_option->set_phony(true); + spacing_option->set_phony(false); width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; @@ -5876,8 +5876,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "solid_infill_extrusion_spacing") { ConfigOptionFloatOrPercent* width_option = this->option("solid_infill_extrusion_width"); if (width_option) { - width_option->phony = true; - spacing_option->phony = false; + width_option->set_phony(true); + spacing_option->set_phony(false); width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; @@ -5886,8 +5886,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "top_infill_extrusion_spacing") { ConfigOptionFloatOrPercent* width_option = this->option("top_infill_extrusion_width"); if (width_option) { - width_option->phony = true; - spacing_option->phony = false; + width_option->set_phony(true); + spacing_option->set_phony(false); width_option->value = (spacing_option->percent) ? std::round(100 * flow.width / max_nozzle_diameter) : (std::round(flow.width * 10000) / 10000); width_option->percent = spacing_option->percent; something_changed = true; @@ -5921,8 +5921,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "extrusion_width") { ConfigOptionFloatOrPercent* spacing_option = this->option("extrusion_spacing"); if (width_option) { - width_option->phony = false; - spacing_option->phony = true; + width_option->set_phony(false); + spacing_option->set_phony(true); Flow flow = Flow::new_from_config_width(FlowRole::frPerimeter, *width_option, max_nozzle_diameter, layer_height_option->value, 0); spacing_option->value = (width_option->percent) ? std::round(100 * flow.spacing() / max_nozzle_diameter) : (std::round(flow.spacing() * 10000) / 10000); spacing_option->percent = width_option->percent; @@ -5932,8 +5932,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "first_layer_extrusion_width") { ConfigOptionFloatOrPercent* spacing_option = this->option("first_layer_extrusion_spacing"); if (width_option) { - width_option->phony = false; - spacing_option->phony = true; + width_option->set_phony(false); + spacing_option->set_phony(true); Flow flow = Flow::new_from_config_width(FlowRole::frPerimeter, *width_option, max_nozzle_diameter, layer_height_option->value, 0); spacing_option->value = (width_option->percent) ? std::round(100 * flow.spacing() / max_nozzle_diameter) : (std::round(flow.spacing() * 10000) / 10000); spacing_option->percent = width_option->percent; @@ -5944,8 +5944,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const const ConfigOptionPercent* perimeter_overlap_option = find_option("perimeter_overlap", this, config_collection); ConfigOptionFloatOrPercent* spacing_option = this->option("perimeter_extrusion_spacing"); if (width_option && perimeter_overlap_option) { - width_option->phony = false; - spacing_option->phony = true; + width_option->set_phony(false); + spacing_option->set_phony(true); Flow flow = Flow::new_from_config_width(FlowRole::frExternalPerimeter, *width_option, max_nozzle_diameter, layer_height_option->value, 0); flow.spacing_ratio = perimeter_overlap_option->get_abs_value(1); spacing_option->value = (width_option->percent) ? std::round(100 * flow.spacing() / max_nozzle_diameter) : (std::round(flow.spacing() * 10000) / 10000); @@ -5957,8 +5957,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const const ConfigOptionPercent* external_perimeter_overlap_option = find_option("external_perimeter_overlap", this, config_collection); ConfigOptionFloatOrPercent* spacing_option = this->option("external_perimeter_extrusion_spacing"); if (width_option && external_perimeter_overlap_option) { - width_option->phony = false; - spacing_option->phony = true; + width_option->set_phony(false); + spacing_option->set_phony(true); Flow ext_perimeter_flow = Flow::new_from_config_width(FlowRole::frPerimeter, *width_option, max_nozzle_diameter, layer_height_option->value, 0); ext_perimeter_flow.spacing_ratio = external_perimeter_overlap_option->get_abs_value(0.5); spacing_option->value = (width_option->percent) ? std::round(100 * ext_perimeter_flow.spacing() / max_nozzle_diameter) : (std::round(ext_perimeter_flow.spacing() * 10000) / 10000); @@ -5969,8 +5969,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "infill_extrusion_width") { ConfigOptionFloatOrPercent* spacing_option = this->option("infill_extrusion_spacing"); if (width_option) { - width_option->phony = false; - spacing_option->phony = true; + width_option->set_phony(false); + spacing_option->set_phony(true); Flow flow = Flow::new_from_config_width(FlowRole::frInfill, *width_option, max_nozzle_diameter, layer_height_option->value, 0); spacing_option->value = (width_option->percent) ? std::round(100 * flow.spacing() / max_nozzle_diameter) : (std::round(flow.spacing() * 10000) / 10000); spacing_option->percent = width_option->percent; @@ -5980,8 +5980,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "solid_infill_extrusion_width") { ConfigOptionFloatOrPercent* spacing_option = this->option("solid_infill_extrusion_spacing"); if (width_option) { - width_option->phony = false; - spacing_option->phony = true; + width_option->set_phony(false); + spacing_option->set_phony(true); Flow flow = Flow::new_from_config_width(FlowRole::frSolidInfill, *width_option, max_nozzle_diameter, layer_height_option->value, 0); spacing_option->value = (width_option->percent) ? std::round(100 * flow.spacing() / max_nozzle_diameter) : (std::round(flow.spacing() * 10000) / 10000); spacing_option->percent = width_option->percent; @@ -5991,8 +5991,8 @@ bool DynamicPrintConfig::value_changed(const t_config_option_key& opt_key, const if (opt_key == "top_infill_extrusion_width") { ConfigOptionFloatOrPercent* spacing_option = this->option("top_infill_extrusion_spacing"); if (width_option) { - width_option->phony = false; - spacing_option->phony = true; + width_option->set_phony(false); + spacing_option->set_phony(true); Flow flow = Flow::new_from_config_width(FlowRole::frTopSolidInfill, *width_option, max_nozzle_diameter, layer_height_option->value, 0); spacing_option->value = (width_option->percent) ? std::round(100 * flow.spacing() / max_nozzle_diameter) : (std::round(flow.spacing() * 10000) / 10000); spacing_option->percent = width_option->percent; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 2af86563e..3228fce74 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -661,12 +661,12 @@ void Tab::update_changed_ui() const Preset& selected_preset = m_presets->get_selected_preset(); const Preset* system_preset = m_presets->get_selected_preset_parent(); for (auto& opt_key : m_presets->get_edited_preset().config.keys()) { - if (edited_preset.config.option(opt_key)->phony) + if (edited_preset.config.option(opt_key)->is_phony()) //ensure that osCurrentPhony is in the bitmask m_options_list[opt_key] |= osCurrentPhony; - if (selected_preset.config.option(opt_key)->phony) + if (selected_preset.config.option(opt_key)->is_phony()) m_options_list[opt_key] |= osInitPhony; - if (system_preset && system_preset->config.option(opt_key)->phony) + if (system_preset && system_preset->config.option(opt_key)->is_phony()) m_options_list[opt_key] |= osSystemPhony; }