From aef1bf7f37c83343e941333d9c7e130e90a110ce Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Mon, 30 Apr 2018 22:17:42 -0500 Subject: [PATCH] Ported scaled_points_to_pixel, made Polygon and Polylines versions. --- src/GUI/Plater/Plate2D.cpp | 10 ++++++++++ src/GUI/Plater/Plate2D.hpp | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/GUI/Plater/Plate2D.cpp b/src/GUI/Plater/Plate2D.cpp index e9a906c22..3791b10b8 100644 --- a/src/GUI/Plater/Plate2D.cpp +++ b/src/GUI/Plater/Plate2D.cpp @@ -157,6 +157,16 @@ void Plate2D::update_bed_size() { assert(this->scaling_factor != 0); +std::vector Plate2D::scaled_points_to_pixel(const Slic3r::Polygon& poly, bool unscale) { + return this->scaled_points_to_pixel(Polyline(poly), unscale); } +std::vector Plate2D::scaled_points_to_pixel(const Slic3r::Polyline& poly, bool unscale) { + std::vector result; + for (const auto& pt : poly.points) { + const auto tmp {wxPoint(pt.x, pt.y)}; + result.push_back( (unscale ? unscaled_point_to_pixel(tmp) : tmp) ); + } + return result; +} } } // Namespace Slic3r::GUI diff --git a/src/GUI/Plater/Plate2D.hpp b/src/GUI/Plater/Plate2D.hpp index 5bd57e75f..6c7ab3dc8 100644 --- a/src/GUI/Plater/Plate2D.hpp +++ b/src/GUI/Plater/Plate2D.hpp @@ -66,7 +66,8 @@ private: void set_colors(); /// Convert a scale point array to a pixel polygon suitable for DrawPolygon - std::vector scaled_points_to_pixel(std::vector points, bool unscale); + std::vector scaled_points_to_pixel(const Slic3r::Polygon& poly, bool unscale); + std::vector scaled_points_to_pixel(const Slic3r::Polyline& poly, bool unscale); // For a specific point, unscaled it wxPoint unscaled_point_to_pixel(const wxPoint& in) {