· Learn and apply 2D concepts including rubber-banding, picking, and 2D transformations.
· Explore concepts in interface design while learning to use FLTK and FLUID.
For this you will need to write a simple 2D drawing program. It has 3 parts:
1. The first part is to draw rectangles and point-to-point line segments (Polylines) using mouse input in the Fl_Gl_Window. Rectangles are drawn by clicking down on a corner and dragging the mouse and releasing at the opposite diagonal corner. Polylines are drawn by clicking on joints using the left button and ended by clicking with the right button. Both rectangles and polylines are drawn in rubber-band style (stretching from one end to the other) while being specified.
2. The second part is picking the objects drawn using the mouse. This requires your program to keep track of all the objects (rectangles and polylines) that have been created at any instant. To indicate which object has been picked you can either print it on the terminal screen or render the picked object in a different color.
3. The third component of your program should allow existing objects to be transformed, and you should be able to translate, rotate and scale any of the objects. When translating polylines, the entire polyline is transformed as a whole. You don't need to worry about moving individual points of the polyline. Constraining the movement to keep objects within the borders of the viewport is optional. You can use sliders for specifying translation, rotation and scaling.
In order to create the interface for this program you should use FLUID (Fast Light User Interface Designer). FLUID helps create nice user interfaces interactively. You can then compile the ‘.fl’ file and generate ‘.cxx’ and ‘.h’ files that can be included in your main program.
1. Allow the user to change color/fill style.
2. You can allow the user to create other shapes such as triangles, circles, etc.
· Here is a sample template (prog2TemplateUNIX.tar.gz for UNIX) or (prog2FluidTemplateUNIX.tar.gz for UNIX Fluid AND README) or (prog2TemplateWIN32 for Windows) that you can use. The template contains code for drawing basic primitives, picking, and mouse interface.
·
To submit the program log on to one of the CATS
systems (unix, teach, learn, hawking, etc.) and type
% submit cmps160-skl.s07 prog2 file1 file2 ...
·
To check what you submitted type
% peek cmps160-skl.s07 prog2
·
What to submit
1. All
source/header files used
2. The
Makefile.
3. A
README file that explains your program in brief. The README is not a substitute
for source documentation. Please make sure that your code is appropriately
documented and indented.
· In the Red Book, read the sections in Chapter 3 on Viewing and Modeling Transformations, and the sections on manipulating the Matrix Stacks. Also, read Chapter 4 on Color.
· Chapter 9 of FLTK documentation describes working with FLUID.
If you have any questions regarding the programming
assignment, please contact Jacob
Telleen
with a CC to Suresh Lodha.