xref: /AOO42X/main/basegfx/inc/basegfx/point/b2ipoint.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
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_B2IPOINT_HXX
25 #define _BGFX_POINT_B2IPOINT_HXX
26 
27 #include <basegfx/tuple/b2ituple.hxx>
28 #include <basegfx/basegfxdllapi.h>
29 
30 namespace basegfx
31 {
32     // predeclaration
33     class B2DHomMatrix;
34 
35     /** Base Point class with two sal_Int32 values
36 
37         This class derives all operators and common handling for
38         a 2D data class from B2ITuple. All necessary extensions
39         which are special for points will be added here.
40 
41         @see B2ITuple
42     */
43     class BASEGFX_DLLPUBLIC B2IPoint : public ::basegfx::B2ITuple
44     {
45     public:
46         /** Create a 2D Point
47 
48             The point is initialized to (0, 0)
49         */
B2IPoint()50         B2IPoint()
51         :   B2ITuple()
52         {}
53 
54         /** Create a 2D Point
55 
56             @param nX
57             This parameter is used to initialize the X-coordinate
58             of the 2D Point.
59 
60             @param nY
61             This parameter is used to initialize the Y-coordinate
62             of the 2D Point.
63         */
B2IPoint(sal_Int32 nX,sal_Int32 nY)64         B2IPoint(sal_Int32 nX, sal_Int32 nY)
65         :   B2ITuple(nX, nY)
66         {}
67 
68         /** Create a copy of a 2D Point
69 
70             @param rPoint
71             The 2D Point which will be copied.
72         */
B2IPoint(const B2IPoint & rPoint)73         B2IPoint(const B2IPoint& rPoint)
74         :   B2ITuple(rPoint)
75         {}
76 
77         /** constructor with tuple to allow copy-constructing
78             from B2ITuple-based classes
79         */
B2IPoint(const::basegfx::B2ITuple & rTuple)80         B2IPoint(const ::basegfx::B2ITuple& rTuple)
81         :   B2ITuple(rTuple)
82         {}
83 
~B2IPoint()84         ~B2IPoint()
85         {}
86 
87         /** *=operator to allow usage from B2IPoint, too
88         */
operator *=(const B2IPoint & rPnt)89         B2IPoint& operator*=( const B2IPoint& rPnt )
90         {
91             mnX *= rPnt.mnX;
92             mnY *= rPnt.mnY;
93             return *this;
94         }
95 
96         /** *=operator to allow usage from B2IPoint, too
97         */
operator *=(sal_Int32 t)98         B2IPoint& operator*=(sal_Int32 t)
99         {
100             mnX *= t;
101             mnY *= t;
102             return *this;
103         }
104 
105         /** assignment operator to allow assigning the results
106             of B2ITuple calculations
107         */
108         B2IPoint& operator=( const ::basegfx::B2ITuple& rPoint );
109 
110         /** Transform point by given transformation matrix.
111 
112             The translational components of the matrix are, in
113             contrast to B2DVector, applied.
114         */
115         B2IPoint& operator*=( const ::basegfx::B2DHomMatrix& rMat );
116 
getEmptyPoint()117         static const B2IPoint& getEmptyPoint()
118         {
119             return (const B2IPoint&) ::basegfx::B2ITuple::getEmptyTuple();
120         }
121     };
122 } // end of namespace basegfx
123 
124 #endif /* _BGFX_POINT_B2IPOINT_HXX */
125