From 266673213d7a8c33e6f1db5f717b4bb3cef459ed Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 18 Dec 2013 19:11:20 +0100 Subject: [PATCH] New option for turning autocentering off. #404 --- lib/Slic3r/Config.pm | 2 +- lib/Slic3r/GUI.pm | 2 ++ lib/Slic3r/GUI/Plater.pm | 26 ++++++++++++++++++++------ lib/Slic3r/GUI/Preferences.pm | 7 +++++++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index adf83bec2..332ad5314 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -62,7 +62,7 @@ our $Options = { # printer options 'print_center' => { label => 'Print center', - tooltip => 'Enter the G-code coordinates of the point you want to center your print around.', + tooltip => 'These G-code coordinates are used to center your plater viewport.', sidetext => 'mm', cli => 'print-center=s', type => 'point', diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 9388ff90e..9d66ea960 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -54,6 +54,7 @@ our $Settings = { _ => { mode => 'simple', version_check => 1, + autocenter => 1, }, }; @@ -88,6 +89,7 @@ sub OnInit { $Settings = $ini if $ini; $last_version = $Settings->{_}{version}; $Settings->{_}{mode} ||= 'expert'; + $Settings->{_}{autocenter} //= 1; } $Settings->{_}{version} = $Slic3r::VERSION; Slic3r::GUI->save_settings; diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 1a2d324ba..a566c36c2 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -409,11 +409,16 @@ sub load_model_object { # add a default instance and center object around origin $o->center_around_origin; - $o->add_instance(offset => [0,0]); + $o->add_instance(offset => [ @{$self->{config}->print_center} ]); } $self->{print}->add_model_object($o); + # if user turned autocentering off, automatic arranging would disappoint them + if (!$Slic3r::GUI::Settings->{_}{autocenter}) { + $need_arrange = 0; + } + $self->object_loaded($#{ $self->{objects} }, no_arrange => !$need_arrange); } @@ -484,7 +489,13 @@ sub increase { ); $self->{print}->objects->[$obj_idx]->add_copy(@{$i->offset}); $self->{list}->SetItem($obj_idx, 1, $model_object->instances_count); - $self->arrange; + + # only autoarrange if user has autocentering enabled + if ($Slic3r::GUI::Settings->{_}{autocenter}) { + $self->arrange; + } else { + $self->{canvas}->Refresh; + } } sub decrease { @@ -573,7 +584,8 @@ sub changescale { $object->transform_thumbnail($self->{model}, $obj_idx); } $self->selection_changed(1); # refresh info (size, volume etc.) - $self->arrange; + $self->update; + $self->{canvas}->Refresh; } sub arrange { @@ -584,7 +596,7 @@ sub arrange { }; # ignore arrange warnings on purpose - $self->update; + $self->update(1); $self->{canvas}->Refresh; } @@ -864,9 +876,11 @@ sub clean_instance_thumbnails { # this method gets called whenever print center is changed or the objects' bounding box changes # (i.e. when an object is added/removed/moved/rotated/scaled) sub update { - my $self = shift; + my ($self, $force_autocenter) = @_; - $self->{model}->center_instances_around_point($self->{config}->print_center); + if ($Slic3r::GUI::Settings->{_}{autocenter} || $force_autocenter) { + $self->{model}->center_instances_around_point($self->{config}->print_center); + } # sync model and print object instances for my $obj_idx (0..$#{$self->{objects}}) { diff --git a/lib/Slic3r/GUI/Preferences.pm b/lib/Slic3r/GUI/Preferences.pm index c004d8b01..4aec38bf4 100644 --- a/lib/Slic3r/GUI/Preferences.pm +++ b/lib/Slic3r/GUI/Preferences.pm @@ -37,6 +37,13 @@ sub new { tooltip => 'If this is enabled, Slic3r will prompt the last output directory instead of the one containing the input files.', default => $Slic3r::GUI::Settings->{_}{remember_output_path}, }, + { + opt_key => 'autocenter', + type => 'bool', + label => 'Auto-center parts', + tooltip => 'If this is enabled, Slic3r will auto-center objects around the configured print center.', + default => $Slic3r::GUI::Settings->{_}{autocenter}, + }, ], on_change => sub { $self->{values}{$_[0]} = $_[1] }, label_width => 100,