Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
Scroom::Utils::Rectangle< T > Class Template Reference

#include <rectangle.hh>

Inheritance diagram for Scroom::Utils::Rectangle< T >:
Inheritance graph
Collaboration diagram for Scroom::Utils::Rectangle< T >:
Collaboration graph

Public Types

using value_type = T
 
using xy_type = Point< T >
 

Public Member Functions

 Rectangle ()=default
 
 Rectangle (value_type x_, value_type y_, value_type width_, value_type height_)
 
 Rectangle (const Segment< value_type > &horizontally_, const Segment< value_type > &vertically_)
 
 Rectangle (const cairo_rectangle_int_t &rect)
 
template<bool T_is_int = std::is_same_v<int, std::remove_cv_t<T>>>
 Rectangle (std::enable_if_t<!T_is_int, Rectangle< int > const & > rect)
 
cairo_rectangle_int_t toGdkRectangle () const
 
Rectangle moveTo (xy_type const &other) const
 
Rectangle moveTo (value_type const &x, value_type const &y) const
 
bool contains (xy_type const &other) const
 
bool contains (const Rectangle &other) const
 
bool intersects (const Rectangle &other) const
 
void reduceSizeToMultipleOf (value_type size)
 
Rectangle intersection (const Rectangle &other) const
 
template<typename U >
Rectangle< std::common_type_t< T, U > > intersection (const Rectangle< U > &other) const
 
value_type getTop () const
 
value_type getLeft () const
 
value_type getBottom () const
 
value_type getRight () const
 
void setTop (value_type v)
 
void setLeft (value_type v)
 
void setBottom (value_type v)
 
void setRight (value_type v)
 
value_type getWidth () const
 
value_type getHeight () const
 
value_type x () const
 
value_type y () const
 
value_type width () const
 
value_type height () const
 
xy_type getTopLeft () const
 
xy_type getTopRight () const
 
xy_type getBottomLeft () const
 
xy_type getBottomRight () const
 
bool isEmpty () const
 
Rectangle< value_typeleftOf (value_type v) const
 
Rectangle< value_typerightOf (value_type v) const
 
Rectangle< value_typeabove (value_type v) const
 
Rectangle< value_typebelow (value_type v) const
 
Rectangle< value_typeleftOf (Rectangle< value_type > const &r) const
 
Rectangle< value_typerightOf (Rectangle< value_type > const &r) const
 
Rectangle< value_typeabove (Rectangle< value_type > const &r) const
 
Rectangle< value_typebelow (Rectangle< value_type > const &r) const
 
bool operator== (const Rectangle &other) const
 
bool operator!= (const Rectangle &other) const
 
Rectangle< value_type > & operator+= (xy_type const &other)
 
Rectangle< value_type > & operator-= (xy_type const &other)
 
Rectangle< value_type > & operator*= (value_type other)
 
Rectangle< value_type > & operator*= (xy_type const &other)
 
Rectangle< value_type > & operator/= (value_type other)
 
Rectangle< value_type > & operator/= (xy_type const &other)
 
const Segment< value_type > & getHorizontally () const
 
const Segment< value_type > & getVertically () const
 
void setSize (xy_type const &s)
 
xy_type getSize () const
 
template<typename U >
Rectangle< U > to () const
 

Private Attributes

Segment< value_typehorizontally
 
Segment< value_typevertically
 

Member Typedef Documentation

◆ value_type

template<typename T >
using Scroom::Utils::Rectangle< T >::value_type = T

◆ xy_type

template<typename T >
using Scroom::Utils::Rectangle< T >::xy_type = Point<T>

Constructor & Destructor Documentation

◆ Rectangle() [1/5]

template<typename T >
Scroom::Utils::Rectangle< T >::Rectangle ( )
default

Referenced by Scroom::Utils::Rectangle< T >::intersection(), and Scroom::Utils::Rectangle< T >::moveTo().

Here is the caller graph for this function:

