degate  0.1.2
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 ()
void cloneDeepInto (DeepCopyable_shptr destination, oldnew_t *oldnew) const
 Deep-copy all members to destination.
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 32 of file Rectangle.h.


Constructor & Destructor Documentation

Definition at line 30 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 38 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:

Definition at line 47 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 55 of file Rectangle.cc.

                      {
}

Member Function Documentation

Definition at line 198 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:

void Rectangle::cloneDeepInto ( DeepCopyable_shptr  destination,
oldnew_t oldnew 
) const [virtual]

Deep-copy all members to destination.

Todo:
Find out whether the default assignment operator can be used to simplify implementations of this method.

Implements degate::DeepCopyableBase.

Reimplemented in degate::Annotation, and degate::Gate.

Definition at line 58 of file Rectangle.cc.

References bounding_box, max_x, max_y, degate::BoundingBox::min_x, min_x, and min_y.

                                                                             {
  auto clone = std::dynamic_pointer_cast<Rectangle>(dest);
  clone->bounding_box = bounding_box;
  clone->min_x = min_x;
  clone->max_x = max_x;
  clone->min_y = min_y;
  clone->max_y = max_y;
}
bool Rectangle::complete_within ( Rectangle const &  rect) const [virtual]

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

Definition at line 113 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::Gate, and degate::Annotation.

Definition at line 72 of file Rectangle.cc.

References bounding_box.

                                                     {
  return bounding_box;
}
int Rectangle::get_center_x ( ) const [virtual]

Definition at line 182 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 186 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 125 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 133 of file Rectangle.cc.

References max_x.

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

Definition at line 141 of file Rectangle.cc.

References max_y.

                               {
  return max_y;
}
int Rectangle::get_min_x ( ) const [virtual]

Definition at line 129 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 137 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 121 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::Gate, and degate::Annotation.

Definition at line 92 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::Gate, and degate::Annotation.

Definition at line 67 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 100 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 84 of file Rectangle.cc.

                                                       {
  return !(*this == other);
}
bool Rectangle::operator== ( const Rectangle other) const [virtual]

Definition at line 77 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 157 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 163 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 145 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 151 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 190 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::Gate, and degate::Annotation.

Definition at line 175 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::Gate, and degate::Annotation.

Definition at line 169 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 37 of file Rectangle.h.

Referenced by calculate_bounding_box(), cloneDeepInto(), 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: