Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix grid lines not aligned to origin #8767

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/slic3r/GUI/PartPlate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox
if (grid_counts.minCoeff() > 1) {
step = static_cast<int>(grid_counts.minCoeff() + 1) * 10;
}

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)));
Expand All @@ -499,6 +501,41 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox
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)));
Expand Down
Loading