◆ Rectangle() [2/5]

template<typename T >
Scroom::Utils::Rectangle< T >::Rectangle ( value_type  x_,
value_type  y_,
value_type  width_,
value_type  height_ 
)
inline
37 : horizontally(x_, width_)
38 , vertically(y_, height_)
39 {
40 }
Segment< value_type > vertically
Definition rectangle.hh:280
Segment< value_type > horizontally
Definition rectangle.hh:279

◆ Rectangle() [3/5]

template<typename T >
Scroom::Utils::Rectangle< T >::Rectangle ( const Segment< value_type > &  horizontally_,
const Segment< value_type > &  vertically_ 
)
inline
43 : horizontally(horizontally_)
44 , vertically(vertically_)
45 {
46 }

◆ Rectangle() [4/5]

template<typename T >
Scroom::Utils::Rectangle< T >::Rectangle ( const cairo_rectangle_int_t &  rect)
inlineexplicit
49 : horizontally(rect.x, rect.width)
50 , vertically(rect.y, rect.height)
51 {
52 }
const auto rect
Definition rectangletests.cc:335

◆ Rectangle() [5/5]

template<typename T >
template<bool T_is_int = std::is_same_v<int, std::remove_cv_t<T>>>
Scroom::Utils::Rectangle< T >::Rectangle ( std::enable_if_t<!T_is_int, Rectangle< int > const & >  rect)
inlineexplicit

Implicit conversion from Rectangle<int> to Rectangle<T>. If T!=int

57 : horizontally(rect.getHorizontally())
58 , vertically(rect.getVertically())
59 {
60 }

Member Function Documentation

◆ above() [1/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::above ( Rectangle< value_type > const &  r) const
inline
184 {
185 if(r.isEmpty())
186 {
187 return r;
188 }
189
190 return Rectangle<value_type>(horizontally.intersection(r.horizontally), vertically.before(r.vertically.getStart()));
191 }
bool isEmpty() const
Definition rectangle.hh:141
Segment< value_type > before(value_type v) const
Definition linearsegment.hh:107
value_type getStart() const
Definition linearsegment.hh:133
Segment< value_type > intersection(const Segment< value_type > &other) const
Definition linearsegment.hh:91
Scroom::Utils::Rectangle< double > const r
Definition transformpresentation_test.cc:65
Here is the call graph for this function:

◆ above() [2/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::above ( value_type  v) const
inline
154 {
155 return Rectangle<value_type>(horizontally, vertically.before(v));
156 }
Here is the call graph for this function:

◆ below() [1/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::below ( Rectangle< value_type > const &  r) const
inline
194 {
195 if(r.isEmpty())
196 {
197 return r;
198 }
199
200 return Rectangle<value_type>(horizontally.intersection(r.horizontally), vertically.after(r.vertically.getEnd()));
201 }
value_type getEnd() const
Definition linearsegment.hh:135
Segment< value_type > after(value_type v) const
Definition linearsegment.hh:120
Here is the call graph for this function:

◆ below() [2/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::below ( value_type  v) const
inline
159 {
160 return Rectangle<value_type>(horizontally, vertically.after(v));
161 }

Referenced by drawOutOfBoundsWithoutBackground().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains() [1/2]

template<typename T >
bool Scroom::Utils::Rectangle< T >::contains ( const Rectangle< T > &  other) const
inline
80 {
81 return horizontally.contains(other.horizontally) && vertically.contains(other.vertically);
82 }
bool contains(value_type p) const
Definition linearsegment.hh:77
Here is the call graph for this function:

◆ contains() [2/2]

template<typename T >
bool Scroom::Utils::Rectangle< T >::contains ( xy_type const &  other) const
inline
75 {
76 return horizontally.contains(other.x) && vertically.contains(other.y);
77 }
Here is the call graph for this function:

◆ getBottom()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::getBottom ( ) const
inline
112{ return vertically.getEnd(); }

Referenced by drawOutOfBoundsWithoutBackground(), PipetteCommonOperationsCMYK::sumPixelValues(), and PipetteCommonOperationsRGB::sumPixelValues().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBottomLeft()

template<typename T >
xy_type Scroom::Utils::Rectangle< T >::getBottomLeft ( ) const
inline
Point< T > xy_type
Definition rectangle.hh:32

Referenced by Scroom::Utils::anonymous_namespace{tweak-view.cc}::corner_getter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBottomRight()

template<typename T >
xy_type Scroom::Utils::Rectangle< T >::getBottomRight ( ) const
inline

Referenced by Scroom::Utils::anonymous_namespace{tweak-view.cc}::corner_getter(), and Scroom::Utils::roundCorners().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHeight()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::getHeight ( ) const
inline
123{ return vertically.getSize(); }
value_type getSize() const
Definition linearsegment.hh:137

Referenced by fmt::formatter< Scroom::Utils::Rectangle< T > >::format(), Scroom::Utils::Rectangle< T >::height(), Scroom::Utils::operator<<(), setClip(), Scroom::TiledBitmap::to_metadata(), and Scroom::Utils::Rectangle< T >::toGdkRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHorizontally()

template<typename T >
const Segment< value_type > & Scroom::Utils::Rectangle< T >::getHorizontally ( ) const
inline
257{ return horizontally; }

Referenced by Scroom::Utils::center(), and Scroom::Utils::roundOutward().

Here is the caller graph for this function:

◆ getLeft()

◆ getRight()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::getRight ( ) const
inline
114{ return horizontally.getEnd(); }

Referenced by PipetteCommonOperationsCMYK::sumPixelValues(), and PipetteCommonOperationsRGB::sumPixelValues().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSize()

template<typename T >
xy_type Scroom::Utils::Rectangle< T >::getSize ( ) const
inline
Here is the call graph for this function:

◆ getTop()

◆ getTopLeft()

◆ getTopRight()

template<typename T >
xy_type Scroom::Utils::Rectangle< T >::getTopRight ( ) const
inline

Referenced by Scroom::Utils::anonymous_namespace{tweak-view.cc}::corner_getter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVertically()

template<typename T >
const Segment< value_type > & Scroom::Utils::Rectangle< T >::getVertically ( ) const
inline
259{ return vertically; }

Referenced by Scroom::Utils::center(), and Scroom::Utils::roundOutward().

Here is the caller graph for this function:

◆ getWidth()

◆ height()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::height ( ) const
inline
131{ return getHeight(); }
value_type getHeight() const
Definition rectangle.hh:123

Referenced by TiledBitmap::drawTile(), operator<<(), traceRectangleContour(), View::updateScrollbars(), and View::updateZoom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersection() [1/2]

template<typename T >
Rectangle Scroom::Utils::Rectangle< T >::intersection ( const Rectangle< T > &  other) const
inline
96 {
97 return Rectangle(horizontally.intersection(other.horizontally), vertically.intersection(other.vertically));
98 }

Referenced by PipetteHandler::computeValues(), anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getPixelAverages(), Scroom::Utils::Rectangle< T >::intersection(), and TiledBitmap::redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersection() [2/2]

template<typename T >
template<typename U >
Rectangle< std::common_type_t< T, U > > Scroom::Utils::Rectangle< T >::intersection ( const Rectangle< U > &  other) const
inline
102 {
103 using R = std::common_type_t<T, U>;
104
105 return Rectangle<R>(*this).intersection(Rectangle<R>(other));
106 }
Here is the call graph for this function:

◆ intersects()

template<typename T >
bool Scroom::Utils::Rectangle< T >::intersects ( const Rectangle< T > &  other) const
inline
85 {
86 return horizontally.intersects(other.horizontally) && vertically.intersects(other.vertically);
87 }
bool intersects(const Segment< value_type > &other) const
Definition linearsegment.hh:84
Here is the call graph for this function:

◆ isEmpty()

template<typename T >
bool Scroom::Utils::Rectangle< T >::isEmpty ( ) const
inline

◆ leftOf() [1/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::leftOf ( Rectangle< value_type > const &  r) const
inline
164 {
165 if(r.isEmpty())
166 {
167 return r;
168 }
169
170 return Rectangle<value_type>(horizontally.before(r.horizontally.getStart()), vertically.intersection(r.vertically));
171 }
Here is the call graph for this function:

◆ leftOf() [2/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::leftOf ( value_type  v) const
inline
144 {
145 return Rectangle<value_type>(horizontally.before(v), vertically);
146 }
Here is the call graph for this function:

◆ moveTo() [1/2]

template<typename T >
Rectangle Scroom::Utils::Rectangle< T >::moveTo ( value_type const &  x,
value_type const &  y 
) const
inline
70 {
72 }
value_type y() const
Definition rectangle.hh:127
value_type x() const
Definition rectangle.hh:125
Segment moveTo(value_type p) const
Definition linearsegment.hh:75
Here is the call graph for this function:

◆ moveTo() [2/2]

template<typename T >
Rectangle Scroom::Utils::Rectangle< T >::moveTo ( xy_type const &  other) const
inline
67{ return moveTo(other.x, other.y); }
Rectangle moveTo(xy_type const &other) const
Definition rectangle.hh:67

Referenced by drawOutOfBoundsWithBackground(), and Scroom::Utils::Rectangle< T >::moveTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

template<typename T >
bool Scroom::Utils::Rectangle< T >::operator!= ( const Rectangle< T > &  other) const
inline
218{ return !(*this == other); }

◆ operator*=() [1/2]

template<typename T >
Rectangle< value_type > & Scroom::Utils::Rectangle< T >::operator*= ( value_type  other)
inline
230 {
231 horizontally *= other;
232 vertically *= other;
233 return *this;
234 }

◆ operator*=() [2/2]

template<typename T >
Rectangle< value_type > & Scroom::Utils::Rectangle< T >::operator*= ( xy_type const &  other)
inline
237 {
238 horizontally *= other.x;
239 vertically *= other.y;
240 return *this;
241 }

◆ operator+=()

template<typename T >
Rectangle< value_type > & Scroom::Utils::Rectangle< T >::operator+= ( xy_type const &  other)
inline
221 {
222 horizontally += other.x;
223 vertically += other.y;
224 return *this;
225 }

◆ operator-=()

template<typename T >
Rectangle< value_type > & Scroom::Utils::Rectangle< T >::operator-= ( xy_type const &  other)
inline
227{ return *this += -other; }

◆ operator/=() [1/2]

template<typename T >
Rectangle< value_type > & Scroom::Utils::Rectangle< T >::operator/= ( value_type  other)
inline
244 {
245 horizontally /= other;
246 vertically /= other;
247 return *this;
248 }

◆ operator/=() [2/2]

template<typename T >
Rectangle< value_type > & Scroom::Utils::Rectangle< T >::operator/= ( xy_type const &  other)
inline
251 {
252 horizontally /= other.x;
253 vertically /= other.y;
254 return *this;
255 }

◆ operator==()

template<typename T >
bool Scroom::Utils::Rectangle< T >::operator== ( const Rectangle< T > &  other) const
inline
204 {
205 if(isEmpty() != other.isEmpty())
206 {
207 return false;
208 }
209
210 if(isEmpty())
211 {
212 return true;
213 }
214
215 return horizontally == other.horizontally && vertically == other.vertically;
216 }
Here is the call graph for this function:

◆ reduceSizeToMultipleOf()

template<typename T >
void Scroom::Utils::Rectangle< T >::reduceSizeToMultipleOf ( value_type  size)
inline
90 {
93 }
void reduceSizeToMultipleOf(value_type m)
Definition linearsegment.hh:89
Here is the call graph for this function:

◆ rightOf() [1/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::rightOf ( Rectangle< value_type > const &  r) const
inline
174 {
175 if(r.isEmpty())
176 {
177 return r;
178 }
179
180 return Rectangle<value_type>(horizontally.after(r.horizontally.getEnd()), vertically.intersection(r.vertically));
181 }
Here is the call graph for this function:

◆ rightOf() [2/2]

template<typename T >
Rectangle< value_type > Scroom::Utils::Rectangle< T >::rightOf ( value_type  v) const
inline
149 {
150 return Rectangle<value_type>(horizontally.after(v), vertically);
151 }

Referenced by drawOutOfBoundsWithoutBackground().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBottom()

template<typename T >
void Scroom::Utils::Rectangle< T >::setBottom ( value_type  v)
inline
118{ vertically.setEnd(v); }
void setEnd(value_type n)
Definition linearsegment.hh:192
Here is the call graph for this function:

◆ setLeft()

template<typename T >
void Scroom::Utils::Rectangle< T >::setLeft ( value_type  v)
inline
void setStart(value_type n)
Definition linearsegment.hh:185
Here is the call graph for this function:

◆ setRight()

template<typename T >
void Scroom::Utils::Rectangle< T >::setRight ( value_type  v)
inline
119{ horizontally.setEnd(v); }
Here is the call graph for this function:

◆ setSize()

template<typename T >
void Scroom::Utils::Rectangle< T >::setSize ( xy_type const &  s)
inline
262 {
265 }
void setSize(value_type n)
Definition linearsegment.hh:191
BitmapSurface::Ptr const s
Definition transformpresentation_test.cc:70
Here is the call graph for this function:

◆ setTop()

template<typename T >
void Scroom::Utils::Rectangle< T >::setTop ( value_type  v)
inline
116{ vertically.setStart(v); }
Here is the call graph for this function:

◆ to()

template<typename T >
template<typename U >
Rectangle< U > Scroom::Utils::Rectangle< T >::to ( ) const
inline
271 {
272 return {
273 horizontally.template to<U>(),
274 vertically.template to<U>(),
275 };
276 }

◆ toGdkRectangle()

template<typename T >
cairo_rectangle_int_t Scroom::Utils::Rectangle< T >::toGdkRectangle ( ) const
inline
63 {
65 }
value_type getTop() const
Definition rectangle.hh:108
value_type getWidth() const
Definition rectangle.hh:121
value_type getLeft() const
Definition rectangle.hh:110
cairo_rectangle_int_t createCairoIntRectangle(int x, int y, int width, int height)
Definition gtk-helpers.hh:71

Referenced by TransparentOverlayViewInfo::redraw(), and ExamplePresentation::redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ width()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::width ( ) const
inline

◆ x()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::x ( ) const
inline
125{ return getLeft(); }

Referenced by Operations1bpp::draw(), Operations8bpp::draw(), Operations::draw(), TiledBitmap::drawTile(), Scroom::Utils::Rectangle< T >::moveTo(), operator<<(), traceRectangleContour(), and View::updateScrollbars().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ y()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::y ( ) const
inline
127{ return getTop(); }

Referenced by Operations1bpp::draw(), Operations8bpp::draw(), Operations::draw(), TiledBitmap::drawTile(), Scroom::Utils::Rectangle< T >::moveTo(), operator<<(), traceRectangleContour(), and View::updateScrollbars().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ horizontally

template<typename T >
Segment<value_type> Scroom::Utils::Rectangle< T >::horizontally
private

Referenced by Scroom::Utils::Rectangle< T >::above(), Scroom::Utils::Rectangle< T >::above(), Scroom::Utils::Rectangle< T >::below(), Scroom::Utils::Rectangle< T >::below(), Scroom::Utils::Rectangle< T >::contains(), Scroom::Utils::Rectangle< T >::contains(), Scroom::Utils::Rectangle< T >::getBottomLeft(), Scroom::Utils::Rectangle< T >::getBottomRight(), Scroom::Utils::Rectangle< T >::getHorizontally(), Scroom::Utils::Rectangle< T >::getLeft(), Scroom::Utils::Rectangle< T >::getRight(), Scroom::Utils::Rectangle< T >::getSize(), Scroom::Utils::Rectangle< T >::getTopLeft(), Scroom::Utils::Rectangle< T >::getTopRight(), Scroom::Utils::Rectangle< T >::getWidth(), Scroom::Utils::Rectangle< T >::intersection(), Scroom::Utils::Rectangle< T >::intersects(), Scroom::Utils::Rectangle< T >::isEmpty(), Scroom::Utils::Rectangle< T >::leftOf(), Scroom::Utils::Rectangle< T >::leftOf(), Scroom::Utils::Rectangle< T >::moveTo(), Scroom::Utils::Rectangle< T >::operator*=(), Scroom::Utils::Rectangle< T >::operator*=(), Scroom::Utils::Rectangle< T >::operator+=(), Scroom::Utils::Rectangle< T >::operator/=(), Scroom::Utils::Rectangle< T >::operator/=(), Scroom::Utils::Rectangle< T >::operator==(), Scroom::Utils::Rectangle< T >::reduceSizeToMultipleOf(), Scroom::Utils::Rectangle< T >::rightOf(), Scroom::Utils::Rectangle< T >::rightOf(), Scroom::Utils::Rectangle< T >::setLeft(), Scroom::Utils::Rectangle< T >::setRight(), Scroom::Utils::Rectangle< T >::setSize(), and Scroom::Utils::Rectangle< T >::to().

◆ vertically

template<typename T >
Segment<value_type> Scroom::Utils::Rectangle< T >::vertically
private

Referenced by Scroom::Utils::Rectangle< T >::above(), Scroom::Utils::Rectangle< T >::above(), Scroom::Utils::Rectangle< T >::below(), Scroom::Utils::Rectangle< T >::below(), Scroom::Utils::Rectangle< T >::contains(), Scroom::Utils::Rectangle< T >::contains(), Scroom::Utils::Rectangle< T >::getBottom(), Scroom::Utils::Rectangle< T >::getBottomLeft(), Scroom::Utils::Rectangle< T >::getBottomRight(), Scroom::Utils::Rectangle< T >::getHeight(), Scroom::Utils::Rectangle< T >::getSize(), Scroom::Utils::Rectangle< T >::getTop(), Scroom::Utils::Rectangle< T >::getTopLeft(), Scroom::Utils::Rectangle< T >::getTopRight(), Scroom::Utils::Rectangle< T >::getVertically(), Scroom::Utils::Rectangle< T >::intersection(), Scroom::Utils::Rectangle< T >::intersects(), Scroom::Utils::Rectangle< T >::isEmpty(), Scroom::Utils::Rectangle< T >::leftOf(), Scroom::Utils::Rectangle< T >::leftOf(), Scroom::Utils::Rectangle< T >::moveTo(), Scroom::Utils::Rectangle< T >::operator*=(), Scroom::Utils::Rectangle< T >::operator*=(), Scroom::Utils::Rectangle< T >::operator+=(), Scroom::Utils::Rectangle< T >::operator/=(), Scroom::Utils::Rectangle< T >::operator/=(), Scroom::Utils::Rectangle< T >::operator==(), Scroom::Utils::Rectangle< T >::reduceSizeToMultipleOf(), Scroom::Utils::Rectangle< T >::rightOf(), Scroom::Utils::Rectangle< T >::rightOf(), Scroom::Utils::Rectangle< T >::setBottom(), Scroom::Utils::Rectangle< T >::setSize(), Scroom::Utils::Rectangle< T >::setTop(), and Scroom::Utils::Rectangle< T >::to().


The documentation for this class was generated from the following file: