~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to utils/view-mesh.pl

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# This script displays 3D preview of a mesh
 
3
 
 
4
use strict;
 
5
use warnings;
 
6
 
 
7
BEGIN {
 
8
    use FindBin;
 
9
    use lib "$FindBin::Bin/../lib";
 
10
}
 
11
 
 
12
use Getopt::Long qw(:config no_auto_abbrev);
 
13
use Slic3r;
 
14
use Slic3r::GUI;
 
15
use Slic3r::GUI::PreviewCanvas;
 
16
$|++;
 
17
 
 
18
my %opt = ();
 
19
{
 
20
    my %options = (
 
21
        'help'                  => sub { usage() },
 
22
    );
 
23
    GetOptions(%options) or usage(1);
 
24
    $ARGV[0] or usage(1);
 
25
}
 
26
 
 
27
{
 
28
    my $model = Slic3r::Model->read_from_file($ARGV[0]);
 
29
    
 
30
    $Slic3r::ViewMesh::object = $model->objects->[0];
 
31
    my $app = Slic3r::ViewMesh->new;
 
32
    $app->MainLoop;
 
33
}
 
34
 
 
35
 
 
36
sub usage {
 
37
    my ($exit_code) = @_;
 
38
    
 
39
    print <<"EOF";
 
40
Usage: view-mesh.pl [ OPTIONS ] file.stl
 
41
 
 
42
    --help              Output this usage screen and exit
 
43
    
 
44
EOF
 
45
    exit ($exit_code || 0);
 
46
}
 
47
 
 
48
package Slic3r::ViewMesh;
 
49
use Wx qw(:sizer);
 
50
use base qw(Wx::App);
 
51
 
 
52
our $object;
 
53
 
 
54
sub OnInit {
 
55
    my $self = shift;
 
56
    
 
57
    my $frame = Wx::Frame->new(undef, -1, 'Mesh Viewer', [-1, -1], [500, 400]);
 
58
    my $panel = Wx::Panel->new($frame, -1);
 
59
    
 
60
    my $sizer = Wx::BoxSizer->new(wxVERTICAL);
 
61
    $sizer->Add(Slic3r::GUI::PreviewCanvas->new($panel, $object), 1, wxEXPAND, 0);
 
62
    $panel->SetSizer($sizer);
 
63
    $sizer->SetSizeHints($panel);
 
64
    
 
65
    $frame->Show(1);
 
66
}
 
67
 
 
68
__END__