Minor refactor

This commit is contained in:
tamasmeszaros 2019-07-18 16:30:32 +02:00
parent 6b8c72944d
commit e3ca95152c
2 changed files with 9 additions and 6 deletions

View file

@ -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<ArrangePolygon>;

View file

@ -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() ?