Path: utzoo!mnetor!uunet!bbn.com!rsalz From: rsalz@bbn.com (Rich Salz) Newsgroups: comp.sources.unix Subject: v14i027: Device-independant graphics system, with drivers Message-ID: <598@fig.bbn.com> Date: 6 Apr 88 22:03:24 GMT Organization: BBN Laboratories Inc., Cambridge MA Lines: 722 Approved: rsalz@uunet.UU.NET Submitted-by: Joe Dellinger Posting-number: Volume 14, Issue 27 Archive-name: vplot/part22 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Vplot_Kernel/Documentation/hacker.doc.2' <<'END_OF_FILE' color 0. The box should be of the same color and fatness as the text. Which value of txovly corresponds to what action is defined in vplot.h. It is up to the device to decide how big a box around the text is appropriate for a given font. (It is probably a good idea to follow gentext's example in this.) X Pathx, pathy, upx, and upy define the size, shape, and orientation of the text. Pathx and upx are in HORIZONTAL device units, and pathy and upy are in VERTICAL device units. (This distinction is important if your device does not have aspect_ratio=1..) Note that all 4 values are FLOATS, not ints. X The vector (pathx,pathy) defines the text path, and the vector (upx,upy) defines the character up vector. (This is just like in the GKS text notation conventions.) To understand the meaning of these two vectors, consider normal horizontal text with a height of 100 pixels. (We'll assume our device has square pixels for the moment.) For this text, (pathx,pathy) = (100.,0.) and (upx,upy) = (0.,100.). Now the position of any point on this text can be expressed as a linear combination of the path vector and the up vector. This is how dev.text should represent all text internally. In this way, if we linearly transform just the path vector and the up vector, then we do the transform to every point of the text too. If we rotate both the path and up vectors, the text rotates. if we multiply both the path and up vectors by two, the text gets twice as big. If the path and up vectors are not orthogonal, the text gets sheared. X To test a device-dependent text routine, try switching between a device-dependent font and one of the gentext fonts (txfontconf.c. X From here on ERR has the same syntax as "printf", except that ERR will automatically throw a carriage-return line-feed on for you (so you don't want to end with "\n"). X After ERR has been called with type FATAL, dovplot and frontend will do necessary cleaning up, in the process calling dev.close. Device-dependent cleaning up should be done by that routine at that time. X The define ERR is used so that conflicts with other subroutines named X"error", "err", etc, can be avoided. Currently "ERR" is defined to be X"filtererror", a name we haven't had any trouble with. X X------------------------------------------------------------------------- BEING TRICKY ABOUT THE ORDER THINGS ARE PLOTTED X The external variable extern int (*genreader) (); can be changed in dev.open to point to your own routine for processing input files. You should only need to change this variable if for some reason you want to be able to change the order or way in which input files are handled, or if you want to know the actual file names of the input plot files. (You might find this handy if you are creating an interactive vplot editor, for example.) X The default input file handling routine, which is what you get if you ignore this section of the documentation, is the following. Frontend already does the job of finding all the input files, verifying that they exist, and opening them for reading. X gen_do_dovplot (nn, inpltin, innames) int nn; FILE ** inpltin; char innames[][MAXFLEN+1]; X{ X int ii; X X for (ii = 0; ii < nn; ii++) X { X pltin = inpltin[ii]; X strcpy (pltname, innames[ii]); X dovplot (); X fclose (pltin); X } X} X X"Nn" is the number of input files. "Inpltin" is an array of nn stream pointers each of which point to an open (but unread-upon) input stream. X"Innames" is the corresponding array of strings giving the associated name of the input file for each of the streams in inpltin. X The external integer "buffer_input" can be set to NO in dev.open to assure that all the input streams are unbuffered. The external integer X"allow_pipe" can be set to NO in dev.open to assure that all the input streams are seekable on. X It is possible to change most variables set by command line arguments between calls to dovplot without ill effect. There are comments in init_vplot at the end of the section of code where command line arguments are processed listing which variables have been explicitly set up to be changeable in this way. X Variables controlling the mapping between the device's and vplot's coordinate system can also be changed, but the subroutine X"reset_parameters()" in frontend must be called afterwards to reinitialize all the related variables that may need it. X X./filters/vplib/vpdovplot.c is an example of a routine that makes X2 passes through a vplot file, doing things differently the second time around. X X------------------------------------------------------------------------- THINGS THAT GET RESET BETWEEN FRAMES (AND THINGS THAT DON'T) X Vplot has many "global" parameters. Some of these get reset between frames (or between input files); a few don't. X The following parameters get reset (by reset()) at the start of every new frame: clipping windows, drawing fatness, current drawing color, text alignment mode, text font, text precision, text overlay mode, raster overlay mode, dash line pattern. X The plot style also gets reset at the start of every new frame, but it is handled separately. X The following DO NOT GET RESET AT ALL: color tables, current pen position X The global vplot origin command is another special case. Generally, this command is only used when you are creating a figure "by hand" using plas. It is reset when reset_parameters() is called, but is global otherwise. It has no libvplot command on purpose. X X------------------------------------------------------------------------- GROUPS X The begin-end group commands are provided so that a "MacDraw"-like vplot editor may be created. The device knows when groups are opened and closed, and their positions within the current plot file, via the dev.attributes(BEGIN_GROUP,...) and dev.attributes(END_GROUP,...) calls. You can use fseek to reposition the plot stream to the beginning of a desired group, and then call dovplot to plot the group again. When the group open (number one, not zero) command is processed, the device gets a chance to reset global attributes from their "initialized" values. X(For example, to change the color.) When the group close (number one) command is processed, the device gets a chance to to reposition pltin to the end of the file and so cause dovplot to think it's done and return. X It is possible for the user to violate the grouping laws, ie: begin-group and end-group commands must be paired within a file, erases may not be contained within a group. Dovplot will warn the user if this happens. How the device handles such an error, however, is up to it. Caveat user. X A group number 0 is generated by dovplot itself for each plot frame, and consists of everything in the plot frame excepting erases. Erases lie between groups. Initial erase and style commands are not contained in the first group numbered 0. Groups generated by the begin-end group commands in the vplot file are numbered from 1 on up. X The external integer "group_number" gives the number of currently open groups. X X------------------------------------------------------------------------- SEPLIB TRICKS X If you don't use the seplib versions of the filters, you can ignore this section. X Pen filters have to do some tricky things with SEPlib since the standard defaults are inappropriate. Normally seplib wants to send the header to standard out. Since the output of Pen filters are usually not redirected, this would dump the header on your screen and possibly interfere with your plot. By the same token, the data output usually SHOULD go to your screen, instead of being saved in a file or sent down a pipe. The normal SEPlib method of self-documenting also has to be subverted in order to be consistent between the SEP and non-SEP versions of the programs. X To accomplish this, several things are done: X A library "tseplib" is provided that contains routines for which the standard seplib versions had to be modified. This should be linked AHEAD of seplib so that the modified versions get taken. The routines are documented as to how they differ and why. X X"OUT" and "HEAD" are defined to be the external variables "sepoutwhere" and "sepheadwhere", respectively. These are normally "/dev/tty" and X"/dev/null". (These values are grabbed from the routine "sepwhere" in tseplib.) If these values are inappropriate for your filter (unlikely to be the case for most filters; see Vppen for an example of one) you can create your own version of this routine and make sure it gets linked in ahead of tseplib. X If head=/dev/null and this was the default in sepheadwhere and standard out is redirected, then it is assumed the user really wants some sort of header despite the fact that the Pen filter killed the real one and so a "fake" one will be created for them by frontend. Frontend will only actually write something into it if "out" is not standard out (to avoid mixing header and data). The device-dependent code may do so if it wishes, though (see Raspen for an example). The device should only use "Puthead" to write to the header, to make sure everything is done properly. The "fake" header has the advantage that information can be added to it at any time. Normal SEPlib headers must be closed before any data can be written. Thus only fake headers can have "n3=number_of_frames" added onto the header. (This is why Raspen uses fake headers.) X X------------------------------------------------------------------------- FRONTEND, and DOING IT YOURSELF X The system-user interface is split among three routines, which together are called the "frontend". X Main_vplot is responsible for finding the input files and opening them, deciding where the output should go for devices that aren't strong-willed enough to insist on figuring it out for themselves, setting up signal catching, interfacing with SEPlib, and doing self-documentation. It also calls the other 2 routines, init_vplot and proc_vplot. X Init_vplot initializes all variables and calls dev.open to open the device. X Proc_vplot processes the input files. X It is possible to skip main_vplot and call init_vplot and proc_vplot yourself directly. However, init_vplot and proc_vplot expect certain things to be set before they are called. X Init_vplot expects: X XXargc and xargv are just copies of main's argc and argv, but declared globally so that other routines (namely getpar) have access to them. XXargc and xargv should be declared in the calling program. X Callname is a string which gives the "pen filter name" of the set of device-dependent routines you want. It should have the path stripped. The device-dependent code may want to know callname in order to pick between similar devices. Callname should be declared external. X Pltout is just a copy of stdout. It is an external FILE *. X Proc_vplot expects: X Infileno gives the number of input files. It is an external integer. X Pltinname[infileno] gives the names of the input files. It is an external array of pointers to chars. X Pltinarray[infileno] gives the already-open stream pointers for the afore-mentioned files. It is an external array of FILE *'s. X That's it. It is also possible to bypass even calling proc_vplot. See sample.c in .../vplot/filters for an example of how to do this. X X------------------------------------------------------------------------- AUTHORS The present generation of pen filters were created by Joe Dellinger. The original pen programs were written by Jeff Thorson and Rob Clayton. Glenn Kroeger and Michel Debiche cleaned up the organization of the code. Wes Monroe, Chuck Karish, Rick Ottolini, Doug Wilson, and Jean-Luc Guiziou have added support for new devices. Steve Cole added dithering. Stew Levin has found and fixed obscure bugs. X COPYRIGHT Vplot is copyrighted. Please read the copyright in the accompanying X"Vplot" manual page. The copyright is not very restrictive. If you want to include vplot (or derivatives thereof) as part of some other X"public domain" or "nearly public domain" package, we can probably work something out. The desired effect of the copyright is to permit widespread distribution without somebody trying to grab control of it for themselves or trying to sell it. X SEE ALSO vplot(L) pen(L) plas(L) pldb(L) seplib(L) getpar(L) END_OF_FILE if test 29413 -ne `wc -c <'Vplot_Kernel/Documentation/hacker.doc.2'`; then echo shar: \"'Vplot_Kernel/Documentation/hacker.doc.2'\" unpacked with wrong size! fi # end of 'Vplot_Kernel/Documentation/hacker.doc.2' fi echo shar: End of archive 22 \(of 24\). cp /dev/null ark22isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 24 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.