degate 0.1.1
Public Member Functions | Private Member Functions | Private Attributes
degate::Rectangle Class Reference

#include <Rectangle.h>

Inheritance diagram for degate::Rectangle:
Inheritance graph
[legend]

List of all members.

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

Detailed Description

Definition at line 30 of file Rectangle.h.


Constructor & Destructor Documentation

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();
}

Here is the call graph for this function:

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();
}

Here is the call graph for this function:

Rectangle::Rectangle ( const Rectangle o)

Definition at line 46 of file Rectangle.cc.

References calculate_bounding_box(), max_x, max_y, min_x, and min_y.

                                       {
  this->min_x = o.min_x;
  this->max_x = o.max_x;
  this->min_y = o.min_y;
  this->max_y = o.max_y;
  calculate_bounding_box();
}

Here is the call graph for this function:

Rectangle::~Rectangle ( ) [virtual]

Definition at line 54 of file Rectangle.cc.

                      {
}

Member Function Documentation

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().

Here is the caller graph for this function:

bool Rectangle::complete_within ( Rectangle const &  rect) const [virtual]

Check, if rectangle rect is complete within rectangle represented by this.

Definition at line 103 of file Rectangle.cc.

References max_x, max_y, min_x, and min_y.

                                                            {

  return (min_x <= rect.min_x &&
          max_x >= rect.max_x &&
          min_y <= rect.min_y &&
          max_y >= rect.max_y);
}
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.

                                  {
  return min_x + get_width() / 2;
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

unsigned int Rectangle::get_height ( ) const [virtual]

Definition at line 115 of file Rectangle.cc.

References max_y, and min_y.

Referenced by get_center_y(), degate::Gate::get_relative_y_position_within_gate(), and degate::Gate::set_gate_template().

                                         {
  return max_y - min_y;
}

Here is the caller graph for this function:

int Rectangle::get_max_x ( ) const [virtual]

Definition at line 123 of file Rectangle.cc.

References max_x.

                               {
  return max_x;
}
int Rectangle::get_max_y ( ) const [virtual]

Definition at line 131 of file Rectangle.cc.

References max_y.

                               {
  return max_y;
}
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;
}

Here is the caller graph for this function:

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;
}

Here is the caller graph for this function:

unsigned int Rectangle::get_width ( ) const [virtual]

Definition at line 111 of file Rectangle.cc.

References max_x, and min_x.

Referenced by get_center_x(), degate::Gate::get_relative_x_position_within_gate(), and degate::Gate::set_gate_template().

                                        {
  return max_x - min_x;
}

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

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.

References max_x, max_y, min_x, and min_y.

                                                             {
  return (x >= min_x - max_distance && x <= max_x + max_distance &&
          y >= min_y - max_distance && y <= max_y + max_distance) ? true : false;
}
bool Rectangle::intersects ( Rectangle const &  rect) const [virtual]

Definition at line 90 of file Rectangle.cc.

References max_x, max_y, min_x, and min_y.

                                                       {

  return !( rect.min_x > max_x ||
            rect.max_x < min_x ||
            rect.min_y > max_y ||
            rect.max_y < min_y);
}
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]

Definition at line 67 of file Rectangle.cc.

References max_x, max_y, min_x, and min_y.

                                                       {
  return (min_x == other.min_x &&
          max_x == other.max_x &&
          min_y == other.min_y &&
          max_y == other.max_y);
}
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();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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();
}

Here is the call graph for this function:

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();
}

Here is the call graph for this function:

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();
}

Here is the call graph for this function:

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();
}

Here is the call graph for this function:

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();
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 35 of file Rectangle.h.

Referenced by calculate_bounding_box(), and get_bounding_box().

int degate::Rectangle::max_x [private]
int degate::Rectangle::max_y [private]
int degate::Rectangle::min_x [private]
int degate::Rectangle::min_y [private]

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