From e3ca95152c7754f6700d06eee2100bf71a432d29 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 18 Jul 2019 16:30:32 +0200 Subject: [PATCH] Minor refactor --- src/libslic3r/Arrange.hpp | 5 ++++- src/slic3r/GUI/Plater.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/Arrange.hpp b/src/libslic3r/Arrange.hpp index 3391eb0d7..c02393dd9 100644 --- a/src/libslic3r/Arrange.hpp +++ b/src/libslic3r/Arrange.hpp @@ -127,7 +127,7 @@ public: }; /// A logical bed representing an object not being arranged. Either the arrange -/// has not yet succesfully run on this ArrangePolygon or it could not fit the +/// has not yet successfully run on this ArrangePolygon or it could not fit the /// object due to overly large size or invalid geometry. static const constexpr int UNARRANGED = -1; @@ -152,6 +152,9 @@ struct ArrangePolygon { /// Helper function to call the setter with the arrange data arguments void apply() const { if (setter) setter(*this); } + + /// Test if arrange() was called previously and gave a successful result. + bool is_arranged() const { return bed_idx != UNARRANGED; } }; using ArrangePolygons = std::vector; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 0c7a8a3ee..d4697e7b3 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1345,7 +1345,6 @@ struct Plater::priv // Cache the wti info class WipeTower: public GLCanvas3D::WipeTowerInfo { using ArrangePolygon = arrangement::ArrangePolygon; - static const constexpr auto UNARRANGED = arrangement::UNARRANGED; friend priv; public: @@ -1535,7 +1534,6 @@ struct Plater::priv // The gap between logical beds in the x axis expressed in ratio of // the current bed width. static const constexpr double LOGICAL_BED_GAP = 1. / 5.; - static const constexpr int UNARRANGED = arrangement::UNARRANGED; ArrangePolygons m_selected, m_unselected; @@ -1578,7 +1576,7 @@ struct Plater::priv ap.bed_idx = ap.translation.x() / stride; ap.setter = [mi, stride](const ArrangePolygon &p) { - if (p.bed_idx != UNARRANGED) { + if (p.is_arranged()) { auto t = p.translation; t.x() += p.bed_idx * stride; mi->apply_arrange_result(t, p.rotation); } @@ -1596,8 +1594,10 @@ struct Plater::priv ap.bed_idx = ap.translation.x() / stride; ap.priority = 1; // Wipe tower should be on physical bed ap.setter = [&wti, stride](const ArrangePolygon &p) { - auto t = p.translation; t.x() += p.bed_idx * stride; - wti.apply_arrange_result(t, p.rotation); + if (p.is_arranged()) { + auto t = p.translation; t.x() += p.bed_idx * stride; + wti.apply_arrange_result(t, p.rotation); + } }; sel.is_wipe_tower() ?