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