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); |
---|
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(double *, double *, double *, long); |
---|
112 | |
---|
113 | |
---|
114 | /* For povray, added by Dan F. */ |
---|
115 | #define TREE_TEXTURE "T_Tree\0" |
---|
116 | #define NAME_TEXTURE "T_Name\0" |
---|
117 | |
---|
118 | |
---|
119 | |
---|
120 | #ifdef X |
---|
121 | Display *display; /* the X display */ |
---|
122 | extern Window mainwin; /* the main display window */ |
---|
123 | int x, y; /* the corner of the window */ |
---|
124 | unsigned int width, height; /* the width and height of the window */ |
---|
125 | #define FONT "-*-new century schoolbook-medium-r-*-*-14-*" |
---|
126 | char *fontrsc; /* the font resource */ |
---|
127 | XFontStruct *fontst; /* the font strcture for the font */ |
---|
128 | XGCValues gcv; /* graphics context values */ |
---|
129 | GC gc1; /* a graphics context */ |
---|
130 | XtAppContext appcontext; |
---|
131 | Widget toplevel; |
---|
132 | int nargc; |
---|
133 | char** nargv; |
---|
134 | extern String res[16]; |
---|
135 | |
---|
136 | #define DEFGEOMETRY "600x400+20+50" |
---|
137 | #endif |
---|
138 | #define LARGE_BUF_LENGTH 500 |
---|
139 | extern char fontname[LARGE_BUF_LENGTH]; /* the font name to use */ |
---|
140 | |
---|
141 | #ifdef WIN32 |
---|
142 | #define DEFPLOTTER lw |
---|
143 | #define DEFPREV winpreview |
---|
144 | #endif |
---|
145 | #ifdef DOS |
---|
146 | #define DEFPLOTTER lw |
---|
147 | #define DEFPREV ibm |
---|
148 | #endif |
---|
149 | #ifdef MAC |
---|
150 | #define DEFPLOTTER pict |
---|
151 | #define DEFPREV mac |
---|
152 | #endif |
---|
153 | #ifdef VMS |
---|
154 | #define DEFPLOTTER lw |
---|
155 | #define DEFPREV decregis |
---|
156 | #endif |
---|
157 | #ifndef DOS |
---|
158 | #ifndef MAC |
---|
159 | #ifndef VMS |
---|
160 | #ifndef WIN32 |
---|
161 | #define DEFPLOTTER lw |
---|
162 | #ifdef X |
---|
163 | #define DEFPREV xpreview |
---|
164 | #endif |
---|
165 | #ifndef X |
---|
166 | #define DEFPREV tek |
---|
167 | #endif |
---|
168 | #endif |
---|
169 | #endif |
---|
170 | #endif |
---|
171 | #endif |
---|
172 | |
---|
173 | /* Define SEEK_SET (needed for fseek()) for machines that haven't |
---|
174 | got it already, */ |
---|
175 | #ifndef SEEK_SET |
---|
176 | #define SEEK_SET 0 |
---|
177 | #endif |
---|
178 | |
---|