COS 426 Computer Graphics - Fall 1997

Project 3 hints - user interface for curves

In menu.tcl, replace the existing code for the "Curve..." menu item under the Options menu with the following code:
.menubar.options.menu add cascade -label "Curves..."  -menu \
    .menubar.options.menu.sub1 -command options_curve
set m2 [menu .menubar.options.menu.sub1 -tearoff 0]
$m2 add radio -label "Cubic Bezier" -variable curve_type \
    -value 1
$m2 add radio -label "Catmull-Rom Spline" -variable curve_type \
    -value 2
$m2 add radio -label "Cubic B-spline" -variable curve_type \
    -value 3
In app.c, insert the following variable definition:
int curve_type;
In app.h, declare that variable:
extern int curve_type;
In main.c, in the function app_init(), link that C variable with the Tcl variable:
Tcl_LinkVar(ti, "curve_type", (char *) &curve_type, TCL_LINK_INT);
That's it. You should just need to switch on curve_type to draw the right kind of curve in app.c.