mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-01 21:21:10 -06:00
Very basic implementation of 3D preview - install Wx::GLCanvas to get it working
This commit is contained in:
parent
228c84ddc1
commit
5c74fd095b
7 changed files with 221 additions and 149 deletions
67
utils/view-mesh.pl
Normal file
67
utils/view-mesh.pl
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#!/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;
|
||||
$|++;
|
||||
|
||||
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]);
|
||||
|
||||
$Slic3r::ViewMesh::mesh = $model->mesh;
|
||||
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);
|
||||
|
||||
our $mesh;
|
||||
|
||||
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);
|
||||
$sizer->Add(Slic3r::GUI::PreviewCanvas->new($panel, $mesh), 1, wxEXPAND, 0);
|
||||
$panel->SetSizer($sizer);
|
||||
$sizer->SetSizeHints($panel);
|
||||
|
||||
$frame->Show(1);
|
||||
}
|
||||
|
||||
__END__
|
||||
Loading…
Add table
Add a link
Reference in a new issue