2016-09-14 09:38:59 +02:00
|
|
|
# Implements pure perl packages
|
|
|
|
#
|
|
|
|
# Slic3r::GUI::3DScene::Base;
|
|
|
|
# Slic3r::GUI::3DScene;
|
|
|
|
#
|
|
|
|
# Slic3r::GUI::Plater::3D derives from Slic3r::GUI::3DScene,
|
2018-02-14 20:35:59 +01:00
|
|
|
# Slic3r::GUI::Plater::3DPreview,
|
2016-10-03 17:01:29 +02:00
|
|
|
# Slic3r::GUI::Plater::ObjectCutDialog and Slic3r::GUI::Plater::ObjectPartsPanel
|
2016-09-14 09:38:59 +02: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 17:25:56 +01:00
|
|
|
package Slic3r::GUI::3DScene::Base;
|
2013-05-16 12:01:38 +02:00
|
|
|
use strict;
|
2013-05-17 14:14:33 +02:00
|
|
|
use warnings;
|
2013-06-30 23:51:06 +02:00
|
|
|
|
2017-12-11 18:00:51 +01:00
|
|
|
use Wx qw(wxTheApp :timer :bitmap :icon :dialog);
|
2013-05-16 12:01:38 +02:00
|
|
|
# must load OpenGL *before* Wx::GLCanvas
|
2014-12-15 15:19:42 +01:00
|
|
|
use OpenGL qw(:glconstants :glfunctions :glufunctions :gluconstants);
|
2013-05-17 14:14:33 +02:00
|
|
|
use base qw(Wx::GLCanvas Class::Accessor);
|
2013-05-16 12:01:38 +02:00
|
|
|
use Wx::GLCanvas qw(:all);
|
2016-11-16 09:24:27 +01:00
|
|
|
|
2013-05-16 12:01:38 +02:00
|
|
|
sub new {
|
2014-07-13 12:10:34 +02:00
|
|
|
my ($class, $parent) = @_;
|
2014-11-08 14:37:37 +01:00
|
|
|
|
2016-05-27 23:38:45 +02: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 20:47:36 +01:00
|
|
|
! wxTheApp->{app_config}->get('use_legacy_opengl') &&
|
2016-05-27 23:38:45 +02: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 14:37:37 +01: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 23:38:45 +02:00
|
|
|
my $self = $class->SUPER::new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, 0, "", $attrib);
|
2018-05-09 10:47:04 +02:00
|
|
|
|
2018-06-11 15:49:04 +02:00
|
|
|
Slic3r::GUI::_3DScene::add_canvas($self);
|
2018-05-23 15:35:11 +02:00
|
|
|
Slic3r::GUI::_3DScene::allow_multisample($self, $can_multisample);
|
2014-12-15 01:28:11 +01:00
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2016-12-14 15:36:18 +01:00
|
|
|
sub Destroy {
|
|
|
|
my ($self) = @_;
|
2018-05-09 10:47:04 +02:00
|
|
|
Slic3r::GUI::_3DScene::remove_canvas($self);
|
2016-12-14 15:36:18 +01:00
|
|
|
return $self->SUPER::Destroy;
|
|
|
|
}
|
|
|
|
|
2016-09-14 09:38:59 +02:00
|
|
|
# The 3D canvas to display objects and tool paths.
|
2015-01-13 17:25:56 +01:00
|
|
|
package Slic3r::GUI::3DScene;
|
|
|
|
use base qw(Slic3r::GUI::3DScene::Base);
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $class = shift;
|
|
|
|
|
2018-06-21 12:21:51 +02:00
|
|
|
my $self = $class->SUPER::new(@_);
|
2015-01-13 17:25:56 +01:00
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2013-05-17 14:14:33 +02:00
|
|
|
1;
|