Rect Class Reference
[Abstract Data Types]

Rectangle Class. More...

#include <frect.h>

Public Member Functions

 Rect ()
 create empty rectangle with coordinates set to zero
 Rect (UCoord left, UCoord top, UCoord right, UCoord bottom)
 create rectangle with four individual coordinates
 Rect (UCoord w, UCoord h)
 create rectangle with zero left/top coordinates and right/bottom coordinates according to the given width and height
 Rect (const Point &topLeft, const Point &bottomRight)
 create rectangle defined by a top/left Point and a bottom/right Point
 Rect (const Point &topLeft, UCoord width, UCoord height)
 create rectangle defined by a top/left Point and the given width and height
 Rect (const ViewRect &vr)
 create rectangle defined by a ViewRect
UCoord getWidth () const
 return width of rectangle (right coordinate - left coordinate)
UCoord getHeight () const
 return height of rectangle (bottom coordinate - top coordinate)
RectsetWidth (const UCoord w)
 set width by setting the right coordinate with respect to the left
RectsetHeight (const UCoord h)
 set height by setting the bottom coordinate with respect to the top
void setEmpty ()
 resets coordinates to all zero - now isEmpty returns true
Point getTopLeft () const
 get top/left as Point
PointgetTopLeft (Point &) const
 get top/left as Point
Point getBottomRight () const
 get bottom/right as Point
PointgetBottomRight (Point &) const
 get bottom/right as Point
Point getTopRight () const
 get top/right as Point
PointgetTopRight (Point &) const
 get top/right as Point
Point getBottomLeft () const
 get bottom/left as Point
PointgetBottomLeft (Point &) const
 get bottom/left as Point
PointtoPoint (Direction dir, Point &p) const
 convert rectangle to a point
Point toPoint (Direction dir) const
 convert rectangle to a point
RectsetTopLeft (const UCoord left, const UCoord top)
 set top/left from coordinates
RectsetBottomRight (const UCoord right, const UCoord bottom)
 set bottom/right from coordinates
RectsetSize (const UCoord w, const UCoord h)
 set size by setting bottom/right with respect to left/top
Rectoperator() (UCoord left, UCoord top, UCoord right, UCoord bottom)
 set left/top/right/bottom from four individual coordinates
Rectoperator() (const Point &topLeft, const Point &bottomRight)
 set left/top/right/bottom from top/left Point and bottom/right Point
void set (UCoord left, UCoord top, UCoord right, UCoord bottom)
 return height of rectangle (bottom coordinate - top coordinate)
RectmoveTo (const Point &where)
 move rectangle to a new top/left point while maintaining width and height
Rectoffset (UCoord x, UCoord y=0)
 offset rectangle by x/y coordinates maintaining width and height
Rectoffset (const Point &where)
 offset rectangle by a x/y Point maintaining width and height
Rectinset (UCoord delta)
 inset top/left and bottom/right by equal amounts to change rectangle size
Rectinset (UCoord deltaH, UCoord deltaV)
 inset left/right by an equal amount similarly, inset top/bottom by an equal amount, to change rectangle size
Rectinset (UCoord deltaL, UCoord deltaT, UCoord deltaR, UCoord deltaB)
 inset left/top/right/bottom each by a separate amount to change the rectangle size
Rectoriginize ()
 move rectangle so the left/top coordinate are zero while maintaining the width and height
Rectnormalize ()
 flips left/right and top/bottom values if value pairs are such that right<left or bottom<top coordinates
Rectcenter (const Rect &rect)
 centers this with respect to rect
RectcenterH (const Rect &rect)
 centers this with respect to rect
RectcenterV (const Rect &rect)
 centers this with respect to rect
bool bound (const Rect &rect)
 set this to the intersection of this and rect; returns false if intersection is empty
bool slideInside (const Rect &rect)
 fit this inside the larger rect. if not possible return false.
bool join (const Rect &rect)
 set this to the union of this and rect
bool subtract (const Rect &rect)
 trim this by the rect given
bool isEmpty () const
bool rectInside (const Rect &rect) const
 checks if rect is enclosed by this
bool rectIntersect (const Rect &rect) const
 checks if rect touches this
bool rectIntersect (const Rect &rect, Rect &result) const
 checks if rect touches this: if true intersection is in result
Point getCenter () const
 get point in the middle of the rect (might not be precise for even sized rects)
Point getLeftCenter () const
Point getRightCenter () const
Point getTopCenter () const
Point getBottomCenter () const
bool overlapHorizontal (const Rect &rect) const
 checks if the horizontal coord ranges overlap
bool overlapVertical (const Rect &rect) const
 checks if the vertical coord ranges overlap
UCoord getOverlapHorizontal (const Rect &rect) const
 get horizontal overlapping area, returns 0 if not overlapping
UCoord getOverlapVertical (const Rect &rect) const
 get vertical overlapping area, returns 0 if not overlapping
bool pointInside (const Point &where) const
 checks if point is inside this rect
Pointconstrain (Point &p) const
 constrains the point such that is lies within this rect
bool lineInside (const Point &p1, const Point &p2) const
 is line inside rect ?
bool lineIntersect (const Point &p1, const Point &p2) const
 is line intersecting rect?
bool boundLine (Point &p1, Point &p2) const
 bound line to rect, returns false if line does not intersect rect
Rectoperator+= (const Point &p)
 performs a 'offset' operation on this
Rectoperator+= (const Rect &rect)
 performs a 'join' operation on this
bool operator== (const Rect &rect) const
 tests for equality of coordinates of this and the rect
bool operator!= (const Rect &rect) const
ViewRect & toViewRect (ViewRect &vr) const
 sets the ViewRect coordinates to the current coordinates of this
void fromViewRect (const ViewRect &vr)
 sets the current coordinates of this to the ViewRect coordinates
Rectoperator= (const ViewRect &vr)
 performs a 'fromViewRect' operation
 operator ViewRect () const
 conversion operator to ViewRect

Data Fields

UCoord left
UCoord top
UCoord right
UCoord bottom

Detailed Description

Rectangle Class.

See also:
Point, UCoord

Constructor & Destructor Documentation

Rect (  )  [inline]

create empty rectangle with coordinates set to zero

Create empty rectangle with coordinates set to zero.

Rect ( UCoord  left,
UCoord  top,
UCoord  right,
UCoord  bottom 
) [inline]

create rectangle with four individual coordinates

Create rectangle with four individual coordinates.

Rect ( UCoord  w,
UCoord  h 
) [inline]

create rectangle with zero left/top coordinates and right/bottom coordinates according to the given width and height

Create rectangle with zero left/top coordinates and right/bottom coordinates according to the given width and height.

Rect ( const Point topLeft,
const Point bottomRight 
) [inline]

create rectangle defined by a top/left Point and a bottom/right Point

Create rectangle defined by a top/left Point and a bottom/right Point.

Rect ( const Point topLeft,
UCoord  width,
UCoord  height 
) [inline]

create rectangle defined by a top/left Point and the given width and height

Create rectangle defined by a top/left Point and the given width and height.

Rect ( const ViewRect &  vr  ) 

create rectangle defined by a ViewRect


Member Function Documentation

UCoord getWidth (  )  const [inline]

return width of rectangle (right coordinate - left coordinate)

Return width of rectangle (right coordinate - left coordinate).

UCoord getHeight (  )  const [inline]

return height of rectangle (bottom coordinate - top coordinate)

Return height of rectangle (bottom coordinate - top coordinate).

Rect & setWidth ( const UCoord  w  )  [inline]

set width by setting the right coordinate with respect to the left

Set width by setting the right coordinate with respect to the left.

Rect & setHeight ( const UCoord  h  )  [inline]

set height by setting the bottom coordinate with respect to the top

Set height by setting the bottom coordinate with respect to the top.

void setEmpty (  )  [inline]

resets coordinates to all zero - now isEmpty returns true

Resets coordinates to all zero - now isEmpty returns true.

Point getTopLeft (  )  const [inline]

get top/left as Point

Get top/left as Point.

Point & getTopLeft ( Point p  )  const [inline]

get top/left as Point

Get top/left as Point.

Point getBottomRight (  )  const [inline]

get bottom/right as Point

Get bottom/right as Point.

Point & getBottomRight ( Point p  )  const [inline]

get bottom/right as Point

Get bottom/right as Point.

Point getTopRight (  )  const [inline]

get top/right as Point

Get top/right as Point.

Point & getTopRight ( Point p  )  const [inline]

get top/right as Point

Get top/right as Point.

Point getBottomLeft (  )  const [inline]

get bottom/left as Point

Get bottom/left as Point.

Point & getBottomLeft ( Point p  )  const [inline]

get bottom/left as Point

Get bottom/left as Point.

Point & toPoint ( Direction  dir,
Point p 
) const

convert rectangle to a point

Point toPoint ( Direction  dir  )  const [inline]

convert rectangle to a point

Rect & setTopLeft ( const UCoord  left,
const UCoord  top 
) [inline]

set top/left from coordinates

Set top/left from coordinates.

Rect & setBottomRight ( const UCoord  right,
const UCoord  bottom 
) [inline]

set bottom/right from coordinates

Set bottom/right from coordinates.

Rect & setSize ( const UCoord  w,
const UCoord  h 
) [inline]

set size by setting bottom/right with respect to left/top

