|
degate 0.1.1
|
#include <Rectangle.h>

Public Member Functions | |
| Rectangle () | |
| Rectangle (int min_x, int max_x, int min_y, int max_y) | |
| Rectangle (const Rectangle &) | |
| virtual | ~Rectangle () |
| virtual bool | in_shape (int x, int y, int max_distance=0) const |
| Check in the Point with coordinates x and y is within the area of the shape. | |
| virtual bool | in_bounding_box (BoundingBox const &bbox) const |
| Check, if this rectangle is in the bounding box. | |
| virtual BoundingBox const & | get_bounding_box () const |
| Get the bounding box. | |
| virtual bool | operator== (const Rectangle &other) const |
| virtual bool | operator!= (const Rectangle &other) const |
| virtual bool | intersects (Rectangle const &rect) const |
| virtual bool | complete_within (Rectangle const &rect) const |
| Check, if rectangle rect is complete within rectangle represented by this. | |
| virtual unsigned int | get_width () const |
| virtual unsigned int | get_height () const |
| virtual int | get_min_x () const |
| virtual int | get_max_x () const |
| virtual int | get_min_y () const |
| virtual int | get_max_y () const |
| virtual int | get_center_x () const |
| virtual int | get_center_y () const |
| virtual void | set_min_x (int min_x) |
| virtual void | set_min_y (int min_y) |
| virtual void | set_max_x (int max_x) |
| virtual void | set_max_y (int max_y) |
| virtual void | set_position (int min_x, int max_x, int min_y, int max_y) |
| virtual void | shift_x (int delta_x) |
| Shift the shape vertically. | |
| virtual void | shift_y (int delta_y) |
| Shift the shape horizontally. | |
Private Member Functions | |
| void | calculate_bounding_box () |
Private Attributes | |
| int | min_x |
| int | max_x |
| int | min_y |
| int | max_y |
| BoundingBox | bounding_box |
Definition at line 30 of file Rectangle.h.
| Rectangle::Rectangle | ( | ) |
Definition at line 29 of file Rectangle.cc.
References calculate_bounding_box().
: min_x(0), max_x(0), min_y(0), max_y(0) { calculate_bounding_box(); }

| Rectangle::Rectangle | ( | int | min_x, |
| int | max_x, | ||
| int | min_y, | ||
| int | max_y | ||
| ) |
Definition at line 37 of file Rectangle.cc.
References calculate_bounding_box().
{
this->min_x = std::min(min_x, max_x);
this->max_x = std::max(min_x, max_x);
this->min_y = std::min(min_y, max_y);
this->max_y = std::max(min_y, max_y);
calculate_bounding_box();
}

| Rectangle::Rectangle | ( | const Rectangle & | o | ) |
| Rectangle::~Rectangle | ( | ) | [virtual] |
Definition at line 54 of file Rectangle.cc.
{
}
| void Rectangle::calculate_bounding_box | ( | ) | [private] |
Definition at line 188 of file Rectangle.cc.
References bounding_box, max_x, max_y, min_x, and min_y.
Referenced by Rectangle(), set_max_x(), set_max_y(), set_min_x(), set_min_y(), set_position(), shift_x(), and shift_y().
{
bounding_box = BoundingBox(min_x, max_x, min_y, max_y);
}

| bool Rectangle::complete_within | ( | Rectangle const & | rect | ) | const [virtual] |
| BoundingBox const & Rectangle::get_bounding_box | ( | ) | const [virtual] |
Get the bounding box.
Implements degate::AbstractShape.
Reimplemented in degate::Annotation, and degate::Gate.
Definition at line 62 of file Rectangle.cc.
References bounding_box.
{
return bounding_box;
}
| int Rectangle::get_center_x | ( | ) | const [virtual] |
Definition at line 172 of file Rectangle.cc.
References get_width(), and min_x.

| int Rectangle::get_center_y | ( | ) | const [virtual] |
Definition at line 176 of file Rectangle.cc.
References get_height(), and min_y.
{
return min_y + get_height() / 2;
}

| unsigned int Rectangle::get_height | ( | ) | const [virtual] |
Definition at line 115 of file Rectangle.cc.
Referenced by get_center_y(), degate::Gate::get_relative_y_position_within_gate(), and degate::Gate::set_gate_template().

| int Rectangle::get_max_x | ( | ) | const [virtual] |
| int Rectangle::get_max_y | ( | ) | const [virtual] |
| int Rectangle::get_min_x | ( | ) | const [virtual] |
Definition at line 119 of file Rectangle.cc.
References min_x.
Referenced by degate::Gate::add_port(), and degate::Gate::set_gate_template().
{
return min_x;
}

| int Rectangle::get_min_y | ( | ) | const [virtual] |
Definition at line 127 of file Rectangle.cc.
References min_y.
Referenced by degate::Gate::add_port(), and degate::Gate::set_gate_template().
{
return min_y;
}

| unsigned int Rectangle::get_width | ( | ) | const [virtual] |
Definition at line 111 of file Rectangle.cc.
Referenced by get_center_x(), degate::Gate::get_relative_x_position_within_gate(), and degate::Gate::set_gate_template().

