From 25a6c7e30e83e6a691d580fdf3645635ed459a06 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 9 Aug 2018 16:55:43 +0200 Subject: Created a new gizmo for flattening an object --- lib/Slic3r/GUI/Plater.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a0eef72fe..e9cdf1527 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -141,8 +141,9 @@ sub new { # callback to react to gizmo rotate my $on_gizmo_rotate = sub { - my ($angle_z) = @_; + my ($angle_z, $angle_y) = @_; $self->rotate(rad2deg($angle_z), Z, 'absolute'); + $self->rotate(rad2deg($angle_y), Y, 'absolute'); }; # callback to update object's geometry info while using gizmos -- cgit v1.2.3 From b0dd328fdec094cd072ece2cbfff87dcf07d51c2 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 20 Aug 2018 11:27:25 +0200 Subject: Lay flat - icons and invalidation improvement --- lib/Slic3r/GUI/Plater.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 8ab749e24..98f31fb8b 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -143,7 +143,7 @@ sub new { my $on_gizmo_rotate = sub { my ($angle_z, $angle_y) = @_; $self->rotate(rad2deg($angle_z), Z, 'absolute'); - $self->rotate(rad2deg($angle_y), Y, 'absolute'); + $self->rotate(rad2deg($angle_y), Y, 'absolute') if $angle_y != 0; }; # callback to update object's geometry info while using gizmos -- cgit v1.2.3 From 86b67bbd4282016fbbbbc94306e37eada582daf1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 21 Aug 2018 15:40:11 +0200 Subject: Lay flat - rotation is now done in one go directly about the necessary axis --- lib/Slic3r/GUI/Plater.pm | 56 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 98f31fb8b..7000d16d7 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -140,10 +140,16 @@ sub new { }; # callback to react to gizmo rotate + # omitting last three parameters means rotation around Z + # otherwise they are the components of the rotation axis vector my $on_gizmo_rotate = sub { - my ($angle_z, $angle_y) = @_; - $self->rotate(rad2deg($angle_z), Z, 'absolute'); - $self->rotate(rad2deg($angle_y), Y, 'absolute') if $angle_y != 0; + my ($angle, $axis_x, $axis_y, $axis_z) = @_; + if (!defined $axis_x) { + $self->rotate(rad2deg($angle), Z, 'absolute'); + } + else { + $self->rotate(rad2deg($angle), undef, 'absolute', $axis_x, $axis_y, $axis_z) if $angle != 0; + } }; # callback to update object's geometry info while using gizmos @@ -1031,28 +1037,40 @@ sub _get_number_from_user { } sub rotate { - my ($self, $angle, $axis, $relative_key) = @_; + my ($self, $angle, $axis, $relative_key, $axis_x, $axis_y, $axis_z) = @_; $relative_key //= 'absolute'; # relative or absolute coordinates - $axis //= Z; # angle is in degrees - + $axis_x //= 0; + $axis_y //= 0; + $axis_z //= 0; my $relative = $relative_key eq 'relative'; - + my ($obj_idx, $object) = $self->selected_object; return if !defined $obj_idx; - + my $model_object = $self->{model}->objects->[$obj_idx]; my $model_instance = $model_object->instances->[0]; - + if (!defined $angle) { my $axis_name = $axis == X ? 'X' : $axis == Y ? 'Y' : 'Z'; my $default = $axis == Z ? rad2deg($model_instance->rotation) : 0; $angle = $self->_get_number_from_user(L("Enter the rotation angle:"), L("Rotate around ").$axis_name.(" axis"), L("Invalid rotation angle entered"), $default); return if $angle eq ''; } + + # Let's calculate vector of rotation axis (if we don't have it already) + # The minus is there so that the direction is the same as was established + if (defined $axis) { + if ($axis == X) { + $axis_x = -1; + } + if ($axis == Y) { + $axis_y = -1; + } + } $self->stop_background_process; - if ($axis == Z) { + if (defined $axis && $axis == Z) { my $new_angle = deg2rad($angle); foreach my $inst (@{ $model_object->instances }) { my $rotation = ($relative ? $inst->rotation : 0.) + $new_angle; @@ -1067,13 +1085,15 @@ sub rotate { } # $object->transform_thumbnail($self->{model}, $obj_idx); } else { - # rotation around X and Y needs to be performed on mesh - # so we first apply any Z rotation - if ($model_instance->rotation != 0) { - $model_object->rotate($model_instance->rotation, Z); - $_->set_rotation(0) for @{ $model_object->instances }; + if (defined $axis) { + # rotation around X and Y needs to be performed on mesh + # so we first apply any Z rotation + if ($model_instance->rotation != 0) { + $model_object->rotate($model_instance->rotation, Slic3r::Pointf3->new(0, 0, -1)); + $_->set_rotation(0) for @{ $model_object->instances }; + } } - $model_object->rotate(deg2rad($angle), $axis); + $model_object->rotate(deg2rad($angle), Slic3r::Pointf3->new($axis_x, $axis_y, $axis_z)); # # realign object to Z = 0 # $model_object->center_around_origin; @@ -1099,7 +1119,7 @@ sub mirror { # apply Z rotation before mirroring if ($model_instance->rotation != 0) { - $model_object->rotate($model_instance->rotation, Z); + $model_object->rotate($model_instance->rotation, Slic3r::Pointf3->new(0, 0, 1)); $_->set_rotation(0) for @{ $model_object->instances }; } @@ -1146,7 +1166,7 @@ sub changescale { # apply Z rotation before scaling if ($model_instance->rotation != 0) { - $model_object->rotate($model_instance->rotation, Z); + $model_object->rotate($model_instance->rotation, Slic3r::Pointf3->new(0, 0, 1)); $_->set_rotation(0) for @{ $model_object->instances }; } -- cgit v1.2.3 From 0b210426065f02b46be2d0a2c62ee25435b272f3 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 22 Aug 2018 14:02:32 +0200 Subject: Lay flat minor bugfix (ObjectCutDialog called a changed function using the old signature) --- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index 35aa28818..26a6fdec3 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -137,7 +137,7 @@ sub new { # Adjust position / orientation of the split object halves. if ($self->{new_model_objects}{lower}) { if ($self->{cut_options}{rotate_lower}) { - $self->{new_model_objects}{lower}->rotate(PI, X); + $self->{new_model_objects}{lower}->rotate(PI, Slic3r::Pointf3->new(1,0,0)); $self->{new_model_objects}{lower}->center_around_origin; # align to Z = 0 } } -- cgit v1.2.3 From a4176ef9338e7a1984fd983661351275c7ff19f1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 24 Aug 2018 16:52:06 +0200 Subject: Bugfix - dialog that changes number of copies deleted the object when cancelled --- lib/Slic3r/GUI/Plater.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index dbdf0be27..cae167f28 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -995,9 +995,10 @@ sub set_number_of_copies { my $model_object = $self->{model}->objects->[$obj_idx]; # prompt user - my $copies = Wx::GetNumberFromUser("", L("Enter the number of copies of the selected object:"), L("Copies"), $model_object->instances_count, 0, 1000, $self); + my $copies = -1; + $copies = Wx::GetNumberFromUser("", L("Enter the number of copies of the selected object:"), L("Copies"), $model_object->instances_count, 0, 1000, $self); my $diff = $copies - $model_object->instances_count; - if ($diff == 0) { + if ($diff == 0 || $copies == -1) { # no variation $self->resume_background_process; } elsif ($diff > 0) { -- cgit v1.2.3 From 8eb36b1bf91a22e94df18fec3ae462668dd076a4 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 27 Aug 2018 14:13:06 +0200 Subject: Fixed undefined axis in rotate method of plater.pm --- lib/Slic3r/GUI/Plater.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 4055b2b36..8e5882049 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -157,11 +157,6 @@ sub new { $self->rotate(rad2deg($angle), Z, 'absolute'); } else { - - print "angle: "; - print $angle; - print "\n"; - $self->rotate(rad2deg($angle), undef, 'absolute', $axis_x, $axis_y, $axis_z) if $angle != 0; } }; @@ -1187,7 +1182,10 @@ sub rotate { # $model_object->center_around_origin; # $self->reset_thumbnail($obj_idx); } - Slic3r::GUI::update_rotation_value(deg2rad($angle), $axis == X ? "x" : ($axis == Y ? "y" : "z")); + + if (defined $axis) { + Slic3r::GUI::update_rotation_value(deg2rad($angle), $axis == X ? "x" : ($axis == Y ? "y" : "z")); + } # update print and start background processing $self->{print}->add_model_object($model_object, $obj_idx); -- cgit v1.2.3