xref: /AOO41X/main/basegfx/inc/basegfx/point/b2dpoint.hxx (revision ce9c7ef7bd056b6da7d6eeebb749fbf2160d647b)
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 
30 //////////////////////////////////////////////////////////////////////////////
31 
32 namespace basegfx
33 {
34     // predeclaration
35     class B2DHomMatrix;
36 
37     /** Base Point class with two double values
38 
39         This class derives all operators and common handling for
40         a 2D data class from B2DTuple. All necessary extensions
41         which are special for points will be added here.
42 
43         @see B2DTuple
44     */
45     class B2DPoint : public ::basegfx::B2DTuple
46     {
47     public:
48         /** Create a 2D Point
49 
50             The point is initialized to (0.0, 0.0)
51         */
B2DPoint()52         B2DPoint()
53         :   B2DTuple()
54         {}
55 
56         /** Create a 2D Point
57 
58             @param fX
59             This parameter is used to initialize the X-coordinate
60             of the 2D Point.
61 
62             @param fY
63             This parameter is used to initialize the Y-coordinate
64             of the 2D Point.
65         */
B2DPoint(double fX,double fY)66         B2DPoint(double fX, double fY)
67         :   B2DTuple(fX, fY)
68         {}
69 
70         /** Create a copy of a 2D Point
71 
72             @param rPoint
73             The 2D Point which will be copied.
74         */
B2DPoint(const B2DPoint & rPoint)75         B2DPoint(const B2DPoint& rPoint)
76         :   B2DTuple(rPoint)
77         {}
78 
79         /** Create a copy of a 2D Point
80 
81             @param rPoint
82             The 2D Point which will be copied.
83         */
B2DPoint(const::basegfx::B2IPoint & rPoint)84         B2DPoint(const ::basegfx::B2IPoint& rPoint)
85         :   B2DTuple(rPoint)
86         {}
87 
88         /** constructor with tuple to allow copy-constructing
89             from B2DTuple-based classes
90         */
B2DPoint(const::basegfx::B2DTuple & rTuple)91         B2DPoint(const ::basegfx::B2DTuple& rTuple)
92         :   B2DTuple(rTuple)
93         {}
94 
~B2DPoint()95         ~B2DPoint()
96         {}
97 
98         /** *=operator to allow usage from B2DPoint, too
99         */
operator *=(const B2DPoint & rPnt)100         B2DPoint& operator*=( const B2DPoint& rPnt )
101         {
102             mfX *= rPnt.mfX;
103             mfY *= rPnt.mfY;
104             return *this;
105         }
106 
107         /** *=operator to allow usage from B2DPoint, too
108         */
operator *=(double t)109         B2DPoint& operator*=(double t)
110         {
111             mfX *= t;
112             mfY *= t;
113             return *this;
114         }
115 
116         /** assignment operator to allow assigning the results
117             of B2DTuple calculations
118         */
119         B2DPoint& operator=( const ::basegfx::B2DTuple& rPoint );
120 
121         /** Transform point by given transformation matrix.
122 
123             The translational components of the matrix are, in
124             contrast to B2DVector, applied.
125         */
126         B2DPoint& operator*=( const ::basegfx::B2DHomMatrix& rMat );
127 
getEmptyPoint()128         static const B2DPoint& getEmptyPoint()
129         {
130             return (const B2DPoint&) ::basegfx::B2DTuple::getEmptyTuple();
131         }
132     };
133 
134     // external operators
135     //////////////////////////////////////////////////////////////////////////
136 
137     /** Transform B2DPoint by given transformation matrix.
138 
139         Since this is a Point, translational components of the
140         matrix are used.
141     */
142     B2DPoint operator*( const B2DHomMatrix& rMat, const B2DPoint& rPoint );
143 } // end of namespace basegfx
144 
145 //////////////////////////////////////////////////////////////////////////////
146 
147 #endif /* _BGFX_POINT_B2DPOINT_HXX */
148