From 2c9b41623a3d003134501fa66bfe9c1947ca2db4 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 16 Aug 2018 13:22:02 +0200 Subject: [PATCH 1/5] Fixed wipe tower loosing selection after displacement --- xs/src/slic3r/GUI/GLCanvas3D.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 92bde34ce7..f5122539e3 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -3017,6 +3017,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } _on_move(volume_idxs); + + // force re-selection of the wipe tower, if needed + if ((volume_idxs.size() == 1) && m_volumes.volumes[volume_idxs[0]]->is_wipe_tower) + select_volume(volume_idxs[0]); } else if (!m_mouse.dragging && (m_hover_volume_id == -1) && !gizmos_overlay_contains_mouse && !m_gizmos.is_dragging() && !is_layers_editing_enabled()) { From d38816bd9c32badaf2f2946f0bfe395c4632858c Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 16 Aug 2018 13:35:56 +0200 Subject: [PATCH 2/5] GLVolume use a pointer to ModelVolume's convex hull instead of a copy of it --- xs/src/slic3r/GUI/3DScene.cpp | 8 ++++---- xs/src/slic3r/GUI/3DScene.hpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 0709271b8c..171f4dbe85 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -204,6 +204,7 @@ GLVolume::GLVolume(float r, float g, float b, float a) , m_scale_factor(1.0f) , m_transformed_bounding_box_dirty(true) , m_transformed_convex_hull_bounding_box_dirty(true) + , m_convex_hull(nullptr) , composite_id(-1) , select_group_id(-1) , drag_group_id(-1) @@ -293,7 +294,7 @@ void GLVolume::set_scale_factor(float scale_factor) void GLVolume::set_convex_hull(const TriangleMesh& convex_hull) { - m_convex_hull = convex_hull; + m_convex_hull = &convex_hull; } std::vector GLVolume::world_matrix() const @@ -322,8 +323,8 @@ BoundingBoxf3 GLVolume::transformed_convex_hull_bounding_box() const { if (m_transformed_convex_hull_bounding_box_dirty) { - if (m_convex_hull.stl.stats.number_of_facets > 0) - m_transformed_convex_hull_bounding_box = m_convex_hull.transformed_bounding_box(world_matrix()); + if ((m_convex_hull != nullptr) && (m_convex_hull->stl.stats.number_of_facets > 0)) + m_transformed_convex_hull_bounding_box = m_convex_hull->transformed_bounding_box(world_matrix()); else m_transformed_convex_hull_bounding_box = bounding_box.transformed(world_matrix()); @@ -747,7 +748,6 @@ int GLVolumeCollection::load_wipe_tower_preview( v.drag_group_id = obj_idx * 1000; v.is_wipe_tower = true; v.shader_outside_printer_detection_enabled = ! size_unknown; - v.set_convex_hull(mesh.convex_hull_3d()); return int(this->volumes.size() - 1); } diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 1265bc20de..5cd144c680 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -264,8 +264,8 @@ private: mutable BoundingBoxf3 m_transformed_bounding_box; // Whether or not is needed to recalculate the transformed bounding box. mutable bool m_transformed_bounding_box_dirty; - // Convex hull of the original mesh, if any. - TriangleMesh m_convex_hull; + // Pointer to convex hull of the original mesh, if any. + const TriangleMesh* m_convex_hull; // Bounding box of this volume, in unscaled coordinates. mutable BoundingBoxf3 m_transformed_convex_hull_bounding_box; // Whether or not is needed to recalculate the transformed convex hull bounding box. From 1fff2252bce88b4a7099f6347d7b264ecb793571 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 16 Aug 2018 13:42:35 +0200 Subject: [PATCH 3/5] Detection of out of print volume disabled for wipe tower of unknown size --- xs/src/slic3r/GUI/3DScene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 171f4dbe85..7053470943 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -833,7 +833,7 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M for (GLVolume* volume : this->volumes) { - if ((volume != nullptr) && !volume->is_modifier) + if ((volume != nullptr) && !volume->is_modifier && (!volume->is_wipe_tower || (volume->is_wipe_tower && volume->shader_outside_printer_detection_enabled))) { const BoundingBoxf3& bb = volume->transformed_convex_hull_bounding_box(); bool contained = print_volume.contains(bb); From b6e0458201128b5db4db5faaeb41d307e395edd6 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 17 Aug 2018 09:16:34 +0200 Subject: [PATCH 4/5] Fixed lost selection of imported objects --- lib/Slic3r/GUI/Plater.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index a0eef72fea..4fd9a2692a 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1291,7 +1291,9 @@ sub async_apply_config { # We also need to reload 3D scene because of the wipe tower preview box if ($self->{config}->wipe_tower) { - Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 1) if $self->{canvas3D} + my $selections = $self->collect_selections; + Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections); + Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 1) if $self->{canvas3D} } } } @@ -1507,6 +1509,8 @@ sub on_process_completed { $self->{preview3D}->reload_print if $self->{preview3D}; # in case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth: + my $selections = $self->collect_selections; + Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections); Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 1); # if we have an export filename, start a new thread for exporting G-code From 048f3a03fe884566b2ec290164e46ca3fce39b28 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 17 Aug 2018 10:12:43 +0200 Subject: [PATCH 5/5] Fixed scale to size of objects with multiple instances --- lib/Slic3r/GUI/Plater.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 4fd9a2692a..b4677b1af6 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1126,8 +1126,7 @@ sub changescale { my $model_object = $self->{model}->objects->[$obj_idx]; my $model_instance = $model_object->instances->[0]; - my $object_size = $model_object->bounding_box->size; - my $bed_size = Slic3r::Polygon->new_scale(@{$self->{config}->bed_shape})->bounding_box->size; + my $object_size = $model_object->instance_bounding_box(0)->size; if (defined $axis) { my $axis_name = $axis == X ? 'X' : $axis == Y ? 'Y' : 'Z'; @@ -1135,7 +1134,7 @@ sub changescale { if ($tosize) { my $cursize = $object_size->[$axis]; my $newsize = $self->_get_number_from_user( - sprintf(L('Enter the new size for the selected object (print bed: %smm):'), unscale($bed_size->[$axis])), + L('Enter the new size for the selected object:'), L("Scale along ").$axis_name, L('Invalid scaling value entered'), $cursize, 1); return if $newsize eq ''; $scale = $newsize / $cursize * 100;