degate  0.1.2
Public Member Functions | Private Member Functions | Private Attributes
degate::Circle Class Reference

#include <Circle.h>

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

List of all members.

Public Member Functions

 Circle ()
 Circle (int x, int y, unsigned int diameter)
virtual ~Circle ()
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 shape is in the bounding box.
virtual BoundingBox const & get_bounding_box () const
 Get the bounding box.
virtual bool operator== (const Circle &other) const
virtual bool operator!= (const Circle &other) const
virtual int get_x () const
virtual int get_y () const
virtual unsigned int get_diameter () const
virtual void set_x (int x)
virtual void set_y (int y)
virtual void set_diameter (unsigned int diameter)
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 x
int y
unsigned int diameter
BoundingBox bounding_box

Detailed Description

Definition at line 32 of file Circle.h.


Constructor & Destructor Documentation

Definition at line 31 of file Circle.cc.

References calculate_bounding_box(), diameter, x, and y.

Here is the call graph for this function:

Circle::Circle ( int  x,
int  y,
unsigned int  diameter 
)

Definition at line 36 of file Circle.cc.

References calculate_bounding_box(), diameter, x, and y.

                                                  {
  this->x = x;
  this->y = y;
  this->diameter = diameter;
  calculate_bounding_box();
}

Here is the call graph for this function:

virtual degate::Circle::~Circle ( ) [inline, virtual]

Definition at line 47 of file Circle.h.

{}

Member Function Documentation

void Circle::calculate_bounding_box ( ) [private]

Definition at line 113 of file Circle.cc.

References bounding_box, diameter, x, and y.

Referenced by Circle(), set_diameter(), set_x(), set_y(), shift_x(), and shift_y().

                                    {
  unsigned int radius = diameter / 2;
  bounding_box = BoundingBox(x - radius, x + radius,
                             y - radius, y + radius);

}

Here is the caller graph for this function:

void Circle::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::GatePort, degate::Via, and degate::EMarker.

Definition at line 43 of file Circle.cc.

References bounding_box, diameter, x, and y.

                                                                          {
  auto clone = std::dynamic_pointer_cast<Circle>(dest);
  clone->x = x;
  clone->y = y;
  clone->diameter = diameter;
  clone->bounding_box = bounding_box;
}
BoundingBox const & Circle::get_bounding_box ( ) const [virtual]

Get the bounding box.

Implements degate::AbstractShape.

Reimplemented in degate::GatePort, degate::Via, and degate::EMarker.

Definition at line 61 of file Circle.cc.

References bounding_box.

                                                  {
  return bounding_box;
}
unsigned int Circle::get_diameter ( ) const [virtual]

Definition at line 83 of file Circle.cc.

References diameter.

Referenced by degate::GatePort::print(), degate::EMarker::push_object_to_server(), and degate::Via::push_object_to_server().

                                        {
  return diameter;
}

Here is the caller graph for this function:

int Circle::get_x ( ) const [virtual]

Definition at line 74 of file Circle.cc.

References x.

Referenced by degate::EMarker::print(), degate::Via::print(), degate::GatePort::print(), degate::EMarker::push_object_to_server(), and degate::Via::push_object_to_server().

                        {
  return x;
}

Here is the caller graph for this function:

int Circle::get_y ( ) const [virtual]

Definition at line 78 of file Circle.cc.

References y.

Referenced by degate::EMarker::print(), degate::Via::print(), degate::GatePort::print(), degate::EMarker::push_object_to_server(), and degate::Via::push_object_to_server().

                        {
  return y;
}

Here is the caller graph for this function:

bool Circle::in_bounding_box ( BoundingBox const &  bbox) const [virtual]

Check if this shape is in the bounding box.

Note: it is somhow unclear if this 'in' means complete within or if an intersection is sufficient.

Implements degate::AbstractShape.

Reimplemented in degate::GatePort, degate::Via, and degate::EMarker.

Definition at line 57 of file Circle.cc.

References bounding_box, and degate::BoundingBox::in_bounding_box().

                                                          {
  return bounding_box.in_bounding_box(bbox);
}

Here is the call graph for this function:

bool Circle::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::GatePort, degate::Via, and degate::EMarker.

Definition at line 51 of file Circle.cc.

References diameter, x, and y.

                                                          {
  int delta_x = this->x - x;
  int delta_y = this->y - y;
  return sqrt((double)(delta_x * delta_x + delta_y * delta_y)) <= diameter + max_distance;
}
bool Circle::operator!= ( const Circle other) const [virtual]

Definition at line 70 of file Circle.cc.

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

Definition at line 66 of file Circle.cc.

References diameter, x, and y.

                                                 {
    return (x == other.x && y == other.y && diameter == other.diameter);
}
void Circle::set_diameter ( unsigned int  diameter) [virtual]

Reimplemented in degate::GatePort, degate::Via, and degate::EMarker.

Definition at line 97 of file Circle.cc.

References calculate_bounding_box(), and diameter.

Here is the call graph for this function:

void Circle::set_x ( int  x) [virtual]

Reimplemented in degate::GatePort, degate::Via, and degate::EMarker.

Definition at line 87 of file Circle.cc.

References calculate_bounding_box(), and x.

                        {
  this->x = x;
  calculate_bounding_box();
}

Here is the call graph for this function:

void Circle::set_y ( int  y) [virtual]

Reimplemented in degate::GatePort, degate::Via, and degate::EMarker.

Definition at line 92 of file Circle.cc.

References calculate_bounding_box(), and y.

                        {
  this->y = y;
  calculate_bounding_box();
}

Here is the call graph for this function:

void Circle::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::GatePort, degate::Via, and degate::EMarker.

Definition at line 107 of file Circle.cc.

References calculate_bounding_box(), and x.

                                {
  x += delta_x;
  calculate_bounding_box();
}

Here is the call graph for this function:

void Circle::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::GatePort, degate::Via, and degate::EMarker.

Definition at line 102 of file Circle.cc.

References calculate_bounding_box(), and y.

                                {
  y += delta_y;
  calculate_bounding_box();
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 38 of file Circle.h.

Referenced by calculate_bounding_box(), cloneDeepInto(), get_bounding_box(), and in_bounding_box().

unsigned int degate::Circle::diameter [private]
int degate::Circle::x [private]
int degate::Circle::y [private]

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