From d7edc08287fb00cde3ca0d29d5101c950e048b20 Mon Sep 17 00:00:00 2001 From: uclaros Date: Wed, 2 Nov 2016 14:05:36 +0200 Subject: [PATCH] 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 a36d2263c..95269cbd2 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) = @_;