Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Circle Class Reference

A drawing element representing a circle. More...

#include <Circle.h>

Inheritance diagram for Circle:

DrawElement Object List of all members.

Public Methods

 Circle ()
 Create a cirle with radius 0 at the origin.

 Circle (const Position &, color, float radius)
 Create a circle with given center, color and radius.

virtual void add_feature (std::string, float)
 Allow radius to be specified.

bool is_hit (const Position &)
 return true if position is inside the circle.

int mutate (const Position &)
 Use the new position to set the radius.

void render (SimpleWindow *)
 Draws the Circle.


Private Attributes

float radius

Static Private Attributes

Circle::Factory factory
 A factory for creating circle objects.


Detailed Description

A drawing element representing a circle.

Only used directly in the CircleTool class, although it can be used indirectly, as a DrawElement, anywhere DrawElement is used.


Constructor & Destructor Documentation

Circle::Circle  
 

Create a cirle with radius 0 at the origin.

00004 : DrawElement(), radius(0.0) {}

Circle::Circle const Position &   ,
color   ,
float    radius
 

Create a circle with given center, color and radius.

00006   : DrawElement(pos,c), radius(r) {}


Member Function Documentation

void Circle::add_feature std::string   ,
float   
[virtual]
 

Allow radius to be specified.

Reimplemented from Object.

00009 {
00010   if (key == "radius") {
00011     radius = value;
00012   } else {
00013     Object::add_feature(key,value);
00014   }
00015 }

bool Circle::is_hit const Position &    [virtual]
 

return true if position is inside the circle.

Implements DrawElement.

00018 {
00019   Position delta = pos-get_center();
00020   return abs(delta) <= radius;
00021 }

int Circle::mutate const Position &    [virtual]
 

Use the new position to set the radius.

Reimplemented from DrawElement.

00024 {
00025   radius = abs(pos-get_center());
00026   inform_location();
00027   return 1;
00028 }

void Circle::render SimpleWindow   w [virtual]
 

Draws the Circle.

Uses SimpleWindow's RenderEllipse.

Implements DrawElement.

00034 {
00035   Position delta = Position(radius,radius);
00036   w->RenderEllipse(get_center()-delta,get_center()+delta,get_color(),
00037                      is_selected());
00038 }


Member Data Documentation

Circle::Factory Circle::factory [static, private]
 

A factory for creating circle objects.

float Circle::radius [private]
 


The documentation for this class was generated from the following files:
Generated on Fri Nov 8 10:52:28 2002 for Draw by doxygen1.2.17