1 /* dispn.c associated subroutines for matching sequences */
2 /* tcdispn.c uses turbo'c' 1.5 graphics calls */
3
4
5 #include <Quickdraw.h>
6 #include <Windows.h>
7 #include <Types.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #define BASE_RES_ID 400
13 #define NIL_POINTER 0L
14 #define MOVE_TO_FRONT (WindowPtr)-1L
15 #define REMOVE_ALL_EVENTS 0
16 #define MENU_HEIGHT 30
17
18 int colorArray[]={blackColor,whiteColor,redColor,greenColor,blueColor,
19 cyanColor,magentaColor,yellowColor};
20
21 int ncolors=8;
22 int icolor=0;
23
24 #define PEN_WIDTH 2
25 #define PEN_HEIGHT 2
26 static int curHt=PEN_HEIGHT;
27 static int curWd=PEN_WIDTH;
28 ConstPatternParam curPat= &qd.black;
29
30 WindowPtr gDrawWindow;
31 long gFillColor=blackColor;
32
33
34 #define XTERNAL
35 #include "upam.gbl"
36
37 /*
38 #define YES 1
39 #define NO 0
40 */
41
42 extern int iscore, gscore;
43 extern char name0[], ltitle[];
44 /*extern int colflg;*/
45
46 extern char lvstr[];
47
48 int plinval[3]={200,100,50};
49 int dlinval[3]={400,200,100};
50 int *linval;
51
52 extern int dnaseq;
53
54 extern int smin0,smin1;
55 extern long loffset;
56
57 #define DIAG 1
58 #define INS0 2
59 #define INS1 4
60
61 long pminx, pmaxx, pminy, pmaxy;
62
63 int max_x, max_y;
64
65 double fxscal, fyscal, fxoff, fyoff, aratio;
66 #define SX(x) (int)((double)(x)*fxscal+fxoff)
67 #define SY(y) (int)((double)(y)*fyscal+fyoff)
68
discons(seqc0,seqc1,nc)69 discons(seqc0, seqc1, nc)
70 char *seqc0, *seqc1;
71 int nc;
72 {
73 long x0, x1, y0, y1;
74 int direct, ii;
75
76 y1 = y0 = smin0;
77 x1 = x0 = smin1 + loffset;
78
79 direct = DIAG;
80
81 move(SX(x0),SY(y0));
82
83 for (ii=0; ii<nc; ii++) {
84 if (seqc0[ii]==' ' || seqc1[ii]==' ') continue;
85 if (seqc0[ii]!='-'&&seqc1[ii]!='-') {
86 if (direct!=DIAG) {
87 draw(SX(x1),SY(y1));
88 x0 = x1; y0 = y1;
89 direct = DIAG;
90 }
91 x1++; y1++;
92 }
93 else if (seqc0[ii]=='-') {
94 if (direct!=INS0) {
95 draw(SX(x1),SY(y1));
96 x0 = x1; y0 = y1;
97 direct = INS0;
98 }
99 x1++;
100 }
101 else if (seqc1[ii]=='-') {
102 if (direct!=INS1) {
103 draw(SX(x1),SY(y1));
104 x0 = x1; y0 = y1;
105 direct = INS1;
106 }
107 y1++;
108 }
109 }
110
111 draw(SX(x1),SY(y1));
112 if (y1 > pmaxy) printf("\r* n0 * %3ld %3ld\n",y1,pmaxy);
113 if (x1 > pmaxx) printf("\r* n1 * %3ld %3ld\n",x1,pmaxx);
114 }
115
aancpy(to,from,count)116 aancpy(to,from,count)
117 char *to, *from;
118 int count;
119 {
120 char *tp;
121 tp=to;
122 while (count--&& *from>=0) {
123 if (*from<nsq) *tp++ = sq[*(from++)];
124 else *tp++ = *from++;
125 }
126 *tp=0;
127 }
128
iidex(str,chr)129 iidex(str, chr)
130 char *str, chr;
131 {
132 int i;
133 for (i=0; str[i]; i++) if (str[i]==chr) return i;
134 return (-1);
135 }
136
min(arg1,arg2)137 min(arg1, arg2)
138 int arg1, arg2;
139 {
140 return (arg1<=arg2) ? arg1 : arg2;
141 }
142
143
144 PicHandle aPic;
145
openplt(n0,n1)146 openplt(n0, n1)
147 long n0, n1;
148 {
149 char *getenv(), *sptr;
150 double ftemp;
151
152 gDrawWindow=GetNewWindow(BASE_RES_ID,NIL_POINTER,(WindowPtr)MOVE_TO_FRONT);
153 SizeWindow(gDrawWindow,qd.screenBits.bounds.right-qd.screenBits.bounds.left-10,
154 qd.screenBits.bounds.bottom-qd.screenBits.bounds.top-20-MENU_HEIGHT,TRUE);
155 SelectWindow(gDrawWindow);
156 ShowWindow(gDrawWindow);
157
158 SetPort(gDrawWindow);
159 TextFont(monaco);
160 TextSize(9);
161 PenPat(&qd.black);
162 PenSize(PEN_WIDTH,PEN_HEIGHT);
163 PenMode(patOr);
164
165
166 max_x = gDrawWindow->portRect.right-gDrawWindow->portRect.left;
167 max_y = gDrawWindow->portRect.bottom-gDrawWindow->portRect.top-MENU_HEIGHT;
168
169 ClipRect(&(gDrawWindow->portRect));
170 aPic = OpenPicture(&gDrawWindow->portRect);
171 ShowPen();
172
173 if (strlen(lvstr)>0) {
174 sscanf(lvstr,"%d %d %d",&plinval[0],&plinval[1],&plinval[2]);
175 linval = plinval;
176 }
177 else if ((sptr=getenv("LINEVAL"))!=NULL && strlen(sptr)>0) {
178 sscanf(sptr,"%d %d %d",&plinval[0],&plinval[1],&plinval[2]);
179 linval = plinval;
180 }
181 else {
182 if (dnaseq==1) linval=dlinval;
183 else linval=plinval;
184 }
185
186 pmaxx = n1;
187 pmaxy = n0;
188
189 fxscal = (double)(max_x-1)/(double)(n1);
190 fyscal = (double)(max_y-1)/(double)(n0);
191
192 ftemp=0.0;
193 if (fxscal > fyscal) fxscal = fyscal;
194 else {ftemp = (fyscal-fxscal)*(double)max_y/2.0;
195 fyscal = fxscal;}
196
197 if (fyscal * n0 < (double)max_y/5.0)
198 fyscal = (double)(max_y-1)/((double)(n0)*5.0);
199
200 fxscal *= 0.9; fxoff = (double)(max_x-1)/11.0;
201 fyscal *= 0.9; fyoff = (double)(max_y-1)/11.0 + ftemp;
202
203
204 linetype(-1);
205 move(SX(0),SY(0));
206 draw(SX(0),SY(n0));
207 draw(SX(n1),SY(n0));
208 draw(SX(n1),SY(0));
209 draw(SX(0),SY(0));
210 xaxis(n1);
211 yaxis(n0);
212 legend(n1);
213 }
214
drawdiag(n0,n1)215 drawdiag(n0,n1)
216 long n0, n1;
217 {
218 linetype(0);
219 move(SX(0),SY(0));
220 draw(SX(n0),SY(n1));
221 }
222
223 int tarr[] = {10,20,50,100,200,500,1000,2000,5000};
224 int ntarr = sizeof(tarr);
xaxis(n)225 xaxis(n)
226 long n;
227 {
228 int i, jm, tick;
229 long js;
230 char numstr[20];
231
232 tick = 6;
233
234 for (i=0; i<ntarr; i++) if ((jm = n/tarr[i])<21) goto found;
235 jm = n/5000l; i=ntarr-1;
236 found: js = tarr[i];
237
238 for (i=1; i<=jm; i++) {
239 move(SX((long)i*js),SY(0));
240 draw(SX((long)i*js),SY(0)-tick);
241 }
242
243 sprintf(numstr,"%ld",js);
244 CtoPstr(numstr);
245 move(SX(js)-StringWidth((StringPtr)numstr)/2,SY(0)-tick-18);
246 DrawString((StringPtr)numstr);
247 sprintf(numstr,"%ld",jm*js);
248 CtoPstr(numstr);
249 move(SX((long)jm*js)-StringWidth((StringPtr)numstr)/2,SY(0)-tick-18);
250 DrawString((StringPtr)numstr);
251
252 CtoPstr(ltitle);
253 move(SX(n/2)-StringWidth((StringPtr)ltitle)/2,SY(0)-tick-40);
254 DrawString((StringPtr)ltitle);
255 PtoCstr((StringPtr)ltitle);
256 }
257
yaxis(n)258 yaxis(n)
259 long n;
260 {
261 int i, jm, tick;
262 long js;
263 char numstr[20];
264
265 tick = 6;
266
267 for (i=0; i<ntarr; i++) if ((jm = n/tarr[i])<21) goto found;
268 jm = n/5000l; i=ntarr-1;
269 found: js = (long)tarr[i];
270
271 for (i=1; i<=jm; i++) {
272 move(SX(0),SY((long)i*js));
273 draw(SX(0)-tick,SY((long)i*js));
274 }
275 sprintf(numstr,"%ld",js);
276 CtoPstr(numstr);
277 move(SX(0)-tick-StringWidth((StringPtr)numstr)-2,SY(js)-5);
278 DrawString((StringPtr)numstr);
279
280 sprintf(numstr,"%ld",(long)jm*js);
281 CtoPstr(numstr);
282 move(SX(0)-tick-StringWidth((StringPtr)numstr)-2,SY((long)jm*js)-5);
283 DrawString((StringPtr)numstr);
284 }
285
legend(n)286 legend(n)
287 long n;
288 {
289 int i, del;
290 int ixp, iyp;
291 char numstr[10];
292
293 del = 10;
294 if (SX(n)>(max_x-11*del)) return;
295 for (i=0; i<4; i++) {
296 linetype(i);
297 ixp = max_x - 11*del;
298 iyp = max_y*(4-i)/5;
299 move(ixp,iyp);
300 draw(ixp+5*del,iyp);
301 move(ixp+6*del,iyp);
302 if (i==3) sprintf(numstr,"<%3d",linval[2]);
303 else sprintf(numstr,">%3d",linval[i]);
304 drawstr(numstr);
305 }
306 }
307
linetype(type)308 linetype(type)
309 int type;
310 {
311 switch (type) {
312 /*
313 case -1: curPat = black; curHt=curWd=2; break;
314 case 0: curPat = black; curHt=curWd=1; break;
315 case 1: curPat = dkGray; curHt=curWd=1; break;
316 case 2: curPat = gray; curHt=curWd=1; break;
317 case 3: curPat = ltGray; curHt=curWd=1; break;
318 */
319 case -1: curHt=curWd=2; ForeColor(blackColor); break;
320 case 0: curHt=curWd=1; ForeColor(blackColor); break;
321 case 1: curHt=curWd=1; ForeColor(blueColor); break;
322 case 2: curHt=curWd=1; ForeColor(greenColor); break;
323 case 3: curHt=curWd=1; ForeColor(redColor); break;
324 }
325 }
326
327 SFReply reply;
328 OSErr err;
329 long refCon;
330 short PicFile;
331
closeplt()332 closeplt()
333 {
334 short vRefNum,err;
335 char buffer[512];
336 long hsize;
337
338 SetWTitle(gDrawWindow,"\pClick in window to continue");
339
340 ClosePicture();
341
342 SelectWindow(gDrawWindow);
343 SetPort(gDrawWindow);
344
345 HidePen();
346 /* DrawPicture(aPic,&(gDrawWindow->portRect)); */
347 GetVol((unsigned char *)buffer,&vRefNum);
348 memset((void *)buffer,0,(size_t)512);
349 Create("\pplalign.PICT",0,'MDRW','PICT');
350 if ((err=FSOpen((StringPtr)"\pplalign.PICT",0,&PicFile))!=noErr)
351 fprintf(stderr," cannot open Pic File %d\n",err);
352 else {
353 hsize= 512L;
354 FSWrite(PicFile,&hsize,buffer);
355 hsize=GetHandleSize((Handle)aPic);
356 FSWrite(PicFile,&hsize,*aPic);
357 FSClose(PicFile);
358 }
359 /* while (Waitkey((int)'\r')==0); */
360 while (!Button());
361
362 KillPicture(aPic);
363 DisposeWindow(gDrawWindow);
364 }
365
opnline(x,y,s,e_val,percent,nc)366 opnline(x,y,s,e_val,percent,nc)
367 long x, y;
368 int s,nc;
369 double e_val;
370 double percent;
371 {
372 if (s>linval[0]) linetype(0);
373 else if (s>linval[1]) linetype(1);
374 else if (s>linval[2]) linetype(2);
375 else linetype(3);
376 }
377
clsline(x,y,s)378 clsline(x,y,s)
379 long x, y;
380 int s;
381 {
382 }
383
move(x,y)384 move(x,y)
385 int x, y;
386 {
387 MoveTo((short)x,(short)(max_y-y));
388 }
389
draw(x,y)390 draw(x,y)
391 int x, y;
392 {
393 PenPat(curPat);
394 PenSize(curHt,curWd);
395 LineTo((short)x,(short)(max_y-y));
396 }
397
drawstr(str)398 drawstr(str)
399 char *str;
400 {
401 CtoPstr(str);
402 DrawString((StringPtr)str);
403 PtoCstr((StringPtr)str);
404 }
405
406 #ifdef VMS
memset(str,c,cnt)407 memset(str, c, cnt)
408 char *str; int cnt; char c;
409 {
410 while (cnt--) *str++ = c;
411 }
412 #endif
413