mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-09-17 00:03:17 +08:00
fix for macos: phony is stored on 4 bytes
This commit is contained in:
parent
534f0b0257
commit
833edf1d28
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -5518,7 +5518,7 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value,
|
||||
if (std::set<std::string>{"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<ConfigOptionFloatOrPercent>(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::vector<const DynamicPrintConfig
|
||||
ConfigOptionFloatOrPercent* width_option = this->option<ConfigOptionFloatOrPercent>(key_width);
|
||||
ConfigOptionFloatOrPercent* spacing_option = this->option<ConfigOptionFloatOrPercent>(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<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionPercent>("perimeter_overlap", this, config_collection);
|
||||
ConfigOptionFloatOrPercent* width_option = this->option<ConfigOptionFloatOrPercent>("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<ConfigOptionPercent>("external_perimeter_overlap", this, config_collection);
|
||||
ConfigOptionFloatOrPercent* width_option = this->option<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionPercent>("perimeter_overlap", this, config_collection);
|
||||
ConfigOptionFloatOrPercent* spacing_option = this->option<ConfigOptionFloatOrPercent>("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<ConfigOptionPercent>("external_perimeter_overlap", this, config_collection);
|
||||
ConfigOptionFloatOrPercent* spacing_option = this->option<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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<ConfigOptionFloatOrPercent>("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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user