HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Rect< T > Class Template Reference

Base Integer Rectangle class. More...

#include <IMG_AddMetaData.h>

Public Member Functions

 UT_Rect ()
 
void clear ()
 Clear rect to empty. More...
 
bool isEmpty () const
 Return true if rectangle is empty. More...
 
bool isValid () const
 Return true if rectangle is valid (true if empty) More...
 
void standardize ()
 
bool isInside (int px, int py) const
 Returns true if the given point is within the rectangle. More...
 
bool contains (const T &r) const
 Returns true if T is entirely contained by this rectangle. More...
 
void getRelative (int &px, int &py) const
 Get relative coordinates from absolute. More...
 
void getAbsolute (int &px, int &py) const
 Get absolute coordinates from relative. More...
 
bool intersect (const T &r)
 Intersect this rectangle with the given one. Returns if result is valid. More...
 
void enlarge (const T &r)
 Enlarge this rectangle to include the given rectangle (ie. a union) More...
 
void translate (int x, int y)
 Translate by given offset. More...
 
void inset (int dx, int dy)
 Inset the rect by a dx and dy margins. More...
 
void inset (int dx1, int dy1, int dx2, int dy2)
 Replace by the inclusive rect (x1()+dx1, y1()+dy1, x2()-dx2, y2()-dy2) More...
 
void scale (fpreal factor)
 Scale by given factor. More...
 
void clamp (int &px, int &py) const
 Clamp the coordinates to be inclusive of this rect (ie. make it inside) More...
 
SYS_FORCE_INLINE SYS_HashType hash () const
 
int64 getMemoryUsage (bool inclusive) const
 
void dump (UT_WorkBuffer &wbuf, const char *msg="") const
 
void dump (const char *msg="") const
 
 UT_Rect (int v1, int v2, int v3, int v4)
 Construct with native rect type values. More...
 
 UT_Rect (int v[4])
 Construct with native rect type values. More...
 
 UT_Rect (const UT_DimRect &r)
 Conversion constructor. More...
 
 UT_Rect (const UT_InclusiveRect &r)
 Conversion constructor. More...
 
 UT_Rect (const UT_ExclusiveRect &r)
 Conversion constructor. More...
 
UT_Rectoperator= (const UT_DimRect &r)
 Assignment operator. Can convert from any rect type. More...
 
UT_Rectoperator= (const UT_InclusiveRect &r)
 Assignment operator. Can convert from any rect type. More...
 
UT_Rectoperator= (const UT_ExclusiveRect &r)
 Assignment operator. Can convert from any rect type. More...
 
void set (int v1, int v2, int v3, int v4)
 Set the native rect type values. More...
 
void set (int v[4])
 Set the native rect type values. More...
 
bool isInsideX (int px) const
 Returns true if the rectangle contains the given coord. More...
 
bool isInsideY (int py) const
 Returns true if the rectangle contains the given coord. More...
 
void flipX (int awidth)
 Flip rectangle within the given width/height. More...
 
void flipY (int aheight)
 Flip rectangle within the given width/height. More...
 
bool overlapX (const T &r) const
 Returns true if the given side would overlap the other rectangle if projected onto it. More...
 
bool overlapY (const T &r) const
 Returns true if the given side would overlap the other rectangle if projected onto it. More...
 
void enlarge (int x, int y)
 Enlarge this rectangle to include the given point. More...
 
void enlarge (float x, float y)
 Enlarge this rectangle to include the given point. More...
 
int x () const
 Get lower-left corner. More...
 
int y () const
 Get lower-left corner. More...
 
int x1 () const
 Get lower-left corner. More...
 
int y1 () const
 Get lower-left corner. More...
 
void setX (int x_)
 Set the lower-left corner position, always maintaining the size. More...
 
void setY (int y_)
 Set the lower-left corner position, always maintaining the size. More...
 
void setX1 (int x_)
 Set lower-left corner, without changing the upper-right corner. More...
 
void setY1 (int y_)
 Set lower-left corner, without changing the upper-right corner. More...
 
int w () const
 Get width/height dimensions. More...
 
int h () const
 Get width/height dimensions. More...
 
int width () const
 Get width/height dimensions. More...
 
int height () const
 Get width/height dimensions. More...
 
void setWidth (int awidth)
 Set the width/height, always maintaining the lower-left position. More...
 
void setHeight (int aheight)
 Set the width/height, always maintaining the lower-left position. More...
 
int x2 () const
 Get upper-right corner (inclusive) More...
 
int y2 () const
 Get upper-right corner (inclusive) More...
 
void setX2 (int x_)
 Set upper-right corner (inclusive), without changing lower-left. More...
 
void setY2 (int y_)
 Set upper-right corner (inclusive), without changing lower-left. More...
 
