2016-09-13 09:24:55 +00:00
|
|
|
# This package loads all the non-GUI Slic3r perl packages.
|
|
|
|
|
2011-09-01 19:06:28 +00:00
|
|
|
package Slic3r;
|
|
|
|
|
2012-01-18 19:04:18 +00:00
|
|
|
# Copyright holder: Alessandro Ranellucci
|
|
|
|
# This application is licensed under the GNU Affero General Public License, version 3
|
|
|
|
|
2011-09-01 19:06:28 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2017-02-19 15:04:57 +00:00
|
|
|
use Config;
|
2012-01-22 12:56:15 +00:00
|
|
|
require v5.10;
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2014-11-09 19:41:27 +00:00
|
|
|
our $VERSION = VERSION();
|
2017-02-19 15:04:57 +00:00
|
|
|
our $BUILD = BUILD();
|
2016-10-21 14:53:42 +00:00
|
|
|
our $FORK_NAME = FORK_NAME();
|
2011-11-13 21:57:58 +00:00
|
|
|
|
2011-09-05 11:33:09 +00:00
|
|
|
our $debug = 0;
|
|
|
|
sub debugf {
|
|
|
|
printf @_ if $debug;
|
|
|
|
}
|
|
|
|
|
2016-11-24 12:44:51 +00:00
|
|
|
our $loglevel = 0;
|
|
|
|
|
2012-05-21 16:44:31 +00:00
|
|
|
BEGIN {
|
2016-09-26 10:57:15 +00:00
|
|
|
$debug = 1 if (defined($ENV{'SLIC3R_DEBUGOUT'}) && $ENV{'SLIC3R_DEBUGOUT'} == 1);
|
|
|
|
print "Debugging output enabled\n" if $debug;
|
2012-05-21 16:44:31 +00:00
|
|
|
}
|
2012-05-19 18:25:59 +00:00
|
|
|
|
2012-05-29 12:19:14 +00:00
|
|
|
use FindBin;
|
2017-10-25 10:53:31 +00:00
|
|
|
|
|
|
|
# Let the XS module know where the GUI resources reside.
|
2017-12-10 22:27:22 +00:00
|
|
|
set_resources_dir(decode_path($FindBin::Bin) . (($^O eq 'darwin') ? '/../Resources' : '/resources'));
|
2017-12-10 20:14:03 +00:00
|
|
|
set_var_dir(resources_dir() . "/icons");
|
2018-02-12 07:57:32 +00:00
|
|
|
set_local_dir(resources_dir() . "/localization/");
|
2012-05-29 12:19:14 +00:00
|
|
|
|
2013-09-12 09:09:03 +00:00
|
|
|
use Moo 1.003001;
|
2013-01-13 09:18:34 +00:00
|
|
|
|
2013-07-14 11:05:55 +00:00
|
|
|
use Slic3r::XS; # import all symbols (constants etc.) before they get parsed
|
2011-10-03 09:55:32 +00:00
|
|
|
use Slic3r::Config;
|
2011-10-15 09:36:05 +00:00
|
|
|
use Slic3r::ExPolygon;
|
2011-09-25 21:15:45 +00:00
|
|
|
use Slic3r::ExtrusionLoop;
|
2011-09-04 10:04:01 +00:00
|
|
|
use Slic3r::ExtrusionPath;
|
2012-06-06 16:05:03 +00:00
|
|
|
use Slic3r::Flow;
|
2013-05-13 18:14:33 +00:00
|
|
|
use Slic3r::GCode::Reader;
|
2013-06-07 21:16:02 +00:00
|
|
|
use Slic3r::Geometry::Clipper;
|
2011-09-01 19:06:28 +00:00
|
|
|
use Slic3r::Layer;
|
|
|
|
use Slic3r::Line;
|
2012-08-29 14:49:38 +00:00
|
|
|
use Slic3r::Model;
|
2011-09-01 19:06:28 +00:00
|
|
|
use Slic3r::Point;
|
2011-10-15 09:36:05 +00:00
|
|
|
use Slic3r::Polygon;
|
2011-09-01 19:06:28 +00:00
|
|
|
use Slic3r::Polyline;
|
2012-04-29 10:51:20 +00:00
|
|
|
use Slic3r::Print::Object;
|
2017-06-14 10:05:23 +00:00
|
|
|
use Slic3r::Print::Simple;
|
2011-09-01 19:06:28 +00:00
|
|
|
use Slic3r::Surface;
|
2013-04-27 18:55:43 +00:00
|
|
|
our $build = eval "use Slic3r::Build; 1";
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2016-09-13 09:24:55 +00:00
|
|
|
# Scaling between the float and integer coordinates.
|
|
|
|
# Floats are in mm.
|
2012-07-27 19:13:03 +00:00
|
|
|
use constant SCALING_FACTOR => 0.000001;
|
|
|
|
|
2016-11-24 12:44:51 +00:00
|
|
|
# Set the logging level at the Slic3r XS module.
|
|
|
|
$Slic3r::loglevel = (defined($ENV{'SLIC3R_LOGLEVEL'}) && $ENV{'SLIC3R_LOGLEVEL'} =~ /^[1-9]/) ? $ENV{'SLIC3R_LOGLEVEL'} : 0;
|
|
|
|
set_logging_level($Slic3r::loglevel);
|
|
|
|
|
2017-12-18 11:14:09 +00:00
|
|
|
# Let the palceholder parser evaluate one expression to initialize its local static macro_processor
|
|
|
|
# class instance in a thread safe manner.
|
|
|
|
Slic3r::GCode::PlaceholderParser->new->evaluate_boolean_expression('1==1');
|
|
|
|
|
2016-09-13 09:24:55 +00:00
|
|
|
# Open a file by converting $filename to local file system locales.
|
2013-01-13 09:18:34 +00:00
|
|
|
sub open {
|
|
|
|
my ($fh, $mode, $filename) = @_;
|
2013-02-22 17:40:00 +00:00
|
|
|
return CORE::open $$fh, $mode, encode_path($filename);
|
2013-01-13 09:18:34 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 15:04:57 +00:00
|
|
|
sub tags {
|
|
|
|
my ($format) = @_;
|
|
|
|
$format //= '';
|
|
|
|
my %tags;
|
|
|
|
# End of line
|
|
|
|
$tags{eol} = ($format eq 'html') ? '<br>' : "\n";
|
|
|
|
# Heading
|
2017-02-19 18:08:58 +00:00
|
|
|
$tags{h2start} = ($format eq 'html') ? '<b>' : '';
|
|
|
|
$tags{h2end} = ($format eq 'html') ? '</b>' : '';
|
2017-02-19 15:04:57 +00:00
|
|
|
# Bold font
|
|
|
|
$tags{bstart} = ($format eq 'html') ? '<b>' : '';
|
|
|
|
$tags{bend} = ($format eq 'html') ? '</b>' : '';
|
|
|
|
# Verbatim
|
|
|
|
$tags{vstart} = ($format eq 'html') ? '<pre>' : '';
|
|
|
|
$tags{vend} = ($format eq 'html') ? '</pre>' : '';
|
|
|
|
return %tags;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub slic3r_info
|
|
|
|
{
|
|
|
|
my (%params) = @_;
|
|
|
|
my %tag = Slic3r::tags($params{format});
|
|
|
|
my $out = '';
|
|
|
|
$out .= "$tag{bstart}$Slic3r::FORK_NAME$tag{bend}$tag{eol}";
|
|
|
|
$out .= "$tag{bstart}Version: $tag{bend}$Slic3r::VERSION$tag{eol}";
|
|
|
|
$out .= "$tag{bstart}Build: $tag{bend}$Slic3r::BUILD$tag{eol}";
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub copyright_info
|
|
|
|
{
|
|
|
|
my (%params) = @_;
|
|
|
|
my %tag = Slic3r::tags($params{format});
|
|
|
|
my $out =
|
|
|
|
'Copyright © 2016 Vojtech Bubnik, Prusa Research. <br />' .
|
|
|
|
'Copyright © 2011-2016 Alessandro Ranellucci. <br />' .
|
|
|
|
'<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 />' .
|
|
|
|
'Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Y. Sapir, Mike Sheldrake and numerous others. ' .
|
|
|
|
'Manual by Gary Hodgson. Inspired by the RepRap community. <br />' .
|
|
|
|
'Slic3r logo designed by Corey Daniels, <a href="http://www.famfamfam.com/lab/icons/silk/">Silk Icon Set</a> designed by Mark James. ';
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub system_info
|
|
|
|
{
|
|
|
|
my (%params) = @_;
|
|
|
|
my %tag = Slic3r::tags($params{format});
|
|
|
|
|
|
|
|
my $out = '';
|
|
|
|
$out .= "$tag{bstart}Operating System: $tag{bend}$Config{osname}$tag{eol}";
|
|
|
|
$out .= "$tag{bstart}System Architecture: $tag{bend}$Config{archname}$tag{eol}";
|
|
|
|
if ($^O eq 'MSWin32') {
|
|
|
|
$out .= "$tag{bstart}Windows Version: $tag{bend}" . `ver` . $tag{eol};
|
|
|
|
} else {
|
|
|
|
# Hopefully some kind of unix / linux.
|
|
|
|
$out .= "$tag{bstart}System Version: $tag{bend}" . `uname -a` . $tag{eol};
|
|
|
|
}
|
|
|
|
$out .= $tag{vstart} . Config::myconfig . $tag{vend};
|
|
|
|
$out .= " $tag{bstart}\@INC:$tag{bend}$tag{eol}$tag{vstart}";
|
|
|
|
foreach my $i (@INC) {
|
|
|
|
$out .= " $i\n";
|
|
|
|
}
|
|
|
|
$out .= "$tag{vend}";
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
2011-09-01 19:06:28 +00:00
|
|
|
1;
|