From 68ad0d14c9c3a2042f396e6cc28f7af403f1b769 Mon Sep 17 00:00:00 2001 From: yw4z Date: Sat, 8 Mar 2025 17:07:40 +0300 Subject: [PATCH 1/2] fix --- src/slic3r/GUI/PartPlate.cpp | 83 ++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index e5f2a190f02..23528f36551 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -475,30 +475,67 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox 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))); - if ( (count % 5) == 0 ) - axes_lines_bolder.push_back(line); - else - axes_lines.push_back(line); - count ++; - } - count = 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)); - axes_lines.push_back(line); - - if ( (count % 5) == 0 ) - axes_lines_bolder.push_back(line); - else - axes_lines.push_back(line); - count ++; - } + if (0) { + 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))); + + if ((count % 5) == 0) + axes_lines_bolder.push_back(line); + else + axes_lines.push_back(line); + count++; + } + count = 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)); + axes_lines.push_back(line); + + if ((count % 5) == 0) + axes_lines_bolder.push_back(line); + else + axes_lines.push_back(line); + count++; + } + } + + // ORCA draw grid lines relative to origin + for (coord_t x = m_origin.x(); x >= pp_bbox.min(0); x -= scale_(step)) { // Negative X axis + ((count % 5) == 0 ? axes_lines_bolder : axes_lines).push_back(Polyline( + Point(x, pp_bbox.min(1)), + Point(x, pp_bbox.max(1)) + )); + count ++; + } + count = 0; + for (coord_t x = m_origin.x(); x <= pp_bbox.max(0); x += scale_(step)) { // Positive X axis + ((count % 5) == 0 ? axes_lines_bolder : axes_lines).push_back(Polyline( + Point(x, pp_bbox.min(1)), + Point(x, pp_bbox.max(1)) + )); + count ++; + } + count = 0; + for (coord_t y = m_origin.x(); y >= pp_bbox.min(1); y -= scale_(step)) { // Negative Y axis + ((count % 5) == 0 ? axes_lines_bolder : axes_lines).push_back(Polyline( + Point(pp_bbox.min(0), y), + Point(pp_bbox.max(0), y) + )); + count ++; + } + count = 0; + for (coord_t y = m_origin.x(); y <= pp_bbox.max(1); y += scale_(step)) { // Positive Y axis + ((count % 5) == 0 ? axes_lines_bolder : axes_lines).push_back(Polyline( + Point(pp_bbox.min(0), y), + Point(pp_bbox.max(0), y) + )); + count ++; + } + count = 0; // clip with a slightly grown expolygon because our lines lay on the contours and may get erroneously clipped Lines gridlines = to_lines(intersection_pl(axes_lines, offset(poly, (float)SCALED_EPSILON))); From 0918fe4408a1c23331f591893e036d2e3379ab67 Mon Sep 17 00:00:00 2001 From: yw4z Date: Sat, 8 Mar 2025 21:36:07 +0300 Subject: [PATCH 2/2] Update PartPlate.cpp --- src/slic3r/GUI/PartPlate.cpp | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 23528f36551..343e5d70c2b 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -477,30 +477,30 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox } if (0) { - 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))); + 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))); - if ((count % 5) == 0) - axes_lines_bolder.push_back(line); - else - axes_lines.push_back(line); - count++; - } - count = 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)); - axes_lines.push_back(line); - - if ((count % 5) == 0) - axes_lines_bolder.push_back(line); - else - axes_lines.push_back(line); - count++; - } + if ( (count % 5) == 0 ) + axes_lines_bolder.push_back(line); + else + axes_lines.push_back(line); + count ++; + } + count = 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)); + axes_lines.push_back(line); + + if ( (count % 5) == 0 ) + axes_lines_bolder.push_back(line); + else + axes_lines.push_back(line); + count ++; + } } // ORCA draw grid lines relative to origin