Merge branch 'master' into avoid-crossing-perimeters

Conflicts:
	lib/Slic3r/GCode.pm
	lib/Slic3r/GUI/Plater.pm
	lib/Slic3r/Print.pm
	lib/Slic3r/SVG.pm
This commit is contained in:
Alessandro Ranellucci 2013-01-12 19:00:18 +01:00
commit 48e00a4c40
52 changed files with 2388 additions and 821 deletions

View file

@ -5,10 +5,8 @@ use utf8;
use List::Util qw(first);
use constant PI => 4 * atan2(1, 1);
# cemetery of old config settings
our @Ignore = qw(duplicate_x duplicate_y multiply_x multiply_y support_material_tool);
our @Ignore = qw(duplicate_x duplicate_y multiply_x multiply_y support_material_tool acceleration);
my $serialize_comma = sub { join ',', @{$_[0]} };
my $deserialize_comma = sub { [ split /,/, $_[0] ] };
@ -155,7 +153,7 @@ our $Options = {
default => [1],
},
'temperature' => {
label => 'Temperature',
label => 'Other layers',
tooltip => 'Extruder temperature for layers after the first one. Set this to zero to disable temperature control commands in the output.',
sidetext => '°C',
cli => 'temperature=i@',
@ -166,7 +164,7 @@ our $Options = {
default => [200],
},
'first_layer_temperature' => {
label => 'First layer temperature',
label => 'First layer',
tooltip => 'Extruder temperature for first layer. If you want to control temperature manually during print, set this to zero to disable temperature control commands in the output file.',
sidetext => '°C',
cli => 'first-layer-temperature=i@',
@ -203,7 +201,7 @@ our $Options = {
# filament options
'first_layer_bed_temperature' => {
label => 'First layer bed temperature',
label => 'First layer',
tooltip => 'Heated build plate temperature for the first layer. Set this to zero to disable bed temperature control commands in the output.',
sidetext => '°C',
cli => 'first-layer-bed-temperature=i',
@ -212,7 +210,7 @@ our $Options = {
default => 0,
},
'bed_temperature' => {
label => 'Bed Temperature',
label => 'Other layers',
tooltip => 'Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output.',
sidetext => '°C',
cli => 'bed-temperature=i',
@ -286,6 +284,14 @@ our $Options = {
ratio_over => 'solid_infill_speed',
default => 50,
},
'support_material_speed' => {
label => 'Support material',
tooltip => 'Speed for printing support material.',
sidetext => 'mm/s',
cli => 'support-material-speed=f',
type => 'f',
default => 60,
},
'bridge_speed' => {
label => 'Bridges',
tooltip => 'Speed for printing bridges.',
@ -295,6 +301,14 @@ our $Options = {
aliases => [qw(bridge_feed_rate)],
default => 60,
},
'gap_fill_speed' => {
label => 'Gap fill',
tooltip => 'Speed for filling small gaps using short zigzag moves. Keep this reasonably low to avoid too much shaking and resonance issues. Set zero to disable gaps filling.',
sidetext => 'mm/s',
cli => 'gap-fill-speed=f',
type => 'f',
default => 20,
},
'first_layer_speed' => {
label => 'First layer speed',
tooltip => 'If expressed as absolute value in mm/s, this speed will be applied to all the print moves of the first layer, regardless of their type. If expressed as a percentage (for example: 40%) it will scale the default speeds.',
@ -305,25 +319,29 @@ our $Options = {
},
# acceleration options
'acceleration' => {
label => 'Enable acceleration control',
cli => 'acceleration!',
type => 'bool',
'default_acceleration' => {
label => 'Default',
tooltip => 'This is the acceleration your printer will be reset to after the role-specific acceleration values are used (perimeter/infill). Set zero to prevent resetting acceleration at all.',
sidetext => 'mm/s²',
cli => 'default-acceleration',
type => 'f',
default => 0,
},
'perimeter_acceleration' => {
label => 'Perimeters',
tooltip => 'This is the acceleration your printer will use for perimeters. A high value like 9000 usually gives good results if your hardware is up to the job. Set zero to disable acceleration control for perimeters.',
sidetext => 'mm/s²',
cli => 'perimeter-acceleration',
type => 'f',
default => 25,
default => 0,
},
'infill_acceleration' => {
label => 'Infill',
tooltip => 'This is the acceleration your printer will use for infill. Set zero to disable acceleration control for infill.',
sidetext => 'mm/s²',
cli => 'infill-acceleration',
type => 'f',
default => 50,
default => 0,
},
# accuracy options
@ -412,6 +430,14 @@ our $Options = {
type => 'f',
default => 1,
},
'vibration_limit' => {
label => 'Vibration limit',
tooltip => 'This experimental option will slow down those moves hitting the configured frequency limit. The purpose of limiting vibrations is to avoid mechanical resonance. Set zero to disable.',
sidetext => 'Hz',
cli => 'vibration-limit=f',
type => 'f',
default => 0,
},
# print options
'perimeters' => {
@ -424,9 +450,23 @@ our $Options = {
},
'solid_layers' => {
label => 'Solid layers',
tooltip => 'Number of solid layers to generate on top and bottom.',
tooltip => 'Number of solid layers to generate on top and bottom surfaces.',
cli => 'solid-layers=i',
type => 'i',
shortcut => [qw(top_solid_layers bottom_solid_layers)],
},
'top_solid_layers' => {
label => 'Top',
tooltip => 'Number of solid layers to generate on top surfaces.',
cli => 'top-solid-layers=i',
type => 'i',
default => 3,
},
'bottom_solid_layers' => {
label => 'Bottom',
tooltip => 'Number of solid layers to generate on bottom surfaces.',
cli => 'bottom-solid-layers=i',
type => 'i',
default => 3,
},
'fill_pattern' => {
@ -507,11 +547,11 @@ our $Options = {
},
'support_material_threshold' => {
label => 'Overhang threshold',
tooltip => 'Support material will not generated for overhangs whose slope angle is above the given threshold.',
tooltip => 'Support material will not generated for overhangs whose slope angle is above the given threshold. Set to zero for automatic detection.',
sidetext => '°',
cli => 'support-material-threshold=i',
type => 'i',
default => 45,
default => 0,
},
'support_material_pattern' => {
label => 'Pattern',
@ -578,6 +618,18 @@ END
deserialize => sub { join "\n", split /\\n/, $_[0] },
default => '',
},
'toolchange_gcode' => {
label => 'Tool change G-code',
tooltip => 'This custom code is inserted at every extruder change. Note that you can use placeholder variables for all Slic3r settings as well as [previous_extruder] and [next_extruder].',
cli => 'toolchange-gcode=s',
type => 's',
multiline => 1,
full_width => 1,
height => 50,
serialize => sub { join '\n', split /\R+/, $_[0] },
deserialize => sub { join "\n", split /\\n/, $_[0] },
default => '',
},
'post_process' => {
label => 'Post-processing scripts',
tooltip => 'If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables.',
@ -673,7 +725,7 @@ END
default => 0,
},
'min_fan_speed' => {
label => 'Min fan speed',
label => 'Min',
tooltip => 'This setting represents the minimum PWM your fan needs to work.',
sidetext => '%',
cli => 'min-fan-speed=i',
@ -682,7 +734,7 @@ END
default => 35,
},
'max_fan_speed' => {
label => 'Max fan speed',
label => 'Max',
tooltip => 'This setting represents the maximum speed of your fan.',
sidetext => '%',
cli => 'max-fan-speed=i',
@ -691,7 +743,7 @@ END
default => 100,
},
'bridge_fan_speed' => {
label => 'Bridge fan speed',
label => 'Bridges fan speed',
tooltip => 'This fan speed is enforced during all bridges.',
sidetext => '%',
cli => 'bridge-fan-speed=i',
@ -753,6 +805,15 @@ END
type => 'i',
default => 1,
},
'min_skirt_length' => {
label => 'Minimum extrusion length',
tooltip => 'Generate no less than the number of skirt loops required to consume the specified amount of filament on the bottom layer. For multi-extruder machines, this minimum applies to each extruder.',
sidetext => 'mm',
cli => 'min-skirt-length=f',
type => 'f',
default => 0,
min => 0,
},
'skirt_distance' => {
label => 'Distance from object',
tooltip => 'Distance between skirt and object(s). Set this to zero to attach the skirt to the object(s) and get a brim for better adhesion.',
@ -837,7 +898,7 @@ END
default => 0,
},
'extruder_clearance_radius' => {
label => 'Extruder clearance radius',
label => 'Radius',
tooltip => 'Set this to the clearance radius around your extruder. If the extruder is not centered, choose the largest value for safety. This setting is used to check for collisions and to display the graphical preview in the plater.',
sidetext => 'mm',
cli => 'extruder-clearance-radius=f',
@ -845,7 +906,7 @@ END
default => 20,
},
'extruder_clearance_height' => {
label => 'Extruder clearance height',
label => 'Height',
tooltip => 'Set this to the vertical distance between your nozzle tip and (usually) the X carriage rods. In other words, this is the height of the clearance cylinder around your extruder, and it represents the maximum depth the extruder can peek before colliding with other printed objects.',
sidetext => 'mm',
cli => 'extruder-clearance-height=f',
@ -874,7 +935,11 @@ sub new {
sub new_from_defaults {
my $class = shift;
my @opt_keys =
return $class->new(map { $_ => $Options->{$_}{default} } (@_ ? @_ : keys %$Options));
return $class->new(
map { $_ => $Options->{$_}{default} }
grep !$Options->{$_}{shortcut},
(@_ ? @_ : keys %$Options)
);
}
sub new_from_cli {
@ -883,7 +948,7 @@ sub new_from_cli {
delete $args{$_} for grep !defined $args{$_}, keys %args;
for (qw(start end layer)) {
for (qw(start end layer toolchange)) {
my $opt_key = "${_}_gcode";
if ($args{$opt_key}) {
die "Invalid value for --${_}-gcode: file does not exist\n"
@ -967,8 +1032,12 @@ sub set {
}
if (!exists $Options->{$opt_key}) {
$opt_key = +(grep { $Options->{$_}{aliases} && grep $_ eq $opt_key, @{$Options->{$_}{aliases}} } keys %$Options)[0]
or warn "Unknown option $opt_key\n";
my @keys = grep { $Options->{$_}{aliases} && grep $_ eq $opt_key, @{$Options->{$_}{aliases}} } keys %$Options;
if (!@keys) {
warn "Unknown option $opt_key\n";
return;
}
$opt_key = $keys[0];
}
# clone arrayrefs
@ -979,6 +1048,10 @@ sub set {
if $deserialize && $Options->{$opt_key}{deserialize};
$self->{$opt_key} = $value;
if ($Options->{$opt_key}{shortcut}) {
$self->set($_, $value, $deserialize) for @{$Options->{$opt_key}{shortcut}};
}
}
sub set_ifndef {
@ -1010,6 +1083,7 @@ sub save {
my $ini = { _ => {} };
foreach my $opt_key (sort keys %$self) {
next if $Options->{$opt_key}{shortcut};
next if $Options->{$opt_key}{gui_only};
$ini->{_}{$opt_key} = $self->serialize($opt_key);
}
@ -1062,8 +1136,9 @@ sub validate {
if $self->perimeters < 0;
# --solid-layers
die "Invalid value for --solid-layers\n"
if $self->solid_layers < 0;
die "Invalid value for --solid-layers\n" if defined $self->solid_layers && $self->solid_layers < 0;
die "Invalid value for --top-solid-layers\n" if $self->top_solid_layers < 0;
die "Invalid value for --bottom-solid-layers\n" if $self->bottom_solid_layers < 0;
# --print-center
die "Invalid value for --print-center\n"
@ -1132,9 +1207,11 @@ sub replace_options {
my $self = shift;
my ($string, $more_variables) = @_;
if ($more_variables) {
my $variables = join '|', keys %$more_variables;
$string =~ s/\[($variables)\]/$more_variables->{$1}/eg;
$more_variables ||= {};
$more_variables->{$_} = $ENV{$_} for grep /^SLIC3R_/, keys %ENV;
{
my $variables_regex = join '|', keys %$more_variables;
$string =~ s/\[($variables_regex)\]/$more_variables->{$1}/eg;
}
my @lt = localtime; $lt[5] += 1900; $lt[4] += 1;
@ -1148,13 +1225,21 @@ sub replace_options {
$string =~ s/\[version\]/$Slic3r::VERSION/eg;
# build a regexp to match the available options
my $options = join '|',
grep !$Slic3r::Config::Options->{$_}{multiline},
my @options = grep !$Slic3r::Config::Options->{$_}{multiline},
grep $self->has($_),
keys %{$Slic3r::Config::Options};
my $options_regex = join '|', @options;
# use that regexp to search and replace option names with option values
$string =~ s/\[($options)\]/$self->serialize($1)/eg;
$string =~ s/\[($options_regex)\]/$self->serialize($1)/eg;
foreach my $opt_key (grep ref $self->$_ eq 'ARRAY', @options) {
my $value = $self->$opt_key;
$string =~ s/\[${opt_key}_${_}\]/$value->[$_]/eg for 0 .. $#$value;
if ($Options->{$opt_key}{type} eq 'point') {
$string =~ s/\[${opt_key}_X\]/$value->[0]/eg;
$string =~ s/\[${opt_key}_Y\]/$value->[1]/eg;
}
}
return $string;
}