29
Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger [email protected]

Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger [email protected]

Embed Size (px)

Citation preview

Page 1: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

Vplot(or, why I took 7 ½ years to graduate...)

Joseph A. [email protected]

Page 2: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

2

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!

Page 3: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

3

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

Page 4: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

4

Where did Vplot come from?

• Dave Hale invented a vector font for it:

(Later we also added Hershey fonts, which look nicer...)

Page 5: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

5

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…

Page 6: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

6

Solution: The device structurestruct 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.

Page 7: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

7

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.

Page 8: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

This one tests whether polygon fill is working properly.

Page 9: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

This one tests whether the width of fat lines, height of characters, positionsof characters, and dashed-line intervals are all true to scale.

Page 10: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com
Page 11: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

11

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…

Page 12: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

12

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...)

Page 13: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

13Oops, hit a bug in the ppt postscript converter!This should be a uniform grey scale. It did areally sucky job on fattening vectors, too.

Letting vplot rasterize the plot produced a better result.

Page 14: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

14

Vplot examples

• Forgotten capabilities

• Mixing and matching

• Manual Vplot file hacking

• Repurposing a plot

Page 15: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

15

sfspike k1=5 n1=10 | sfgraph title=“\s200 \F11 CHebyshchev\^\s100 2” > plot.vpl

vplot2gif plot.vpl plot.gif fat=3 scale=1.5 yscale=.7

Page 16: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com
Page 17: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

17

Page 18: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com
Page 19: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

19

sfpldb < fig.vpl | sed –e ‘s/Cusp/Asparagus/’ | sfplas > fig2.vpl

vplot2gif fig2.vpl fig2.gif yscale=.5 txscale=1.5 dashscale=3

Page 20: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

20

vplot2eps align.vpl align.eps fat=4 color=y

Page 21: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

21

vplot2eps align.vpl align.eps fat=4 color=y yscale=.6 txscale=1.2

Page 22: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

22

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.

Page 23: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

23

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

Page 24: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

24

vppen align.vpl fat=4 yscale=.6 txscale=1.2 txsquare=no > alignv.vpl

vplot2eps alignv.vpl alignv.eps color=y

Page 25: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

25

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:

Page 26: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

26

vppen demo*.vpl gridnum=2,2 grid=2 > junkvplot2eps junk junk.eps color=y fat=2

Page 27: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

27

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…

Page 28: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

28

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?

Page 29: Vplot (or, why I took 7 ½ years to graduate...) Joseph A. Dellinger dellinja@bp.com

Thanks to all those who helped create vplot, in particular:

Jon Claerbout,Rob Clayton, andDave Hale

Dave Nichols andSteve Cole

Glenn Kroeger

Thanks to Sergey for keeping vplot alive!