#include <DrawElement.h>
Inheritance diagram for DrawElement:
Public Methods | |
DrawElement (const Position &=Position(0.0, 0.0), color=Black) | |
Create something at the given position with the given fill color. | |
virtual | ~DrawElement () |
virtual void | add_feature (std::string, std::string) |
Permit color to be specified. | |
virtual void | add_feature (std::string, Position) |
Permit the center to be specified. | |
Position | get_center () const |
Return the center of the thing. | |
virtual void | move (const Position &new_center) |
Move the thing to a new place. | |
color | get_color () const |
Return the fill color of the thing. | |
virtual void | set_color (color) |
Set the fill color. | |
virtual bool | is_hit (const Position &)=0 |
Determine whether the given position is inside the shape. | |
bool | is_selected () const |
Is this element selected? If selected, it is drawn with a border. | |
virtual void | set_selected (bool) |
Set whether selected. | |
virtual int | mutate (const Position &new_position) |
Change the shape in some way given a position. | |
virtual void | render (SimpleWindow *)=0 |
Draw the thing in the window. | |
bool | set_location (Group *) |
Set the group for an orphaned element. | |
bool | reset_location (Group *) |
Remove a draw element from the group. | |
bool | check_location (Group *) |
Returns true if this element indeed has this group. | |
Protected Methods | |
void | inform_location () |
Called to let the group know that this thing has changed in some way. | |
Group * | get_location () const |
Return the group of this element. | |
Private Attributes | |
Position | center |
color | the_color |
bool | selected |
Group * | location |
Each draw element supports a generic set of operations. Each element is located inside some Group (except for the outermost group).
|
Create something at the given position with the given fill color.
|
|
00008 {} |
|
Permit the center to be specified.
Reimplemented from Object.
00020 { 00021 if (key == "center") { 00022 move(pos); 00023 } else { 00024 Object::add_feature(key,pos); 00025 } 00026 } |
|
Permit color to be specified.
Reimplemented from Object.
00011 { 00012 if (key == "color") { 00013 if (!Utilities::from_string(value,the_color)) 00014 throw unknown_feature("unknown color name " + value); 00015 } else { 00016 Object::add_feature(key,value); 00017 } 00018 } |
|
Returns true if this element indeed has this group.
00085 { 00086 return (location == loc); 00087 } |
|
Return the center of the thing.
00029 { 00030 return center; 00031 } |
|
Return the fill color of the thing.
00041 { 00042 return the_color; 00043 } |
|
Return the group of this element. This function is made protected because normally the group of an element should be either irrelevant or else known already.
00095 { 00096 return location; 00097 } |
|
Called to let the group know that this thing has changed in some way.
00090 { 00091 location->set_changed(this); 00092 } |
|
Determine whether the given position is inside the shape. May record where it hit for a mutate operation.
|
|
Is this element selected? If selected, it is drawn with a border.
00053 { 00054 return selected; 00055 } |
|
Move the thing to a new place.
Reimplemented in Group.
00035 { 00036 center = new_center; 00037 if (location) location->set_changed(this); 00038 } |
|
Change the shape in some way given a position. The type of mutation depends on the shape, and also (perhaps) on the previous hit.
Reimplemented in Circle, Group, and Rectangle.
00065 { 00066 move(new_position); 00067 return 1; 00068 } |
|
Draw the thing in the window.
|
|
Remove a draw element from the group.
|
|
Set the fill color.
Reimplemented in Group.
00047 { 00048 the_color = c; 00049 if (location) location->set_changed(this); 00050 } |
|
Set the group for an orphaned element.
00071 { 00072 if (location) return false; 00073 location = loc; 00074 return true; 00075 } |
|
Set whether selected. This function should only be called by the group in which this element resides, or (for the outermost grpup) by the drawing object itself. Reimplemented in Group.
00059 { 00060 selected = s; 00061 if (location) location->set_changed(this); 00062 } |
|
|
|
|
|
|
|
|