Fix arrange distance with enabled sequential printing

fixes #5258
This commit is contained in:
tamasmeszaros 2020-12-01 14:07:34 +01:00
parent 27243c0785
commit 8027f6608a
4 changed files with 30 additions and 11 deletions

View File

@ -1102,12 +1102,18 @@ static GLCanvas3D::ArrangeSettings load_arrange_settings()
std::string dist_str = std::string dist_str =
wxGetApp().app_config->get("arrange", "min_object_distance"); 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 = std::string en_rot_str =
wxGetApp().app_config->get("arrange", "enable_rotation"); wxGetApp().app_config->get("arrange", "enable_rotation");
if (!dist_str.empty()) if (!dist_str.empty())
settings.distance = std::stof(dist_str); 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()) if (!en_rot_str.empty())
settings.enable_rotation = (en_rot_str == "1" || en_rot_str == "yes"); 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; auto &appcfg = wxGetApp().app_config;
bool settings_changed = false; 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; 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)) { if (imgui->checkbox(_L("Enable rotations (slow)"), settings.enable_rotation)) {
m_arrange_settings.enable_rotation = settings.enable_rotation; m_arrange_settings.enable_rotation = settings.enable_rotation;
settings_changed = true; settings_changed = true;
@ -3930,6 +3942,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
if (settings_changed) { if (settings_changed) {
appcfg->set("arrange", "min_object_distance", std::to_string(m_arrange_settings.distance)); 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"); appcfg->set("arrange", "enable_rotation", m_arrange_settings.enable_rotation? "1" : "0");
} }

View File

@ -388,7 +388,8 @@ public:
struct ArrangeSettings struct ArrangeSettings
{ {
float distance = 6.; float distance = 6.;
float accuracy = 0.65f; float distance_seq_print = 6.; // Used when sequential print is ON
float accuracy = 0.65f; // Unused currently
bool enable_rotation = false; bool enable_rotation = false;
}; };

View File

@ -149,8 +149,11 @@ void ArrangeJob::process()
m_plater->canvas3D()->get_arrange_settings(); m_plater->canvas3D()->get_arrange_settings();
arrangement::ArrangeParams params; arrangement::ArrangeParams params;
params.min_obj_distance = scaled(settings.distance);
params.allow_rotations = settings.enable_rotation; 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()); auto count = unsigned(m_selected.size() + m_unprintable.size());
Points bedpts = get_bed_shape(*m_plater->config()); Points bedpts = get_bed_shape(*m_plater->config());

View File

@ -87,8 +87,10 @@ void FillBedJob::process()
m_plater->canvas3D()->get_arrange_settings(); m_plater->canvas3D()->get_arrange_settings();
arrangement::ArrangeParams params; arrangement::ArrangeParams params;
params.min_obj_distance = scaled(settings.distance);
params.allow_rotations = settings.enable_rotation; 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; bool do_stop = false;
params.stopcondition = [this, &do_stop]() { params.stopcondition = [this, &do_stop]() {