Isle
Loading...
Searching...
No Matches
MxRect< T > Class Template Reference

[AI] 2D rectangle class templated on its value type. More...

#include <mxgeometry.h>

Public Member Functions

 MxRect ()
 [AI] Default constructor, does not initialize rectangle. More...
 
 MxRect (const MxRect &p_r)
 [AI] Copy constructor. More...
 
 MxRect (T p_l, T p_t, T p_r, T p_b)
 [AI] Construct from coordinates. More...
 
 MxRect (const MxPoint< T > &p_p, const MxSize< T > &p_s)
 [AI] Construct from point and size. More...
 
GetLeft () const
 [AI] Get the left edge. More...
 
void SetLeft (T p_left)
 [AI] Set the left edge. More...
 
GetTop () const
 [AI] Get the top edge. More...
 
void SetTop (T p_top)
 [AI] Set the top edge. More...
 
GetRight () const
 [AI] Get the right edge. More...
 
void SetRight (T p_right)
 [AI] Set the right edge. More...
 
GetBottom () const
 [AI] Get the bottom edge. More...
 
void SetBottom (T p_bottom)
 [AI] Set the bottom edge. More...
 
GetWidth () const
 [AI] Get the rectangle's width. More...
 
GetHeight () const
 [AI] Get the rectangle's height. More...
 
MxPoint< T > GetLT () const
 [AI] Get the top-left point of the rectangle. More...
 
MxPoint< T > GetRB () const
 [AI] Get the bottom-right point of the rectangle. More...
 
MxBool Empty () const
 [AI] Returns whether the rectangle is empty or not. More...
 
MxBool Contains (const MxPoint< T > &p_p) const
 [AI] Test whether a point is inside the rectangle (inclusive). More...
 
MxBool Intersects (const MxRect &p_r) const
 [AI] Returns whether this rectangle intersects another. More...
 
void operator= (const MxRect &p_r)
 [AI] Assignment operator. More...
 
MxBool operator== (const MxRect &p_r) const
 [AI] Equality operator. More...
 
MxBool operator!= (const MxRect &p_r) const
 [AI] Inequality operator. More...
 
void operator+= (const MxPoint< T > &p_p)
 [AI] Translate the rectangle by a point, in-place. More...
 
void operator-= (const MxPoint< T > &p_p)
 [AI] Translate the rectangle by the negative of a point, in-place. More...
 
void operator&= (const MxRect &p_r)
 [AI] Intersect rectangle in-place with another. More...
 
void operator|= (const MxRect &p_r)
 [AI] Unites this rectangle with another in-place. More...
 
MxRect operator+ (const MxPoint< T > &p_p) const
 [AI] Returns a translated rectangle. More...
 
MxRect operator- (const MxPoint< T > &p_p) const
 [AI] Returns a translated rectangle (by negative). More...
 
MxRect operator& (const MxRect &p_r) const
 [AI] Returns the intersection of this rectangle and another. More...
 
MxRect operator| (const MxRect &p_r) const
 [AI] Returns the bounding rectangle (union) of this and another. More...
 

Protected Attributes

m_left
 [AI] Left edge (minimum x). More...
 
m_top
 [AI] Top edge (minimum y). More...
 
m_right
 [AI] Right edge (maximum x). More...
 
m_bottom
 [AI] Bottom edge (maximum y). More...
 

Detailed Description

template<class T>
class MxRect< T >

[AI] 2D rectangle class templated on its value type.

[AI] Represents a rectangular region using left/top/right/bottom coordinates.

Template Parameters
T[AI] Underlying type for coordinates (e.g., int, float, etc.)

Definition at line 165 of file mxgeometry.h.

Constructor & Destructor Documentation

◆ MxRect() [1/4]

template<class T >
MxRect< T >::MxRect ( )
inline

[AI] Default constructor, does not initialize rectangle.

Definition at line 176 of file mxgeometry.h.

◆ MxRect() [2/4]

template<class T >
MxRect< T >::MxRect ( const MxRect< T > &  p_r)
inline