int x2e () const
 Get upper-right corner (exclusive) More...
 
int y2e () const
 Get upper-right corner (exclusive) More...
 
void setX2e (int x_)
 Set upper-right corner (exclusive), without changing lower-left. More...
 
void setY2e (int y_)
 Set upper-right corner (exclusive), without changing lower-left. More...
 
int centerX () const
 Get center. More...
 
int centerY () const
 Get center. More...
 
void getDim (int &x_, int &y_, int &w_, int &h_) const
 Get rectangle values. More...
 
void getIncl (int &x1_, int &y1_, int &x2_, int &y2_) const
 Get rectangle values. More...
 
void getExcl (int &x1_, int &y1_, int &x2_, int &y2_) const
 Get rectangle values. More...
 
void setDim (int x_, int y_, int w_, int h_)
 Set rectangle values. More...
 
void setDim (int v[4])
 Set rectangle values. More...
 
void setIncl (int x1_, int y1_, int x2_, int y2_)
 Set rectangle values. More...
 
void setIncl (int v[4])
 Set rectangle values. More...
 
void setExcl (int x1_, int y1_, int x2_, int y2_)
 Set rectangle values. More...
 
void setExcl (int v[4])
 Set rectangle values. More...
 
intoperator() (int i)
 Native data access. More...
 
int operator() (int i) const
 Native data access. More...
 
const intdata () const
 Native data access. More...
 
intdata ()
 Native data access. More...
 

Static Public Member Functions

static UT_Rect zero ()
 Convenience method for creating an empty rect. More...
 

Detailed Description

template<typename T>
class UT_Rect< T >

Base Integer Rectangle class.

UT_Rect is an integer rectangle class. You do NOT instantiate this but instead choose from one of the 3 different types of underlying rectangle implementations, each with the same interface:

UT_DimRect: Stores the data as (x, y, width, height)
UT_InclusiveRect: Stores the data as inclusive (x1, y1, x2, y2).
ie. lower-left and upper-right corner positions
UT_ExclusiveRect: Stores the data as exclusive (x1, y1, x2e, y2e).
The upper-right corner position (x2e, y2e) is
equivalent to (x2+1, y2+1).

The "lower-left"/"upper-right" terms here assume (0,0) is in the lower-left corner of your coordinate system. If your (0,0) is in the top-left corner instead, substitute these terms with "top-left"/"bottom-right".

To convert internal data representations from one type to another, use the copy constructor and assignment operators. Otherwise, use the methods found in UT_Rect.

Definition at line 23 of file IMG_AddMetaData.h.

Constructor & Destructor Documentation

template<typename T>
UT_Rect< T >::UT_Rect ( )
inline

Definition at line 91 of file UT_Rect.h.

template<typename T>
UT_Rect< T >::UT_Rect ( int  v1,
int  v2,
int  v3,
int  v4 
)
inline

Construct with native rect type values.

The actual construction signatures are:

UT_DimRect(int x, int y, int width, int height)
UT_InclusiveRect(int x1, int y1, int x2, int y2)
UT_ExclusiveRect(int x1, int y1, int x2e, int y2e)

Definition at line 102 of file UT_Rect.h.

template<typename T>
UT_Rect< T >::UT_Rect ( int  v[4])
inline

Construct with native rect type values.

The actual construction signatures are:

UT_DimRect(int x, int y, int width, int height)
UT_InclusiveRect(int x1, int y1, int x2, int y2)
UT_ExclusiveRect(int x1, int y1, int x2e, int y2e)

Definition at line 103 of file UT_Rect.h.

template<typename T>
UT_Rect< T >::UT_Rect ( const UT_DimRect r)
inline

Conversion constructor.

Definition at line 108 of file UT_Rect.h.

template<typename T>
UT_Rect< T >::UT_Rect ( const UT_InclusiveRect r)
inline

Conversion constructor.

Definition at line 109 of file UT_Rect.h.

template<typename T>
UT_Rect< T >::UT_Rect ( const UT_ExclusiveRect r)
inline

Conversion constructor.

Definition at line 110 of file UT_Rect.h.

Member Function Documentation

template<typename T>
int UT_Rect< T >::centerX ( ) const
inline

Get center.

Definition at line 281 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::centerY ( ) const
inline

Get center.

Definition at line 282 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::clamp ( int px,
int py 
) const
inline

Clamp the coordinates to be inclusive of this rect (ie. make it inside)

Definition at line 211 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::clear ( void  )
inline

Clear rect to empty.

Definition at line 124 of file UT_Rect.h.

template<typename T>
bool UT_Rect< T >::contains ( const T r) const

Returns true if T is entirely contained by this rectangle.

template<typename T>
const int* UT_Rect< T >::data ( ) const
inline

Native data access.

See Also
UT_Rect::UT_Rect()

