DPA 4010 / 6010

Spring 2016

Polygon Editor

Homework Assignment 8

Due: Midnight, Friday April 22


Assignment:

For this project your assignment is to write an interactive C++ program that to allows the user to construct, adjust and edit a polygon. The program should open a window, and accept user input via the mouse. When the program first starts up it is in entry mode.

In entry mode, the user can enter and move vertices for the polygon. A new vertex is entered on left-button press, and can be dragged around as long as the button is held down. When the button is released the vertex is frozen. Vertex entry is completed when the middle-button is clicked, at which point the polygon is closed. During these operations, the polygon outline should be continuously updated on screen as vertices are entered and/or moved. After the polygon is closed, the program should enter editing mode.

In editing mode, the user can move existing vertices around using the left mouse button, but there should now be two additional options: deleting and inserting vertices. The user deletes a vertex by clicking on it with the right mouse button. The user inserts a new vertex by pressing the left mouse button on an edge. The new vertex is placed at the mouse position, on the edge. As long as the left-button is held down, the vertex can be dragged. When the button is released, the vertex is frozen. The polygon outline should be continuously updated on screen as vertices are entered, deleted, or dragged.

The program should not quit until either the 'q' or 'esc' key is pressed on the keyboard.


Advanced Extension: The polygon should be maintained as a linked list.

Please submit your program using the standard handin procedure. You should include your all of your source code .cpp and .h files, and a Makefile.