tbx  0.7.5
Public Member Functions | Public Attributes | List of all members
tbx::BBox Class Reference

Class to represent a two dimensional bounding box. More...

#include <bbox.h>

Public Member Functions

 BBox ()
 Uninitialised bounding box.
 
 BBox (int xmin, int ymin, int xmax, int ymax)
 Construct from the x and y coordinates.
 
 BBox (const BBox &other)
 Construct from another bounding box.
 
 BBox (const Point &imin, const Point &imax)
 Construct from the minimum and maximum points of the box.
 
 BBox (const Point &imin, const Size &size)
 Construct from the minimum point and size of the box.
 
const Pointbottom_left () const
 Get the bottom left of the box. More...
 
void bottom_left (const Point &pos)
 Set the bottom left of the box.
 
const Pointtop_right () const
 Get the top right of the box. More...
 
void top_right (const Point &pos)
 Set the top right of the box.
 
Point top_left () const
 Get top left of box.
 
void top_left (const Point &pos)
 Set top left of box.
 
Point bottom_right () const
 Get bottom right of box.
 
void bottom_right (const Point &pos)
 Set bottom right of box.
 
BBoxoperator= (const BBox &other)
 Assign value from another bounding box.
 
bool operator== (const BBox &other) const
 Check if two bounding boxes are equal.
 
bool operator!= (const BBox &other) const
 Check if two bounding boxes are not equal.
 
int width () const
 Return the width of the bounding box.
 
int height () const
 Return the height of the bounding box.
 
Size size () const
 Return the width and height of the bounding box as a Size.
 
void size (int width, int height)
 Resize the bounding box.
 
void size (const Size &size)
 Resize the bounding box.
 
void move (int bx, int by)
 Move whole box by given amounts.
 
void move_right (int bx)
 Move box right.
 
void move_left (int bx)
 Move box left.
 
void move_up (int by)
 Move box up.
 
void move_down (int by)
 Move box down.
 
void move_to (int x, int y)
 Move box to position without resizing. More...
 
void move_to (const Point &pos)
 Move box to position without resizing. More...
 
void cover (const BBox &to_cover)
 Increase bounds to cover given box.
 
void inflate (int amount)
 Inflate box by given amount on each side.
 
bool contains (const Point &pt) const
 Check if point is in rectangle.
 
bool contains (int x, int y) const
 Check if point is in rectangle.
 
bool intersects (const BBox &other) const
 Check if bounds intesect with another rect.
 
void normalise ()
 Ensure min.x <= max.x and min.y <= max.y.
 

Public Attributes

Point min
 Minimum coordinate of the bounding box.
 
Point max
 Maximum coordinate of the bounding box.
 

Detailed Description

Class to represent a two dimensional bounding box.

Member Function Documentation

◆ bottom_left()

const Point& tbx::BBox::bottom_left ( ) const
inline

Get the bottom left of the box.

This is the same as min

◆ move_to() [1/2]

void tbx::BBox::move_to ( int  x,
int  y 
)
inline

Move box to position without resizing.

Parameters
xnew minimum x position
ynew minimum y position

◆ move_to() [2/2]

void tbx::BBox::move_to ( const Point pos)
inline

Move box to position without resizing.

Parameters
posnew minimum x/y position of box

◆ top_right()

const Point& tbx::BBox::top_right ( ) const
inline

Get the top right of the box.

This is the same as max


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