Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2014-06-17 01:58:45 +0400
committerAlessandro Ranellucci <aar@cpan.org>2014-06-17 01:58:45 +0400
commit928335f18618095393eef5a0b5249b5af11375b7 (patch)
treef816bb5919d2514709bf6e00747b664f88fe4136
parent4d8ecccc5e538e535ea34d2d3959f17846a411e4 (diff)
Removed print_center option (but left --print-center from CLI)
-rw-r--r--lib/Slic3r/Config.pm9
-rw-r--r--lib/Slic3r/GUI/ConfigWizard.pm8
-rw-r--r--lib/Slic3r/GUI/Plater.pm17
-rw-r--r--lib/Slic3r/GUI/Plater/2D.pm10
-rw-r--r--lib/Slic3r/GUI/SimpleTab.pm2
-rw-r--r--lib/Slic3r/GUI/Tab.pm3
-rw-r--r--lib/Slic3r/Print/Simple.pm7
-rw-r--r--lib/Slic3r/Test.pm2
-rwxr-xr-xslic3r.pl9
-rw-r--r--t/print.t8
-rwxr-xr-xutils/pdf-slices.pl5
-rw-r--r--xs/src/Print.cpp1
-rw-r--r--xs/src/PrintConfig.cpp6
-rw-r--r--xs/src/PrintConfig.hpp3
-rw-r--r--xs/t/15_config.t17
15 files changed, 54 insertions, 53 deletions
diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm
index 2f37b9f67..62b6caf88 100644
--- a/lib/Slic3r/Config.pm
+++ b/lib/Slic3r/Config.pm
@@ -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}};
diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm
index a5fa9c1cc..f0f309800 100644
--- a/lib/Slic3r/GUI/ConfigWizard.pm
+++ b/lib/Slic3r/GUI/ConfigWizard.pm
@@ -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]);
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index 1007c33fa..d687e68a0 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -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;
diff --git a/lib/Slic3r/GUI/Plater/2D.pm b/lib/Slic3r/GUI/Plater/2D.pm
index 43c5ef976..0508b6d33 100644
--- a/lib/Slic3r/GUI/Plater/2D.pm
+++ b/lib/Slic3r/GUI/Plater/2D.pm
@@ -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
diff --git a/lib/Slic3r/GUI/SimpleTab.pm b/lib/Slic3r/GUI/SimpleTab.pm
index 064b3495e..42599f8ac 100644
--- a/lib/Slic3r/GUI/SimpleTab.pm
+++ b/lib/Slic3r/GUI/SimpleTab.pm
@@ -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(
diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm
index 56e052ff7..4b2d91bb0 100644
--- a/lib/Slic3r/GUI/Tab.pm
+++ b/lib/Slic3r/GUI/Tab.pm
@@ -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'),
],
},
diff --git a/lib/Slic3r/Print/Simple.pm b/lib/Slic3r/Print/Simple.pm
index 27ca4126d..bdb89e79e 100644
--- a/lib/Slic3r/Print/Simple.pm
+++ b/lib/Slic3r/Print/Simple.pm
@@ -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);
diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm
index 403ca4947..46cc7fd98 100644
--- a/lib/Slic3r/Test.pm
+++ b/lib/Slic3r/Test.pm
@@ -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);
diff --git a/slic3r.pl b/slic3r.pl
index 471e546d4..f1a2fc1af 100755
--- a/slic3r.pl
+++ b/slic3r.pl
@@ -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,
diff --git a/t/print.t b/t/print.t
index d6256c83b..28cf1ee42 100644
--- a/t/print.t
+++ b/t/print.t
@@ -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)';
}
{
diff --git a/utils/pdf-slices.pl b/utils/pdf-slices.pl
index 3931dceac..fa7612bb1 100755
--- a/utils/pdf-slices.pl
+++ b/utils/pdf-slices.pl
@@ -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;
diff --git a/xs/src/Print.cpp b/xs/src/Print.cpp
index 67efad678..43b168fa1 100644
--- a/xs/src/Print.cpp
+++ b/xs/src/Print.cpp
@@ -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"
diff --git a/xs/src/PrintConfig.cpp b/xs/src/PrintConfig.cpp
index cbee8d475..95e66c609 100644
--- a/xs/src/PrintConfig.cpp
+++ b/xs/src/PrintConfig.cpp
@@ -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";
diff --git a/xs/src/PrintConfig.hpp b/xs/src/PrintConfig.hpp
index 470cdd385..5bcc3a32d 100644
--- a/xs/src/PrintConfig.hpp
+++ b/xs/src/PrintConfig.hpp
@@ -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;
diff --git a/xs/t/15_config.t b/xs/t/15_config.t
index 9541f4310..2627c895d 100644
--- a/xs/t/15_config.t
+++ b/xs/t/15_config.t
@@ -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';