mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 00:01:09 -06:00
Fix extruder assignment and tests
This commit is contained in:
parent
10bf334a58
commit
071097d3f1
10 changed files with 109 additions and 186 deletions
|
@ -4,44 +4,4 @@ namespace Slic3r {
|
|||
|
||||
t_optiondef_map PrintConfigDef::def = PrintConfigDef::build_def();
|
||||
|
||||
void
|
||||
StaticPrintConfig::prepare_extruder_option(const t_config_option_key opt_key, DynamicPrintConfig& other)
|
||||
{
|
||||
// don't apply role-based extruders if their value is zero
|
||||
if (other.has(opt_key) && other.option(opt_key)->getInt() == 0)
|
||||
other.erase(opt_key);
|
||||
|
||||
// only apply default extruder if our role-based value is zero
|
||||
// (i.e. default extruder has the lowest priority among all other values)
|
||||
if (other.has("extruder")) {
|
||||
int extruder = other.option("extruder")->getInt();
|
||||
if (extruder > 0) {
|
||||
if (!other.has(opt_key) && this->option(opt_key)->getInt() == 0)
|
||||
other.option(opt_key, true)->setInt(extruder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PrintObjectConfig::apply(const ConfigBase &other, bool ignore_nonexistent) {
|
||||
DynamicPrintConfig other_clone;
|
||||
other_clone.apply(other);
|
||||
|
||||
this->prepare_extruder_option("support_material_extruder", other_clone);
|
||||
this->prepare_extruder_option("support_material_interface_extruder", other_clone);
|
||||
|
||||
StaticConfig::apply(other_clone, ignore_nonexistent);
|
||||
};
|
||||
|
||||
void
|
||||
PrintRegionConfig::apply(const ConfigBase &other, bool ignore_nonexistent) {
|
||||
DynamicPrintConfig other_clone;
|
||||
other_clone.apply(other);
|
||||
|
||||
this->prepare_extruder_option("infill_extruder", other_clone);
|
||||
this->prepare_extruder_option("perimeter_extruder", other_clone);
|
||||
|
||||
StaticConfig::apply(other_clone, ignore_nonexistent);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -399,10 +399,9 @@ class PrintConfigDef
|
|||
Options["infill_extruder"].type = coInt;
|
||||
Options["infill_extruder"].label = "Infill extruder";
|
||||
Options["infill_extruder"].category = "Extruders";
|
||||
Options["infill_extruder"].tooltip = "The extruder to use when printing infill. First extruder is 1, while zero means use default extruder.";
|
||||
Options["infill_extruder"].sidetext = "(leave 0 for default)";
|
||||
Options["infill_extruder"].tooltip = "The extruder to use when printing infill.";
|
||||
Options["infill_extruder"].cli = "infill-extruder=i";
|
||||
Options["infill_extruder"].min = 0;
|
||||
Options["infill_extruder"].min = 1;
|
||||
|
||||
Options["infill_extrusion_width"].type = coFloatOrPercent;
|
||||
Options["infill_extrusion_width"].label = "Infill";
|
||||
|
@ -524,11 +523,10 @@ class PrintConfigDef
|
|||
Options["perimeter_extruder"].type = coInt;
|
||||
Options["perimeter_extruder"].label = "Perimeter extruder";
|
||||
Options["perimeter_extruder"].category = "Extruders";
|
||||
Options["perimeter_extruder"].tooltip = "The extruder to use when printing perimeters. First extruder is 1, while zero means use default extruder.";
|
||||
Options["perimeter_extruder"].sidetext = "(leave 0 for default)";
|
||||
Options["perimeter_extruder"].tooltip = "The extruder to use when printing perimeters. First extruder is 1.";
|
||||
Options["perimeter_extruder"].cli = "perimeter-extruder=i";
|
||||
Options["perimeter_extruder"].aliases.push_back("perimeters_extruder");
|
||||
Options["perimeter_extruder"].min = 0;
|
||||
Options["perimeter_extruder"].min = 1;
|
||||
|
||||
Options["perimeter_extrusion_width"].type = coFloatOrPercent;
|
||||
Options["perimeter_extrusion_width"].label = "Perimeters";
|
||||
|
@ -774,10 +772,9 @@ class PrintConfigDef
|
|||
Options["support_material_extruder"].type = coInt;
|
||||
Options["support_material_extruder"].label = "Support material extruder";
|
||||
Options["support_material_extruder"].category = "Extruders";
|
||||
Options["support_material_extruder"].tooltip = "The extruder to use when printing support material. This affects brim and raft too. First extruder is 1, while zero means use default extruder.";
|
||||
Options["support_material_extruder"].sidetext = "(leave 0 for default)";
|
||||
Options["support_material_extruder"].tooltip = "The extruder to use when printing support material. This affects brim and raft too.";
|
||||
Options["support_material_extruder"].cli = "support-material-extruder=i";
|
||||
Options["support_material_extruder"].min = 0;
|
||||
Options["support_material_extruder"].min = 1;
|
||||
|
||||
Options["support_material_extrusion_width"].type = coFloatOrPercent;
|
||||
Options["support_material_extrusion_width"].label = "Support material";
|
||||
|
@ -789,10 +786,9 @@ class PrintConfigDef
|
|||
Options["support_material_interface_extruder"].type = coInt;
|
||||
Options["support_material_interface_extruder"].label = "Support material interface extruder";
|
||||
Options["support_material_interface_extruder"].category = "Extruders";
|
||||
Options["support_material_interface_extruder"].tooltip = "The extruder to use when printing support material interface. This affects raft too. First extruder is 1, while zero means use default extruder.";
|
||||
Options["support_material_interface_extruder"].sidetext = "(leave 0 for default)";
|
||||
Options["support_material_interface_extruder"].tooltip = "The extruder to use when printing support material interface. This affects raft too.";
|
||||
Options["support_material_interface_extruder"].cli = "support-material-interface-extruder=i";
|
||||
Options["support_material_interface_extruder"].min = 0;
|
||||
Options["support_material_interface_extruder"].min = 1;
|
||||
|
||||
Options["support_material_interface_layers"].type = coInt;
|
||||
Options["support_material_interface_layers"].label = "Interface layers";
|
||||
|
@ -940,6 +936,21 @@ class DynamicPrintConfig : public DynamicConfig
|
|||
DynamicPrintConfig() {
|
||||
this->def = &PrintConfigDef::def;
|
||||
};
|
||||
|
||||
void normalize() {
|
||||
if (this->has("extruder")) {
|
||||
int extruder = this->option("extruder")->getInt();
|
||||
this->erase("extruder");
|
||||
if (!this->has("infill_extruder"))
|
||||
this->option("infill_extruder", true)->setInt(extruder);
|
||||
if (!this->has("perimeter_extruder"))
|
||||
this->option("infill_extruder", true)->setInt(extruder);
|
||||
if (!this->has("support_material_extruder"))
|
||||
this->option("support_material_extruder", true)->setInt(extruder);
|
||||
if (!this->has("support_material_interface_extruder"))
|
||||
this->option("support_material_interface_extruder", true)->setInt(extruder);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class StaticPrintConfig : public virtual StaticConfig
|
||||
|
@ -948,9 +959,6 @@ class StaticPrintConfig : public virtual StaticConfig
|
|||
StaticPrintConfig() {
|
||||
this->def = &PrintConfigDef::def;
|
||||
};
|
||||
|
||||
protected:
|
||||
void prepare_extruder_option(const t_config_option_key opt_key, DynamicPrintConfig& other);
|
||||
};
|
||||
|
||||
class PrintObjectConfig : public virtual StaticPrintConfig
|
||||
|
@ -987,10 +995,10 @@ class PrintObjectConfig : public virtual StaticPrintConfig
|
|||
this->support_material.value = false;
|
||||
this->support_material_angle.value = 0;
|
||||
this->support_material_enforce_layers.value = 0;
|
||||
this->support_material_extruder.value = 0;
|
||||
this->support_material_extruder.value = 1;
|
||||
this->support_material_extrusion_width.value = 0;
|
||||
this->support_material_extrusion_width.percent = false;
|
||||
this->support_material_interface_extruder.value = 0;
|
||||
this->support_material_interface_extruder.value = 1;
|
||||
this->support_material_interface_layers.value = 3;
|
||||
this->support_material_interface_spacing.value = 0;
|
||||
this->support_material_pattern.value = smpHoneycomb;
|
||||
|
@ -1021,8 +1029,6 @@ class PrintObjectConfig : public virtual StaticPrintConfig
|
|||
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void apply(const ConfigBase &other, bool ignore_nonexistent = false);
|
||||
};
|
||||
|
||||
class PrintRegionConfig : public virtual StaticPrintConfig
|
||||
|
@ -1053,11 +1059,11 @@ class PrintRegionConfig : public virtual StaticPrintConfig
|
|||
this->fill_angle.value = 45;
|
||||
this->fill_density.value = 40;
|
||||
this->fill_pattern.value = ipHoneycomb;
|
||||
this->infill_extruder.value = 0;
|
||||
this->infill_extruder.value = 1;
|
||||
this->infill_extrusion_width.value = 0;
|
||||
this->infill_extrusion_width.percent = false;
|
||||
this->infill_every_layers.value = 1;
|
||||
this->perimeter_extruder.value = 0;
|
||||
this->perimeter_extruder.value = 1;
|
||||
this->perimeter_extrusion_width.value = 0;
|
||||
this->perimeter_extrusion_width.percent = false;
|
||||
this->perimeters.value = 3;
|
||||
|
@ -1094,8 +1100,6 @@ class PrintRegionConfig : public virtual StaticPrintConfig
|
|||
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void apply(const ConfigBase &other, bool ignore_nonexistent = false);
|
||||
};
|
||||
|
||||
class PrintConfig : public virtual StaticPrintConfig
|
||||
|
@ -1398,12 +1402,6 @@ class FullPrintConfig : public PrintObjectConfig, public PrintRegionConfig, publ
|
|||
if ((opt = PrintConfig::option(opt_key, create)) != NULL) return opt;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void apply(const ConfigBase &other, bool ignore_nonexistent = false) {
|
||||
PrintObjectConfig::apply(other, ignore_nonexistent);
|
||||
PrintRegionConfig::apply(other, ignore_nonexistent);
|
||||
PrintConfig::apply(other, ignore_nonexistent);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue