From 9efe92acaa9c2507fb0d4d1b7dfd57c1b5af6529 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Mon, 30 Apr 2018 23:38:12 -0500 Subject: [PATCH] Added point_to_model_units() and clarified a couple comments. --- src/GUI/Plater/Plate2D.hpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/GUI/Plater/Plate2D.hpp b/src/GUI/Plater/Plate2D.hpp index 9b33c80eb..01eb01abe 100644 --- a/src/GUI/Plater/Plate2D.hpp +++ b/src/GUI/Plater/Plate2D.hpp @@ -14,7 +14,6 @@ #include "Plater/Plater2DObject.hpp" #include "misc_ui.hpp" - #include "Log.hpp" @@ -42,7 +41,7 @@ private: std::shared_ptr config; std::shared_ptr settings; - // Different brushes to draw with + // Different brushes to draw with, initialized from settings->Color during the constructor wxBrush objects_brush {}; wxBrush instance_brush {}; wxBrush selected_brush {}; @@ -76,7 +75,7 @@ private: 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 + /// For a specific point, unscale it relative to the origin wxPoint unscaled_point_to_pixel(const wxPoint& in) { const auto& canvas_height {this->GetSize().GetHeight()}; const auto& zero = this->bed_origin; @@ -103,6 +102,20 @@ private: const std::string LogChannel {"GUI_2D"}; + Slic3r::Point point_to_model_units(coordf_t x, coordf_t y) { + const auto& zero {this->bed_origin}; + return Slic3r::Point( + scale_(x - zero.x) / this->scaling_factor, + scale_(y - zero.y) / this->scaling_factor + ); + } + Slic3r::Point point_to_model_units(const wxPoint& pt) { + return this->point_to_model_units(pt.x, pt.y); + } + Slic3r::Point point_to_model_units(const Pointf& pt) { + return this->point_to_model_units(pt.x, pt.y); + } + }; } } // Namespace Slic3r::GUI