2013-05-17 12:14:33 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# This script displays 3D preview of a mesh
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
}
|
|
|
|
|
|
|
|
use Getopt::Long qw(:config no_auto_abbrev);
|
|
|
|
use Slic3r;
|
|
|
|
use Slic3r::GUI;
|
2013-06-27 09:47:07 +00:00
|
|
|
use Slic3r::GUI::PreviewCanvas;
|
2013-05-17 12:14:33 +00:00
|
|
|
$|++;
|
|
|
|
|
|
|
|
my %opt = ();
|
|
|
|
{
|
|
|
|
my %options = (
|
|
|
|
'help' => sub { usage() },
|
|
|
|
);
|
|
|
|
GetOptions(%options) or usage(1);
|
|
|
|
$ARGV[0] or usage(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
my $model = Slic3r::Model->read_from_file($ARGV[0]);
|
|
|
|
|
2014-07-12 15:06:42 +00:00
|
|
|
# make sure all objects have at least one defined instance
|
|
|
|
$model->add_default_instances;
|
|
|
|
|
2013-08-25 14:35:21 +00:00
|
|
|
$Slic3r::ViewMesh::object = $model->objects->[0];
|
2013-05-17 12:14:33 +00:00
|
|
|
my $app = Slic3r::ViewMesh->new;
|
|
|
|
$app->MainLoop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub usage {
|
|
|
|
my ($exit_code) = @_;
|
|
|
|
|
|
|
|
print <<"EOF";
|
|
|
|
Usage: view-mesh.pl [ OPTIONS ] file.stl
|
|
|
|
|
|
|
|
--help Output this usage screen and exit
|
|
|
|
|
|
|
|
EOF
|
|
|
|
exit ($exit_code || 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
package Slic3r::ViewMesh;
|
|
|
|
use Wx qw(:sizer);
|
|
|
|
use base qw(Wx::App);
|
|
|
|
|
2013-08-25 14:35:21 +00:00
|
|
|
our $object;
|
2013-05-17 12:14:33 +00:00
|
|
|
|
|
|
|
sub OnInit {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $frame = Wx::Frame->new(undef, -1, 'Mesh Viewer', [-1, -1], [500, 400]);
|
|
|
|
my $panel = Wx::Panel->new($frame, -1);
|
|
|
|
|
|
|
|
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
2013-08-25 14:35:21 +00:00
|
|
|
$sizer->Add(Slic3r::GUI::PreviewCanvas->new($panel, $object), 1, wxEXPAND, 0);
|
2013-05-17 12:14:33 +00:00
|
|
|
$panel->SetSizer($sizer);
|
|
|
|
$sizer->SetSizeHints($panel);
|
|
|
|
|
|
|
|
$frame->Show(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
__END__
|