LibreOffice Module basegfx (master) 1
b1drange.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
23
24
25namespace basegfx
26{
27
43 {
45
46 public:
48
50 explicit B1DRange(double fStartValue)
51 : maRange(fStartValue)
52 {
53 }
54
56 B1DRange(double fStartValue1, double fStartValue2)
57 : maRange(fStartValue1)
58 {
59 expand(fStartValue2);
60 }
61
67 bool isEmpty() const
68 {
69 return maRange.isEmpty();
70 }
71
72 bool operator==( const B1DRange& rRange ) const
73 {
74 return (maRange == rRange.maRange);
75 }
76
77 bool operator!=( const B1DRange& rRange ) const
78 {
79 return (maRange != rRange.maRange);
80 }
81
83 double getMinimum() const
84 {
85 return maRange.getMinimum();
86 }
87
89 double getMaximum() const
90 {
91 return maRange.getMaximum();
92 }
93
95 double getRange() const
96 {
97 return maRange.getRange();
98 }
99
101 double getCenter() const
102 {
103 return maRange.getCenter();
104 }
105
107 bool isInside(double fValue) const
108 {
109 return maRange.isInside(fValue);
110 }
111
113 bool overlaps(const B1DRange& rRange) const
114 {
115 return maRange.overlaps(rRange.maRange);
116 }
117
119 bool overlapsMore(const B1DRange& rRange) const
120 {
121 return maRange.overlapsMore(rRange.maRange);
122 }
123
125 void expand(double fValue)
126 {
127 maRange.expand(fValue);
128 }
129
131 void expand(const B1DRange& rRange)
132 {
133 maRange.expand(rRange.maRange);
134 }
135
137 void intersect(const B1DRange& rRange)
138 {
139 maRange.intersect(rRange.maRange);
140 }
141
143 double clamp(double fValue) const
144 {
145 return maRange.clamp(fValue);
146 }
147 };
148
150 template<typename charT, typename traits>
151 inline std::basic_ostream<charT, traits>& operator<<(
152 std::basic_ostream<charT, traits>& stream, const B1DRange& range)
153 {
154 return stream << "[" << range.getMinimum() << ", " << range.getMaximum() << "]";
155 }
156
157} // end of namespace basegfx
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A one-dimensional interval over doubles.
Definition: b1drange.hxx:43
double getRange() const
return difference between upper and lower value. returns 0 for empty sets.
Definition: b1drange.hxx:95
bool operator!=(const B1DRange &rRange) const
Definition: b1drange.hxx:77
bool isEmpty() const
Check if the interval set is empty.
Definition: b1drange.hxx:67
bool overlaps(const B1DRange &rRange) const
yields true if rRange at least partly inside set
Definition: b1drange.hxx:113
B1DRange(double fStartValue1, double fStartValue2)
Create proper interval between the two given double values.
Definition: b1drange.hxx:56
void expand(double fValue)
add fValue to the set, expanding as necessary
Definition: b1drange.hxx:125
bool overlapsMore(const B1DRange &rRange) const
yields true if overlaps(rRange) does, and the overlap is larger than infinitesimal
Definition: b1drange.hxx:119
void expand(const B1DRange &rRange)
add rRange to the set, expanding as necessary
Definition: b1drange.hxx:131
B1DRange(double fStartValue)
Create degenerate interval consisting of a single double number.
Definition: b1drange.hxx:50
double clamp(double fValue) const
clamp value on range
Definition: b1drange.hxx:143
double getMinimum() const
get lower bound of the set. returns arbitrary values for empty sets.
Definition: b1drange.hxx:83
double getCenter() const
return middle of upper and lower value. returns 0 for empty sets.
Definition: b1drange.hxx:101
::basegfx::BasicRange< double, DoubleTraits > maRange
Definition: b1drange.hxx:44
double getMaximum() const
get upper bound of the set. returns arbitrary values for empty sets.
Definition: b1drange.hxx:89
bool isInside(double fValue) const
yields true if value is contained in set
Definition: b1drange.hxx:107
void intersect(const B1DRange &rRange)
calc set intersection
Definition: b1drange.hxx:137
bool operator==(const B1DRange &rRange) const
Definition: b1drange.hxx:72
bool overlaps(const BasicRange &rRange) const
Definition: basicrange.hxx:108
T clamp(T nValue) const
Definition: basicrange.hxx:250
bool isEmpty() const
Definition: basicrange.hxx:57
bool overlapsMore(const BasicRange &rRange) const
Definition: basicrange.hxx:127
bool isInside(T nValue) const
Definition: basicrange.hxx:77
double getCenter() const
Definition: basicrange.hxx:65
void intersect(const BasicRange &rRange)
Definition: basicrange.hxx:205
T getMaximum() const
Definition: basicrange.hxx:63
T getMinimum() const
Definition: basicrange.hxx:62
void expand(T nValue)
Definition: basicrange.hxx:152
Traits::DifferenceType getRange() const
Definition: basicrange.hxx:276
Reference< XOutputStream > stream
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, BColor const &color)
Definition: bcolor.hxx:176