fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / basegfx / matrix / b2dhommatrix.hxx
blob30204b91fad5c1e44b16d0abe38f5e0f319f24fa
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 #ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
21 #define _BGFX_MATRIX_B2DHOMMATRIX_HXX
23 #include <sal/types.h>
24 #include <o3tl/cow_wrapper.hxx>
25 #include <basegfx/basegfxdllapi.h>
27 namespace basegfx
29 class B2DTuple;
30 class Impl2DHomMatrix;
32 class BASEGFX_DLLPUBLIC B2DHomMatrix
34 public:
35 typedef o3tl::cow_wrapper< Impl2DHomMatrix > ImplType;
37 private:
38 ImplType mpImpl;
40 public:
41 B2DHomMatrix();
42 B2DHomMatrix(const B2DHomMatrix& rMat);
43 ~B2DHomMatrix();
45 /** constructor to allow setting all needed values for a 3x2 matrix at once. The
46 parameter f_0x1 e.g. is the same as using set(0, 1, f)
48 B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2);
50 double get(sal_uInt16 nRow, sal_uInt16 nColumn) const;
51 void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue);
53 /** allow setting all needed values for a 3x2 matrix in one call. The
54 parameter f_0x1 e.g. is the same as using set(0, 1, f)
56 void set3x2(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2);
58 // test if last line is default to see if last line needs to be
59 // involved in calculations
60 bool isLastLineDefault() const;
62 // reset to a standard matrix
63 bool isIdentity() const;
64 void identity();
66 bool isInvertible() const;
67 bool invert();
69 void rotate(double fRadiant);
71 void translate(double fX, double fY);
73 void scale(double fX, double fY);
75 // Shearing-Matrices
76 void shearX(double fSx);
77 void shearY(double fSy);
79 B2DHomMatrix& operator+=(const B2DHomMatrix& rMat);
80 B2DHomMatrix& operator-=(const B2DHomMatrix& rMat);
82 bool operator==(const B2DHomMatrix& rMat) const;
83 bool operator!=(const B2DHomMatrix& rMat) const;
85 B2DHomMatrix& operator*=(double fValue);
86 B2DHomMatrix& operator/=(double fValue);
88 // matrix multiplication from the left to the local
89 B2DHomMatrix& operator*=(const B2DHomMatrix& rMat);
91 // assignment operator
92 B2DHomMatrix& operator=(const B2DHomMatrix& rMat);
94 // Help routine to decompose given homogen 3x3 matrix to components. A correction of
95 // the components is done to avoid inaccuracies.
96 bool decompose(B2DTuple& rScale, B2DTuple& rTranslate, double& rRotate, double& rShearX) const;
99 // addition, subtraction
100 inline B2DHomMatrix operator+(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB)
102 B2DHomMatrix aSum(rMatA);
103 aSum += rMatB;
104 return aSum;
107 inline B2DHomMatrix operator-(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB)
109 B2DHomMatrix aDiv(rMatA);
110 aDiv -= rMatB;
111 return aDiv;
114 // multiplication, division by a constant
115 inline B2DHomMatrix operator*(const B2DHomMatrix& rMat, double fValue)
117 B2DHomMatrix aNew(rMat);
118 aNew *= fValue;
119 return aNew;
122 inline B2DHomMatrix operator/(const B2DHomMatrix& rMat, double fValue)
124 B2DHomMatrix aNew(rMat);
125 aNew *= 1.0 / fValue;
126 return aNew;
129 inline B2DHomMatrix operator*(const B2DHomMatrix& rMatA, const B2DHomMatrix& rMatB)
131 B2DHomMatrix aMul(rMatB);
132 aMul *= rMatA;
133 return aMul;
135 } // end of namespace basegfx
137 #endif /* _BGFX_MATRIX_B2DHOMMATRIX_HXX */
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */