Removed from Perl all 3DScene methods already moved to c++

This commit is contained in:
Enrico Turri 2018-05-24 16:11:34 +02:00
parent c2e38fc6fe
commit f121817501
4 changed files with 99 additions and 99 deletions

View File

@ -102,15 +102,13 @@ use constant TRACKBALLSIZE => 0.8;
use constant TURNTABLE_MODE => 1; use constant TURNTABLE_MODE => 1;
#============================================================================================================================== #==============================================================================================================================
#use constant GROUND_Z => -0.02; #use constant GROUND_Z => -0.02;
#============================================================================================================================== ## For mesh selection: Not selected - bright yellow.
# For mesh selection: Not selected - bright yellow. #use constant DEFAULT_COLOR => [1,1,0];
use constant DEFAULT_COLOR => [1,1,0]; ## For mesh selection: Selected - bright green.
# For mesh selection: Selected - bright green. #use constant SELECTED_COLOR => [0,1,0,1];
use constant SELECTED_COLOR => [0,1,0,1]; ## For mesh selection: Mouse hovers over the object, but object not selected yet - dark green.
# For mesh selection: Mouse hovers over the object, but object not selected yet - dark green. #use constant HOVER_COLOR => [0.4,0.9,0,1];
use constant HOVER_COLOR => [0.4,0.9,0,1]; #
#==============================================================================================================================
## phi / theta angles to orient the camera. ## phi / theta angles to orient the camera.
#use constant VIEW_DEFAULT => [45.0,45.0]; #use constant VIEW_DEFAULT => [45.0,45.0];
#use constant VIEW_LEFT => [90.0,90.0]; #use constant VIEW_LEFT => [90.0,90.0];
@ -710,7 +708,10 @@ sub mouse_wheel_event {
# $zoom = $self->_zoom / (1-$zoom); # $zoom = $self->_zoom / (1-$zoom);
#============================================================================================================================== #==============================================================================================================================
# Don't allow to zoom too far outside the scene. # Don't allow to zoom too far outside the scene.
my $zoom_min = $self->get_zoom_to_bounding_box_factor($self->max_bounding_box); #==============================================================================================================================
my $zoom_min = $self->get_zoom_to_bounding_box_factor(Slic3r::GUI::_3DScene::get_max_bounding_box($self));
# my $zoom_min = $self->get_zoom_to_bounding_box_factor($self->max_bounding_box);
#==============================================================================================================================
$zoom_min *= 0.4 if defined $zoom_min; $zoom_min *= 0.4 if defined $zoom_min;
$zoom = $zoom_min if defined $zoom_min && $zoom < $zoom_min; $zoom = $zoom_min if defined $zoom_min && $zoom < $zoom_min;
#============================================================================================================================== #==============================================================================================================================
@ -737,7 +738,8 @@ sub mouse_wheel_event {
$self->on_viewport_changed->() if $self->on_viewport_changed; $self->on_viewport_changed->() if $self->on_viewport_changed;
#============================================================================================================================== #==============================================================================================================================
$self->Resize($self->GetSizeWH) if Slic3r::GUI::_3DScene::is_shown_on_screen($self); #==============================================================================================================================
Slic3r::GUI::_3DScene::resize($self, $self->GetSizeWH) if Slic3r::GUI::_3DScene::is_shown_on_screen($self);
# $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen; # $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen;
#============================================================================================================================== #==============================================================================================================================
$self->Refresh; $self->Refresh;
@ -778,13 +780,12 @@ sub set_viewport_from_scene {
#============================================================================================================================== #==============================================================================================================================
} }
# Set the camera to a default orientation,
# zoom to volumes.
sub select_view {
my ($self, $direction) = @_;
#============================================================================================================================== #==============================================================================================================================
Slic3r::GUI::_3DScene::select_view($self, $direction); ## Set the camera to a default orientation,
## zoom to volumes.
#sub select_view {
# my ($self, $direction) = @_;
#
# my $dirvec; # my $dirvec;
# if (ref($direction)) { # if (ref($direction)) {
# $dirvec = $direction; # $dirvec = $direction;
@ -815,8 +816,8 @@ sub select_view {
# $self->on_viewport_changed->() if $self->on_viewport_changed; # $self->on_viewport_changed->() if $self->on_viewport_changed;
# $self->Refresh; # $self->Refresh;
# } # }
#}
#============================================================================================================================== #==============================================================================================================================
}
sub get_zoom_to_bounding_box_factor { sub get_zoom_to_bounding_box_factor {
my ($self, $bb) = @_; my ($self, $bb) = @_;
@ -927,20 +928,15 @@ sub get_zoom_to_bounding_box_factor {
# $self->Refresh; # $self->Refresh;
# } # }
#} #}
#============================================================================================================================== #
#sub zoom_to_bed {
sub zoom_to_bed { # my ($self) = @_;
my ($self) = @_; #
#==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_bed($self);
# if ($self->bed_shape) { # if ($self->bed_shape) {
# $self->zoom_to_bounding_box($self->bed_bounding_box); # $self->zoom_to_bounding_box($self->bed_bounding_box);
# } # }
#============================================================================================================================== #}
} #
#==============================================================================================================================
#sub zoom_to_volume { #sub zoom_to_volume {
# my ($self, $volume_idx) = @_; # my ($self, $volume_idx) = @_;
# #
@ -948,60 +944,43 @@ sub zoom_to_bed {
# my $bb = $volume->transformed_bounding_box; # my $bb = $volume->transformed_bounding_box;
# $self->zoom_to_bounding_box($bb); # $self->zoom_to_bounding_box($bb);
#} #}
#============================================================================================================================== #
#sub zoom_to_volumes {
sub zoom_to_volumes { # my ($self) = @_;
my ($self) = @_; #
#==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_volumes($self);
# $self->_apply_zoom_to_volumes_filter(1); # $self->_apply_zoom_to_volumes_filter(1);
# $self->zoom_to_bounding_box($self->volumes_bounding_box); # $self->zoom_to_bounding_box($self->volumes_bounding_box);
# $self->_apply_zoom_to_volumes_filter(0); # $self->_apply_zoom_to_volumes_filter(0);
#============================================================================================================================== #}
} #
#sub volumes_bounding_box {
sub volumes_bounding_box { # my ($self) = @_;
my ($self) = @_; #
#==============================================================================================================================
return Slic3r::GUI::_3DScene::get_volumes_bounding_box($self);
# my $bb = Slic3r::Geometry::BoundingBoxf3->new; # my $bb = Slic3r::Geometry::BoundingBoxf3->new;
# foreach my $v (@{$self->volumes}) { # foreach my $v (@{$self->volumes}) {
# $bb->merge($v->transformed_bounding_box) if (! $self->_apply_zoom_to_volumes_filter || $v->zoom_to_volumes); # $bb->merge($v->transformed_bounding_box) if (! $self->_apply_zoom_to_volumes_filter || $v->zoom_to_volumes);
# } # }
# return $bb; # return $bb;
#============================================================================================================================== #}
} #
#sub bed_bounding_box {
sub bed_bounding_box { # my ($self) = @_;
my ($self) = @_; #
#==============================================================================================================================
return Slic3r::GUI::_3DScene::get_bed_bounding_box($self);
# my $bb = Slic3r::Geometry::BoundingBoxf3->new; # my $bb = Slic3r::Geometry::BoundingBoxf3->new;
# if ($self->bed_shape) { # if ($self->bed_shape) {
# $bb->merge_point(Slic3r::Pointf3->new(@$_, 0)) for @{$self->bed_shape}; # $bb->merge_point(Slic3r::Pointf3->new(@$_, 0)) for @{$self->bed_shape};
# } # }
# return $bb; # return $bb;
#============================================================================================================================== #}
} #
#sub max_bounding_box {
sub max_bounding_box { # my ($self) = @_;
my ($self) = @_; #
#==============================================================================================================================
return Slic3r::GUI::_3DScene::get_max_bounding_box($self);
# my $bb = $self->bed_bounding_box; # my $bb = $self->bed_bounding_box;
# $bb->merge($self->volumes_bounding_box); # $bb->merge($self->volumes_bounding_box);
# return $bb; # return $bb;
#============================================================================================================================== #}
} #
#==============================================================================================================================
## Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane ## Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane
## to support the scene objects. ## to support the scene objects.
#sub set_auto_bed_shape { #sub set_auto_bed_shape {
@ -1085,12 +1064,10 @@ sub select_volume {
if $volume_idx != -1; if $volume_idx != -1;
} }
sub SetCuttingPlane {
my ($self, $z, $expolygons) = @_;
#============================================================================================================================== #==============================================================================================================================
Slic3r::GUI::_3DScene::set_cutting_plane($self, $z, $expolygons); #sub SetCuttingPlane {
# my ($self, $z, $expolygons) = @_;
#
# $self->cutting_plane_z($z); # $self->cutting_plane_z($z);
# #
# # grow slices in order to display them better # # grow slices in order to display them better
@ -1104,8 +1081,8 @@ sub SetCuttingPlane {
# ); # );
# } # }
# $self->cut_lines_vertices(OpenGL::Array->new_list(GL_FLOAT, @verts)); # $self->cut_lines_vertices(OpenGL::Array->new_list(GL_FLOAT, @verts));
#}
#============================================================================================================================== #==============================================================================================================================
}
# Given an axis and angle, compute quaternion. # Given an axis and angle, compute quaternion.
sub axis_to_quat { sub axis_to_quat {
@ -1277,12 +1254,10 @@ sub UseVBOs {
#============================================================================================================================== #==============================================================================================================================
} }
sub Resize { #==============================================================================================================================
my ($self, $x, $y) = @_; #sub Resize {
# my ($self, $x, $y) = @_;
#============================================================================================================================== #
Slic3r::GUI::_3DScene::resize($self, $x, $y);
# return unless $self->GetContext; # return unless $self->GetContext;
# $self->_dirty(0); # $self->_dirty(0);
# #
@ -1320,8 +1295,8 @@ sub Resize {
# glFrustum(-$w2, $w2, -$h2, $h2, $nr, $fr); # glFrustum(-$w2, $w2, -$h2, $h2, $nr, $fr);
# } # }
# glMatrixMode(GL_MODELVIEW); # glMatrixMode(GL_MODELVIEW);
#}
#============================================================================================================================== #==============================================================================================================================
}
sub InitGL { sub InitGL {
my $self = shift; my $self = shift;
@ -1341,11 +1316,12 @@ sub InitGL {
$self->volumes->finalize_geometry(1) $self->volumes->finalize_geometry(1)
if ($^O eq 'linux' && $self->UseVBOs); if ($^O eq 'linux' && $self->UseVBOs);
$self->zoom_to_bed; #==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_bed($self);
#===================================================================================================================================
Slic3r::GUI::_3DScene::init($self, $self->UseVBOs); Slic3r::GUI::_3DScene::init($self, $self->UseVBOs);
# $self->zoom_to_bed;
#
# glClearColor(0, 0, 0, 1); # glClearColor(0, 0, 0, 1);
# glColor3f(1, 0, 0); # glColor3f(1, 0, 0);
# glEnable(GL_DEPTH_TEST); # glEnable(GL_DEPTH_TEST);

View File

@ -385,7 +385,10 @@ sub new {
$self->{canvas}->update_bed_size; $self->{canvas}->update_bed_size;
if ($self->{canvas3D}) { if ($self->{canvas3D}) {
$self->{canvas3D}->update_bed_size; $self->{canvas3D}->update_bed_size;
$self->{canvas3D}->zoom_to_bed; #==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_bed($self->{canvas3D});
# $self->{canvas3D}->zoom_to_bed;
#==============================================================================================================================
} }
if ($self->{preview3D}) { if ($self->{preview3D}) {
$self->{preview3D}->set_bed_shape($self->{config}->bed_shape); $self->{preview3D}->set_bed_shape($self->{config}->bed_shape);
@ -840,8 +843,10 @@ sub load_model_objects {
$self->update; $self->update;
# zoom to objects # zoom to objects
$self->{canvas3D}->zoom_to_volumes #==============================================================================================================================
if $self->{canvas3D}; Slic3r::GUI::_3DScene::zoom_to_volumes($self->{canvas3D}) if $self->{canvas3D};
# $self->{canvas3D}->zoom_to_volumes if $self->{canvas3D};
#==============================================================================================================================
$self->{list}->Update; $self->{list}->Update;
$self->{list}->Select($obj_idx[-1], 1); $self->{list}->Select($obj_idx[-1], 1);
@ -1923,7 +1928,10 @@ sub object_cut_dialog {
$self->remove($obj_idx); $self->remove($obj_idx);
$self->load_model_objects(grep defined($_), @new_objects); $self->load_model_objects(grep defined($_), @new_objects);
$self->arrange; $self->arrange;
$self->{canvas3D}->zoom_to_volumes if $self->{canvas3D}; #==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_volumes($self->{canvas3D}) if $self->{canvas3D};
# $self->{canvas3D}->zoom_to_volumes if $self->{canvas3D};
#==============================================================================================================================
} }
} }
@ -2202,10 +2210,16 @@ sub select_view {
my $idx_page = $self->{preview_notebook}->GetSelection; my $idx_page = $self->{preview_notebook}->GetSelection;
my $page = ($idx_page == &Wx::wxNOT_FOUND) ? L('3D') : $self->{preview_notebook}->GetPageText($idx_page); my $page = ($idx_page == &Wx::wxNOT_FOUND) ? L('3D') : $self->{preview_notebook}->GetPageText($idx_page);
if ($page eq L('Preview')) { if ($page eq L('Preview')) {
$self->{preview3D}->canvas->select_view($direction); #==============================================================================================================================
Slic3r::GUI::_3DScene::select_view($self->{preview3D}->canvas, $direction);
# $self->{preview3D}->canvas->select_view($direction);
#==============================================================================================================================
$self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas); $self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas);
} else { } else {
$self->{canvas3D}->select_view($direction); #==============================================================================================================================
Slic3r::GUI::_3DScene::select_view($self->{canvas3D}, $direction);
# $self->{canvas3D}->select_view($direction);
#==============================================================================================================================
$self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D}); $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D});
} }
} }

View File

@ -118,7 +118,9 @@ sub new {
$canvas->load_object($self->{model_object}, undef, undef, [0]); $canvas->load_object($self->{model_object}, undef, undef, [0]);
#============================================================================================================================== #==============================================================================================================================
Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas); Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas);
Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size })); Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ Slic3r::GUI::_3DScene::get_volumes_bounding_box($canvas)->size }));
# Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size }));
# $canvas->set_auto_bed_shape; # $canvas->set_auto_bed_shape;
#============================================================================================================================== #==============================================================================================================================
$canvas->SetSize([500,500]); $canvas->SetSize([500,500]);
@ -260,10 +262,13 @@ sub _update {
# $self->{canvas}->reset_objects; # $self->{canvas}->reset_objects;
#============================================================================================================================== #==============================================================================================================================
$self->{canvas}->load_object($_, undef, undef, [0]) for @objects; $self->{canvas}->load_object($_, undef, undef, [0]) for @objects;
$self->{canvas}->SetCuttingPlane( #==============================================================================================================================
$self->{cut_options}{z}, Slic3r::GUI::_3DScene::set_cutting_plane($self->{canvas}, $self->{cut_options}{z}, [@expolygons]);
[@expolygons], # $self->{canvas}->SetCuttingPlane(
); # $self->{cut_options}{z},
# [@expolygons],
# );
#==============================================================================================================================
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config}); $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config});
$self->{canvas}->Render; $self->{canvas}->Render;
} }

View File

@ -166,9 +166,11 @@ sub new {
}); });
$canvas->load_object($self->{model_object}, undef, undef, [0]); $canvas->load_object($self->{model_object}, undef, undef, [0]);
#============================================================================================================================== #==============================================================================================================================
Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas); Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas);
Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size })); Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ Slic3r::GUI::_3DScene::get_volumes_bounding_box($canvas)->size }));
# Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ $canvas->volumes_bounding_box->size }));
# $canvas->set_auto_bed_shape; # $canvas->set_auto_bed_shape;
#============================================================================================================================== #==============================================================================================================================
$canvas->SetSize([500,700]); $canvas->SetSize([500,700]);
@ -502,7 +504,10 @@ sub _parts_changed {
# $self->{canvas}->reset_objects; # $self->{canvas}->reset_objects;
#============================================================================================================================== #==============================================================================================================================
$self->{canvas}->load_object($self->{model_object}); $self->{canvas}->load_object($self->{model_object});
$self->{canvas}->zoom_to_volumes; #==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_volumes($self->{canvas});
# $self->{canvas}->zoom_to_volumes;
#==============================================================================================================================
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config}); $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
$self->{canvas}->Render; $self->{canvas}->Render;
} }