Definition at line 323 of file UT_Rect.h.

template<typename T>
int* UT_Rect< T >::data ( )
inline

Native data access.

See Also
UT_Rect::UT_Rect()

Definition at line 324 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::dump ( UT_WorkBuffer wbuf,
const char *  msg = "" 
) const
template<typename T>
void UT_Rect< T >::dump ( const char *  msg = "") const
template<typename T>
void UT_Rect< T >::enlarge ( const T r)

Enlarge this rectangle to include the given rectangle (ie. a union)

template<typename T>
void UT_Rect< T >::enlarge ( int  x,
int  y 
)

Enlarge this rectangle to include the given point.

template<typename T>
void UT_Rect< T >::enlarge ( float  x,
float  y 
)

Enlarge this rectangle to include the given point.

template<typename T>
void UT_Rect< T >::flipX ( int  awidth)
inline

Flip rectangle within the given width/height.

Definition at line 175 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::flipY ( int  aheight)
inline

Flip rectangle within the given width/height.

Definition at line 176 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::getAbsolute ( int px,
int py 
) const
inline

Get absolute coordinates from relative.

Definition at line 170 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::getDim ( int x_,
int y_,
int w_,
int h_ 
) const
inline

Get rectangle values.

This will return you the desired semantic regardless of the underlying rectangle type.

Definition at line 292 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::getExcl ( int x1_,
int y1_,
int x2_,
int y2_ 
) const
inline

Get rectangle values.

This will return you the desired semantic regardless of the underlying rectangle type.

Definition at line 296 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::getIncl ( int x1_,
int y1_,
int x2_,
int y2_ 
) const
inline

Get rectangle values.

This will return you the desired semantic regardless of the underlying rectangle type.

Definition at line 294 of file UT_Rect.h.

template<typename T>
int64 UT_Rect< T >::getMemoryUsage ( bool  inclusive) const
inline

Definition at line 336 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::getRelative ( int px,
int py 
) const
inline

Get relative coordinates from absolute.

Definition at line 166 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::h ( ) const
inline

Get width/height dimensions.

Definition at line 247 of file UT_Rect.h.

template<typename T>
SYS_FORCE_INLINE SYS_HashType UT_Rect< T >::hash ( void  ) const
inline

Definition at line 327 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::height ( void  ) const
inline

Get width/height dimensions.

Definition at line 249 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::inset ( int  dx,
int  dy 
)

Inset the rect by a dx and dy margins.

template<typename T>
void UT_Rect< T >::inset ( int  dx1,
int  dy1,
int  dx2,
int  dy2 
)

Replace by the inclusive rect (x1()+dx1, y1()+dy1, x2()-dx2, y2()-dy2)

template<typename T>
bool UT_Rect< T >::intersect ( const T r)

Intersect this rectangle with the given one. Returns if result is valid.

template<typename T>
bool UT_Rect< T >::isEmpty ( ) const
inline

Return true if rectangle is empty.

Definition at line 143 of file UT_Rect.h.

template<typename T>
bool UT_Rect< T >::isInside ( int  px,
int  py 
) const
inline

Returns true if the given point is within the rectangle.

Definition at line 159 of file UT_Rect.h.

template<typename T>
bool UT_Rect< T >::isInsideX ( int  px) const
inline

Returns true if the rectangle contains the given coord.

Definition at line 154 of file UT_Rect.h.

template<typename T>
bool UT_Rect< T >::isInsideY ( int  py) const
inline

Returns true if the rectangle contains the given coord.

Definition at line 155 of file UT_Rect.h.

template<typename T>
bool UT_Rect< T >::isValid ( ) const
inline

Return true if rectangle is valid (true if empty)

Definition at line 146 of file UT_Rect.h.

template<typename T>
int& UT_Rect< T >::operator() ( int  i)
inline

Native data access.

See Also
UT_Rect::UT_Rect()

Definition at line 321 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::operator() ( int  i) const
inline

Native data access.

See Also
UT_Rect::UT_Rect()

Definition at line 322 of file UT_Rect.h.

template<typename T>
UT_Rect& UT_Rect< T >::operator= ( const UT_DimRect r)
inline

Assignment operator. Can convert from any rect type.

Definition at line 115 of file UT_Rect.h.

template<typename T>
UT_Rect& UT_Rect< T >::operator= ( const UT_InclusiveRect r)
inline

Assignment operator. Can convert from any rect type.

Definition at line 116 of file UT_Rect.h.

template<typename T>
UT_Rect& UT_Rect< T >::operator= ( const UT_ExclusiveRect r)
inline

Assignment operator. Can convert from any rect type.

Definition at line 117 of file UT_Rect.h.

template<typename T>
bool UT_Rect< T >::overlapX ( const T r) const

