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
*/
template <class C>
inline edge_pair<double>
inline edge_pair<db::DCoord>
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;
}
/**
* @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
*
@ -944,11 +954,10 @@ operator* (const Tr &t, const path<typename Tr::coord_type> &p)
* @return The scaled path
*/
template <class C>
inline path<double>
inline path<db::DCoord>
operator* (const path<C> &p, double s)
{
db::complex_trans<C, double> ct (s);
return ct * p;
return p.scaled (s);
}
/**

View File

@ -159,6 +159,14 @@ public:
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)
* This alias is needed for compatibility with other shapes

View File

@ -1958,6 +1958,16 @@ public:
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
*
@ -2864,6 +2874,16 @@ public:
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
*
@ -3564,11 +3584,10 @@ operator* (const Tr &t, const simple_polygon<typename Tr::coord_type> &p)
* @return The scaled polygon
*/
template <class C>
inline polygon<double>
inline polygon<db::DCoord>
operator* (const polygon<C> &p, double s)
{
db::complex_trans<C, double> ct (s);
return ct * p;
return p.scaled (s);
}
/**
@ -3580,11 +3599,10 @@ operator* (const polygon<C> &p, double s)
* @return The scaled polygon
*/
template <class C>
inline simple_polygon<double>
inline simple_polygon<db::DCoord>
operator* (const simple_polygon<C> &p, double s)
{
db::complex_trans<C, double> ct (s);
return ct * p;
return p.scaled (s);
}
/**

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
*
@ -964,11 +974,10 @@ operator* (const TargetTr &t, const text_ref<Text, Tr> &p)
* @return The scaled text
*/
template <class C>
inline text<double>
inline text<db::DCoord>
operator* (const text<C> &t, double s)
{
db::complex_trans<C, double> ct (s);
return ct * t;
return t.scaled (s);
}
/**

View File

@ -379,6 +379,15 @@ public:
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
*