Removed print_center option (but left --print-center from CLI)
This commit is contained in:
parent
4d8ecccc5e
commit
928335f186
15 changed files with 54 additions and 53 deletions
|
@ -9,7 +9,7 @@ use List::Util qw(first max);
|
|||
our @Ignore = qw(duplicate_x duplicate_y multiply_x multiply_y support_material_tool acceleration
|
||||
adjust_overhang_flow standby_temperature scale rotate duplicate duplicate_grid
|
||||
rotate scale duplicate_grid start_perimeters_at_concave_points start_perimeters_at_non_overhang
|
||||
randomize_start seal_position bed_size);
|
||||
randomize_start seal_position bed_size print_center);
|
||||
|
||||
our $Options = print_config_def();
|
||||
|
||||
|
@ -63,7 +63,7 @@ sub new_from_cli {
|
|||
|
||||
# we use set_deserialize() for bool options since GetOpt::Long doesn't handle
|
||||
# arrays of boolean values
|
||||
if ($opt_key =~ /^(?:print_center|bed_size|duplicate_grid|extruder_offset)$/ || $opt_def->{type} eq 'bool') {
|
||||
if ($opt_key =~ /^(?:bed_shape|duplicate_grid|extruder_offset)$/ || $opt_def->{type} eq 'bool') {
|
||||
$self->set_deserialize($opt_key, $args{$opt_key});
|
||||
} elsif (my $shortcut = $opt_def->{shortcut}) {
|
||||
$self->set($_, $args{$opt_key}) for @$shortcut;
|
||||
|
@ -280,11 +280,6 @@ sub validate {
|
|||
die "--use-firmware-retraction is not compatible with --wipe\n"
|
||||
if $self->use_firmware_retraction && first {$_} @{$self->wipe};
|
||||
|
||||
# --print-center
|
||||
die "Invalid value for --print-center\n"
|
||||
if !ref $self->print_center
|
||||
&& (!$self->print_center || $self->print_center !~ /^\d+,\d+$/);
|
||||
|
||||
# --fill-pattern
|
||||
die "Invalid value for --fill-pattern\n"
|
||||
if !first { $_ eq $self->fill_pattern } @{$Options->{fill_pattern}{values}};
|
||||
|
|
|
@ -53,14 +53,6 @@ sub run {
|
|||
# it would be cleaner to have these defined inside each page class,
|
||||
# in some event getting called before leaving the page
|
||||
{
|
||||
# set print_center to center of bed_shape
|
||||
{
|
||||
my $bed_shape = $self->{config}->bed_shape;
|
||||
my $polygon = Slic3r::Polygon->new_scale(@$bed_shape);
|
||||
my $center = $polygon->centroid;
|
||||
$self->{config}->set('print_center', [ map unscale($_), @$center ]);
|
||||
}
|
||||
|
||||
# set first_layer_height + layer_height based on nozzle_diameter
|
||||
my $nozzle = $self->{config}->nozzle_diameter;
|
||||
$self->{config}->set('first_layer_height', $nozzle->[0]);
|
||||
|
|
|
@ -50,7 +50,7 @@ sub new {
|
|||
my ($parent) = @_;
|
||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
$self->{config} = Slic3r::Config->new_from_defaults(qw(
|
||||
bed_shape print_center complete_objects extruder_clearance_radius skirts skirt_distance
|
||||
bed_shape complete_objects extruder_clearance_radius skirts skirt_distance
|
||||
));
|
||||
$self->{model} = Slic3r::Model->new;
|
||||
$self->{print} = Slic3r::Print->new;
|
||||
|
@ -420,6 +420,8 @@ sub load_file {
|
|||
sub load_model_objects {
|
||||
my ($self, @model_objects) = @_;
|
||||
|
||||
my $bed_centerf = $self->bed_centerf;
|
||||
|
||||
my $need_arrange = 0;
|
||||
my @obj_idx = ();
|
||||
foreach my $model_object (@model_objects) {
|
||||
|
@ -436,7 +438,7 @@ sub load_model_objects {
|
|||
|
||||
# add a default instance and center object around origin
|
||||
$o->center_around_origin;
|
||||
$o->add_instance(offset => Slic3r::Pointf->new(@{$self->{config}->print_center}));
|
||||
$o->add_instance(offset => $bed_centerf);
|
||||
}
|
||||
|
||||
$self->{print}->auto_assign_extruders($o);
|
||||
|
@ -476,6 +478,14 @@ sub objects_loaded {
|
|||
$self->schedule_background_process;
|
||||
}
|
||||
|
||||
sub bed_centerf {
|
||||
my ($self) = @_;
|
||||
|
||||
my $bed_shape = Slic3r::Polygon->new_scale(@{$self->{config}->bed_shape});
|
||||
my $bed_center = $bed_shape->bounding_box->center;
|
||||
return Slic3r::Pointf->new(unscale($bed_center->x), unscale($bed_center->y)); #)
|
||||
}
|
||||
|
||||
sub remove {
|
||||
my $self = shift;
|
||||
my ($obj_idx) = @_;
|
||||
|
@ -1105,7 +1115,7 @@ sub update {
|
|||
my ($self, $force_autocenter) = @_;
|
||||
|
||||
if ($Slic3r::GUI::Settings->{_}{autocenter} || $force_autocenter) {
|
||||
$self->{model}->center_instances_around_point($self->{config}->print_center);
|
||||
$self->{model}->center_instances_around_point($self->bed_centerf);
|
||||
}
|
||||
|
||||
# sync model and print object instances
|
||||
|
@ -1147,7 +1157,6 @@ sub on_config_change {
|
|||
$self->{canvas}->update_bed_size;
|
||||
$self->update;
|
||||
}
|
||||
$self->update if $opt_key eq 'print_center';
|
||||
}
|
||||
|
||||
return if !$self->GetFrame->is_loaded;
|
||||
|
|
|
@ -87,14 +87,14 @@ sub repaint {
|
|||
|
||||
# draw print center
|
||||
if (@{$self->{objects}} && $Slic3r::GUI::Settings->{_}{autocenter}) {
|
||||
my $center = $self->unscaled_point_to_pixel($self->{config}->print_center);
|
||||
my $center = $self->unscaled_point_to_pixel($self->{print_center});
|
||||
$dc->SetPen($self->{print_center_pen});
|
||||
$dc->DrawLine($center->[X], 0, $center->[X], $size[Y]);
|
||||
$dc->DrawLine(0, $center->[Y], $size[X], $center->[Y]);
|
||||
$dc->SetTextForeground(Wx::Colour->new(0,0,0));
|
||||
$dc->SetFont(Wx::Font->new(10, wxDEFAULT, wxNORMAL, wxNORMAL));
|
||||
$dc->DrawLabel("X = " . $self->{config}->print_center->[X], Wx::Rect->new(0, 0, $center->[X]*2, $self->GetSize->GetHeight), wxALIGN_CENTER_HORIZONTAL | wxALIGN_BOTTOM);
|
||||
$dc->DrawRotatedText("Y = " . $self->{config}->print_center->[Y], 0, $center->[Y]+15, 90);
|
||||
$dc->DrawLabel("X = " . $self->{print_center}->[X], Wx::Rect->new(0, 0, $center->[X]*2, $self->GetSize->GetHeight), wxALIGN_CENTER_HORIZONTAL | wxALIGN_BOTTOM);
|
||||
$dc->DrawRotatedText("Y = " . $self->{print_center}->[Y], 0, $center->[Y]+15, 90);
|
||||
}
|
||||
|
||||
# draw frame
|
||||
|
@ -258,6 +258,10 @@ sub update_bed_size {
|
|||
$canvas_h - ($self->GetSize->GetHeight/2 - (unscale($bb->y_max + $bb->y_min)/2 * $self->{scaling_factor})),
|
||||
];
|
||||
|
||||
# calculate print center
|
||||
my $center = $bb->center;
|
||||
$self->{print_center} = [ unscale($center->x), unscale($center->y) ]; #))
|
||||
|
||||
# cache bed contours and grid
|
||||
{
|
||||
my $step = scale 10; # 1cm grid
|
||||
|
|
|
@ -196,7 +196,7 @@ sub build {
|
|||
|
||||
$self->append_optgroup(
|
||||
title => 'Size and coordinates',
|
||||
options => [qw(bed_size print_center z_offset)],
|
||||
options => [qw(bed_size z_offset)],
|
||||
);
|
||||
|
||||
$self->append_optgroup(
|
||||
|
|
|
@ -704,14 +704,13 @@ sub build {
|
|||
$self->add_options_page('General', 'printer_empty.png', optgroups => [
|
||||
{
|
||||
title => 'Size and coordinates',
|
||||
options => [qw(bed_shape print_center z_offset)],
|
||||
options => [qw(bed_shape z_offset)],
|
||||
lines => [
|
||||
{
|
||||
label => 'Bed shape',
|
||||
widget => $bed_shape_widget,
|
||||
options => ['bed_shape'],
|
||||
},
|
||||
Slic3r::GUI::OptionsGroup->single_option_line('print_center'),
|
||||
Slic3r::GUI::OptionsGroup->single_option_line('z_offset'),
|
||||
],
|
||||
},
|
||||
|
|
|
@ -36,6 +36,11 @@ has 'status_cb' => (
|
|||
default => sub { sub {} },
|
||||
);
|
||||
|
||||
has 'print_center' => (
|
||||
is => 'rw',
|
||||
default => sub { [100,100] },
|
||||
);
|
||||
|
||||
has 'output_file' => (
|
||||
is => 'rw',
|
||||
);
|
||||
|
@ -63,7 +68,7 @@ sub set_model {
|
|||
# if all input objects have defined position(s) apply duplication to the whole model
|
||||
$model->duplicate($self->duplicate, $self->_print->config->min_object_distance);
|
||||
}
|
||||
$model->center_instances_around_point($self->_print->config->print_center);
|
||||
$model->center_instances_around_point($self->print_center);
|
||||
|
||||
foreach my $model_object (@{$model->objects}) {
|
||||
$self->_print->auto_assign_extruders($model_object);
|
||||
|
|
|
@ -156,7 +156,7 @@ sub init_print {
|
|||
$model->duplicate($params{duplicate} // 1, $print->config->min_object_distance);
|
||||
}
|
||||
$model->arrange_objects($print->config->min_object_distance);
|
||||
$model->center_instances_around_point($print->config->print_center);
|
||||
$model->center_instances_around_point($params{print_center} // [100,100]);
|
||||
foreach my $model_object (@{$model->objects}) {
|
||||
$print->auto_assign_extruders($model_object);
|
||||
$print->add_model_object($model_object);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue