Table of Contents
Function editor
Overview
The cpfg 4.0 program makes it possible to define a function as a spline
curve in 2D.
Condition:
If for any 0<=i<n-1 (where n is the number of
control points) X(pi)<=X(pi+1) and
X(p0) = 0 and X(pn-1) = 1 then the curve might
be interpreted as y being a function of x in the range [0,
1].
Figure 1. funcedit window
The funcedit is a simple spline curve editor with built-in restrictions
so that the condition is always satisfied.
A user's view of funcedit
Funcedit command line syntax is funcedit [file]. The optional
parameter file is a function description file. By convention this file
should have extension .func. If the parameter is present then
funcedit opens the file and the user can edit an existing object.
If the file does not exist funcedit starts with a default function.
If the file argument is not present the filename is assumed noname.func.
The default function has 4 control points: (0, 0), (1/3, 0), (2/3, 0),
(1, 0).
-
To move a control point click the left mouse button on the point and drag
the point. Control points can be moved to any location if it does not violates
the condition.
-
To add a new control point click the middle mouse button at the location
where you want the new point to be added
-
To remove a control point click the middle mouse button at the point you
want to remove. The first and the last point cannot be removed. Also no
point can be removed if there are only four control points.
The right mouse button opens a popup menu. The popup menu contains the
following commands:
-
Reload - reads the function file from disk. This command can be
used as a primitive undo mechanism.
-
Save - saves the function file to disk.
-
View points - toggles display of control points
-
View segments - toggles display of lines connecting control points
-
View curve - toggles display of the funciton curve
-
View limits - toggles display of the axes and grid
-
Reload colors - rereads color configuration file (see below)
-
Exit - quits the program
Colors
Colors used to display in the funcedit can be customized by the
user. When the funcedit is launched it looks for a file funcedit
in the directory specified by the $VLABCONFIGDIR environment variable.
The user can edit this file to change the colors. The format of the file
is:
label1: R G B
label2: R G B
...
labeln: R G B
label must be one of: background, points,
segments, curve, grid, xaxis, yaxis,
labels. R, G and B are real numbers
in the range [0, 1] separated by spaces that represent red, green and blue
components of the color. At any moment when working with funcedit the user
can edit the colors file and call the command Reload colors from
the popup menu.
Function description file format
Function description is stored in a text file. The format of the file is:
range: 0.00 1.00
points: n
x1 y1
x2 y2
...
xn yn
n is the number of contorl points. It cannot be less than 4.
xi and yi are real numbers that
are x and y coordinates of control points.
Credits
funcedit has been implemented by Radek Karwowski (radekk@cpsc.ucalgary.ca).
Bugs
- No interactive view manipulation
- No undo
Contact
If you have any questions or comments you can send them by e-mail to vlab@cpsc.ucalgary.ca
or radekk@cpsc.ucalgary.ca.
Last updated by Radek
Karwowski, July 22nd, 1999