summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basegfx/source/point/b2dpoint.cxx7
-rw-r--r--basegfx/source/vector/b2dvector.cxx7
-rw-r--r--include/basegfx/point/b2dpoint.hxx9
-rw-r--r--include/basegfx/tuple/Tuple2D.hxx48
-rw-r--r--include/basegfx/tuple/b2dtuple.hxx32
-rw-r--r--include/basegfx/vector/b2dvector.hxx11
6 files changed, 59 insertions, 55 deletions
diff --git a/basegfx/source/point/b2dpoint.cxx b/basegfx/source/point/b2dpoint.cxx
index 0dc18b513db1..02e6711ac44c 100644
--- a/basegfx/source/point/b2dpoint.cxx
+++ b/basegfx/source/point/b2dpoint.cxx
@@ -23,13 +23,6 @@
namespace basegfx
{
- B2DPoint& B2DPoint::operator=( const ::basegfx::B2DTuple& rPoint )
- {
- mfX = rPoint.getX();
- mfY = rPoint.getY();
- return *this;
- }
-
B2DPoint& B2DPoint::operator*=( const ::basegfx::B2DHomMatrix& rMat )
{
double fTempX(
diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx
index 1ad51a9b5a4c..d0fcebb62eac 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -51,13 +51,6 @@ namespace basegfx
return *this;
}
- B2DVector& B2DVector::operator=( const B2DTuple& rVec )
- {
- mfX = rVec.getX();
- mfY = rVec.getY();
- return *this;
- }
-
double B2DVector::getLength() const
{
if(fTools::equalZero(mfX))
diff --git a/include/basegfx/point/b2dpoint.hxx b/include/basegfx/point/b2dpoint.hxx
index d2f77aa493a3..3bd6af90af9c 100644
--- a/include/basegfx/point/b2dpoint.hxx
+++ b/include/basegfx/point/b2dpoint.hxx
@@ -73,7 +73,7 @@ namespace basegfx
/** constructor with tuple to allow copy-constructing
from B2DTuple-based classes
*/
- B2DPoint(const ::basegfx::B2DTuple& rTuple)
+ B2DPoint(Tuple2D<double> const& rTuple)
: B2DTuple(rTuple)
{}
@@ -98,7 +98,12 @@ namespace basegfx
/** assignment operator to allow assigning the results
of B2DTuple calculations
*/
- BASEGFX_DLLPUBLIC B2DPoint& operator=( const ::basegfx::B2DTuple& rPoint );
+ BASEGFX_DLLPUBLIC B2DPoint& operator=(Tuple2D<double>& rPoint)
+ {
+ mfX = rPoint.getX();
+ mfY = rPoint.getY();
+ return *this;
+ }
/** Transform point by given transformation matrix.
diff --git a/include/basegfx/tuple/Tuple2D.hxx b/include/basegfx/tuple/Tuple2D.hxx
index 44d546df6a30..8bc53fe9b88d 100644
--- a/include/basegfx/tuple/Tuple2D.hxx
+++ b/include/basegfx/tuple/Tuple2D.hxx
@@ -105,53 +105,85 @@ public:
// operator overrides
- Tuple2D& operator+=(const Tuple2D& rTup)
+ Tuple2D<TYPE>& operator+=(const Tuple2D<TYPE>& rTup)
{
mfX += rTup.mfX;
mfY += rTup.mfY;
return *this;
}
- Tuple2D& operator-=(const Tuple2D& rTup)
+ Tuple2D<TYPE>& operator-=(const Tuple2D<TYPE>& rTup)
{
mfX -= rTup.mfX;
mfY -= rTup.mfY;
return *this;
}
- Tuple2D& operator/=(const Tuple2D& rTup)
+ Tuple2D<TYPE>& operator/=(const Tuple2D<TYPE>& rTup)
{
mfX /= rTup.mfX;
mfY /= rTup.mfY;
return *this;
}
- Tuple2D& operator*=(const Tuple2D& rTup)
+ Tuple2D<TYPE>& operator*=(const Tuple2D<TYPE>& rTup)
{
mfX *= rTup.mfX;
mfY *= rTup.mfY;
return *this;
}
- Tuple2D& operator*=(TYPE t)
+ Tuple2D<TYPE>& operator*=(TYPE t)
{
mfX *= t;
mfY *= t;
return *this;
}
- Tuple2D& operator/=(TYPE t)
+ Tuple2D<TYPE>& operator/=(TYPE t)
{
mfX /= t;
mfY /= t;
return *this;
}
- bool operator==(const Tuple2D& rTup) const { return mfX == rTup.mfX && mfY == rTup.mfY; }
+ bool operator==(const Tuple2D<TYPE>& rTup) const { return mfX == rTup.mfX && mfY == rTup.mfY; }
- bool operator!=(const Tuple2D& rTup) const { return !(*this == rTup); }
+ bool operator!=(const Tuple2D<TYPE>& rTup) const { return !(*this == rTup); }
};
+template <typename TYPE>
+inline Tuple2D<TYPE> operator-(const Tuple2D<TYPE>& rTupA, const Tuple2D<TYPE>& rTupB)
+{
+ Tuple2D<TYPE> aNew(rTupA);
+ aNew -= rTupB;
+ return aNew;
+}
+
+template <typename TYPE>
+inline Tuple2D<TYPE> operator+(const Tuple2D<TYPE>& rTupA, const Tuple2D<TYPE>& rTupB)
+{
+ Tuple2D<TYPE> aNew(rTupA);
+ aNew += rTupB;
+ return aNew;
+}
+
+template <typename TYPE>
+inline Tuple2D<TYPE> operator*(const Tuple2D<TYPE>& rTupA, const Tuple2D<TYPE>& rTupB)
+{
+ Tuple2D<TYPE> aNew(rTupA);
+ aNew *= rTupB;
+ return aNew;
+}
+
+template <typename TYPE>
+inline Tuple2D<TYPE> operator/(const Tuple2D<TYPE>& rTupA, const Tuple2D<TYPE>& rTupB)
+{
+ Tuple2D<TYPE> aNew(rTupA);
+ aNew /= rTupB;
+ return aNew;
+}
+
} // end of namespace basegfx
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/tuple/b2dtuple.hxx b/include/basegfx/tuple/b2dtuple.hxx
index c47b7b898c17..30b5587f7bd8 100644
--- a/include/basegfx/tuple/b2dtuple.hxx
+++ b/include/basegfx/tuple/b2dtuple.hxx
@@ -61,6 +61,10 @@ namespace basegfx
: Tuple2D(fX, fY)
{}
+ B2DTuple(Tuple2D<double> const& rTuple)
+ : Tuple2D(rTuple)
+ {}
+
/** Create a copy of a 2D integer Tuple
@param rTup
@@ -118,34 +122,6 @@ namespace basegfx
rtl_math_approxEqual(rOld1.getY(), rOld2.getY()) ? rOld1.getY() : (rOld1.getY() + rOld2.getY()) * 0.5);
}
- inline B2DTuple operator+(const B2DTuple& rTupA, const B2DTuple& rTupB)
- {
- B2DTuple aSum(rTupA);
- aSum += rTupB;
- return aSum;
- }
-
- inline B2DTuple operator-(const B2DTuple& rTupA, const B2DTuple& rTupB)
- {
- B2DTuple aSub(rTupA);
- aSub -= rTupB;
- return aSub;
- }
-
- inline B2DTuple operator/(const B2DTuple& rTupA, const B2DTuple& rTupB)
- {
- B2DTuple aDiv(rTupA);
- aDiv /= rTupB;
- return aDiv;
- }
-
- inline B2DTuple operator*(const B2DTuple& rTupA, const B2DTuple& rTupB)
- {
- B2DTuple aMul(rTupA);
- aMul *= rTupB;
- return aMul;
- }
-
inline B2DTuple operator*(const B2DTuple& rTup, double t)
{
B2DTuple aNew(rTup);
diff --git a/include/basegfx/vector/b2dvector.hxx b/include/basegfx/vector/b2dvector.hxx
index 17a9c60b0f71..c7d8bc08a867 100644
--- a/include/basegfx/vector/b2dvector.hxx
+++ b/include/basegfx/vector/b2dvector.hxx
@@ -72,8 +72,8 @@ namespace basegfx
/** constructor with tuple to allow copy-constructing
from B2DTuple-based classes
*/
- B2DVector(const ::basegfx::B2DTuple& rTuple)
- : B2DTuple(rTuple)
+ B2DVector(Tuple2D<double> const& rTuple)
+ : B2DTuple(rTuple)
{}
/** *=operator to allow usage from B2DVector, too
@@ -97,7 +97,12 @@ namespace basegfx
/** assignment operator to allow assigning the results
of B2DTuple calculations
*/
- B2DVector& operator=( const ::basegfx::B2DTuple& rVec );
+ B2DVector& operator=(Tuple2D<double> const& rVector)
+ {
+ mfX = rVector.getX();
+ mfY = rVector.getY();
+ return *this;
+ }
/** Calculate the length of this 2D Vector