[AI] Copy constructor.

Parameters
p_r[AI] Rectangle to copy.

Definition at line 182 of file mxgeometry.h.

◆ MxRect() [3/4]

template<class T >
MxRect< T >::MxRect ( p_l,
p_t,
p_r,
p_b 
)
inline

[AI] Construct from coordinates.

Parameters
p_l[AI] Left.
p_t[AI] Top.
p_r[AI] Right.
p_b[AI] Bottom.

Definition at line 197 of file mxgeometry.h.

◆ MxRect() [4/4]

template<class T >
MxRect< T >::MxRect ( const MxPoint< T > &  p_p,
const MxSize< T > &  p_s 
)
inline

[AI] Construct from point and size.

Parameters
p_p[AI] Top-left point.
p_s[AI] Size.

Definition at line 210 of file mxgeometry.h.

Member Function Documentation

◆ Contains()

template<class T >
MxBool MxRect< T >::Contains ( const MxPoint< T > &  p_p) const
inline

[AI] Test whether a point is inside the rectangle (inclusive).

Parameters
p_p[AI] Point to check.

Definition at line 290 of file mxgeometry.h.

◆ Empty()

template<class T >
MxBool MxRect< T >::Empty ( ) const
inline

[AI] Returns whether the rectangle is empty or not.

[AI] Returns true if left >= right or top >= bottom.

Definition at line 284 of file mxgeometry.h.

◆ GetBottom()

template<class T >
T MxRect< T >::GetBottom ( ) const
inline

[AI] Get the bottom edge.

Definition at line 251 of file mxgeometry.h.

◆ GetHeight()

template<class T >
T MxRect< T >::GetHeight ( ) const
inline

[AI] Get the rectangle's height.

[AI] (bottom - top + 1)

Definition at line 268 of file mxgeometry.h.

◆ GetLeft()

template<class T >
T MxRect< T >::GetLeft ( ) const
inline

[AI] Get the left edge.

Definition at line 221 of file mxgeometry.h.

◆ GetLT()

template<class T >
MxPoint< T > MxRect< T >::GetLT ( ) const
inline

[AI] Get the top-left point of the rectangle.

Definition at line 273 of file mxgeometry.h.

◆ GetRB()

template<class T >
MxPoint< T > MxRect< T >::GetRB ( ) const
inline

[AI] Get the bottom-right point of the rectangle.

Definition at line 278 of file mxgeometry.h.

◆ GetRight()

template<class T >
T MxRect< T >::GetRight ( ) const
inline

[AI] Get the right edge.

Definition at line 241 of file mxgeometry.h.

◆ GetTop()

template<class T >
T MxRect< T >::GetTop ( ) const
inline

[AI] Get the top edge.

Definition at line 231 of file mxgeometry.h.

◆ GetWidth()

template<class T >
T MxRect< T >::GetWidth ( ) const
inline

[AI] Get the rectangle's width.

[AI] (right - left + 1)

Definition at line 262 of file mxgeometry.h.

◆ Intersects()

template<class T >
MxBool MxRect< T >::Intersects ( const MxRect< T > &  p_r) const
inline

[AI] Returns whether this rectangle intersects another.

Parameters
p_r[AI] Rectangle to test.

Definition at line 299 of file mxgeometry.h.

◆ operator!=()

template<class T >
MxBool MxRect< T >::operator!= ( const MxRect< T > &  p_r) const
inline

[AI] Inequality operator.

Parameters
p_r[AI] Rectangle to compare.

Definition at line 329 of file mxgeometry.h.

◆ operator&()

template<class T >
MxRect MxRect< T >::operator& ( const MxRect< T > &  p_r) const
inline

[AI] Returns the intersection of this rectangle and another.

Parameters
p_r[AI] Rectangle to intersect.

Definition at line 403 of file mxgeometry.h.

◆ operator&=()

template<class T >
void MxRect< T >::operator&= ( const MxRect< T > &  p_r)
inline

[AI] Intersect rectangle in-place with another.

