290 likes | 355 Views
Vplot (or, why I took 7 ½ years to graduate...). Joseph A. Dellinger dellinja@bp.com. Where did Vplot come from?. SEP was one of the first users of Unix Jon just loved to buy fancy new graphics devices Gould (200 dpi printer, greasy wet plots) Varian (300 dpi printer)
E N D
Vplot(or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com
Where did Vplot come from? • SEP was one of the first users of Unix • Jon just loved to buy fancy new graphics devices • Gould (200 dpi printer, greasy wet plots) • Varian (300 dpi printer) • Several flavors of Tektronix • Gigi (oooh, 8 colors!) • Envision (even better, 8 _settable_ colors!) • RasterTek (the “Movie” machine: 256 settable colors! WOW!) • Each of these devices had its own proprietary protocol. • They were all buggy. • SEP wanted to plot on all the different devices!
Where did Vplot come from? • Rob Clayton, circa 1979, came up with the idea of a “virtual device” and a “virtual plot language”. • This way you didn’t have to write a new program for every pairwise combination of geophysical application and plotting device! • Vplot was designed to be a superset of the various devices of the time: • 600dpi • 8 predefined, 256 user-settable colors • 4 by 3 aspect-ratio screen • screen 10.24 inches tall • a “pen” filter was written for each device to translate vplot language into that device’s language
Where did Vplot come from? • Dave Hale invented a vector font for it: (Later we also added Hershey fonts, which look nicer...)
Where did Vplot come from? • Each SEP student had a computer maintenance task assigned. • I was given the job of maintaining the various “pen” filters… • They contained 80% similar code, yet • they all interpreted vplot a little differently. • Maintaining all of them was a *@&^ nightmare…
Solution: The device structure struct device{ /* control routines */ int (*open)(); int (*reset)(); int (*message)(); int (*erase)(); int (*close)(); /* high level output */ int (*vector)(); int (*marker)(); int (*text)(); int (*area)(); int (*raster)(); int (*point)(); int (*attributes)(); /* input */ int (*getpoint)(); int (*interact)(); }; Generic high-level routines digest complex commands into simpler ones. For example: the generic polygon fill routine draws vectors back and forth inside the polygon. If you don’t care about supporting the device efficiently, all you really need to support are a minimal few low-level routines, use the generic routines for everything else, and the device can then do “everything”. Inefficiently, perhaps, but it works. That’s how we could add “raster” capabilities to vplot and immediately have EVERY device suddenly able to do raster.
Supporting a new device • First, support the commands for “move”, “draw”, “erase”, and “change drawing color”. • Add in other routines as needed to improve plotting efficiency. • One person can be writing and debugging one device-dependent routine while another person works on another. The device-independent and device-dependent parts can be worked on simultaneously as well. • Vplot has an extensive test suite that deviously exercises every part of the language, so you can test whether new code really works or not, and check that no unanticipated bugs have been introduced.
This one tests whether the width of fat lines, height of characters, positions of characters, and dashed-line intervals are all true to scale.
Surely we have evolved beyond vplot today? • Today our incompatible plotting devices are called: • X [8-bit, 16-bit, 24-bit, different screen resolutions and shapes...] • Color (RGB or CMYK), grayscale, monochrome • gif, tiff, jpeg, png... • Postscript level 1, Postscript level 3, encapsulated postscript… • Svg, Cairo, OpenGL…
Challenges • The concept of a “virtual device” is surprisingly slippery: • Fit to screen, or true scale? • Aspect ratio of screen? (Stretchy or rigid?) • Color, black and white, true grey scale, or dithered grey? • Black background or white? If black is white, what happens to the other colors, then? Does raster invert too? What if the background is set to some other random color? • Should text scale anisotropically or not? • How to handle multi-frame plots? • How to shield the user from device inadequacies? (e.g., generic routines for missing capabilities, pixc + greyc, dithering in software, limited number of colors...)
Oops, hit a bug in the ppt postscript converter! This should be a uniform grey scale. It did a really sucky job on fattening vectors, too. Letting vplot rasterize the plot produced a better result.
Vplot examples • Forgotten capabilities • Mixing and matching • Manual Vplot file hacking • Repurposing a plot
sfspike k1=5 n1=10 | sfgraph title=“\s200 \F11 CHebyshchev\^\s100 2” > plot.vplvplot2gif plot.vpl plot.gif fat=3 scale=1.5 yscale=.7
sfpldb < fig.vpl | sed –e ‘s/Cusp/Asparagus/’ | sfplas > fig2.vplvplot2gif fig2.vpl fig2.gif yscale=.5 txscale=1.5 dashscale=3
vplot2eps align.vpl align.eps fat=4 color=y yscale=.6 txscale=1.2
vplot2eps align.vpl align.eps fat=4 color=y yscale=.6 txscale=1.2 \ txsquare=no Programs that include text in their graphics should justify their output text properly, so that labels grow and shrink the right way.
vppen: the pen filter for the virtual vplot device • There are quite a lot of parameters that can be used to transform a plot while plotting it • Once you like the result, plot it with “vppen” • It then writes back out a vplot file that will produce what you see without needing any transformation parameters
vppen align.vpl fat=4 yscale=.6 txscale=1.2 txsquare=no > alignv.vplvplot2eps alignv.vpl alignv.eps color=y
Other things vppen can do • Instead of plotting, it can tell you the size and position of a plot. vppen stat=y *.vpl demo_bering.vpl: h= 7.81 w= 12.07; x=( 0.42, 12.49) y=( 1.07, 8.88) demo_impulse.vpl: h= 5.85 w= 7.95; x=( 0.62, 8.56) y=( 0.77, 6.62) demo_jon.vpl: h= 6.39 w= 13.45; x=( 0.14, 13.60) y=( 0.74, 7.12) demo_reciprocity.vpl: h= 6.61 w= 6.20; x=( 0.70, 6.90) y=( 0.40, 7.01) All 4: h= 8.48 w= 13.46; x=( 0.14, 13.60) y=( 0.40, 8.88) Total 4 plot frames. It can also take apart / combine plots in various ways:
vppen demo*.vpl gridnum=2,2 grid=2 > junkvplot2eps junk junk.eps color=y fat=2
sfvplotdiff Vplotdiff compares two vplot files and tells you if they make “the same plot”. The line numbers in its messages correspond to the line numbers pldb uses. A surprisingly difficult task…
Where to from here? • Use more of vplot’s existing features: • named groups • user-defined fonts (i.e. math ligatures?) • fonts with filled areas • hatched polygons • the “interact” option • Enhancements? • Incorporate some modern fonts (need splines) • More colors • Interface to a GUI editor? • Higher-resolution coordinates? • 3D? • Two-way communication?
Thanks to all those who helped create vplot, in particular: Jon Claerbout, Rob Clayton, and Dave Hale Dave Nichols and Steve Cole Glenn Kroeger Thanks to Sergey for keeping vplot alive!