source: branches/stable/GDE/PHYLIP/doc/draw.html

Last change on this file was 2176, checked in by westram, 21 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 41.6 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<HTML>
3<HEAD>
4<TITLE>main</TITLE>
5<META NAME="description" CONTENT="draw">
6<META NAME="keywords" CONTENT="draw">
7<META NAME="resource-type" CONTENT="document">
8<META NAME="distribution" CONTENT="global">
9<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
10</HEAD>
11<BODY BGCOLOR="#ccffff">
12<DIV ALIGN=RIGHT>
13version 3.6
14</DIV>
15<P>
16<DIV ALIGN=CENTER>
17<H1>DRAWTREE and DRAWGRAM</H1>
18</DIV>
19<P>
20&#169; Copyright 1986-2002 by The University of
21Washington.  Written by Joseph Felsenstein.  Permission is granted to copy
22this document provided that no fee is charged for it and that this copyright
23notice is not removed.
24<P>
25DRAWTREE and DRAWGRAM are interactive tree-plotting programs that take a
26tree description in a file and read it, and then let you interactively make
27various settings and then plot the tree on a laser printer, plotter,
28or dot matrix printer.  In many cases (with  Macintosh or PC graphics,
29with X windows, or with a Tektronix-compatible graphics terminal)
30you can preview the resulting tree.  This allows you to modify the tree
31until you like the result, then plot the result.  DRAWTREE plots
32unrooted trees and DRAWGRAM plots rooted cladograms and phenograms.  On
33good laser printers or as files for good drawing programs both can produce
34fully publishable
35results.  On dot matrix printers the results look grainy but are good
36enough for overhead transparencies or slides for presentations.
37<P>
38These programs are descended from PLOTGRAM and PLOTREE written by
39Christopher Meacham.  I have incorporated his code for fonts and his
40plotter drivers, and in DRAWTREE have used some of his code for drawing
41unrooted trees.  In both programs I have also included some plotter driver
42code by David Swofford, Julian Humphries and George D.F. "Buz" Wilson,
43to all of whom I am very grateful.  Mostly, however, they consist of my own
44code and that of my programmers.  The font files are printable-character
45recodings of the public-domain Hershey fonts, recoded by Christopher Meacham.
46<P>
47This document will describe the features common to both programs.  The
48documents for DRAWTREE and DRAWGRAM describe the particular choices you
49can make in each of those programs.  The Appendix to this documentation file
50contains some pieces of C code that can be inserted to make the program
51handle another plotting device -- the plotters by Calcomp.
52<P>
53<H2>A Short Introduction</H2>
54<P>
55To use DRAWTREE and DRAWGRAM, you must have
56<P>
57<DL COMPACT>
58<DT>(1)</DT> <DD>The compiled version of the program.  If you have not obtained a
59version of PHYLIP precompiled for your machine, you will have to take
60the source code given here and modify it for your C
61compiler and then compile it.  This is not too hard: it is discussed below.</DD>
62<P>
63<DT>(2)</DT> <DD>A tree file.  Trees are described in the nested-parenthesis notation
64used throughout PHYLIP and standardized in an informal meeting of
65program authors in Durham, New Hampshire in June, 1986.  Trees for
66both programs may be either bifurcating or multifurcating, and may
67either have or not have branch lengths.  Tree files produced by
68the PHYLIP programs are in this form. There is further description of the
69tree file format later in this document.</DD>
70<P>
71<DT>(3)</DT> <DD>A font file.  There are six font files distributed with PHYLIP:
72these consist of three Roman, two Italic, and one Russian Cyrillic font,
73all from the public-domain
74Hershey Fonts, in ASCII readable form.  The details of font
75representation need not concern you; all you need to do is to copy the
76font file corresponding to the font you want into the appropriate
77directory under the appropriate file name, and let the program use it.
78Or you can let the program ask you for the name of the font file, which
79it will do if it does not find one itself.
80The six fonts are, respectively, a one- and a two-stroke sans-serif
81Roman font, a three-stroke serifed Roman font, a two- and a three-
82stroke serifed Italic font, and a two-stroke Cyrillic font for the Russian
83language.  If this is not clear just try them all.  Note that for some
84printers several built-in fonts such as Times-Roman and Courier can be used
85too.</DD>
86<P>
87<DT>(4)</DT> <DD>A plotting device, and if possible a screen on which you can preview
88the plot.  The programs work with Postscript-compatible laser printers,
89laser printers compatible with the PCL printer language of the Hewlett-Packard
90Laserjet series,
91IBM PC graphics screens,
92the PICT format for the MacDraw drawing program,
93the PCX file format for the PC Paintbrush painting program,
94the file format for the freeware X-windows drawing programs <TT>xfig</TT> and
95<TT>idraw</TT>,
96the X Bitmap format for X-windows,
97plotters including Hewlett-Packard models, dot matrix printers including
98models by Epson and Apple, graphics terminals from DEC and Tektronix,
99the input format for the freeware ray-tracing (3-dimensional rendering)
100programs <TT>POV</TT> and <TT>rayshade</TT>,
101and, strangest and most wonderful of all,
102the Virtual Reality Markup Language (VRML) which is a file format that is
103used by freely-available virtual reality programs like Cosmo Player.
104You can choose the plotting and previewing
105devices from a menu at run time, and these can be different.  There are
106places in the source code for the program where you can insert code for
107a new plotter, should you want to do that.</DD>
108</DL>
109<P>
110Once you have all these, the programs should be fairly self explanatory,
111particular if you can preview your plots so that you can discover the
112meaning of the different options by trying them out.
113<P>
114Once you have a compiled version of the appropriate program, say
115DRAWGRAM, and a file called (say) <TT>treefile</TT> with the tree in it, and
116a font file (say <TT>font2</TT> which you have copied as a file called
117<TT>fontfile</TT>),
118all you do is run the program DRAWGRAM.  It should automatically read the
119font and tree files, and will allow you to change the graphics devices.  Then
120it will let you see the options it has chosen, and ask you if you
121want to change these.  Once you have modified those that you want to,
122you can tell it to accept those.  The program will then allow you to
123preview the tree on your screen, if you have told it that you have
124an appropriate graphics screen. After
125previewing the tree, the program will want to know whether you are ready to
126plot the tree.  In Windows you answer this using the File menu of the preview
127window.  In X Windows and Macintosh systems you can close the preview
128window by clicking on its corner.  Whether or not you close it, if you
129get back to the text window that had the menus, and it accepts typing in
130that window, you will be asked whether you want to accept the plot as is.
131If you say no, it will once again allow you to change options and
132will the allow you to preview the tree again, and so on as many times
133as you want.  If you say yes, then it will write a file called (say)
134<TT>plotfile</TT>.  If you then copy this file to your printer or plotter,
135it should result in a beautifully plotted tree.  If the final plotting
136device is a Macintosh or PC graphics screen, it may not write a plot file
137but will plot directly on the screen.
138<P> 
139Having read the above, you may be ready to run the program.  Below you
140Will find more information about representation of trees in the tree
141file, on the different kinds of graphics devices supported by this
142program, and on how to recompile these programs.
143<P>
144<H2>Trees</H2>
145<P>
146The Newick Standard for representing trees in computer-readable
147form makes use of the correspondence between trees and nested
148parentheses, noticed in 1857 by the famous English mathematician Arthur
149Cayley.  If we have this rooted tree:
150<P>
151<PRE>
152                         A                 D
153                          \         E     /
154                           \   C   /     /
155                            \  !  /     /
156                             \ ! /     /
157                        B     \!/     /
158                         \     o     /
159                          \    !    /
160                           \   !   /
161                            \  !  /
162                             \ ! /
163                              \!/
164                               o
165                               !
166                               !
167</PRE>
168<P>
169then in the tree file it is represented by the following sequence of printable
170characters, starting at the beginning of the file:
171<P>
172(B,(A,C,E),D);
173<P>
174The tree ends with a semicolon.  Everything after the semicolon in the
175input file is ignored, including any other trees.  The bottommost node
176in the tree is an interior node, not a tip.  Interior nodes are
177represented by a pair of matched parentheses.  Between them are
178representations of the nodes that are immediately descended from that
179node, separated by commas.   In the above tree, the immediate
180descendants are B, another interior node, and D.  The other interior
181node is represented by a pair of parentheses, enclosing representations
182of its immediate descendants, A, C, and E.
183<P>
184Tips are represented by their names.  A name can be any string of
185printable characters except blanks, colons, semcolons, parentheses, and
186square brackets.  In the programs a maximum of 20 characters are allowed
187for names: this limit can easily be increased by recompiling the program
188and changing the constant
189declaration for "MAXNCH" in <TT>phylip.h</TT>.
190<P>
191Because you may want to include a blank in a name, it is assumed that
192an underscore character ("_") stands for a blank; any of these in a
193name will be converted to a blank when it is read in.  Any name may also
194be empty: a tree like
195<P>
196(,(,,),);
197<P>
198is allowed.   Trees can be multifurcating at any level (while in many
199of the programs multifurcations of user-defined trees are not allowed
200or restricted to a trifurcation at the bottommost level, these programs
201do make any such restriction).
202<P>
203Branch lengths can be incorporated into a tree by putting a real
204number, with or without decimal point, after a node and preceded by
205a colon.  This represents the length of the branch immediately
206below that node.  Thus the above tree might have lengths
207represented as:
208<P>
209(B:6.0,(A:5.0,C:3.0,E:4.0):5.0,D:11.0);
210<P>
211These programs will be able to make use of this information only if
212lengths exist for every branch, except the one at the bottom of
213the tree.
214<P>
215The tree starts on the first line of the file, and can continue to
216subsequent lines.  It is best to proceed to a new line, if at all,
217immediately after a comma.  Blanks can be inserted at any point except
218in the middle of a species name or a branch length.
219<P>
220The above description is of a subset of the Newick Standard.  For
221example, interior nodes can have names in that standard, but if
222any are included the present programs will omit them.
223<P>
224To help you understand this tree representation, here are some trees
225in the above form:
226<P>
227<PRE>
228((raccoon:19.19959,bear:6.80041):0.84600,((sea_lion:11.99700,
229seal:12.00300):7.52973,((monkey:100.85930,cat:47.14069):20.59201,
230weasel:18.87953):2.09460):3.87382,dog:25.46154);
231<P>
232(Bovine:0.69395,(Gibbon:0.36079,(Orang:0.33636,(Gorilla:0.17147,(Chimp:0.19268,
233Human:0.11927):0.08386):0.06124):0.15057):0.54939,Mouse:1.21460);
234<P>
235(Bovine:0.69395,(Hylobates:0.36079,(Pongo:0.33636,(G._Gorilla:0.17147,
236(P._paniscus:0.19268,H._sapiens:0.11927):0.08386):0.06124):0.15057):0.54939,
237Rodent:1.21460);
238<P>
239();
240<P>
241((A,B),(C,D));
242<P>
243(Alpha,Beta,Gamma,Delta,,Epsilon,,,);
244</PRE>
245<P>
246The Newick Standard was adopted June 26, 1986 by an informal
247committee meeting during the Society for the Study of Evolution
248meetings in Durham, New Hampshire and consisting of James Archie,
249William H.E. Day, Wayne Maddison, Christopher Meacham, F. James Rohlf,
250David Swofford, and myself.  A web page describing it will be found
251at <A HREF="http://evolution.gs.washington.edu/phylip/newicktree.html">
252http://evolution.gs.washington.edu/phylip/newicktree.html</A>.
253<P>
254<H2>Plotter file formats</H2>
255<P>
256When the programs run they have a menu which allows you to set (on its
257option P) the final plotting device, and another menu which allows you
258to set the type of preview screen.  The
259choices for previewing are a subset of those available for plotting,
260and they can be different (the most useful combination will usually be a
261previewing graphics screen with a hard-copy plotter or a drawing program
262graphics file format).
263<P>
264The plotting device menu looks like this:
265<P>
266<TABLE><TR><TD BGCOLOR=white>
267<PRE>
268   type:       to choose one compatible with:
269
270        L         Postscript printer file format
271        M         PICT format (for drawing programs)
272        J         HP Laserjet PCL file format
273        W         MS-Windows Bitmap
274        F         FIG 2.0 drawing program format         
275        A         Idraw drawing program format           
276        Z         VRML Virtual Reality Markup Language file
277        P         PCX file format (for drawing programs)
278        K         TeKtronix 4010 graphics terminal
279        X         X Bitmap format
280        V         POVRAY 3D rendering program file
281        R         Rayshade 3D rendering program file
282        H         Hewlett-Packard pen plotter (HPGL file format)
283        D         DEC ReGIS graphics (VT240 terminal)
284        E         Epson MX-80 dot-matrix printer
285        C         Prowriter/Imagewriter dot-matrix printer
286        T         Toshiba 24-pin dot-matrix printer
287        O         Okidata dot-matrix printer
288        B         Houston Instruments plotter
289        U         other: one you have inserted code for
290 Choose one:
291</PRE>
292</TD></TR></TABLE>
293<P>
294Here are the choices, with some comments on each:
295<P>
296<B>Postscript printer file format.</B>  This means that the program will
297generate a file containing Postscript commands as its plot file.  This
298can be printed on any Postscript-compatible laser printer.  The page
299size is assumed to be 8.5 by 11 inches, but as plotting is within this
300limit A4 metric paper should work well too.  This is the best
301quality output option.  For this printer the menu options in DRAWGRAM
302and DRAWTREE that allow you to select one of the built-in fonts will
303work. The programs default to Times-Roman when this plotting option
304is in effect.  I have been able to use fonts Courier, Times-Roman, and
305Helvetica.  The others have eluded me for some reason known only to those
306who really understand Postscript.
307<P>
308If your laser printer, supposedly
309Postcript-compatible, refuses to print the plot file, you might
310consider whether the first line of the plot file, which starts with <TT>%!</TT>
311needs to be altered somehow or eliminated.  If your Laserwriter is hooked to
312a Macintosh it will be necessary
313to persuade it to print the plot file.
314In recent versions of the Macintosh operating systems this can supposedly
315be done by dragging the file icon onto the printer icon on the desktop.
316In earlier versions of the MacOS operating system you might have to use
317a utility called the Laserwriter Font Utility, which was distributed with the
318operating system.
319<P>
320<B>PICT format (for drawing programs).</B>  This file format is read by
321many drawing programs (an early example was MacDraw).  It has support for
322some fonts, though if fonts are used the species names can only be drawn
323horizontally or vertically, not at other angles in between.  The control over
324line widths is a bit rough also, so that some lines at different angles
325may turn out to be different widths when you do not want them to be.
326If you are working on a Macintosh system and have not been able to persuade
327it to print a Postscript file, this option may be the best solution, as you
328could then read the file into a drawing program and then order it to print
329the resulting screen.   The PICT file format has font support, and the
330default font for this plotting option is set to Times.  You can also
331choose font attributes for the labels such as Bold, Italic, Outline, and
332Shadowed.
333<P>
334<B>HP Laserjet PCL file format.</B>  Hewlett-Packard's extremely popular line
335of laser printers has been emulated by many other brands of laser printer,
336so that this format is compatible with more printers than any other.
337One limitation of the PCL4
338command language for these printers is that it does not have primitive
339operations for drawing arbitrary diagonal lines.  This means that they must
340be treated by these programs as if they were dot matrix printers with a
341great many dots.  This makes output files large, and output can be slow.
342The user will be asked to choose
343the dot resoluton (75, 150, or 300 dots per inch).  The 300 dot per inch
344setting should not be used if the laser printer's memory is less than
345512k bytes.  The quality of output is also not as good as it might
346be so that the Postscript file format will usually produce better results even
347at the same resolution.  I am
348grateful to Kevin Nixon for inadvertently pointing out that on Laserjets one
349does not have to dump the complete bitmap of a page to plot a tree.
350<P>
351<B>MS-Windows Bitmap.</B>  This file format is used by most Windows
352drawing and paint programs, including Windows Paint which comes with the
353Windows operating system.  It asks you to choose the height and width
354of the graphic image in pixels.  For the moment, the image is set to be
355a monochrome image which can only be black or white.  We hope to change
356that soon, but note that by pasting the image into a copy of Paint that
357is set to have a color image of the appropriate size, one can get a version
358whose color can be changed.  Note also that Windows Bitmap files can be
359used as "wallpaper" images for the background of a desktop.
360<P>
361<B>IBM PC graphics screens.</B> The code for this in the programs is available
362in the precompiled PC executables or if you compile the programs
363yourself in C.  The graphics modes supported are CGA, EGA, VGA,
364Hercules, and AT&T (Olivetti).
365This option is also available for previewing plots, and
366in either previewing or final plotting it draws directly on the screen
367and does not make a plot file.
368<P>
369<B>FIG 2.0 drawing program format.</B> This is the file format of the
370free drawing program Xfig, available for X-windows systems on Unix or
371Linux systems.  Xfig
372can be <A HREF="http://duke.usask.ca/~macphed/soft/fig/">obtained from</A>
373<TT>http://duke.usask.ca/~macphed/soft/fig/</TT>
374<P>
375You should also get transfig, which contains the fig2dev program which converts
376xfig output to the various printer languages.  Transfig is on the same machine
377in
378<P>
379<PRE>
380    /contrib/R5fixes/transfig-patches/transfig.2.1.6.tar.Z.
381</PRE>
382<P>
383The present format
384does not write the species labels in fonts recognized by
385Xfig but draws them with lines.  This often makes the names look rather
386bumpy.  We hope to change this soon.
387<P>
388<B>Idraw drawing program format.</B>  Idraw is a free drawing program for
389X windows systems (such as Unix and Linux systems).  Its interface is
390loosely based on MacDraw, and I find it much more useable than Xfig.
391Though it was unsupported for a number of years, it has more recently
392been actively supported by Scott Johnston, of
393<A HREF="http://www.vectaport.com/index.html">Vectaport, Inc.</A> (<TT>http://www.vectaport.com</TT>).  He has produced, in his <TT>ivtools</TT> package, a number
394of specialized versions of Idraw, and he also distributes the original
395Idraw as part of it.  Linux executables for all these are available from
396Vectaport, or from various archive machines.
397<P>
398The Idraw file format that our programs produce can be read into Idraw, or
399can be imported into the other Ivtools programs.  The file format saved
400from Idraw (or which can be exported from the other Ivtools programs)
401is Postscript, and if one does not print directly from Idraw one can
402simply send the file to the printer.  But the format we produce is missing
403some of the header information and will not work directly as a Postscript
404file.  However if you read it into Idraw and then save it (or import it into
405one of the other Ivtools programs and then export it) you will get a Postscript
406version that is fully useable.
407<P>
408DRAWGRAM and DRAWTREE have font support in their Idraw file format options.
409The default font is Times-Bold but you can also enter the name of any
410other font that is supported by your Postscript printer.  Idraw labels
411can be rotated to any angle.
412<P>
413<B>VRML Virtual Reality Markup Language file.</B>  This is by far the most
414interesting plotting file format.  VRML files describe objects in 3-dimensional
415space with lighting on them.  A number of freely available "virtual reality
416browsers" such as Cosmo Player can read VRML files.
417<A HREF="http://www.web3d.org/vrml/browpi.htm">A list of available virtual reality browsers and browser plugins</A>
418can be found at <TT>http://www.web3d.org/vrml/browpi.htm</TT>.
419These allow you to
420wander around looking at the tree from various angles, including from
421behind!  At the moment our VRML output is primitive, with labels that
422always look the same no matter what angle you look at them from, and
423with a "sun" that is always behind you.  The tree is made of three-dimensional
424tubes but is basically flat.  We hope to change these soon.  What's
425next?  Trees whose branches stick out in three dimensions? Animated trees
426whose forks rotate slowly? 
427A video game involving combat among schools of systematists?
428<P>
429<B>PCX file format (for drawing programs).</B>  A bitmap format that was
430formerly much used on the PC platform, this has been largely superseded by
431the Windows Bitmap (BMP) format, but it is still useful.  This file format
432is simple and is read by many other programs as well.  The user must
433choose one of three resolutions for the file, 640x480, 800x600, or 1024x768.
434The file is a monochrome paint file.   Our PCX format is correct but is not
435read correctly by versions of Microsoft Paint (PBrush) that are running on
436systems that have loaded Word97.
437<P>
438<B>Tektronix 4010 graphics terminal.</B>  The plot file will contain commands
439for driving the Tektronix series of graphics terminals. Other
440graphics terminals were compatible with the Tektronix 4010 and its
441immediate descendants.  The PCDOS version of the public domain communications
442program Kermit, versions 2.30 and later, can emulate a Tektronix
443graphics terminal if the command "set terminal tek" is given.  Of course
444that assumes that you are communicating with another computer.  There are
445also similar terminal emulation programs for Macintoshes that emulate
446Tektronix graphics.  On workstations with X windows you can use one option of
447the "xterm" utility to create a Tektronix-compatible window.  On Sun
448workstations there used to be a
449Tektronix emulator you can run called "tektool" which can be used to
450view the trees.  The Tektronix option is also available in our programs
451for previewing the plots, in which case the plotting commands will be not be
452written into a file but will be sent directly to your terminal.
453<P>
454<B>X Bitmap format.</B>  This produces an X-bitmap for the X Windows system
455on Unix or Linux systems,
456which can be displayed on X screens.  You will be asked for the
457size of the bitmap (e.g., 16x16, or 256x256, etc.).  This format
458cannot be printed out without further format conversion but is
459usable for backgrounds of windows ("wallpaper").  This can be a very
460bulky format if you choose a large bitmap.  The bitmap is a structure
461that can actually be compiled into a C program (and thus built in to it),
462if you should have some reason for doing that.
463<P>
464<B>POVRAY 3D rendering program file.</B>  This produces a file for the
465free ray-tracing program POVRay (Persistence of Vision Raytracer),
466which is <A HREF="http://www.povray.org/">available at</A>
467<TT>http://www.povray.org/</TT>.
468It shows a tree floating above a flat landscape.  The tree is flat but
469made out of tubes (as are the letters of the species names).  It
470casts a realistic shadow across the landscape. lit from over the left
471shoulder of the viewer.  You will be asked to confirm the colors of the
472tree branches, the species names, the background, and the bottom plane.
473These default to Blue, Yellow, White, and White respectively.
474<P>
475<B>Rayshade 3D rendering program file.</B> The input format for the
476free ray-tracing program "rayshade" which is
477<A HREF="http://www-graphics.stanford.edu/~cek/rayshade/rayshade.html">available</A>
478at <TT>http://www-graphics.stanford.edu/~cek/rayshade/rayshade.html</TT>
479for many kinds of systems.  Rayshade
480takes files of this format and turns them into color scenes in "raw"
481raster format (also called "MTV" format after a raytracing
482program of that name).  If you get the pbmplus package
483(<A HREF="http://sourceforge.net/projects/netpbm/">available from</A>
484<TT>http://sourceforge.net/projects/netpbm/</TT>).
485and compile it on your system
486you can use the "mtvtoppm" and "ppmtogif" programs to convert this
487into the widely-used GIF raster format. (the pbmplus package will also
488allow you to convert into tiff, pcx and many other formats) The
489resultant image will show a tree floating above a landscape, rendered
490in a real-looking 3-dimensional scene with shadows and illumination.
491It is possible to use Rayshade to
492make two scenes that together are a stereo pair.  When producing
493output for Rayshade you will be asked by the DRAWGRAM or DRAWTREE
494whether you want to reset the values for the colors you want for the
495tree, the species names, the background, and the desired resolution.
496<P>
497<B>Hewlett-Packard pen plotter (HPGL file format).</B>
498This means that the program will generate a
499file as its plot file which uses the HPGL graphics language.  Hewlett-Packard
5007470, 7475, and many other plotters are compatible with this.  The
501paper size is again assumed to be 8.5 by 11 inches (again, A4 should
502work well too).  It is assumed that there are two pens, a finer one for
503drawing names, and the HPGL commands will call for switching between
504these.  The Hewlett-Packard Laserjet III printer can emulate an HP plotter,
505and this feature is included in its PCL5 command language (but not in the
506PCL4 command languages of earlier Hewlett-Packard models).  As plotters
507are now rare the main use of HPGL will be when they are emulated by
508laser printers, but other file formats such as PCL and Postscript will be
509better choices in those cases.
510<P>
511<B>DEC ReGIS graphics (VT240 terminal).</B> The DEC ReGIS standard is
512used by the VT240 and VT340 series terminals by DEC (Digital Equipment
513Corporation).  There used to be many graphics terminals that emulate the
514VT240 or VT340 as well.  The DECTerm windows in many versions
515of Digital's (now Compaq's) DECWindows windowing system do so.
516This option is available in our programs for
517previewing trees as well.  In preview mode it does not write a plot file
518but sends the commands directly to the screen; in final mode it writes a
519plot file.  In DEC's version of Unix, Ultrix version 4.1 and later,
520the windowing system allows DEC ReGIS graphics as a default.
521<P>
522<B>Epson MX-80 dot-matrix printer.</B>  This file format is for the dot-matrix
523printers by Epson (starting with the MX80 and continuing on to many other
524models), as well as the IBM Graphics printers.  The code here plots in
525double-density graphics mode.  Many of the later models are capable of
526higher-density graphics but not with every dot printed.  This
527density was chosen for reasonably wide compatibility.  Many other dot-matrix
528printers on the market have graphics modes compatible with the
529Epson printers.  I cannot guarantee that the plot files generated by
530these programs will be compatible with all of these, but they do work on
531Epsons.  They have also worked, in our hands, on IBM Graphics Printers.  There
532used to be many printers that claimed compatibility with these too, but I
533do not know whether it will work on all of them.  If you have trouble
534with any of these you might consider trying in the epson option of
535procedure initplotter to put in a fprintf statement
536that writes to plotfile an escape sequence that changes line spacing.
537As dot matrix printers are rare these days, I suspect this option will
538not get much testing.
539<P>
540<B>Prowriter/Imagewriter dot-matrix printer.</B>
541The trading firm C. Itoh distributed this line of
542dot-matrix printers, which was made by Tokyo Electric (TEC) and also was
543sold by NEC under the product number PC8023.  These were 9-pin dot matrix
544printers.  In a slightly modified form they were also the Imagewriter
545printer sold by Apple for their Macintosh line.  The same escape codes
546seem to work on both machines, the Apple version being a serial
547interface version.  They are not related to the IBM Proprinter, despite
548the name.
549<P>
550<B>Toshiba 24-pin dot-matrix printer.</B>
551The 24-pin printers from Toshiba were covered
552by this option.  These included the P1340, P1350, P1351, P351, 321, and
553later models.  For a 24-pin printer the plot file can get fairly large
554as it contains a bit map of the image and there are more bits with a
55524-pin image.  Printing was usually slow.
556<P>
557<B>Okidata dot-matrix printer.</B>
558The ML81, 82, 83 and ML181, 182, 183 line of dot-matrix
559printers from Okidata had their own graphics codes and those are dealt
560with by this option.  The later Okidata ML190 series emulated IBM Graphics
561Printers so that you would not want to use this option for them but the option
562for that printer.
563<P>
564<B>Houston Instruments plotter.</B> The Houston Instruments line of plotters
565were also known as Bausch and Lomb plotters.  The code in the
566programs for these has not been tested recently; I would appreciate
567anyone who tries it out telling me whether it works.  I do not have
568access to such a plotter myself, and doubt most users will come across one.
569<P>
570Conversion from these formats to others is also possible.
571There is a free program by Jef Poskanzer called "PBMPLUS" that interconverts
572many bitmap formats (see above under Rayshade).
573<P>
574<H2>Drivers for Preview of Plots</H2>
575<P>
576Plots may be previewed in a number of formats which are chosen using the
577menu option.  Previewing defaults to different drivers depending on which
578kind of system you are running the programs on.  For Unix or Linux systems
579it defaults to X Windows, for Windows systems to Windows graphics, and
580for Macintosh systems to macintosh graphics screens.
581<P>
582We have already mentioned (above) some of the options that are also used
583for previewing.  These include:
584<P>
585<B>MSDOS Graphics Screens.</B>  These were mentioned
586above as possible output images.
587<P>
588<B>Macintosh graphics screens.</B>   Using the windowing features of
589Codewarrior C from Metrowerks, our Macintosh executables
590open a graphics window and draw preview trees in it.  We have
591not provided this option for final plotting of the tree.
592The window is about 2/3 the height of the desktop screen and has the tree drawn
593in black on a white background.
594After the preview appears, you can dismiss the window by closing it
595using the usual little box in its corner, or by typing Command-Q.
596<P>
597<B>X Windows display.</B>  Our Unix and Linux code tries to do previews
598in X Windows.  We hope that the Unix/Linux Makefle will find the correct
599libraries to link from.  An X window appears with the preview of the tree
600in it.  To dismiss this window one needs to put the mouse over the
601text window that had the menus in it (or click on them) and then type Y
602or N to plot the tree or return to the menu.
603<P>
604<B>MS Windows display.</B>  The executables produced using the Cygwin
605Gnu C++ compiler should produce this graphics preview window.  The preview
606window can be dismissed using its File menu.  In its menu the Change
607Parameters otion will lead you back to the text menu to make more
608changes, and the Plot option will cause the final plot file to be written.
609The Quit option will interrupt the program, causing no plot file to b produced.
610Normally you will not want to use that option.
611<P>
612<B>Tektronix 4010 graphics terminal.</B>  This previewing option was
613described above as a final plot option.
614<P>
615<B>DEC ReGIS graphics (VT240 terminal).</B>  This previewing option was
616described above as a final plot option.
617<P>
618<H2>Problems Copying Files to Printers</H2>
619<P>
620A problem may arose in how to get the plot files to the plotting device
621or printer.  One has to copy them directly, but one should be careful to
622not let your serial or parallel port strip off the high-order bits in the
623bytes if you are using one of the options that generate nonprintable
624characters.  This will be true for most of the dot matrix printers and
625for bitmaps dumped to an HP Laserjet-compatible printer.  This can be
626a problem under Unix or MSDOS.  If, for example, you have a dot-matrix
627printer connected to a parallel port under PCDOS, to copy the file
628PLOTFILE to the printer without losing the high-order bits, you must use
629the /B switch on the COPY command:
630<P>
631<PRE>
632  COPY/B PLOTFILE PRN:
633</PRE>
634<P>
635<H2>The VAX VMS Line Length Problem</H2>
636<P>
637A problem that may occur under some operating systems, particularly the
638VMS operating system for Digital VAXes, is having a plot file with lines
639that exceed some operating system limit such as 255 characters.  This can
640happen if you are using the Tektronix option.
641You should set your terminal type with the
642command
643<P>
644<PRE>
645   $ SET TERM/NOWRAP/ESCAPE
646</PRE>
647<BR>
648which will allow Tektronix and DEC ReGIS
649plots to successfully appear on your terminal.  That way, if you have a
650terminal capable of plotting one of these kinds of plots, the operating
651system will not interfere with the process.  It will not be possible to
652use files of Tektronix commands as final plot files, however, as the TYPE
653command usually used to get them to appear on the screen does not allow
654lines longer than 2048 bytes, and Tektronix plots are single lines longer
655than that.
656<P>
657<H2>Other problems and opportunities</H2>
658<P>
659Another problem is adding labels (such as vertical scales and branch
660lengths) to the plots produced by this program.  This may require you to
661use the BMP, PICT, Idrawm, Xfig, PCX or Postscript file format and use a draw
662or paint program to add them.
663<P>
664I would like to add more fonts.  The present fonts are recoded versions of
665the Hershey fonts.  They are legally publicly distributable.  Most other font
666families on the market are not public domain and I cannot
667afford to license them for distribution.  Some people have noticed that the
668Hershey fonts, which are drawn by a series of straight lines, have noticeable
669angles in what are supposed to be curves, when they are printed on modern
670laser printers and looked at closely.  This is less a problem than one might
671think since, fortunately, when scientific journals print a tree it is usually
672shrunk so small that these imperfections (and often the tree itself)
673are hard to see!
674<P>
675One more font that could be added from the Hershey font collection would be a
676Greek font.  If Greek users would
677find that useful I could add it, but my impression is that they publish
678mostly in English anyway.
679<P>
680<H2>Writing Code for a new Plotter, Printer or File Format</H2>
681<P>
682The C version of these programs consists of two C programs, "drawgram.c"
683and "drawtree.c".  Each of these has common sections of code compiled
684into it called
685"draw.c", "draw2.c" and a common header file, "draw.h".  In addition
686the Macintosh version requires two more files, "interface.c" and
687"interface.h".  All of the graphics commands that are common to both
688programs will be found in "draw.c" and "draw2.c".  The following instructions
689for writing your own code to drive a different kind of printer,
690plotter, or graphics file format, require you only to make changes in
691"drawgraphics.c".  The two programs can then be recompiled.
692<P>
693If you want to write code for other printers, plotters, or vector
694file formats, this is not
695too hard.  The plotter option "U" is provided as a place for you to insert
696your own code.  Chris Meacham's system was to draw everything, including the
697characters in the names and all curves, by drawing a series of straight
698lines.  Thus you need only master your plotter's commands for drawing
699straight lines.  In function "plotrparms"
700you must set up the values of
701variables "xunitspercm" and "yunitspercm", which are the number of units in
702the x and y directions per centimeter, as well as variables "xsize" and
703"ysize" which are the size of the plotting area in centimeters in the x
704direction and the y direction.  A variable "penchange" of a user-defined type
705is set to "yes" or "no" depending on whether the commands to change the pen
706must be issued when switching between plotting lines and drawing
707characters.   Even though dot-matrix printers do not have pens, penchange
708should be set to "yes" for them.  In function "plot" you must issue commands
709to draw a line from the current
710position (which is at (xnow, ynow) in the plotter's units) to the position
711(xabs, yabs), under the
712convention that the lower-left corner of the plotting area is (0.0, 0.0).  In
713functions "initplotter" and "finishplotter"
714you must issue commands to
715initialize the plotter and to finish plotting, respectively.  If the pen is
716to be changed an appropriate piece of code must be inserted in
717function "penchange".
718<P>
719For dot matrix printers and raster graphics matters are a bit more complex. The
720functions "plotrparms", "initplotter", "finishplotter" and "plot"
721still respectively set up the parameters for the plotter, initialize it,
722finish a plot, and plot one line.  But now the plotting consists of drawing
723dots into a two-dimensional array called "stripe".  Once the plot is
724finished this array is printed out.  In most cases the array is not as tall
725as a full plot: instead it is a rectangular strip across it.  When the
726program has finished drawing in ther strip, it prints it out and then
727moves down the plot to the next strip.  For example, for Hewlett-Packard
728Laserjets we have defined the strip as 2550 dots wide and 20 dots deep.  When
729the program goes to draw a line, it draws it into the strip and ignores
730any part of it that falls outside the strip.  Thus the program does a complete
731plotting into the strip, then prints it, then moves down the diagram by (in
732this case) 20 dots, then does a complete plot into that strip, and so on.
733<P>
734To work with a new raster or dot matrix format, you will have to define the
735desired width of a strip ("strpwide"), the desired depth ("strpdeep"), and
736how many lines of bytes must be printed out to print a strip.  For example
737Toshiba P351 printers in graphics mode print strips of dots 1350 bits wide
738by 24 bits deep, each column of 24 bits printing out as consecutive four bytes
739with 6 bits each.  In that case, one prints out a
740strip by printing up to 1350 groups of 4 bytes.  "strpdiv" is 4, and
741"strpwide" is 1350, and "strpdeep" is 24.  Procedure "striprint"
742is the one that prints out a strip, and has special-case code for the
743different printers and file formats.  For file formats, all of which
744print out a single row of dots at a time, the variable "strpdiv" is not
745used.  The variable "dotmatrix" is set to
746"true" or "false" in function "plotrparms"
747according to whether or not "strpdiv" is to be used.  Procedure "plotdot"
748sets a single dot in the array "strip" to 1 at position (xabs, yabs).  The
749coordinates run from 1 at the top of the plot to larger numbers as we
750proceed down the page.  Again, there is special-case code for different
751printers and file formats in that
752function.
753You will probably want to read the code for some of the dot matrix or file
754format options if you want to write code for one of them.  Many of them
755have provision for printing only part of a line, ignoring parts of it that
756have no dots to print.
757<P>
758I would be happy to obtain the resulting code from you to consider
759adding it to this listing so we can cover more kinds of plotters, printers,
760and file formats.
761<P>
762<HR>
763<P>
764<H2>APPENDIX 1.</H2>  Code to drive some other graphics devices.
765These pieces of code are to be
766inserted in the places reserved for the "Y" plotter option.  The variables
767necessary to run this
768have already been incorporated into the
769programs.
770<P>
771<H3>Calcomp plotters:</H3>
772<P>
773Calcomp's industrial-strength plotters are not as much a fixture of
774University computer centers as they one were, but just in case you need to
775use one, this code should work:
776<P>
777A global declaration needed near the front of drawtree.c:
778<P>
779<PRE>Char cchex[16];</PRE>
780<P>
781Code to be inserted into function plotrparms:
782<P>
783<PRE>
784  case 'Y':
785    plotter = other;
786    xunitspercm = 39.37;
787    yunitspercm = 39.37;
788    xsize = 25.0;
789    ysize = 25.0;
790    xposition = 12.5;
791    yposition = 0.0;
792    xoption = center;
793    yoption = above;
794    rotation = 0.0;
795    break;
796</PRE>
797<P>
798Code to be inserted into function plot:
799<P>
800Declare these variables at the beginning of the function:
801<P>
802<PRE>
803long n, inc, xinc, yinc, xlast, ylast, xrel,
804   yrel, xhigh, yhigh, xlow, ylow;
805Char quadrant;
806</PRE>
807<P>
808and insert this into the switch statement:
809<P>
810<PRE>
811  case other:
812    if (penstatus == pendown)
813      putc('H', plotfile);
814    else
815      putc('D', plotfile);
816    xrel = (long)floor(xabs + 0.5) - xnow;
817    yrel = (long)floor(yabs + 0.5) - ynow;
818    xnow = (long)floor(xabs + 0.5);
819    ynow = (long)floor(yabs + 0.5);
820    if (xrel > 0) {
821      if (yrel > 0)
822        quadrant = 'P';
823      else
824        quadrant = 'T';
825    } else if (yrel > 0)
826      quadrant = 'X';
827    else
828      quadrant = '1';
829    xrel = labs(xrel);
830    yrel = labs(yrel);
831    if (xrel > yrel)
832      n = xrel / 255 + 1;
833    else
834      n = yrel / 255 + 1;
835    xinc = xrel / n;
836    yinc = yrel / n;
837    xlast = xrel % n;
838    ylast = yrel % n;
839    xhigh = xinc / 16;
840    yhigh = yinc / 16;
841    xlow = xinc & 15;
842    ylow = yinc & 15;
843    for (i = 1; i <= n; i++)
844      fprintf(plotfile, "%c%c%c%c%c",
845              quadrant, cchex[xhigh - 1], cchex[xlow - 1], cchex[yhigh - 1],
846              cchex[ylow - 1]);
847    if (xlast != 0 || ylast != 0)
848      fprintf(plotfile, "%c%c%c%c%c",
849              quadrant, cchex[-1], cchex[xlast - 1], cchex[-1],
850              cchex[ylast - 1]);
851    break;
852</PRE>
853<P>
854Code to be inserted into function initplotter:
855<P>
856<PRE>
857  case other:
858    cchex[-1] = 'C';
859    cchex[0] = 'D';
860    cchex[1] = 'H';
861    cchex[2] = 'L';
862    cchex[3] = 'P';
863    cchex[4] = 'T';
864    cchex[5] = 'X';
865    cchex[6] = '1';
866    cchex[7] = '5';
867    cchex[8] = '9';
868    cchex[9] = '/';
869    cchex[10] = '=';
870    cchex[11] = '#';
871    cchex[12] = '"';
872    cchex[13] = '\'';
873    cchex[14] = '^';
874    xnow = 0.0;
875    ynow = 0.0;
876    fprintf(plotfile, "CCCCCCCCCC");
877    break;
878</PRE>
879<P>
880Code to be inserted into function finishplotter:
881<P>
882<PRE>
883  case other:
884    plot(penup, 0.0, yrange + 50.0);
885    break;
886</PRE>
887</BODY>
888</HTML>
Note: See TracBrowser for help on using the repository browser.