From 11b0325c66b7851be91a5564d33b1c3928051d70 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Jul 2018 10:03:17 +0200 Subject: [PATCH 1/5] Fixed calculation of bed origin in bed shape dialog --- xs/src/slic3r/GUI/BedShapeDialog.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/xs/src/slic3r/GUI/BedShapeDialog.cpp b/xs/src/slic3r/GUI/BedShapeDialog.cpp index 3dd60ef88a..d525355897 100644 --- a/xs/src/slic3r/GUI/BedShapeDialog.cpp +++ b/xs/src/slic3r/GUI/BedShapeDialog.cpp @@ -9,6 +9,8 @@ #include "Model.hpp" #include "boost/nowide/iostream.hpp" +#include + namespace Slic3r { namespace GUI { @@ -146,21 +148,18 @@ void BedShapePanel::set_shape(ConfigOptionPoints* points) if (lines[0].parallel_to(lines[2]) && lines[1].parallel_to(lines[3])) { // okay, it's a rectangle // find origin - // the || 0 hack prevents "-0" which might confuse the user - int x_min, x_max, y_min, y_max; - x_max = x_min = points->values[0].x; + coordf_t x_min, x_max, y_min, y_max; + x_max = x_min = points->values[0].x; y_max = y_min = points->values[0].y; - for (auto pt : points->values){ - if (x_min > pt.x) x_min = pt.x; - if (x_max < pt.x) x_max = pt.x; - if (y_min > pt.y) y_min = pt.y; - if (y_max < pt.y) y_max = pt.y; - } - if (x_min < 0) x_min = 0; - if (x_max < 0) x_max = 0; - if (y_min < 0) y_min = 0; - if (y_max < 0) y_max = 0; - auto origin = new ConfigOptionPoints{ Pointf(-x_min, -y_min) }; + for (auto pt : points->values) + { + x_min = std::min(x_min, pt.x); + x_max = std::max(x_max, pt.x); + y_min = std::min(y_min, pt.y); + y_max = std::max(y_max, pt.y); + } + + auto origin = new ConfigOptionPoints{ Pointf(-x_min, -y_min) }; m_shape_options_book->SetSelection(SHAPE_RECTANGULAR); auto optgroup = m_optgroups[SHAPE_RECTANGULAR]; From 3f6d3b903d836e78047af5b3824d7a2ffb526896 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Jul 2018 10:35:08 +0200 Subject: [PATCH 2/5] Fixed rotation of 3D view camera after change of bed data --- xs/src/slic3r/GUI/GLCanvas3D.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 46bcf4f445..872ae2dc67 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -1947,6 +1947,12 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape) m_axes.origin = Pointf3(0.0, 0.0, (coordf_t)GROUND_Z); set_axes_length(0.3f * (float)m_bed.get_bounding_box().max_size()); + // forces the selection of the proper camera target + if (m_volumes.volumes.empty()) + zoom_to_bed(); + else + zoom_to_volumes(); + m_dirty = true; } From df201d65f406a23cbd85da159abbd93147640391 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Jul 2018 11:38:36 +0200 Subject: [PATCH 3/5] Minimum z of object to lay on the bed after rotations. Fixes #1093 --- xs/src/libslic3r/Model.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index d6f1f05c96..2f73cad200 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -1109,9 +1109,23 @@ void ModelObject::scale(const Pointf3 &versor) void ModelObject::rotate(float angle, const Axis &axis) { + float min_z = FLT_MAX; for (ModelVolume *v : this->volumes) + { v->mesh.rotate(angle, axis); - this->origin_translation = Pointf3(0,0,0); + min_z = std::min(min_z, v->mesh.stl.stats.min.z); + } + + if (min_z != 0.0f) + { + // translate the object so that its minimum z lays on the bed + for (ModelVolume *v : this->volumes) + { + v->mesh.translate(0.0f, 0.0f, -min_z); + } + } + + this->origin_translation = Pointf3(0, 0, 0); this->invalidate_bounding_box(); } From 09de343e6592e8f0dc1210f5cff545e37d34c23b Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Jul 2018 13:54:54 +0200 Subject: [PATCH 4/5] Fixed slice info after re-export of gcode. Fixes #1081 --- lib/Slic3r/GUI/Plater.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a5d5eaf532..5790965ffe 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1600,7 +1600,7 @@ sub print_info_box_show { my ($self, $show) = @_; my $scrolled_window_panel = $self->{scrolled_window_panel}; my $scrolled_window_sizer = $self->{scrolled_window_sizer}; - return if $scrolled_window_sizer->IsShown(2) == $show; + return if (!$show && ($scrolled_window_sizer->IsShown(2) == $show)); if ($show) { my $print_info_sizer = $self->{print_info_sizer}; @@ -1836,6 +1836,8 @@ sub update { $self->resume_background_process; } + $self->print_info_box_show(0); + # $self->{canvas}->reload_scene if $self->{canvas}; my $selections = $self->collect_selections; Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections); From 2f7876b8522c83c0d04595d48f5f5a6efb22d729 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 30 Jul 2018 13:57:05 +0200 Subject: [PATCH 5/5] Fixed camera jump after object rotate --- xs/src/slic3r/GUI/GLCanvas3D.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 872ae2dc67..f8dd94fd4b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -1941,17 +1941,22 @@ void GLCanvas3D::set_model(Model* model) void GLCanvas3D::set_bed_shape(const Pointfs& shape) { - m_bed.set_shape(shape); + bool new_shape = (shape != m_bed.get_shape()); + if (new_shape) + m_bed.set_shape(shape); // Set the origin and size for painting of the coordinate system axes. m_axes.origin = Pointf3(0.0, 0.0, (coordf_t)GROUND_Z); set_axes_length(0.3f * (float)m_bed.get_bounding_box().max_size()); - // forces the selection of the proper camera target - if (m_volumes.volumes.empty()) - zoom_to_bed(); - else - zoom_to_volumes(); + if (new_shape) + { + // forces the selection of the proper camera target + if (m_volumes.volumes.empty()) + zoom_to_bed(); + else + zoom_to_volumes(); + } m_dirty = true; }