pswigb.c
来自「su 的源代码库」· C语言 代码 · 共 482 行 · 第 1/2 页
C
482 行
/* set wt=va for va with solid/grey coloring */ if (va>=2) { wt=va; va=1; } /* get axes parameters */ xbox = 1.5; getparfloat("xbox",&xbox); ybox = 1.5; getparfloat("ybox",&ybox); wbox = 6.0; getparfloat("wbox",&wbox); hbox = 8.0; getparfloat("hbox",&hbox); x1beg = x1min; getparfloat("x1beg",&x1beg); x1end = x1max; getparfloat("x1end",&x1end); d1num = 0.0; getparfloat("d1num",&d1num); f1num = x1min; getparfloat("f1num",&f1num); n1tic = 1; getparint("n1tic",&n1tic); getparstring("grid1",&grid1s); if (STREQ("dot",grid1s)) grid1 = DOT; else if (STREQ("dash",grid1s)) grid1 = DASH; else if (STREQ("solid",grid1s)) grid1 = SOLID; else grid1 = NONE; getparstring("label1",&label1); x2beg = x2min; getparfloat("x2beg",&x2beg); x2end = x2max; getparfloat("x2end",&x2end); d2num = 0.0; getparfloat("d2num",&d2num); f2num = 0.0; getparfloat("f2num",&f2num); n2tic = 1; getparint("n2tic",&n2tic); getparstring("grid2",&grid2s); if (STREQ("dot",grid2s)) grid2 = DOT; else if (STREQ("dash",grid2s)) grid2 = DASH; else if (STREQ("solid",grid2s)) grid2 = SOLID; else grid2 = NONE; getparstring("label2",&label2); getparstring("labelfont",&labelfont); labelsize = 18.0; getparfloat("labelsize",&labelsize); getparstring("title",&title); getparstring("titlefont",&titlefont); titlesize = 24.0; getparfloat("titlesize",&titlesize); getparstring("titlecolor",&titlecolor); getparstring("axescolor",&axescolor); getparstring("gridcolor",&gridcolor); if(!getparfloat("axeswidth",&axeswidth)) axeswidth=1; if (!getparfloat("ticwidth",&ticwidth)) ticwidth=axeswidth; if(!getparfloat("gridwidth",&gridwidth)) gridwidth =axeswidth;; if (is_curve) { if ((ncurvewidth=countparval("curvewidth"))<curve) { curvewidth=ealloc1float(curve); if (!getparfloat("curvewidth",curvewidth)) { curvewidth[0]=axeswidth; ncurvewidth=1; } for (i=ncurvewidth; i<curve; i++) curvewidth[i]=curvewidth[ncurvewidth-1]; } else { curvewidth=ealloc1float(ncurvewidth); getparfloat("curvewidth",curvewidth); } } getparstring("style",&styles); if (STREQ("normal",styles)) style = NORMAL; else style = SEISMIC; /* determine bitmap dimensions and allocate space for bitmap */ nbpi = 72; getparint("nbpi",&nbpi); n1bits = nbpi*((style==NORMAL)?wbox:hbox); n2bits = nbpi*((style==NORMAL)?hbox:wbox); nbpr = 1+(n2bits-1)/8; bits = ealloc1(nbpr*n1bits,sizeof(unsigned char)); for (i=0,nbytes=nbpr*n1bits; i<nbytes; i++) bits[i] = 0; /* determine number of traces that fall within axis 2 bounds */ x2min = MIN(x2beg,x2end); x2max = MAX(x2beg,x2end); for (i2=0,n2in=0; i2<n2; i2++) if (x2[i2]>=x2min && x2[i2]<=x2max) n2in++; /* determine pads for wiggle excursion along axis 2 */ xcur = 1.0; getparfloat("xcur",&xcur); xcur = fabs(xcur); if (n2in>1) xcur *= (x2max-x2min)/(n2in-1); p2beg = (x2end>=x2beg)?-xcur:xcur; p2end = (x2end>=x2beg)?xcur:-xcur; /* set interpolation flag */ if (!getparint("interp",&interp)) interp = 0; /* determine scale and offset to map x2 units to bitmap units */ bscale = (n2bits-1)/(x2end+p2end-x2beg-p2beg); boffset = -(x2beg+p2beg)*bscale; bxcur = xcur*bscale; /* adjust x1beg and x1end to fall on sampled values */ i1beg = NINT((x1beg-f1)/d1); i1beg = MAX(0,MIN(n1-1,i1beg)); x1beg = f1+i1beg*d1; i1end = NINT((x1end-f1)/d1); i1end = MAX(0,MIN(n1-1,i1end)); x1end = f1+i1end*d1; /* determine first sample and number of samples to rasterize */ if1r = MIN(i1beg,i1end); n1r = MAX(i1beg,i1end)-if1r+1; /* determine bits corresponding to first and last samples */ b1fz = (x1end>x1beg)?0:n1bits-1; b1lz = (x1end>x1beg)?n1bits-1:0; /* rasterize traces */ for (i2=0; i2<n2; i2++,z+=n1) { /* skip traces not in bounds */ if (x2[i2]<x2min || x2[i2]>x2max) continue; /* determine bitmap coordinate of trace */ bx2 = boffset+x2[i2]*bscale; /* rasterize one trace */ if (interp==0) { /* no sinc interpolation */ rfwtva(n1r,&z[if1r],-clip,clip,va?0:clip, (int)(bx2-bxcur),(int)(bx2+bxcur),b1fz,b1lz, wt,nbpr,bits,endian); } else { /* do sinc interpolation */ rfwtvaint(n1r,&z[if1r],-clip,clip,va?0:clip, (int)(bx2-bxcur),(int)(bx2+bxcur),b1fz,b1lz, wt,nbpr,bits,endian); } } /* invert bitmap for PostScript (for which black=0, white=1) */ for (i=0,nbytes=nbpr*n1bits; i<nbytes; i++) { if (endian==0) { /* little endian bitmap inversion */ bits[i]= (bits[i]&((unsigned char) 128))>>7 | (bits[i]&((unsigned char) 64))>>5 | (bits[i]&((unsigned char) 32))>>3 | (bits[i]&((unsigned char) 16))>>1 | (bits[i]&8)<<1 | (bits[i]&4)<<3 | (bits[i]&2)<<5 | (bits[i]&1)<<7; } bits[i] = ~bits[i]; } /* convert axes box parameters from inches to points */ xbox *= 72.0; ybox *= 72.0; wbox *= 72.0; hbox *= 72.0; /* set bounding box */ psAxesBBox( xbox,ybox,wbox,hbox, labelfont,labelsize, titlefont,titlesize, style,bbox); boundingbox(bbox[0],bbox[1],bbox[2],bbox[3]); /* begin PostScript */ begineps(); /* save graphics state */ gsave(); /* translate coordinate system by box offset */ translate(xbox,ybox); /* determine image matrix */ if (style==NORMAL) { matrix[0] = 0; matrix[1] = n1bits; matrix[2] = n2bits; matrix[3] = 0; matrix[4] = 0; matrix[5] = 0; } else { matrix[0] = n2bits; matrix[1] = 0; matrix[2] = 0; matrix[3] = -n1bits; matrix[4] = 0; matrix[5] = n1bits; } scale(wbox,hbox); /* draw the image (before axes so grid lines are visible) */ image(n2bits,n1bits,1,matrix,bits); /* restore graphics state */ grestore(); /* draw curve */ for (i=0; i<curve; i++) { gsave(); psDrawCurve( xbox,ybox,wbox,hbox, x1beg,x1end,0.0,0.0, x2beg,x2end,p2beg,p2end, x1curve[i],x2curve[i],npair[i], curvecolor[i],curvewidth[i],style); grestore(); } /* draw axes and title */ psAxesBox( xbox,ybox,wbox,hbox, x1beg,x1end,0.0,0.0, d1num,f1num,n1tic,grid1,label1, x2beg,x2end,p2beg,p2end, d2num,f2num,n2tic,grid2,label2, labelfont,labelsize, title,titlefont,titlesize, titlecolor,axescolor,gridcolor, ticwidth,axeswidth,gridwidth, style); /* end PostScript */ showpage(); endeps(); if (curve) { free1int(npair); for (i=0; i<curve; i++) { free1float(x1curve[i]); free1float(x2curve[i]); } free1float(curvewidth); free((void**)x1curve); free((void**)x2curve); free((void**)curvefile); free((void**)curvecolor); } return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?