[AI] Produces the intersection of this rectangle with another (the overlapping area).

Parameters
p_r[AI] Rectangle to intersect with.

Definition at line 360 of file mxgeometry.h.

◆ operator+()

template<class T >
MxRect MxRect< T >::operator+ ( const MxPoint< T > &  p_p) const
inline

[AI] Returns a translated rectangle.

Parameters
p_p[AI] Amount to translate by.

Definition at line 385 of file mxgeometry.h.

◆ operator+=()

template<class T >
void MxRect< T >::operator+= ( const MxPoint< T > &  p_p)
inline

[AI] Translate the rectangle by a point, in-place.

Parameters
p_p[AI] Point to add to corners.

Definition at line 335 of file mxgeometry.h.

◆ operator-()

template<class T >
MxRect MxRect< T >::operator- ( const MxPoint< T > &  p_p) const
inline

[AI] Returns a translated rectangle (by negative).

Parameters
p_p[AI] Amount to translate by.

Definition at line 394 of file mxgeometry.h.

◆ operator-=()

template<class T >
void MxRect< T >::operator-= ( const MxPoint< T > &  p_p)
inline

[AI] Translate the rectangle by the negative of a point, in-place.

Parameters
p_p[AI] Point to subtract from corners.

Definition at line 347 of file mxgeometry.h.

◆ operator=()

template<class T >
void MxRect< T >::operator= ( const MxRect< T > &  p_r)
inline

[AI] Assignment operator.

Parameters
p_r[AI] Rectangle to copy.

Definition at line 308 of file mxgeometry.h.

◆ operator==()

template<class T >
MxBool MxRect< T >::operator== ( const MxRect< T > &  p_r) const
inline

[AI] Equality operator.

Parameters
p_r[AI] Rectangle to compare.

Definition at line 320 of file mxgeometry.h.

◆ operator|()

template<class T >
MxRect MxRect< T >::operator| ( const MxRect< T > &  p_r) const
inline

[AI] Returns the bounding rectangle (union) of this and another.

Parameters
p_r[AI] Rectangle to unite.

Definition at line 417 of file mxgeometry.h.

◆ operator|=()

template<class T >
void MxRect< T >::operator|= ( const MxRect< T > &  p_r)
inline

[AI] Unites this rectangle with another in-place.

[AI] Produces the bounding rectangle covering both.

Parameters
p_r[AI] Rectangle to unite with.

Definition at line 373 of file mxgeometry.h.

◆ SetBottom()

template<class T >
void MxRect< T >::SetBottom ( p_bottom)
inline

[AI] Set the bottom edge.

Parameters
p_bottom[AI] Value to set.

Definition at line 256 of file mxgeometry.h.

◆ SetLeft()

template<class T >
void MxRect< T >::SetLeft ( p_left)
inline

[AI] Set the left edge.

Parameters
p_left[AI] Value to set.

Definition at line 226 of file mxgeometry.h.

◆ SetRight()

template<class T >
void MxRect< T >::SetRight ( p_right)
inline

[AI] Set the right edge.

Parameters
p_right[AI] Value to set.

Definition at line 246 of file mxgeometry.h.

◆ SetTop()

template<class T >
void MxRect< T >::SetTop ( p_top)
inline

[AI] Set the top edge.

Parameters
p_top[AI] Value to set.

Definition at line 236 of file mxgeometry.h.

Member Data Documentation

◆ m_bottom

template<class T >
T MxRect< T >::m_bottom
protected

[AI] Bottom edge (maximum y).

Definition at line 170 of file mxgeometry.h.

◆ m_left

template<class T >
T MxRect< T >::m_left
protected

[AI] Left edge (minimum x).

Definition at line 167 of file mxgeometry.h.

◆ m_right

template<class T >
T MxRect< T >::m_right
protected

[AI] Right edge (maximum x).

Definition at line 169 of file mxgeometry.h.

◆ m_top

template<class T >
T MxRect< T >::m_top
protected

[AI] Top edge (minimum y).

Definition at line 168 of file mxgeometry.h.


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