Fix: Grid size calculation wrong on large scale (#9500)

* Update PartPlate.cpp

* Update PartPlate.cpp

* add descriptions

* simplify calculations
This commit is contained in:
yw4z 2025-04-28 10:17:47 +03:00 committed by GitHub
parent 5bf1596d65
commit 84d3bd2b48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -468,13 +468,16 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox
Polylines axes_lines, axes_lines_bolder; Polylines axes_lines, axes_lines_bolder;
int count = 0; int count = 0;
int step = 10; int step = 10; // Uses up to 599mm Main Grid: 10 x 5 = 50mm
// Orca: use 500 x 500 bed size as baseline. // Orca: use 500 x 500 bed size as baseline.
const Point grid_counts = pp_bbox.size() / ((coord_t) scale_(step * 50));
// if the grid is too dense, we increase the step // if the grid is too dense, we increase the step
if (grid_counts.minCoeff() > 1) { auto min_edge_scaled = (pp_bbox.size() / ((coord_t) scale_(1))).minCoeff();
step = static_cast<int>(grid_counts.minCoeff() + 1) * 10; if ( min_edge_scaled >= 6000) // Switch when short edge >= 6000mm Main Grid: 100 x 5 = 500mm
} step = 100;
else if (min_edge_scaled >= 1200) // Switch when short edge >= 1200mm Main Grid: 50 x 5 = 250mm
step = 50;
else if (min_edge_scaled >= 600) // Switch when short edge >= 600mm Main Grid: 20 x 5 = 100mm
step = 20;
// ORCA draw grid lines relative to origin // ORCA draw grid lines relative to origin
for (coord_t x = scale_(m_origin.x()); x >= pp_bbox.min(0); x -= scale_(step)) { // Negative X axis for (coord_t x = scale_(m_origin.x()); x >= pp_bbox.min(0); x -= scale_(step)) { // Negative X axis