LibreOffice Module basegfx (master) 1
b2dsize.hxx
Go to the documentation of this file.
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#pragma once
21
27
28namespace basegfx
29{
30class B2DSize : public Size2D<double>
31{
32public:
34 : Size2D(0.0, 0.0)
35 {
36 }
37
38 B2DSize(double fX, double fY)
39 : Size2D(fX, fY)
40 {
41 }
42
43 B2DSize(Size2D<double> const& rSize)
44 : Size2D(rSize)
45 {
46 }
47
48 explicit B2DSize(B2ISize const& rSize)
49 : Size2D(rSize.getWidth(), rSize.getHeight())
50 {
51 }
52
55 {
56 const double fTempX(rMatrix.get(0, 0) * getWidth() + rMatrix.get(0, 1) * getHeight());
57 const double fTempY(rMatrix.get(1, 0) * getWidth() + rMatrix.get(1, 1) * getHeight());
58 setWidth(fTempX);
59 setHeight(fTempY);
60 return *this;
61 }
62
68
69 double getLength() const
70 {
72 {
73 return fabs(getHeight());
74 }
75 else if (fTools::equalZero(getHeight()))
76 {
77 return fabs(getWidth());
78 }
79
80 return hypot(getWidth(), getHeight());
81 }
82};
83
84template <typename charT, typename traits>
85inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
86 const B2DSize& size)
87{
88 return stream << "(" << size.getWidth() << "," << size.getHeight() << ")";
89}
90
91inline B2DSize operator*(B2DHomMatrix const& rMatrix, B2DSize const& rSize)
92{
93 B2DSize aRes(rSize);
94 aRes *= rMatrix;
95 return aRes;
96}
97
98} // end basegfx
99
100/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
B2DSize(double fX, double fY)
Definition: b2dsize.hxx:38
B2DSize(Size2D< double > const &rSize)
Definition: b2dsize.hxx:43
double getLength() const
Definition: b2dsize.hxx:69
B2DSize & operator*=(const B2DHomMatrix &rMatrix)
Transform size by given transformation matrix.
Definition: b2dsize.hxx:54
B2DSize(B2ISize const &rSize)
Definition: b2dsize.hxx:48
void setHeight(double const &rHeight)
Definition: Size2D.hxx:36
double getWidth() const
Definition: Size2D.hxx:30
void setWidth(double const &rWidth)
Definition: Size2D.hxx:34
double getHeight() const
Definition: Size2D.hxx:32
Reference< XOutputStream > stream
bool equalZero(const T &rfVal)
Compare against small value.
Definition: ftools.hxx:156
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, BColor const &color)
Definition: bcolor.hxx:176
B2DPoint operator*(const ::basegfx::B2DHomMatrix &rMat, const B2DPoint &rPoint)
Definition: b2dpoint.cxx:43
size