2016-09-14 07:38:59 +00:00
|
|
|
# Implements pure perl packages
|
|
|
|
#
|
|
|
|
# Slic3r::GUI::3DScene::Base;
|
|
|
|
# Slic3r::GUI::3DScene;
|
|
|
|
#
|
|
|
|
# Slic3r::GUI::Plater::3D derives from Slic3r::GUI::3DScene,
|
2018-02-14 19:35:59 +00:00
|
|
|
# Slic3r::GUI::Plater::3DPreview,
|
2016-10-03 15:01:29 +00:00
|
|
|
# Slic3r::GUI::Plater::ObjectCutDialog and Slic3r::GUI::Plater::ObjectPartsPanel
|
2016-09-14 07:38:59 +00:00
|
|
|
# own $self->{canvas} of the Slic3r::GUI::3DScene type.
|
|
|
|
#
|
|
|
|
# Therefore the 3DScene supports renderng of STLs, extrusions and cutting planes,
|
|
|
|
# and camera manipulation.
|
|
|
|
|
2015-01-13 16:25:56 +00:00
|
|
|
package Slic3r::GUI::3DScene::Base;
|
2013-05-16 10:01:38 +00:00
|
|
|
use strict;
|
2013-05-17 12:14:33 +00:00
|
|
|
use warnings;
|
2013-06-30 21:51:06 +00:00
|
|
|
|
2017-12-11 17:00:51 +00:00
|
|
|
use Wx qw(wxTheApp :timer :bitmap :icon :dialog);
|
2013-05-16 10:01:38 +00:00
|
|
|
# must load OpenGL *before* Wx::GLCanvas
|
2014-12-15 14:19:42 +00:00
|
|
|
use OpenGL qw(:glconstants :glfunctions :glufunctions :gluconstants);
|
2013-05-17 12:14:33 +00:00
|
|
|
use base qw(Wx::GLCanvas Class::Accessor);
|
2013-05-16 10:01:38 +00:00
|
|
|
use Wx::GLCanvas qw(:all);
|
2016-11-16 08:24:27 +00:00
|
|
|
|
2013-05-16 10:01:38 +00:00
|
|
|
sub new {
|
2014-07-13 10:10:34 +00:00
|
|
|
my ($class, $parent) = @_;
|
2014-11-08 13:37:37 +00:00
|
|
|
|
2016-05-27 21:38:45 +00:00
|
|
|
# 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 =
|
2017-12-12 19:47:36 +00:00
|
|
|
! wxTheApp->{app_config}->get('use_legacy_opengl') &&
|
2016-05-27 21:38:45 +00:00
|
|
|
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);
|
|
|
|
|
2014-11-08 13:37:37 +00:00
|
|
|
# we request a depth buffer explicitely because it looks like it's not created by
|
|
|
|
# default on Linux, causing transparency issues
|
2016-05-27 21:38:45 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-12-14 14:36:18 +00:00
|
|
|
sub Destroy {
|
|
|
|
my ($self) = @_;
|
2018-05-09 08:47:04 +00:00
|
|
|
Slic3r::GUI::_3DScene::remove_canvas($self);
|
2016-12-14 14:36:18 +00:00
|
|
|
return $self->SUPER::Destroy;
|
|
|
|
}
|
|
|
|
|
2016-09-14 07:38:59 +00:00
|
|
|
# The 3D canvas to display objects and tool paths.
|
2015-01-13 16:25:56 +00:00
|
|
|
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(@_);
|
2015-01-13 16:25:56 +00:00
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2013-05-17 12:14:33 +00:00
|
|
|
1;
|