| 1 | |
|---|
| 2 | #include "phylip.h" |
|---|
| 3 | |
|---|
| 4 | #ifdef X |
|---|
| 5 | #include <X11/Xlib.h> |
|---|
| 6 | #include <X11/Intrinsic.h> |
|---|
| 7 | #include <X11/StringDefs.h> |
|---|
| 8 | #include <X11/Xaw/Label.h> |
|---|
| 9 | #include <X11/Xatom.h> |
|---|
| 10 | #include <X11/Shell.h> |
|---|
| 11 | #include <X11/Xaw/SimpleMenu.h> |
|---|
| 12 | #include <X11/Xaw/Paned.h> |
|---|
| 13 | #include <X11/Xaw/Box.h> |
|---|
| 14 | #include <X11/Xaw/MenuButton.h> |
|---|
| 15 | #include <X11/Xaw/SmeBSB.h> |
|---|
| 16 | #include <X11/Xaw/Form.h> |
|---|
| 17 | #include <X11/Xaw/Dialog.h> |
|---|
| 18 | #include <X11/Xlib.h> |
|---|
| 19 | #include <X11/Xutil.h> |
|---|
| 20 | #endif |
|---|
| 21 | |
|---|
| 22 | #ifdef MAC |
|---|
| 23 | #include "interface.h" |
|---|
| 24 | #endif |
|---|
| 25 | |
|---|
| 26 | /* Added by Dan F. for bmp code */ |
|---|
| 27 | #include "math.h" |
|---|
| 28 | #define DEFAULT_STRIPE_HEIGHT 20 |
|---|
| 29 | |
|---|
| 30 | #define maxnodes 1200 |
|---|
| 31 | #define minus '-' |
|---|
| 32 | #define stripewidth 3000L |
|---|
| 33 | #define maxstripedepth 3500 |
|---|
| 34 | #define fontsize 3800 |
|---|
| 35 | #define pi 3.1415926535897932384626433 |
|---|
| 36 | #define epsilond 0.00001 |
|---|
| 37 | #define ebcdic EBCDIC |
|---|
| 38 | #define segments 40 |
|---|
| 39 | #define xstart 10 |
|---|
| 40 | #define ystart 35 |
|---|
| 41 | #define LF 10 |
|---|
| 42 | #define CR 13 |
|---|
| 43 | #define escape (ebcdic ? '\'' : '\033') |
|---|
| 44 | #define null '\000' |
|---|
| 45 | #define AFMDIR "/usr/lib/transcript/" /* note trailing slash */ |
|---|
| 46 | |
|---|
| 47 | typedef unsigned char byte; |
|---|
| 48 | /*typedef char byte; */ |
|---|
| 49 | typedef enum {treepen, labelpen} pentype; |
|---|
| 50 | typedef enum {lw,hp,tek,ibm,mac,houston,decregis,epson,oki,fig, |
|---|
| 51 | citoh,toshiba,pcx,pcl,pict,ray,pov,xpreview,xbm,bmp, |
|---|
| 52 | gif,idraw,vrml,winpreview,other} plottertype; |
|---|
| 53 | typedef enum {vertical, horizontal} growth; |
|---|
| 54 | typedef enum {cladogram,phenogram,curvogram, |
|---|
| 55 | eurogram,swoopogram,circular} treestyle; |
|---|
| 56 | typedef enum {penup,pendown} pensttstype; |
|---|
| 57 | typedef enum {plotnow, changeparms, quitnow} winactiontype; |
|---|
| 58 | typedef short fonttype[fontsize]; |
|---|
| 59 | typedef Char *striparray; |
|---|
| 60 | typedef striparray striptype[maxstripedepth]; |
|---|
| 61 | |
|---|
| 62 | struct LOC_plottext { /* Local variables for plottext: */ |
|---|
| 63 | double height, compress; |
|---|
| 64 | short *font; |
|---|
| 65 | short coord; |
|---|
| 66 | double heightfont, xfactor, yfactor, xfont, yfont, xplot, yplot, sinslope, |
|---|
| 67 | cosslope, xx, yy; |
|---|
| 68 | pensttstype penstatus; |
|---|
| 69 | } ; |
|---|
| 70 | |
|---|
| 71 | typedef struct colortype { |
|---|
| 72 | const char *name; |
|---|
| 73 | double red, green, blue; |
|---|
| 74 | } colortype; |
|---|
| 75 | |
|---|
| 76 | typedef struct vrmllighttype { |
|---|
| 77 | double intensity, x, y, z; |
|---|
| 78 | } vrmllighttype; |
|---|
| 79 | |
|---|
| 80 | double lengthtext(char *, long, char *, fonttype); |
|---|
| 81 | double heighttext(fonttype, char *); |
|---|
| 82 | void plotrparms(long ntips); |
|---|
| 83 | void clearit(void); |
|---|
| 84 | void getplotter(void); |
|---|
| 85 | void getpreview(void); |
|---|
| 86 | const char *figfontname(int id); |
|---|
| 87 | boolean isfigfont(char *); |
|---|
| 88 | void plot(pensttstype, double, double); |
|---|
| 89 | void curvespline(double, double, double, double, boolean, long); |
|---|
| 90 | void swoopspline(double x1, double y1, double x2, double y2, double x3, |
|---|
| 91 | double y3, boolean sense, long segs); |
|---|
| 92 | void changepen(pentype pen); |
|---|
| 93 | void plottext(Char *pstring,long nchars,double height_,double cmpress2, |
|---|
| 94 | double x,double y,double slope,short *font_,char *fontname); |
|---|
| 95 | void loadfont(short *font, char *application); |
|---|
| 96 | long allocstripe(striptype stripe, long x, long y); |
|---|
| 97 | boolean plotpreview(char *, double *, double *, double *, long , node *); |
|---|
| 98 | void initplotter(long ntips, char *fontname); |
|---|
| 99 | void drawit(char *fontname, double *xoffset, double *yoffset, |
|---|
| 100 | long numlines, node *root); |
|---|
| 101 | void finishplotter(void); |
|---|
| 102 | void write_bmp_header(FILE *, int, int); |
|---|
| 103 | void turn_rows(byte *, int, int); |
|---|
| 104 | void write_full_pic(byte *, int); |
|---|
| 105 | void translate_stripe_to_bmp(striptype *stripe, byte *full_pic, |
|---|
| 106 | int increment, int width, int div, int *total_bytes); |
|---|
| 107 | void plottree(node *, node *); |
|---|
| 108 | void plotlabels(char *fontname); |
|---|
| 109 | void pout(long); |
|---|
| 110 | double computeAngle(double oldx, double oldy, double newx, double newy); |
|---|
| 111 | boolean plot_without_preview(char *, double *, double *, double *, long, |
|---|
| 112 | node *); |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | /* For povray, added by Dan F. */ |
|---|
| 116 | #define TREE_TEXTURE "T_Tree\0" |
|---|
| 117 | #define NAME_TEXTURE "T_Name\0" |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | #ifdef X |
|---|
| 122 | Display *display; /* the X display */ |
|---|
| 123 | extern Window mainwin; /* the main display window */ |
|---|
| 124 | int x, y; /* the corner of the window */ |
|---|
| 125 | unsigned int width, height; /* the width and height of the window */ |
|---|
| 126 | #define FONT "-*-new century schoolbook-medium-r-*-*-14-*" |
|---|
| 127 | char *fontrsc; /* the font resource */ |
|---|
| 128 | XFontStruct *fontst; /* the font strcture for the font */ |
|---|
| 129 | XGCValues gcv; /* graphics context values */ |
|---|
| 130 | GC gc1; /* a graphics context */ |
|---|
| 131 | XtAppContext appcontext; |
|---|
| 132 | Widget toplevel; |
|---|
| 133 | int nargc; |
|---|
| 134 | char** nargv; |
|---|
| 135 | extern String res[16]; |
|---|
| 136 | |
|---|
| 137 | #define DEFGEOMETRY "600x400+20+50" |
|---|
| 138 | #endif |
|---|
| 139 | #define LARGE_BUF_LENGTH 500 |
|---|
| 140 | extern char fontname[LARGE_BUF_LENGTH]; /* the font name to use */ |
|---|
| 141 | |
|---|
| 142 | #ifdef WIN32 |
|---|
| 143 | #define DEFPLOTTER lw |
|---|
| 144 | #define DEFPREV winpreview |
|---|
| 145 | #endif |
|---|
| 146 | #ifdef DOS |
|---|
| 147 | #define DEFPLOTTER lw |
|---|
| 148 | #define DEFPREV ibm |
|---|
| 149 | #endif |
|---|
| 150 | #ifdef MAC |
|---|
| 151 | #define DEFPLOTTER pict |
|---|
| 152 | #define DEFPREV mac |
|---|
| 153 | #endif |
|---|
| 154 | #ifdef VMS |
|---|
| 155 | #define DEFPLOTTER lw |
|---|
| 156 | #define DEFPREV decregis |
|---|
| 157 | #endif |
|---|
| 158 | #ifndef DOS |
|---|
| 159 | #ifndef MAC |
|---|
| 160 | #ifndef VMS |
|---|
| 161 | #ifndef WIN32 |
|---|
| 162 | #define DEFPLOTTER lw |
|---|
| 163 | #ifdef X |
|---|
| 164 | #define DEFPREV xpreview |
|---|
| 165 | #endif |
|---|
| 166 | #ifndef X |
|---|
| 167 | #define DEFPREV tek |
|---|
| 168 | #endif |
|---|
| 169 | #endif |
|---|
| 170 | #endif |
|---|
| 171 | #endif |
|---|
| 172 | #endif |
|---|
| 173 | |
|---|
| 174 | /* Define SEEK_SET (needed for fseek()) for machines that haven't |
|---|
| 175 | got it already, */ |
|---|
| 176 | #ifndef SEEK_SET |
|---|
| 177 | #define SEEK_SET 0 |
|---|
| 178 | #endif |
|---|
| 179 | |
|---|