Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _BGFX_POINT_B2DPOINT_HXX
30 : : #define _BGFX_POINT_B2DPOINT_HXX
31 : :
32 : : #include <basegfx/tuple/b2dtuple.hxx>
33 : : #include <basegfx/point/b2ipoint.hxx>
34 : : #include <basegfx/basegfxdllapi.h>
35 : :
36 : : //////////////////////////////////////////////////////////////////////////////
37 : :
38 : : namespace basegfx
39 : : {
40 : : // predeclaration
41 : : class B2DHomMatrix;
42 : :
43 : : /** Base Point class with two double values
44 : :
45 : : This class derives all operators and common handling for
46 : : a 2D data class from B2DTuple. All necessary extensions
47 : : which are special for points will be added here.
48 : :
49 : : @see B2DTuple
50 : : */
51 : 11543525 : class B2DPoint : public ::basegfx::B2DTuple
52 : : {
53 : : public:
54 : : /** Create a 2D Point
55 : :
56 : : The point is initialized to (0.0, 0.0)
57 : : */
58 : 187063 : B2DPoint()
59 : 187063 : : B2DTuple()
60 : 187063 : {}
61 : :
62 : : /** Create a 2D Point
63 : :
64 : : @param fX
65 : : This parameter is used to initialize the X-coordinate
66 : : of the 2D Point.
67 : :
68 : : @param fY
69 : : This parameter is used to initialize the Y-coordinate
70 : : of the 2D Point.
71 : : */
72 : 5229491 : B2DPoint(double fX, double fY)
73 : 5229491 : : B2DTuple(fX, fY)
74 : 5229491 : {}
75 : :
76 : : /** Create a copy of a 2D Point
77 : :
78 : : @param rPoint
79 : : The 2D Point which will be copied.
80 : : */
81 : 99704668 : B2DPoint(const B2DPoint& rPoint)
82 : 99704668 : : B2DTuple(rPoint)
83 : 99704668 : {}
84 : :
85 : : /** Create a copy of a 2D Point
86 : :
87 : : @param rPoint
88 : : The 2D Point which will be copied.
89 : : */
90 : : explicit B2DPoint(const ::basegfx::B2IPoint& rPoint)
91 : : : B2DTuple(rPoint)
92 : : {}
93 : :
94 : : /** constructor with tuple to allow copy-constructing
95 : : from B2DTuple-based classes
96 : : */
97 : 695187 : B2DPoint(const ::basegfx::B2DTuple& rTuple)
98 : 695187 : : B2DTuple(rTuple)
99 : 695187 : {}
100 : :
101 : 72934846 : ~B2DPoint()
102 : 72934846 : {}
103 : :
104 : : /** *=operator to allow usage from B2DPoint, too
105 : : */
106 : : B2DPoint& operator*=( const B2DPoint& rPnt )
107 : : {
108 : : mfX *= rPnt.mfX;
109 : : mfY *= rPnt.mfY;
110 : : return *this;
111 : : }
112 : :
113 : : /** *=operator to allow usage from B2DPoint, too
114 : : */
115 : : B2DPoint& operator*=(double t)
116 : : {
117 : : mfX *= t;
118 : : mfY *= t;
119 : : return *this;
120 : : }
121 : :
122 : : /** assignment operator to allow assigning the results
123 : : of B2DTuple calculations
124 : : */
125 : : BASEGFX_DLLPUBLIC B2DPoint& operator=( const ::basegfx::B2DTuple& rPoint );
126 : :
127 : : /** Transform point by given transformation matrix.
128 : :
129 : : The translational components of the matrix are, in
130 : : contrast to B2DVector, applied.
131 : : */
132 : : BASEGFX_DLLPUBLIC B2DPoint& operator*=( const ::basegfx::B2DHomMatrix& rMat );
133 : :
134 : 10925 : static const B2DPoint& getEmptyPoint()
135 : : {
136 : 10925 : return (const B2DPoint&) ::basegfx::B2DTuple::getEmptyTuple();
137 : : }
138 : : };
139 : :
140 : : // external operators
141 : : //////////////////////////////////////////////////////////////////////////
142 : :
143 : : /** Transform B2DPoint by given transformation matrix.
144 : :
145 : : Since this is a Point, translational components of the
146 : : matrix are used.
147 : : */
148 : : BASEGFX_DLLPUBLIC B2DPoint operator*( const B2DHomMatrix& rMat, const B2DPoint& rPoint );
149 : : } // end of namespace basegfx
150 : :
151 : : //////////////////////////////////////////////////////////////////////////////
152 : :
153 : : #endif /* _BGFX_POINT_B2DPOINT_HXX */
154 : :
155 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|