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);
|
||||
|
|
|
@ -43,6 +43,7 @@ my %cli_options = ();
|
|||
'rotate=i' => \$opt{rotate},
|
||||
'duplicate=i' => \$opt{duplicate},
|
||||
'duplicate-grid=s' => \$opt{duplicate_grid},
|
||||
'print-center=s' => \$opt{print_center},
|
||||
);
|
||||
foreach my $opt_key (keys %{$Slic3r::Config::Options}) {
|
||||
my $cli = $Slic3r::Config::Options->{$opt_key}->{cli} or next;
|
||||
|
@ -157,12 +158,16 @@ if (@ARGV) { # slicing from command line
|
|||
if (defined $opt{duplicate_grid}) {
|
||||
$opt{duplicate_grid} = [ split /[,x]/, $opt{duplicate_grid}, 2 ];
|
||||
}
|
||||
if (defined $opt{print_center}) {
|
||||
$opt{print_center} = [ split /[,x]/, $opt{print_center}, 2 ];
|
||||
}
|
||||
|
||||
my $sprint = Slic3r::Print::Simple->new(
|
||||
scale => $opt{scale} // 1,
|
||||
rotate => $opt{rotate} // 0,
|
||||
duplicate => $opt{duplicate} // 1,
|
||||
duplicate_grid => $opt{duplicate_grid} // [1,1],
|
||||
print_center => $opt{print_center} // [100,100],
|
||||
status_cb => sub {
|
||||
my ($percent, $message) = @_;
|
||||
printf "=> %s\n", $message;
|
||||
|
@ -248,8 +253,8 @@ $j
|
|||
|
||||
Printer options:
|
||||
--nozzle-diameter Diameter of nozzle in mm (default: $config->{nozzle_diameter}->[0])
|
||||
--print-center Coordinates in mm of the point to center the print around
|
||||
(default: $config->{print_center}->[0],$config->{print_center}->[1])
|
||||
--print-center Coordinates in mm of the point to center the print around
|
||||
(default: 100,100)
|
||||
--z-offset Additional height in mm to add to vertical coordinates
|
||||
(+/-, default: $config->{z_offset})
|
||||
--gcode-flavor The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/no-extrusion,
|
||||
|
|
|
@ -14,8 +14,8 @@ use Slic3r::Test;
|
|||
|
||||
{
|
||||
my $config = Slic3r::Config->new_from_defaults;
|
||||
$config->set('print_center', [100,100]);
|
||||
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||
my $print_center = [100,100];
|
||||
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, print_center => $print_center);
|
||||
my @extrusion_points = ();
|
||||
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
||||
my ($self, $cmd, $args, $info) = @_;
|
||||
|
@ -26,8 +26,8 @@ use Slic3r::Test;
|
|||
});
|
||||
my $bb = Slic3r::Geometry::BoundingBox->new_from_points(\@extrusion_points);
|
||||
my $center = $bb->center;
|
||||
ok abs(unscale($center->[X]) - $config->print_center->[X]) < epsilon, 'print is centered around print_center (X)';
|
||||
ok abs(unscale($center->[Y]) - $config->print_center->[Y]) < epsilon, 'print is centered around print_center (Y)';
|
||||
ok abs(unscale($center->[X]) - $print_center->[X]) < epsilon, 'print is centered around print_center (X)';
|
||||
ok abs(unscale($center->[Y]) - $print_center->[Y]) < epsilon, 'print is centered around print_center (Y)';
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -31,13 +31,14 @@ my %opt = ();
|
|||
# prepare config
|
||||
my $config = Slic3r::Config->new;
|
||||
$config->set('layer_height', $opt{layer_height}) if $opt{layer_height};
|
||||
$config->set('print_center', [0,0]);
|
||||
|
||||
# read model
|
||||
my $model = Slic3r::Model->read_from_file(my $input_file = $ARGV[0]);
|
||||
|
||||
# init print object
|
||||
my $sprint = Slic3r::Print::Simple->new;
|
||||
my $sprint = Slic3r::Print::Simple->new(
|
||||
print_center => [0,0],
|
||||
);
|
||||
$sprint->apply_config($config);
|
||||
$sprint->set_model($model);
|
||||
my $print = $sprint->_print;
|
||||
|
|
|
@ -464,7 +464,6 @@ Print::invalidate_state_by_config_options(const std::vector<t_config_option_key>
|
|||
|| *opt_key == "output_filename_format"
|
||||
|| *opt_key == "perimeter_acceleration"
|
||||
|| *opt_key == "post_process"
|
||||
|| *opt_key == "print_center"
|
||||
|| *opt_key == "retract_before_travel"
|
||||
|| *opt_key == "retract_layer_change"
|
||||
|| *opt_key == "retract_length"
|
||||
|
|
|
@ -546,12 +546,6 @@ PrintConfigDef::build_def() {
|
|||
Options["post_process"].full_width = true;
|
||||
Options["post_process"].height = 60;
|
||||
|
||||
Options["print_center"].type = coPoint;
|
||||
Options["print_center"].label = "Print center";
|
||||
Options["print_center"].tooltip = "These G-code coordinates are used to center your plater viewport.";
|
||||
Options["print_center"].sidetext = "mm";
|
||||
Options["print_center"].cli = "print-center=s";
|
||||
|
||||
Options["raft_layers"].type = coInt;
|
||||
Options["raft_layers"].label = "Raft layers";
|
||||
Options["raft_layers"].category = "Support material";
|
||||
|
|
|
@ -349,7 +349,6 @@ class PrintConfig : public virtual StaticPrintConfig
|
|||
ConfigOptionString output_filename_format;
|
||||
ConfigOptionFloat perimeter_acceleration;
|
||||
ConfigOptionStrings post_process;
|
||||
ConfigOptionPoint print_center;
|
||||
ConfigOptionFloat resolution;
|
||||
ConfigOptionFloats retract_before_travel;
|
||||
ConfigOptionBools retract_layer_change;
|
||||
|
@ -429,7 +428,6 @@ class PrintConfig : public virtual StaticPrintConfig
|
|||
this->ooze_prevention.value = false;
|
||||
this->output_filename_format.value = "[input_filename_base].gcode";
|
||||
this->perimeter_acceleration.value = 0;
|
||||
this->print_center.point = Pointf(100,100);
|
||||
this->resolution.value = 0;
|
||||
this->retract_before_travel.values.resize(1);
|
||||
this->retract_before_travel.values[0] = 2;
|
||||
|
@ -511,7 +509,6 @@ class PrintConfig : public virtual StaticPrintConfig
|
|||
if (opt_key == "output_filename_format") return &this->output_filename_format;
|
||||
if (opt_key == "perimeter_acceleration") return &this->perimeter_acceleration;
|
||||
if (opt_key == "post_process") return &this->post_process;
|
||||
if (opt_key == "print_center") return &this->print_center;
|
||||
if (opt_key == "resolution") return &this->resolution;
|
||||
if (opt_key == "retract_before_travel") return &this->retract_before_travel;
|
||||
if (opt_key == "retract_layer_change") return &this->retract_layer_change;
|
||||
|
|
|
@ -4,7 +4,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 115;
|
||||
use Test::More tests => 103;
|
||||
|
||||
foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
|
||||
$config->set('layer_height', 0.3);
|
||||
|
@ -33,13 +33,14 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
|
|||
ok abs($config->get_abs_value('first_layer_height') - 0.15) < 1e-4, 'set/get relative floatOrPercent';
|
||||
is $config->serialize('first_layer_height'), '50%', 'serialize relative floatOrPercent';
|
||||
|
||||
ok $config->set('print_center', [50,80]), 'valid point coordinates';
|
||||
is_deeply $config->get('print_center'), [50,80], 'set/get point';
|
||||
is $config->serialize('print_center'), '50,80', 'serialize point';
|
||||
$config->set_deserialize('print_center', '20,10');
|
||||
is_deeply $config->get('print_center'), [20,10], 'deserialize point';
|
||||
ok !$config->set('print_center', ['t',80]), 'invalid point X';
|
||||
ok !$config->set('print_center', [50,'t']), 'invalid point Y';
|
||||
# Uh-oh, we have no point option to test at the moment
|
||||
#ok $config->set('print_center', [50,80]), 'valid point coordinates';
|
||||
#is_deeply $config->get('print_center'), [50,80], 'set/get point';
|
||||
#is $config->serialize('print_center'), '50,80', 'serialize point';
|
||||
#$config->set_deserialize('print_center', '20,10');
|
||||
#is_deeply $config->get('print_center'), [20,10], 'deserialize point';
|
||||
#ok !$config->set('print_center', ['t',80]), 'invalid point X';
|
||||
#ok !$config->set('print_center', [50,'t']), 'invalid point Y';
|
||||
|
||||
$config->set('use_relative_e_distances', 1);
|
||||
is $config->get('use_relative_e_distances'), 1, 'set/get bool';
|
||||
|
|
Loading…
Reference in a new issue