Returns true if the given side would overlap the other rectangle if projected onto it.

template<typename T>
bool UT_Rect< T >::overlapY ( const T r) const

Returns true if the given side would overlap the other rectangle if projected onto it.

template<typename T>
void UT_Rect< T >::scale ( fpreal  factor)

Scale by given factor.

template<typename T>
void UT_Rect< T >::set ( int  v1,
int  v2,
int  v3,
int  v4 
)
inline

Set the native rect type values.

Interpretation will differ depending on type T. The actual signatures are:

UT_DimRect::set(int x, int y, int width, int height)
UT_InclusiveRect::set(int x1, int y1, int x2, int y2)
UT_ExclusiveRect::set(int x1, int y1e, int x2, int y2e)

Definition at line 136 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::set ( int  v[4])
inline

Set the native rect type values.

Interpretation will differ depending on type T. The actual signatures are:

UT_DimRect::set(int x, int y, int width, int height)
UT_InclusiveRect::set(int x1, int y1, int x2, int y2)
UT_ExclusiveRect::set(int x1, int y1e, int x2, int y2e)

Definition at line 138 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setDim ( int  x_,
int  y_,
int  w_,
int  h_ 
)
inline

Set rectangle values.

Regardless of the underlying type of rectangle, it will set it up properly using the given semantic.

Definition at line 305 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setDim ( int  v[4])
inline

Set rectangle values.

Regardless of the underlying type of rectangle, it will set it up properly using the given semantic.

Definition at line 307 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setExcl ( int  x1_,
int  y1_,
int  x2_,
int  y2_ 
)
inline

Set rectangle values.

Regardless of the underlying type of rectangle, it will set it up properly using the given semantic.

Definition at line 313 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setExcl ( int  v[4])
inline

Set rectangle values.

Regardless of the underlying type of rectangle, it will set it up properly using the given semantic.

Definition at line 315 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setHeight ( int  aheight)
inline

Set the width/height, always maintaining the lower-left position.

Definition at line 255 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setIncl ( int  x1_,
int  y1_,
int  x2_,
int  y2_ 
)
inline

Set rectangle values.

Regardless of the underlying type of rectangle, it will set it up properly using the given semantic.

Definition at line 309 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setIncl ( int  v[4])
inline

Set rectangle values.

Regardless of the underlying type of rectangle, it will set it up properly using the given semantic.

Definition at line 311 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setWidth ( int  awidth)
inline

Set the width/height, always maintaining the lower-left position.

Definition at line 254 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setX ( int  x_)
inline

Set the lower-left corner position, always maintaining the size.

Definition at line 234 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setX1 ( int  x_)
inline

Set lower-left corner, without changing the upper-right corner.

Definition at line 240 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setX2 ( int  x_)
inline

Set upper-right corner (inclusive), without changing lower-left.

Definition at line 265 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setX2e ( int  x_)
inline

Set upper-right corner (exclusive), without changing lower-left.

Definition at line 275 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setY ( int  y_)
inline

Set the lower-left corner position, always maintaining the size.

Definition at line 235 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setY1 ( int  y_)
inline

Set lower-left corner, without changing the upper-right corner.

Definition at line 241 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setY2 ( int  y_)
inline

Set upper-right corner (inclusive), without changing lower-left.

Definition at line 266 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::setY2e ( int  y_)
inline

Set upper-right corner (exclusive), without changing lower-left.

Definition at line 276 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::standardize ( )
inline

Modify the rectangle so that it has non-negative width/height values (ie. isValid() returns true)

Definition at line 150 of file UT_Rect.h.

template<typename T>
void UT_Rect< T >::translate ( int  x,
int  y 
)

Translate by given offset.

template<typename T>
int UT_Rect< T >::w ( ) const
inline

Get width/height dimensions.

Definition at line 246 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::width ( void  ) const
inline

Get width/height dimensions.

Definition at line 248 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::x ( ) const
inline

Get lower-left corner.

Definition at line 226 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::x1 ( ) const
inline

Get lower-left corner.

Definition at line 228 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::x2 ( ) const
inline

Get upper-right corner (inclusive)

Definition at line 260 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::x2e ( ) const
inline

Get upper-right corner (exclusive)

Definition at line 270 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::y ( ) const
inline

Get lower-left corner.

Definition at line 227 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::y1 ( ) const
inline

Get lower-left corner.

Definition at line 229 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::y2 ( ) const
inline

Get upper-right corner (inclusive)

Definition at line 261 of file UT_Rect.h.

template<typename T>
int UT_Rect< T >::y2e ( ) const
inline

Get upper-right corner (exclusive)

Definition at line 271 of file UT_Rect.h.

template<typename T>
static UT_Rect UT_Rect< T >::zero ( )
inlinestatic

Convenience method for creating an empty rect.


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