#include <boundingbox.h>
Public Member Functions | |
| BoundingBox () | |
| Default constructor. | |
| BoundingBox (int x, int y, int w, int h) | |
| Constructor from a point coordinates, a width and a height. | |
| ~BoundingBox () | |
| Destrutor of the BoundingBox. | |
| int | GetOriginX () const |
| Return the abscissa of the origin. | |
| int | GetOriginY () const |
| Return the ordinate of the origin. | |
| int | GetEndX () const |
| Return the abscissa of the end point. | |
| int | GetEndY () const |
| Return the ordinate of the end point. | |
| int | GetWidth () const |
| Return the width of the box. | |
| int | GetHeight () const |
| Return the height of the box. | |
| void | SetOriginX (int pos) |
| Set the abscissa of the origin. | |
| void | SetOriginY (int pos) |
| Set the ordinate of the origin. | |
| void | SetEndX (int pos) |
| Set the abscissa of the end point. | |
| void | SetEndY (int pos) |
| Set the ordinate of the end point. | |
| void | MakeSquare () |
| Forces the height and the width to be equal to the smallest of the two (so the box is square). | |
| void | Display () const |
| Display the coordinates of the BoundingBox. | |
| void | SetCoord (int x1, int y1, int x2, int y2) |
| Initialize the BoundingBox from its 2 corners. | |
| void | SetBoundingBox (int x1, int y1, int w, int h) |
| Initialize the BoundingBox from a corner and its size. | |
| bool | IsInside (int x, int y, bool border=true) const |
| Test if a given point falls within the BoundingBox. | |
| bool | IsInside (const BoundingBox &bb) const |
| Test if another BoundingBox bb is inside the BoundingBox. | |
| void | Move (int dx, int dy) |
| Move the boundingBox. | |
| bool | IsEmpty () const |
| Test if the BoundingBox is empty, i.e. if its width or its height are non zero. | |
| void | Validate () |
| Reorder the parameters of the BoundingBox if it has a negative width and/or a negative height. | |
| BoundingBox | operator| (const BoundingBox &bb) const |
| Overload for the operator | . . | |
| BoundingBox & | operator|= (const BoundingBox &bb) |
| Overload for the operator |= . Modify in-place our BoundingBox. | |
| bool | operator== (const BoundingBox &bb) |
| Overload for the operator == : test if 2 BoundingBoxes are identical. | |
| BoundingBox & | operator= (const BoundingBox &bb) |
| Assignment operator. | |
Protected Attributes | |
| int | m_x1 |
| abscissa of the origin (top left) | |
| int | m_y1 |
| ordinate of the origin (top left) | |
| int | m_x2 |
| abscissa of the end point (bottom right) | |
| int | m_y2 |
| ordinate of the end point (bottom right) | |
It is used in the Shape class to store the smallest rectangle able to contain a given shape. A BoundingBox can be characterized by its 2 opposite corners:
Definition at line 24 of file boundingbox.h.
| BoundingBox::BoundingBox | ( | ) |
| BoundingBox::BoundingBox | ( | int | x, | |
| int | y, | |||
| int | w, | |||
| int | h | |||
| ) |
Constructor from a point coordinates, a width and a height.
| x,: | abscissa of the origin | |
| y,: | ordinate of the origin | |
| w,: | width of the box | |
| h,: | height of the box |
Definition at line 21 of file boundingbox.cpp.
References SetBoundingBox().

| BoundingBox::~BoundingBox | ( | ) |
| int BoundingBox::GetOriginX | ( | ) | const |
Return the abscissa of the origin.
Definition at line 198 of file boundingbox.cpp.
References m_x1.
Referenced by Rectangle::Draw(), Shape::GetCenterX(), and Rectangle::SumValues().

| int BoundingBox::GetOriginY | ( | ) | const |
Return the ordinate of the origin.
Definition at line 202 of file boundingbox.cpp.
References m_y1.
Referenced by Rectangle::Draw(), Shape::GetCenterY(), and Rectangle::SumValues().

| int BoundingBox::GetEndX | ( | ) | const |
Return the abscissa of the end point.
Definition at line 206 of file boundingbox.cpp.
References m_x2.
Referenced by Rectangle::SumValues().

| int BoundingBox::GetEndY | ( | ) | const |
Return the ordinate of the end point.
Definition at line 210 of file boundingbox.cpp.
References m_y2.
Referenced by Rectangle::SumValues().

| int BoundingBox::GetWidth | ( | ) | const |
Return the width of the box.
Definition at line 50 of file boundingbox.cpp.
Referenced by Rectangle::Draw(), Shape::GetCenterX(), Shape::GetWidth(), and MakeSquare().

| int BoundingBox::GetHeight | ( | ) | const |
Return the height of the box.
Definition at line 59 of file boundingbox.cpp.
Referenced by Rectangle::Draw(), Shape::GetCenterY(), Shape::GetHeight(), and MakeSquare().

| void BoundingBox::SetOriginX | ( | int | pos | ) |
| void BoundingBox::SetOriginY | ( | int | pos | ) |
| void BoundingBox::SetEndX | ( | int | pos | ) |
Set the abscissa of the end point.
Definition at line 222 of file boundingbox.cpp.
References m_x2.
Referenced by Shape::ModifyEndShape().

| void BoundingBox::SetEndY | ( | int | pos | ) |
Set the ordinate of the end point.
Definition at line 226 of file boundingbox.cpp.
References m_y2.
Referenced by Shape::ModifyEndShape().

| void BoundingBox::MakeSquare | ( | ) |
Forces the height and the width to be equal to the smallest of the two (so the box is square).
Definition at line 94 of file boundingbox.cpp.
References GetHeight(), GetWidth(), m_x1, m_x2, m_y1, and m_y2.

| void BoundingBox::Display | ( | ) | const |
| void BoundingBox::SetCoord | ( | int | x1, | |
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) |
Initialize the BoundingBox from its 2 corners.
| x1,y1 | : Coordinates of the first corner | |
| x2,y2 | : Coordinates of the second corner |
Definition at line 86 of file boundingbox.cpp.
References m_x1, m_x2, m_y1, and m_y2.
Referenced by Shape::Init().

| void BoundingBox::SetBoundingBox | ( | int | x1, | |
| int | y1, | |||
| int | w, | |||
| int | h | |||
| ) |
Initialize the BoundingBox from a corner and its size.
| x1 | : Abscissa of the 1st corner | |
| y1 | : Ordinate of the 1st corner | |
| w | : width of the BoundingBox | |
| h | : height of the BoundingBox |
Definition at line 42 of file boundingbox.cpp.
References m_x1, m_x2, m_y1, and m_y2.
Referenced by BoundingBox().

| bool BoundingBox::IsInside | ( | int | x, | |
| int | y, | |||
| bool | border = true | |||
| ) | const |
Test if a given point falls within the BoundingBox.
| x,y | : coordinates of the point to test | |
| border | : if border is true, also include the border as part of the BoundingBox definition |
Definition at line 120 of file boundingbox.cpp.
References m_x1, m_x2, m_y1, and m_y2.
Referenced by Rectangle::IsInside().

| bool BoundingBox::IsInside | ( | const BoundingBox & | bb | ) | const |
Test if another BoundingBox bb is inside the BoundingBox.
| bb | : BoundingBox to be tested |
Definition at line 138 of file boundingbox.cpp.
| void BoundingBox::Move | ( | int | dx, | |
| int | dy | |||
| ) |
| bool BoundingBox::IsEmpty | ( | ) | const |
Test if the BoundingBox is empty, i.e. if its width or its height are non zero.
Definition at line 36 of file boundingbox.cpp.
References m_x1, m_x2, m_y1, and m_y2.
Referenced by Shape::Validate().

| void BoundingBox::Validate | ( | ) |
Reorder the parameters of the BoundingBox if it has a negative width and/or a negative height.
Definition at line 68 of file boundingbox.cpp.
References m_x1, m_x2, m_y1, and m_y2.
Referenced by Shape::Validate().

| BoundingBox BoundingBox::operator| | ( | const BoundingBox & | bb | ) | const |
Overload for the operator | .
.
| bb | boundingBox to compare with |
Definition at line 146 of file boundingbox.cpp.
| BoundingBox & BoundingBox::operator|= | ( | const BoundingBox & | bb | ) |
Overload for the operator |= .
Modify in-place our BoundingBox.
| bb | BoundingBox to compare |
Definition at line 175 of file boundingbox.cpp.
| bool BoundingBox::operator== | ( | const BoundingBox & | bb | ) |
Overload for the operator == : test if 2 BoundingBoxes are identical.
| bb | BoundingBox to compare |
Definition at line 181 of file boundingbox.cpp.
| BoundingBox & BoundingBox::operator= | ( | const BoundingBox & | bb | ) |
Assignment operator.
| bb | BoundingBox to copy from |
Definition at line 189 of file boundingbox.cpp.
int BoundingBox::m_x1 [protected] |
abscissa of the origin (top left)
Definition at line 51 of file boundingbox.h.
Referenced by BoundingBox(), Display(), GetOriginX(), GetWidth(), IsEmpty(), IsInside(), MakeSquare(), Move(), operator=(), operator==(), operator|(), SetBoundingBox(), SetCoord(), SetOriginX(), and Validate().
int BoundingBox::m_y1 [protected] |
ordinate of the origin (top left)
Definition at line 55 of file boundingbox.h.
Referenced by BoundingBox(), Display(), GetHeight(), GetOriginY(), IsEmpty(), IsInside(), MakeSquare(), Move(), operator=(), operator==(), operator|(), SetBoundingBox(), SetCoord(), SetOriginY(), and Validate().
int BoundingBox::m_x2 [protected] |
abscissa of the end point (bottom right)
Definition at line 59 of file boundingbox.h.
Referenced by BoundingBox(), Display(), GetEndX(), GetWidth(), IsEmpty(), IsInside(), MakeSquare(), Move(), operator=(), operator|(), SetBoundingBox(), SetCoord(), SetEndX(), and Validate().
int BoundingBox::m_y2 [protected] |
ordinate of the end point (bottom right)
Definition at line 63 of file boundingbox.h.
Referenced by BoundingBox(), Display(), GetEndY(), GetHeight(), IsEmpty(), IsInside(), MakeSquare(), Move(), operator=(), operator==(), operator|(), SetBoundingBox(), SetCoord(), SetEndY(), and Validate().
1.5.6