summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/basegfx/tuple/Tuple2D.hxx157
-rw-r--r--include/basegfx/tuple/Tuple3D.hxx139
-rw-r--r--include/basegfx/tuple/b2dtuple.hxx121
-rw-r--r--include/basegfx/tuple/b2i64tuple.hxx105
-rw-r--r--include/basegfx/tuple/b2ituple.hxx119
-rw-r--r--include/basegfx/tuple/b3dtuple.hxx109
-rw-r--r--include/basegfx/tuple/b3ituple.hxx87
7 files changed, 325 insertions, 512 deletions
diff --git a/include/basegfx/tuple/Tuple2D.hxx b/include/basegfx/tuple/Tuple2D.hxx
new file mode 100644
index 000000000000..e38dd1542207
--- /dev/null
+++ b/include/basegfx/tuple/Tuple2D.hxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <sal/types.h>
+#include <basegfx/basegfxdllapi.h>
+#include <basegfx/utils/common.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+namespace basegfx
+{
+template <typename TYPE> class Tuple2D
+{
+protected:
+ union {
+ // temporary alias mnX with mfX and mnY with mfY
+ struct
+ {
+ TYPE mnX;
+ TYPE mnY;
+ };
+ struct
+ {
+ TYPE mfX;
+ TYPE mfY;
+ };
+ };
+
+public:
+ /** Create a 2D Tuple
+
+ @param nX
+ This parameter is used to initialize the X-coordinate
+ of the 2D Tuple.
+
+ @param nY
+ This parameter is used to initialize the Y-coordinate
+ of the 2D Tuple.
+ */
+ Tuple2D(TYPE x, TYPE y)
+ : mnX(x)
+ , mnY(y)
+ {
+ }
+
+ double get(Axis2D eAxis) { return eAxis == Axis2D::X ? getX() : getY(); }
+
+ void set(Axis2D eAxis, TYPE fValue)
+ {
+ if (eAxis == Axis2D::X)
+ setX(fValue);
+ else
+ setY(fValue);
+ }
+
+ /// Get X-Coordinate of 2D Tuple
+ TYPE getX() const { return mnX; }
+
+ /// Get Y-Coordinate of 2D Tuple
+ TYPE getY() const { return mnY; }
+
+ /// Set X-Coordinate of 2D Tuple
+ void setX(TYPE fX) { mnX = fX; }
+
+ /// Set Y-Coordinate of 2D Tuple
+ void setY(TYPE fY) { mnY = fY; }
+
+ // comparators with tolerance
+
+ template <typename T = TYPE,
+ typename std::enable_if<std::is_integral<T>::value, bool>::type = false>
+ bool equal(const Tuple2D<TYPE>& rTup) const
+ {
+ return mfX == rTup.mfX && mfY == rTup.mfY;
+ }
+
+ template <typename T = TYPE,
+ typename std::enable_if<std::is_floating_point<T>::value, bool>::type = false>
+ bool equal(const Tuple2D<TYPE>& rTup) const
+ {
+ return this == &rTup || (fTools::equal(mfX, rTup.mfX) && fTools::equal(mfY, rTup.mfY));
+ }
+
+ template <typename T = TYPE,
+ typename std::enable_if<std::is_integral<T>::value, bool>::type = false>
+ bool equalZero() const
+ {
+ return mnX == 0 && mnY == 0;
+ }
+
+ template <typename T = TYPE,
+ typename std::enable_if<std::is_floating_point<T>::value, bool>::type = false>
+ bool equalZero() const
+ {
+ return fTools::equalZero(mfX) && fTools::equalZero(mfY);
+ }
+
+ // operator overrides
+
+ Tuple2D& operator+=(const Tuple2D& rTup)
+ {
+ mfX += rTup.mfX;
+ mfY += rTup.mfY;
+ return *this;
+ }
+
+ Tuple2D& operator-=(const Tuple2D& rTup)
+ {
+ mfX -= rTup.mfX;
+ mfY -= rTup.mfY;
+ return *this;
+ }
+
+ Tuple2D& operator/=(const Tuple2D& rTup)
+ {
+ mfX /= rTup.mfX;
+ mfY /= rTup.mfY;
+ return *this;
+ }
+
+ Tuple2D& operator*=(const Tuple2D& rTup)
+ {
+ mfX *= rTup.mfX;
+ mfY *= rTup.mfY;
+ return *this;
+ }
+
+ Tuple2D& operator*=(TYPE t)
+ {
+ mfX *= t;
+ mfY *= t;
+ return *this;
+ }
+
+ Tuple2D& 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& rTup) const { return !(*this == rTup); }
+};
+
+} // end of namespace basegfx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/tuple/Tuple3D.hxx b/include/basegfx/tuple/Tuple3D.hxx
new file mode 100644
index 000000000000..8ddcec8c618b
--- /dev/null
+++ b/include/basegfx/tuple/Tuple3D.hxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <sal/types.h>
+#include <basegfx/basegfxdllapi.h>
+#include <basegfx/utils/common.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+namespace basegfx
+{
+template <typename TYPE> class Tuple3D
+{
+protected:
+ union {
+ // temporary alias mnX with mfX, mnY with mfY and mnZ with mfZ
+ struct
+ {
+ TYPE mnX;
+ TYPE mnY;
+ TYPE mnZ;
+ };
+ struct
+ {
+ TYPE mfX;
+ TYPE mfY;
+ TYPE mfZ;
+ };
+ };
+
+public:
+ /** Create a 3D Tuple
+
+ @param x
+ This parameter is used to initialize the X-coordinate
+ of the 3D Tuple.
+
+ @param y
+ This parameter is used to initialize the Y-coordinate
+ of the 3D Tuple.
+
+ @param z
+ This parameter is used to initialize the Z-coordinate
+ of the 3D Tuple.
+ */
+ Tuple3D(TYPE x, TYPE y, TYPE z)
+ : mnX(x)
+ , mnY(y)
+ , mnZ(z)
+ {
+ }
+
+ /// Get X-Coordinate of 3D Tuple
+ TYPE getX() const { return mnX; }
+
+ /// Get Y-Coordinate of 3D Tuple
+ TYPE getY() const { return mnY; }
+
+ /// Get Z-Coordinate of 3D Tuple
+ TYPE getZ() const { return mnZ; }
+
+ /// Set X-Coordinate of 3D Tuple
+ void setX(TYPE fX) { mnX = fX; }
+
+ /// Set Y-Coordinate of 3D Tuple
+ void setY(TYPE fY) { mnY = fY; }
+
+ /// Set Z-Coordinate of 3D Tuple
+ void setZ(TYPE fZ) { mnZ = fZ; }
+
+ // operators
+
+ Tuple3D& operator+=(const Tuple3D& rTup)
+ {
+ mfX += rTup.mfX;
+ mfY += rTup.mfY;
+ mfZ += rTup.mfZ;
+ return *this;
+ }
+
+ Tuple3D& operator-=(const Tuple3D& rTup)
+ {
+ mfX -= rTup.mfX;
+ mfY -= rTup.mfY;
+ mfZ -= rTup.mfZ;
+ return *this;
+ }
+
+ Tuple3D& operator/=(const Tuple3D& rTup)
+ {
+ mfX /= rTup.mfX;
+ mfY /= rTup.mfY;
+ mfZ /= rTup.mfZ;
+ return *this;
+ }
+
+ Tuple3D& operator*=(const Tuple3D& rTup)
+ {
+ mfX *= rTup.mfX;
+ mfY *= rTup.mfY;
+ mfZ *= rTup.mfZ;
+ return *this;
+ }
+
+ Tuple3D& operator*=(TYPE t)
+ {
+ mfX *= t;
+ mfY *= t;
+ mfZ *= t;
+ return *this;
+ }
+
+ Tuple3D& operator/=(TYPE t)
+ {
+ mfX /= t;
+ mfY /= t;
+ mfZ /= t;
+ return *this;
+ }
+
+ bool operator==(const Tuple3D& rTup) const
+ {
+ return mfX == rTup.mfX && mfY == rTup.mfY && mfZ == rTup.mfZ;
+ }
+
+ bool operator!=(const Tuple3D& rTup) const { return !operator==(rTup); }
+};
+
+} // 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 0c7b7f463261..c523501b9639 100644
--- a/include/basegfx/tuple/b2dtuple.hxx
+++ b/include/basegfx/tuple/b2dtuple.hxx
@@ -22,7 +22,7 @@
#include <sal/types.h>
#include <basegfx/numeric/ftools.hxx>
#include <basegfx/basegfxdllapi.h>
-#include <basegfx/utils/common.hxx>
+#include <basegfx/tuple/Tuple2D.hxx>
namespace basegfx
{
@@ -36,12 +36,8 @@ namespace basegfx
@derive Use this class to implement Points or Vectors
which are based on two double values
*/
- class SAL_WARN_UNUSED B2DTuple
+ class SAL_WARN_UNUSED B2DTuple : public Tuple2D<double>
{
- protected:
- double mfX;
- double mfY;
-
public:
/** Create a 2D Tuple
@@ -49,8 +45,7 @@ namespace basegfx
The tuple is initialized to (0.0, 0.0)
*/
B2DTuple()
- : mfX(0.0),
- mfY(0.0)
+ : Tuple2D(0.0, 0.0)
{}
/** Create a 2D Tuple
@@ -64,8 +59,7 @@ namespace basegfx
of the 2D Tuple.
*/
B2DTuple(double fX, double fY)
- : mfX( fX ),
- mfY( fY )
+ : Tuple2D(fX, fY)
{}
/** Create a copy of a 2D integer Tuple
@@ -75,120 +69,13 @@ namespace basegfx
*/
BASEGFX_DLLPUBLIC explicit B2DTuple(const B2ITuple& rTup);
- /// Get X-Coordinate of 2D Tuple
- double getX() const
- {
- return mfX;
- }
-
- /// Get Y-Coordinate of 2D Tuple
- double getY() const
- {
- return mfY;
- }
-
- /// Set X-Coordinate of 2D Tuple
- void setX(double fX)
- {
- mfX = fX;
- }
-
- /// Set Y-Coordinate of 2D Tuple
- void setY(double fY)
- {
- mfY = fY;
- }
-
- double get(Axis2D eAxis)
- {
- return eAxis == Axis2D::X ? getX() : getY();
- }
-
- void set(Axis2D eAxis, double fValue)
- {
- if (eAxis == Axis2D::X)
- setX(fValue);
- else
- setY(fValue);
- }
-
- // comparators with tolerance
-
- bool equalZero() const
- {
- return (this == &getEmptyTuple() ||
- (fTools::equalZero(mfX) && fTools::equalZero(mfY)));
- }
-
- bool equal(const B2DTuple& rTup) const
- {
- return (
- this == &rTup ||
- (fTools::equal(mfX, rTup.mfX) &&
- fTools::equal(mfY, rTup.mfY)));
- }
-
// operators
-
- B2DTuple& operator+=( const B2DTuple& rTup )
- {
- mfX += rTup.mfX;
- mfY += rTup.mfY;
- return *this;
- }
-
- B2DTuple& operator-=( const B2DTuple& rTup )
- {
- mfX -= rTup.mfX;
- mfY -= rTup.mfY;
- return *this;
- }
-
- B2DTuple& operator/=( const B2DTuple& rTup )
- {
- mfX /= rTup.mfX;
- mfY /= rTup.mfY;
- return *this;
- }
-
- B2DTuple& operator*=( const B2DTuple& rTup )
- {
- mfX *= rTup.mfX;
- mfY *= rTup.mfY;
- return *this;
- }
-
- B2DTuple& operator*=(double t)
- {
- mfX *= t;
- mfY *= t;
- return *this;
- }
-
- B2DTuple& operator/=(double t)
- {
- const double fVal(1.0 / t);
- mfX *= fVal;
- mfY *= fVal;
- return *this;
- }
-
B2DTuple operator-(void) const
{
return B2DTuple(-mfX, -mfY);
}
- bool operator==( const B2DTuple& rTup ) const
- {
- return mfX == rTup.mfX && mfY == rTup.mfY;
- }
-
- bool operator!=( const B2DTuple& rTup ) const
- {
- return mfX != rTup.mfX || mfY != rTup.mfY;
- }
-
BASEGFX_DLLPUBLIC static const B2DTuple& getEmptyTuple();
};
diff --git a/include/basegfx/tuple/b2i64tuple.hxx b/include/basegfx/tuple/b2i64tuple.hxx
index 5f2350b66ac1..70838572f321 100644
--- a/include/basegfx/tuple/b2i64tuple.hxx
+++ b/include/basegfx/tuple/b2i64tuple.hxx
@@ -21,7 +21,7 @@
#include <sal/types.h>
#include <basegfx/basegfxdllapi.h>
-
+#include <basegfx/tuple/Tuple2D.hxx>
namespace basegfx
{
@@ -33,34 +33,29 @@ namespace basegfx
@derive Use this class to implement Points or Vectors
which are based on two sal_Int64 values
*/
- class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B2I64Tuple final
+ class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B2I64Tuple : public Tuple2D<sal_Int64>
{
- sal_Int64 mnX;
- sal_Int64 mnY;
-
public:
/** Create a 2D Tuple
The tuple is initialized to (0, 0)
*/
B2I64Tuple()
- : mnX(0),
- mnY(0)
+ : Tuple2D(0, 0)
{}
/** Create a 2D Tuple
- @param fX
+ @param nX
This parameter is used to initialize the X-coordinate
of the 2D Tuple.
- @param fY
+ @param nY
This parameter is used to initialize the Y-coordinate
of the 2D Tuple.
*/
- B2I64Tuple(sal_Int64 fX, sal_Int64 fY)
- : mnX( fX ),
- mnY( fY )
+ B2I64Tuple(sal_Int64 nX, sal_Int64 nY)
+ : Tuple2D(nX, nY)
{}
/** Create a copy of a 2D Tuple
@@ -69,100 +64,16 @@ namespace basegfx
The 2D Tuple which will be copied.
*/
B2I64Tuple(const B2I64Tuple& rTup)
- : mnX( rTup.mnX ),
- mnY( rTup.mnY )
+ : Tuple2D(rTup.mnX, rTup.mnY)
{}
- /// Get X-Coordinate of 2D Tuple
- sal_Int64 getX() const
- {
- return mnX;
- }
-
- /// Get Y-Coordinate of 2D Tuple
- sal_Int64 getY() const
- {
- return mnY;
- }
-
- /// Array-access to 2D Tuple
- const sal_Int64& operator[] (int nPos) const
- {
- // Here, normally one if(...) should be used. In the assumption that
- // both sal_Int64 members can be accessed as an array a shortcut is used here.
- // if(0 == nPos) return mnX; return mnY;
- return *((&mnX) + nPos);
- }
-
- /// Array-access to 2D Tuple
- sal_Int64& operator[] (int nPos)
- {
- // Here, normally one if(...) should be used. In the assumption that
- // both sal_Int64 members can be accessed as an array a shortcut is used here.
- // if(0 == nPos) return mnX; return mnY;
- return *((&mnX) + nPos);
- }
-
// operators
-
- B2I64Tuple& operator+=( const B2I64Tuple& rTup )
- {
- mnX += rTup.mnX;
- mnY += rTup.mnY;
- return *this;
- }
-
- B2I64Tuple& operator-=( const B2I64Tuple& rTup )
- {
- mnX -= rTup.mnX;
- mnY -= rTup.mnY;
- return *this;
- }
-
- B2I64Tuple& operator/=( const B2I64Tuple& rTup )
- {
- mnX /= rTup.mnX;
- mnY /= rTup.mnY;
- return *this;
- }
-
- B2I64Tuple& operator*=( const B2I64Tuple& rTup )
- {
- mnX *= rTup.mnX;
- mnY *= rTup.mnY;
- return *this;
- }
-
- B2I64Tuple& operator*=(sal_Int64 t)
- {
- mnX *= t;
- mnY *= t;
- return *this;
- }
-
- B2I64Tuple& operator/=(sal_Int64 t)
- {
- mnX /= t;
- mnY /= t;
- return *this;
- }
-
B2I64Tuple operator-(void) const
{
return B2I64Tuple(-mnX, -mnY);
}
- bool operator==( const B2I64Tuple& rTup ) const
- {
- return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY);
- }
-
- bool operator!=( const B2I64Tuple& rTup ) const
- {
- return !(*this == rTup);
- }
-
B2I64Tuple& operator=( const B2I64Tuple& rTup )
{
mnX = rTup.mnX;
diff --git a/include/basegfx/tuple/b2ituple.hxx b/include/basegfx/tuple/b2ituple.hxx
index b8f6c3e96386..e3f195596a37 100644
--- a/include/basegfx/tuple/b2ituple.hxx
+++ b/include/basegfx/tuple/b2ituple.hxx
@@ -21,6 +21,7 @@
#include <sal/types.h>
#include <basegfx/basegfxdllapi.h>
+#include <basegfx/tuple/Tuple2D.hxx>
namespace basegfx
{
@@ -32,143 +33,37 @@ namespace basegfx
@derive Use this class to implement Points or Vectors
which are based on two sal_Int32 values
*/
- class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B2ITuple
+ class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B2ITuple : public Tuple2D<sal_Int32>
{
- protected:
- sal_Int32 mnX;
- sal_Int32 mnY;
-
public:
/** Create a 2D Tuple
The tuple is initialized to (0, 0)
*/
B2ITuple()
- : mnX(0),
- mnY(0)
+ : Tuple2D(0, 0)
{}
/** Create a 2D Tuple
- @param fX
+ @param nX
This parameter is used to initialize the X-coordinate
of the 2D Tuple.
- @param fY
+ @param nY
This parameter is used to initialize the Y-coordinate
of the 2D Tuple.
*/
- B2ITuple(sal_Int32 fX, sal_Int32 fY)
- : mnX( fX ),
- mnY( fY )
+ B2ITuple(sal_Int32 nX, sal_Int32 nY)
+ : Tuple2D(nX, nY)
{}
- /// Get X-Coordinate of 2D Tuple
- sal_Int32 getX() const
- {
- return mnX;
- }
-
- /// Get Y-Coordinate of 2D Tuple
- sal_Int32 getY() const
- {
- return mnY;
- }
-
- /// Set X-Coordinate of 2D Tuple
- void setX(sal_Int32 fX)
- {
- mnX = fX;
- }
-
- /// Set Y-Coordinate of 2D Tuple
- void setY(sal_Int32 fY)
- {
- mnY = fY;
- }
-
- /// Array-access to 2D Tuple
- const sal_Int32& operator[] (int nPos) const
- {
- // Here, normally one if(...) should be used. In the assumption that
- // both sal_Int32 members can be accessed as an array a shortcut is used here.
- // if(0 == nPos) return mnX; return mnY;
- return *((&mnX) + nPos);
- }
-
- /// Array-access to 2D Tuple
- sal_Int32& operator[] (int nPos)
- {
- // Here, normally one if(...) should be used. In the assumption that
- // both sal_Int32 members can be accessed as an array a shortcut is used here.
- // if(0 == nPos) return mnX; return mnY;
- return *((&mnX) + nPos);
- }
-
// operators
-
- B2ITuple& operator+=( const B2ITuple& rTup )
- {
- mnX += rTup.mnX;
- mnY += rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator-=( const B2ITuple& rTup )
- {
- mnX -= rTup.mnX;
- mnY -= rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator/=( const B2ITuple& rTup )
- {
- mnX /= rTup.mnX;
- mnY /= rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator*=( const B2ITuple& rTup )
- {
- mnX *= rTup.mnX;
- mnY *= rTup.mnY;
- return *this;
- }
-
- B2ITuple& operator*=(sal_Int32 t)
- {
- mnX *= t;
- mnY *= t;
- return *this;
- }
-
- B2ITuple& operator/=(sal_Int32 t)
- {
- mnX /= t;
- mnY /= t;
- return *this;
- }
-
B2ITuple operator-(void) const
{
return B2ITuple(-mnX, -mnY);
}
-
- bool equalZero() const
- {
- return mnX == 0 && mnY == 0;
- }
-
- bool operator==( const B2ITuple& rTup ) const
- {
- return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY);
- }
-
- bool operator!=( const B2ITuple& rTup ) const
- {
- return !(*this == rTup);
- }
};
// external operators
diff --git a/include/basegfx/tuple/b3dtuple.hxx b/include/basegfx/tuple/b3dtuple.hxx
index 791cc5f3e667..bb8f4b4067c3 100644
--- a/include/basegfx/tuple/b3dtuple.hxx
+++ b/include/basegfx/tuple/b3dtuple.hxx
@@ -23,6 +23,7 @@
#include <sal/types.h>
#include <basegfx/numeric/ftools.hxx>
#include <basegfx/basegfxdllapi.h>
+#include <basegfx/tuple/Tuple3D.hxx>
namespace basegfx
{
@@ -36,22 +37,15 @@ namespace basegfx
@derive Use this class to implement Points or Vectors
which are based on three double values
*/
- class SAL_WARN_UNUSED UNLESS_MERGELIBS(BASEGFX_DLLPUBLIC) B3DTuple
+ class SAL_WARN_UNUSED UNLESS_MERGELIBS(BASEGFX_DLLPUBLIC) B3DTuple : public Tuple3D<double>
{
- protected:
- double mfX;
- double mfY;
- double mfZ;
-
public:
/** Create a 3D Tuple
The tuple is initialized to (0.0, 0.0, 0.0)
*/
B3DTuple()
- : mfX(0.0),
- mfY(0.0),
- mfZ(0.0)
+ : Tuple3D(0.0, 0.0, 0.0)
{}
/** Create a 3D Tuple
@@ -69,47 +63,9 @@ namespace basegfx
of the 3D Tuple.
*/
B3DTuple(double fX, double fY, double fZ)
- : mfX(fX),
- mfY(fY),
- mfZ(fZ)
+ : Tuple3D(fX, fY, fZ)
{}
- /// get X-Coordinate of 3D Tuple
- double getX() const
- {
- return mfX;
- }
-
- /// get Y-Coordinate of 3D Tuple
- double getY() const
- {
- return mfY;
- }
-
- /// get Z-Coordinate of 3D Tuple
- double getZ() const
- {
- return mfZ;
- }
-
- /// set X-Coordinate of 3D Tuple
- void setX(double fX)
- {
- mfX = fX;
- }
-
- /// set Y-Coordinate of 3D Tuple
- void setY(double fY)
- {
- mfY = fY;
- }
-
- /// set Z-Coordinate of 3D Tuple
- void setZ(double fZ)
- {
- mfZ = fZ;
- }
-
/// Array-access to 3D Tuple
const double& operator[] (int nPos) const
{
@@ -150,70 +106,17 @@ namespace basegfx
// operators
-
- B3DTuple& operator+=( const B3DTuple& rTup )
- {
- mfX += rTup.mfX;
- mfY += rTup.mfY;
- mfZ += rTup.mfZ;
- return *this;
- }
-
- B3DTuple& operator-=( const B3DTuple& rTup )
- {
- mfX -= rTup.mfX;
- mfY -= rTup.mfY;
- mfZ -= rTup.mfZ;
- return *this;
- }
-
- B3DTuple& operator/=( const B3DTuple& rTup )
- {
- mfX /= rTup.mfX;
- mfY /= rTup.mfY;
- mfZ /= rTup.mfZ;
- return *this;
- }
-
- B3DTuple& operator*=( const B3DTuple& rTup )
- {
- mfX *= rTup.mfX;
- mfY *= rTup.mfY;
- mfZ *= rTup.mfZ;
- return *this;
- }
-
- B3DTuple& operator*=(double t)
- {
- mfX *= t;
- mfY *= t;
- mfZ *= t;
- return *this;
- }
-
- B3DTuple& operator/=(double t)
- {
- const double fVal(1.0 / t);
- mfX *= fVal;
- mfY *= fVal;
- mfZ *= fVal;
- return *this;
- }
-
B3DTuple operator-(void) const
{
return B3DTuple(-mfX, -mfY, -mfZ);
}
- bool operator==( const B3DTuple& rTup ) const
+ bool operator==(const B3DTuple& rTup) const
{
return mfX == rTup.mfX && mfY == rTup.mfY && mfZ == rTup.mfZ;
}
- bool operator!=( const B3DTuple& rTup ) const
- {
- return mfX != rTup.mfX || mfY != rTup.mfY || mfZ != rTup.mfZ;
- }
+ bool operator!=(const B3DTuple& rTup) const { return !operator==(rTup); }
void correctValues(const double fCompareValue = 0.0)
{
diff --git a/include/basegfx/tuple/b3ituple.hxx b/include/basegfx/tuple/b3ituple.hxx
index 7fe49ea92e93..72c9fa81402a 100644
--- a/include/basegfx/tuple/b3ituple.hxx
+++ b/include/basegfx/tuple/b3ituple.hxx
@@ -21,6 +21,7 @@
#include <sal/types.h>
#include <basegfx/basegfxdllapi.h>
+#include <basegfx/tuple/Tuple3D.hxx>
namespace basegfx
{
@@ -32,22 +33,15 @@ namespace basegfx
@derive Use this class to implement Points or Vectors
which are based on three sal_Int32 values
*/
- class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B3ITuple
+ class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC B3ITuple : public Tuple3D<sal_Int32>
{
- protected:
- sal_Int32 mnX;
- sal_Int32 mnY;
- sal_Int32 mnZ;
-
public:
/** Create a 3D Tuple
The tuple is initialized to (0, 0, 0)
*/
B3ITuple()
- : mnX(0),
- mnY(0),
- mnZ(0)
+ : Tuple3D(0, 0, 0)
{}
/** Create a 3D Tuple
@@ -65,23 +59,9 @@ namespace basegfx
of the 3D Tuple.
*/
B3ITuple(sal_Int32 nX, sal_Int32 nY, sal_Int32 nZ)
- : mnX(nX),
- mnY(nY),
- mnZ(nZ)
+ : Tuple3D(nX, nY, nZ)
{}
- /// get X-Coordinate of 3D Tuple
- sal_Int32 getX() const
- {
- return mnX;
- }
-
- /// get Y-Coordinate of 3D Tuple
- sal_Int32 getY() const
- {
- return mnY;
- }
-
/// Array-access to 3D Tuple
const sal_Int32& operator[] (int nPos) const
{
@@ -102,69 +82,10 @@ namespace basegfx
// operators
-
- B3ITuple& operator+=( const B3ITuple& rTup )
- {
- mnX += rTup.mnX;
- mnY += rTup.mnY;
- mnZ += rTup.mnZ;
- return *this;
- }
-
- B3ITuple& operator-=( const B3ITuple& rTup )
- {
- mnX -= rTup.mnX;
- mnY -= rTup.mnY;
- mnZ -= rTup.mnZ;
- return *this;
- }
-
- B3ITuple& operator/=( const B3ITuple& rTup )
- {
- mnX /= rTup.mnX;
- mnY /= rTup.mnY;
- mnZ /= rTup.mnZ;
- return *this;
- }
-
- B3ITuple& operator*=( const B3ITuple& rTup )
- {
- mnX *= rTup.mnX;
- mnY *= rTup.mnY;
- mnZ *= rTup.mnZ;
- return *this;
- }
-
- B3ITuple& operator*=(sal_Int32 t)
- {
- mnX *= t;
- mnY *= t;
- mnZ *= t;
- return *this;
- }
-
- B3ITuple& operator/=(sal_Int32 t)
- {
- mnX /= t;
- mnY /= t;
- mnZ /= t;
- return *this;
- }
-
B3ITuple operator-(void) const
{
return B3ITuple(-mnX, -mnY, -mnZ);
}
-
- bool operator==( const B3ITuple& rTup ) const
- {
- return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ);
- }
-
- bool operator!=( const B3ITuple& rTup ) const
- {
- return !(*this == rTup);
- }
};
} // end of namespace basegfx