PolygonDrawing Member Functions
(created by Eric)
PolygonState GetState()
purpose:
return the state of polygon_drawing,
either INACTIVE_STATE, DRAWING_STATE, or EDITING_STATE
int CachedPolygon(void)
purpose:
return whether polygon has cached
polygon
void AcceptPolygon(unsigned char
*buffer, int width, int height)
purpose:
to rasterize the current polygon
into a buffer & copy the edited polygon
into the polygon cache
parameters:
buffer - an array of unsigned
chars interpreted as an RGBA buffer
width - the width of the
buffer
height - the height of the buffer
pre:
buffer array has size width*height*4
state == EDITING_STATE
post:
state == INACTIVE_STATE
void PastePolygon(void)
purpose:
copy the cached polygon to the
edited polygon
pre:
cached_polygon == 1
state == INACTIVE_STATE
post:
state == EDITING_STATE
void Draw(float pixel_x, float pixel_y)
purpose:
draw the polyline being drawn
or the polygon being edited
parameters:
pixel_x - this is a width in the
polygon's space that is a single
pixel width on screen
pixel_y - this is a height in
the polygon's space that is a single
pixel height on screen
pre: none - expected to exit if
state is INACTIVE_STATE
int Handle(int event, float x, float y, float pixel_x, float pixel_y)
purpose:
handle events from the window
that contains polygon drawing object:
if internal state is DRAWING_STATE
left-click creates subsequent
vertices of the polygon,
right-click closes polygon
and puts polygon in EDITING_STATE
if internal state is EDITING_STATE
shift-left-click on vertex
adds vertex to selection
shift-left-click off vertex
begins dragging a rubber-band box
shift-right-click performs same actions but de-selects vertices
left-click in selection
box begins dragging of selected vertices
left-click outside selection
box cancels selection, begins a
dragging of a rubber-band
box
left-release after dragging
adds vertices inside rubber-band box
to selection
pressing the 'insert' key
calls Insert()
pressing the 'delete' key
calls Delete()
parameters:
event - an Fl event
number
x
- the x of the point clicked in the space of the polygon
y
- the y of the point clicked in the space of the polygon
pixel_x - see Draw()
pixel_y - see Draw()
pre:
window that calls this has the
drawing lock
post:
if event is used, 1 is returned,
else 0