Actually unscale instead of doing silly things.

This commit is contained in:
Joseph Lenox 2018-05-07 21:26:07 -05:00 committed by Joseph Lenox
parent bb9ce8dd6f
commit e880d9d3ee
2 changed files with 11 additions and 9 deletions

View File

@ -286,15 +286,22 @@ std::vector<wxPoint> Plate2D::scaled_points_to_pixel(const Slic3r::Polygon& poly
return this->scaled_points_to_pixel(Polyline(poly), unscale); return this->scaled_points_to_pixel(Polyline(poly), unscale);
} }
std::vector<wxPoint> Plate2D::scaled_points_to_pixel(const Slic3r::Polyline& poly, bool unscale) { std::vector<wxPoint> Plate2D::scaled_points_to_pixel(const Slic3r::Polyline& poly, bool _unscale) {
std::vector<wxPoint> result; std::vector<wxPoint> result;
for (const auto& pt : poly.points) { for (const auto& pt : poly.points) {
const auto tmp {wxPoint(pt.x, pt.y)}; const auto x {_unscale ? Slic3r::unscale(pt.x) : pt.x};
result.push_back( (unscale ? unscaled_point_to_pixel(tmp) : tmp) ); const auto y {_unscale ? Slic3r::unscale(pt.y) : pt.y};
result.push_back(wxPoint(x, y));
} }
return result; return result;
} }
wxPoint Plate2D::unscaled_point_to_pixel(const wxPoint& in) {
const auto& canvas_height {this->GetSize().GetHeight()};
const auto& zero = this->bed_origin;
return wxPoint(in.x * this->scaling_factor + zero.x,
in.y * this->scaling_factor + (zero.y - canvas_height));
}
} } // Namespace Slic3r::GUI } } // Namespace Slic3r::GUI

View File

@ -79,12 +79,7 @@ private:
std::vector<wxPoint> scaled_points_to_pixel(const Slic3r::Polyline& poly, bool unscale); std::vector<wxPoint> scaled_points_to_pixel(const Slic3r::Polyline& poly, bool unscale);
/// For a specific point, unscale it relative to the origin /// For a specific point, unscale it relative to the origin
wxPoint unscaled_point_to_pixel(const wxPoint& in) { wxPoint unscaled_point_to_pixel(const wxPoint& in);
const auto& canvas_height {this->GetSize().GetHeight()};
const auto& zero = this->bed_origin;
return wxPoint(in.x * this->scaling_factor + zero.x,
in.y * this->scaling_factor + (zero.y - canvas_height));
}
/// Read print bed size from config and calculate the scaled rendition of the bed given the draw canvas. /// Read print bed size from config and calculate the scaled rendition of the bed given the draw canvas.
void update_bed_size(); void update_bed_size();