Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _BGFX_POINT_B2DPOINT_HXX
21 : #define _BGFX_POINT_B2DPOINT_HXX
22 :
23 : #include <basegfx/tuple/b2dtuple.hxx>
24 : #include <basegfx/point/b2ipoint.hxx>
25 : #include <basegfx/basegfxdllapi.h>
26 :
27 : //////////////////////////////////////////////////////////////////////////////
28 :
29 : namespace basegfx
30 : {
31 : // predeclaration
32 : class B2DHomMatrix;
33 :
34 : /** Base Point class with two double values
35 :
36 : This class derives all operators and common handling for
37 : a 2D data class from B2DTuple. All necessary extensions
38 : which are special for points will be added here.
39 :
40 : @see B2DTuple
41 : */
42 15310 : class SAL_WARN_UNUSED B2DPoint : public ::basegfx::B2DTuple
43 : {
44 : public:
45 : /** Create a 2D Point
46 :
47 : The point is initialized to (0.0, 0.0)
48 : */
49 3348 : B2DPoint()
50 3348 : : B2DTuple()
51 3348 : {}
52 :
53 : /** Create a 2D Point
54 :
55 : @param fX
56 : This parameter is used to initialize the X-coordinate
57 : of the 2D Point.
58 :
59 : @param fY
60 : This parameter is used to initialize the Y-coordinate
61 : of the 2D Point.
62 : */
63 229493 : B2DPoint(double fX, double fY)
64 229493 : : B2DTuple(fX, fY)
65 229493 : {}
66 :
67 : /** Create a copy of a 2D Point
68 :
69 : @param rPoint
70 : The 2D Point which will be copied.
71 : */
72 26883 : B2DPoint(const B2DPoint& rPoint)
73 26883 : : B2DTuple(rPoint)
74 26883 : {}
75 :
76 : /** Create a copy of a 2D Point
77 :
78 : @param rPoint
79 : The 2D Point which will be copied.
80 : */
81 0 : explicit B2DPoint(const ::basegfx::B2IPoint& rPoint)
82 0 : : B2DTuple(rPoint)
83 0 : {}
84 :
85 : /** constructor with tuple to allow copy-constructing
86 : from B2DTuple-based classes
87 : */
88 8624 : B2DPoint(const ::basegfx::B2DTuple& rTuple)
89 8624 : : B2DTuple(rTuple)
90 8624 : {}
91 :
92 937220 : ~B2DPoint()
93 937220 : {}
94 :
95 : /** *=operator to allow usage from B2DPoint, too
96 : */
97 0 : B2DPoint& operator*=( const B2DPoint& rPnt )
98 : {
99 0 : mfX *= rPnt.mfX;
100 0 : mfY *= rPnt.mfY;
101 0 : return *this;
102 : }
103 :
104 : /** *=operator to allow usage from B2DPoint, too
105 : */
106 : B2DPoint& operator*=(double t)
107 : {
108 : mfX *= t;
109 : mfY *= t;
110 : return *this;
111 : }
112 :
113 : /** assignment operator to allow assigning the results
114 : of B2DTuple calculations
115 : */
116 : BASEGFX_DLLPUBLIC B2DPoint& operator=( const ::basegfx::B2DTuple& rPoint );
117 :
118 : /** Transform point by given transformation matrix.
119 :
120 : The translational components of the matrix are, in
121 : contrast to B2DVector, applied.
122 : */
123 : BASEGFX_DLLPUBLIC B2DPoint& operator*=( const ::basegfx::B2DHomMatrix& rMat );
124 :
125 : static const B2DPoint& getEmptyPoint()
126 : {
127 : return (const B2DPoint&) ::basegfx::B2DTuple::getEmptyTuple();
128 : }
129 : };
130 :
131 : // external operators
132 : //////////////////////////////////////////////////////////////////////////
133 :
134 : /** Transform B2DPoint by given transformation matrix.
135 :
136 : Since this is a Point, translational components of the
137 : matrix are used.
138 : */
139 : BASEGFX_DLLPUBLIC B2DPoint operator*( const B2DHomMatrix& rMat, const B2DPoint& rPoint );
140 : } // end of namespace basegfx
141 :
142 : //////////////////////////////////////////////////////////////////////////////
143 :
144 : #endif /* _BGFX_POINT_B2DPOINT_HXX */
145 :
146 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|