Skip to content

Commit

Permalink
Add arrange parameter to set min distance from bed
Browse files Browse the repository at this point in the history
implements FR prusa3d#8442
  • Loading branch information
tamasmeszaros committed Sep 12, 2022
1 parent 819c42e commit 2c64312
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,12 +1111,21 @@ void GLCanvas3D::load_arrange_settings()
std::string dist_fff_str =
wxGetApp().app_config->get("arrange", "min_object_distance_fff");

std::string dist_bed_fff_str =
wxGetApp().app_config->get("arrange", "min_bed_distance_fff");

std::string dist_fff_seq_print_str =
wxGetApp().app_config->get("arrange", "min_object_distance_fff_seq_print");

std::string dist_bed_fff_seq_print_str =
wxGetApp().app_config->get("arrange", "min_bed_distance_fff_seq_print");

std::string dist_sla_str =
wxGetApp().app_config->get("arrange", "min_object_distance_sla");

std::string dist_bed_sla_str =
wxGetApp().app_config->get("arrange", "min_bed_distance_sla");

std::string en_rot_fff_str =
wxGetApp().app_config->get("arrange", "enable_rotation_fff");

Expand All @@ -1129,12 +1138,21 @@ void GLCanvas3D::load_arrange_settings()
if (!dist_fff_str.empty())
m_arrange_settings_fff.distance = string_to_float_decimal_point(dist_fff_str);

if (!dist_bed_fff_str.empty())
m_arrange_settings_fff.distance_from_bed = string_to_float_decimal_point(dist_bed_fff_str);

if (!dist_fff_seq_print_str.empty())
m_arrange_settings_fff_seq_print.distance = string_to_float_decimal_point(dist_fff_seq_print_str);

if (!dist_bed_fff_seq_print_str.empty())
m_arrange_settings_fff_seq_print.distance_from_bed = string_to_float_decimal_point(dist_bed_fff_seq_print_str);

if (!dist_sla_str.empty())
m_arrange_settings_sla.distance = string_to_float_decimal_point(dist_sla_str);

if (!dist_bed_sla_str.empty())
m_arrange_settings_sla.distance_from_bed = string_to_float_decimal_point(dist_bed_sla_str);

if (!en_rot_fff_str.empty())
m_arrange_settings_fff.enable_rotation = (en_rot_fff_str == "1" || en_rot_fff_str == "yes");

Expand Down Expand Up @@ -4525,11 +4543,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)

bool settings_changed = false;
float dist_min = 0.f;
std::string dist_key = "min_object_distance", rot_key = "enable_rotation";
float dist_bed_min = 0.f;
std::string dist_key = "min_object_distance";
std::string dist_bed_key = "min_bed_distance";
std::string rot_key = "enable_rotation";
std::string postfix;

if (ptech == ptSLA) {
dist_min = 0.f;
postfix = "_sla";
} else if (ptech == ptFFF) {
auto co_opt = m_config->option<ConfigOptionBool>("complete_objects");
Expand All @@ -4543,7 +4563,8 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
}

dist_key += postfix;
rot_key += postfix;
dist_bed_key += postfix;
rot_key += postfix;

imgui->text(GUI::format_wxstr(_L("Press %1%left mouse button to enter the exact value"), shortkey_ctrl_prefix()));

Expand All @@ -4554,6 +4575,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
settings_changed = true;
}

if (imgui->slider_float(_L("Spacing from bed"), &settings.distance_from_bed, dist_bed_min, 100.0f, "%5.2f") || dist_bed_min > settings.distance_from_bed) {
settings.distance_from_bed = std::max(dist_bed_min, settings.distance_from_bed);
settings_out.distance_from_bed = settings.distance_from_bed;
appcfg->set("arrange", dist_bed_key.c_str(), float_to_string_decimal_point(settings_out.distance_from_bed));
settings_changed = true;
}

if (imgui->checkbox(_L("Enable rotations (slow)"), settings.enable_rotation)) {
settings_out.enable_rotation = settings.enable_rotation;
appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0");
Expand All @@ -4566,6 +4594,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
settings_out = ArrangeSettings{};
settings_out.distance = std::max(dist_min, settings_out.distance);
appcfg->set("arrange", dist_key.c_str(), float_to_string_decimal_point(settings_out.distance));
appcfg->set("arrange", dist_bed_key.c_str(), float_to_string_decimal_point(settings_out.distance_from_bed));
appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0");
settings_changed = true;
}
Expand Down

0 comments on commit 2c64312

Please sign in to comment.