home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
-
-
-
-
- USERS GUIDE
- FOR
- PLOT FILTERS
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- David Chang
-
- Nicholas Christopher
-
- 16 June 1987
-
-
-
- 1. INTRODUCTION TO PLOT FILTERS
- The UNIX operating system has, as one of its standard libraries, a library
- which produces graphics output in a device-independent manner. This output
- can then be used as input for any compatible device-specific plot filter.
- The plot filter generates commands, that when redirected to its
- corresponding graphics device, will generate the desired graphics output.
-
- The graphics library should be linked to your C program by using the -lplot
- compiler switch.
-
-
-
- 2. COMMANDS
- The subroutines that are included in the standard UNIX Plot library
- are as follows:
-
- - openpl()
- Prepares the output device for taking
- commands. It should always be called
- before calling any other plot subroutines.
-
- - erase()
- Reinitializes the output device.
-
- - label(s) char[s];
- Places text in the output at the current
- point. It takes a string variable or a string
- in quotes as its argument. The argument is
- null-terminated and does not contain newlines.
- A local modification of the command allows the
- LN03 to use its technical font. To use the LN03
- technical font begin the label with a tilde
- character ("~"). A space-tilde, " ~", will
- allow a label in the regular font to begin
- with a tilde.
-
- - line(x1,y1,x2,y2)
- Produces a line that starts at the point
- designated by the first two arguments that are
- passed to the subroutine and terminates at the
- point designated by the final two arguments.
-
- - circle(x,y,r)
- Produces a circle whose center is given by the
- first two arguments and whose radius is given
- by the final argument.
-
- - arc(x,y,x1,y1,x2,y2)
- Produces an arc whose center is determined by
- the first two arguments. The starting
- point is given by the third and fourth
- arguments and the end point is given by the
- final two arguments. The arc is drawn
- counter-clockwise.
-
- - move(x,y)
- Changes the current point to the point given
- by the two arguments.
-
- - cont(x,y)
- Draws a point from the current point to the
- point given by the two arguments.
-
- - point(x,y)
- Draws a single point at the given coordinates.
-
- - linemod(s) char[s];
- Changes the line style to the given style.
- the styles that are available are `dotted',
- `longdashed', `shortdashed', and `dotdashed'.
-
- - space(x1,y1,x2,y2)
- Changes the plot area, using the first two
- coordinates as the upper right hand corner of
- the plotting area and the final two arguments
- as the lower left hand corner of the plotting
- area. The plot will be reduced or magnified
- to fit the device as closely as possible.
-
- - closepl()
- Closes the output device. This should always
- be called at the end of your program.
-
- There are two subroutines that have been added to the standard Plot
- library here at Columbia. They are as follows:
-
- - box(x1,y1,x2,y2)
- Draws a box using the two points that are
- passed as arguments as two corners. This
- available on all the devices.
-
- - color(n)
- Changes the pen on a multicolor pen plotter
- to the pen number designated by the argument.
- This is only available on the pen plotters and
- ink-jet printer.
-
-
-
- This graphics package can be used on the Hewlett-Packard 7470A, the DEC
-
- LVP16, the DEC LN03 laser printer, and the DEC LCP01 color ink-jet printer.
-
- The HP 7470A is a two pen plotter. The DEC LVP16 is a six pen plotter.
-
- Columbia has several pen plotters available at 251 Engineering Terrace and
-
- LN03s at both the Engineering Terrace and SIA terminal room. The use of the
-
- plotters requires your own plotter pens, which can be obtained in the Business
-
- Office, and your own 8.5" by 11" or 11" by 17" paper.
-
-
-
- 3. SAMPLE SESSION
-
- Below is an example program in the language C to put a round peg in a
-
- square hole. If you are not familiar with the C language you should be warned
-
- that it is case sensitive and so if you plan to try running the following
-
- program maintain the capitalization exactly.
- /* This is a comment */
- main() /* Start of program */
- {
- openpl(); /* Initialize plot routines */
-
- move(10,10); /* Position cursor */
- label("Demo."); /* Text starts at cursor */
-
- box(100,100,500,500); /* Draw a square hole */
- circle(300,300,200); /* Put the round peg in */
-
- move(10,600); /* Position cursor */
- label("Done!"); /* Some more text */
-
- closepl(); /* Close the plot routines */
- }
-
-
-
- Note that the only C in the entire program was "main() { }" the rest was
-
- entirely plot commands. C code could have been present, to calculate a sin wave
-
- by points for example, but knowledge of C is not required to use plot.
-
- The above code must be compiled before it will run. Assume that the above
-
- C program is in a file named peg.c. The command to compile C code which uses
-
- plot commands is as follows:
-
-
- cc -o peg peg.c -lplot
-
-
- The above command generates the program peg can be run at any time,
-
- however it is still not producing output for any specific printing device.
-
- Suppose that you were sitting at a Tektronics terminal and wanted to see the
-
- demonstration right on the screen. The command to give would be:
-
-
- peg | tek
-
-
- The above command takes the generalized output from peg and feeds it to
-
- the program tek which knows how to display graphics on a Tektronics terminal
-
- (the "|" character is called a pipe in UNIX and must be included). The tek
-
- program then produces the graphics on your screen. The command:
-
-
- peg | ln03 | lpr -Pmuddl1
-
-
- Would take the same generalized output from peg feed it to ln03 a program
-
- which creates output for the DEC LN03 printer. Then ln03 program would feeds
-
- its output to the print command, lpr -Pmuddl1, which actually prints the given
-
- output on the LN03 printer located in 251 Engineering Terrace.
-
- For further documentation look in sections 1,3 and 5 of the UNIX manual
-
- under the title plot. On a UNIX machine these manual sections can be read by
-
- saying:
- man 1 plot
- man 3 plot
- man 5 plot
-