/* * xdrawfile.c 4/3/88 Jim Piper * * *************************************************************************** * MODIFICATION HISTORY * -------------------- * Who when What * --- ---- ---- * JP 05-09-86 xdrawfile [-n] [-f] [-s scale] [infile] */ #include #include #include #include #include #include "xprobe.h" #include #define FACTOR 128.0 main(argc,argv) char **argv; { int objnum,number,nonum; int scale,cellw,celll; int cellkol1,cellline1,celllastkl,celllastln; long daytime; struct chromosome *objlist[200], *obj, *readobj(); struct chromplist *plist; char s[512], *cell, *timestring; FILE *infile; struct pframe f; int FIP=0; int screensize=80; int bckgrey; daytime = time(); timestring = ctime(&daytime); timestring[24] = ' '; scale = -1; nonum = 0; while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'n': nonum++; break; case 'f': FIP++; break; case 's': scale = atoi(argv[2]); if (scale <= 0 || scale > 1024) { fprintf(stderr,"ridiculous scale\n"); exit(1); } f.scale = scale; argc--; argv++; break; case 'x': screensize = atoi(argv[2]); if (screensize < 5 || screensize > 100) { fprintf(stderr,"ridiculous screen size\n"); exit(1); } argc--; argv++; break; case 'b': bckgrey = atoi(argv[2]); argc--; argv++; break; } argc--; argv++; } if (argc > 1) { cell = argv[1]; infile = fopen(cell,"r"); if (infile == NULL) { fprintf(stderr,"Can't open %s\n",cell); exit(1); } } else { cell = "type == 1) plist = obj->plist; if (obj->type == 1 && (plist->otype <= 1 || (plist->otype == 2 && plist->history[1]==0) || (plist->otype == 3 && plist->history[1]==0))) { objlist[number++] = obj; if (number == 1) { cellline1 = obj->idom->line1; cellkol1 = obj->idom->kol1; celllastln = obj->idom->lastln; celllastkl = obj->idom->lastkl; } else { cellline1 = min(cellline1,obj->idom->line1); cellkol1 = min(cellkol1,obj->idom->kol1); celllastln = max(celllastln,obj->idom->lastln); celllastkl = max(celllastkl,obj->idom->lastkl); } } } f.type = 60; f.dx = f.dy = 2048; f.ix = f.iy = 1; f.ox = (cellkol1 + celllastkl)/2; f.oy = (cellline1 + celllastln)/2; if (scale < 0) { celll = celllastln - cellline1 + 1; if (FIP) celll = 3*celll/4; cellw = celllastkl - cellkol1 + 1; f.scale = 4000/max(celll,cellw); if (f.scale > 8) f.scale=8; fprintf(stderr,"scale = %d\n",f.scale); } if (FIP) { f.ix = f.scale; f.iy = (3*f.scale+2)/4; f.scale = 1; } if (number > 0) { dinit(); clear(); logo(bckgrey,screensize); sprintf(s,"%s: file %s",timestring,cell); dispstring(s,24,24); user(screensize,0); /* for laser printer */ tsize(40,40); normaliseset(objlist,number); for (objnum=1; objnum<=number; objnum++) { obj = objlist[objnum-1]; exponential(obj); picframe(obj,&f); } if (!nonum) for (objnum=1; objnum<=number; objnum++) frameobjnum(objnum,objlist[objnum-1],&f); for (objnum=1; objnum<=number; objnum++) if (objlist[objnum-1]->plist->Cbtype & XPROBE) bdisprect(objlist[objnum-1],&f); finish(); } } max(i,j) { return ( i>j? i: j); } min(i,j) { return ( i 0) { user(2*s/3,0); pixbegin(8,1,1,4092,4092); pixel(g); pixend(); } lwidth(3); lineby(4092,0); lineby(0,4092); lineby(-4092,0); lineby(0,-4092); lwidth(1); user(9,0); } /* * display the enclosing right rectangle of an object, enlarged somewhat */ bdisprect(obj,f) struct chromosome *obj; struct pframe *f; { register struct intervaldomain *idom; struct chromplist *plist = obj->plist; struct irect r; struct object ro; r.type = 1; ro.type = 20; ro.idom = (struct intervaldomain *) &r; idom = obj->idom; r.irk[0] = r.irk[1] = idom->kol1 - 4; r.irk[2] = r.irk[3] = idom->lastkl + 4; r.irl[0] = r.irl[3] = idom->line1 - 4; r.irl[1] = r.irl[2] = idom->lastln + 4; picframe(&ro,f); } exponential(obj) struct object *obj; { struct iwspace iwsp; struct gwspace gwsp; int i; float g, MULTFACTOR; MULTFACTOR = 255.0 / (exp (255.0/FACTOR)-1.0); if (obj->type == 1) { initgreyscan(obj,&iwsp,&gwsp); while (nextgreyinterval(&iwsp) ==0) { for (i=0; i max) min = max = v; else if (v > max) max = v; else if (v < min) min = v; } } } range = max - min + (int) 1; for (n=0; n