From f0325575c212236b2447ab3241873716acbf97c4 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 21 Jun 2017 16:15:39 +0200 Subject: [PATCH] Slic3r has been modified to propagate the following filament specific values to GCode generator, one per active extruder: bed_temperature bridge_fan_speed cooling disable_fan_first_layers fan_always_on fan_below_layer_time first_layer_bed_temperature max_fan_speed min_fan_speed min_print_speed slowdown_below_layer_time Now it remains to extend Slic3r to correctly apply these values. --- lib/Slic3r/GUI/ConfigWizard.pm | 4 +- lib/Slic3r/GUI/Tab.pm | 47 +++++----- slic3r.pl | 16 ++-- t/cooling.t | 32 +++---- t/fill.t | 4 +- t/flow.t | 2 +- t/gaps.t | 2 +- t/multi.t | 2 +- t/perimeters.t | 14 +-- t/shells.t | 8 +- t/skirt_brim.t | 6 +- t/support.t | 4 +- xs/src/libslic3r/GCode.cpp | 18 ++-- xs/src/libslic3r/GCode/CoolingBuffer.cpp | 28 +++--- xs/src/libslic3r/PrintConfig.cpp | 106 ++++++++++++++++------- xs/src/libslic3r/PrintConfig.hpp | 22 ++--- 16 files changed, 180 insertions(+), 135 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index b90837937..eeecdd224 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -66,7 +66,7 @@ sub run { # set first_layer_bed_temperature to temperature + 5 $self->{config}->set('first_layer_bed_temperature', - ($self->{config}->bed_temperature > 0) ? ($self->{config}->bed_temperature + 5) : 0); + [ ($self->{config}->bed_temperature->[0] > 0) ? ($self->{config}->bed_temperature->[0] + 5) : 0 ]); } $self->Destroy; @@ -364,7 +364,7 @@ sub new { $self->append_text('Enter the bed temperature needed for getting your filament to stick to your heated bed, then click Next.'); $self->append_text('A rule of thumb is 60 °C for PLA and 110 °C for ABS. Leave zero if you have no heated bed.'); - $self->append_option('bed_temperature'); + $self->append_option('bed_temperature#0'); return $self; } diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index aee0c9c57..2c3de27d9 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -1078,8 +1078,8 @@ sub build { my $line = Slic3r::GUI::OptionsGroup::Line->new( label => 'Bed', ); - $line->append_option($optgroup->get_option('first_layer_bed_temperature')); - $line->append_option($optgroup->get_option('bed_temperature')); + $line->append_option($optgroup->get_option('first_layer_bed_temperature', 0)); + $line->append_option($optgroup->get_option('bed_temperature', 0)); $optgroup->append_line($line); } } @@ -1089,8 +1089,8 @@ sub build { my $page = $self->add_options_page('Cooling', 'hourglass.png'); { my $optgroup = $page->new_optgroup('Enable'); - $optgroup->append_single_option_line('fan_always_on'); - $optgroup->append_single_option_line('cooling'); + $optgroup->append_single_option_line('fan_always_on', 0); + $optgroup->append_single_option_line('cooling', 0); my $line = Slic3r::GUI::OptionsGroup::Line->new( label => '', @@ -1109,21 +1109,21 @@ sub build { my $line = Slic3r::GUI::OptionsGroup::Line->new( label => 'Fan speed', ); - $line->append_option($optgroup->get_option('min_fan_speed')); - $line->append_option($optgroup->get_option('max_fan_speed')); + $line->append_option($optgroup->get_option('min_fan_speed', 0)); + $line->append_option($optgroup->get_option('max_fan_speed', 0)); $optgroup->append_line($line); } - $optgroup->append_single_option_line('bridge_fan_speed'); - $optgroup->append_single_option_line('disable_fan_first_layers'); + $optgroup->append_single_option_line('bridge_fan_speed', 0); + $optgroup->append_single_option_line('disable_fan_first_layers', 0); } { my $optgroup = $page->new_optgroup('Cooling thresholds', label_width => 250, ); - $optgroup->append_single_option_line('fan_below_layer_time'); - $optgroup->append_single_option_line('slowdown_below_layer_time'); - $optgroup->append_single_option_line('min_print_speed'); + $optgroup->append_single_option_line('fan_below_layer_time', 0); + $optgroup->append_single_option_line('slowdown_below_layer_time', 0); + $optgroup->append_single_option_line('min_print_speed', 0); } } @@ -1182,10 +1182,11 @@ sub _update { $self->_update_description; - my $cooling = $self->{config}->cooling; - $self->get_field($_)->toggle($cooling) + my $cooling = $self->{config}->cooling->[0]; + my $fan_always_on = $cooling || $self->{config}->fan_always_on->[0]; + $self->get_field($_, 0)->toggle($cooling) for qw(max_fan_speed fan_below_layer_time slowdown_below_layer_time min_print_speed); - $self->get_field($_)->toggle($cooling || $self->{config}->fan_always_on) + $self->get_field($_, 0)->toggle($fan_always_on) for qw(min_fan_speed disable_fan_first_layers); } @@ -1195,21 +1196,21 @@ sub _update_description { my $config = $self->config; my $msg = ""; - my $fan_other_layers = $config->fan_always_on - ? sprintf "will always run at %d%%%s.", $config->min_fan_speed, - ($config->disable_fan_first_layers > 1 - ? " except for the first " . $config->disable_fan_first_layers . " layers" - : $config->disable_fan_first_layers == 1 + my $fan_other_layers = $config->fan_always_on->[0] + ? sprintf "will always run at %d%%%s.", $config->min_fan_speed->[0], + ($config->disable_fan_first_layers->[0] > 1 + ? " except for the first " . $config->disable_fan_first_layers->[0] . " layers" + : $config->disable_fan_first_layers->[0] == 1 ? " except for the first layer" : "") : "will be turned off."; - if ($config->cooling) { + if ($config->cooling->[0]) { $msg = sprintf "If estimated layer time is below ~%ds, fan will run at %d%% and print speed will be reduced so that no less than %ds are spent on that layer (however, speed will never be reduced below %dmm/s).", - $config->slowdown_below_layer_time, $config->max_fan_speed, $config->slowdown_below_layer_time, $config->min_print_speed; - if ($config->fan_below_layer_time > $config->slowdown_below_layer_time) { + $config->slowdown_below_layer_time->[0], $config->max_fan_speed->[0], $config->slowdown_below_layer_time->[0], $config->min_print_speed->[0]; + if ($config->fan_below_layer_time->[0] > $config->slowdown_below_layer_time->[0]) { $msg .= sprintf "\nIf estimated layer time is greater, but still below ~%ds, fan will run at a proportionally decreasing speed between %d%% and %d%%.", - $config->fan_below_layer_time, $config->max_fan_speed, $config->min_fan_speed; + $config->fan_below_layer_time->[0], $config->max_fan_speed->[0], $config->min_fan_speed->[0]; } $msg .= "\nDuring the other layers, fan $fan_other_layers" } else { diff --git a/slic3r.pl b/slic3r.pl index 54c295008..e158da656 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -315,7 +315,7 @@ $j --temperature Extrusion temperature in degree Celsius, set 0 to disable (default: $config->{temperature}->[0]) --first-layer-temperature Extrusion temperature for the first layer, in degree Celsius, set 0 to disable (default: same as --temperature) - --bed-temperature Heated bed temperature in degree Celsius, set 0 to disable (default: $config->{bed_temperature}) + --bed-temperature Heated bed temperature in degree Celsius, set 0 to disable (default: $config->{bed_temperature}[0]) --first-layer-bed-temperature Heated bed temperature for the first layer, in degree Celsius, set 0 to disable (default: same as --bed-temperature) @@ -464,15 +464,15 @@ $j Cooling options: --cooling Enable fan and cooling control - --min-fan-speed Minimum fan speed (default: $config->{min_fan_speed}%) - --max-fan-speed Maximum fan speed (default: $config->{max_fan_speed}%) - --bridge-fan-speed Fan speed to use when bridging (default: $config->{bridge_fan_speed}%) + --min-fan-speed Minimum fan speed (default: $config->{min_fan_speed}[0]%) + --max-fan-speed Maximum fan speed (default: $config->{max_fan_speed}[0]%) + --bridge-fan-speed Fan speed to use when bridging (default: $config->{bridge_fan_speed}[0]%) --fan-below-layer-time Enable fan if layer print time is below this approximate number - of seconds (default: $config->{fan_below_layer_time}) + of seconds (default: $config->{fan_below_layer_time}[0]) --slowdown-below-layer-time Slow down if layer print time is below this approximate number - of seconds (default: $config->{slowdown_below_layer_time}) - --min-print-speed Minimum print speed (mm/s, default: $config->{min_print_speed}) - --disable-fan-first-layers Disable fan for the first N layers (default: $config->{disable_fan_first_layers}) + of seconds (default: $config->{slowdown_below_layer_time}[0]) + --min-print-speed Minimum print speed (mm/s, default: $config->{min_print_speed}[0]) + --disable-fan-first-layers Disable fan for the first N layers (default: $config->{disable_fan_first_layers}[0]) --fan-always-on Keep fan always on at min fan speed, even for layers that don't need cooling diff --git a/t/cooling.t b/t/cooling.t index 2324e86c1..560af1beb 100644 --- a/t/cooling.t +++ b/t/cooling.t @@ -27,18 +27,18 @@ sub buffer { } my $config = Slic3r::Config->new_from_defaults; -$config->set('disable_fan_first_layers', 0); +$config->set('disable_fan_first_layers', [ 0 ]); { my $buffer = buffer($config); - $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->slowdown_below_layer_time + 1); + $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->slowdown_below_layer_time->[0] + 1); my $gcode = $buffer->append('G1 F3000;_EXTRUDE_SET_SPEED\nG1 X100 E1', 0, 0, 0) . $buffer->flush; like $gcode, qr/F3000/, 'speed is not altered when elapsed time is greater than slowdown threshold'; } { my $buffer = buffer($config); - $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->slowdown_below_layer_time - 1); + $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->slowdown_below_layer_time->[0] - 1); my $gcode = $buffer->append( "G1 X50 F2500\n" . "G1 F3000;_EXTRUDE_SET_SPEED\n" . @@ -53,7 +53,7 @@ $config->set('disable_fan_first_layers', 0); { my $buffer = buffer($config); - $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->fan_below_layer_time + 1); + $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->fan_below_layer_time->[0] + 1); my $gcode = $buffer->append('G1 X100 E1 F3000', 0, 0, 0) . $buffer->flush; unlike $gcode, qr/M106/, 'fan is not activated when elapsed time is greater than fan threshold'; } @@ -63,7 +63,7 @@ $config->set('disable_fan_first_layers', 0); my $gcode = ""; for my $obj_id (0 .. 1) { # use an elapsed time which is < the slowdown threshold but greater than it when summed twice - $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->slowdown_below_layer_time - 1); + $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->slowdown_below_layer_time->[0] - 1); $gcode .= $buffer->append("G1 X100 E1 F3000\n", $obj_id, 0, 0); } $gcode .= $buffer->flush; @@ -76,7 +76,7 @@ $config->set('disable_fan_first_layers', 0); for my $layer_id (0 .. 1) { for my $obj_id (0 .. 1) { # use an elapsed time which is < the threshold but greater than it when summed twice - $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->fan_below_layer_time - 1); + $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->fan_below_layer_time->[0] - 1); $gcode .= $buffer->append("G1 X100 E1 F3000\n", $obj_id, $layer_id, 0); } } @@ -90,7 +90,7 @@ $config->set('disable_fan_first_layers', 0); for my $layer_id (0 .. 1) { for my $obj_id (0 .. 1) { # use an elapsed time which is < the threshold even when summed twice - $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->fan_below_layer_time/2 - 1); + $buffer->gcodegen->set_elapsed_time($buffer->gcodegen->config->fan_below_layer_time->[0]/2 - 1); $gcode .= $buffer->append("G1 X100 E1 F3000\n", $obj_id, $layer_id, 0); } } @@ -100,10 +100,10 @@ $config->set('disable_fan_first_layers', 0); { my $config = Slic3r::Config->new_from_defaults; - $config->set('cooling', 1); - $config->set('bridge_fan_speed', 100); - $config->set('fan_below_layer_time', 0); - $config->set('slowdown_below_layer_time', 0); + $config->set('cooling', [ 1 ]); + $config->set('bridge_fan_speed', [ 100 ]); + $config->set('fan_below_layer_time', [ 0 ]); + $config->set('slowdown_below_layer_time', [ 0 ]); $config->set('bridge_speed', 99); $config->set('top_solid_layers', 1); # internal bridges use solid_infil speed $config->set('bottom_solid_layers', 1); # internal bridges use solid_infil speed @@ -134,10 +134,10 @@ $config->set('disable_fan_first_layers', 0); { 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); - $config->set('min_print_speed', 0); + $config->set('cooling', [ 1 ]); + $config->set('fan_below_layer_time', [ 0 ]); + $config->set('slowdown_below_layer_time', [ 10 ]); + $config->set('min_print_speed', [ 0 ]); $config->set('start_gcode', ''); my $print = Slic3r::Test::init_print('20mm_cube', config => $config); @@ -152,7 +152,7 @@ $config->set('disable_fan_first_layers', 0); $layer_times[-1] += abs($info->{dist_XY} || $info->{dist_E} || $info->{dist_Z} || 0) / ($args->{F} // $self->F) * 60; } }); - my $all_below = !defined first { $_ > 0 && $_ < $config->slowdown_below_layer_time } @layer_times; + my $all_below = !defined first { $_ > 0 && $_ < $config->slowdown_below_layer_time->[0] } @layer_times; ok $all_below, 'slowdown_below_layer_time is honored'; } diff --git a/t/fill.t b/t/fill.t index 626144301..3c434ea52 100644 --- a/t/fill.t +++ b/t/fill.t @@ -199,7 +199,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { $config->set('infill_extruder', 2); $config->set('infill_extrusion_width', 0.5); $config->set('fill_density', 40); - $config->set('cooling', 0); # for preventing speeds from being altered + $config->set('cooling', [ 0 ]); # for preventing speeds from being altered $config->set('first_layer_speed', '100%'); # for preventing speeds from being altered my $test = sub { @@ -249,7 +249,7 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { $config->set('solid_infill_every_layers', 2); $config->set('perimeter_speed', 99); $config->set('external_perimeter_speed', 99); - $config->set('cooling', 0); + $config->set('cooling', [ 0 ]); $config->set('first_layer_speed', '100%'); my $print = Slic3r::Test::init_print('20mm_cube', config => $config); diff --git a/t/flow.t b/t/flow.t index 071d290c8..659a1171e 100644 --- a/t/flow.t +++ b/t/flow.t @@ -43,7 +43,7 @@ use Slic3r::Test; 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 + $config->set('cooling', [ 0 ]); # to prevent speeds from being altered $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered my $test = sub { diff --git a/t/gaps.t b/t/gaps.t index 16baa0363..6210a7dce 100644 --- a/t/gaps.t +++ b/t/gaps.t @@ -23,7 +23,7 @@ use Slic3r::Test; $config->set('small_perimeter_speed', 66); $config->set('gap_fill_speed', 99); $config->set('perimeters', 1); - $config->set('cooling', 0); # to prevent speeds from being altered + $config->set('cooling', [ 0 ]); # to prevent speeds from being altered $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered $config->set('perimeter_extrusion_width', 0.35); $config->set('first_layer_extrusion_width', 0.35); diff --git a/t/multi.t b/t/multi.t index 362f1f7b4..f709f14ed 100644 --- a/t/multi.t +++ b/t/multi.t @@ -128,7 +128,7 @@ use Slic3r::Test; $config->set('fill_density', 0); $config->set('solid_infill_speed', 99); $config->set('top_solid_infill_speed', 99); - $config->set('cooling', 0); # for preventing speeds from being altered + $config->set('cooling', [ 0 ]); # for preventing speeds from being altered $config->set('first_layer_speed', '100%'); # for preventing speeds from being altered my $test = sub { diff --git a/t/perimeters.t b/t/perimeters.t index b328b2b5f..b1706f29c 100644 --- a/t/perimeters.t +++ b/t/perimeters.t @@ -161,7 +161,7 @@ use Slic3r::Test; $config->set('perimeters', 3); $config->set('top_solid_layers', 0); $config->set('bottom_solid_layers', 0); - $config->set('cooling', 0); # to prevent speeds from being altered + $config->set('cooling', [ 0 ]); # to prevent speeds from being altered $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered { @@ -242,10 +242,10 @@ use Slic3r::Test; $config->set('perimeter_speed', 77); $config->set('external_perimeter_speed', 66); $config->set('bridge_speed', 99); - $config->set('cooling', 1); - $config->set('fan_below_layer_time', 0); - $config->set('slowdown_below_layer_time', 0); - $config->set('bridge_fan_speed', 100); + $config->set('cooling', [ 1 ]); + $config->set('fan_below_layer_time', [ 0 ]); + $config->set('slowdown_below_layer_time', [ 0 ]); + $config->set('bridge_fan_speed', [ 100 ]); $config->set('bridge_flow_ratio', 33); # arbitrary value $config->set('overhangs', 1); my $print = Slic3r::Test::init_print('overhang', config => $config); @@ -289,7 +289,7 @@ use Slic3r::Test; $config->set('layer_height', 0.4); $config->set('first_layer_height', 0.35); $config->set('extra_perimeters', 1); - $config->set('cooling', 0); # to prevent speeds from being altered + $config->set('cooling', [ 0 ]); # to prevent speeds from being altered $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered $config->set('perimeter_speed', 99); $config->set('external_perimeter_speed', 99); @@ -377,7 +377,7 @@ use Slic3r::Test; $config->set('bridge_speed', 99); $config->set('fill_density', 0); # to prevent bridging over sparse infill $config->set('overhangs', 1); - $config->set('cooling', 0); # to prevent speeds from being altered + $config->set('cooling', [ 0 ]); # to prevent speeds from being altered $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered my $test = sub { diff --git a/t/shells.t b/t/shells.t index e7eb5da13..eeec94ce2 100644 --- a/t/shells.t +++ b/t/shells.t @@ -20,7 +20,7 @@ use Slic3r::Test; $config->set('top_solid_infill_speed', 99); $config->set('bridge_speed', 72); $config->set('first_layer_speed', '100%'); - $config->set('cooling', 0); + $config->set('cooling', [ 0 ]); my $test = sub { my ($conf) = @_; @@ -86,7 +86,7 @@ use Slic3r::Test; $config->set('first_layer_height', '100%'); $config->set('bottom_solid_layers', 0); $config->set('top_solid_layers', 3); - $config->set('cooling', 0); + $config->set('cooling', [ 0 ]); $config->set('bridge_speed', 99); $config->set('solid_infill_speed', 99); $config->set('top_solid_infill_speed', 99); @@ -115,7 +115,7 @@ use Slic3r::Test; # discarded instead of grown $config->set('perimeters', 1); $config->set('fill_density', 0); - $config->set('cooling', 0); # prevent speed alteration + $config->set('cooling', [ 0 ]); # prevent speed alteration $config->set('first_layer_speed', '100%'); # prevent speed alteration $config->set('layer_height', 0.4); $config->set('first_layer_height', '100%'); @@ -138,7 +138,7 @@ use Slic3r::Test; { my $config = Slic3r::Config->new_from_defaults; $config->set('perimeters', 3); - $config->set('cooling', 0); # prevent speed alteration + $config->set('cooling', [ 0 ]); # prevent speed alteration $config->set('first_layer_speed', '100%'); # prevent speed alteration $config->set('layer_height', 0.4); $config->set('first_layer_height', '100%'); diff --git a/t/skirt_brim.t b/t/skirt_brim.t index 878a78840..7a4507942 100644 --- a/t/skirt_brim.t +++ b/t/skirt_brim.t @@ -18,7 +18,7 @@ use Slic3r::Test; $config->set('skirt_height', 2); $config->set('perimeters', 0); $config->set('support_material_speed', 99); - $config->set('cooling', 0); # to prevent speeds to be altered + $config->set('cooling', [ 0 ]); # to prevent speeds to be altered $config->set('first_layer_speed', '100%'); # to prevent speeds to be altered my $test = sub { @@ -52,7 +52,7 @@ use Slic3r::Test; $config->set('bottom_solid_layers', 0); # to prevent solid shells and their speeds $config->set('brim_width', 5); $config->set('support_material_speed', 99); - $config->set('cooling', 0); # to prevent speeds to be altered + $config->set('cooling', [ 0 ]); # to prevent speeds to be altered $config->set('first_layer_speed', '100%'); # to prevent speeds to be altered my $print = Slic3r::Test::init_print('20mm_cube', config => $config); @@ -97,7 +97,7 @@ use Slic3r::Test; $config->set('support_material_speed', 99); $config->set('perimeter_extruder', 1); $config->set('support_material_extruder', 2); - $config->set('cooling', 0); # to prevent speeds to be altered + $config->set('cooling', [ 0 ]); # to prevent speeds to be altered $config->set('first_layer_speed', '100%'); # to prevent speeds to be altered my $print = Slic3r::Test::init_print('overhang', config => $config); diff --git a/t/support.t b/t/support.t index e30571c09..e024b7cbe 100644 --- a/t/support.t +++ b/t/support.t @@ -114,7 +114,7 @@ use Slic3r::Test; $config->set('support_material_extrusion_width', 0.6); $config->set('first_layer_extrusion_width', '100%'); $config->set('bridge_speed', 99); - $config->set('cooling', 0); # prevent speed alteration + $config->set('cooling', [ 0 ]); # prevent speed alteration $config->set('first_layer_speed', '100%'); # prevent speed alteration $config->set('start_gcode', ''); # prevent any unexpected Z move my $print = Slic3r::Test::init_print('20mm_cube', config => $config); @@ -197,7 +197,7 @@ use Slic3r::Test; $config->set('support_material', 1); $config->set('top_solid_layers', 0); # so that we don't have the internal bridge over infill $config->set('bridge_speed', 99); - $config->set('cooling', 0); + $config->set('cooling', [ 0 ]); $config->set('first_layer_speed', '100%'); my $test = sub { diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index f3d298d41..f73866b76 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -445,14 +445,14 @@ bool GCode::do_export(FILE *file, Print &print) m_placeholder_parser.update_timestamp(); // Disable fan. - if (print.config.cooling.value && print.config.disable_fan_first_layers.value) + if (print.config.cooling.values.front() && print.config.disable_fan_first_layers.values.front()) write(file, m_writer.set_fan(0, true)); // Set bed temperature if the start G-code does not contain any bed temp control G-codes. - if (print.config.first_layer_bed_temperature.value > 0 && + if (print.config.first_layer_bed_temperature.values.front() > 0 && boost::ifind_first(print.config.start_gcode.value, std::string("M140")).empty() && boost::ifind_first(print.config.start_gcode.value, std::string("M190")).empty()) - write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature.value, true)); + write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature.values.front(), true)); // Get optimal tool ordering to minimize tool switches of a multi-exruder print. // For a print by objects, find the 1st printing object. @@ -582,8 +582,8 @@ bool GCode::do_export(FILE *file, Print &print) // Ff we are printing the bottom layer of an object, and we have already finished // another one, set first layer temperatures. This happens before the Z move // is triggered, so machine has more time to reach such temperatures. - if (print.config.first_layer_bed_temperature.value > 0) - write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature)); + if (print.config.first_layer_bed_temperature.values.front() > 0) + write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature.values.front())); // Set first layer extruder. this->_print_first_layer_extruder_temperatures(file, print, initial_extruder_id, false); } @@ -819,8 +819,8 @@ void GCode::process_layer( if (temperature > 0 && temperature != print.config.first_layer_temperature.get_at(extruder.id)) gcode += m_writer.set_temperature(temperature, false, extruder.id); } - if (print.config.bed_temperature.value > 0 && print.config.bed_temperature != print.config.first_layer_bed_temperature.value) - gcode += m_writer.set_bed_temperature(print.config.bed_temperature); + if (print.config.bed_temperature.values.front() > 0 && print.config.bed_temperature.values.front() != print.config.first_layer_bed_temperature.values.front()) + gcode += m_writer.set_bed_temperature(print.config.bed_temperature.values.front()); // Mark the temperature transition from 1st to 2nd layer to be finished. m_second_layer_things_done = true; } @@ -1861,7 +1861,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, this->set_last_pos(path.last_point()); - if (m_config.cooling) + if (m_config.cooling.values.front()) m_elapsed_time += path_length / F * 60.f; return gcode; @@ -1913,7 +1913,7 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string factor on the whole elapsed time but only alters non-travel moves, thus the resulting time is still shorter than the configured threshold. We could create a new elapsed_travel_time but we would still need to account for bridges, retractions, wipe etc. - if (m_config.cooling) + if (m_config.cooling.values.front()) m_elapsed_time += unscale(travel.length()) / m_config.get_abs_value("travel_speed"); */ diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index 0ddc6a75d..9040a86a9 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -59,25 +59,25 @@ std::string CoolingBuffer::flush() m_gcode.clear(); m_elapsed_time = 0.; - int fan_speed = config.fan_always_on ? config.min_fan_speed.value : 0; + int fan_speed = config.fan_always_on.values.front() ? config.min_fan_speed.values.front() : 0; float speed_factor = 1.0; - if (config.cooling) { + if (config.cooling.values.front()) { #ifdef SLIC3R_DEBUG printf("Layer %zu estimated printing time: %f seconds\n", m_layer_id, elapsed); #endif - if (elapsed < (float)config.slowdown_below_layer_time) { + if (elapsed < (float)config.slowdown_below_layer_time.values.front()) { // Layer time very short. Enable the fan to a full throttle and slow down the print // (stretch the layer print time to slowdown_below_layer_time). - fan_speed = config.max_fan_speed; - speed_factor = elapsed / (float)config.slowdown_below_layer_time; - } else if (elapsed < (float)config.fan_below_layer_time) { + fan_speed = config.max_fan_speed.values.front(); + speed_factor = elapsed / (float)config.slowdown_below_layer_time.values.front(); + } else if (elapsed < (float)config.fan_below_layer_time.values.front()) { // Layer time quite short. Enable the fan proportionally according to the current layer time. - fan_speed = config.max_fan_speed - - (config.max_fan_speed - config.min_fan_speed) - * (elapsed - (float)config.slowdown_below_layer_time) - / (config.fan_below_layer_time - config.slowdown_below_layer_time); + fan_speed = config.max_fan_speed.values.front() + - (config.max_fan_speed.values.front() - config.min_fan_speed.values.front()) + * (elapsed - (float)config.slowdown_below_layer_time.values.front()) + / (config.fan_below_layer_time.values.front() - config.slowdown_below_layer_time.values.front()); } #ifdef SLIC3R_DEBUG @@ -92,7 +92,7 @@ std::string CoolingBuffer::flush() std::istringstream ss(gcode); std::string line; bool bridge_fan_start = false; - float min_print_speed = float(config.min_print_speed * 60.); + float min_print_speed = float(config.min_print_speed.values.front() * 60.); while (std::getline(ss, line)) { if (boost::starts_with(line, "G1") && boost::contains(line, ";_EXTRUDE_SET_SPEED") @@ -107,17 +107,17 @@ std::string CoolingBuffer::flush() gcode = new_gcode; } } - if (m_layer_id < config.disable_fan_first_layers) + if (m_layer_id < config.disable_fan_first_layers.values.front()) fan_speed = 0; gcode = m_gcodegen.writer().set_fan(fan_speed) + gcode; // bridge fan speed - if (!config.cooling || config.bridge_fan_speed == 0 || m_layer_id < config.disable_fan_first_layers) { + if (!config.cooling.values.front() || config.bridge_fan_speed.values.front() == 0 || m_layer_id < config.disable_fan_first_layers.values.front()) { boost::replace_all(gcode, ";_BRIDGE_FAN_START", ""); boost::replace_all(gcode, ";_BRIDGE_FAN_END", ""); } else { - boost::replace_all(gcode, ";_BRIDGE_FAN_START", m_gcodegen.writer().set_fan(config.bridge_fan_speed, true)); + boost::replace_all(gcode, ";_BRIDGE_FAN_START", m_gcodegen.writer().set_fan(config.bridge_fan_speed.values.front(), true)); boost::replace_all(gcode, ";_BRIDGE_FAN_END", m_gcodegen.writer().set_fan(fan_speed, true)); } boost::replace_all(gcode, ";_WIPE", ""); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 10123bf64..a9074b6a4 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -26,14 +26,18 @@ PrintConfigDef::PrintConfigDef() def->default_value = opt; } - def = this->add("bed_temperature", coInt); + def = this->add("bed_temperature", coInts); def->label = "Other layers"; def->tooltip = "Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output."; - def->cli = "bed-temperature=i"; + def->cli = "bed-temperature=i@"; def->full_label = "Bed temperature"; def->min = 0; def->max = 300; - def->default_value = new ConfigOptionInt(0); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(0); + def->default_value = opt; + } def = this->add("before_layer_gcode", coString); def->label = "Before layer change G-code"; @@ -61,14 +65,18 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(0); - def = this->add("bridge_fan_speed", coInt); + def = this->add("bridge_fan_speed", coInts); def->label = "Bridges fan speed"; def->tooltip = "This fan speed is enforced during all bridges and overhangs."; def->sidetext = "%"; - def->cli = "bridge-fan-speed=i"; + def->cli = "bridge-fan-speed=i@"; def->min = 0; def->max = 100; - def->default_value = new ConfigOptionInt(100); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(100); + def->default_value = opt; + } def = this->add("bridge_flow_ratio", coFloat); def->label = "Bridge flow ratio"; @@ -108,11 +116,15 @@ PrintConfigDef::PrintConfigDef() def->cli = "complete-objects!"; def->default_value = new ConfigOptionBool(false); - def = this->add("cooling", coBool); + def = this->add("cooling", coBools); def->label = "Enable auto cooling"; def->tooltip = "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time."; def->cli = "cooling!"; - def->default_value = new ConfigOptionBool(true); + { + ConfigOptionBools* opt = new ConfigOptionBools(); + opt->values.push_back(true); + def->default_value = opt; + } def = this->add("default_acceleration", coFloat); def->label = "Default"; @@ -122,14 +134,18 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(0); - def = this->add("disable_fan_first_layers", coInt); + def = this->add("disable_fan_first_layers", coInts); def->label = "Disable fan for the first"; def->tooltip = "You can set this to a positive value to disable fan at all during the first layers, so that it does not make adhesion worse."; def->sidetext = "layers"; - def->cli = "disable-fan-first-layers=i"; + def->cli = "disable-fan-first-layers=i@"; def->min = 0; def->max = 1000; - def->default_value = new ConfigOptionInt(3); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(3); + def->default_value = opt; + } def = this->add("dont_support_bridges", coBool); def->label = "Don't support bridges"; @@ -304,21 +320,29 @@ PrintConfigDef::PrintConfigDef() def->cli = "extrusion-width=s"; def->default_value = new ConfigOptionFloatOrPercent(0, false); - def = this->add("fan_always_on", coBool); + def = this->add("fan_always_on", coBools); def->label = "Keep fan always on"; def->tooltip = "If this is enabled, fan will never be disabled and will be kept running at least at its minimum speed. Useful for PLA, harmful for ABS."; def->cli = "fan-always-on!"; - def->default_value = new ConfigOptionBool(false); + { + ConfigOptionBools* opt = new ConfigOptionBools(); + opt->values.push_back(false); + def->default_value = opt; + } - def = this->add("fan_below_layer_time", coInt); + def = this->add("fan_below_layer_time", coInts); def->label = "Enable fan if layer print time is below"; def->tooltip = "If layer print time is estimated below this number of seconds, fan will be enabled and its speed will be calculated by interpolating the minimum and maximum speeds."; def->sidetext = "approximate seconds"; - def->cli = "fan-below-layer-time=i"; + def->cli = "fan-below-layer-time=i@"; def->width = 60; def->min = 0; def->max = 1000; - def->default_value = new ConfigOptionInt(60); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(60); + def->default_value = opt; + } def = this->add("filament_colour", coStrings); def->label = "Color"; @@ -516,13 +540,17 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(0); - def = this->add("first_layer_bed_temperature", coInt); + def = this->add("first_layer_bed_temperature", coInts); def->label = "First layer"; def->tooltip = "Heated build plate temperature for the first layer. Set this to zero to disable bed temperature control commands in the output."; - def->cli = "first-layer-bed-temperature=i"; + def->cli = "first-layer-bed-temperature=i@"; def->max = 0; def->max = 300; - def->default_value = new ConfigOptionInt(0); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(0); + def->default_value = opt; + } def = this->add("first_layer_extrusion_width", coFloatOrPercent); def->label = "First layer"; @@ -694,14 +722,18 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(0.3); - def = this->add("max_fan_speed", coInt); + def = this->add("max_fan_speed", coInts); def->label = "Max"; def->tooltip = "This setting represents the maximum speed of your fan."; def->sidetext = "%"; - def->cli = "max-fan-speed=i"; + def->cli = "max-fan-speed=i@"; def->min = 0; def->max = 100; - def->default_value = new ConfigOptionInt(100); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(100); + def->default_value = opt; + } def = this->add("max_layer_height", coFloats); def->label = "Max"; @@ -749,14 +781,18 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(0); - def = this->add("min_fan_speed", coInt); + def = this->add("min_fan_speed", coInts); def->label = "Min"; def->tooltip = "This setting represents the minimum PWM your fan needs to work."; def->sidetext = "%"; - def->cli = "min-fan-speed=i"; + def->cli = "min-fan-speed=i@"; def->min = 0; def->max = 100; - def->default_value = new ConfigOptionInt(35); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(35); + def->default_value = opt; + } def = this->add("min_layer_height", coFloats); def->label = "Min"; @@ -770,13 +806,17 @@ PrintConfigDef::PrintConfigDef() def->default_value = opt; } - def = this->add("min_print_speed", coFloat); + def = this->add("min_print_speed", coFloats); def->label = "Min print speed"; def->tooltip = "Slic3r will not scale speed down below this speed."; def->sidetext = "mm/s"; - def->cli = "min-print-speed=f"; + def->cli = "min-print-speed=f@"; def->min = 0; - def->default_value = new ConfigOptionFloat(10); + { + ConfigOptionFloats* opt = new ConfigOptionFloats(); + opt->values.push_back(10.); + def->default_value = opt; + } def = this->add("min_skirt_length", coFloat); def->label = "Minimum extrusion length"; @@ -1151,15 +1191,19 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionInt(1); - def = this->add("slowdown_below_layer_time", coInt); + def = this->add("slowdown_below_layer_time", coInts); def->label = "Slow down if layer print time is below"; def->tooltip = "If layer print time is estimated below this number of seconds, print moves speed will be scaled down to extend duration to this value."; def->sidetext = "approximate seconds"; - def->cli = "slowdown-below-layer-time=i"; + def->cli = "slowdown-below-layer-time=i@"; def->width = 60; def->min = 0; def->max = 1000; - def->default_value = new ConfigOptionInt(5); + { + ConfigOptionInts* opt = new ConfigOptionInts(); + opt->values.push_back(5); + def->default_value = opt; + } def = this->add("small_perimeter_speed", coFloatOrPercent); def->label = "Small perimeters"; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 9876befa8..55b5324ed 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -425,35 +425,35 @@ class PrintConfig : public GCodeConfig public: ConfigOptionBool avoid_crossing_perimeters; ConfigOptionPoints bed_shape; - ConfigOptionInt bed_temperature; + ConfigOptionInts bed_temperature; ConfigOptionFloat bridge_acceleration; - ConfigOptionInt bridge_fan_speed; + ConfigOptionInts bridge_fan_speed; ConfigOptionFloat brim_width; ConfigOptionBool complete_objects; - ConfigOptionBool cooling; + ConfigOptionBools cooling; ConfigOptionFloat default_acceleration; - ConfigOptionInt disable_fan_first_layers; + ConfigOptionInts disable_fan_first_layers; ConfigOptionFloat duplicate_distance; ConfigOptionFloat extruder_clearance_height; ConfigOptionFloat extruder_clearance_radius; ConfigOptionStrings extruder_colour; ConfigOptionPoints extruder_offset; - ConfigOptionBool fan_always_on; - ConfigOptionInt fan_below_layer_time; + ConfigOptionBools fan_always_on; + ConfigOptionInts fan_below_layer_time; ConfigOptionStrings filament_colour; ConfigOptionStrings filament_notes; ConfigOptionFloat first_layer_acceleration; - ConfigOptionInt first_layer_bed_temperature; + ConfigOptionInts first_layer_bed_temperature; ConfigOptionFloatOrPercent first_layer_extrusion_width; ConfigOptionFloatOrPercent first_layer_speed; ConfigOptionInts first_layer_temperature; ConfigOptionFloat infill_acceleration; ConfigOptionBool infill_first; - ConfigOptionInt max_fan_speed; + ConfigOptionInts max_fan_speed; ConfigOptionFloats max_layer_height; - ConfigOptionInt min_fan_speed; + ConfigOptionInts min_fan_speed; ConfigOptionFloats min_layer_height; - ConfigOptionFloat min_print_speed; + ConfigOptionFloats min_print_speed; ConfigOptionFloat min_skirt_length; ConfigOptionString notes; ConfigOptionFloats nozzle_diameter; @@ -469,7 +469,7 @@ public: ConfigOptionFloat skirt_distance; ConfigOptionInt skirt_height; ConfigOptionInt skirts; - ConfigOptionInt slowdown_below_layer_time; + ConfigOptionInts slowdown_below_layer_time; ConfigOptionBool spiral_vase; ConfigOptionInt standby_temperature_delta; ConfigOptionInts temperature;