New option for turning autocentering off. #404

This commit is contained in:
Alessandro Ranellucci 2013-12-18 19:11:20 +01:00
parent 15235699e4
commit 266673213d
4 changed files with 30 additions and 7 deletions

View File

@ -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',

View File

@ -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;

View File

@ -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}}) {

View File

@ -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,