From 494efe65b2263bf64872a791816e3453c469d6b3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 29 Dec 2014 22:29:24 +0100 Subject: [PATCH] Bugfix: auto-center didn't update the PrintObject copies properly, causing misalignment. #2464 --- lib/Slic3r/GUI/Plater.pm | 44 +++++++++++++++----------------------- xs/src/libslic3r/Print.cpp | 10 +++++++++ xs/src/libslic3r/Print.hpp | 1 + xs/xsp/Print.xsp | 1 + 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 46aa55139..ca548e1aa 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -89,16 +89,7 @@ sub new { }; my $on_instance_moved = sub { my ($obj_idx, $instance_idx) = @_; - $self->update; - - $self->pause_background_process; - my $invalidated = $self->{print}->objects->[$obj_idx]->reload_model_instances(); - if ($invalidated) { - $self->schedule_background_process; - } else { - $self->resume_background_process; - } }; # Initialize 2D preview canvas @@ -564,7 +555,6 @@ sub remove { $self->select_object(undef); $self->update; - $self->schedule_background_process; } @@ -675,10 +665,10 @@ sub rotate { $model_object->update_bounding_box; # update print and start background processing $self->{print}->add_model_object($model_object, $obj_idx); - $self->schedule_background_process; $self->selection_changed; # refresh info (size etc.) $self->update; + $self->schedule_background_process; } sub flip { @@ -703,11 +693,10 @@ sub flip { # update print and start background processing $self->stop_background_process; $self->{print}->add_model_object($model_object, $obj_idx); - $self->schedule_background_process; $self->selection_changed; # refresh info (size etc.) $self->update; - $self->refresh_canvases; + $self->schedule_background_process; } sub changescale { @@ -758,11 +747,10 @@ sub changescale { # update print and start background processing $self->stop_background_process; $self->{print}->add_model_object($model_object, $obj_idx); - $self->schedule_background_process; $self->selection_changed(1); # refresh info (size, volume etc.) $self->update; - $self->refresh_canvases; + $self->schedule_background_process; } sub arrange { @@ -778,17 +766,6 @@ sub arrange { # when parts don't fit in print bed $self->update(1); - - my $invalidated = 0; - foreach my $object (@{$self->{print}->objects}) { - $invalidated = 1 if $object->reload_model_instances; - } - if ($invalidated) { - $self->schedule_background_process; - } else { - $self->resume_background_process; - } - $self->refresh_canvases; } sub split_object { @@ -1207,7 +1184,6 @@ sub on_thumbnail_made { my ($obj_idx) = @_; $self->{objects}[$obj_idx]->transform_thumbnail($self->{model}, $obj_idx); - $self->update; $self->refresh_canvases; } @@ -1220,9 +1196,23 @@ sub update { $self->{model}->center_instances_around_point($self->bed_centerf); } + $self->pause_background_process; + my $invalidated = $self->{print}->reload_model_instances(); + if ($invalidated) { + $self->schedule_background_process; + } else { + $self->resume_background_process; + } + $self->refresh_canvases; } +sub on_model_instances_changed { + my ($self) = @_; + + +} + sub on_extruders_change { my ($self, $num_extruders) = @_; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index b40430fec..b87d1c8cf 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -116,6 +116,16 @@ Print::reload_object(size_t idx) } } +bool +Print::reload_model_instances() +{ + bool invalidated = false; + FOREACH_OBJECT(this, object) { + if ((*object)->reload_model_instances()) invalidated = true; + } + return invalidated; +} + void Print::clear_regions() { diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 0e7334eaf..aa67e1c6d 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -174,6 +174,7 @@ class Print PrintObject* get_object(size_t idx); void delete_object(size_t idx); void reload_object(size_t idx); + bool reload_model_instances(); // methods for handling regions PrintRegion* get_region(size_t idx); diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index c3c9a97c5..fb0d17721 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -143,6 +143,7 @@ _constant() Ref get_object(int idx); void delete_object(int idx); void reload_object(int idx); + bool reload_model_instances(); size_t object_count() %code%{ RETVAL = THIS->objects.size(); %};