Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / basegfx / point / b2dpoint.hxx
blob6252352fdebe04ba787137641f8b8b30d869f2b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <ostream>
24 #include <basegfx/tuple/b2dtuple.hxx>
25 #include <basegfx/point/b2ipoint.hxx>
26 #include <basegfx/vector/b2dsize.hxx>
27 #include <basegfx/basegfxdllapi.h>
29 namespace basegfx
31 class B2DHomMatrix;
33 /** Base Point class with two double values
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.
39 @see B2DTuple
41 class SAL_WARN_UNUSED B2DPoint : public ::basegfx::B2DTuple
43 public:
44 /** Create a 2D Point
46 The point is initialized to (0.0, 0.0)
48 B2DPoint()
51 /** Create a 2D Point
53 @param fX
54 This parameter is used to initialize the X-coordinate
55 of the 2D Point.
57 @param fY
58 This parameter is used to initialize the Y-coordinate
59 of the 2D Point.
61 B2DPoint(double fX, double fY)
62 : B2DTuple(fX, fY)
65 /** Create a copy of a 2D Point
67 @param rPoint
68 The 2D Point which will be copied.
70 explicit B2DPoint(const ::basegfx::B2IPoint& rPoint)
71 : B2DTuple(rPoint)
74 /** constructor with tuple to allow copy-constructing
75 from B2DTuple-based classes
77 B2DPoint(Tuple2D<double> const& rTuple)
78 : B2DTuple(rTuple)
81 /** create a point from a size object */
82 explicit B2DPoint(Size2D<double> const& rSize)
83 : B2DTuple(rSize.getWidth(), rSize.getHeight())
86 /** *=operator to allow usage from B2DPoint, too
88 B2DPoint& operator*=( const B2DPoint& rPnt )
90 mfX *= rPnt.mfX;
91 mfY *= rPnt.mfY;
92 return *this;
95 /** *=operator to allow usage from B2DPoint, too
97 B2DPoint& operator*=(double t)
99 mfX *= t;
100 mfY *= t;
101 return *this;
104 /** assignment operator to allow assigning the results
105 of B2DTuple calculations
107 BASEGFX_DLLPUBLIC B2DPoint& operator=(Tuple2D<double>& rPoint)
109 mfX = rPoint.getX();
110 mfY = rPoint.getY();
111 return *this;
114 /** Transform point by given transformation matrix.
116 The translational components of the matrix are, in
117 contrast to B2DVector, applied.
119 BASEGFX_DLLPUBLIC B2DPoint& operator*=( const ::basegfx::B2DHomMatrix& rMat );
121 static const B2DPoint& getEmptyPoint()
123 return static_cast<const B2DPoint&>( ::basegfx::B2DTuple::getEmptyTuple() );
127 // external operators
129 /** Transform B2DPoint by given transformation matrix.
131 Since this is a Point, translational components of the
132 matrix are used.
134 BASEGFX_DLLPUBLIC B2DPoint operator*( const B2DHomMatrix& rMat, const B2DPoint& rPoint );
136 template< typename charT, typename traits >
137 inline std::basic_ostream<charT, traits> & operator <<(
138 std::basic_ostream<charT, traits> & stream, const B2DPoint& point )
140 return stream << "(" << point.getX() << "," << point.getY() << ")";
143 } // end of namespace basegfx
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */