From 8027f6608a12b544293ac45533321aba8084b0ba Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 1 Dec 2020 14:07:34 +0100 Subject: [PATCH] Fix arrange distance with enabled sequential printing fixes #5258 --- src/slic3r/GUI/GLCanvas3D.cpp | 23 ++++++++++++++++++----- src/slic3r/GUI/GLCanvas3D.hpp | 7 ++++--- src/slic3r/GUI/Jobs/ArrangeJob.cpp | 7 +++++-- src/slic3r/GUI/Jobs/FillBedJob.cpp | 4 +++- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index c1ae73776..4e0eb1042 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1102,12 +1102,18 @@ static GLCanvas3D::ArrangeSettings load_arrange_settings() std::string dist_str = wxGetApp().app_config->get("arrange", "min_object_distance"); + std::string dist_seq_print_str = + wxGetApp().app_config->get("arrange", "min_object_distance_seq_print"); + std::string en_rot_str = wxGetApp().app_config->get("arrange", "enable_rotation"); if (!dist_str.empty()) settings.distance = std::stof(dist_str); + if (!dist_seq_print_str.empty()) + settings.distance_seq_print = std::stof(dist_seq_print_str); + if (!en_rot_str.empty()) settings.enable_rotation = (en_rot_str == "1" || en_rot_str == "yes"); @@ -3907,15 +3913,21 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) auto &appcfg = wxGetApp().app_config; bool settings_changed = false; + bool is_seq_print = m_config->opt_bool("complete_objects"); + + imgui->text(_L("Use CTRL+left mouse key to enter text edit mode:")); + + float &dist_val = is_seq_print ? settings.distance_seq_print : settings.distance; + float dist_min = is_seq_print ? float(min_object_distance(*m_config)) : 0.f; + dist_val = std::max(dist_min, dist_val); + + if (imgui->slider_float(_L("Clearance size"), &dist_val, dist_min, 100.0f, "%5.2f")) { + is_seq_print ? m_arrange_settings.distance_seq_print = dist_val : + m_arrange_settings.distance = dist_val; - if (ImGui::DragFloat(_L("Gal size").ToUTF8().data(), &settings.distance, .01f, 0.0f, 100.0f, "%5.2f")) { - m_arrange_settings.distance = settings.distance; settings_changed = true; } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("%s", _L("Use CTRL+Left mouse button to enter text edit mode.\nUse SHIFT key to increase stepping.").ToUTF8().data()); - if (imgui->checkbox(_L("Enable rotations (slow)"), settings.enable_rotation)) { m_arrange_settings.enable_rotation = settings.enable_rotation; settings_changed = true; @@ -3930,6 +3942,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) if (settings_changed) { appcfg->set("arrange", "min_object_distance", std::to_string(m_arrange_settings.distance)); + appcfg->set("arrange", "min_object_distance_seq_print", std::to_string(m_arrange_settings.distance_seq_print)); appcfg->set("arrange", "enable_rotation", m_arrange_settings.enable_rotation? "1" : "0"); } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index a40f1b98d..efa1dfed7 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -387,9 +387,10 @@ public: struct ArrangeSettings { - float distance = 6.; - float accuracy = 0.65f; - bool enable_rotation = false; + float distance = 6.; + float distance_seq_print = 6.; // Used when sequential print is ON + float accuracy = 0.65f; // Unused currently + bool enable_rotation = false; }; private: diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index 7a8c21365..8d28d0a7c 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -147,10 +147,13 @@ void ArrangeJob::process() GLCanvas3D::ArrangeSettings settings = m_plater->canvas3D()->get_arrange_settings(); - + arrangement::ArrangeParams params; - params.min_obj_distance = scaled(settings.distance); params.allow_rotations = settings.enable_rotation; + params.min_obj_distance = m_plater->config()->opt_bool("complete_objects") ? + scaled(settings.distance_seq_print) : + scaled(settings.distance); + auto count = unsigned(m_selected.size() + m_unprintable.size()); Points bedpts = get_bed_shape(*m_plater->config()); diff --git a/src/slic3r/GUI/Jobs/FillBedJob.cpp b/src/slic3r/GUI/Jobs/FillBedJob.cpp index c34cc00c4..533fe64da 100644 --- a/src/slic3r/GUI/Jobs/FillBedJob.cpp +++ b/src/slic3r/GUI/Jobs/FillBedJob.cpp @@ -87,8 +87,10 @@ void FillBedJob::process() m_plater->canvas3D()->get_arrange_settings(); arrangement::ArrangeParams params; - params.min_obj_distance = scaled(settings.distance); params.allow_rotations = settings.enable_rotation; + params.min_obj_distance = m_plater->config()->opt_bool("complete_objects") ? + scaled(settings.distance_seq_print) : + scaled(settings.distance); bool do_stop = false; params.stopcondition = [this, &do_stop]() {