Further reduction of Perl Config.pm methods.

This commit is contained in:
bubnikv 2017-10-27 18:52:35 +02:00
parent 3bc79e80d5
commit 2455aee97c
28 changed files with 118 additions and 136 deletions

View File

@ -8,12 +8,6 @@ use utf8;
use List::Util qw(first max);
# cemetery of old config settings
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 print_center g0 vibration_limit gcode_arcs pressure_advance);
# C++ Slic3r::PrintConfigDef exported as a Perl hash of hashes.
# The C++ counterpart is a constant singleton.
our $Options = print_config_def();
@ -29,23 +23,6 @@ $Options->{threads}{readonly} = !$Slic3r::have_threads;
}
}
# Fill in the underlying C++ Slic3r::DynamicPrintConfig with the content of the defaults
# provided by the C++ class Slic3r::FullPrintConfig.
# Used by the UI.
sub new_from_defaults {
my ($class, @opt_keys) = @_;
my $self = $class->new;
# Instantiating the C++ class Slic3r::FullPrintConfig.
my $defaults = Slic3r::Config::Full->new;
if (@opt_keys) {
$self->set($_, $defaults->get($_))
for grep $defaults->has($_), @opt_keys;
} else {
$self->apply_static($defaults);
}
return $self;
}
# From command line parameters, used by slic3r.pl
sub new_from_cli {
my $class = shift;
@ -87,27 +64,6 @@ sub new_from_cli {
return $self;
}
sub merge {
my $class = shift;
my $config = $class->new;
$config->apply($_) for @_;
return $config;
}
sub clone {
my $self = shift;
my $new = (ref $self)->new;
$new->apply($self);
return $new;
}
sub get_value {
my ($self, $opt_key) = @_;
return $Options->{$opt_key}{ratio_over}
? $self->get_abs_value($opt_key)
: $self->get($opt_key);
}
# CLASS METHODS:
# Write a "Windows" style ini file with categories enclosed in squre brackets.

View File

@ -202,7 +202,7 @@ sub append_option {
# populate repository with the factory default
my ($opt_key, $opt_index) = split /#/, $full_key, 2;
$self->config->apply(Slic3r::Config->new_from_defaults($opt_key));
$self->config->apply(Slic3r::Config::new_from_defaults_keys($opt_key));
# draw the control
my $optgroup = Slic3r::GUI::ConfigOptionsGroup->new(
@ -300,7 +300,7 @@ sub new {
$self->append_text('Set the shape of your printer\'s bed, then click Next.');
$self->config->apply(Slic3r::Config->new_from_defaults('bed_shape'));
$self->config->apply(Slic3r::Config::new_from_defaults_keys('bed_shape'));
$self->{bed_shape_panel} = my $panel = Slic3r::GUI::BedShapePanel->new($self, $self->config->bed_shape);
$self->{bed_shape_panel}->on_change(sub {
$self->config->set('bed_shape', $self->{bed_shape_panel}->GetValue);

View File

@ -49,7 +49,7 @@ sub new {
my $class = shift;
my ($parent) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
$self->{config} = Slic3r::Config->new_from_defaults(qw(
$self->{config} = Slic3r::Config::new_from_defaults_keys(qw(
bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width variable_layer_height
serial_port serial_speed octoprint_host octoprint_apikey
nozzle_diameter single_extruder_multi_material

View File

@ -312,7 +312,7 @@ sub selection_changed {
$config = $self->{model_object}->config;
}
# get default values
my $default_config = Slic3r::Config->new_from_defaults(@opt_keys);
my $default_config = Slic3r::Config::new_from_defaults_keys(@opt_keys);
# append default extruder
push @opt_keys, 'extruder';
@ -490,12 +490,12 @@ sub CanClose {
# validate options before allowing user to dismiss the dialog
# the validate method only works on full configs so we have
# to merge our settings with the default ones
my $config = Slic3r::Config->merge($self->GetParent->GetParent->GetParent->GetParent->GetParent->config, $self->model_object->config);
my $config = $self->GetParent->GetParent->GetParent->GetParent->GetParent->config->clone;
eval {
$config->apply($self->model_object->config);
$config->validate;
};
return 0 if Slic3r::GUI::catch_error($self);
return 1;
return ! Slic3r::GUI::catch_error($self);
}
sub PartsChanged {

View File

@ -92,12 +92,12 @@ if ($opt{save}) {
if (@{$cli_config->get_keys} > 0) {
$cli_config->save($opt{save});
} else {
Slic3r::Config->new_from_defaults->save($opt{save});
Slic3r::Config::new_from_defaults->save($opt{save});
}
}
# apply command line config on top of default config
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->apply($cli_config);
# locate or create data directory
@ -242,7 +242,7 @@ if (@ARGV) { # slicing from command line
sub usage {
my ($exit_code) = @_;
my $config = Slic3r::Config->new_from_defaults->as_hash;
my $config = Slic3r::Config::new_from_defaults->as_hash;
my $j = '';
if ($Slic3r::have_threads) {

View File

@ -13,7 +13,7 @@ use Slic3r;
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('avoid_crossing_perimeters', 2);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2);
ok my $gcode = Slic3r::Test::gcode($print), "no crash with avoid_crossing_perimeters and multiple objects";

View File

@ -109,7 +109,7 @@ sub check_angle {
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('top_solid_layers', 0); # to prevent bridging on sparse infill
$config->set('bridge_speed', 99);

View File

@ -54,7 +54,7 @@ plan tests => 8;
'infill is only present in correct number of layers';
};
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('layer_height', 0.2);
$config->set('first_layer_height', 0.2);
$config->set('nozzle_diameter', [0.5]);
@ -73,7 +73,7 @@ plan tests => 8;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('layer_height', 0.2);
$config->set('first_layer_height', 0.2);
$config->set('nozzle_diameter', [0.5]);
@ -98,7 +98,7 @@ plan tests => 8;
# the following needs to be adapted to the new API
if (0) {
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('solid_layers', 0);
$config->set('bottom_solid_layers', 0);

View File

@ -12,7 +12,7 @@ use Slic3r;
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('perimeter_extrusion_width', '250%');
ok $config->validate, 'percent extrusion width is validated';
}

View File

@ -42,7 +42,7 @@ my $print_time1 = 100 / (3000 / 60); # 2 sec
my $gcode2 = $gcode1 . "G1 X0 E1 F3000\n";
my $print_time2 = 2 * $print_time1; # 4 sec
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
# Default cooling settings.
$config->set('bridge_fan_speed', [ 100 ]);
$config->set('cooling', [ 1 ]);
@ -138,7 +138,7 @@ $config->set('disable_fan_first_layers', [ 0 ]);
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('cooling', [ 1 ]);
$config->set('bridge_fan_speed', [ 100 ]);
$config->set('fan_below_layer_time', [ 0 ]);
@ -172,7 +172,7 @@ $config->set('disable_fan_first_layers', [ 0 ]);
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('cooling', [ 1 ]);
$config->set('fan_below_layer_time', [ 0 ]);
$config->set('slowdown_below_layer_time', [ 10 ]);

View File

@ -13,7 +13,7 @@ use Slic3r;
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
my $test = sub {
my ($conf) = @_;
@ -47,7 +47,7 @@ use Slic3r::Test;
{
my $parser = Slic3r::GCode::PlaceholderParser->new;
$parser->apply_config(my $config = Slic3r::Config->new_from_defaults);
$parser->apply_config(my $config = Slic3r::Config::new_from_defaults);
$parser->set('foo' => '0');
is $parser->process('[temperature_[foo]]'),
$config->temperature->[0],
@ -55,7 +55,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('output_filename_format', 'ts_[travel_speed]_lh_[layer_height].gcode');
$config->set('start_gcode', "TRAVEL:[travel_speed] HEIGHT:[layer_height]\n");
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
@ -108,7 +108,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('before_layer_gcode', ';BEFORE [layer_num]');
$config->set('layer_gcode', ';CHANGE [layer_num]');
$config->set('support_material', 1);

View File

@ -163,7 +163,7 @@ SKIP:
}
for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('fill_pattern', $pattern);
$config->set('external_fill_pattern', $pattern);
$config->set('perimeters', 1);
@ -194,7 +194,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('infill_only_where_needed', 1);
$config->set('bottom_solid_layers', 0);
$config->set('infill_extruder', 2);
@ -240,7 +240,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeters', 1);
$config->set('fill_density', 0);
@ -270,7 +270,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeters', 3);
$config->set('fill_density', 0);

View File

@ -14,7 +14,7 @@ use Slic3r::Geometry qw(scale PI);
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 1);
$config->set('brim_width', 2);
$config->set('perimeters', 3);
@ -41,7 +41,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('bridge_speed', 99);
$config->set('bridge_flow_ratio', 1);
$config->set('cooling', [ 0 ]); # to prevent speeds from being altered

View File

@ -16,7 +16,7 @@ use Slic3r::Surface ':types';
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeter_speed', 66);
$config->set('external_perimeter_speed', 66);

View File

@ -21,7 +21,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('wipe', [1]);
$config->set('retract_layer_change', [0]);
@ -52,7 +52,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('z_offset', 5);
$config->set('start_gcode', '');
@ -86,7 +86,7 @@ use Slic3r::Test;
# - Z moves are correctly generated for both objects
# - no travel moves go outside skirt
# - temperatures are set correctly
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('gcode_comments', 1);
$config->set('complete_objects', 1);
$config->set('extrusion_axis', 'A');
@ -130,7 +130,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('retract_length', [1000000]);
$config->set('use_relative_e_distances', 1);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
@ -162,7 +162,7 @@ use Slic3r::Test;
};
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('gcode_flavor', 'sailfish');
$config->set('raft_layers', 3);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
@ -170,21 +170,21 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('gcode_flavor', 'sailfish');
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2);
$test->($print, 'two copies of single object');
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('gcode_flavor', 'sailfish');
my $print = Slic3r::Test::init_print(['20mm_cube','20mm_cube'], config => $config);
$test->($print, 'two objects');
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('gcode_flavor', 'sailfish');
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, scale_xyz => [1,1, 1/(20/$config->layer_height) ]);
$test->($print, 'one layer object');
@ -192,7 +192,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('start_gcode', 'START:[input_filename]');
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
my $gcode = Slic3r::Test::gcode($print);
@ -200,7 +200,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('spiral_vase', 1);
my $print = Slic3r::Test::init_print('cube_with_hole', config => $config);
@ -220,7 +220,7 @@ use Slic3r::Test;
{
# Tests that the Repetier flavor produces M201 Xnnn Ynnn for resetting
# acceleration, also that M204 Snnn syntax is not generated.
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('gcode_flavor', 'repetier');
$config->set('default_acceleration', 1337);
my $print = Slic3r::Test::init_print('cube_with_hole', config => $config);

View File

@ -13,7 +13,7 @@ use Slic3r;
use Slic3r::Test qw(_eq);
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
my $test = sub {
my ($conf) = @_;

View File

@ -15,7 +15,7 @@ use Slic3r::Geometry::Clipper qw(offset);
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('raft_layers', 2);
$config->set('infill_extruder', 2);
$config->set('solid_infill_extruder', 3);
@ -88,7 +88,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('support_material_extruder', 3);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
@ -125,7 +125,7 @@ use Slic3r::Test;
$upper_config->set('extruder', 2);
$upper_config->set('bottom_solid_layers', 1);
$upper_config->set('top_solid_layers', 0);
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('fill_density', 0);
$config->set('solid_infill_speed', 99);
$config->set('top_solid_infill_speed', 99);
@ -171,7 +171,7 @@ use Slic3r::Test;
my $model = stacked_cubes();
my $object = $model->objects->[0];
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('layer_height', 0.4);
$config->set('first_layer_height', '100%');
$config->set('skirts', 0);

View File

@ -156,7 +156,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('fill_density', 0);
$config->set('perimeters', 3);
@ -284,7 +284,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeters', 3);
$config->set('layer_height', 0.4);
@ -314,7 +314,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('nozzle_diameter', [0.4]);
$config->set('perimeters', 2);
$config->set('perimeter_extrusion_width', 0.4);
@ -372,7 +372,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeters', 3);
$config->set('layer_height', 0.4);
@ -401,7 +401,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('seam_position', 'random');
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
ok Slic3r::Test::gcode($print), 'successful generation of G-code with seam_position = random';
@ -410,7 +410,7 @@ use Slic3r::Test;
{
my $test = sub {
my ($model_name) = @_;
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('seam_position', 'aligned');
$config->set('skirts', 0);
$config->set('perimeters', 1);

View File

@ -14,7 +14,7 @@ use Slic3r::Geometry qw(unscale X Y);
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
my $print_center = [100,100];
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, print_center => $print_center);
my @extrusion_points = ();
@ -33,7 +33,7 @@ use Slic3r::Test;
{
# this represents the aggregate config from presets
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
# user adds one object to the plater
my $print = Slic3r::Test::init_print(my $model = Slic3r::Test::model('20mm_cube'), config => $config);

View File

@ -13,7 +13,7 @@ use Slic3r;
use Slic3r::Test qw(_eq);
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
my $duplicate = 1;
my $test = sub {
@ -131,7 +131,7 @@ use Slic3r::Test qw(_eq);
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('start_gcode', ''); # prevent any default priming Z move from affecting our lift detection
$config->set('retract_length', [0]);
$config->set('retract_layer_change', [0]);
@ -165,7 +165,7 @@ use Slic3r::Test qw(_eq);
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('use_firmware_retraction', 1);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
@ -188,7 +188,7 @@ use Slic3r::Test qw(_eq);
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('use_firmware_retraction', 1);
$config->set('retract_length', [0]);
@ -206,7 +206,7 @@ use Slic3r::Test qw(_eq);
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('start_gcode', '');
$config->set('retract_lift', [3, 4]);

View File

@ -14,7 +14,7 @@ use Slic3r::Geometry qw(epsilon);
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeters', 0);
$config->set('solid_infill_speed', 99);
@ -82,7 +82,7 @@ use Slic3r::Test;
# issue #1161
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('layer_height', 0.3);
$config->set('first_layer_height', '100%');
$config->set('bottom_solid_layers', 0);
@ -106,7 +106,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
# we need to check against one perimeter because this test is calibrated
# (shape, extrusion_width) so that perimeters cover the bottom surfaces of
# their lower layer - the test checks that shells are not generated on the
@ -137,7 +137,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('perimeters', 3);
$config->set('cooling', [ 0 ]); # prevent speed alteration
$config->set('first_layer_speed', '100%'); # prevent speed alteration
@ -161,7 +161,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('perimeters', 1);
$config->set('fill_density', 0);
$config->set('top_solid_layers', 0);
@ -221,7 +221,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('spiral_vase', 1);
$config->set('perimeters', 1);
$config->set('fill_density', 0);
@ -292,7 +292,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('perimeters', 1);
$config->set('fill_density', 0);
$config->set('top_solid_layers', 0);

View File

@ -14,7 +14,7 @@ use Slic3r::Geometry qw(unscale convex_hull);
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 1);
$config->set('skirt_height', 2);
$config->set('perimeters', 0);
@ -46,7 +46,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('perimeters', 0);
$config->set('top_solid_layers', 0); # to prevent solid shells and their speeds
@ -72,7 +72,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 1);
$config->set('brim_width', 10);
@ -81,7 +81,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 1);
$config->set('skirt_height', 0);
@ -90,7 +90,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('layer_height', 0.4);
$config->set('first_layer_height', 0.4);
$config->set('skirts', 1);
@ -135,7 +135,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('min_skirt_length', 20);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
ok Slic3r::Test::gcode($print), 'no crash when using min_skirt_length';

View File

@ -19,7 +19,7 @@ use Slic3r::Geometry::Clipper qw(diff);
use Slic3r::Test;
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('support_material', 1);
my @contact_z = my @top_z = ();
@ -77,7 +77,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('raft_layers', 3);
$config->set('brim_width', 0);
$config->set('skirts', 0);
@ -108,7 +108,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('raft_layers', 3);
$config->set('support_material_pattern', 'honeycomb');
@ -153,7 +153,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('layer_height', 0.35);
$config->set('first_layer_height', 0.3);
@ -192,7 +192,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('brim_width', 0);
$config->set('skirts', 0);
$config->set('support_material', 1);
@ -232,7 +232,7 @@ use Slic3r::Test;
}
{
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('skirts', 0);
$config->set('start_gcode', '');
$config->set('raft_layers', 8);

View File

@ -16,7 +16,7 @@ use Slic3r::Test;
# Disable this until a more robust implementation is provided. It currently
# fails on Linux 32bit because some spurious extrudates are generated.
if (0) {
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
$config->set('layer_height', 0.2);
$config->set('first_layer_height', '100%');
$config->set('extrusion_width', 0.5);

View File

@ -33,7 +33,7 @@ my %opt = ();
my $model = Slic3r::Model->read_from_file($ARGV[0]);
# load config
my $config = Slic3r::Config->new_from_defaults;
my $config = Slic3r::Config::new_from_defaults;
if ($opt{load}) {
$config->apply(Slic3r::Config->load($opt{load}));
}

View File

@ -1,7 +1,10 @@
#include "PrintConfig.hpp"
#include <set>
#include <boost/algorithm/string/replace.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <float.h>
namespace Slic3r {
@ -1719,18 +1722,16 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
value = "60%";
}
// cemetery of old config settings
if (opt_key == "duplicate_x" || opt_key == "duplicate_y" || opt_key == "multiply_x"
|| opt_key == "multiply_y" || opt_key == "support_material_tool"
|| opt_key == "acceleration" || opt_key == "adjust_overhang_flow"
|| opt_key == "standby_temperature" || opt_key == "scale" || opt_key == "rotate"
|| opt_key == "duplicate" || opt_key == "duplicate_grid" || opt_key == "rotate"
|| opt_key == "scale" || opt_key == "duplicate_grid"
|| opt_key == "start_perimeters_at_concave_points"
|| opt_key == "start_perimeters_at_non_overhang" || opt_key == "randomize_start"
|| opt_key == "seal_position" || opt_key == "bed_size" || opt_key == "octoprint_host"
|| opt_key == "print_center" || opt_key == "g0" || opt_key == "threads")
{
// Ignore the following obsolete configuration keys:
static std::set<std::string> ignore = {
"duplicate_x", "duplicate_y", "gcode_arcs", "multiply_x", "multiply_y",
"support_material_tool", "acceleration", "adjust_overhang_flow",
"standby_temperature", "scale", "rotate", "duplicate", "duplicate_grid",
"start_perimeters_at_concave_points", "start_perimeters_at_non_overhang", "randomize_start",
"seal_position", "vibration_limit", "bed_size", "octoprint_host",
"print_center", "g0", "threads", "pressure_advance"
};
if (ignore.find(opt_key) != ignore.end()) {
opt_key = "";
return;
}
@ -1744,6 +1745,18 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
PrintConfigDef print_config_def;
DynamicPrintConfig* DynamicPrintConfig::new_from_defaults()
{
return new_from_defaults_keys(FullPrintConfig::defaults().keys());
}
DynamicPrintConfig* DynamicPrintConfig::new_from_defaults_keys(const std::vector<std::string> &keys)
{
auto *out = new DynamicPrintConfig();
out->apply_only(FullPrintConfig::defaults(), keys);
return out;
}
void DynamicPrintConfig::normalize()
{
if (this->has("extruder")) {

View File

@ -142,6 +142,9 @@ public:
DynamicPrintConfig() {}
DynamicPrintConfig(const DynamicPrintConfig &other) : DynamicConfig(other) {}
static DynamicPrintConfig* new_from_defaults();
static DynamicPrintConfig* new_from_defaults_keys(const std::vector<std::string> &keys);
// Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here.
const ConfigDef* def() const override { return &print_config_def; }

View File

@ -8,6 +8,9 @@
%name{Slic3r::Config} class DynamicPrintConfig {
DynamicPrintConfig();
~DynamicPrintConfig();
static DynamicPrintConfig* new_from_defaults();
static DynamicPrintConfig* new_from_defaults_keys(std::vector<std::string> keys);
DynamicPrintConfig* clone() %code{% RETVAL = new DynamicPrintConfig(*THIS); %};
bool has(t_config_option_key opt_key);
SV* as_hash()
%code{% RETVAL = ConfigBase__as_hash(THIS); %};
@ -15,6 +18,13 @@
%code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
SV* get_at(t_config_option_key opt_key, int i)
%code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
SV* get_value(t_config_option_key opt_key)
%code{%
const ConfigOptionDef *def = THIS->def()->get(opt_key);
RETVAL = (def != nullptr && ! def->ratio_over.empty()) ?
newSVnv(THIS->get_abs_value(opt_key)) :
ConfigBase__get(THIS, opt_key);
%};
bool set(t_config_option_key opt_key, SV* value)
%code{% RETVAL = ConfigBase__set(THIS, opt_key, value); %};
bool set_deserialize(t_config_option_key opt_key, SV* str)