jsdialog: send message for weld::Menu
[LibreOffice.git] / include / basegfx / range / b2drange.hxx
blobb0f726ac0e369fea654fcfef14ce7d805553a4a6
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>
23 #include <vector>
25 #include <basegfx/basegfxdllapi.h>
26 #include <basegfx/vector/b2dvector.hxx>
27 #include <basegfx/point/b2dpoint.hxx>
28 #include <basegfx/range/basicrange.hxx>
29 #include <basegfx/range/Range2D.hxx>
31 namespace basegfx
33 class B2IRange;
34 class B2DHomMatrix;
36 /** A two-dimensional interval over doubles
38 This is a set of real numbers, bounded by a lower and an upper
39 pair. All inbetween values are included in the set (see also
40 http://en.wikipedia.org/wiki/Interval_%28mathematics%29).
42 The set is closed, i.e. the upper and the lower bound are
43 included (if you're used to the notation - we're talking about
44 [a,b] here, compared to half-open [a,b) or open intervals
45 (a,b)).
47 That means, isInside(val) will return true also for values of
48 val=a or val=b.
50 @see B1DRange
52 class SAL_WARN_UNUSED B2DRange : public Range2D<double, DoubleTraits>
54 public:
55 B2DRange()
56 : Range2D()
59 /// Create degenerate interval consisting of a single point
60 explicit B2DRange(const Tuple2D<ValueType>& rTuple)
61 : Range2D(rTuple)
65 /// Create proper interval between the two given points
66 B2DRange(const Tuple2D<ValueType>& rTuple1,
67 const Tuple2D<ValueType>& rTuple2)
68 : Range2D(rTuple1, rTuple2)
72 B2DRange(ValueType x1, ValueType y1, ValueType x2, ValueType y2)
73 : Range2D(x1, y1, x2, y2)
76 BASEGFX_DLLPUBLIC explicit B2DRange(const B2IRange& rRange);
78 /// get lower bound of the set. returns arbitrary values for empty sets.
79 B2DPoint getMinimum() const
81 return B2DPoint(
82 maRangeX.getMinimum(),
83 maRangeY.getMinimum()
87 /// get upper bound of the set. returns arbitrary values for empty sets.
88 B2DPoint getMaximum() const
90 return B2DPoint(
91 maRangeX.getMaximum(),
92 maRangeY.getMaximum()
96 /// return difference between upper and lower point. returns (0,0) for empty sets.
97 B2DVector getRange() const
99 return B2DVector(
100 maRangeX.getRange(),
101 maRangeY.getRange()
105 /// return center point of set. returns (0,0) for empty sets.
106 B2DPoint getCenter() const
108 return B2DPoint(
109 maRangeX.getCenter(),
110 maRangeY.getCenter()
114 /** Transform Range by given transformation matrix. */
115 BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix& rMatrix);
117 /** Transform Range by given transformation matrix.
119 This operation transforms the Range by transforming all four possible
120 extrema points (corners) of the given range and building a new one.
121 This means that the range will grow evtl. when a shear and/or rotation
122 is part of the transformation.
124 BASEGFX_DLLPUBLIC B2DRange& operator*=( const ::basegfx::B2DHomMatrix& rMat );
126 /** Get a range filled with (0.0, 0.0, 1.0, 1.0) */
127 BASEGFX_DLLPUBLIC static const B2DRange& getUnitB2DRange();
130 /** Transform B2DRange by given transformation matrix (see operator*=())
132 B2DRange operator*( const B2DHomMatrix& rMat, const B2DRange& rB2DRange );
134 /** Round double to nearest integer for 2D range
136 @return the nearest integer for this range
138 BASEGFX_DLLPUBLIC B2IRange fround(const B2DRange& rRange);
140 /** Compute the set difference of the two given ranges
142 This method calculates the symmetric difference (aka XOR)
143 between the two given ranges, and returning the resulting
144 ranges. Thus, the result will contain all areas where one, but
145 not both ranges lie.
147 @param o_rResult
148 Result vector. The up to four difference ranges are returned
149 within this vector
151 @param rFirst
152 The first range
154 @param rSecond
155 The second range
157 @return the input vector
159 BASEGFX_DLLPUBLIC std::vector<B2DRange>& computeSetDifference(
160 std::vector<B2DRange>& o_rResult,
161 const B2DRange& rFirst,
162 const B2DRange& rSecond);
164 /** Write to char stream */
165 template<typename charT, typename traits>
166 inline std::basic_ostream<charT, traits>& operator<<(
167 std::basic_ostream<charT, traits>& stream, const B2DRange& range)
169 return stream << range.getWidth() << "x" << range.getHeight() << "@" << range.getMinimum();
172 } // end of namespace basegfx
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */