Scroom  0.14
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<int, typename std::remove_cv<T>::type>::value>
 Rectangle (typename std::enable_if<!T_is_int, Rectangle< int > const & >::type 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< typename std::common_type< T, U >::type > 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< int >::intersection(), and Scroom::Utils::Rectangle< int >::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  }

◆ 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  }

◆ Rectangle() [5/5]

template<typename T >
template<bool T_is_int = std::is_same<int, typename std::remove_cv<T>::type>::value>
Scroom::Utils::Rectangle< T >::Rectangle ( typename std::enable_if<!T_is_int, Rectangle< int > const & >::type  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  }

◆ 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  }

Referenced by BOOST_AUTO_TEST_CASE(), and drawOutOfBoundsWithoutBackground().

Here is the caller 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  }

◆ 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 BOOST_AUTO_TEST_CASE(), and drawOutOfBoundsWithoutBackground().

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  }

◆ 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  }

◆ getBottom()

◆ getBottomLeft()

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

Referenced by BOOST_AUTO_TEST_CASE().

Here is the caller graph for this function:

◆ getBottomRight()

template<typename T >
xy_type Scroom::Utils::Rectangle< T >::getBottomRight ( ) const
inline
139 { return xy_type(horizontally.getEnd(), vertically.getEnd()); }

Referenced by BOOST_AUTO_TEST_CASE(), PipetteHandler::displayValues(), rects_are_close(), and Scroom::Utils::roundCorners().

Here is the caller graph for this function:

◆ getHeight()

◆ getHorizontally()

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

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

Here is the caller graph for this function:

◆ getLeft()

◆ getRight()

◆ getSize()

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

◆ getTop()

◆ getTopLeft()

◆ getTopRight()

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

Referenced by BOOST_AUTO_TEST_CASE().

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 BOOST_AUTO_TEST_CASE(), 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(); }

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

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

◆ intersection() [2/2]

template<typename T >
template<typename U >
Rectangle<typename std::common_type<T, U>::type> Scroom::Utils::Rectangle< T >::intersection ( const Rectangle< U > &  other) const
inline
102  {
103  using R = typename std::common_type<T, U>::type;
104 
105  return Rectangle<R>(*this).intersection(Rectangle<R>(other));
106  }

◆ 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  }

◆ isEmpty()

◆ 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  }

◆ 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  }

Referenced by BOOST_AUTO_TEST_CASE(), and drawOutOfBoundsWithoutBackground().

Here is the caller 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  }

◆ 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); }

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

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  }

◆ reduceSizeToMultipleOf()

template<typename T >
void Scroom::Utils::Rectangle< T >::reduceSizeToMultipleOf ( value_type  size)
inline

◆ 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  }

◆ 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 BOOST_AUTO_TEST_CASE(), and drawOutOfBoundsWithoutBackground().

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); }

◆ setLeft()

template<typename T >
void Scroom::Utils::Rectangle< T >::setLeft ( value_type  v)
inline
117 { horizontally.setStart(v); }

◆ setRight()

template<typename T >
void Scroom::Utils::Rectangle< T >::setRight ( value_type  v)
inline
119 { horizontally.setEnd(v); }

◆ setSize()

template<typename T >
void Scroom::Utils::Rectangle< T >::setSize ( xy_type const &  s)
inline
262  {
263  horizontally.setSize(s.x);
264  vertically.setSize(s.y);
265  }

◆ setTop()

template<typename T >
void Scroom::Utils::Rectangle< T >::setTop ( value_type  v)
inline
116 { vertically.setStart(v); }

◆ 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

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

Here is the caller graph for this function:

◆ width()

template<typename T >
value_type Scroom::Utils::Rectangle< T >::width ( ) const
inline
129 { return getWidth(); }

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

Here is the caller graph for this function:

◆ x()

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

◆ y()

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

Member Data Documentation

◆ horizontally

◆ vertically


The documentation for this class was generated from the following file:
Scroom::Utils::Rectangle::isEmpty
bool isEmpty() const
Definition: rectangle.hh:141
Scroom::Utils::Rectangle::x
value_type x() const
Definition: rectangle.hh:125
Scroom::Utils::Rectangle::xy_type
Point< T > xy_type
Definition: rectangle.hh:32
Scroom::Utils::Rectangle::vertically
Segment< value_type > vertically
Definition: rectangle.hh:280
Scroom::Utils::Segment::contains
bool contains(value_type p) const
Definition: linearsegment.hh:77
Scroom::Utils::Rectangle::getHeight
value_type getHeight() const
Definition: rectangle.hh:123
Scroom::Utils::Segment::getEnd
value_type getEnd() const
Definition: linearsegment.hh:135
Scroom::Utils::Segment::setSize
void setSize(value_type n)
Definition: linearsegment.hh:191
Scroom::Utils::Rectangle::moveTo
Rectangle moveTo(xy_type const &other) const
Definition: rectangle.hh:67
Scroom::Utils::Rectangle::getWidth
value_type getWidth() const
Definition: rectangle.hh:121
Scroom::Utils::Segment::intersects
bool intersects(const Segment< value_type > &other) const
Definition: linearsegment.hh:84
Scroom::Utils::Rectangle::Rectangle
Rectangle()=default
Scroom::Utils::Rectangle::horizontally
Segment< value_type > horizontally
Definition: rectangle.hh:279
Scroom::Utils::Rectangle::getLeft
value_type getLeft() const
Definition: rectangle.hh:110
Scroom::Utils::Segment::reduceSizeToMultipleOf
void reduceSizeToMultipleOf(value_type m)
Definition: linearsegment.hh:89
Scroom::Utils::Segment::moveTo
Segment moveTo(value_type p) const
Definition: linearsegment.hh:75
Scroom::Utils::Segment::intersection
Segment< value_type > intersection(const Segment< value_type > &other) const
Definition: linearsegment.hh:91
Scroom::Utils::Segment::setEnd
void setEnd(value_type n)
Definition: linearsegment.hh:192
Scroom::Utils::Rectangle::y
value_type y() const
Definition: rectangle.hh:127
Scroom::Utils::Segment::getStart
value_type getStart() const
Definition: linearsegment.hh:133
Scroom::GtkHelpers::createCairoIntRectangle
cairo_rectangle_int_t createCairoIntRectangle(int x, int y, int width, int height)
Definition: gtk-helpers.hh:71
Scroom::Utils::Segment::isEmpty
bool isEmpty() const
Definition: linearsegment.hh:139
Scroom::Utils::Rectangle::getTop
value_type getTop() const
Definition: rectangle.hh:108
Scroom::Utils::Segment::getSize
value_type getSize() const
Definition: linearsegment.hh:137
Scroom::Utils::Segment::before
Segment< value_type > before(value_type v) const
Definition: linearsegment.hh:107
Scroom::Utils::Segment::after
Segment< value_type > after(value_type v) const
Definition: linearsegment.hh:120
Scroom::Utils::Segment::setStart
void setStart(value_type n)
Definition: linearsegment.hh:185