From f12181750194a0586b721c3e8693c0b8d7005ec6 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 24 May 2018 16:11:34 +0200 Subject: [PATCH] Removed from Perl all 3DScene methods already moved to c++ --- lib/Slic3r/GUI/3DScene.pm | 144 +++++++++------------- lib/Slic3r/GUI/Plater.pm | 26 +++- lib/Slic3r/GUI/Plater/ObjectCutDialog.pm | 15 ++- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 13 +- 4 files changed, 99 insertions(+), 99 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index c2f1b8fa8..d8ee842bd 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -102,15 +102,13 @@ use constant TRACKBALLSIZE => 0.8; use constant TURNTABLE_MODE => 1; #============================================================================================================================== #use constant GROUND_Z => -0.02; -#============================================================================================================================== -# For mesh selection: Not selected - bright yellow. -use constant DEFAULT_COLOR => [1,1,0]; -# For mesh selection: Selected - bright green. -use constant SELECTED_COLOR => [0,1,0,1]; -# 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]; - -#============================================================================================================================== +## For mesh selection: Not selected - bright yellow. +#use constant DEFAULT_COLOR => [1,1,0]; +## For mesh selection: Selected - bright green. +#use constant SELECTED_COLOR => [0,1,0,1]; +## 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]; +# ## phi / theta angles to orient the camera. #use constant VIEW_DEFAULT => [45.0,45.0]; #use constant VIEW_LEFT => [90.0,90.0]; @@ -710,7 +708,10 @@ sub mouse_wheel_event { # $zoom = $self->_zoom / (1-$zoom); #============================================================================================================================== # 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 = $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->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->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; # if (ref($direction)) { # $dirvec = $direction; @@ -815,8 +816,8 @@ sub select_view { # $self->on_viewport_changed->() if $self->on_viewport_changed; # $self->Refresh; # } +#} #============================================================================================================================== -} sub get_zoom_to_bounding_box_factor { my ($self, $bb) = @_; @@ -927,20 +928,15 @@ sub get_zoom_to_bounding_box_factor { # $self->Refresh; # } #} -#============================================================================================================================== - -sub zoom_to_bed { - my ($self) = @_; - -#============================================================================================================================== - Slic3r::GUI::_3DScene::zoom_to_bed($self); +# +#sub zoom_to_bed { +# my ($self) = @_; +# # if ($self->bed_shape) { # $self->zoom_to_bounding_box($self->bed_bounding_box); # } -#============================================================================================================================== -} - -#============================================================================================================================== +#} +# #sub zoom_to_volume { # my ($self, $volume_idx) = @_; # @@ -948,60 +944,43 @@ sub zoom_to_bed { # my $bb = $volume->transformed_bounding_box; # $self->zoom_to_bounding_box($bb); #} -#============================================================================================================================== - -sub zoom_to_volumes { - my ($self) = @_; -#============================================================================================================================== - Slic3r::GUI::_3DScene::zoom_to_volumes($self); - +# +#sub zoom_to_volumes { +# my ($self) = @_; +# # $self->_apply_zoom_to_volumes_filter(1); # $self->zoom_to_bounding_box($self->volumes_bounding_box); # $self->_apply_zoom_to_volumes_filter(0); -#============================================================================================================================== -} - -sub volumes_bounding_box { - my ($self) = @_; - -#============================================================================================================================== - return Slic3r::GUI::_3DScene::get_volumes_bounding_box($self); - +#} +# +#sub volumes_bounding_box { +# my ($self) = @_; +# # my $bb = Slic3r::Geometry::BoundingBoxf3->new; # foreach my $v (@{$self->volumes}) { # $bb->merge($v->transformed_bounding_box) if (! $self->_apply_zoom_to_volumes_filter || $v->zoom_to_volumes); # } # return $bb; -#============================================================================================================================== -} - -sub bed_bounding_box { - my ($self) = @_; - -#============================================================================================================================== - return Slic3r::GUI::_3DScene::get_bed_bounding_box($self); - +#} +# +#sub bed_bounding_box { +# my ($self) = @_; +# # my $bb = Slic3r::Geometry::BoundingBoxf3->new; # if ($self->bed_shape) { # $bb->merge_point(Slic3r::Pointf3->new(@$_, 0)) for @{$self->bed_shape}; # } # return $bb; -#============================================================================================================================== -} - -sub max_bounding_box { - my ($self) = @_; - -#============================================================================================================================== - return Slic3r::GUI::_3DScene::get_max_bounding_box($self); - +#} +# +#sub max_bounding_box { +# my ($self) = @_; +# # my $bb = $self->bed_bounding_box; # $bb->merge($self->volumes_bounding_box); # return $bb; -#============================================================================================================================== -} - -#============================================================================================================================== +#} +# ## Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane ## to support the scene objects. #sub set_auto_bed_shape { @@ -1085,12 +1064,10 @@ sub select_volume { 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); # # # 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)); +#} #============================================================================================================================== -} # Given an axis and angle, compute quaternion. sub axis_to_quat { @@ -1277,12 +1254,10 @@ sub UseVBOs { #============================================================================================================================== } -sub Resize { - my ($self, $x, $y) = @_; - -#============================================================================================================================== - Slic3r::GUI::_3DScene::resize($self, $x, $y); - +#============================================================================================================================== +#sub Resize { +# my ($self, $x, $y) = @_; +# # return unless $self->GetContext; # $self->_dirty(0); # @@ -1320,8 +1295,8 @@ sub Resize { # glFrustum(-$w2, $w2, -$h2, $h2, $nr, $fr); # } # glMatrixMode(GL_MODELVIEW); +#} #============================================================================================================================== -} sub InitGL { my $self = shift; @@ -1341,11 +1316,12 @@ sub InitGL { $self->volumes->finalize_geometry(1) if ($^O eq 'linux' && $self->UseVBOs); - $self->zoom_to_bed; - -#=================================================================================================================================== +#============================================================================================================================== + Slic3r::GUI::_3DScene::zoom_to_bed($self); Slic3r::GUI::_3DScene::init($self, $self->UseVBOs); - + +# $self->zoom_to_bed; +# # glClearColor(0, 0, 0, 1); # glColor3f(1, 0, 0); # glEnable(GL_DEPTH_TEST); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 4581de41b..e7de0eb9b 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -385,7 +385,10 @@ sub new { $self->{canvas}->update_bed_size; if ($self->{canvas3D}) { $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}) { $self->{preview3D}->set_bed_shape($self->{config}->bed_shape); @@ -840,8 +843,10 @@ sub load_model_objects { $self->update; # 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}->Select($obj_idx[-1], 1); @@ -1923,7 +1928,10 @@ sub object_cut_dialog { $self->remove($obj_idx); $self->load_model_objects(grep defined($_), @new_objects); $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 $page = ($idx_page == &Wx::wxNOT_FOUND) ? L('3D') : $self->{preview_notebook}->GetPageText($idx_page); 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); } 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}); } } diff --git a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm index b379ba8ef..ab53da4a5 100644 --- a/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectCutDialog.pm @@ -118,7 +118,9 @@ sub new { $canvas->load_object($self->{model_object}, undef, undef, [0]); #============================================================================================================================== 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->SetSize([500,500]); @@ -260,10 +262,13 @@ sub _update { # $self->{canvas}->reset_objects; #============================================================================================================================== $self->{canvas}->load_object($_, undef, undef, [0]) for @objects; - $self->{canvas}->SetCuttingPlane( - $self->{cut_options}{z}, - [@expolygons], - ); +#============================================================================================================================== + Slic3r::GUI::_3DScene::set_cutting_plane($self->{canvas}, $self->{cut_options}{z}, [@expolygons]); +# $self->{canvas}->SetCuttingPlane( +# $self->{cut_options}{z}, +# [@expolygons], +# ); +#============================================================================================================================== $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config}); $self->{canvas}->Render; } diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 54fdc249e..bab628e23 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -166,9 +166,11 @@ sub new { }); $canvas->load_object($self->{model_object}, undef, undef, [0]); -#============================================================================================================================== - 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_auto_bed_shape($canvas); + 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->SetSize([500,700]); @@ -502,7 +504,10 @@ sub _parts_changed { # $self->{canvas}->reset_objects; #============================================================================================================================== $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}->Render; }