Browse Source

Merge branch 'master' into avoid-crossing-perimeters

Conflicts:
	lib/Slic3r/GCode.pm
	lib/Slic3r/Print.pm
Alessandro Ranellucci 12 years ago
parent
commit
61b164b539

+ 2 - 1
Build.PL

@@ -8,10 +8,11 @@ my $build = Module::Build->new(
     license         => 'perl',
     requires        => {
         'Boost::Geometry::Utils'    => '0',
+        'Encode::Locale'            => '0',
         'File::Basename'            => '0',
         'File::Spec'                => '0',
         'Getopt::Long'              => '0',
-        'Math::Clipper'             => '1.15',
+        'Math::Clipper'             => '1.17',
         'Math::ConvexHull::MonotoneChain' => '0.01',
         'Math::Geometry::Voronoi'   => '1.3',
         'Math::PlanePath'           => '53',

+ 3 - 3
README.markdown

@@ -108,7 +108,7 @@ The author of the Silk icon set is Mark James.
                             (default: 100,100)
         --z-offset          Additional height in mm to add to vertical coordinates
                             (+/-, default: 0)
-        --gcode-flavor      The type of G-code to generate (reprap/teacup/makerbot/mach3/no-extrusion,
+        --gcode-flavor      The type of G-code to generate (reprap/teacup/makerbot/sailfish/mach3/no-extrusion,
                             default: reprap)
         --use-relative-e-distances Enable this to get relative E values
         --gcode-arcs        Use G2/G3 commands for native arcs (experimental, not supported
@@ -275,7 +275,7 @@ The author of the Silk icon set is Mark James.
                             (like 0.65) or a percentage over layer height (like 200%)
         --first-layer-extrusion-width
                             Set a different extrusion width for first layer
-        --perimeters-extrusion-width
+        --perimeter-extrusion-width
                             Set a different extrusion width for perimeters
         --infill-extrusion-width
                             Set a different extrusion width for infill
@@ -286,7 +286,7 @@ The author of the Silk icon set is Mark James.
        Multiple extruder options:
         --extruder-offset   Offset of each extruder, if firmware doesn't handle the displacement
                             (can be specified multiple times, default: 0x0)
-        --perimeters-extruder
+        --perimeter-extruder
                             Extruder to use for perimeters (1+, default: 1)
         --infill-extruder   Extruder to use for infill (1+, default: 1)
         --support-material-extruder

+ 9 - 1
lib/Slic3r.pm

@@ -7,7 +7,7 @@ use strict;
 use warnings;
 require v5.10;
 
-our $VERSION = "0.9.8-dev";
+our $VERSION = "0.9.9-dev";
 
 our $debug = 0;
 sub debugf {
@@ -27,7 +27,10 @@ warn "Running Slic3r under Perl >= 5.16 is not supported nor recommended\n"
 use FindBin;
 our $var = "$FindBin::Bin/var";
 
+use Encode;
+use Encode::Locale;
 use Moo 0.091009;
+
 use Slic3r::Config;
 use Slic3r::ExPolygon;
 use Slic3r::Extruder;
@@ -89,4 +92,9 @@ sub parallelize {
     }
 }
 
+sub open {
+    my ($fh, $mode, $filename) = @_;
+    return CORE::open $$fh, $mode, encode('locale_fs', $filename);
+}
+
 1;

+ 20 - 9
lib/Slic3r/Config.pm

@@ -64,8 +64,8 @@ our $Options = {
         tooltip => 'Some G/M-code commands, including temperature control and others, are not universal. Set this option to your printer\'s firmware to get a compatible output. The "No extrusion" flavor prevents Slic3r from exporting any extrusion value at all.',
         cli     => 'gcode-flavor=s',
         type    => 'select',
-        values  => [qw(reprap teacup makerbot mach3 no-extrusion)],
-        labels  => ['RepRap (Marlin/Sprinter)', 'Teacup', 'MakerBot', 'Mach3/EMC', 'No extrusion'],
+        values  => [qw(reprap teacup makerbot sailfish mach3 no-extrusion)],
+        labels  => ['RepRap (Marlin/Sprinter)', 'Teacup', 'MakerBot', 'Sailfish', 'Mach3/EMC', 'No extrusion'],
         default => 'reprap',
     },
     'use_relative_e_distances' => {
@@ -158,7 +158,7 @@ our $Options = {
         sidetext => '°C',
         cli     => 'temperature=i@',
         type    => 'i',
-        max     => 300,
+        max     => 400,
         serialize   => $serialize_comma,
         deserialize => sub { $_[0] ? [ split /,/, $_[0] ] : [0] },
         default => [200],
@@ -171,7 +171,7 @@ our $Options = {
         type    => 'i',
         serialize   => $serialize_comma,
         deserialize => sub { $_[0] ? [ split /,/, $_[0] ] : [0] },
-        max     => 300,
+        max     => 400,
         default => [200],
     },
     
@@ -703,7 +703,7 @@ END
         type    => 'f',
         serialize   => $serialize_comma,
         deserialize => $deserialize_comma,
-        default => [3],
+        default => [10],
     },
     'retract_restart_extra_toolchange' => {
         label   => 'Extra length on restart',
@@ -722,7 +722,7 @@ END
         tooltip => 'This flag enables all the cooling features.',
         cli     => 'cooling!',
         type    => 'bool',
-        default => 0,
+        default => 1,
     },
     'min_fan_speed' => {
         label   => 'Min',
@@ -953,7 +953,7 @@ sub new_from_cli {
         if ($args{$opt_key}) {
             die "Invalid value for --${_}-gcode: file does not exist\n"
                 if !-e $args{$opt_key};
-            open my $fh, "<", $args{$opt_key}
+            Slic3r::open(\my $fh, "<", $args{$opt_key})
                 or die "Failed to open $args{$opt_key}\n";
             binmode $fh, ':utf8';
             $args{$opt_key} = do { local $/; <$fh> };
@@ -1031,6 +1031,17 @@ sub set {
         $value = 1;
     }
     
+    # For historical reasons, the world's full of configs having these very low values;
+    # to avoid unexpected behavior we need to ignore them.  Banning these two hard-coded
+    # values is a dirty hack and will need to be removed sometime in the future, but it
+    # will avoid lots of complaints for now.
+    if ($opt_key eq 'perimeter_acceleration' && $value == '25') {
+        $value = 0;
+    }
+    if ($opt_key eq 'infill_acceleration' && $value == '50') {
+        $value = 0;
+    }
+    
     if (!exists $Options->{$opt_key}) {
         my @keys = grep { $Options->{$_}{aliases} && grep $_ eq $opt_key, @{$Options->{$_}{aliases}} } keys %$Options;
         if (!@keys) {
@@ -1258,7 +1269,7 @@ sub write_ini {
     my $class = shift;
     my ($file, $ini) = @_;
     
-    open my $fh, '>', $file;
+    Slic3r::open(\my $fh, '>', $file);
     binmode $fh, ':utf8';
     my $localtime = localtime;
     printf $fh "# generated by Slic3r $Slic3r::VERSION on %s\n", "$localtime";
@@ -1276,7 +1287,7 @@ sub read_ini {
     my ($file) = @_;
     
     local $/ = "\n";
-    open my $fh, '<', $file;
+    Slic3r::open(\my $fh, '<', $file);
     binmode $fh, ':utf8';
     
     my $ini = { _ => {} };

+ 2 - 2
lib/Slic3r/Format/AMF.pm

@@ -13,7 +13,7 @@ sub read_file {
     	1;
     } or die "AMF parsing requires XML::SAX\n";
     
-    open my $fh, '<', $file or die "Failed to open $file\n";
+    Slic3r::open(\my $fh, '<', $file) or die "Failed to open $file\n";
     
     my $model = Slic3r::Model->new;
     XML::SAX::ParserFactory
@@ -30,7 +30,7 @@ sub write_file {
     
     my %vertices_offset = ();
     
-    open my $fh, '>', $file;
+    Slic3r::open(\my $fh, '>', $file);
     binmode $fh, ':utf8';
     printf $fh qq{<?xml version="1.0" encoding="UTF-8"?>\n};
     printf $fh qq{<amf unit="millimeter">\n};

+ 1 - 1
lib/Slic3r/Format/OBJ.pm

@@ -5,7 +5,7 @@ sub read_file {
     my $self = shift;
     my ($file) = @_;
     
-    open my $fh, '<', $file or die "Failed to open $file\n";
+    Slic3r::open(\my $fh, '<', $file) or die "Failed to open $file\n";
     my $vertices = [];
     my $facets = [];
     while (my $_ = <$fh>) {

+ 2 - 2
lib/Slic3r/Format/STL.pm

@@ -7,7 +7,7 @@ sub read_file {
     my $self = shift;
     my ($file) = @_;
     
-    open my $fh, '<', $file or die "Failed to open $file\n";
+    Slic3r::open(\my $fh, '<', $file) or die "Failed to open $file\n";
     
     # let's detect whether file is ASCII or binary
     my $mode;
@@ -103,7 +103,7 @@ sub write_file {
     my $self = shift;
     my ($file, $model, %params) = @_;
     
-    open my $fh, '>', $file;
+    Slic3r::open(\my $fh, '>', $file);
     
     $params{binary}
         ? _write_binary($fh, $model->mesh)

+ 33 - 9
lib/Slic3r/GCode.pm

@@ -7,6 +7,7 @@ use Slic3r::Geometry qw(scale unscale scaled_epsilon points_coincide PI X Y B);
 use Slic3r::Geometry::Clipper qw(union_ex);
 
 has 'multiple_extruders' => (is => 'ro', default => sub {0} );
+has 'layer_count'        => (is => 'ro', required => 1 );
 has 'layer'              => (is => 'rw');
 has 'move_z_callback'    => (is => 'rw');
 has 'shift_x'            => (is => 'rw', default => sub {0} );
@@ -80,6 +81,14 @@ sub change_layer {
             islands => union_ex([ map @$_, @{$layer->slices} ], undef, 1),
         ));
     }
+    
+    my $gcode = "";
+    if ($Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/) {
+        $gcode .= sprintf "M73 P%s%s\n",
+            int(100 * ($layer->id / ($self->layer_count - 1))),
+            ($Slic3r::Config->gcode_comments ? ' ; update progress' : '');
+    }
+    return $gcode;
 }
 
 # this method accepts Z in scaled coordinates
@@ -502,8 +511,18 @@ sub set_extruder {
     
     # set the new extruder
     $self->extruder($extruder);
-    $gcode .= sprintf "T%d%s\n", $extruder->id, ($Slic3r::Config->gcode_comments ? ' ; change extruder' : '');
-    $gcode .= $self->reset_e;
+    my $toolchange_gcode = sprintf "%s%d%s\n", 
+        ($Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/ ? 'M108 T' : 'T'),
+        $extruder->id,
+        ($Slic3r::Config->gcode_comments ? ' ; change extruder' : '');
+    
+    if ($Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/) {
+        $gcode .= $self->reset_e;
+        $gcode .= $toolchange_gcode;
+    } else {
+        $gcode .= $toolchange_gcode;
+        $gcode .= $self->reset_e;
+    }
     
     return $gcode;
 }
@@ -517,11 +536,17 @@ sub set_fan {
         if ($speed == 0) {
             my $code = $Slic3r::Config->gcode_flavor eq 'teacup'
                 ? 'M106 S0'
-                : 'M107';
+                : $Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/
+                    ? 'M127'
+                    : 'M107';
             return sprintf "$code%s\n", ($Slic3r::Config->gcode_comments ? ' ; disable fan' : '');
         } else {
-            return sprintf "M106 %s%d%s\n", ($Slic3r::Config->gcode_flavor eq 'mach3' ? 'P' : 'S'),
-                (255 * $speed / 100), ($Slic3r::Config->gcode_comments ? ' ; enable fan' : '');
+            if ($Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/) {
+                return sprintf "M126%s\n", ($Slic3r::Config->gcode_comments ? ' ; enable fan' : '');
+            } else {
+                return sprintf "M106 %s%d%s\n", ($Slic3r::Config->gcode_flavor eq 'mach3' ? 'P' : 'S'),
+                    (255 * $speed / 100), ($Slic3r::Config->gcode_comments ? ' ; enable fan' : '');
+            }
         }
     }
     return "";
@@ -531,14 +556,14 @@ sub set_temperature {
     my $self = shift;
     my ($temperature, $wait, $tool) = @_;
     
-    return "" if $wait && $Slic3r::Config->gcode_flavor eq 'makerbot';
+    return "" if $wait && $Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/;
     
     my ($code, $comment) = ($wait && $Slic3r::Config->gcode_flavor ne 'teacup')
         ? ('M109', 'wait for temperature to be reached')
         : ('M104', 'set temperature');
     my $gcode = sprintf "$code %s%d %s; $comment\n",
         ($Slic3r::Config->gcode_flavor eq 'mach3' ? 'P' : 'S'), $temperature,
-        (defined $tool && $self->multiple_extruders) ? "T$tool " : "";
+        (defined $tool && ($self->multiple_extruders || $Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/)) ? "T$tool " : "";
     
     $gcode .= "M116 ; wait for temperature to be reached\n"
         if $Slic3r::Config->gcode_flavor eq 'teacup' && $wait;
@@ -551,8 +576,7 @@ sub set_bed_temperature {
     my ($temperature, $wait) = @_;
     
     my ($code, $comment) = ($wait && $Slic3r::Config->gcode_flavor ne 'teacup')
-        ? (($Slic3r::Config->gcode_flavor eq 'makerbot' ? 'M109'
-            : 'M190'), 'wait for bed temperature to be reached')
+        ? (($Slic3r::Config->gcode_flavor =~ /^(?:makerbot|sailfish)$/ ? 'M109' : 'M190'), 'wait for bed temperature to be reached')
         : ('M140', 'set bed temperature');
     my $gcode = sprintf "$code %s%d ; $comment\n",
         ($Slic3r::Config->gcode_flavor eq 'mach3' ? 'P' : 'S'), $temperature;

+ 3 - 2
lib/Slic3r/GUI.pm

@@ -413,8 +413,9 @@ sub notify {
             my $notifier = $serv->get_object('/org/freedesktop/Notifications',
                                              'org.freedesktop.Notifications');
             $notifier->Notify('Slic3r', 0, $self->{icon}, $title, $message, [], {}, -1);
-        }
-    };
+            undef $Net::DBus::bus_session;
+        };
+    }
 }
 
 1;

+ 2 - 2
lib/Slic3r/GUI/AboutDialog.pm

@@ -47,12 +47,12 @@ sub new {
         '<html>' .
         '<body bgcolor="#ffffff" link="#808080">' .
         '<font color="#808080">' .
-        'Copyright &copy; 2011-2012 Alessandro Ranellucci. All rights reserved. ' .
+        'Copyright &copy; 2011-2013 Alessandro Ranellucci. All rights reserved. ' .
         '<a href="http://slic3r.org/">Slic3r</a> is licensed under the ' .
         '<a href="http://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License, version 3</a>.' .
         '<br /><br /><br />' .
         'Slic3r logo designed by Corey Daniels, <a href="http://www.famfamfam.com/lab/icons/silk/">Silk Icon Set</a> designed by Mark James. ' .
-        'Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess and numerous others.' .
+        'Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Mike Sheldrake and numerous others.' .
         '</font>' .
         '</body>' .
         '</html>';

Some files were not shown because too many files changed in this diff