From d7edc08287fb00cde3ca0d29d5101c950e048b20 Mon Sep 17 00:00:00 2001 From: uclaros Date: Wed, 2 Nov 2016 14:05:36 +0200 Subject: [PATCH 1/4] Added small axis marker on the center of rotation when rotating or translating. --- lib/Slic3r/GUI/3DScene.pm | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index a36d2263ca..95269cbd2f 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -46,6 +46,7 @@ use constant GROUND_Z => -0.02; use constant DEFAULT_COLOR => [1,1,0]; use constant SELECTED_COLOR => [0,1,0,1]; use constant HOVER_COLOR => [0.4,0.9,0,1]; +use constant PI => 3.1415927; # make OpenGL::Array thread-safe { @@ -833,11 +834,46 @@ sub Render { glDisable(GL_BLEND); } + if (defined $self->_drag_start_pos || defined $self->_drag_start_xy) { + $self->draw_center_of_rotation($self->_camera_target->x, $self->_camera_target->y, $self->_camera_target->z); + } + glFlush(); $self->SwapBuffers(); } +sub draw_axes { + my ($self, $x, $y, $z, $length, $width, $allways_visible) = @_; + if ($allways_visible) { + glDisable(GL_DEPTH_TEST); + } else { + glEnable(GL_DEPTH_TEST); + } + glLineWidth($width); + glBegin(GL_LINES); + # draw line for x axis + glColor3f(1, 0, 0); + glVertex3f($x, $y, $z); + glVertex3f($x + $length, $y, $z); + # draw line for y axis + glColor3f(0, 1, 0); + glVertex3f($x, $y, $z); + glVertex3f($x, $y + $length, $z); + # draw line for Z axis + glColor3f(0, 0, 1); + glVertex3f($x, $y, $z); + glVertex3f($x, $y, $z + $length); + glEnd(); +} + +sub draw_center_of_rotation { + my ($self, $x, $y, $z) = @_; + + $self->draw_axes($x, $y, $z, 10, 1, 1); + $self->draw_axes($x, $y, $z, 10, 4, 0); +} + sub draw_volumes { my ($self, $fakecolor) = @_; From 8738d7f5e7b7964c38479754e9bae7b23bebe6c9 Mon Sep 17 00:00:00 2001 From: uclaros Date: Wed, 2 Nov 2016 14:11:22 +0200 Subject: [PATCH 2/4] Don't select objects when the shift button pressed. This allows for easier rotating when zoomed in. --- lib/Slic3r/GUI/3DScene.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 95269cbd2f..ce158bd748 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -148,7 +148,7 @@ sub mouse_event { } elsif ($e->LeftDClick) { $self->on_double_click->() if $self->on_double_click; - } elsif ($e->LeftDown || $e->RightDown) { + } elsif (($e->LeftDown || $e->RightDown) && not $e->ShiftDown) { # If user pressed left or right button we first check whether this happened # on a volume or not. my $volume_idx = $self->_hover_volume_idx // -1; From 45922e6f5df5ee74e63c4945cd9c4224692258f8 Mon Sep 17 00:00:00 2001 From: uclaros Date: Wed, 2 Nov 2016 14:38:25 +0200 Subject: [PATCH 3/4] DoubleClick middle mouse button to zoom to extents (AutoCad style). --- lib/Slic3r/GUI/3DScene.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index ce158bd748..079008314c 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -148,6 +148,14 @@ sub mouse_event { } elsif ($e->LeftDClick) { $self->on_double_click->() if $self->on_double_click; + } elsif ($e->MiddleDClick) { + if (@{$self->volumes}) { + $self->zoom_to_volumes; + } else { + $self->zoom_to_bed; + } + $self->_dirty(1); + $self->Refresh; } elsif (($e->LeftDown || $e->RightDown) && not $e->ShiftDown) { # If user pressed left or right button we first check whether this happened # on a volume or not. From 6563a5fe9ac6a34212cdcdc9767fd209fce91a6a Mon Sep 17 00:00:00 2001 From: uclaros Date: Wed, 2 Nov 2016 15:53:09 +0200 Subject: [PATCH 4/4] Use Alt modifier to move camera center (center of rotation) up or down --- lib/Slic3r/GUI/3DScene.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 079008314c..9adf7db032 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -218,7 +218,16 @@ sub mouse_event { $self->_dragged(1); $self->Refresh; } elsif ($e->Dragging) { - if ($e->LeftIsDown) { + if ($e->AltDown) { + # Move the camera center on the Z axis based on mouse Y axis movement + if (defined $self->_drag_start_pos) { + my $orig = $self->_drag_start_pos; + $self->_camera_target->translate(0, 0, $pos->y - $orig->y); + $self->on_viewport_changed->() if $self->on_viewport_changed; + $self->Refresh; + } + $self->_drag_start_pos($pos); + } elsif ($e->LeftIsDown) { # if dragging over blank area with left button, rotate if (defined $self->_drag_start_pos) { my $orig = $self->_drag_start_pos;