From 875035c09e33d2cb613cd91d040373cb98cbf214 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 13 Nov 2014 00:16:41 +0100 Subject: [PATCH] Minor improvement to plater: select/drag uppermost object when user clicks on overlapping objects --- lib/Slic3r/GUI/Plater/2D.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/2D.pm b/lib/Slic3r/GUI/Plater/2D.pm index 5f85aa746f..b3514c4914 100644 --- a/lib/Slic3r/GUI/Plater/2D.pm +++ b/lib/Slic3r/GUI/Plater/2D.pm @@ -183,9 +183,11 @@ sub mouse_event { my $point = $self->point_to_model_units([ $pos->x, $pos->y ]); #]] if ($event->ButtonDown) { $self->{on_select_object}->(undef); - OBJECTS: for my $obj_idx (0 .. $#{$self->{objects}}) { + # traverse objects and instances in reverse order, so that if they're overlapping + # we get the one that gets drawn last, thus on top (as user expects that to move) + OBJECTS: for my $obj_idx (reverse 0 .. $#{$self->{objects}}) { my $object = $self->{objects}->[$obj_idx]; - for my $instance_idx (0 .. $#{ $object->instance_thumbnails }) { + for my $instance_idx (reverse 0 .. $#{ $object->instance_thumbnails }) { my $thumbnail = $object->instance_thumbnails->[$instance_idx]; if (defined first { $_->contour->contains_point($point) } @$thumbnail) { $self->{on_select_object}->($obj_idx);