Your program should take a single command line argument, the name of the input ascii file containing the segments. The format of the input file is as follows:
x1 y1 x2 y2 x1 y1 x2 y2 x1 y1 x2 y2 ...where x1, y1, x2, y2 are floating point numbers and (x1,y1) and (x2,y2) represent the coordinates of the two endpoints of the segment.
When invoked with a wrong number of arguments your program should display a help message like a standard unix command. Your program should handle correctly the situations when the input file does not exist and other possible error scenarios.
Include a menu that allows to select a color for the segments, toggles between two line patterns (pick two, say continuous and dotted line), and allows to quit.
Note: Your display function will be called every time the window needs to be redrawn; if you read the segments from the file every single time, that will be very inneficient! You will need to read the segments into a structure in memory.
Extra work (leading into the first project): Implement keyboard options to translate left and right. (with a predefined distance) and to zoom in and out.
Extra note: the due date is firm. Monday before class!
The format of the input file is as follows:
x1 y1 x2 y2 x1 y1 x2 y2 x1 y1 x2 y2 ...where x1, y1, x2, y2 are floating point numbers and (x1,y1) and (x2,y2) represent the coordinates of the two endpoints of the segment.
When you run your program it should like something like this:
%./shiftseg usage: shiftseg < fin > < fout > < sx > < sy > < fin >=input file name < fout >=output file name < sx >=shift amount x < sy >=shift amount y %./shiftseg f1 foo 2.3 4.5 reading input file f1. creating file foo. done. total segments=...Your program should handle correctly the case when the input file does not exist or other special cases that may occur.
For example on using command line arguments and file I/O check out fileseg.tar.
Input test files: here.