1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _BGFX_POINT_B2DPOINT_HXX
25 #define _BGFX_POINT_B2DPOINT_HXX
26 
27 #include <basegfx/tuple/b2dtuple.hxx>
28 #include <basegfx/point/b2ipoint.hxx>
29 #include <basegfx/basegfxdllapi.h>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 
33 namespace basegfx
34 {
35 	// predeclaration
36 	class B2DHomMatrix;
37 
38 	/** Base Point class with two double values
39 
40 		This class derives all operators and common handling for
41 		a 2D data class from B2DTuple. All necessary extensions
42 		which are special for points will be added here.
43 
44 		@see B2DTuple
45 	*/
46 	class B2DPoint : public ::basegfx::B2DTuple
47 	{
48 	public:
49 		/**	Create a 2D Point
50 
51         	The point is initialized to (0.0, 0.0)
52 		*/
B2DPoint()53 		B2DPoint()
54 		:	B2DTuple()
55 		{}
56 
57 		/**	Create a 2D Point
58 
59 			@param fX
60 			This parameter is used to initialize the X-coordinate
61 			of the 2D Point.
62 
63 			@param fY
64 			This parameter is used to initialize the Y-coordinate
65 			of the 2D Point.
66 		*/
B2DPoint(double fX,double fY)67 		B2DPoint(double fX, double fY)
68 		:	B2DTuple(fX, fY)
69 		{}
70 
71 		/**	Create a copy of a 2D Point
72 
73 			@param rPoint
74 			The 2D Point which will be copied.
75 		*/
B2DPoint(const B2DPoint & rPoint)76 		B2DPoint(const B2DPoint& rPoint)
77 		:	B2DTuple(rPoint)
78 		{}
79 
80 		/**	Create a copy of a 2D Point
81 
82 			@param rPoint
83 			The 2D Point which will be copied.
84 		*/
B2DPoint(const::basegfx::B2IPoint & rPoint)85 		B2DPoint(const ::basegfx::B2IPoint& rPoint)
86 		:	B2DTuple(rPoint)
87 		{}
88 
89 		/** constructor with tuple to allow copy-constructing
90 			from B2DTuple-based classes
91 		*/
B2DPoint(const::basegfx::B2DTuple & rTuple)92 		B2DPoint(const ::basegfx::B2DTuple& rTuple)
93 		:	B2DTuple(rTuple)
94 		{}
95 
~B2DPoint()96 		~B2DPoint()
97 		{}
98 
99 		/** *=operator to allow usage from B2DPoint, too
100 		*/
operator *=(const B2DPoint & rPnt)101 		B2DPoint& operator*=( const B2DPoint& rPnt )
102 		{
103 			mfX *= rPnt.mfX;
104 			mfY *= rPnt.mfY;
105 			return *this;
106 		}
107 
108 		/** *=operator to allow usage from B2DPoint, too
109 		*/
operator *=(double t)110 		B2DPoint& operator*=(double t)
111 		{
112 			mfX *= t;
113 			mfY *= t;
114 			return *this;
115 		}
116 
117 		/** assignment operator to allow assigning the results
118 			of B2DTuple calculations
119 		*/
120 		BASEGFX_DLLPUBLIC B2DPoint& operator=( const ::basegfx::B2DTuple& rPoint );
121 
122 		/** Transform point by given transformation matrix.
123 
124         	The translational components of the matrix are, in
125         	contrast to B2DVector, applied.
126 		*/
127 		BASEGFX_DLLPUBLIC B2DPoint& operator*=( const ::basegfx::B2DHomMatrix& rMat );
128 
getEmptyPoint()129 		static const B2DPoint& getEmptyPoint()
130 		{
131 			return (const B2DPoint&) ::basegfx::B2DTuple::getEmptyTuple();
132 		}
133 	};
134 
135 	// external operators
136 	//////////////////////////////////////////////////////////////////////////
137 
138 	/** Transform B2DPoint by given transformation matrix.
139 
140 		Since this is a Point, translational components of the
141     	matrix are used.
142 	*/
143 	BASEGFX_DLLPUBLIC B2DPoint operator*( const B2DHomMatrix& rMat, const B2DPoint& rPoint );
144 } // end of namespace basegfx
145 
146 //////////////////////////////////////////////////////////////////////////////
147 
148 #endif /* _BGFX_POINT_B2DPOINT_HXX */
149