Split external_fill_pattern into top_infill_pattern and bottom_infill_pattern. Retrocompatibile change. #945

This commit is contained in:
Alessandro Ranellucci 2017-03-12 13:01:14 +01:00
parent e6553599b6
commit 4b4a0c8a5c
10 changed files with 91 additions and 32 deletions

View File

@ -265,8 +265,10 @@ sub validate {
if !first { $_ eq $self->fill_pattern } @{$Options->{fill_pattern}{values}}; if !first { $_ eq $self->fill_pattern } @{$Options->{fill_pattern}{values}};
# --external-fill-pattern # --external-fill-pattern
die "Invalid value for --external-fill-pattern\n" die "Invalid value for --top-infill-pattern\n"
if !first { $_ eq $self->external_fill_pattern } @{$Options->{external_fill_pattern}{values}}; if !first { $_ eq $self->top_infill_pattern } @{$Options->{top_infill_pattern}{values}};
die "Invalid value for --bottom-infill-pattern\n"
if !first { $_ eq $self->bottom_infill_pattern } @{$Options->{bottom_infill_pattern}{values}};
# --fill-density # --fill-density
die "The selected fill pattern is not supposed to work at 100% density\n" die "The selected fill pattern is not supposed to work at 100% density\n"

View File

@ -466,7 +466,7 @@ sub build {
top_solid_layers bottom_solid_layers top_solid_layers bottom_solid_layers
extra_perimeters avoid_crossing_perimeters thin_walls overhangs extra_perimeters avoid_crossing_perimeters thin_walls overhangs
seam_position external_perimeters_first seam_position external_perimeters_first
fill_density fill_pattern external_fill_pattern fill_gaps fill_density fill_pattern top_infill_pattern bottom_infill_pattern fill_gaps
infill_every_layers infill_only_where_needed infill_every_layers infill_only_where_needed
solid_infill_every_layers fill_angle solid_infill_below_area solid_infill_every_layers fill_angle solid_infill_below_area
only_retract_when_crossing_perimeters infill_first only_retract_when_crossing_perimeters infill_first
@ -542,7 +542,14 @@ sub build {
my $optgroup = $page->new_optgroup('Infill'); my $optgroup = $page->new_optgroup('Infill');
$optgroup->append_single_option_line('fill_density'); $optgroup->append_single_option_line('fill_density');
$optgroup->append_single_option_line('fill_pattern'); $optgroup->append_single_option_line('fill_pattern');
$optgroup->append_single_option_line('external_fill_pattern'); {
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'External infill pattern',
);
$line->append_option($optgroup->get_option('top_infill_pattern'));
$line->append_option($optgroup->get_option('bottom_infill_pattern'));
$optgroup->append_line($line);
}
} }
{ {
my $optgroup = $page->new_optgroup('Reducing printing time'); my $optgroup = $page->new_optgroup('Reducing printing time');
@ -794,7 +801,7 @@ sub _update {
} }
if ($config->fill_density == 100 if ($config->fill_density == 100
&& !first { $_ eq $config->fill_pattern } @{$Slic3r::Config::Options->{external_fill_pattern}{values}}) { && !first { $_ eq $config->fill_pattern } @{$Slic3r::Config::Options->{top_infill_pattern}{values}}) {
my $dialog = Wx::MessageDialog->new($self, my $dialog = Wx::MessageDialog->new($self,
"The " . $config->fill_pattern . " infill pattern is not supposed to work at 100% density.\n" "The " . $config->fill_pattern . " infill pattern is not supposed to work at 100% density.\n"
. "\nShall I switch to rectilinear fill pattern?", . "\nShall I switch to rectilinear fill pattern?",
@ -824,8 +831,8 @@ sub _update {
my $have_solid_infill = ($config->top_solid_layers > 0) || ($config->bottom_solid_layers > 0); my $have_solid_infill = ($config->top_solid_layers > 0) || ($config->bottom_solid_layers > 0);
# solid_infill_extruder uses the same logic as in Print::extruders() # solid_infill_extruder uses the same logic as in Print::extruders()
$self->get_field($_)->toggle($have_solid_infill) $self->get_field($_)->toggle($have_solid_infill)
for qw(external_fill_pattern infill_first solid_infill_extruder solid_infill_extrusion_width for qw(top_infill_pattern bottom_infill_pattern infill_first solid_infill_extruder
solid_infill_speed); solid_infill_extrusion_width solid_infill_speed);
$self->get_field($_)->toggle($have_infill || $have_solid_infill) $self->get_field($_)->toggle($have_infill || $have_solid_infill)
for qw(fill_angle infill_extrusion_width infill_speed bridge_speed); for qw(fill_angle infill_extrusion_width infill_speed bridge_speed);

View File

@ -431,7 +431,10 @@ $j
--fill-angle Infill angle in degrees (range: 0-90, default: $config->{fill_angle}) --fill-angle Infill angle in degrees (range: 0-90, default: $config->{fill_angle})
--fill-pattern Pattern to use to fill non-solid layers (default: $config->{fill_pattern}) --fill-pattern Pattern to use to fill non-solid layers (default: $config->{fill_pattern})
--fill-gaps Fill gaps with single passes (default: yes) --fill-gaps Fill gaps with single passes (default: yes)
--external-fill-pattern Pattern to use to fill solid layers (default: $config->{external_fill_pattern}) --external-infill-pattern Pattern to use to fill solid layers.
(Shortcut for --top-infill-pattern and --bottom-infill-pattern)
--top-infill-pattern Pattern to use to fill top solid layers (default: $config->{top_infill_pattern})
--bottom-infill-pattern Pattern to use to fill bottom solid layers (default: $config->{bottom_infill_pattern})
--start-gcode Load initial G-code from the supplied file. This will overwrite --start-gcode Load initial G-code from the supplied file. This will overwrite
the default command (home all axes [G28]). the default command (home all axes [G28]).
--end-gcode Load final G-code from the supplied file. This will overwrite --end-gcode Load final G-code from the supplied file. This will overwrite

View File

@ -192,7 +192,9 @@ ConfigOptionDef::ConfigOptionDef(const ConfigOptionDef &other)
full_label(other.full_label), category(other.category), tooltip(other.tooltip), full_label(other.full_label), category(other.category), tooltip(other.tooltip),
sidetext(other.sidetext), cli(other.cli), ratio_over(other.ratio_over), sidetext(other.sidetext), cli(other.cli), ratio_over(other.ratio_over),
multiline(other.multiline), full_width(other.full_width), readonly(other.readonly), multiline(other.multiline), full_width(other.full_width), readonly(other.readonly),
height(other.height), width(other.width), min(other.min), max(other.max) height(other.height), width(other.width), min(other.min), max(other.max),
aliases(other.aliases), shortcut(other.shortcut), enum_values(other.enum_values),
enum_labels(other.enum_labels), enum_keys_map(other.enum_keys_map)
{ {
if (other.default_value != NULL) if (other.default_value != NULL)
this->default_value = other.default_value->clone(); this->default_value = other.default_value->clone();
@ -212,6 +214,13 @@ ConfigDef::add(const t_config_option_key &opt_key, ConfigOptionType type)
return opt; return opt;
} }
ConfigOptionDef*
ConfigDef::add(const t_config_option_key &opt_key, const ConfigOptionDef &def)
{
this->options.emplace(opt_key, def);
return &this->options[opt_key];
}
const ConfigOptionDef* const ConfigOptionDef*
ConfigDef::get(const t_config_option_key &opt_key) const ConfigDef::get(const t_config_option_key &opt_key) const
{ {

View File

@ -641,6 +641,7 @@ class ConfigDef
public: public:
t_optiondef_map options; t_optiondef_map options;
ConfigOptionDef* add(const t_config_option_key &opt_key, ConfigOptionType type); ConfigOptionDef* add(const t_config_option_key &opt_key, ConfigOptionType type);
ConfigOptionDef* add(const t_config_option_key &opt_key, const ConfigOptionDef &def);
const ConfigOptionDef* get(const t_config_option_key &opt_key) const; const ConfigOptionDef* get(const t_config_option_key &opt_key) const;
void merge(const ConfigDef &other); void merge(const ConfigDef &other);
}; };

View File

@ -35,6 +35,7 @@ class FillArchimedeanChords : public FillPlanePath
public: public:
virtual Fill* clone() const { return new FillArchimedeanChords(*this); }; virtual Fill* clone() const { return new FillArchimedeanChords(*this); };
virtual ~FillArchimedeanChords() {} virtual ~FillArchimedeanChords() {}
virtual bool can_solid() const { return true; };
protected: protected:
virtual bool _centered() const { return true; } virtual bool _centered() const { return true; }
@ -46,6 +47,7 @@ class FillHilbertCurve : public FillPlanePath
public: public:
virtual Fill* clone() const { return new FillHilbertCurve(*this); }; virtual Fill* clone() const { return new FillHilbertCurve(*this); };
virtual ~FillHilbertCurve() {} virtual ~FillHilbertCurve() {}
virtual bool can_solid() const { return true; };
protected: protected:
virtual bool _centered() const { return false; } virtual bool _centered() const { return false; }
@ -57,6 +59,7 @@ class FillOctagramSpiral : public FillPlanePath
public: public:
virtual Fill* clone() const { return new FillOctagramSpiral(*this); }; virtual Fill* clone() const { return new FillOctagramSpiral(*this); };
virtual ~FillOctagramSpiral() {} virtual ~FillOctagramSpiral() {}
virtual bool can_solid() const { return true; };
protected: protected:
virtual bool _centered() const { return true; } virtual bool _centered() const { return true; }

View File

@ -67,7 +67,9 @@ LayerRegion::make_fill()
group_attrib[i].is_solid = true; group_attrib[i].is_solid = true;
group_attrib[i].fw = (surface.surface_type == stTop) ? top_solid_infill_flow.width : solid_infill_flow.width; group_attrib[i].fw = (surface.surface_type == stTop) ? top_solid_infill_flow.width : solid_infill_flow.width;
group_attrib[i].pattern = surface.is_external() ? this->region()->config.external_fill_pattern.value : ipRectilinear; group_attrib[i].pattern = surface.surface_type == stTop ? this->region()->config.top_infill_pattern.value
: surface.is_bottom() ? this->region()->config.bottom_infill_pattern.value
: ipRectilinear;
} }
// Loop through solid groups, find compatible groups and append them to this one. // Loop through solid groups, find compatible groups and append them to this one.
for (size_t i = 0; i < groups.size(); ++i) { for (size_t i = 0; i < groups.size(); ++i) {
@ -171,8 +173,8 @@ LayerRegion::make_fill()
if (surface.is_solid()) { if (surface.is_solid()) {
density = 100.; density = 100.;
fill_pattern = (surface.is_external() && !is_bridge) fill_pattern = (surface.surface_type == stTop) ? this->region()->config.top_infill_pattern.value
? this->region()->config.external_fill_pattern.value : (surface.is_bottom() && !is_bridge) ? this->region()->config.bottom_infill_pattern.value
: ipRectilinear; : ipRectilinear;
} else if (density <= 0) } else if (density <= 0)
continue; continue;

View File

@ -5,6 +5,20 @@ namespace Slic3r {
PrintConfigDef::PrintConfigDef() PrintConfigDef::PrintConfigDef()
{ {
ConfigOptionDef external_fill_pattern;
external_fill_pattern.type = coEnum;
external_fill_pattern.enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
external_fill_pattern.enum_values.push_back("rectilinear");
external_fill_pattern.enum_values.push_back("concentric");
external_fill_pattern.enum_values.push_back("hilbertcurve");
external_fill_pattern.enum_values.push_back("archimedeanchords");
external_fill_pattern.enum_values.push_back("octagramspiral");
external_fill_pattern.enum_labels.push_back("Rectilinear");
external_fill_pattern.enum_labels.push_back("Concentric");
external_fill_pattern.enum_labels.push_back("Hilbert Curve");
external_fill_pattern.enum_labels.push_back("Archimedean Chords");
external_fill_pattern.enum_labels.push_back("Octagram Spiral");
ConfigOptionDef* def; ConfigOptionDef* def;
def = this->add("avoid_crossing_perimeters", coBool); def = this->add("avoid_crossing_perimeters", coBool);
@ -47,6 +61,14 @@ PrintConfigDef::PrintConfigDef()
def->height = 50; def->height = 50;
def->default_value = new ConfigOptionString(""); def->default_value = new ConfigOptionString("");
def = this->add("bottom_infill_pattern", external_fill_pattern);
def->label = "Bottom";
def->full_label = "Bottom infill pattern";
def->category = "Infill";
def->tooltip = "Infill pattern for bottom layers. This only affects the external visible layer, and not its adjacent solid shells.";
def->cli = "bottom-infill-pattern=s";
def->default_value = new ConfigOptionEnum<InfillPattern>(ipRectilinear);
def = this->add("bottom_solid_layers", coInt); def = this->add("bottom_solid_layers", coInt);
def->label = "Bottom"; def->label = "Bottom";
def->category = "Layers and Perimeters"; def->category = "Layers and Perimeters";
@ -177,27 +199,15 @@ PrintConfigDef::PrintConfigDef()
def->default_value = opt; def->default_value = opt;
} }
def = this->add("external_fill_pattern", coEnum); def = this->add("external_fill_pattern", external_fill_pattern);
def->label = "Top/bottom fill pattern"; def->label = "Top/bottom fill pattern";
def->category = "Infill"; def->category = "Infill";
def->tooltip = "Fill pattern for top/bottom infill. This only affects the external visible layer, and not its adjacent solid shells."; def->tooltip = "Fill pattern for top/bottom infill. This only affects the external visible layer, and not its adjacent solid shells.";
def->cli = "external-fill-pattern|solid-fill-pattern=s"; def->cli = "external-fill-pattern|external-infill-pattern|solid-fill-pattern=s";
def->enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
def->enum_values.push_back("rectilinear");
def->enum_values.push_back("alignedrectilinear");
def->enum_values.push_back("concentric");
def->enum_values.push_back("hilbertcurve");
def->enum_values.push_back("archimedeanchords");
def->enum_values.push_back("octagramspiral");
def->enum_labels.push_back("Rectilinear");
def->enum_labels.push_back("Aligned Rectilinear");
def->enum_labels.push_back("Concentric");
def->enum_labels.push_back("Hilbert Curve");
def->enum_labels.push_back("Archimedean Chords");
def->enum_labels.push_back("Octagram Spiral");
def->aliases.push_back("solid_fill_pattern"); def->aliases.push_back("solid_fill_pattern");
def->default_value = new ConfigOptionEnum<InfillPattern>(ipRectilinear); def->shortcut.push_back("top_infill_pattern");
def->shortcut.push_back("bottom_infill_pattern");
def = this->add("external_perimeter_extrusion_width", coFloatOrPercent); def = this->add("external_perimeter_extrusion_width", coFloatOrPercent);
def->label = "↳ external"; def->label = "↳ external";
def->gui_type = "f_enum_open"; def->gui_type = "f_enum_open";
@ -1402,6 +1412,14 @@ PrintConfigDef::PrintConfigDef()
def->enum_labels.push_back("default"); def->enum_labels.push_back("default");
def->default_value = new ConfigOptionFloatOrPercent(0, false); def->default_value = new ConfigOptionFloatOrPercent(0, false);
def = this->add("top_infill_pattern", external_fill_pattern);
def->label = "Top";
def->full_label = "Top infill pattern";
def->category = "Infill";
def->tooltip = "Infill pattern for top layers. This only affects the external visible layer, and not its adjacent solid shells.";
def->cli = "top-infill-pattern=s";
def->default_value = new ConfigOptionEnum<InfillPattern>(ipRectilinear);
def = this->add("top_solid_infill_speed", coFloatOrPercent); def = this->add("top_solid_infill_speed", coFloatOrPercent);
def->label = "↳ top solid"; def->label = "↳ top solid";
def->gui_type = "f_enum_open"; def->gui_type = "f_enum_open";
@ -1504,6 +1522,17 @@ DynamicPrintConfig::normalize() {
} }
} }
/*
if (this->has("external_fill_pattern")) {
InfillPattern p = this->opt<ConfigOptionEnum<InfillPattern> >("external_fill_pattern");
this->erase("external_fill_pattern");
if (!this->has("bottom_infill_pattern"))
this->opt<ConfigOptionEnum<InfillPattern> >("bottom_infill_pattern", true)->value = p;
if (!this->has("top_infill_pattern"))
this->opt<ConfigOptionEnum<InfillPattern> >("top_infill_pattern", true)->value = p;
}
*/
if (!this->has("solid_infill_extruder") && this->has("infill_extruder")) if (!this->has("solid_infill_extruder") && this->has("infill_extruder"))
this->option("solid_infill_extruder", true)->setInt(this->option("infill_extruder")->getInt()); this->option("solid_infill_extruder", true)->setInt(this->option("infill_extruder")->getInt());

View File

@ -202,10 +202,10 @@ class PrintObjectConfig : public virtual StaticPrintConfig
class PrintRegionConfig : public virtual StaticPrintConfig class PrintRegionConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionEnum<InfillPattern> bottom_infill_pattern;
ConfigOptionInt bottom_solid_layers; ConfigOptionInt bottom_solid_layers;
ConfigOptionFloat bridge_flow_ratio; ConfigOptionFloat bridge_flow_ratio;
ConfigOptionFloat bridge_speed; ConfigOptionFloat bridge_speed;
ConfigOptionEnum<InfillPattern> external_fill_pattern;
ConfigOptionFloatOrPercent external_perimeter_extrusion_width; ConfigOptionFloatOrPercent external_perimeter_extrusion_width;
ConfigOptionFloatOrPercent external_perimeter_speed; ConfigOptionFloatOrPercent external_perimeter_speed;
ConfigOptionBool external_perimeters_first; ConfigOptionBool external_perimeters_first;
@ -233,6 +233,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig
ConfigOptionFloatOrPercent solid_infill_speed; ConfigOptionFloatOrPercent solid_infill_speed;
ConfigOptionBool thin_walls; ConfigOptionBool thin_walls;
ConfigOptionFloatOrPercent top_infill_extrusion_width; ConfigOptionFloatOrPercent top_infill_extrusion_width;
ConfigOptionEnum<InfillPattern> top_infill_pattern;
ConfigOptionInt top_solid_layers; ConfigOptionInt top_solid_layers;
ConfigOptionFloatOrPercent top_solid_infill_speed; ConfigOptionFloatOrPercent top_solid_infill_speed;
@ -242,10 +243,10 @@ class PrintRegionConfig : public virtual StaticPrintConfig
} }
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) { virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
OPT_PTR(bottom_infill_pattern);
OPT_PTR(bottom_solid_layers); OPT_PTR(bottom_solid_layers);
OPT_PTR(bridge_flow_ratio); OPT_PTR(bridge_flow_ratio);
OPT_PTR(bridge_speed); OPT_PTR(bridge_speed);
OPT_PTR(external_fill_pattern);
OPT_PTR(external_perimeter_extrusion_width); OPT_PTR(external_perimeter_extrusion_width);
OPT_PTR(external_perimeter_speed); OPT_PTR(external_perimeter_speed);
OPT_PTR(external_perimeters_first); OPT_PTR(external_perimeters_first);
@ -273,6 +274,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig
OPT_PTR(solid_infill_speed); OPT_PTR(solid_infill_speed);
OPT_PTR(thin_walls); OPT_PTR(thin_walls);
OPT_PTR(top_infill_extrusion_width); OPT_PTR(top_infill_extrusion_width);
OPT_PTR(top_infill_pattern);
OPT_PTR(top_solid_infill_speed); OPT_PTR(top_solid_infill_speed);
OPT_PTR(top_solid_layers); OPT_PTR(top_solid_layers);

View File

@ -257,7 +257,8 @@ PrintObject::invalidate_state_by_config_options(const std::vector<t_config_optio
|| *opt_key == "solid_infill_extruder" || *opt_key == "solid_infill_extruder"
|| *opt_key == "infill_extrusion_width") { || *opt_key == "infill_extrusion_width") {
steps.insert(posPrepareInfill); steps.insert(posPrepareInfill);
} else if (*opt_key == "external_fill_pattern" } else if (*opt_key == "top_infill_pattern"
|| *opt_key == "bottom_infill_pattern"
|| *opt_key == "fill_angle" || *opt_key == "fill_angle"
|| *opt_key == "fill_pattern" || *opt_key == "fill_pattern"
|| *opt_key == "top_infill_extrusion_width" || *opt_key == "top_infill_extrusion_width"