Set size by setting bottom/right with respect to left/top.

Rect & operator() ( UCoord  left,
UCoord  top,
UCoord  right,
UCoord  bottom 
) [inline]

set left/top/right/bottom from four individual coordinates

Set left/top/right/bottom from four individual coordinates.

Rect & operator() ( const Point topLeft,
const Point bottomRight 
) [inline]

set left/top/right/bottom from top/left Point and bottom/right Point

Set left/top/right/bottom from top/left Point and bottom/right Point.

void set ( UCoord  left,
UCoord  top,
UCoord  right,
UCoord  bottom 
) [inline]

return height of rectangle (bottom coordinate - top coordinate)

Return height of rectangle (bottom coordinate - top coordinate).

Rect & moveTo ( const Point where  ) 

move rectangle to a new top/left point while maintaining width and height

Rect & offset ( UCoord  x,
UCoord  y = 0 
) [inline]

offset rectangle by x/y coordinates maintaining width and height

Rect & offset ( const Point where  )  [inline]

offset rectangle by a x/y Point maintaining width and height

Rect & inset ( UCoord  delta  ) 

inset top/left and bottom/right by equal amounts to change rectangle size

Rect & inset ( UCoord  deltaH,
UCoord  deltaV 
)

inset left/right by an equal amount similarly, inset top/bottom by an equal amount, to change rectangle size

Rect & inset ( UCoord  deltaL,
UCoord  deltaT,
UCoord  deltaR,
UCoord  deltaB 
)

inset left/top/right/bottom each by a separate amount to change the rectangle size

Rect & originize (  )  [inline]

move rectangle so the left/top coordinate are zero while maintaining the width and height

Rect & normalize (  )  [inline]

flips left/right and top/bottom values if value pairs are such that right<left or bottom<top coordinates

Rect & center ( const Rect rect  ) 

centers this with respect to rect

Rect & centerH ( const Rect rect  ) 

centers this with respect to rect

Rect & centerV ( const Rect rect  ) 

centers this with respect to rect

bool bound ( const Rect rect  )  [inline]

set this to the intersection of this and rect; returns false if intersection is empty

Set this to the intersection of this and rect; returns false if intersection is empty.

bool slideInside ( const Rect rect  ) 

fit this inside the larger rect. if not possible return false.

bool join ( const Rect rect  ) 

set this to the union of this and rect

bool subtract ( const Rect rect  ) 

trim this by the rect given

bool isEmpty (  )  const
bool rectInside ( const Rect rect  )  const

checks if rect is enclosed by this

bool rectIntersect ( const Rect rect  )  const

checks if rect touches this

bool rectIntersect ( const Rect rect,
Rect result 
) const

checks if rect touches this: if true intersection is in result

Point getCenter (  )  const [inline]

get point in the middle of the rect (might not be precise for even sized rects)

Point getLeftCenter (  )  const [inline]
Point getRightCenter (  )  const [inline]
Point getTopCenter (  )  const [inline]
Point getBottomCenter (  )  const [inline]
bool overlapHorizontal ( const Rect rect  )  const

checks if the horizontal coord ranges overlap

bool overlapVertical ( const Rect rect  )  const

checks if the vertical coord ranges overlap

UCoord getOverlapHorizontal ( const Rect rect  )  const

get horizontal overlapping area, returns 0 if not overlapping

UCoord getOverlapVertical ( const Rect rect  )  const

get vertical overlapping area, returns 0 if not overlapping

bool pointInside ( const Point where  )  const

checks if point is inside this rect

Point & constrain ( Point p  )  const

constrains the point such that is lies within this rect

bool lineInside ( const Point p1,
const Point p2 
) const

is line inside rect ?

bool lineIntersect ( const Point p1,
const Point p2 
) const

is line intersecting rect?

bool boundLine ( Point p1,
Point p2 
) const

bound line to rect, returns false if line does not intersect rect

Rect & operator+= ( const Point p  )  [inline]

performs a 'offset' operation on this

Performs a 'offset' operation on this.

Rect & operator+= ( const Rect rect  )  [inline]

performs a 'join' operation on this

Performs a 'join' operation on this.

bool operator== ( const Rect rect  )  const

tests for equality of coordinates of this and the rect

bool operator!= ( const Rect rect  )  const
ViewRect & toViewRect ( ViewRect &  vr  )  const

sets the ViewRect coordinates to the current coordinates of this

void fromViewRect ( const ViewRect &  vr  ) 

sets the current coordinates of this to the ViewRect coordinates

Rect & operator= ( const ViewRect &  vr  ) 

performs a 'fromViewRect' operation

operator ViewRect (  )  const

conversion operator to ViewRect


Field Documentation

UCoord left
UCoord top
UCoord right
UCoord bottom
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.