PrusaSlicer-NonPlainar/lib/Slic3r/GUI/3DScene.pm

71 lines
2.4 KiB
Perl
Raw Normal View History

# Implements pure perl packages
#
# Slic3r::GUI::3DScene::Base;
# Slic3r::GUI::3DScene;
#
# Slic3r::GUI::Plater::3D derives from Slic3r::GUI::3DScene,
# Slic3r::GUI::Plater::3DPreview,
# Slic3r::GUI::Plater::ObjectCutDialog and Slic3r::GUI::Plater::ObjectPartsPanel
# own $self->{canvas} of the Slic3r::GUI::3DScene type.
#
# Therefore the 3DScene supports renderng of STLs, extrusions and cutting planes,
# and camera manipulation.
package Slic3r::GUI::3DScene::Base;
2013-05-16 10:01:38 +00:00
use strict;
use warnings;
2013-06-30 21:51:06 +00:00
use Wx qw(wxTheApp :timer :bitmap :icon :dialog);
2013-05-16 10:01:38 +00:00
# must load OpenGL *before* Wx::GLCanvas
use OpenGL qw(:glconstants :glfunctions :glufunctions :gluconstants);
use base qw(Wx::GLCanvas Class::Accessor);
2013-05-16 10:01:38 +00:00
use Wx::GLCanvas qw(:all);
2013-05-16 10:01:38 +00:00
sub new {
2014-07-13 10:10:34 +00:00
my ($class, $parent) = @_;
# We can only enable multi sample anti aliasing wih wxWidgets 3.0.3 and with a hacked Wx::GLCanvas,
# which exports some new WX_GL_XXX constants, namely WX_GL_SAMPLE_BUFFERS and WX_GL_SAMPLES.
my $can_multisample =
! wxTheApp->{app_config}->get('use_legacy_opengl') &&
Wx::wxVERSION >= 3.000003 &&
defined Wx::GLCanvas->can('WX_GL_SAMPLE_BUFFERS') &&
defined Wx::GLCanvas->can('WX_GL_SAMPLES');
my $attrib = [WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24];
if ($can_multisample) {
# Request a window with multi sampled anti aliasing. This is a new feature in Wx 3.0.3 (backported from 3.1.0).
# Use eval to avoid compilation, if the subs WX_GL_SAMPLE_BUFFERS and WX_GL_SAMPLES are missing.
eval 'push(@$attrib, (WX_GL_SAMPLE_BUFFERS, 1, WX_GL_SAMPLES, 4));';
}
# wxWidgets expect the attrib list to be ended by zero.
push(@$attrib, 0);
# we request a depth buffer explicitely because it looks like it's not created by
# default on Linux, causing transparency issues
my $self = $class->SUPER::new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, 0, "", $attrib);
2018-05-09 08:47:04 +00:00
2018-06-11 13:49:04 +00:00
Slic3r::GUI::_3DScene::add_canvas($self);
2018-05-23 13:35:11 +00:00
Slic3r::GUI::_3DScene::allow_multisample($self, $can_multisample);
2014-12-15 00:28:11 +00:00
return $self;
}
sub Destroy {
my ($self) = @_;
2018-05-09 08:47:04 +00:00
Slic3r::GUI::_3DScene::remove_canvas($self);
return $self->SUPER::Destroy;
}
# The 3D canvas to display objects and tool paths.
package Slic3r::GUI::3DScene;
use base qw(Slic3r::GUI::3DScene::Base);
sub new {
my $class = shift;
2018-06-21 10:21:51 +00:00
my $self = $class->SUPER::new(@_);
return $self;
}
1;