From 25d88bddff1aa323de1144b7373d511b4599f018 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 30 Oct 2012 14:11:32 +0100 Subject: [PATCH] Remove the change_layer method --- lib/Slic3r/GCode.pm | 17 ++--------------- lib/Slic3r/Print.pm | 4 +++- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 095b5666a..d9a41129a 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -6,7 +6,7 @@ use Slic3r::ExtrusionPath ':roles'; use Slic3r::Geometry qw(scale unscale scaled_epsilon points_coincide PI X Y A B); has 'multiple_extruders' => (is => 'ro', default => sub {0} ); -has 'layer' => (is => 'rw'); # this is not very correct, we should replace it with explicit layer_id and avoid using $self->layer->flow at all here because it's too general +has 'layer' => (is => 'rw'); has 'shift_x' => (is => 'rw', default => sub {0} ); has 'shift_y' => (is => 'rw', default => sub {0} ); has 'z' => (is => 'rw'); @@ -51,19 +51,6 @@ my %role_speeds = ( &EXTR_ROLE_SUPPORTMATERIAL => 'perimeter', ); -sub change_layer { - my $self = shift; - my ($layer) = @_; - - $self->layer($layer); - - my $gcode = ""; - $gcode .= $Slic3r::Config->replace_options($Slic3r::Config->layer_gcode) . "\n" - if $Slic3r::Config->layer_gcode; - - return $gcode; -} - # this method accepts Z in scaled coordinates sub move_z { my $self = shift; @@ -76,7 +63,7 @@ sub move_z { my $current_z = $self->z; if (!defined $current_z || $current_z != ($z + $self->lifted)) { $gcode .= $self->retract(move_z => $z); - $gcode .= $self->G0(undef, $z, 0, $comment || 'move to next layer (' . $self->layer->id . ')') + $gcode .= $self->G0(undef, $z, 0, $comment || ('move to next layer (' . $self->layer->id . ')')) unless ($current_z // -1) != ($self->z // -1); } diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 94f1d377b..9100da634 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -737,8 +737,10 @@ sub write_gcode { } # set new layer, but don't move Z as support material interfaces may need an intermediate one - $gcode .= $gcodegen->change_layer($self->objects->[$object_copies->[0][0]]->layers->[$layer_id]); + $gcodegen->layer($self->objects->[$object_copies->[0][0]]->layers->[$layer_id]); $gcodegen->elapsed_time(0); + $gcode .= $Slic3r::Config->replace_options($Slic3r::Config->layer_gcode) . "\n" + if $Slic3r::Config->layer_gcode; # extrude skirt if ($skirt_done < $Slic3r::Config->skirt_height) {