From 3e9a46c5bb623687e831a0dd02d0707aac7d0b5b Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sun, 12 May 2024 16:16:38 +0800 Subject: [PATCH] auto adjust grid size --- src/slic3r/GUI/PartPlate.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index df761f00ee..6c4a75f06f 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -468,7 +468,14 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox Polylines axes_lines, axes_lines_bolder; int count = 0; - for (coord_t x = pp_bbox.min(0); x <= pp_bbox.max(0); x += scale_(10.0)) { + int step = 10; + // Orca: use 500 x 500 bed size as baseline. + auto grid_counts = pp_bbox.size() / ((coord_t) scale_(step * 50)); + // if the grid is too dense, we increase the step + if (grid_counts.minCoeff() > 1) { + step = static_cast(grid_counts.minCoeff() + 1) * 10; + } + for (coord_t x = pp_bbox.min(0); x <= pp_bbox.max(0); x += scale_(step)) { Polyline line; line.append(Point(x, pp_bbox.min(1))); line.append(Point(x, pp_bbox.max(1))); @@ -480,7 +487,7 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox count ++; } count = 0; - for (coord_t y = pp_bbox.min(1); y <= pp_bbox.max(1); y += scale_(10.0)) { + for (coord_t y = pp_bbox.min(1); y <= pp_bbox.max(1); y += scale_(step)) { Polyline line; line.append(Point(pp_bbox.min(0), y)); line.append(Point(pp_bbox.max(0), y));