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:
-rw-r--r--lib/Slic3r/Config.pm44
-rw-r--r--lib/Slic3r/GUI/ConfigWizard.pm4
-rw-r--r--lib/Slic3r/GUI/Plater.pm2
-rw-r--r--lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm8
-rwxr-xr-xslic3r.pl6
-rw-r--r--t/avoid_crossing_perimeters.t2
-rw-r--r--t/bridges.t2
-rw-r--r--t/combineinfill.t6
-rw-r--r--t/config.t2
-rw-r--r--t/cooling.t6
-rw-r--r--t/custom_gcode.t8
-rw-r--r--t/fill.t8
-rw-r--r--t/flow.t4
-rw-r--r--t/gaps.t2
-rw-r--r--t/gcode.t22
-rw-r--r--t/layers.t2
-rw-r--r--t/multi.t8
-rw-r--r--t/perimeters.t12
-rw-r--r--t/print.t4
-rw-r--r--t/retraction.t10
-rw-r--r--t/shells.t14
-rw-r--r--t/skirt_brim.t12
-rw-r--r--t/support.t12
-rw-r--r--t/thin.t2
-rwxr-xr-xutils/view-toolpaths.pl2
-rw-r--r--xs/src/libslic3r/PrintConfig.cpp37
-rw-r--r--xs/src/libslic3r/PrintConfig.hpp3
-rw-r--r--xs/xsp/Config.xsp10
28 files changed, 118 insertions, 136 deletions
diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm
index 4b6e5d453..c5e49df6b 100644
--- a/lib/Slic3r/Config.pm
+++ b/lib/Slic3r/Config.pm
@@ -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.
diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm
index 19310b3c1..8cdcac052 100644
--- a/lib/Slic3r/GUI/ConfigWizard.pm
+++ b/lib/Slic3r/GUI/ConfigWizard.pm
@@ -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);
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index 827170a8b..c4b401cce 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -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
diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
index 469794766..039c642c7 100644
--- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
+++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
@@ -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 {
diff --git a/slic3r.pl b/slic3r.pl
index 76def3d28..9864c0714 100755
--- a/slic3r.pl
+++ b/slic3r.pl
@@ -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) {
diff --git a/t/avoid_crossing_perimeters.t b/t/avoid_crossing_perimeters.t
index 60442f47f..86c3e91cb 100644
--- a/t/avoid_crossing_perimeters.t
+++ b/t/avoid_crossing_perimeters.t
@@ -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";
diff --git a/t/bridges.t b/t/bridges.t
index e3c89faa7..ca55862b6 100644
--- a/t/bridges.t
+++ b/t/bridges.t
@@ -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);
diff --git a/t/combineinfill.t b/t/combineinfill.t
index 66e461d45..e94cf9eb5 100644
--- a/t/combineinfill.t
+++ b/t/combineinfill.t
@@ -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);
diff --git a/t/config.t b/t/config.t
index 829ef5f39..f4a1867de 100644
--- a/t/config.t
+++ b/t/config.t
@@ -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';
}
diff --git a/t/cooling.t b/t/cooling.t
index 87a557a04..ee4f6abea 100644
--- a/t/cooling.t
+++ b/t/cooling.t
@@ -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 ]);
diff --git a/t/custom_gcode.t b/t/custom_gcode.t
index 653bb26ae..ed74e750c 100644
--- a/t/custom_gcode.t
+++ b/t/custom_gcode.t
@@ -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);
diff --git a/t/fill.t b/t/fill.t
index 15b1a2e04..a6fe8619c 100644
--- a/t/fill.t
+++ b/t/fill.t
@@ -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);
diff --git a/t/flow.t b/t/flow.t
index a0d445ce5..2fa0d8f10 100644
--- a/t/flow.t
+++ b/t/flow.t
@@ -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
diff --git a/t/gaps.t b/t/gaps.t
index 70e605a4b..f0c75c353 100644
--- a/t/gaps.t
+++ b/t/gaps.t
@@ -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);
diff --git a/t/gcode.t b/t/gcode.t
index 956c579d4..126c621b7 100644
--- a/t/gcode.t
+++ b/t/gcode.t
@@ -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);
diff --git a/t/layers.t b/t/layers.t
index a85998077..a9f7dfe39 100644
--- a/t/layers.t
+++ b/t/layers.t
@@ -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) = @_;
diff --git a/t/multi.t b/t/multi.t
index caedb982e..49d35d907 100644
--- a/t/multi.t
+++ b/t/multi.t
@@ -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);
diff --git a/t/perimeters.t b/t/perimeters.t
index 2c190fd69..ee332616d 100644
--- a/t/perimeters.t
+++ b/t/perimeters.t
@@ -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);
diff --git a/t/print.t b/t/print.t
index 29ad7cbaa..6939d5f15 100644
--- a/t/print.t
+++ b/t/print.t
@@ -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);
diff --git a/t/retraction.t b/t/retraction.t
index a0631f31a..d7f1ea145 100644
--- a/t/retraction.t
+++ b/t/retraction.t
@@ -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]);
diff --git a/t/shells.t b/t/shells.t
index 03bc5665c..eac95aa32 100644
--- a/t/shells.t
+++ b/t/shells.t
@@ -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);
diff --git a/t/skirt_brim.t b/t/skirt_brim.t
index 4d0155eba..225b0a92f 100644
--- a/t/skirt_brim.t
+++ b/t/skirt_brim.t
@@ -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';
diff --git a/t/support.t b/t/support.t
index ed68c276e..a0cac1470 100644
--- a/t/support.t
+++ b/t/support.t
@@ -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);
diff --git a/t/thin.t b/t/thin.t
index 2d256d286..9147236ee 100644
--- a/t/thin.t
+++ b/t/thin.t
@@ -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);
diff --git a/utils/view-toolpaths.pl b/utils/view-toolpaths.pl
index d4c47f072..234a8123d 100755
--- a/utils/view-toolpaths.pl
+++ b/utils/view-toolpaths.pl
@@ -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}));
}
diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp
index 420bd4490..8986bb59d 100644
--- a/xs/src/libslic3r/PrintConfig.cpp
+++ b/xs/src/libslic3r/PrintConfig.cpp
@@ -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")) {
diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp
index 18beeff6f..20f787b1e 100644
--- a/xs/src/libslic3r/PrintConfig.hpp
+++ b/xs/src/libslic3r/PrintConfig.hpp
@@ -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; }
diff --git a/xs/xsp/Config.xsp b/xs/xsp/Config.xsp
index 2f8946e8b..f78b3bf60 100644
--- a/xs/xsp/Config.xsp
+++ b/xs/xsp/Config.xsp
@@ -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)