diff options
author | Thorsten Behrens <thb@openoffice.org> | 2004-01-16 09:34:43 +0000 |
---|---|---|
committer | Thorsten Behrens <thb@openoffice.org> | 2004-01-16 09:34:43 +0000 |
commit | fb6fefbd9482f6fa26447be417286ae1935c0702 (patch) | |
tree | df3b1b957f17a5f70a83b705865b4c1291b1f382 /basegfx/inc | |
parent | 08761ff6d5991730ed66b7e13817b325ce848da3 (diff) |
#110496# Added integer point, size and rectangle classes, needed for the new canvas
Diffstat (limited to 'basegfx/inc')
24 files changed, 334 insertions, 301 deletions
diff --git a/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx b/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx index 83b18f9c75c5..dd23a841d51a 100644 --- a/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx +++ b/basegfx/inc/basegfx/curve/b2dcubicbezier.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dcubicbezier.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:46 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,11 +89,11 @@ namespace basegfx B2DCubicBezier& operator=(const B2DCubicBezier& rBezier); // compare operators - sal_Bool operator==(const B2DCubicBezier& rBezier) const; - sal_Bool operator!=(const B2DCubicBezier& rBezier) const; + bool operator==(const B2DCubicBezier& rBezier) const; + bool operator!=(const B2DCubicBezier& rBezier) const; // test if vectors are used - sal_Bool isBezier() const; + bool isBezier() const; // test if contained bezier is trivial and reset vectors accordingly void testAndSolveTrivialBezier(); diff --git a/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx b/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx index 6f81f26d97a7..259b19cc09c5 100644 --- a/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx +++ b/basegfx/inc/basegfx/curve/b2dquadraticbezier.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dquadraticbezier.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:46 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,11 +88,11 @@ namespace basegfx B2DQuadraticBezier& operator=(const B2DQuadraticBezier& rBezier); // compare operators - sal_Bool operator==(const B2DQuadraticBezier& rBezier) const; - sal_Bool operator!=(const B2DQuadraticBezier& rBezier) const; + bool operator==(const B2DQuadraticBezier& rBezier) const; + bool operator!=(const B2DQuadraticBezier& rBezier) const; // test if control point is placed on the edge - sal_Bool isBezier() const; + bool isBezier() const; // data interface ::basegfx::B2DPoint getStartPoint() const { return maStartPoint; } diff --git a/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx b/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx index f574e062f5c1..ff00ea0cc8af 100644 --- a/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx +++ b/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dhommatrix.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:47 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,15 +90,15 @@ namespace basegfx void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); // Auf Einheitsmatrix zuruecksetzen - sal_Bool isIdentity() const; + bool isIdentity() const; void identity(); // Invertierung - sal_Bool isInvertible() const; - sal_Bool invert(); + bool isInvertible() const; + bool invert(); // Normalisierung - sal_Bool isNormalized() const; + bool isNormalized() const; void normalize(); // Determinante @@ -128,8 +128,8 @@ namespace basegfx B2DHomMatrix& operator-=(const B2DHomMatrix& rMat); // Vergleichsoperatoren - sal_Bool operator==(const B2DHomMatrix& rMat) const; - sal_Bool operator!=(const B2DHomMatrix& rMat) const; + bool operator==(const B2DHomMatrix& rMat) const; + bool operator!=(const B2DHomMatrix& rMat) const; // Multiplikation, Division mit Konstante B2DHomMatrix& operator*=(double fValue); @@ -144,7 +144,7 @@ namespace basegfx // Help routine to decompose given homogen 3x3 matrix to components. A correction of // the components is done to avoid inaccuracies. // Zerlegung - sal_Bool decompose(B2DTuple& rScale, B2DTuple& rTranslate, double& rRotate, double& rShearX) const; + bool decompose(B2DTuple& rScale, B2DTuple& rTranslate, double& rRotate, double& rShearX) const; }; // Addition, Subtraktion diff --git a/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx b/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx index e2751a76c3cd..206f8ba82fa7 100644 --- a/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx +++ b/basegfx/inc/basegfx/matrix/b3dhommatrix.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dhommatrix.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:48 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,15 +89,15 @@ namespace basegfx double get(sal_uInt16 nRow, sal_uInt16 nColumn) const; void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); - sal_Bool isIdentity() const; + bool isIdentity() const; /// Reset to the identity matrix void identity(); - sal_Bool isInvertible() const; + bool isInvertible() const; /// Invert the matrix (if possible) - sal_Bool invert(); + bool invert(); - sal_Bool isNormalized() const; + bool isNormalized() const; /// Normalize (i.e. force w=1) the matrix void normalize(); @@ -139,8 +139,8 @@ namespace basegfx B3DHomMatrix& operator-=(const B3DHomMatrix& rMat); // comparison - sal_Bool operator==(const B3DHomMatrix& rMat) const; - sal_Bool operator!=(const B3DHomMatrix& rMat) const; + bool operator==(const B3DHomMatrix& rMat) const; + bool operator!=(const B3DHomMatrix& rMat) const; // multiplication, division by constant value B3DHomMatrix& operator*=(double fValue); @@ -153,7 +153,7 @@ namespace basegfx B3DHomMatrix& operator=(const B3DHomMatrix& rMat); // decomposition - sal_Bool decompose(B3DTuple& rScale, B3DTuple& rTranslate, B3DTuple& rRotate, B3DTuple& rShear) const; + bool decompose(B3DTuple& rScale, B3DTuple& rTranslate, B3DTuple& rRotate, B3DTuple& rShear) const; }; // addition, subtraction diff --git a/basegfx/inc/basegfx/numeric/ftools.hxx b/basegfx/inc/basegfx/numeric/ftools.hxx index 9ae52843cfe0..44627976da32 100644 --- a/basegfx/inc/basegfx/numeric/ftools.hxx +++ b/basegfx/inc/basegfx/numeric/ftools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ftools.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:50 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -95,6 +95,24 @@ #define F_2PI 6.28318530717958647694 #endif +/** Round double to nearest integer + + @return the nearest integer + */ +inline sal_Int32 fround( double fVal ) +{ + return fVal > 0.0 ? static_cast<sal_Int32>( fVal + .5 ) : -static_cast<sal_Int32>( -fVal + .5 ); +} + +/** Round double to nearest integer + + @return the nearest 64 bit integer + */ +inline sal_Int64 fround64( double fVal ) +{ + return fVal > 0.0 ? static_cast<sal_Int64>( fVal + .5 ) : -static_cast<sal_Int64>( -fVal + .5 ); +} + ////////////////////////////////////////////////////////////////////////////// // fTools defines @@ -109,64 +127,64 @@ namespace basegfx static void setSmallValue(const double& rfNew) { mfSmallValue = rfNew; } - static sal_Bool equalZero(const double& rfVal) + static bool equalZero(const double& rfVal) { return (fabs(rfVal) <= getSmallValue()); } - static sal_Bool equalZero(const double& rfVal, const double& rfSmallValue) + static bool equalZero(const double& rfVal, const double& rfSmallValue) { return (fabs(rfVal) <= rfSmallValue); } - static sal_Bool equal(const double& rfValA, const double& rfValB) + static bool equal(const double& rfValA, const double& rfValB) { return (fabs(rfValB - rfValA) <= getSmallValue()); } - static sal_Bool less(const double& rfValA, const double& rfValB) + static bool less(const double& rfValA, const double& rfValB) { return (rfValA < rfValB && !equal(rfValA, rfValB)); } - static sal_Bool lessOrEqual(const double& rfValA, const double& rfValB) + static bool lessOrEqual(const double& rfValA, const double& rfValB) { return (rfValA < rfValB || equal(rfValA, rfValB)); } - static sal_Bool more(const double& rfValA, const double& rfValB) + static bool more(const double& rfValA, const double& rfValB) { return (rfValA > rfValB && !equal(rfValA, rfValB)); } - static sal_Bool moreOrEqual(const double& rfValA, const double& rfValB) + static bool moreOrEqual(const double& rfValA, const double& rfValB) { return (rfValA > rfValB || equal(rfValA, rfValB)); } - static sal_Bool equal(const double& rfValA, const double& rfValB, const double& rfSmallValue) + static bool equal(const double& rfValA, const double& rfValB, const double& rfSmallValue) { return (fabs(rfValB - rfValA) <= rfSmallValue); } - static sal_Bool less(const double& rfValA, const double& rfValB, const double& rfSmallValue) + static bool less(const double& rfValA, const double& rfValB, const double& rfSmallValue) { return (rfValA < rfValB && !equal(rfValA, rfValB, rfSmallValue)); } - static sal_Bool lessOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) + static bool lessOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) { return (rfValA < rfValB || equal(rfValA, rfValB, rfSmallValue)); } - static sal_Bool more(const double& rfValA, const double& rfValB, const double& rfSmallValue) + static bool more(const double& rfValA, const double& rfValB, const double& rfSmallValue) { return (rfValA > rfValB && !equal(rfValA, rfValB, rfSmallValue)); } - static sal_Bool moreOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) + static bool moreOrEqual(const double& rfValA, const double& rfValB, const double& rfSmallValue) { return (rfValA > rfValB || equal(rfValA, rfValB, rfSmallValue)); } diff --git a/basegfx/inc/basegfx/point/b2dhompoint.hxx b/basegfx/inc/basegfx/point/b2dhompoint.hxx index ca5fdb9fb9b0..d08cfa11440e 100644 --- a/basegfx/inc/basegfx/point/b2dhompoint.hxx +++ b/basegfx/inc/basegfx/point/b2dhompoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dhompoint.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-12-03 09:24:24 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,9 +92,9 @@ namespace basegfx /** Test if this homogen point does have a homogenous part - @return Returns sal_True if this point has no homogenous part + @return Returns true if this point has no homogenous part */ - sal_Bool implIsHomogenized() const; + bool implIsHomogenized() const; /** Remove homogenous part of this Point @@ -119,12 +119,10 @@ namespace basegfx public: /** Create a homogen point - @param fVal - This parameter is used to initialize the coordinate - part of the Point. The homogenous part is initialized to 1.0. + The point is initialized to (0.0, 0.0) */ - B2DHomPoint(double fVal = 0.0) - : maTuple(fVal), + B2DHomPoint() + : maTuple(), mfW(1.0) {} @@ -149,7 +147,7 @@ namespace basegfx The 2D point which will be copied. The homogenous part is initialized to 1.0. */ - B2DHomPoint(const B2DPoint& rVec) + explicit B2DHomPoint(const B2DPoint& rVec) : maTuple(rVec), mfW(1.0) {} @@ -233,9 +231,9 @@ namespace basegfx B2DHomPoint& operator-(void); - sal_Bool operator==( const B2DHomPoint& rPnt ) const; + bool operator==( const B2DHomPoint& rPnt ) const; - sal_Bool operator!=( const B2DHomPoint& rPnt ) const; + bool operator!=( const B2DHomPoint& rPnt ) const; B2DHomPoint& operator=( const B2DHomPoint& rPnt ); }; diff --git a/basegfx/inc/basegfx/point/b2dpoint.hxx b/basegfx/inc/basegfx/point/b2dpoint.hxx index ed07229f4e59..b9c29ee312f9 100644 --- a/basegfx/inc/basegfx/point/b2dpoint.hxx +++ b/basegfx/inc/basegfx/point/b2dpoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpoint.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:51 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,12 +84,10 @@ namespace basegfx public: /** Create a 2D Point - @param fVal - This parameter is used to initialize the coordinate - part of the 2D Point. + The point is initialized to (0.0, 0.0) */ - B2DPoint(double fVal = 0.0) - : B2DTuple(fVal) + B2DPoint() + : B2DTuple() {} /** Create a 2D Point @@ -118,7 +116,7 @@ namespace basegfx /** constructor with tuple to allow copy-constructing from B2DTuple-based classes */ - B2DPoint(const ::basegfx::B2DTuple& rTuple) + explicit B2DPoint(const ::basegfx::B2DTuple& rTuple) : B2DTuple(rTuple) {} diff --git a/basegfx/inc/basegfx/point/b3dhompoint.hxx b/basegfx/inc/basegfx/point/b3dhompoint.hxx index 2366ea578d70..d84dc8c9ef18 100644 --- a/basegfx/inc/basegfx/point/b3dhompoint.hxx +++ b/basegfx/inc/basegfx/point/b3dhompoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dhompoint.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2003-12-03 09:24:25 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,9 +92,9 @@ namespace basegfx /** Test if this homogen point does have a homogenous part - @return Returns sal_True if this point has no homogenous part + @return Returns true if this point has no homogenous part */ - sal_Bool implIsHomogenized() const + bool implIsHomogenized() const { const double fOne(1.0); return ::basegfx::fTools::equal(mfW, fOne); @@ -127,12 +127,10 @@ namespace basegfx public: /** Create a homogen point - @param fVal - This parameter is used to initialize the coordinate - part of the Point. The homogenous part is initialized to 1.0. + The point is initialized to (0.0, 0.0, 0.0) */ - B3DHomPoint(double fVal = 0.0) - : maTuple(fVal), + B3DHomPoint() + : maTuple(), mfW(1.0) {} @@ -161,7 +159,7 @@ namespace basegfx The 3D point which will be copied. The homogenous part is initialized to 1.0. */ - B3DHomPoint(const B3DPoint& rVec) + explicit B3DHomPoint(const B3DPoint& rVec) : maTuple(rVec), mfW(1.0) {} @@ -320,13 +318,13 @@ namespace basegfx return *this; } - sal_Bool operator==( const B3DHomPoint& rPnt ) const + bool operator==( const B3DHomPoint& rPnt ) const { implTestAndHomogenize(); return (maTuple == rPnt.maTuple); } - sal_Bool operator!=( const B3DHomPoint& rPnt ) const + bool operator!=( const B3DHomPoint& rPnt ) const { implTestAndHomogenize(); return (maTuple != rPnt.maTuple); diff --git a/basegfx/inc/basegfx/point/b3dpoint.hxx b/basegfx/inc/basegfx/point/b3dpoint.hxx index 06a4b7e346e1..6dcbad842e9b 100644 --- a/basegfx/inc/basegfx/point/b3dpoint.hxx +++ b/basegfx/inc/basegfx/point/b3dpoint.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpoint.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:51 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,12 +84,10 @@ namespace basegfx public: /** Create a 3D Point - @param fVal - This parameter is used to initialize the coordinate - part of the 3D Point. + The point is initialized to (0.0, 0.0, 0.0) */ - B3DPoint(double fVal = 0.0) - : B3DTuple(fVal) + B3DPoint() + : B3DTuple() {} /** Create a 3D Point @@ -122,7 +120,7 @@ namespace basegfx /** constructor with tuple to allow copy-constructing from B3DTuple-based classes */ - B3DPoint(const ::basegfx::B3DTuple& rTuple) + explicit B3DPoint(const ::basegfx::B3DTuple& rTuple) : B3DTuple(rTuple) {} diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx index 610ce5c75df6..8bc81e641f09 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygon.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:52 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,8 +102,8 @@ namespace basegfx B2DPolygon& operator=(const B2DPolygon& rPolygon); // compare operators - sal_Bool operator==(const B2DPolygon& rPolygon) const; - sal_Bool operator!=(const B2DPolygon& rPolygon) const; + bool operator==(const B2DPolygon& rPolygon) const; + bool operator!=(const B2DPolygon& rPolygon) const; // member count sal_uInt32 count() const; @@ -121,7 +121,7 @@ namespace basegfx void setControlVectorA(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue); ::basegfx::B2DVector getControlVectorB(sal_uInt32 nIndex) const; void setControlVectorB(sal_uInt32 nIndex, const ::basegfx::B2DVector& rValue); - sal_Bool areControlPointsUsed() const; + bool areControlPointsUsed() const; // insert/append other 2D polygons void insert(sal_uInt32 nIndex, const B2DPolygon& rPoly, sal_uInt32 nIndex2 = 0, sal_uInt32 nCount = 0); @@ -134,14 +134,14 @@ namespace basegfx void clear(); // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); + bool isClosed() const; + void setClosed(bool bNew); // flip polygon direction void flip(); // test if Polygon has double points - sal_Bool hasDoublePoints() const; + bool hasDoublePoints() const; // remove double points, at the begin/end and follow-ups, too void removeDoublePoints(); diff --git a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx index 4da9f650a526..3412198c3a68 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolygontools.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:33:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,62 +91,62 @@ namespace basegfx method corrects this (removes double start/end points) and sets the Closed()-state of the polygon correctly. */ - void checkClosed(::basegfx::B2DPolygon& rCandidate); + void checkClosed(B2DPolygon& rCandidate); // Get index of outmost point (e.g. biggest X and biggest Y) - sal_uInt32 getIndexOfOutmostPoint(const ::basegfx::B2DPolygon& rCandidate); + sal_uInt32 getIndexOfOutmostPoint(const B2DPolygon& rCandidate); // Get successor and predecessor indices. Returning the same index means there // is none. Same for successor. - sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); - sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); + sal_uInt32 getIndexOfPredecessor(sal_uInt32 nIndex, const B2DPolygon& rCandidate); + sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const B2DPolygon& rCandidate); // Get index of first different predecessor. Returning the same index means there // is none. Same for successor. - sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); - sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const ::basegfx::B2DPolygon& rCandidate); + sal_uInt32 getIndexOfDifferentPredecessor(sal_uInt32 nIndex, const B2DPolygon& rCandidate); + sal_uInt32 getIndexOfDifferentSuccessor(sal_uInt32 nIndex, const B2DPolygon& rCandidate); // Get orientation of Polygon - ::basegfx::B2DVectorOrientation getOrientation(const ::basegfx::B2DPolygon& rCandidate); + B2VectorOrientation getOrientation(const B2DPolygon& rCandidate); // isInside tests for B2dPoint and other B2dPolygon. On border is not inside as long as - // not sal_True is given in bWithBorder flag. - sal_Bool isInside(const ::basegfx::B2DPolygon& rCandidate, const ::basegfx::B2DPoint& rPoint, sal_Bool bWithBorder = sal_False); - sal_Bool isInside(const ::basegfx::B2DPolygon& rCandidate, const ::basegfx::B2DPolygon& rPolygon, sal_Bool bWithBorder = sal_False); + // not true is given in bWithBorder flag. + bool isInside(const B2DPolygon& rCandidate, const B2DPoint& rPoint, bool bWithBorder = false); + bool isInside(const B2DPolygon& rCandidate, const B2DPolygon& rPolygon, bool bWithBorder = false); // get size of polygon. Control vectors are included in that ranges. - ::basegfx::B2DRange getRange(const ::basegfx::B2DPolygon& rCandidate); + B2DRange getRange(const B2DPolygon& rCandidate); // get area of polygon - double getArea(const ::basegfx::B2DPolygon& rCandidate); + double getArea(const B2DPolygon& rCandidate); // get length of polygon edge from point nIndex to nIndex + 1 - double getEdgeLength(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex); + double getEdgeLength(const B2DPolygon& rCandidate, sal_uInt32 nIndex); // get length of polygon - double getLength(const ::basegfx::B2DPolygon& rCandidate); + double getLength(const B2DPolygon& rCandidate); // get position on polygon for absolute given distance. If // length is given, it is assumed the correct polygon length, if 0.0 it is calculated // using getLength(...) - ::basegfx::B2DPoint getPositionAbsolute(const ::basegfx::B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); + B2DPoint getPositionAbsolute(const B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); // get position on polygon for relative given distance in range [0.0 .. 1.0]. If // length is given, it is assumed the correct polygon length, if 0.0 it is calculated // using getLength(...) - ::basegfx::B2DPoint getPositionRelative(const ::basegfx::B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); + B2DPoint getPositionRelative(const B2DPolygon& rCandidate, double fDistance, double fLength = 0.0); // get orientation at given polygon point - ::basegfx::B2DVectorOrientation getPointOrientation(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex); + B2VectorOrientation getPointOrientation(const B2DPolygon& rCandidate, sal_uInt32 nIndex); // Continuity check for point with given index - ::basegfx::B2DVectorContinuity getContinuityInPoint(const ::basegfx::B2DPolygon& rCandidate, sal_uInt32 nIndex); + B2VectorContinuity getContinuityInPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex); // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::B2DPolygon adaptiveSubdivideByDistance(const ::basegfx::B2DPolygon& rCandidate, double fDistanceBound = 0.0); + B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, double fDistanceBound = 0.0); // Subdivide all contained curves. Use distanceBound value if given. - ::basegfx::B2DPolygon adaptiveSubdivideByAngle(const ::basegfx::B2DPolygon& rCandidate, double fAngleBound = 5.0); + B2DPolygon adaptiveSubdivideByAngle(const B2DPolygon& rCandidate, double fAngleBound = 5.0); // Definitions for the cut flags used from the findCut methods typedef sal_uInt16 CutFlagValue; @@ -164,7 +164,7 @@ namespace basegfx // and pCut2 will contain the cut coordinate on each edge in ]0.0, 1.0] // (if given) and the return value will contain a cut description. CutFlagValue findCut( - const ::basegfx::B2DPolygon& rCandidate, + const B2DPolygon& rCandidate, sal_uInt32 nIndex1, sal_uInt32 nIndex2, CutFlagValue aCutFlags = CUTFLAG_DEFAULT, double* pCut1 = 0L, double* pCut2 = 0L); @@ -172,26 +172,26 @@ namespace basegfx // This version is working with two indexed edges from different // polygons. CutFlagValue findCut( - const ::basegfx::B2DPolygon& rCandidate1, sal_uInt32 nIndex1, - const ::basegfx::B2DPolygon& rCandidate2, sal_uInt32 nIndex2, + const B2DPolygon& rCandidate1, sal_uInt32 nIndex1, + const B2DPolygon& rCandidate2, sal_uInt32 nIndex2, CutFlagValue aCutFlags = CUTFLAG_DEFAULT, double* pCut1 = 0L, double* pCut2 = 0L); // This version works with two points and vectors to define the // edges for the cut test. CutFlagValue findCut( - const ::basegfx::B2DPoint& rEdge1Start, const ::basegfx::B2DVector& rEdge1Delta, - const ::basegfx::B2DPoint& rEdge2Start, const ::basegfx::B2DVector& rEdge2Delta, + const B2DPoint& rEdge1Start, const B2DVector& rEdge1Delta, + const B2DPoint& rEdge2Start, const B2DVector& rEdge2Delta, CutFlagValue aCutFlags = CUTFLAG_DEFAULT, double* pCut1 = 0L, double* pCut2 = 0L); // test if point is on the given edge in range ]0.0..1.0[ without - // the start/end points. If so, return sal_True and put the parameter + // the start/end points. If so, return true and put the parameter // value in pCut (if provided) - sal_Bool isPointOnEdge( - const ::basegfx::B2DPoint& rPoint, - const ::basegfx::B2DPoint& rEdgeStart, - const ::basegfx::B2DVector& rEdgeDelta, + bool isPointOnEdge( + const B2DPoint& rPoint, + const B2DPoint& rEdgeStart, + const B2DVector& rEdgeDelta, double* pCut = 0L); diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx index 1bffaee504f4..2fe9ea8b7063 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygon.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,8 +97,8 @@ namespace basegfx B2DPolyPolygon& operator=(const B2DPolyPolygon& rPolyPolygon); // compare operators - sal_Bool operator==(const B2DPolyPolygon& rPolyPolygon) const; - sal_Bool operator!=(const B2DPolyPolygon& rPolyPolygon) const; + bool operator==(const B2DPolyPolygon& rPolyPolygon) const; + bool operator!=(const B2DPolyPolygon& rPolyPolygon) const; // polygon interface sal_uInt32 count() const; @@ -107,7 +107,7 @@ namespace basegfx void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon); // test for curve - sal_Bool areControlPointsUsed() const; + bool areControlPointsUsed() const; // insert/append single polygon void insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount = 1); @@ -124,14 +124,14 @@ namespace basegfx void clear(); // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); + bool isClosed() const; + void setClosed(bool bNew); // flip polygon direction void flip(); // test if PolyPolygon has double points - sal_Bool hasDoublePoints() const; + bool hasDoublePoints() const; // remove double points, at the begin/end and follow-ups, too void removeDoublePoints(); diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx index 641045afa14e..02e1872a71ba 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygoncutter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygoncutter.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -119,14 +119,14 @@ namespace basegfx void addToList(B2DPolygonNode*& rpList); void remFromList(B2DPolygonNode*& rpList); - sal_Bool getOrientation() const; + bool getOrientation() const; void swapOrientation(); ::basegfx::B2DRange getRange() const; // isInside tests for B2dPoint and other B2DPolygonNode Polygon. On border is not inside as long as - // not sal_True is given in bWithBorder flag. - sal_Bool isInside(const ::basegfx::B2DPoint& rPnt, sal_Bool bWithBorder = sal_False) const; - sal_Bool isPolygonInside(B2DPolygonNode* pPoly, sal_Bool bWithBorder = sal_False) const; + // not true is given in bWithBorder flag. + bool isInside(const ::basegfx::B2DPoint& rPnt, bool bWithBorder = false) const; + bool isPolygonInside(B2DPolygonNode* pPoly, bool bWithBorder = false) const; }; // a type definition to have a vector of pointers to B2DPolygonNodes @@ -149,7 +149,7 @@ namespace basegfx unsigned mbOrientation : 1; public: - B2DSimpleCut(B2DPolygonNode* pL, B2DPolygonNode* pR, sal_Bool bCoOr = sal_False, sal_Bool bOr = sal_True) + B2DSimpleCut(B2DPolygonNode* pL, B2DPolygonNode* pR, bool bCoOr = false, bool bOr = true) : mpLeft(pL), mpRight(pR), mbCorrectOrientation(bCoOr), @@ -161,7 +161,7 @@ namespace basegfx B2DPolygonNode* getLeft() const { return mpLeft; } B2DPolygonNode* getRight() const { return mpRight; } - sal_Bool isSameCut(B2DPolygonNode* pA, B2DPolygonNode* pB) const + bool isSameCut(B2DPolygonNode* pA, B2DPolygonNode* pB) const { return ((pA == mpLeft && pB == mpRight) || (pB == mpLeft && pA == mpRight)); } @@ -190,10 +190,10 @@ namespace basegfx void init(B2DPolygonNode* pNew); const ::basegfx::B2DRange& getRange() const { return maRange; } - sal_Bool getOrientation() const { return mbOrientation; } + bool getOrientation() const { return mbOrientation; } sal_Int32 getDepth() const { return mnDepth; } - void changeDepth(sal_Bool bOrientation); + void changeDepth(bool bOrientation); }; } // end of namespace basegfx @@ -209,22 +209,22 @@ namespace basegfx B2DPolyPolygon maNotClosedPolygons; // help routines - sal_Bool isSamePos(const ::basegfx::B2DPoint& rPntA, const ::basegfx::B2DPoint& rPntB) + bool isSamePos(const ::basegfx::B2DPoint& rPntA, const ::basegfx::B2DPoint& rPntB) { return rPntA.equal(rPntB); } B2DSimpleCut* getExistingCut(B2DSimpleCutVector& rTmpCuts, B2DPolygonNode* pA, B2DPolygonNode* pB); B2DPolygonNode* extractNextPolygon(B2DPolygonNode*& rpList); - sal_Bool isCrossover(B2DPolygonNode* pA, B2DPolygonNode* pB); - sal_Bool isCrossover(B2DSimpleCut* pEnter, B2DSimpleCut* pLeave); + bool isCrossover(B2DPolygonNode* pA, B2DPolygonNode* pB); + bool isCrossover(B2DSimpleCut* pEnter, B2DSimpleCut* pLeave); - sal_Bool isNextSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) + bool isNextSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) { return isSamePos(pA->getNext()->getPosition(), pB->getNext()->getPosition()); } - sal_Bool isPrevSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) + bool isPrevSamePos(B2DPolygonNode* pA, B2DPolygonNode* pB) { return isSamePos(pA->getPrevious()->getPosition(), pB->getPrevious()->getPosition()); } @@ -235,12 +235,12 @@ namespace basegfx void polysToList(B2DPolygonNode*& rpList); void listToPolys(B2DPolygonNode*& rpList); - sal_Bool doRangesIntersect(const ::basegfx::B2DRange& rRange1, const ::basegfx::B2DRange& rRange2) const + bool doRangesIntersect(const ::basegfx::B2DRange& rRange1, const ::basegfx::B2DRange& rRange2) const { return rRange1.overlaps(rRange2); } - sal_Bool doRangesInclude(const ::basegfx::B2DRange& rRange1, const ::basegfx::B2DRange& rRange2) const + bool doRangesInclude(const ::basegfx::B2DRange& rRange1, const ::basegfx::B2DRange& rRange2) const { return rRange1.isInside(rRange2); } @@ -252,7 +252,7 @@ namespace basegfx ~B2DPolyPolygonCutter(); // put/get poly - void addPolyPolygon(const B2DPolyPolygon& rPolyPolygon, sal_Bool bForceOrientation = sal_False); + void addPolyPolygon(const B2DPolyPolygon& rPolyPolygon, bool bForceOrientation = false); void getPolyPolygon(B2DPolyPolygon& rPolyPolygon); // transformations @@ -260,7 +260,7 @@ namespace basegfx void removeDoubleIntersections(); // remove included - void removeIncludedPolygons(sal_Bool bUseOr = sal_True); + void removeIncludedPolygons(bool bUseOr = true); }; } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx index f51f64e9ec23..2e5843c2fbe1 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dpolypolygontools.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -98,12 +98,12 @@ namespace basegfx // in the given PolyPolygon. Only closed polygons are handled. The non-closed // polygons or the ones with less than 3 points are preserved, but not // computed. - // bForceOrientation: If sal_True, the orientations of all contained polygons + // bForceOrientation: If true, the orientations of all contained polygons // is changed to ORIENTATION_POSITIVE before computing. - // bInvertRemove: if sal_True, created polygons which are inside others and + // bInvertRemove: if true, created polygons which are inside others and // have the same orientation are removed (cleanup). void removeIntersections(::basegfx::B2DPolyPolygon& rCandidate, - sal_Bool bForceOrientation = sal_True, sal_Bool bInvertRemove = sal_False); + bool bForceOrientation = true, bool bInvertRemove = false); // Subdivide all contained curves. Use distanceBound value if given. ::basegfx::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::B2DPolyPolygon& rCandidate, double fDistanceBound = 0.0); diff --git a/basegfx/inc/basegfx/polygon/b3dpolygon.hxx b/basegfx/inc/basegfx/polygon/b3dpolygon.hxx index ef18da4035f9..8db419704fce 100644 --- a/basegfx/inc/basegfx/polygon/b3dpolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b3dpolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpolygon.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:53 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,8 +101,8 @@ namespace basegfx B3DPolygon& operator=(const B3DPolygon& rPolygon); // compare operators - sal_Bool operator==(const B3DPolygon& rPolygon) const; - sal_Bool operator!=(const B3DPolygon& rPolygon) const; + bool operator==(const B3DPolygon& rPolygon) const; + bool operator!=(const B3DPolygon& rPolygon) const; // member count sal_uInt32 count() const; @@ -126,14 +126,14 @@ namespace basegfx void clear(); // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); + bool isClosed() const; + void setClosed(bool bNew); // flip polygon direction void flip(); // test if Polygon has double points - sal_Bool hasDoublePoints() const; + bool hasDoublePoints() const; // remove double points, at the begin/end and follow-ups, too void removeDoublePoints(); diff --git a/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx index c3a84e3e8750..875e8d431e13 100644 --- a/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b3dpolypolygon.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dpolypolygon.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:54 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,8 +97,8 @@ namespace basegfx B3DPolyPolygon& operator=(const B3DPolyPolygon& rPolyPolygon); // compare operators - sal_Bool operator==(const B3DPolyPolygon& rPolyPolygon) const; - sal_Bool operator!=(const B3DPolyPolygon& rPolyPolygon) const; + bool operator==(const B3DPolyPolygon& rPolyPolygon) const; + bool operator!=(const B3DPolyPolygon& rPolyPolygon) const; // polygon interface sal_uInt32 count() const; @@ -121,14 +121,14 @@ namespace basegfx void clear(); // closed state - sal_Bool isClosed() const; - void setClosed(sal_Bool bNew); + bool isClosed() const; + void setClosed(bool bNew); // flip polygon direction void flip(); // test if PolyPolygon has double points - sal_Bool hasDoublePoints() const; + bool hasDoublePoints() const; // remove double points, at the begin/end and follow-ups, too void removeDoublePoints(); diff --git a/basegfx/inc/basegfx/range/b1drange.hxx b/basegfx/inc/basegfx/range/b1drange.hxx index 4bb457b28d35..d31e6c65ee73 100644 --- a/basegfx/inc/basegfx/range/b1drange.hxx +++ b/basegfx/inc/basegfx/range/b1drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b1drange.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,18 +66,19 @@ #include <basegfx/range/basicrange.hxx> #endif + namespace basegfx { class B1DRange { - ::basegfx::BasicRange maRange; + ::basegfx::BasicRange< double, DoubleTraits > maRange; public: B1DRange() { } - B1DRange(double fStartValue) + explicit B1DRange(double fStartValue) : maRange(fStartValue) { } @@ -87,7 +88,7 @@ namespace basegfx { } - sal_Bool isEmpty() const + bool isEmpty() const { return maRange.isEmpty(); } @@ -122,17 +123,17 @@ namespace basegfx return maRange.getCenter(); } - sal_Bool isInside(double fValue) const + bool isInside(double fValue) const { return maRange.isInside(fValue); } - sal_Bool isInside(const B1DRange& rRange) const + bool isInside(const B1DRange& rRange) const { return maRange.isInside(rRange.maRange); } - sal_Bool overlaps(const B1DRange& rRange) const + bool overlaps(const B1DRange& rRange) const { return maRange.overlaps(rRange.maRange); } diff --git a/basegfx/inc/basegfx/range/b2drange.hxx b/basegfx/inc/basegfx/range/b2drange.hxx index c30d461f259a..6c0e90fbff56 100644 --- a/basegfx/inc/basegfx/range/b2drange.hxx +++ b/basegfx/inc/basegfx/range/b2drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2drange.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,15 +74,17 @@ namespace basegfx { class B2DRange { - ::basegfx::BasicRange maRangeX; - ::basegfx::BasicRange maRangeY; + typedef ::basegfx::BasicRange< double, DoubleTraits > MyBasicRange; + + MyBasicRange maRangeX; + MyBasicRange maRangeY; public: B2DRange() { } - B2DRange(const B2DTuple& rTuple) + explicit B2DRange(const B2DTuple& rTuple) : maRangeX(rTuple.getX()), maRangeY(rTuple.getY()) { @@ -94,7 +96,7 @@ namespace basegfx { } - sal_Bool isEmpty() const + bool isEmpty() const { return ( maRangeX.isEmpty() @@ -146,7 +148,7 @@ namespace basegfx ); } - sal_Bool isInside(const B2DTuple& rTuple) const + bool isInside(const B2DTuple& rTuple) const { return ( maRangeX.isInside(rTuple.getX()) @@ -154,7 +156,7 @@ namespace basegfx ); } - sal_Bool isInside(const B2DRange& rRange) const + bool isInside(const B2DRange& rRange) const { return ( maRangeX.isInside(rRange.maRangeX) @@ -162,7 +164,7 @@ namespace basegfx ); } - sal_Bool overlaps(const B2DRange& rRange) const + bool overlaps(const B2DRange& rRange) const { return ( maRangeX.overlaps(rRange.maRangeX) @@ -182,6 +184,7 @@ namespace basegfx maRangeY.expand(rRange.maRangeY); } }; + } // end of namespace basegfx #endif // _BGFX_RANGE_B2DRANGE_HXX diff --git a/basegfx/inc/basegfx/range/b3drange.hxx b/basegfx/inc/basegfx/range/b3drange.hxx index a4d5be99f6ec..d5128934e309 100644 --- a/basegfx/inc/basegfx/range/b3drange.hxx +++ b/basegfx/inc/basegfx/range/b3drange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3drange.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,16 +74,18 @@ namespace basegfx { class B3DRange { - ::basegfx::BasicRange maRangeX; - ::basegfx::BasicRange maRangeY; - ::basegfx::BasicRange maRangeZ; + typedef ::basegfx::BasicRange< double, DoubleTraits > MyBasicRange; + + MyBasicRange maRangeX; + MyBasicRange maRangeY; + MyBasicRange maRangeZ; public: B3DRange() { } - B3DRange(const B3DTuple& rTuple) + explicit B3DRange(const B3DTuple& rTuple) : maRangeX(rTuple.getX()), maRangeY(rTuple.getY()), maRangeZ(rTuple.getZ()) @@ -97,7 +99,7 @@ namespace basegfx { } - sal_Bool isEmpty() const + bool isEmpty() const { return ( maRangeX.isEmpty() @@ -156,7 +158,7 @@ namespace basegfx ); } - sal_Bool isInside(const B3DTuple& rTuple) const + bool isInside(const B3DTuple& rTuple) const { return ( maRangeX.isInside(rTuple.getX()) @@ -165,7 +167,7 @@ namespace basegfx ); } - sal_Bool isInside(const B3DRange& rRange) const + bool isInside(const B3DRange& rRange) const { return ( maRangeX.isInside(rRange.maRangeX) @@ -174,7 +176,7 @@ namespace basegfx ); } - sal_Bool overlaps(const B3DRange& rRange) const + bool overlaps(const B3DRange& rRange) const { return ( maRangeX.overlaps(rRange.maRangeX) diff --git a/basegfx/inc/basegfx/range/basicrange.hxx b/basegfx/inc/basegfx/range/basicrange.hxx index 732a95abcf70..120e930c4523 100644 --- a/basegfx/inc/basegfx/range/basicrange.hxx +++ b/basegfx/inc/basegfx/range/basicrange.hxx @@ -2,9 +2,9 @@ * * $RCSfile: basicrange.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:56 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,105 +70,124 @@ #include <float.h> #endif -#define START_MINIMUM_VALUE (DBL_MAX) -#define START_MAXIMUM_VALUE (DBL_MIN) namespace basegfx { - class BasicRange + template< typename T, typename Traits > class BasicRange { protected: - double mfMinimum; - double mfMaximum; + T mnMinimum; + T mnMaximum; public: - void reset() + BasicRange() : + mnMinimum(Traits::initMin()), + mnMaximum(Traits::initMax()) { - mfMinimum = START_MINIMUM_VALUE; - mfMaximum = START_MAXIMUM_VALUE; } - sal_Bool isEmpty() const + BasicRange( T nValue ) : + mnMinimum(nValue), + mnMaximum(nValue) { - return sal_Bool(START_MINIMUM_VALUE == mfMinimum && START_MAXIMUM_VALUE == mfMaximum); } - double getMinimum() const { return mfMinimum; } - double getMaximum() const { return mfMaximum; } - - double getRange() const + BasicRange(const BasicRange& rRange) : + mnMinimum(rRange.mnMinimum), + mnMaximum(rRange.mnMaximum) { - return (mfMaximum - mfMinimum); } - double getCenter() const + void reset() { - return ((mfMaximum + mfMinimum) / 2.0); + mnMinimum = Traits::initMin(); + mnMaximum = Traits::initMax(); } - sal_Bool isInside(double fValue) const + bool isEmpty() const { - return sal_Bool((fValue >= mfMinimum) && (fValue <= mfMaximum)); + return Traits::initMin() == mnMinimum && Traits::initMax() == mnMaximum; } - sal_Bool isInside(const BasicRange& rRange) const - { - return sal_Bool((rRange.getMinimum() >= mfMinimum) && (rRange.getMaximum() <= mfMaximum)); - } + T getMinimum() const { return mnMinimum; } + T getMaximum() const { return mnMaximum; } - sal_Bool overlaps(const BasicRange& rRange) const + double getCenter() const { - return !sal_Bool((rRange.getMaximum() < mfMinimum) || (rRange.getMinimum() > mfMaximum)); + return ((mnMaximum + mnMinimum) / 2.0); } - BasicRange() - : mfMinimum(START_MINIMUM_VALUE), - mfMaximum(START_MAXIMUM_VALUE) + bool isInside(T nValue) const { + return (nValue >= mnMinimum) && (nValue <= mnMaximum); } - BasicRange(double fStartValue) - : mfMinimum(fStartValue), - mfMaximum(fStartValue) + + bool isInside(const BasicRange& rRange) const { + return (rRange.mnMinimum >= mnMinimum) && (rRange.mnMaximum <= mnMaximum); } - BasicRange(const BasicRange& rRange) - : mfMinimum(rRange.getMinimum()), - mfMaximum(rRange.getMaximum()) + + bool overlaps(const BasicRange& rRange) const { + return !((rRange.mnMinimum < mnMinimum) || (rRange.mnMaximum > mnMaximum)); } void operator=(const BasicRange& rRange) { - mfMinimum = rRange.getMinimum(); - mfMaximum = rRange.getMaximum(); + mnMinimum = rRange.mnMinimum; + mnMaximum = rRange.mnMaximum; } - void expand(double fValue) + void expand(T nValue) { - if(fValue < mfMinimum) + if(nValue < mnMinimum) { - mfMinimum = fValue; + mnMinimum = nValue; } - if(fValue > mfMaximum) + if(nValue > mnMaximum) { - mfMaximum = fValue; + mnMaximum = nValue; } } void expand(const BasicRange& rRange) { - if(rRange.getMinimum() < mfMinimum) + if(rRange.mnMinimum < mnMinimum) { - mfMinimum = rRange.getMinimum(); + mnMinimum = rRange.mnMinimum; } - if(rRange.getMaximum() > mfMaximum) + if(rRange.mnMaximum > mnMaximum) { - mfMaximum = rRange.getMaximum(); + mnMaximum = rRange.mnMaximum; } } + + typename Traits::DifferenceType getRange() const + { + return (mnMaximum - mnMinimum); + } + + }; + + // some pre-fabricated traits + struct DoubleTraits + { + static double initMin() { return DBL_MAX; }; + static double initMax() { return DBL_MIN; }; + + typedef double DifferenceType; }; + + struct Int32Traits + { + static sal_Int32 initMin() { return 0x7FFFFFFFL; }; + static sal_Int32 initMax() { return 0x80000000UL; }; + + typedef sal_Int64 DifferenceType; + }; + } // end of namespace basegfx #endif _BGFX_RANGE_BASICRANGE_HXX diff --git a/basegfx/inc/basegfx/tuple/b2dtuple.hxx b/basegfx/inc/basegfx/tuple/b2dtuple.hxx index c16cb545fa9a..e83b8cfc2e7e 100644 --- a/basegfx/inc/basegfx/tuple/b2dtuple.hxx +++ b/basegfx/inc/basegfx/tuple/b2dtuple.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dtuple.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-12-03 09:24:26 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,13 +92,11 @@ namespace basegfx public: /** Create a 2D Tuple - @param fVal - This parameter is used to initialize the coordinate - part of the 2D Tuple. + The tuple is initialized to (0.0, 0.0) */ - B2DTuple(double fVal = 0.0) - : mfX(fVal), - mfY(fVal) + B2DTuple() + : mfX(0.0), + mfY(0.0) {} /** Create a 2D Tuple @@ -174,13 +172,13 @@ namespace basegfx // comparators with tolerance ////////////////////////////////////////////////////////////////////// - sal_Bool equalZero() const; + bool equalZero() const; - sal_Bool equalZero(const double& rfSmallValue) const; + bool equalZero(const double& rfSmallValue) const; - sal_Bool equal(const B2DTuple& rTup) const; + bool equal(const B2DTuple& rTup) const; - sal_Bool equal(const B2DTuple& rTup, const double& rfSmallValue) const; + bool equal(const B2DTuple& rTup, const double& rfSmallValue) const; // operators ////////////////////////////////////////////////////////////////////// @@ -233,12 +231,12 @@ namespace basegfx return B2DTuple(-mfX, -mfY); } - sal_Bool operator==( const B2DTuple& rTup ) const + bool operator==( const B2DTuple& rTup ) const { return equal(rTup); } - sal_Bool operator!=( const B2DTuple& rTup ) const + bool operator!=( const B2DTuple& rTup ) const { return !equal(rTup); } @@ -360,8 +358,9 @@ namespace basegfx inline B2DTuple operator/(double t, const B2DTuple& rTup) { - B2DTuple aNew(rTup); - aNew /= t; + B2DTuple aNew(t, t); + B2DTuple aTmp(rTup); + aNew /= aTmp; return aNew; } } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/tuple/b3dtuple.hxx b/basegfx/inc/basegfx/tuple/b3dtuple.hxx index e57e71b8e3e1..e40794cc41b7 100644 --- a/basegfx/inc/basegfx/tuple/b3dtuple.hxx +++ b/basegfx/inc/basegfx/tuple/b3dtuple.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dtuple.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: aw $ $Date: 2003-12-03 09:24:26 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,10 +62,15 @@ #ifndef _BGFX_TUPLE_B3DTUPLE_HXX #define _BGFX_TUPLE_B3DTUPLE_HXX +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + #ifndef _BGFX_NUMERIC_FTOOLS_HXX #include <basegfx/numeric/ftools.hxx> #endif + namespace basegfx { /** Base class for all Points/Vectors with three double values @@ -89,14 +94,12 @@ namespace basegfx public: /** Create a 3D Tuple - @param fVal - This parameter is used to initialize the coordinate - part of the 3D Tuple. + The tuple is initialized to (0.0, 0.0, 0.0) */ - B3DTuple(double fVal = 0.0) - : mfX(fVal), - mfY(fVal), - mfZ(fVal) + B3DTuple() + : mfX(0.0), + mfY(0.0), + mfZ(0.0) {} /** Create a 3D Tuple @@ -190,7 +193,7 @@ namespace basegfx // comparators with tolerance ////////////////////////////////////////////////////////////////////// - sal_Bool equalZero() const + bool equalZero() const { return (this == &maEmptyTuple || (::basegfx::fTools::equalZero(mfX) @@ -198,7 +201,7 @@ namespace basegfx && ::basegfx::fTools::equalZero(mfZ))); } - sal_Bool equalZero(const double& rfSmallValue) const + bool equalZero(const double& rfSmallValue) const { return (this == &maEmptyTuple || (::basegfx::fTools::equalZero(mfX, rfSmallValue) @@ -206,7 +209,7 @@ namespace basegfx && ::basegfx::fTools::equalZero(mfZ, rfSmallValue))); } - sal_Bool equal(const B3DTuple& rTup) const + bool equal(const B3DTuple& rTup) const { return ( ::basegfx::fTools::equal(mfX, rTup.mfX) && @@ -214,7 +217,7 @@ namespace basegfx ::basegfx::fTools::equal(mfZ, rTup.mfZ)); } - sal_Bool equal(const B3DTuple& rTup, const double& rfSmallValue) const + bool equal(const B3DTuple& rTup, const double& rfSmallValue) const { return ( ::basegfx::fTools::equal(mfX, rTup.mfX, rfSmallValue) && @@ -279,12 +282,12 @@ namespace basegfx return B3DTuple(-mfX, -mfY, -mfZ); } - sal_Bool operator==( const B3DTuple& rTup ) const + bool operator==( const B3DTuple& rTup ) const { return equal(rTup); } - sal_Bool operator!=( const B3DTuple& rTup ) const + bool operator!=( const B3DTuple& rTup ) const { return !equal(rTup); } diff --git a/basegfx/inc/basegfx/vector/b2dvector.hxx b/basegfx/inc/basegfx/vector/b2dvector.hxx index 6b5fe724b3e9..e75238f9b2e7 100644 --- a/basegfx/inc/basegfx/vector/b2dvector.hxx +++ b/basegfx/inc/basegfx/vector/b2dvector.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b2dvector.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:58 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,7 +73,7 @@ namespace basegfx /** Descriptor for the mathematical orientations of two 2D Vectors */ - enum B2DVectorOrientation + enum B2VectorOrientation { /// mathematically positive oriented ORIENTATION_POSITIVE = 0, @@ -87,7 +87,7 @@ namespace basegfx /** Descriptor for the mathematical continuity of two 2D Vectors */ - enum B2DVectorContinuity + enum B2VectorContinuity { /// none CONTINUITY_NONE = 0, @@ -112,12 +112,10 @@ namespace basegfx public: /** Create a 2D Vector - @param fVal - This parameter is used to initialize the coordinate - part of the 2D Vector. + The vector is initialized to (0.0, 0.0) */ - B2DVector(double fVal = 0.0) - : B2DTuple(fVal) + B2DVector() + : B2DTuple() {} /** Create a 2D Vector @@ -146,7 +144,7 @@ namespace basegfx /** constructor with tuple to allow copy-constructing from B2DTuple-based classes */ - B2DVector(const ::basegfx::B2DTuple& rTuple) + explicit B2DVector(const ::basegfx::B2DTuple& rTuple) : B2DTuple(rTuple) {} @@ -198,10 +196,10 @@ namespace basegfx /** Test if this 2D Vector is normalized @return - sal_True if lenth of vector is equal to 1.0 - sal_False else + true if lenth of vector is equal to 1.0 + false else */ - sal_Bool isNormalized() const; + bool isNormalized() const; /** Calculate the Scalar with another 2D Vector @@ -264,7 +262,7 @@ namespace basegfx @return The mathematical Orientation of the two involved 2D Vectors */ - B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB ); + B2VectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB ); /** Calculate a perpendicular 2D Vector to the given one @@ -287,10 +285,10 @@ namespace basegfx The second 2D Vector @return - sal_Bool if the two values are parallel. Also sal_True if + bool if the two values are parallel. Also true if one of the vectors is empty. */ - sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB ); + bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB ); /** Transform vector by given transformation matrix. @@ -304,7 +302,7 @@ namespace basegfx The two given vectors are assumed to describe control points on a common point. Calculate if there is a continuity between them. */ - ::basegfx::B2DVectorContinuity getContinuity( const B2DVector& rBackVector, const B2DVector& rForwardVector ); + B2VectorContinuity getContinuity( const B2DVector& rBackVector, const B2DVector& rForwardVector ); } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/vector/b3dvector.hxx b/basegfx/inc/basegfx/vector/b3dvector.hxx index 094bacfb50a1..adcbc1e1878f 100644 --- a/basegfx/inc/basegfx/vector/b3dvector.hxx +++ b/basegfx/inc/basegfx/vector/b3dvector.hxx @@ -2,9 +2,9 @@ * * $RCSfile: b3dvector.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: aw $ $Date: 2003-11-28 11:17:58 $ + * last change: $Author: thb $ $Date: 2004-01-16 10:34:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,12 +84,10 @@ namespace basegfx public: /** Create a 3D Vector - @param fVal - This parameter is used to initialize the coordinate - part of the 3D Vector. + The vector is initialized to (0.0, 0.0, 0.0) */ - B3DVector(double fVal = 0.0) - : B3DTuple(fVal) + B3DVector() + : B3DTuple() {} /** Create a 3D Vector @@ -122,7 +120,7 @@ namespace basegfx /** constructor with tuple to allow copy-constructing from B3DTuple-based classes */ - B3DVector(const ::basegfx::B3DTuple& rTuple) + explicit B3DVector(const ::basegfx::B3DTuple& rTuple) : B3DTuple(rTuple) {} @@ -243,10 +241,10 @@ namespace basegfx /** Test if this 3D Vector is normalized @return - sal_True if lenth of vector is equal to 1.0 - sal_False else + true if lenth of vector is equal to 1.0 + false else */ - sal_Bool isNormalized() const + bool isNormalized() const { const double fOne(1.0); const double fScalar(scalar(*this)); |