From 322b9419ad84664a04abcc23218117f4df4d964b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 4 Jan 2025 19:24:18 +0100 Subject: [PATCH] API harmonization (scaled method) --- src/db/db/dbEdgePair.h | 4 ++-- src/db/db/dbPath.h | 15 ++++++++++++--- src/db/db/dbPoint.h | 8 ++++++++ src/db/db/dbPolygon.h | 30 ++++++++++++++++++++++++------ src/db/db/dbText.h | 15 ++++++++++++--- src/db/db/dbUserObject.h | 9 +++++++++ 6 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/db/db/dbEdgePair.h b/src/db/db/dbEdgePair.h index 9f4955cbf..c2dd09385 100644 --- a/src/db/db/dbEdgePair.h +++ b/src/db/db/dbEdgePair.h @@ -588,10 +588,10 @@ private: * @return The scaled edge pair */ template -inline edge_pair +inline edge_pair operator* (const edge_pair &e, double s) { - return edge_pair (e.first () * s, e.second () * s); + return edge_pair (e.first () * s, e.second () * s); } /** diff --git a/src/db/db/dbPath.h b/src/db/db/dbPath.h index 9e370a422..1638ae928 100644 --- a/src/db/db/dbPath.h +++ b/src/db/db/dbPath.h @@ -631,6 +631,16 @@ public: return res; } + /** + * @brief Returns the scaled path + */ + db::path + scaled (double s) const + { + db::complex_trans ct (s); + return this->transformed (ct); + } + /** * @brief Returns the moved path * @@ -944,11 +954,10 @@ operator* (const Tr &t, const path &p) * @return The scaled path */ template -inline path +inline path operator* (const path &p, double s) { - db::complex_trans ct (s); - return ct * p; + return p.scaled (s); } /** diff --git a/src/db/db/dbPoint.h b/src/db/db/dbPoint.h index 73ab4ef77..ec77fe405 100644 --- a/src/db/db/dbPoint.h +++ b/src/db/db/dbPoint.h @@ -159,6 +159,14 @@ public: return r; } + /** + * @brief Returns the scaled point + */ + point scaled (double s) const + { + return point (m_x * s, m_y * s); + } + /** * @brief Moved point (equivalent to add) * This alias is needed for compatibility with other shapes diff --git a/src/db/db/dbPolygon.h b/src/db/db/dbPolygon.h index 43dd5fadd..9b2ec6c08 100644 --- a/src/db/db/dbPolygon.h +++ b/src/db/db/dbPolygon.h @@ -1958,6 +1958,16 @@ public: return this->transformed_ext (t); } + /** + * @brief Returns the scaled polygon + */ + db::polygon + scaled (double s) const + { + db::complex_trans ct (s); + return this->transformed (ct); + } + /** * @brief Returns the moved polyon * @@ -2864,6 +2874,16 @@ public: return this->transformed_ext (t); } + /** + * @brief Returns the scaled polygon + */ + db::simple_polygon + scaled (double s) const + { + db::complex_trans ct (s); + return this->transformed (ct); + } + /** * @brief Returns the moved polyon * @@ -3564,11 +3584,10 @@ operator* (const Tr &t, const simple_polygon &p) * @return The scaled polygon */ template -inline polygon +inline polygon operator* (const polygon &p, double s) { - db::complex_trans ct (s); - return ct * p; + return p.scaled (s); } /** @@ -3580,11 +3599,10 @@ operator* (const polygon &p, double s) * @return The scaled polygon */ template -inline simple_polygon +inline simple_polygon operator* (const simple_polygon &p, double s) { - db::complex_trans ct (s); - return ct * p; + return p.scaled (s); } /** diff --git a/src/db/db/dbText.h b/src/db/db/dbText.h index b8902b82c..f49e664d3 100644 --- a/src/db/db/dbText.h +++ b/src/db/db/dbText.h @@ -646,6 +646,16 @@ public: } } + /** + * @brief Returns the scaled path + */ + db::text + scaled (double s) const + { + db::complex_trans ct (s); + return this->transformed (ct); + } + /** * @brief Return the moved text * @@ -964,11 +974,10 @@ operator* (const TargetTr &t, const text_ref &p) * @return The scaled text */ template -inline text +inline text operator* (const text &t, double s) { - db::complex_trans ct (s); - return ct * t; + return t.scaled (s); } /** diff --git a/src/db/db/dbUserObject.h b/src/db/db/dbUserObject.h index d2a5b21af..a52af7a35 100644 --- a/src/db/db/dbUserObject.h +++ b/src/db/db/dbUserObject.h @@ -379,6 +379,15 @@ public: return o; } + /** + * @brief Returns the scaled object + */ + db::user_object scaled (double s) const + { + db::complex_trans ct (s); + return this->transformed (ct); + } + /** * @brief Moves the object *