Save the vector used for aligning object volumes to origin and apply it to additional parts added from the object part panel in order to make them coincide

This commit is contained in:
Alessandro Ranellucci 2014-04-02 20:23:26 +02:00
parent 017158c877
commit 45559f87f3
3 changed files with 7 additions and 2 deletions

View File

@ -207,6 +207,9 @@ sub on_btn_load {
$new_volume->material_id($material_name); $new_volume->material_id($material_name);
} }
# apply the same translation we applied to the object
$new_volume->mesh->translate(@{$self->{model_object}->origin_translation}, 0);
# set a default extruder value, since user can't add it manually # set a default extruder value, since user can't add it manually
my $material = $self->{model_object}->model->materials->{$new_volume->material_id}; my $material = $self->{model_object}->model->materials->{$new_volume->material_id};
$material->config->set_ifndef('extruder', 1); $material->config->set_ifndef('extruder', 1);

View File

@ -309,6 +309,7 @@ has 'instances' => (is => 'rw');
has 'config' => (is => 'rw', default => sub { Slic3r::Config->new }); has 'config' => (is => 'rw', default => sub { Slic3r::Config->new });
has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ] has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ]
has '_bounding_box' => (is => 'rw'); has '_bounding_box' => (is => 'rw');
has 'origin_translation' => (is => 'ro', default => sub { Slic3r::Point->new }); # translation vector applied by center_around_origin()
sub add_volume { sub add_volume {
my $self = shift; my $self = shift;
@ -446,6 +447,7 @@ sub center_around_origin {
$shift[Y] -= $size->y/2; #// $shift[Y] -= $size->y/2; #//
$self->translate(@shift); $self->translate(@shift);
$self->origin_translation->translate(@shift[X,Y]);
if (defined $self->instances) { if (defined $self->instances) {
foreach my $instance (@{ $self->instances }) { foreach my $instance (@{ $self->instances }) {

View File

@ -42,8 +42,8 @@ sub BUILD {
# Translate meshes so that our toolpath generation algorithms work with smaller # Translate meshes so that our toolpath generation algorithms work with smaller
# XY coordinates; this translation is an optimization and not strictly required. # XY coordinates; this translation is an optimization and not strictly required.
# However, this also aligns object to Z = 0, which on the contrary is required # A cloned mesh will be aligned to 0 before slicing in _slice_region() since we
# since we don't assume input is already aligned. # don't assume it's already aligned and we don't alter the original position in model.
# We store the XY translation so that we can place copies correctly in the output G-code # We store the XY translation so that we can place copies correctly in the output G-code
# (copies are expressed in G-code coordinates and this translation is not publicly exposed). # (copies are expressed in G-code coordinates and this translation is not publicly exposed).
$self->_copies_shift(Slic3r::Point->new_scale($bb->x_min, $bb->y_min)); $self->_copies_shift(Slic3r::Point->new_scale($bb->x_min, $bb->y_min));