| bool Rectangle::in_bounding_box | ( | BoundingBox const & | bbox | ) | const [virtual] |
Check, if this rectangle is in the bounding box.
Implements degate::AbstractShape.
Reimplemented in degate::Annotation, and degate::Gate.
Definition at line 82 of file Rectangle.cc.
References degate::BoundingBox::get_max_x(), degate::BoundingBox::get_max_y(), degate::BoundingBox::get_min_x(), degate::BoundingBox::get_min_y(), max_x, max_y, min_x, and min_y.
{
return ( bbox.get_min_x() <= min_x ||
bbox.get_max_x() >= max_x ||
bbox.get_min_y() <= min_y ||
bbox.get_max_y() >= max_y);
}

| bool Rectangle::in_shape | ( | int | x, |
| int | y, | ||
| int | max_distance = 0 |
||
| ) | const [virtual] |
Check in the Point with coordinates x and y is within the area of the shape.
Implements degate::AbstractShape.
Reimplemented in degate::Annotation, and degate::Gate.
Definition at line 57 of file Rectangle.cc.
| bool Rectangle::intersects | ( | Rectangle const & | rect | ) | const [virtual] |
| bool Rectangle::operator!= | ( | const Rectangle & | other | ) | const [virtual] |
Definition at line 74 of file Rectangle.cc.
{
return !(*this == other);
}
| bool Rectangle::operator== | ( | const Rectangle & | other | ) | const [virtual] |
| void Rectangle::set_max_x | ( | int | max_x | ) | [virtual] |
Definition at line 147 of file Rectangle.cc.
References calculate_bounding_box(), and min_x.
Referenced by degate::Gate::set_gate_template().
{
this->min_x = std::min(min_x, max_x);
this->max_x = std::max(min_x, max_x);
calculate_bounding_box();
}


| void Rectangle::set_max_y | ( | int | max_y | ) | [virtual] |
Definition at line 153 of file Rectangle.cc.
References calculate_bounding_box(), and min_y.
Referenced by degate::Gate::set_gate_template().
{
this->min_y = std::min(min_y, max_y);
this->max_y = std::max(min_y, max_y);
calculate_bounding_box();
}


| void Rectangle::set_min_x | ( | int | min_x | ) | [virtual] |
Definition at line 135 of file Rectangle.cc.
References calculate_bounding_box(), and max_x.
{
this->min_x = std::min(min_x, max_x);
this->max_x = std::max(min_x, max_x);
calculate_bounding_box();
}

| void Rectangle::set_min_y | ( | int | min_y | ) | [virtual] |
Definition at line 141 of file Rectangle.cc.
References calculate_bounding_box(), and max_y.
{
this->min_y = std::min(min_y, max_y);
this->max_y = std::max(min_y, max_y);
calculate_bounding_box();
}

| void Rectangle::set_position | ( | int | min_x, |
| int | max_x, | ||
| int | min_y, | ||
| int | max_y | ||
| ) | [virtual] |
Definition at line 180 of file Rectangle.cc.
References calculate_bounding_box().
{
this->min_x = std::min(min_x, max_x);
this->max_x = std::max(min_x, max_x);
this->min_y = std::min(min_y, max_y);
this->max_y = std::max(min_y, max_y);
calculate_bounding_box();
}

| void Rectangle::shift_x | ( | int | delta_x | ) | [virtual] |
Shift the shape vertically.
Note: If you store this shape in a QuadTree, you have to manage the changes in your QuadTree by yourself.
Implements degate::AbstractShape.
Reimplemented in degate::Annotation, and degate::Gate.
Definition at line 165 of file Rectangle.cc.
References calculate_bounding_box(), max_x, and min_x.
{
min_x += delta_x;
max_x += delta_x;
calculate_bounding_box();
}

| void Rectangle::shift_y | ( | int | delta_y | ) | [virtual] |
Shift the shape horizontally.
Note: If you store this shape in a QuadTree, you have to manage the changes in your QuadTree by yourself.
Implements degate::AbstractShape.
Reimplemented in degate::Annotation, and degate::Gate.
Definition at line 159 of file Rectangle.cc.
References calculate_bounding_box(), max_y, and min_y.
{
min_y += delta_y;
max_y += delta_y;
calculate_bounding_box();
}

BoundingBox degate::Rectangle::bounding_box [private] |
Definition at line 35 of file Rectangle.h.
Referenced by calculate_bounding_box(), and get_bounding_box().
int degate::Rectangle::max_x [private] |
Definition at line 33 of file Rectangle.h.
Referenced by calculate_bounding_box(), complete_within(), get_max_x(), get_width(), in_bounding_box(), in_shape(), intersects(), operator==(), Rectangle(), set_min_x(), and shift_x().
int degate::Rectangle::max_y [private] |
Definition at line 33 of file Rectangle.h.
Referenced by calculate_bounding_box(), complete_within(), get_height(), get_max_y(), in_bounding_box(), in_shape(), intersects(), operator==(), Rectangle(), set_min_y(), and shift_y().
int degate::Rectangle::min_x [private] |
Definition at line 33 of file Rectangle.h.
Referenced by calculate_bounding_box(), complete_within(), get_center_x(), get_min_x(), get_width(), in_bounding_box(), in_shape(), intersects(), operator==(), Rectangle(), set_max_x(), and shift_x().
int degate::Rectangle::min_y [private] |
Definition at line 33 of file Rectangle.h.
Referenced by calculate_bounding_box(), complete_within(), get_center_y(), get_height(), get_min_y(), in_bounding_box(), in_shape(), intersects(), operator==(), Rectangle(), set_max_y(), and shift_y().
1.7.4