2014-05-14 22:42:30 +00:00
|
|
|
use Test::More tests => 6;
|
2013-06-15 10:10:57 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
2017-08-18 07:58:50 +00:00
|
|
|
use local::lib "$FindBin::Bin/../local-lib";
|
2013-06-15 10:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
use List::Util qw(first);
|
|
|
|
use Slic3r;
|
2017-07-19 08:45:39 +00:00
|
|
|
use Slic3r::Geometry qw(unscale X Y);
|
2013-06-15 10:10:57 +00:00
|
|
|
use Slic3r::Test;
|
|
|
|
|
|
|
|
{
|
2013-12-18 15:34:31 +00:00
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
2014-06-16 21:58:45 +00:00
|
|
|
my $print_center = [100,100];
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, print_center => $print_center);
|
2013-12-18 15:34:31 +00:00
|
|
|
my @extrusion_points = ();
|
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
|
|
|
if ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
|
|
|
|
push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
my $bb = Slic3r::Geometry::BoundingBox->new_from_points(\@extrusion_points);
|
2014-01-07 11:48:09 +00:00
|
|
|
my $center = $bb->center;
|
2017-03-23 12:21:44 +00:00
|
|
|
ok abs(unscale($center->[X]) - $print_center->[X]) < 0.005, 'print is centered around print_center (X)';
|
|
|
|
ok abs(unscale($center->[Y]) - $print_center->[Y]) < 0.005, 'print is centered around print_center (Y)';
|
2013-06-15 10:10:57 +00:00
|
|
|
}
|
|
|
|
|
2014-03-26 18:42:01 +00:00
|
|
|
{
|
|
|
|
# this represents the aggregate config from presets
|
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
|
|
|
|
|
|
|
# user adds one object to the plater
|
2014-03-26 23:01:33 +00:00
|
|
|
my $print = Slic3r::Test::init_print(my $model = Slic3r::Test::model('20mm_cube'), config => $config);
|
2014-03-26 18:42:01 +00:00
|
|
|
|
2014-03-26 23:01:33 +00:00
|
|
|
# user sets a per-region option
|
2014-05-09 12:24:35 +00:00
|
|
|
$print->print->objects->[0]->model_object->config->set('fill_density', 100);
|
|
|
|
$print->print->reload_object(0);
|
2014-05-14 22:42:30 +00:00
|
|
|
is $print->print->regions->[0]->config->fill_density, 100, 'region config inherits model object config';
|
2014-03-26 18:42:01 +00:00
|
|
|
|
|
|
|
# user exports G-code, thus the default config is reapplied
|
2014-05-09 12:24:35 +00:00
|
|
|
$print->print->apply_config($config);
|
2014-03-26 18:42:01 +00:00
|
|
|
|
2014-05-09 12:24:35 +00:00
|
|
|
is $print->print->regions->[0]->config->fill_density, 100, 'apply_config() does not override per-object settings';
|
2014-03-26 23:01:33 +00:00
|
|
|
|
|
|
|
# user assigns object extruders
|
2014-05-09 12:24:35 +00:00
|
|
|
$print->print->objects->[0]->model_object->config->set('extruder', 3);
|
|
|
|
$print->print->objects->[0]->model_object->config->set('perimeter_extruder', 2);
|
|
|
|
$print->print->reload_object(0);
|
2014-03-26 23:01:33 +00:00
|
|
|
|
2014-05-09 12:24:35 +00:00
|
|
|
is $print->print->regions->[0]->config->infill_extruder, 3, 'extruder setting is correctly expanded';
|
|
|
|
is $print->print->regions->[0]->config->perimeter_extruder, 2, 'extruder setting does not override explicitely specified extruders';
|
2014-03-26 18:42:01 +00:00
|
|
|
}
|
|
|
|
|
2013-06-15 10:10:57 +00:00
|
|
|
__END__
|