Fix status indication glitch for bed filling

This commit is contained in:
tamasmeszaros 2020-12-02 17:50:12 +01:00
parent 4f7f08d0de
commit 4e90df1ea5

View file

@ -55,18 +55,17 @@ void FillBedJob::prepare()
double unsel_area = std::accumulate(m_unselected.begin(),
m_unselected.end(), 0.,
[](double s, const auto &ap) {
return s + ap.poly.area();
return s + (ap.bed_idx == 0) * ap.poly.area();
}) / sc;
double fixed_area = unsel_area + m_selected.size() * poly_area;
double bed_area = Polygon{m_bedpts}.area() / sc;
// This is the maximum range, the real number will always be close but less.
double bed_area = Polygon{m_bedpts}.area() / sc;
m_status_range = (bed_area - fixed_area) / poly_area;
// This is the maximum number of items, the real number will always be close but less.
int needed_items = (bed_area - fixed_area) / poly_area;
ModelInstance *mi = model_object->instances[0];
for (int i = 0; i < m_status_range; ++i) {
for (int i = 0; i < needed_items; ++i) {
ArrangePolygon ap;
ap.poly = m_selected.front().poly;
ap.bed_idx = arrangement::UNARRANGED;
@ -77,6 +76,8 @@ void FillBedJob::prepare()
};
m_selected.emplace_back(ap);
}
m_status_range = m_selected.size();
}
void FillBedJob::process()