Don't show arrange alignment combo if not on a rectangular bed

This commit is contained in:
tamasmeszaros 2023-01-25 13:27:03 +01:00
parent 0a5a401d32
commit 068134d58b
3 changed files with 11 additions and 1 deletions

View File

@ -607,6 +607,12 @@ template<class Fn> auto call_with_bed(const Points &bed, Fn &&fn)
} }
} }
bool is_box(const Points &bed)
{
return !bed.empty() &&
((1.0 - poly_area(bed) / area(BoundingBox(bed))) < 1e-3);
}
template<> template<>
void arrange(ArrangePolygons & items, void arrange(ArrangePolygons & items,
const ArrangePolygons &excludes, const ArrangePolygons &excludes,

View File

@ -143,6 +143,8 @@ inline void arrange(ArrangePolygons &items, const CircleBed &bed, const ArrangeP
inline void arrange(ArrangePolygons &items, const Polygon &bed, const ArrangeParams &params = {}) { arrange(items, {}, bed, params); } inline void arrange(ArrangePolygons &items, const Polygon &bed, const ArrangeParams &params = {}) { arrange(items, {}, bed, params); }
inline void arrange(ArrangePolygons &items, const InfiniteBed &bed, const ArrangeParams &params = {}) { arrange(items, {}, bed, params); } inline void arrange(ArrangePolygons &items, const InfiniteBed &bed, const ArrangeParams &params = {}) { arrange(items, {}, bed, params); }
bool is_box(const Points &bed);
}} // namespace Slic3r::arrangement }} // namespace Slic3r::arrangement
#endif // MODELARRANGE_HPP #endif // MODELARRANGE_HPP

View File

@ -4188,7 +4188,9 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
settings_changed = true; settings_changed = true;
} }
if (imgui->combo(_("Alignment"), {"Center", "Top left", "Bottom left", "Bottom right", "Top right", "Random"}, settings.alignment)) { Points bed = m_config ? get_bed_shape(*m_config) : Points{};
if (arrangement::is_box(bed) && imgui->combo(_("Alignment"), {"Center", "Top left", "Bottom left", "Bottom right", "Top right", "Random"}, settings.alignment)) {
settings_out.alignment = settings.alignment; settings_out.alignment = settings.alignment;
appcfg->set("arrange", align_key.c_str(), std::to_string(settings_out.alignment)); appcfg->set("arrange", align_key.c_str(), std::to_string(settings_out.alignment));
settings_changed = true; settings_changed = true;