From 229039d3b880e108c81025f9a6bea88c777f762a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 19 Jan 2015 15:30:34 +0100 Subject: [PATCH] Fixed test and implementation of ooze prevention standby points (wrong test caused wrong implementation). #2103 --- lib/Slic3r/GCode.pm | 13 ++++++++----- lib/Slic3r/GUI/3DScene.pm | 12 ++++++------ lib/Slic3r/Print/GCode.pm | 2 +- lib/Slic3r/Test.pm | 2 +- t/multi.t | 5 ++--- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index c3bc2dfb4..e0a760fdd 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -500,11 +500,14 @@ sub pre_toolchange { # move to the nearest standby point if (@{$self->standby_points}) { - my $last_pos = $gcodegen->last_pos->clone; - $last_pos->translate(scale +$gcodegen->origin->x, scale +$gcodegen->origin->y); #)) - my $standby_point = $last_pos->nearest_point($self->standby_points); - $standby_point->translate(scale -$gcodegen->origin->x, scale -$gcodegen->origin->y); #)) - $gcode .= $gcodegen->travel_to($standby_point, undef, 'move to standby position'); + # get current position in print coordinates + my $pos = Slic3r::Point->new_scale(@{$gcodegen->writer->get_position}[0,1]); + + my $standby_point = Slic3r::Pointf->new_unscale(@{$pos->nearest_point($self->standby_points)}); + # We don't call $gcodegen->travel_to() because we don't need retraction (it was already + # triggered by the caller) nor avoid_crossing_perimeters and also because the coordinates + # of the destination point must not be transformed by origin nor current extruder offset. + $gcode .= $gcodegen->writer->travel_to_xy($standby_point, 'move to standby position'); } if ($gcodegen->config->standby_temperature_delta != 0) { diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index daef81f75..c5837c3e9 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1138,8 +1138,8 @@ sub load_print_object_toolpaths { color => COLORS->[0], quad_verts => OpenGL::Array->new_list(GL_FLOAT, @perim_qverts), quad_norms => OpenGL::Array->new_list(GL_FLOAT, @perim_qnorms), - verts => OpenGL::Array->new_list(GL_FLOAT, @perim_tverts), - norms => OpenGL::Array->new_list(GL_FLOAT, @perim_tnorms), + #verts => OpenGL::Array->new_list(GL_FLOAT, @perim_tverts), + #norms => OpenGL::Array->new_list(GL_FLOAT, @perim_tnorms), offsets => { %perim_offsets }, ); @@ -1148,8 +1148,8 @@ sub load_print_object_toolpaths { color => COLORS->[1], quad_verts => OpenGL::Array->new_list(GL_FLOAT, @infill_qverts), quad_norms => OpenGL::Array->new_list(GL_FLOAT, @infill_qnorms), - verts => OpenGL::Array->new_list(GL_FLOAT, @infill_tverts), - norms => OpenGL::Array->new_list(GL_FLOAT, @infill_tnorms), + #verts => OpenGL::Array->new_list(GL_FLOAT, @infill_tverts), + #norms => OpenGL::Array->new_list(GL_FLOAT, @infill_tnorms), offsets => { %infill_offsets }, ); @@ -1158,8 +1158,8 @@ sub load_print_object_toolpaths { color => COLORS->[2], quad_verts => OpenGL::Array->new_list(GL_FLOAT, @support_qverts), quad_norms => OpenGL::Array->new_list(GL_FLOAT, @support_qnorms), - verts => OpenGL::Array->new_list(GL_FLOAT, @support_tverts), - norms => OpenGL::Array->new_list(GL_FLOAT, @support_tnorms), + #verts => OpenGL::Array->new_list(GL_FLOAT, @support_tverts), + #norms => OpenGL::Array->new_list(GL_FLOAT, @support_tnorms), offsets => { %support_offsets }, ); } diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index 0dee4f858..56196ba31 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -169,8 +169,8 @@ sub export { require "Slic3r/SVG.pm"; Slic3r::SVG::output( "ooze_prevention.svg", - polygons => [$outer_skirt], red_polygons => \@skirts, + polygons => [$outer_skirt], points => $gcodegen->ooze_prevention->standby_points, ); } diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index 32c12ac73..7f1fa5306 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -156,7 +156,7 @@ sub init_print { $model->duplicate($params{duplicate} // 1, $print->config->min_object_distance); } $model->arrange_objects($print->config->min_object_distance); - $model->center_instances_around_point(Slic3r::Pointf->new(@{$params{print_center}}) // Slic3r::Pointf->new(100,100)); + $model->center_instances_around_point($params{print_center} ? Slic3r::Pointf->new(@{$params{print_center}}) : Slic3r::Pointf->new(100,100)); foreach my $model_object (@{$model->objects}) { $print->auto_assign_extruders($model_object); $print->add_model_object($model_object); diff --git a/t/multi.t b/t/multi.t index 9b6340814..362f1f7b4 100644 --- a/t/multi.t +++ b/t/multi.t @@ -44,7 +44,6 @@ use Slic3r::Test; if $tool_temp[$tool] != $expected_temp + $config->standby_temperature_delta; push @toolchange_points, my $point = Slic3r::Point->new_scale($self->X, $self->Y); - $point->translate(map +scale($_), @{ $config->extruder_offset->[$tool] }); } $tool = $1; } elsif ($cmd eq 'M104' || $cmd eq 'M109') { @@ -73,11 +72,11 @@ use Slic3r::Test; if (0) { require "Slic3r/SVG.pm"; Slic3r::SVG::output( - "ooze_prevention.svg", + "ooze_prevention_test.svg", no_arrows => 1, polygons => [$convex_hull], - points => \@toolchange_points, red_points => \@t, + points => \@toolchange_points, ); }