API harmonization (scaled method)

This commit is contained in:
Matthias Koefferlein 2025-01-04 19:24:18 +01:00
parent d036791cec
commit 322b9419ad
6 changed files with 67 additions and 14 deletions

View File

@ -588,10 +588,10 @@ private:
* @return The scaled edge pair * @return The scaled edge pair
*/ */
template <class C> template <class C>
inline edge_pair<double> inline edge_pair<db::DCoord>
operator* (const edge_pair<C> &e, double s) operator* (const edge_pair<C> &e, double s)
{ {
return edge_pair<double> (e.first () * s, e.second () * s); return edge_pair<db::DCoord> (e.first () * s, e.second () * s);
} }
/** /**

View File

@ -631,6 +631,16 @@ public:
return res; return res;
} }
/**
* @brief Returns the scaled path
*/
db::path<db::DCoord>
scaled (double s) const
{
db::complex_trans<C, db::DCoord> ct (s);
return this->transformed (ct);
}
/** /**
* @brief Returns the moved path * @brief Returns the moved path
* *
@ -944,11 +954,10 @@ operator* (const Tr &t, const path<typename Tr::coord_type> &p)
* @return The scaled path * @return The scaled path
*/ */
template <class C> template <class C>
inline path<double> inline path<db::DCoord>
operator* (const path<C> &p, double s) operator* (const path<C> &p, double s)
{ {
db::complex_trans<C, double> ct (s); return p.scaled (s);
return ct * p;
} }
/** /**

View File

@ -159,6 +159,14 @@ public:
return r; return r;
} }
/**
* @brief Returns the scaled point
*/
point<db::DCoord> scaled (double s) const
{
return point<db::DCoord> (m_x * s, m_y * s);
}
/** /**
* @brief Moved point (equivalent to add) * @brief Moved point (equivalent to add)
* This alias is needed for compatibility with other shapes * This alias is needed for compatibility with other shapes

View File

@ -1958,6 +1958,16 @@ public:
return this->transformed_ext<Tr> (t); return this->transformed_ext<Tr> (t);
} }
/**
* @brief Returns the scaled polygon
*/
db::polygon<db::DCoord>
scaled (double s) const
{
db::complex_trans<C, db::DCoord> ct (s);
return this->transformed (ct);
}
/** /**
* @brief Returns the moved polyon * @brief Returns the moved polyon
* *
@ -2864,6 +2874,16 @@ public:
return this->transformed_ext<Tr> (t); return this->transformed_ext<Tr> (t);
} }
/**
* @brief Returns the scaled polygon
*/
db::simple_polygon<db::DCoord>
scaled (double s) const
{
db::complex_trans<C, db::DCoord> ct (s);
return this->transformed (ct);
}
/** /**
* @brief Returns the moved polyon * @brief Returns the moved polyon
* *
@ -3564,11 +3584,10 @@ operator* (const Tr &t, const simple_polygon<typename Tr::coord_type> &p)
* @return The scaled polygon * @return The scaled polygon
*/ */
template <class C> template <class C>
inline polygon<double> inline polygon<db::DCoord>
operator* (const polygon<C> &p, double s) operator* (const polygon<C> &p, double s)
{ {
db::complex_trans<C, double> ct (s); return p.scaled (s);
return ct * p;
} }
/** /**
@ -3580,11 +3599,10 @@ operator* (const polygon<C> &p, double s)
* @return The scaled polygon * @return The scaled polygon
*/ */
template <class C> template <class C>
inline simple_polygon<double> inline simple_polygon<db::DCoord>
operator* (const simple_polygon<C> &p, double s) operator* (const simple_polygon<C> &p, double s)
{ {
db::complex_trans<C, double> ct (s); return p.scaled (s);
return ct * p;
} }
/** /**

View File

@ -646,6 +646,16 @@ public:
} }
} }
/**
* @brief Returns the scaled path
*/
db::text<db::DCoord>
scaled (double s) const
{
db::complex_trans<C, db::DCoord> ct (s);
return this->transformed (ct);
}
/** /**
* @brief Return the moved text * @brief Return the moved text
* *
@ -964,11 +974,10 @@ operator* (const TargetTr &t, const text_ref<Text, Tr> &p)
* @return The scaled text * @return The scaled text
*/ */
template <class C> template <class C>
inline text<double> inline text<db::DCoord>
operator* (const text<C> &t, double s) operator* (const text<C> &t, double s)
{ {
db::complex_trans<C, double> ct (s); return t.scaled (s);
return ct * t;
} }
/** /**

View File

@ -379,6 +379,15 @@ public:
return o; return o;
} }
/**
* @brief Returns the scaled object
*/
db::user_object<C> scaled (double s) const
{
db::complex_trans<C, C> ct (s);
return this->transformed (ct);
}
/** /**
* @brief Moves the object * @brief Moves the object
* *