Refactoring: moved Slic3r::GCode::Base to Slic3r::GCode::Writer

This commit is contained in:
Alessandro Ranellucci 2014-10-25 10:42:07 +02:00
parent c2e710d092
commit 7f57f007cd
12 changed files with 154 additions and 212 deletions

View File

@ -56,6 +56,7 @@ use Slic3r::GCode::PlaceholderParser;
use Slic3r::GCode::Reader; use Slic3r::GCode::Reader;
use Slic3r::GCode::SpiralVase; use Slic3r::GCode::SpiralVase;
use Slic3r::GCode::VibrationLimit; use Slic3r::GCode::VibrationLimit;
use Slic3r::GCode::Writer;
use Slic3r::Geometry qw(PI); use Slic3r::Geometry qw(PI);
use Slic3r::Geometry::Clipper; use Slic3r::Geometry::Clipper;
use Slic3r::Layer; use Slic3r::Layer;

View File

@ -9,9 +9,10 @@ use Slic3r::Geometry qw(epsilon scale unscale scaled_epsilon points_coincide PI
use Slic3r::Geometry::Clipper qw(union_ex offset_ex); use Slic3r::Geometry::Clipper qw(union_ex offset_ex);
use Slic3r::Surface ':types'; use Slic3r::Surface ':types';
extends 'Slic3r::GCode::Base';
has 'config' => (is => 'ro', default => sub { Slic3r::Config::Full->new }); has 'config' => (is => 'ro', default => sub { Slic3r::Config::Full->new });
has '_writer' => (is => 'ro', default => sub { Slic3r::GCode::Writer->new },
handles => [qw(set_fan set_temperature set_bed_temperature
extruders reset_e multiple_extruders extruder)]);
has 'placeholder_parser' => (is => 'rw', default => sub { Slic3r::GCode::PlaceholderParser->new }); has 'placeholder_parser' => (is => 'rw', default => sub { Slic3r::GCode::PlaceholderParser->new });
has 'ooze_prevention' => (is => 'rw'); has 'ooze_prevention' => (is => 'rw');
has 'enable_loop_clipping' => (is => 'rw', default => sub {1}); has 'enable_loop_clipping' => (is => 'rw', default => sub {1});
@ -36,17 +37,17 @@ has 'wipe_path' => (is => 'rw');
sub apply_print_config { sub apply_print_config {
my ($self, $print_config) = @_; my ($self, $print_config) = @_;
$self->SUPER::apply_print_config($print_config); $self->_writer->apply_print_config($print_config);
$self->config->apply_print_config($print_config); $self->config->apply_print_config($print_config);
} }
sub set_extruders { sub set_extruders {
my ($self, $extruder_ids) = @_; my ($self, $extruder_ids) = @_;
$self->SUPER::set_extruders($extruder_ids); $self->_writer->set_extruders($extruder_ids);
# enable wipe path generation if any extruder has wipe enabled # enable wipe path generation if any extruder has wipe enabled
$self->enable_wipe(defined first { $_->wipe } values %{$self->_extruders}); $self->enable_wipe(defined first { $self->config->get_at('wipe', $_) } @$extruder_ids);
} }
sub set_shift { sub set_shift {
@ -82,15 +83,14 @@ sub change_layer {
my $gcode = ""; my $gcode = "";
if (defined $self->layer_count) { if (defined $self->layer_count) {
# TODO: cap this to 99% and add an explicit M73 P100 in the end G-code # TODO: cap this to 99% and add an explicit M73 P100 in the end G-code
$gcode .= $self->update_progress(int(99 * ($self->_layer_index / ($self->layer_count - 1)))); $gcode .= $self->_writer->update_progress(int(99 * ($self->_layer_index / ($self->layer_count - 1))));
} }
my $z = $layer->print_z + $self->config->z_offset; # in unscaled coordinates my $z = $layer->print_z + $self->config->z_offset; # in unscaled coordinates
if ($self->_extruder->retract_layer_change && $self->will_move_z($z)) { if ($self->config->get_at('retract_layer_change', $self->_writer->extruder->id) && $self->_writer->will_move_z($z)) {
$gcode .= $self->retract; $gcode .= $self->retract;
$gcode .= $self->lift;
} }
$gcode .= $self->travel_to_z($z, 'move to next layer (' . $self->layer->id . ')'); $gcode .= $self->_writer->travel_to_z($z, 'move to next layer (' . $self->layer->id . ')');
return $gcode; return $gcode;
} }
@ -120,7 +120,7 @@ sub extrude_loop {
} elsif ($self->config->seam_position eq 'nearest' || $self->config->seam_position eq 'aligned') { } elsif ($self->config->seam_position eq 'nearest' || $self->config->seam_position eq 'aligned') {
# simplify polygon in order to skip false positives in concave/convex detection # simplify polygon in order to skip false positives in concave/convex detection
my $polygon = $loop->polygon; my $polygon = $loop->polygon;
my @simplified = @{$polygon->simplify(scale $self->_extruder->nozzle_diameter/2)}; my @simplified = @{$polygon->simplify(scale $self->config->get_at('nozzle_diameter', $self->_writer->extruder->id)/2)};
# concave vertices have priority # concave vertices have priority
my @candidates = map @{$_->concave_points(PI*4/3)}, @simplified; my @candidates = map @{$_->concave_points(PI*4/3)}, @simplified;
@ -166,7 +166,7 @@ sub extrude_loop {
# if polyline was shorter than the clipping distance we'd get a null polyline, so # if polyline was shorter than the clipping distance we'd get a null polyline, so
# we discard it in that case # we discard it in that case
my $clip_length = $self->enable_loop_clipping my $clip_length = $self->enable_loop_clipping
? scale($self->_extruder->nozzle_diameter) * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER ? scale($self->config->get_at('nozzle_diameter', $self->_writer->extruder->id)) * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER
: 0; : 0;
# get paths # get paths
@ -183,7 +183,7 @@ sub extrude_loop {
my $gcode = join '', map $self->_extrude_path($_, $description, $speed), @paths; my $gcode = join '', map $self->_extrude_path($_, $description, $speed), @paths;
# reset acceleration # reset acceleration
$gcode .= $self->set_acceleration($self->config->default_acceleration); $gcode .= $self->_writer->set_acceleration($self->config->default_acceleration);
$self->wipe_path($paths[-1]->polyline->clone) if $self->enable_wipe; # TODO: don't limit wipe to last path $self->wipe_path($paths[-1]->polyline->clone) if $self->enable_wipe; # TODO: don't limit wipe to last path
@ -200,7 +200,7 @@ sub extrude_loop {
# we make sure we don't exceed the segment length because we don't know # we make sure we don't exceed the segment length because we don't know
# the rotation of the second segment so we might cross the object boundary # the rotation of the second segment so we might cross the object boundary
my $first_segment = Slic3r::Line->new(@$last_path_polyline[0,1]); my $first_segment = Slic3r::Line->new(@$last_path_polyline[0,1]);
my $distance = min(scale($self->_extruder->nozzle_diameter), $first_segment->length); my $distance = min(scale($self->config->get_at('nozzle_diameter', $self->_writer->extruder->id)), $first_segment->length);
my $point = $first_segment->point_at($distance); my $point = $first_segment->point_at($distance);
$point->rotate($angle, $last_path_polyline->first_point); $point->rotate($angle, $last_path_polyline->first_point);
@ -217,7 +217,7 @@ sub extrude_path {
my $gcode = $self->_extrude_path($path, $description, $speed); my $gcode = $self->_extrude_path($path, $description, $speed);
# reset acceleration # reset acceleration
$gcode .= $self->set_acceleration($self->config->default_acceleration); $gcode .= $self->_writer->set_acceleration($self->config->default_acceleration);
return $gcode; return $gcode;
} }
@ -252,12 +252,12 @@ sub _extrude_path {
} else { } else {
$acceleration = $self->config->default_acceleration; $acceleration = $self->config->default_acceleration;
} }
$gcode .= $self->set_acceleration($acceleration); $gcode .= $self->_writer->set_acceleration($acceleration);
} }
# calculate extrusion length per distance unit # calculate extrusion length per distance unit
my $e_per_mm = $self->_extruder->e_per_mm3 * $path->mm3_per_mm; my $e_per_mm = $self->_writer->extruder->e_per_mm3 * $path->mm3_per_mm;
$e_per_mm = 0 if !$self->_extrusion_axis; $e_per_mm = 0 if !$self->_writer->_extrusion_axis;
# set speed # set speed
my $F; my $F;
@ -289,10 +289,11 @@ sub _extrude_path {
$gcode .= ";_BRIDGE_FAN_START\n" if $path->is_bridge; $gcode .= ";_BRIDGE_FAN_START\n" if $path->is_bridge;
my $path_length = unscale $path->length; my $path_length = unscale $path->length;
{ {
$gcode .= $path->gcode($self->_extruder, $e_per_mm, $F, my $extruder_offset = $self->config->get_at('extruder_offset', $self->_writer->extruder->id);
$self->shift_x - $self->_extruder->extruder_offset->x, $gcode .= $path->gcode($self->_writer->extruder, $e_per_mm, $F,
$self->shift_y - $self->_extruder->extruder_offset->y, #,, $self->shift_x - $extruder_offset->x,
$self->_extrusion_axis, $self->shift_y - $extruder_offset->y, #,,
$self->_writer->_extrusion_axis,
$self->config->gcode_comments ? " ; $description" : ""); $self->config->gcode_comments ? " ; $description" : "");
if ($self->enable_wipe) { if ($self->enable_wipe) {
@ -324,7 +325,7 @@ sub travel_to {
# skip retraction if the travel move is contained in an island in the current layer # skip retraction if the travel move is contained in an island in the current layer
# *and* in an island in the upper layer (so that the ooze will not be visible) # *and* in an island in the upper layer (so that the ooze will not be visible)
if ($travel->length < scale $self->_extruder->retract_before_travel if ($travel->length < scale $self->config->get_at('retract_before_travel', $self->_writer->extruder->id)
|| ($self->config->only_retract_when_crossing_perimeters || ($self->config->only_retract_when_crossing_perimeters
&& $self->config->fill_density > 0 && $self->config->fill_density > 0
&& (first { $_->contains_line($travel) } @{$self->_upper_layer_islands}) && (first { $_->contains_line($travel) } @{$self->_upper_layer_islands})
@ -332,11 +333,11 @@ sub travel_to {
|| (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->contains_line($travel) } @{$self->layer->support_islands})) || (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->contains_line($travel) } @{$self->layer->support_islands}))
) { ) {
$self->straight_once(0); $self->straight_once(0);
$gcode .= $self->travel_to_xy($self->point_to_gcode($point), $comment); $gcode .= $self->_writer->travel_to_xy($self->point_to_gcode($point), $comment);
} elsif (!$self->config->avoid_crossing_perimeters || $self->straight_once) { } elsif (!$self->config->avoid_crossing_perimeters || $self->straight_once) {
$self->straight_once(0); $self->straight_once(0);
$gcode .= $self->retract; $gcode .= $self->retract;
$gcode .= $self->travel_to_xy($self->point_to_gcode($point), $comment); $gcode .= $self->_writer->travel_to_xy($self->point_to_gcode($point), $comment);
} else { } else {
if ($self->new_object) { if ($self->new_object) {
$self->new_object(0); $self->new_object(0);
@ -383,7 +384,7 @@ sub _plan {
# append the actual path and return # append the actual path and return
# use G1 because we rely on paths being straight (G0 may make round paths) # use G1 because we rely on paths being straight (G0 may make round paths)
$gcode .= join '', $gcode .= join '',
map $self->travel_to_xy($self->point_to_gcode($_->b), $comment), map $self->_writer->travel_to_xy($self->point_to_gcode($_->b), $comment),
@travel; @travel;
return $gcode; return $gcode;
} }
@ -391,25 +392,25 @@ sub _plan {
sub retract { sub retract {
my ($self, $toolchange) = @_; my ($self, $toolchange) = @_;
return "" if !defined $self->_extruder; return "" if !defined $self->_writer->extruder;
my $gcode = ""; my $gcode = "";
# wipe (if it's enabled for this extruder and we have a stored wipe path) # wipe (if it's enabled for this extruder and we have a stored wipe path)
if ($self->_extruder->wipe && $self->wipe_path) { if ($self->config->get_at('wipe', $self->_writer->extruder->id) && $self->wipe_path) {
# Reduce feedrate a bit; travel speed is often too high to move on existing material. # Reduce feedrate a bit; travel speed is often too high to move on existing material.
# Too fast = ripping of existing material; too slow = short wipe path, thus more blob. # Too fast = ripping of existing material; too slow = short wipe path, thus more blob.
my $wipe_speed = $self->gcode_config->travel_speed * 0.8; my $wipe_speed = $self->_writer->config->travel_speed * 0.8;
# get the retraction length # get the retraction length
my $length = $toolchange my $length = $toolchange
? $self->_extruder->retract_length ? $self->_writer->extruder->retract_length
: $self->_extruder->retract_length_toolchange; : $self->_writer->extruder->retract_length_toolchange;
# Calculate how long we need to travel in order to consume the required # Calculate how long we need to travel in order to consume the required
# amount of retraction. In other words, how far do we move in XY at $wipe_speed # amount of retraction. In other words, how far do we move in XY at $wipe_speed
# for the time needed to consume retract_length at retract_speed? # for the time needed to consume retract_length at retract_speed?
my $wipe_dist = scale($length / $self->_extruder->retract_speed * $wipe_speed); my $wipe_dist = scale($length / $self->_writer->extruder->retract_speed * $wipe_speed);
# Take the stored wipe path and replace first point with the current actual position # Take the stored wipe path and replace first point with the current actual position
# (they might be different, for example, in case of loop clipping). # (they might be different, for example, in case of loop clipping).
@ -427,25 +428,25 @@ sub retract {
# Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one # Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
# due to rounding (TODO: test and/or better math for this) # due to rounding (TODO: test and/or better math for this)
my $dE = $length * ($segment_length / $wipe_dist) * 0.95; my $dE = $length * ($segment_length / $wipe_dist) * 0.95;
$gcode .= $self->set_speed($wipe_speed*60); $gcode .= $self->_writer->set_speed($wipe_speed*60);
$gcode .= $self->extrude_to_xy( $gcode .= $self->_writer->extrude_to_xy(
$self->point_to_gcode($line->b), $self->point_to_gcode($line->b),
-$dE, -$dE,
'retract;_WIPE', 'retract;_WIPE',
); );
$retracted += $dE; $retracted += $dE;
} }
$self->_extruder->set_retracted($self->_extruder->retracted + $retracted); $self->_writer->extruder->set_retracted($self->_writer->extruder->retracted + $retracted);
} }
# The parent class will decide whether we need to perform an actual retraction # The parent class will decide whether we need to perform an actual retraction
# (the extruder might be already retracted fully or partially). We call these # (the extruder might be already retracted fully or partially). We call these
# methods even if we performed wipe, since this will ensure the entire retraction # methods even if we performed wipe, since this will ensure the entire retraction
# length is honored in case wipe path was too short.p # length is honored in case wipe path was too short.p
$gcode .= $toolchange ? $self->retract_for_toolchange : $self->SUPER::retract; $gcode .= $toolchange ? $self->_writer->retract_for_toolchange : $self->_writer->retract;
$gcode .= $self->reset_e; $gcode .= $self->_writer->reset_e;
$gcode .= $self->lift; $gcode .= $self->_writer->lift;
return $gcode; return $gcode;
} }
@ -454,8 +455,8 @@ sub unretract {
my ($self) = @_; my ($self) = @_;
my $gcode = ""; my $gcode = "";
$gcode .= $self->unlift; $gcode .= $self->_writer->unlift;
$gcode .= $self->SUPER::unretract('compensate retraction'); $gcode .= $self->_writer->unretract('compensate retraction');
return $gcode; return $gcode;
} }
@ -463,29 +464,30 @@ sub unretract {
sub point_to_gcode { sub point_to_gcode {
my ($self, $point) = @_; my ($self, $point) = @_;
my $extruder_offset = $self->config->get_at('extruder_offset', $self->_writer->extruder->id);
return Slic3r::Pointf->new( return Slic3r::Pointf->new(
($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $self->_extruder->extruder_offset->x, ($point->x * &Slic3r::SCALING_FACTOR) + $self->shift_x - $extruder_offset->x,
($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $self->_extruder->extruder_offset->y, #** ($point->y * &Slic3r::SCALING_FACTOR) + $self->shift_y - $extruder_offset->y, #**
); );
} }
sub set_extruder { sub set_extruder {
my ($self, $extruder_id) = @_; my ($self, $extruder_id) = @_;
return "" if !$self->need_toolchange($extruder_id); return "" if !$self->_writer->need_toolchange($extruder_id);
# if we are running a single-extruder setup, just set the extruder and return nothing # if we are running a single-extruder setup, just set the extruder and return nothing
if (!$self->_multiple_extruders) { if (!$self->_writer->multiple_extruders) {
return $self->_toolchange($extruder_id); return $self->_writer->toolchange($extruder_id);
} }
# prepend retraction on the current extruder # prepend retraction on the current extruder
my $gcode = $self->retract(1); my $gcode = $self->retract(1);
# append custom toolchange G-code # append custom toolchange G-code
if (defined $self->_extruder && $self->config->toolchange_gcode) { if (defined $self->_writer->extruder && $self->config->toolchange_gcode) {
$gcode .= sprintf "%s\n", $self->placeholder_parser->process($self->config->toolchange_gcode, { $gcode .= sprintf "%s\n", $self->placeholder_parser->process($self->config->toolchange_gcode, {
previous_extruder => $self->_extruder->id, previous_extruder => $self->_writer->extruder->id,
next_extruder => $extruder_id, next_extruder => $extruder_id,
}); });
} }
@ -493,10 +495,10 @@ sub set_extruder {
# if ooze prevention is enabled, park current extruder in the nearest # if ooze prevention is enabled, park current extruder in the nearest
# standby point and set it to the standby temperature # standby point and set it to the standby temperature
$gcode .= $self->ooze_prevention->pre_toolchange($self) $gcode .= $self->ooze_prevention->pre_toolchange($self)
if $self->ooze_prevention && defined $self->_extruder; if $self->ooze_prevention && defined $self->_writer->extruder;
# append the toolchange command # append the toolchange command
$gcode .= $self->_toolchange($extruder_id); $gcode .= $self->_writer->toolchange($extruder_id);
# set the new extruder to the operating temperature # set the new extruder to the operating temperature
$gcode .= $self->ooze_prevention->post_toolchange($self) $gcode .= $self->ooze_prevention->post_toolchange($self)

View File

@ -4,7 +4,7 @@ use Moo;
use List::Util qw(first); use List::Util qw(first);
use Slic3r::Geometry qw(X Y unscale); use Slic3r::Geometry qw(X Y unscale);
has 'print' => (is => 'ro', required => 1); has 'print' => (is => 'ro', required => 1, handles => [qw(config)]);
has 'gcodegen' => (is => 'ro', required => 1, handles => [qw(extruders)]); has 'gcodegen' => (is => 'ro', required => 1, handles => [qw(extruders)]);
has 'shift' => (is => 'ro', default => sub { [0,0] }); has 'shift' => (is => 'ro', default => sub { [0,0] });
@ -64,8 +64,9 @@ sub process_layer {
if (!$self->second_layer_things_done && $layer->id == 1) { if (!$self->second_layer_things_done && $layer->id == 1) {
for my $extruder (@{$self->extruders}) { for my $extruder (@{$self->extruders}) {
$gcode .= $self->gcodegen->set_temperature($extruder->temperature, 0, $extruder->id) my $temperature = $self->config->get_at('temperature', $extruder->id);
if $extruder->temperature && $extruder->temperature != $extruder->first_layer_temperature; $gcode .= $self->gcodegen->set_temperature($temperature, 0, $extruder->id)
if $temperature && $temperature != $self->config->get_at('first_layer_temperature', $extruder->id);
} }
$gcode .= $self->gcodegen->set_bed_temperature($self->print->config->bed_temperature) $gcode .= $self->gcodegen->set_bed_temperature($self->print->config->bed_temperature)
if $self->print->config->bed_temperature && $self->print->config->bed_temperature != $self->print->config->first_layer_bed_temperature; if $self->print->config->bed_temperature && $self->print->config->bed_temperature != $self->print->config->first_layer_bed_temperature;
@ -135,9 +136,9 @@ sub process_layer {
# tweak region ordering to save toolchanges # tweak region ordering to save toolchanges
my @region_ids = 0 .. ($self->print->region_count-1); my @region_ids = 0 .. ($self->print->region_count-1);
if ($self->gcodegen->has_multiple_extruders) { if ($self->gcodegen->multiple_extruders) {
my $last_extruder = $self->gcodegen->extruder; my $last_extruder_id = $self->gcodegen->extruder->id;
my $best_region_id = first { $self->print->regions->[$_]->config->perimeter_extruder-1 eq $last_extruder } @region_ids; my $best_region_id = first { $self->print->regions->[$_]->config->perimeter_extruder-1 == $last_extruder_id } @region_ids;
@region_ids = ($best_region_id, grep $_ != $best_region_id, @region_ids) if $best_region_id; @region_ids = ($best_region_id, grep $_ != $best_region_id, @region_ids) if $best_region_id;
} }
@ -175,7 +176,7 @@ sub process_layer {
# give priority to infill if we were already using its extruder and it wouldn't # give priority to infill if we were already using its extruder and it wouldn't
# be good for perimeters # be good for perimeters
if ($self->print->config->infill_first if ($self->print->config->infill_first
|| ($self->gcodegen->has_multiple_extruders && $region->config->infill_extruder-1 == $self->gcodegen->extruder->id && $region->config->infill_extruder != $region->config->perimeter_extruder)) { || ($self->gcodegen->multiple_extruders && $region->config->infill_extruder-1 == $self->gcodegen->extruder->id && $region->config->infill_extruder != $region->config->perimeter_extruder)) {
$gcode .= $self->_extrude_infill($infill_by_island[$i], $region); $gcode .= $self->_extrude_infill($infill_by_island[$i], $region);
$gcode .= $self->_extrude_perimeters($perimeters_by_island[$i], $region); $gcode .= $self->_extrude_perimeters($perimeters_by_island[$i], $region);
} else { } else {

View File

@ -21,8 +21,8 @@ sub pre_toolchange {
if ($gcodegen->config->standby_temperature_delta != 0) { if ($gcodegen->config->standby_temperature_delta != 0) {
my $temp = defined $gcodegen->layer && $gcodegen->layer->id == 0 my $temp = defined $gcodegen->layer && $gcodegen->layer->id == 0
? $gcodegen->_extruder->first_layer_temperature ? $gcodegen->config->get_at('first_layer_temperature', $gcodegen->extruder->id)
: $gcodegen->_extruder->temperature; : $gcodegen->config->get_at('temperature', $gcodegen->extruder->id);
# we assume that heating is always slower than cooling, so no need to block # we assume that heating is always slower than cooling, so no need to block
$gcode .= $gcodegen->set_temperature($temp + $gcodegen->config->standby_temperature_delta, 0); $gcode .= $gcodegen->set_temperature($temp + $gcodegen->config->standby_temperature_delta, 0);
} }
@ -37,8 +37,8 @@ sub post_toolchange {
if ($gcodegen->config->standby_temperature_delta != 0) { if ($gcodegen->config->standby_temperature_delta != 0) {
my $temp = defined $gcodegen->layer && $gcodegen->layer->id == 0 my $temp = defined $gcodegen->layer && $gcodegen->layer->id == 0
? $gcodegen->_extruder->first_layer_temperature ? $gcodegen->config->get_at('first_layer_temperature', $gcodegen->extruder->id)
: $gcodegen->_extruder->temperature; : $gcodegen->config->get_at('temperature', $gcodegen->extruder->id);
$gcode .= $gcodegen->set_temperature($temp, 1); $gcode .= $gcodegen->set_temperature($temp, 1);
} }

View File

@ -1,14 +1,14 @@
package Slic3r::GCode::Base; package Slic3r::GCode::Writer;
use Moo; use Moo;
use List::Util qw(min max first); use List::Util qw(min max first);
use Slic3r::Geometry qw(X Y epsilon); use Slic3r::Geometry qw(X Y epsilon);
has 'gcode_config' => (is => 'ro', default => sub { Slic3r::Config::GCode->new }); has 'config' => (is => 'ro', default => sub { Slic3r::Config::GCode->new });
has 'multiple_extruders' => (is => 'rw', default => sub { 0 });
has '_extrusion_axis' => (is => 'rw', default => sub { 'E' }); has '_extrusion_axis' => (is => 'rw', default => sub { 'E' });
has '_extruders' => (is => 'ro', default => sub {{}}); has '_extruders' => (is => 'ro', default => sub {{}});
has '_extruder' => (is => 'rw'); has '_extruder' => (is => 'rw', reader => 'extruder');
has '_multiple_extruders' => (is => 'rw', default => sub { 0 });
has '_last_acceleration' => (is => 'rw', default => sub { 0 }); has '_last_acceleration' => (is => 'rw', default => sub { 0 });
has '_last_fan_speed' => (is => 'rw', default => sub { 0 }); has '_last_fan_speed' => (is => 'rw', default => sub { 0 });
has '_lifted' => (is => 'rw', default => sub { 0 }); has '_lifted' => (is => 'rw', default => sub { 0 });
@ -17,14 +17,14 @@ has '_pos' => (is => 'rw', default => sub { Slic3r::Pointf3->ne
sub apply_print_config { sub apply_print_config {
my ($self, $print_config) = @_; my ($self, $print_config) = @_;
$self->gcode_config->apply_print_config($print_config); $self->config->apply_print_config($print_config);
if ($self->gcode_config->gcode_flavor eq 'mach3') { if ($self->config->gcode_flavor eq 'mach3') {
$self->_extrusion_axis('A'); $self->_extrusion_axis('A');
} elsif ($self->gcode_config->gcode_flavor eq 'no-extrusion') { } elsif ($self->config->gcode_flavor eq 'no-extrusion') {
$self->_extrusion_axis(''); $self->_extrusion_axis('');
} else { } else {
$self->_extrusion_axis($self->gcode_config->extrusion_axis); $self->_extrusion_axis($self->config->extrusion_axis);
} }
} }
@ -38,23 +38,23 @@ sub set_extruders {
# we enable support for multiple extruder if any extruder greater than 0 is used # we enable support for multiple extruder if any extruder greater than 0 is used
# (even if prints only uses that one) since we need to output Tx commands # (even if prints only uses that one) since we need to output Tx commands
# first extruder has index 0 # first extruder has index 0
$self->_multiple_extruders(max(@$extruder_ids) > 0); $self->multiple_extruders(max(@$extruder_ids) > 0);
} }
sub set_temperature { sub set_temperature {
my ($self, $temperature, $wait, $tool) = @_; my ($self, $temperature, $wait, $tool) = @_;
return "" if $wait && $self->gcode_config->gcode_flavor =~ /^(?:makerware|sailfish)$/; return "" if $wait && $self->config->gcode_flavor =~ /^(?:makerware|sailfish)$/;
my ($code, $comment) = ($wait && $self->gcode_config->gcode_flavor ne 'teacup') my ($code, $comment) = ($wait && $self->config->gcode_flavor ne 'teacup')
? ('M109', 'wait for temperature to be reached') ? ('M109', 'wait for temperature to be reached')
: ('M104', 'set temperature'); : ('M104', 'set temperature');
my $gcode = sprintf "$code %s%d %s; $comment\n", my $gcode = sprintf "$code %s%d %s; $comment\n",
($self->gcode_config->gcode_flavor eq 'mach3' ? 'P' : 'S'), $temperature, ($self->config->gcode_flavor eq 'mach3' ? 'P' : 'S'), $temperature,
(defined $tool && ($self->_multiple_extruders || $self->gcode_config->gcode_flavor =~ /^(?:makerware|sailfish)$/)) ? "T$tool " : ""; (defined $tool && ($self->multiple_extruders || $self->config->gcode_flavor =~ /^(?:makerware|sailfish)$/)) ? "T$tool " : "";
$gcode .= "M116 ; wait for temperature to be reached\n" $gcode .= "M116 ; wait for temperature to be reached\n"
if $self->gcode_config->gcode_flavor eq 'teacup' && $wait; if $self->config->gcode_flavor eq 'teacup' && $wait;
return $gcode; return $gcode;
} }
@ -62,14 +62,14 @@ sub set_temperature {
sub set_bed_temperature { sub set_bed_temperature {
my ($self, $temperature, $wait) = @_; my ($self, $temperature, $wait) = @_;
my ($code, $comment) = ($wait && $self->gcode_config->gcode_flavor ne 'teacup') my ($code, $comment) = ($wait && $self->config->gcode_flavor ne 'teacup')
? (($self->gcode_config->gcode_flavor =~ /^(?:makerware|sailfish)$/ ? 'M109' : 'M190'), 'wait for bed temperature to be reached') ? (($self->config->gcode_flavor =~ /^(?:makerware|sailfish)$/ ? 'M109' : 'M190'), 'wait for bed temperature to be reached')
: ('M140', 'set bed temperature'); : ('M140', 'set bed temperature');
my $gcode = sprintf "$code %s%d ; $comment\n", my $gcode = sprintf "$code %s%d ; $comment\n",
($self->gcode_config->gcode_flavor eq 'mach3' ? 'P' : 'S'), $temperature; ($self->config->gcode_flavor eq 'mach3' ? 'P' : 'S'), $temperature;
$gcode .= "M116 ; wait for bed temperature to be reached\n" $gcode .= "M116 ; wait for bed temperature to be reached\n"
if $self->gcode_config->gcode_flavor eq 'teacup' && $wait; if $self->config->gcode_flavor eq 'teacup' && $wait;
return $gcode; return $gcode;
} }
@ -80,18 +80,18 @@ sub set_fan {
if ($self->_last_fan_speed != $speed || $dont_save) { if ($self->_last_fan_speed != $speed || $dont_save) {
$self->_last_fan_speed($speed) if !$dont_save; $self->_last_fan_speed($speed) if !$dont_save;
if ($speed == 0) { if ($speed == 0) {
my $code = $self->gcode_config->gcode_flavor eq 'teacup' my $code = $self->config->gcode_flavor eq 'teacup'
? 'M106 S0' ? 'M106 S0'
: $self->gcode_config->gcode_flavor =~ /^(?:makerware|sailfish)$/ : $self->config->gcode_flavor =~ /^(?:makerware|sailfish)$/
? 'M127' ? 'M127'
: 'M107'; : 'M107';
return sprintf "$code%s\n", ($self->gcode_config->gcode_comments ? ' ; disable fan' : ''); return sprintf "$code%s\n", ($self->config->gcode_comments ? ' ; disable fan' : '');
} else { } else {
if ($self->gcode_config->gcode_flavor =~ /^(?:makerware|sailfish)$/) { if ($self->config->gcode_flavor =~ /^(?:makerware|sailfish)$/) {
return sprintf "M126%s\n", ($self->gcode_config->gcode_comments ? ' ; enable fan' : ''); return sprintf "M126%s\n", ($self->config->gcode_comments ? ' ; enable fan' : '');
} else { } else {
return sprintf "M106 %s%d%s\n", ($self->gcode_config->gcode_flavor eq 'mach3' ? 'P' : 'S'), return sprintf "M106 %s%d%s\n", ($self->config->gcode_flavor eq 'mach3' ? 'P' : 'S'),
(255 * $speed / 100), ($self->gcode_config->gcode_comments ? ' ; enable fan' : ''); (255 * $speed / 100), ($self->config->gcode_comments ? ' ; enable fan' : '');
} }
} }
} }
@ -105,13 +105,13 @@ sub set_acceleration {
$self->_last_acceleration($acceleration); $self->_last_acceleration($acceleration);
return sprintf "M204 S%s%s\n", return sprintf "M204 S%s%s\n",
$acceleration, ($self->gcode_config->gcode_comments ? ' ; adjust acceleration' : ''); $acceleration, ($self->config->gcode_comments ? ' ; adjust acceleration' : '');
} }
sub update_progress { sub update_progress {
my ($self, $percent) = @_; my ($self, $percent) = @_;
return "" if $self->gcode_config->gcode_flavor !~ /^(?:makerware|sailfish)$/; return "" if $self->config->gcode_flavor !~ /^(?:makerware|sailfish)$/;
return sprintf "M73 P%s%s\n", return sprintf "M73 P%s%s\n",
int($percent), int($percent),
$self->_comment('update progress'); $self->_comment('update progress');
@ -128,10 +128,10 @@ sub set_extruder {
my ($self, $extruder_id) = @_; my ($self, $extruder_id) = @_;
return "" if !$self->need_toolchange; return "" if !$self->need_toolchange;
return $self->_toolchange($extruder_id); return $self->toolchange($extruder_id);
} }
sub _toolchange { sub toolchange {
my ($self, $extruder_id) = @_; my ($self, $extruder_id) = @_;
# set the new extruder # set the new extruder
@ -140,15 +140,15 @@ sub _toolchange {
# return the toolchange command # return the toolchange command
# if we are running a single-extruder setup, just set the extruder and return nothing # if we are running a single-extruder setup, just set the extruder and return nothing
my $gcode = ""; my $gcode = "";
if ($self->_multiple_extruders) { if ($self->multiple_extruders) {
$gcode .= sprintf "%s%d%s\n", $gcode .= sprintf "%s%d%s\n",
($self->gcode_config->gcode_flavor eq 'makerware' ($self->config->gcode_flavor eq 'makerware'
? 'M135 T' ? 'M135 T'
: $self->gcode_config->gcode_flavor eq 'sailfish' : $self->config->gcode_flavor eq 'sailfish'
? 'M108 T' ? 'M108 T'
: 'T'), : 'T'),
$extruder_id, $extruder_id,
($self->gcode_config->gcode_comments ? ' ; change extruder' : ''); ($self->config->gcode_comments ? ' ; change extruder' : '');
$gcode .= $self->reset_e(1); $gcode .= $self->reset_e(1);
} }
@ -165,8 +165,8 @@ sub reset_e {
$self->_extruder->set_E(0) if $self->_extruder; $self->_extruder->set_E(0) if $self->_extruder;
} }
if ($self->_extrusion_axis ne '' && !$self->gcode_config->use_relative_e_distances) { if ($self->_extrusion_axis ne '' && !$self->config->use_relative_e_distances) {
return sprintf "G92 %s0%s\n", $self->gcode_config->extrusion_axis, ($self->config->gcode_comments ? ' ; reset extrusion distance' : ''); return sprintf "G92 %s0%s\n", $self->config->extrusion_axis, ($self->config->gcode_comments ? ' ; reset extrusion distance' : '');
} else { } else {
return ""; return "";
} }
@ -194,7 +194,7 @@ sub travel_to_xy {
$self->_pos->set_y($pointf->y); # )) $self->_pos->set_y($pointf->y); # ))
return sprintf "G1 X%.3f Y%.3f F%.3f%s\n", return sprintf "G1 X%.3f Y%.3f F%.3f%s\n",
@$pointf, @$pointf,
$self->gcode_config->travel_speed*60, $self->config->travel_speed*60,
$self->_comment($comment); $self->_comment($comment);
} }
@ -223,7 +223,7 @@ sub _travel_to_xyz {
$self->_pos($pointf3); $self->_pos($pointf3);
return sprintf "G1 X%.3f Y%.3f Z%.3f F%.3f%s\n", return sprintf "G1 X%.3f Y%.3f Z%.3f F%.3f%s\n",
@$pointf3, @$pointf3,
$self->gcode_config->travel_speed*60, $self->config->travel_speed*60,
$self->_comment($comment); $self->_comment($comment);
} }
@ -251,7 +251,7 @@ sub _travel_to_z {
$self->_pos->set_z($z); $self->_pos->set_z($z);
return sprintf "G1 Z%.3f F%.3f%s\n", return sprintf "G1 Z%.3f F%.3f%s\n",
$z, $z,
$self->gcode_config->travel_speed*60, $self->config->travel_speed*60,
$self->_comment($comment); $self->_comment($comment);
} }
@ -318,7 +318,7 @@ sub retract_for_toolchange {
sub _retract { sub _retract {
my ($self, $length, $restart_extra, $comment) = @_; my ($self, $length, $restart_extra, $comment) = @_;
if ($self->gcode_config->use_firmware_retraction) { if ($self->config->use_firmware_retraction) {
return "G10 ; retract\n"; return "G10 ; retract\n";
} }
@ -329,11 +329,11 @@ sub _retract {
$self->_extrusion_axis, $self->_extrusion_axis,
$self->_extruder->E, $self->_extruder->E,
$self->_extruder->retract_speed_mm_min, $self->_extruder->retract_speed_mm_min,
$self->_comment($comment . " dE = $dE"); $self->_comment($comment);
} }
$gcode .= "M103 ; extruder off\n" $gcode .= "M103 ; extruder off\n"
if $self->gcode_config->gcode_flavor eq 'makerware'; if $self->config->gcode_flavor eq 'makerware';
return $gcode; return $gcode;
} }
@ -344,9 +344,9 @@ sub unretract {
my $gcode = ""; my $gcode = "";
$gcode .= "M101 ; extruder on\n" $gcode .= "M101 ; extruder on\n"
if $self->gcode_config->gcode_flavor eq 'makerware'; if $self->config->gcode_flavor eq 'makerware';
if ($self->gcode_config->use_firmware_retraction) { if ($self->config->use_firmware_retraction) {
$gcode .= "G11 ; unretract\n"; $gcode .= "G11 ; unretract\n";
$gcode .= $self->reset_e; $gcode .= $self->reset_e;
return $gcode; return $gcode;
@ -371,8 +371,8 @@ sub unretract {
sub lift { sub lift {
my ($self) = @_; my ($self) = @_;
if ($self->_lifted == 0 && $self->gcode_config->retract_lift->[0] > 0) { if ($self->_lifted == 0 && $self->config->retract_lift->[0] > 0) {
my $to_lift = $self->gcode_config->retract_lift->[0]; my $to_lift = $self->config->retract_lift->[0];
$self->_lifted($to_lift); $self->_lifted($to_lift);
return $self->_travel_to_z($self->_pos->z + $to_lift, 'lift Z'); return $self->_travel_to_z($self->_pos->z + $to_lift, 'lift Z');
} }
@ -390,14 +390,9 @@ sub unlift {
return $gcode; return $gcode;
} }
sub has_multiple_extruders { sub hasmultiple_extruders {
my ($self) = @_; my ($self) = @_;
return $self->_multiple_extruders; return $self->multiple_extruders;
}
sub extruder {
my ($self) = @_;
return $self->_extruder;
} }
sub extruders { sub extruders {

View File

@ -875,8 +875,9 @@ sub write_gcode {
if ($finished_objects > 0) { if ($finished_objects > 0) {
$gcodegen->set_shift(map unscale $copy->[$_], X,Y); $gcodegen->set_shift(map unscale $copy->[$_], X,Y);
print $fh $gcodegen->retract; print $fh $gcodegen->retract;
print $fh $gcodegen->travel_to_xy( print $fh $gcodegen->travel_to(
$gcodegen->point_to_gcode($object->_copies_shift->negative), $object->_copies_shift->negative,
undef,
'move to origin position for next object', 'move to origin position for next object',
); );
} }

View File

@ -1,4 +1,4 @@
use Test::More tests => 18; use Test::More tests => 14;
use strict; use strict;
use warnings; use warnings;

View File

@ -123,12 +123,12 @@ ConfigBase::get(t_config_option_key opt_key) {
av_store(av, it - optv->values.begin(), newSVpvn_utf8(it->c_str(), it->length(), true)); av_store(av, it - optv->values.begin(), newSVpvn_utf8(it->c_str(), it->length(), true));
return newRV_noinc((SV*)av); return newRV_noinc((SV*)av);
} else if (ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt)) { } else if (ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt)) {
return optv->point.to_SV_pureperl(); return perl_to_SV_clone_ref(optv->point);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) { } else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) {
AV* av = newAV(); AV* av = newAV();
av_fill(av, optv->values.size()-1); av_fill(av, optv->values.size()-1);
for (Pointfs::iterator it = optv->values.begin(); it != optv->values.end(); ++it) for (Pointfs::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), it->to_SV_pureperl()); av_store(av, it - optv->values.begin(), perl_to_SV_clone_ref(*it));
return newRV_noinc((SV*)av); return newRV_noinc((SV*)av);
} else if (ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt)) { } else if (ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt)) {
return newSViv(optv->value ? 1 : 0); return newSViv(optv->value ? 1 : 0);
@ -158,7 +158,7 @@ ConfigBase::get_at(t_config_option_key opt_key, size_t i) {
std::string val = optv->get_at(i); std::string val = optv->get_at(i);
return newSVpvn_utf8(val.c_str(), val.length(), true); return newSVpvn_utf8(val.c_str(), val.length(), true);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) { } else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) {
return optv->get_at(i).to_SV_pureperl(); return perl_to_SV_clone_ref(optv->get_at(i));
} else if (ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt)) { } else if (ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt)) {
return newSViv(optv->get_at(i) ? 1 : 0); return newSViv(optv->get_at(i) ? 1 : 0);
} else { } else {

View File

@ -2,7 +2,7 @@
namespace Slic3r { namespace Slic3r {
Extruder::Extruder(int id, PrintConfig *config) Extruder::Extruder(int id, GCodeConfig *config)
: id(id), : id(id),
config(config) config(config)
{ {
@ -91,18 +91,6 @@ Extruder::used_filament() const
return this->absolute_E + this->retracted; return this->absolute_E + this->retracted;
} }
Pointf
Extruder::extruder_offset() const
{
return this->config->extruder_offset.get_at(this->id);
}
double
Extruder::nozzle_diameter() const
{
return this->config->nozzle_diameter.get_at(this->id);
}
double double
Extruder::filament_diameter() const Extruder::filament_diameter() const
{ {
@ -115,18 +103,6 @@ Extruder::extrusion_multiplier() const
return this->config->extrusion_multiplier.get_at(this->id); return this->config->extrusion_multiplier.get_at(this->id);
} }
int
Extruder::temperature() const
{
return this->config->temperature.get_at(this->id);
}
int
Extruder::first_layer_temperature() const
{
return this->config->first_layer_temperature.get_at(this->id);
}
double double
Extruder::retract_length() const Extruder::retract_length() const
{ {
@ -151,18 +127,6 @@ Extruder::retract_restart_extra() const
return this->config->retract_restart_extra.get_at(this->id); return this->config->retract_restart_extra.get_at(this->id);
} }
double
Extruder::retract_before_travel() const
{
return this->config->retract_before_travel.get_at(this->id);
}
bool
Extruder::retract_layer_change() const
{
return this->config->retract_layer_change.get_at(this->id);
}
double double
Extruder::retract_length_toolchange() const Extruder::retract_length_toolchange() const
{ {
@ -175,12 +139,6 @@ Extruder::retract_restart_extra_toolchange() const
return this->config->retract_restart_extra_toolchange.get_at(this->id); return this->config->retract_restart_extra_toolchange.get_at(this->id);
} }
bool
Extruder::wipe() const
{
return this->config->wipe.get_at(this->id);
}
#ifdef SLIC3RXS #ifdef SLIC3RXS
REGISTER_CLASS(Extruder, "Extruder"); REGISTER_CLASS(Extruder, "Extruder");

View File

@ -10,7 +10,15 @@ namespace Slic3r {
class Extruder class Extruder
{ {
public: public:
Extruder(int id, PrintConfig *config); int id;
double E;
double absolute_E;
double retracted;
double restart_extra;
double e_per_mm3;
double retract_speed_mm_min;
Extruder(int id, GCodeConfig *config);
virtual ~Extruder() {} virtual ~Extruder() {}
void reset(); void reset();
double extrude(double dE); double extrude(double dE);
@ -20,32 +28,17 @@ class Extruder
double extruded_volume() const; double extruded_volume() const;
double used_filament() const; double used_filament() const;
Pointf extruder_offset() const;
double nozzle_diameter() const;
double filament_diameter() const; double filament_diameter() const;
double extrusion_multiplier() const; double extrusion_multiplier() const;
int temperature() const;
int first_layer_temperature() const;
double retract_length() const; double retract_length() const;
double retract_lift() const; double retract_lift() const;
int retract_speed() const; int retract_speed() const;
double retract_restart_extra() const; double retract_restart_extra() const;
double retract_before_travel() const;
bool retract_layer_change() const;
double retract_length_toolchange() const; double retract_length_toolchange() const;
double retract_restart_extra_toolchange() const; double retract_restart_extra_toolchange() const;
bool wipe() const;
int id;
double E;
double absolute_E;
double retracted;
double restart_extra;
double e_per_mm3;
double retract_speed_mm_min;
private: private:
PrintConfig *config; GCodeConfig *config;
}; };
} }

View File

@ -310,6 +310,8 @@ class GCodeConfig : public virtual StaticPrintConfig
{ {
public: public:
ConfigOptionString extrusion_axis; ConfigOptionString extrusion_axis;
ConfigOptionFloats extrusion_multiplier;
ConfigOptionFloats filament_diameter;
ConfigOptionBool gcode_comments; ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor; ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionFloats retract_length; ConfigOptionFloats retract_length;
@ -324,6 +326,10 @@ class GCodeConfig : public virtual StaticPrintConfig
GCodeConfig() : StaticPrintConfig() { GCodeConfig() : StaticPrintConfig() {
this->extrusion_axis.value = "E"; this->extrusion_axis.value = "E";
this->extrusion_multiplier.values.resize(1);
this->extrusion_multiplier.values[0] = 1;
this->filament_diameter.values.resize(1);
this->filament_diameter.values[0] = 3;
this->gcode_comments.value = false; this->gcode_comments.value = false;
this->gcode_flavor.value = gcfRepRap; this->gcode_flavor.value = gcfRepRap;
this->retract_length.values.resize(1); this->retract_length.values.resize(1);
@ -345,6 +351,8 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOption* option(const t_config_option_key opt_key, bool create = false) { ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "extrusion_axis") return &this->extrusion_axis; if (opt_key == "extrusion_axis") return &this->extrusion_axis;
if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier;
if (opt_key == "filament_diameter") return &this->filament_diameter;
if (opt_key == "gcode_comments") return &this->gcode_comments; if (opt_key == "gcode_comments") return &this->gcode_comments;
if (opt_key == "gcode_flavor") return &this->gcode_flavor; if (opt_key == "gcode_flavor") return &this->gcode_flavor;
if (opt_key == "retract_length") return &this->retract_length; if (opt_key == "retract_length") return &this->retract_length;
@ -379,10 +387,8 @@ class PrintConfig : public GCodeConfig
ConfigOptionFloat extruder_clearance_height; ConfigOptionFloat extruder_clearance_height;
ConfigOptionFloat extruder_clearance_radius; ConfigOptionFloat extruder_clearance_radius;
ConfigOptionPoints extruder_offset; ConfigOptionPoints extruder_offset;
ConfigOptionFloats extrusion_multiplier;
ConfigOptionBool fan_always_on; ConfigOptionBool fan_always_on;
ConfigOptionInt fan_below_layer_time; ConfigOptionInt fan_below_layer_time;
ConfigOptionFloats filament_diameter;
ConfigOptionFloat first_layer_acceleration; ConfigOptionFloat first_layer_acceleration;
ConfigOptionInt first_layer_bed_temperature; ConfigOptionInt first_layer_bed_temperature;
ConfigOptionFloatOrPercent first_layer_extrusion_width; ConfigOptionFloatOrPercent first_layer_extrusion_width;
@ -440,12 +446,8 @@ class PrintConfig : public GCodeConfig
this->extruder_clearance_radius.value = 20; this->extruder_clearance_radius.value = 20;
this->extruder_offset.values.resize(1); this->extruder_offset.values.resize(1);
this->extruder_offset.values[0] = Pointf(0,0); this->extruder_offset.values[0] = Pointf(0,0);
this->extrusion_multiplier.values.resize(1);
this->extrusion_multiplier.values[0] = 1;
this->fan_always_on.value = false; this->fan_always_on.value = false;
this->fan_below_layer_time.value = 60; this->fan_below_layer_time.value = 60;
this->filament_diameter.values.resize(1);
this->filament_diameter.values[0] = 3;
this->first_layer_acceleration.value = 0; this->first_layer_acceleration.value = 0;
this->first_layer_bed_temperature.value = 0; this->first_layer_bed_temperature.value = 0;
this->first_layer_extrusion_width.value = 200; this->first_layer_extrusion_width.value = 200;
@ -507,10 +509,8 @@ class PrintConfig : public GCodeConfig
if (opt_key == "extruder_clearance_height") return &this->extruder_clearance_height; if (opt_key == "extruder_clearance_height") return &this->extruder_clearance_height;
if (opt_key == "extruder_clearance_radius") return &this->extruder_clearance_radius; if (opt_key == "extruder_clearance_radius") return &this->extruder_clearance_radius;
if (opt_key == "extruder_offset") return &this->extruder_offset; if (opt_key == "extruder_offset") return &this->extruder_offset;
if (opt_key == "extrusion_multiplier") return &this->extrusion_multiplier;
if (opt_key == "fan_always_on") return &this->fan_always_on; if (opt_key == "fan_always_on") return &this->fan_always_on;
if (opt_key == "fan_below_layer_time") return &this->fan_below_layer_time; if (opt_key == "fan_below_layer_time") return &this->fan_below_layer_time;
if (opt_key == "filament_diameter") return &this->filament_diameter;
if (opt_key == "first_layer_acceleration") return &this->first_layer_acceleration; if (opt_key == "first_layer_acceleration") return &this->first_layer_acceleration;
if (opt_key == "first_layer_bed_temperature") return &this->first_layer_bed_temperature; if (opt_key == "first_layer_bed_temperature") return &this->first_layer_bed_temperature;
if (opt_key == "first_layer_extrusion_width") return &this->first_layer_extrusion_width; if (opt_key == "first_layer_extrusion_width") return &this->first_layer_extrusion_width;

View File

@ -6,9 +6,7 @@
%} %}
%name{Slic3r::Extruder} class Extruder { %name{Slic3r::Extruder} class Extruder {
// We don't need a Perl constructor with PrintConfig at the moment Extruder(int id, GCodeConfig *config);
//Extruder(int id, PrintConfig *config);
Extruder(int id, FullPrintConfig *config);
~Extruder(); ~Extruder();
void reset(); void reset();
double extrude(double dE); double extrude(double dE);
@ -18,43 +16,36 @@
double extruded_volume(); double extruded_volume();
double used_filament(); double used_filament();
int id() const int id()
%code%{ RETVAL = THIS->id; %}; %code%{ RETVAL = THIS->id; %};
double E() const double E()
%code%{ RETVAL = THIS->E; %}; %code%{ RETVAL = THIS->E; %};
double set_E(double val) const double set_E(double val)
%code%{ RETVAL = THIS->E = val; %}; %code%{ RETVAL = THIS->E = val; %};
double absolute_E() const double absolute_E()
%code%{ RETVAL = THIS->absolute_E; %}; %code%{ RETVAL = THIS->absolute_E; %};
double set_absolute_E(double val) const double set_absolute_E(double val)
%code%{ RETVAL = THIS->absolute_E = val; %}; %code%{ RETVAL = THIS->absolute_E = val; %};
double retracted() const double retracted()
%code%{ RETVAL = THIS->retracted; %}; %code%{ RETVAL = THIS->retracted; %};
double set_retracted(double val) const double set_retracted(double val)
%code%{ RETVAL = THIS->retracted = val; %}; %code%{ RETVAL = THIS->retracted = val; %};
double restart_extra() const double restart_extra()
%code%{ RETVAL = THIS->restart_extra; %}; %code%{ RETVAL = THIS->restart_extra; %};
double set_restart_extra(double val) const double set_restart_extra(double val)
%code%{ RETVAL = THIS->restart_extra = val; %}; %code%{ RETVAL = THIS->restart_extra = val; %};
double e_per_mm3() double e_per_mm3()
%code%{ RETVAL = THIS->e_per_mm3; %}; %code%{ RETVAL = THIS->e_per_mm3; %};
double retract_speed_mm_min() double retract_speed_mm_min()
%code%{ RETVAL = THIS->retract_speed_mm_min; %}; %code%{ RETVAL = THIS->retract_speed_mm_min; %};
Clone<Pointf> extruder_offset() const; double filament_diameter();
double nozzle_diameter() const; double extrusion_multiplier();
double filament_diameter() const; double retract_length();
double extrusion_multiplier() const; double retract_lift();
int temperature() const; int retract_speed();
int first_layer_temperature() const; double retract_restart_extra();
double retract_length() const; double retract_length_toolchange();
double retract_lift() const; double retract_restart_extra_toolchange();
int retract_speed() const;
double retract_restart_extra() const;
double retract_before_travel() const;
bool retract_layer_change() const;
double retract_length_toolchange() const;
double retract_restart_extra_toolchange() const;
bool wipe() const;
}; };