int main (void) { vp_init(); vp_fat(3); vp_color(7); filter(8., 4., "A"); vp_color(6); filter(6., 6., "B"); return 0; }
static void setgraphics (float ox, float oz, float lengthx, float lengthz) { float dash[1]; float gap[1]; dash[0] = 0.1; dash[0] = 0.1; vp_init(); vp_erase (); vp_tjust (TH_CENTER, TV_TOP); vp_tfont (ROMANC, VP_STROKE, VP_NO_CHANGE); vp_purge (); vp_orig (XMIN + .165 * XMAX , YMIN + .875 * YMAX); vp_clip (-VP_MAX, -VP_MAX, VP_MAX, VP_MAX); vp_color (VP_RED); vp_fat (THIN); vp_setdash (dash, gap, 0); vp_uorig (ox , oz); vp_scale (0.75 * XMAX / (lengthx), -0.75 * YMAX / (lengthz)); return; }
int cmdtree(char **para, int np) { static float x1, x2, w, h; static int fontsz=7; if(strcmp(para[0],"dash")==0 && np==2) vp_set_dash(atof(para[1])); else if(strcmp(para[0],"color")==0 && np==2) vp_color(atoi(para[1])); else if(strcmp(para[0],"style")==0 && np==2) vp_style(atoi(para[1])); else if(strcmp(para[0],"fat")==0 && np==2) vp_fat(atoi(para[1])); else if(strcmp(para[0],"fontsz")==0 && np==2) fontsz=atoi(para[1]); else if(strcmp(para[0],"move")==0 && np==3) { x1 = atof(para[1]); x2 = atof(para[2]); vp_move(x1, x2); } else if(strcmp(para[0],"line")==0 && np==3) vp_draw(atof(para[1]), atof(para[2])); else if(strcmp(para[0],"text")==0) switch(np) { case 4: vp_text(x1, x2, atoi(para[1]), atof(para[2]), para[3]); break; case 3: vp_text(x1, x2, fontsz, atof(para[1]), para[2]); break; case 2: vp_text(x1, x2, fontsz, 0.0, para[1]); break; default: break; } else if(strcmp(para[0],"box")==0) switch(np) { case 4: box(x1, x2, atof(para[1]), atof(para[2]), atof(para[3])*SF_PI/180); break; case 3: box(x1, x2, atof(para[1]), atof(para[2]), 0.0); break; default: break; } else if(strcmp(para[0],"frame")==0 && np==4 ) { w = atof(para[1]); h = atof(para[2]); box(x1+w/2, x2+h/2, w, h, 0.0); vp_text(x1+0.1, x2+0.1, fontsz, 0.0, para[3]); }else if(strcmp(para[0],"ell")==0 && np==4) ell(x1, x2, atof(para[1]), atof(para[2]), atof(para[3])*SF_PI/180); else if(strcmp(para[0],"arrow")==0 && np==4) vp_arrow(x1, x2, atof(para[1]), atof(para[2]), atof(para[3])); else return -1; return 0; }
void vp_plotframe(int col) { vp_color(col); vp_umove(min1, min2); vp_udraw(min1, max2); vp_udraw(max1, max2); vp_udraw(max1, min2); vp_udraw(min1, min2); }
void vp_fillin (void) { float xp[4], yp[4]; vp_coltab (8, fillcol[0], fillcol[1], fillcol[2]); vp_color (8); xp[0] = min1; xp[1] = max1; xp[2] = max1; xp[3] = min1; yp[0] = min2; yp[1] = min2; yp[2] = max2; yp[3] = max2; vp_uarea (xp, yp, 4, 0, 1, 1); }
static void draw_wavefronts (struct heptagon *cube, int nr, float DSmax) { int ii; float dp[1], gp[1]; dp[0] = 0.01; gp[0] = 0.008; vp_fat(SKINNY); vp_color(VP_GREEN); vp_setdash(dp, gp, 0); for(ii=0;ii<nr;ii++) { if(cube[ii].cf==END) continue; vp_umove(cube[ii].x1.x, cube[ii].x1.z); vp_udraw(cube[(ii+1+nr)%nr].x1.x, cube[(ii+1+nr)%nr].x1.z); } return; }
static void draw_rays (struct heptagon *cube, int nr) { int ii; float dp[1], gp[1]; dp[0] = 0.01; gp[0] = 0.008; vp_setdash(dp, gp, 0); vp_fat(SKINNY); vp_color(VP_RED); vp_umove(cube[0].x0.x, cube[0].x0.z); vp_udraw(cube[0].x1.x, cube[0].x1.z); for(ii=1;ii<nr;ii++) { if(cube[ii].cf==END && cube[ii-1].cf==END) continue; vp_umove(cube[ii].x0.x, cube[ii].x0.z); vp_udraw(cube[ii].x1.x, cube[ii].x1.z); } return; }
void vp_stdplot (int fastplt, bool wantframe, bool wantframenum, int n3, float o3, float d3) { if (fastplt < 20) { vp_clip (-VP_MAX, -VP_MAX, VP_MAX, VP_MAX); vp_color (axiscol); vp_fat (axisfat); if (wantframe && fastplt < 16) vp_plotframe (axiscol); if (fastplt < 14) { if (axis1.want) { if (!wantframe || axis1.or != min1) plotaxis (&axis1); if (fastplt < 12) { if (axis1.dnum != 0.) { if (axis1.ntic != 0) plottic (&axis1); labeltic (&axis1); } labelaxis (&axis1); } } if (axis2.want) { if (!wantframe || axis2.or != min2) plotaxis (&axis2); if (fastplt < 12) { if (axis2.dnum != 0.) { if (axis2.ntic != 0) plottic (&axis2); labeltic (&axis2); } labelaxis (&axis2); } } } if (fastplt < 3 && wanttitle) vp_plottitle (); if (fastplt < 13 && wantframenum && n3 > 1) { vp_framenum (n3, d3, o3, min1, min2, labelsz); } } }
int main(void) { int ix,nx=100, iz, nz=100, degrees=85; float dx, xmin=-4., xmax=7., tmax=9., x,t, x0; float alfa, c2a, orig, arg; vp_init(); x0= xmin; dx= (xmax-xmin)/(nx-1); vp_uorig( -1.+xmin, 0.); vp_utext( xmin/2, tmax+.45, 18, 0, "Common Shot"); vp_utext( xmax+.1, tmax-.45, 14, 0, "g"); vp_utext( .25 , .1 , 14, 0, "t"); vp_uclip (xmin, .6, xmax, tmax); vp_umove( xmin, tmax); vp_udraw( xmax, tmax); vp_umove( 0., tmax); vp_udraw( 0., tmax-tmax); vp_color(6); for (iz=0; iz < nz; iz++) { orig = 3 * ((xmax-xmin) * rand01() +xmin); alfa = degrees * 2 * 3.14 / 360 * rand01(); c2a = cos( 2*alfa); vp_penup(); for (ix=0; ix < nx; ix++) { /* x=g; s=0 */ x = x0 + ix*dx; arg = orig*orig +(x-orig)*(x-orig) + 2*orig*(x-orig) * c2a; t = sqrtf( arg); if( t < fabsf(x)) t = fabsf(x); vp_upendn(x, tmax-t); } } return 0; }
int main(void) { bool wantframe=false; float xll=1.705,yll=1.37,xur=11.945,yur=8.87,theta3=20.; float sn[3],cs[3],vv[3]={1.5,2.0,2.5},dz[3]={1.0,2.0,1.5}; float zbottom, h, t, x, z, x1,z1, xtxt, ztxt; float xmin, zmin, xmax, zmax, xscale, zscale; int i, plotcol=6,plotfat=1; vp_init(); /* precompute quantities related to vplot scales */ zbottom = 0.; for (i = 0; i < 3; i++) { zbottom += dz[i]; } theta3 *= acosf(-1.)/180.; sn[2]=sinf(theta3); h=0.; t=0.; for (i=2; i >= 0; i--) { if (i != 2) sn[i] = sn[i+1]*vv[i]/vv[i+1]; /* snell's law */ cs[i] = sqrtf(1. - sn[i]*sn[i]); h += dz[i]*sn[i]/cs[i]; t += 2*dz[i]/(cs[i]*vv[i]); } xmin = -h - 0.1*zbottom; if (xmin > -2.) xmin=-2.; zmin = -0.1 * zbottom; xmax = -xmin; zmax = 1.1*zbottom; if (zmax < 3.) zmax=3.; /* set vplot scales */ vp_orig(xll,yur); vp_uorig(xmin,zmin); xscale = (xur-xll)/(xmax-xmin); zscale = -(yur-yll)/(zmax-zmin); vp_scale(xscale,zscale); /* draw flat reflectors */ vp_color(plotcol); vp_fat(plotfat); z=0.; for (i=0; i < 3; i++) { z += dz[i]; vp_umove(xmin,z); vp_udraw(xmax,z); } /* draw vertical zero-offset ray */ vp_color(7); vp_umove(0.,0.); vp_udraw(0.,zbottom); /* draw ray paths from bottom reflector to geophone */ vp_color(2); x=0; z=zbottom; for (i=2; i >= 0; i--) { if (i != 0) { vp_umove(x,z); x += dz[i]*sn[i]/cs[i]; z -= dz[i]; vp_udraw(x,z); } else { x1 = x; z1 = z; x += dz[i]*sn[i]/cs[i]; z -= dz[i]; vp_uarrow(x1,z1,x,z,0.02*zbottom); } } /* draw ray paths from source to bottom reflector */ vp_color(2); x=0; z=zbottom; for (i=2; i >= 0; i--) { if (i != 2) { vp_umove(x,z); x -= dz[i]*sn[i]/cs[i]; z -= dz[i]; vp_udraw(x,z); } else { x1 = x; z1 = z; x -= dz[i]*sn[i]/cs[i]; z -= dz[i]; vp_uarrow(x,z,x1,z1,0.02*zbottom); } } /* draw surface */ vp_color(7); vp_fat(2*plotfat); vp_umove(xmin,0.); vp_udraw(xmax,0.); /* draw text */ vp_color(5); vp_fat(plotfat); vp_tjust(2,3); x = 0.; z = zbottom * 1.05; vp_utext(x,z,8,0,"R"); x = -h; z = 0.- zbottom *.05; vp_utext(x,z,8,0,"S"); x = h; z = 0. - zbottom *.05; vp_utext(x,z,8,0,"G"); x = -h; z = 0. + dz[0]/2.; vp_utext(x,z,8,0,"v\\s60 \\_1"); z += dz[0]/2. + dz[1]/2.; vp_utext(x,z,8,0,"v\\s60 \\_2"); z += dz[1]/2. + dz[2]/2.; vp_utext(x,z,8,0,"v\\s60 \\_3"); x = 0.; z = 0. - zbottom *.05; vp_utext(x,z,8,0,"2h"); x = 0. + 0.05*zbottom; vp_umove(x,z); x1 = h - 0.05 * zbottom; vp_uarrow(x,z,x1,z,-0.02*zbottom); x = 0. - 0.05*zbottom; vp_umove(x,z); x1 = -h + 0.05 * zbottom; vp_uarrow(x,z,x1,z,-0.02*zbottom); /* Highlight the trigonometry */ vp_color(7); vp_fat(plotfat); /* bottom of triangle */ z=zbottom-dz[2]; x=dz[2]*sn[2]/cs[2]; vp_umove(x,z); x1 = x + dz[1]*sn[1]/cs[1]; z1 = z; vp_udraw(x1,z1); xtxt = (x+x1)/2.; ztxt = z + 0.05 * zbottom; vp_utext(xtxt,ztxt,8,0,"\\F9 D\\F3 x\\_\\s60 i"); /* vertical side of triangle */ x = x1; z = z1 - dz[1]; vp_umove(x1,z1); vp_udraw(x,z); xtxt = x + 0.05 * zbottom; ztxt = (z+z1)/2.; vp_utext(xtxt,ztxt,8,0,"\\F9 D\\F3 z\\_\\s60 i"); xtxt = x - sn[1]/cs[1]*dz[1]/8.; ztxt = z + dz[1]/4.; vp_utext(xtxt,ztxt,8,0,"\\F9 q\\F3 \\s60 \\_i"); /* vertical side in tau space */ xtxt = 0. - 0.05*zbottom; ztxt = z + dz[1]/2.; vp_utext(xtxt,ztxt,8,90, "\\F9 Dt\\F3 \\s60 \\_i\\^\\s100 v\\s60 \\_i\\^\\s100 /2"); /* hypotenuse of triangle */ z1=zbottom-dz[2]; x1=dz[2]*sn[2]/cs[2]; vp_umove(x,z); vp_udraw(x1,z1); xtxt = (x+x1)/2. - 0.05 *zbottom; ztxt = (z+z1)/2.; vp_utext(xtxt,ztxt,8,60, "\\F9 D\\F3 t\\s60 \\_i\\^\\s100 v\\s60 \\_i\\^\\s100 /2"); /* draw a frame */ if(wantframe) { vp_color(7); vp_fat(1); vp_umove(xmin,zmin); vp_udraw(xmin,zmax); vp_udraw(xmax,zmax); vp_udraw(xmax,zmin); vp_udraw(xmin,zmin); } exit(0); }
int main (void) { float xval[NARRAY], zval[NARRAY]; int plotfat=1, ith, iflag, emph; bool wantframe=false,option=true,animate=false; float xll=1.705,yll=1.37,xur=11.945,yur=8.87; float h=1.0,y=0.0,time=1.6,v=2.0,theta=30., xstart, zstart; float a, b, xs, xg, surface,slop,xmin,zmin,xmax,zmax; float xscale, zscale, dth, thtmp, xsp; float tanth, sinth, costh, d, xr, zr, x,z, x1,z1, xend,zend; vp_init(); /* set parameters */ a = v * time /2.; b = sqrtf(a*a-h*h); xs = y - h; xg = y + h; surface = 0.; slop = 0.05*a; xmin = -2.; zmin = -1.; xmax = 2.; zmax = 2.; /* set vplot scales */ vp_orig(xll,yur); vp_uorig(xmin,zmin); xscale = (xur-xll)/(xmax-xmin); zscale = -(yur-yll)/(zmax-zmin); vp_scale(xscale,zscale); /* draw and annotate surface */ vp_fat(2*plotfat); vp_color(7); vp_umove(xmin,surface); vp_udraw(xmax,surface); vp_color(5); vp_fat(plotfat); vp_tjust(4,6); vp_utext(xs-0.5*slop,surface-slop,8,0,"S"); vp_utext(xg,surface-slop,8,0,"G"); vp_utext(y,surface-slop,8,0,"M"); dth = 180./(NARRAY-1); vp_color(4); /* LOOP on theta (ith) to generate ellipse */ for (ith = 0; ith < NARRAY; ith++) { thtmp = 90. - ith * dth; thtmp = thtmp*SF_PI/180.; tanth = tanf(thtmp); sinth = sinf(thtmp); costh = cosf(thtmp); d = hypotf(a*sinth,b*costh); xr = y - d*sinth - h*h*costh*costh*sinth/d; zr = surface + d*costh - h*h*costh*sinth*sinth/d; xval[ith] = xr; zval[ith] = zr; } /* Draw ellipse */ vp_color(5); vp_upline(xval,zval,NARRAY); if (option) { /* Loop on theta to draw SRG raypaths */ iflag = 0; emph = 3; for (ith = 0; ith < NARRAY; ith +=5) { iflag++; thtmp = 90. - ith * dth; thtmp = thtmp*SF_PI/180.; tanth = tanf(thtmp); sinth = sinf(thtmp); costh = cosf(thtmp); d = hypotf(a*sinth,b*costh); xr = y - d*sinth - h*h*costh*costh*sinth/d; zr = surface + d*costh - h*h*costh*sinth*sinth/d; /* Shot to reflection point */ vp_color(4); x = xs; z = surface; x1 = xr; z1 = zr; if(iflag == emph) vp_color(6); if(ith != 1 && ith != NARRAY) vp_uarrow(x,z,x1,z1,0.02*zmax); if(iflag == emph) vp_color(4); /* Annotate beta */ xend = (xs + xr)/2.; zend = (surface + zr)/2.; if(iflag == emph) { vp_color(6); vp_utext(xend-slop, zend+0.8*slop,8,0,"\\F9 b"); vp_color(4); } /* reflection point to geophone */ x = xr; z = zr; vp_umove(x,z); x1 = xg; z1 = surface; if(iflag == emph) vp_color(6); if(ith != 1 && ith != NARRAY) vp_uarrow(x,z,x1,z1,0.02*zmax); if(iflag == emph) vp_color(6); /* Annotate alpha */ xend = (xg + xr)/2.; zend = (surface + zr)/2.; if(iflag == emph) { vp_color(6); vp_utext(xend+slop, zend+0.5*slop,8,0,"\\F9 a"); vp_color(4); } if(animate) { vp_erase(); /* clear screen, then redraw basic stuff */ /* redraw and annotate surface */ vp_fat(2*plotfat); vp_color(7); vp_umove(xmin,surface); vp_udraw(xmax,surface); vp_color(5); vp_fat(plotfat); vp_tjust(4,6); vp_utext(xs-0.5*slop,surface-slop,8,0,"S"); vp_utext(xg,surface-slop,8,0,"G"); vp_utext(y,surface-slop,8,0,"M"); /* redraw ellipse */ vp_color(5); vp_upline(xval,zval,NARRAY); } } /* end loop on theta */ } else { /* Begin work for drawing dipping layer */ theta *= SF_PI/180.; tanth = tanf(theta); sinth = sinf(theta); costh = cosf(theta); d = hypotf(a*sinth,b*costh); xr = y - d*sinth - h*h*costh*costh*sinth/d; zr = surface + d*costh - h*h*costh*sinth*sinth/d; xsp = y - h - 2*(d-h*sinth)*sinth; xstart = xsp; zstart = surface + d/costh + tanth * (xstart-y); xend = 0.5*(xg + y); zend = surface + d/costh + tanth * (xend-y); /* Draw dipping reflector */ vp_color(2); vp_umove(xstart,zstart); vp_udraw(xend,zend); vp_dash(0.,0.,0.,0.); /* indicate angle theta */ vp_color(7); vp_dash(.1,.1,.1,.1); vp_umove(xend,zend); vp_udraw(xend-0.5*h,zend); vp_dash(.0,.0,.0,.0); /* finite-offset raypaths */ vp_color(4); /* Shot to reflection point */ vp_uarrow(xs,surface,xr,zr,0.02*zmax); /* reflection point to geophone */ vp_uarrow(xr,zr,xg,surface,0.02*zmax); /* text */ vp_color(5); vp_fat(plotfat); vp_tjust(4,6); vp_utext(xr,zr+2.0*slop,8,0,"R"); vp_utext(xend-5*slop, zend-1.*slop,8,0,"\\F9 q"); } if(wantframe) { vp_dash(0.,0.,0.,0.); vp_color(7); vp_fat(1); vp_umove(xmin,zmin); vp_udraw(xmin,zmax); vp_udraw(xmax,zmax); vp_udraw(xmax,zmin); vp_udraw(xmin,zmin); } return 0; }
void vertvwig(float *data, int n, int fill) { int lpoly = 0; /* Number of points in fill arrays */ static float *xp, *yp; /* Fill corner arrays */ register int i; /* Counter for data points */ /* Allocate fill corner arrays if first entry. */ /* We keep the x, y values of the polygon to be filled in two */ /* separate arrays. The index lpoly points to the last corner. */ if (first) { xp = ealloc1float(n + 2); yp = ealloc1float(n + 2); vp_color(FILLCOLOR); first = false; } /* Initialize pen to top of trace */ vp_umove(data[0], 0.0); /* Start fill arrays if first two x's are significantly positive. */ /* This needs to be handled specially since we cannot detect the */ /* begin of fill by a previous non-fill point in this case. */ if (data[0] > WEPS) { /* Phoney first corner point to tie down the polygon */ yp[0] = 0.0; xp[0] = WEPS; /* Record the actual value */ yp[1] = 0.0; xp[1] = data[0]; lpoly = 2; } if (fill) { /* Loop over interior data points */ for (i = 1; i < n - 1; ++i) { vp_udraw(data[i], (float) i); /* If significantly > 0, add to the fill arrays */ if (data[i] > WEPS) { /* If previous point was not a fill corner, */ /* space up proportionately to start fill */ /* and initialize fill arrays */ if (!lpoly) { yp[0] = i-data[i]/(data[i]-data[i-1]); xp[0] = WEPS; lpoly = 1; } /* Add this fill corner to the previous ones */ yp[lpoly] = i; xp[lpoly] = data[i]; ++lpoly; } /* At end of fill region call uarea to do the fill */ if (data[i] < WEPS && lpoly) { yp[lpoly] = i - data[i]/(data[i]-data[i-1]); xp[lpoly] = WEPS; ++lpoly; if (lpoly > 2) vp_uarea(xp, yp, lpoly, 1, 1, 1); lpoly = 0; } } /* End of loop over interior points on trace */ } else { /* Not filling, just connect the dots */ for (i = 1; i < n - 1; ++i) { vp_udraw(data[i], (float) i); } } /* End if fill */ /* Draw to last x, y on trace */ vp_udraw(data[n-1], (float) n-1); /* Force out fill arrays at end of trace. */ /* Tie down end of polygon. */ if (fill && lpoly) { yp[lpoly] = n - 1; xp[lpoly] = WEPS; ++lpoly; if (lpoly > 2) vp_uarea(xp, yp, lpoly, 1, 1, 1); } }
void vp_plottitle(void) { float labelvs, labelch, ch, vs, xc, yc, pos1, pos2; float x, y, xup, yup, xpath, ypath; ch = titlesz / 33.; vs = ch * 0.6; vp_fat (titlefat); vp_color(axiscol); if (( verttitle && wheretitle != where2) || (!verttitle && wheretitle != where1)) { labelch = labelsz / 33.; labelvs = 0.75 * labelch; } else { labelch = 0.; labelvs = 0.; } if (!verttitle) { pos1 = 0.5*(max1+min1); pos2 = wheretitle? max2: min2; ypath = 0.; yup = ch; xpath = ch; xup = 0.; vp_umove (pos1, pos2); vp_where (&xc, &yc); x = xc; y = wheretitle? yc + vs + labelch + 3*labelvs: yc - vs - labelch - 3*labelvs; } else { pos2 = 0.5*(max2+min2); pos1 = wheretitle? max1: min1; ypath = labelrot? 0.: -ch; yup = 0.; xpath = 0.; xup = labelrot? 0.: ch; vp_umove (pos1, pos2); vp_where (&xc, &yc); y = yc; if (labelrot) { x = wheretitle? xc - vs - labelch - 3*labelvs: xc + vs + labelch + 3*labelvs; } else { x += wheretitle? -(ch + vs + labelvs): +(ch + vs + labelvs); } } tjust(wheretitle); vp_gtext(x, y, xpath, ypath, xup, yup ,title); }
int main(int argc, char* argv[]) { bool transp, start, scalebar, nomin=true, nomax=true, barreverse, framenum; int n1, n2, n3, i1, i2, i3, len, nreserve; float min1, max1, min2, max2, o3, d3, o1, d1, xi, yi, tt; float **x, **y, **tmp, *symbolsz=NULL, symsize, xc, yc; float ***data=NULL, barmin, barmax, minmax[2]; char *symbol, sym[2]=" ", *color=NULL, *barfile; unsigned char **z=NULL, *barbuf[1]; sf_datatype type; sf_file in, depth, bar=NULL; sf_init(argc,argv); in = sf_input("in"); vp_init(); if (NULL != sf_getstring("depth")) { depth = sf_input("depth"); /* values for colored plots */ if (SF_UCHAR != sf_gettype(depth)) sf_error("Need uchar in depth"); } else { depth = NULL; } if (!sf_histint(in,"n1",&n1)) sf_error("No n1= in input"); if (!sf_histint(in,"n2",&n2)) n2=1; n = n1*n2; n3 = sf_leftsize(in,2); if (n3 > 1) { if (!sf_histfloat(in,"o3",&o3)) o3=0.; if (!sf_histfloat(in,"d3",&d3)) d3=1.; } x = sf_floatalloc2(n1,n2); y = sf_floatalloc2(n1,n2); t = sf_floatalloc(n); if (!sf_getbool("scalebar",&scalebar)) scalebar=false; /* if y, draw scalebar */ if (!sf_getbool("wantframenum",&framenum)) framenum = (bool) (n3 > 1); /* if y, display third axis position in the corner */ if (NULL != depth) { z = sf_ucharalloc2(n1,n2); /* initialize color table */ if (NULL == (color = sf_getstring("color"))) color="j"; /* color scheme (default is j) */ if (!sf_getint ("nreserve",&nreserve)) nreserve = 8; /* reserved colors */ vp_rascoltab(nreserve,color); if (scalebar) { barfile = sf_getstring("bar"); /* file for scalebar data */ if (NULL == barfile) { barfile=sf_histstring(depth,"bar"); if (NULL == barfile) sf_error("Need bar="); } nomin = (bool) (!sf_getfloat("minval",&barmin)); /* minimum value for scalebar (default is the data minimum) */ nomax = (bool) (!sf_getfloat("maxval",&barmax)); /* maximum value for scalebar (default is the data maximum) */ bar = sf_input(barfile); if (SF_UCHAR != sf_gettype(bar)) sf_error("Need uchar in bar"); if (nomin) nomin = (bool) (!sf_histfloat(bar,"minval",&barmin)); if (nomax) nomax = (bool) (!sf_histfloat(bar,"maxval",&barmax)); barbuf[0] = (unsigned char*) sf_alloc(VP_BSIZE,sizeof(unsigned char)); if (!sf_getbool("barreverse",&barreverse)) barreverse=false; /* if y, go from small to large on the bar scale */ } } if (!sf_getfloat("pclip",&pclip)) pclip=100.; /* clip percentile */ type = sf_gettype(in); switch (type) { case SF_FLOAT: if (!sf_histfloat(in,"o1",&o1)) o1=0.; if (!sf_histfloat(in,"d1",&d1)) d1=1.; for (i2=0; i2 < n2; i2++) { for (i1=0; i1 < n1; i1++) { x[i2][i1] = o1 + i1*d1; } } break; case SF_COMPLEX: data = sf_floatalloc3(2,n1,n2); break; default: sf_error("Wrong data type (need float or complex)"); } vp_plot_init(n2); symbol = sf_getstring("symbol"); /* if set, plot with symbols instead of lines */ if (NULL != symbol) { len = strlen(symbol); if (len < n2) { symbol = (char*) sf_realloc(symbol,n2,sizeof(char)); for (i2=len; i2 < n2; i2++) { symbol[i2] = symbol[i2 % len]; } } symbolsz = sf_floatalloc(n2); if (!sf_getfloats("symbolsz",symbolsz,n2)) { /* symbol size (default is 2) */ for (i2 = 0; i2 < n2; i2++) symbolsz[i2] = 2./33.; } else { for (i2 = 0; i2 < n2; i2++) symbolsz[i2] /= 33.; } } if (!sf_getbool ("transp",&transp)) transp=false; /* if y, transpose the axes */ for (i3 = 0; i3 < n3; i3++) { if (SF_COMPLEX == type) { sf_floatread(data[0][0],2*n,in); for (i2=0; i2 < n2; i2++) { for (i1=0; i1 < n1; i1++) { x[i2][i1] = data[i2][i1][0]; y[i2][i1] = data[i2][i1][1]; } } getminmax(x[0],&min1,&max1); } else { sf_floatread(y[0],n,in); min1=o1; max1=o1+(n1-1)*d1; } getminmax(y[0],&min2,&max2); if (NULL != depth) sf_ucharread(z[0],n,depth); vp_stdplot_init (min1, max1, min2, max2, transp,false,false,true); vp_frame_init(in,"blt",false); if (transp) { tmp=x; x=y; y=tmp; tt=max1; max1=max2; max2=tt; tt=min1; min1=min2; min2=tt; } if (i3 > 0) vp_erase(); if (framenum) vp_framenum(o3+i3*d3); vp_frame(); for (i2=0; i2 < n2; i2++) { vp_plot_set (i2); symsize = 2./33.; if (NULL != symbol) { sym[0] = symbol[i2]; symsize = symbolsz[i2]; } start = true; for (i1=0; i1 < n1; i1++) { xi = x[i2][i1]; yi = y[i2][i1]; if (NULL != depth) vp_color(z[i2][i1]+256); if (isfinite(xi) && isfinite(yi)) { if (NULL != symbol) { vp_umove(xi,yi); vp_where (&xc, &yc); vp_tjust (TH_SYMBOL, TV_SYMBOL); vp_gtext (xc,yc,symsize,0.,0.,symsize,sym); } else if (start) { vp_umove(xi,yi); start=false; } else { vp_udraw(xi,yi); } } else { start=true; } } } if (depth && scalebar) { sf_floatread(minmax,2,bar); sf_ucharread(barbuf[0],VP_BSIZE,bar); if (nomin) barmin=minmax[0]; if (nomax) barmax=minmax[1]; if (barreverse) { vp_barframe_init (depth,barmax,barmin); } else { vp_barframe_init (depth,barmin,barmax); } vp_barraster(VP_BSIZE, barbuf); } if (transp) { tmp=x; x=y; y=tmp; tt=max1; max1=max2; max2=tt; tt=min1; min1=min2; min2=tt; } } exit(0); }