This is plzbx.c in view mode; [Download] [Up]
/* This draws a vertical line from (wx,wy1) to (wx,wy2) */ /* which represents the vertical axis of a 3-d graph with data */ /* values from "vmin" to "vmax". Depending on "opt", ticks and/or*/ /* subticks are placed on the line at major tick interval "tick" */ /* with "nsub" subticks between major ticks. If "tick" and/or */ /* "nsub" is zero, automatic tick positions are computed */ /* B: Draws left-hand axis*/ /* C: Draws right-hand axis*/ /* I: Inverts tick marks (i.e. drawn to the left) */ /* L: Logarithmic axes, major ticks at decades, minor ticks at units*/ /* M: Write numeric label on right axis*/ /* N: Write numeric label on left axis*/ /* S: Draw minor tick marks */ /* T: Draw major tick marks */ /* U: Writes left-hand label*/ /* V: Writes right-hand label*/ #include "plplot.h" #include <stdio.h> #include <math.h> #define BETW(c,a,b) ((a <= c && c <= b) || (b <= c && c <= a)) static double xlog[8] = {0.301030,0.477121,0.602060,0.698970,0.778151,0.845098, 0.903090,0.954243}; void plzbx(opt,label,right,dx,dy,wx,wy1,wy2,vmin,vmax,tick,nsub) char *opt, *label; double dx, dy, wx, wy1, wy2, vmin, vmax, tick; int nsub, right; { static char string[40]; int lb,lc,li,ll,lm,ln,ls,lt,lu,lv; int i, mode, prec, scal; int nsub1; double xpmm, ypmm, defmaj, defmin, tick1; double pos, tn, tp, temp; double dwy, lambda, diag, major, minor, xmajor, xminor; double ymajor, yminor, dxm, dym, xscl, xoff, yscl, yoff; dwy = wy2 - wy1; /* Tick and subtick sizes in device coords */ gpixmm(&xpmm,&ypmm); gmaj(&defmaj,&major); gmin(&defmin,&minor); tick1=tick; nsub1=nsub; lb=stsearch(opt,'b'); lc=stsearch(opt,'c'); li=stsearch(opt,'i'); ll=stsearch(opt,'l'); lm=stsearch(opt,'m'); ln=stsearch(opt,'n'); ls=stsearch(opt,'s'); lt=stsearch(opt,'t'); lu=stsearch(opt,'u'); lv=stsearch(opt,'v'); if (lu && !right) plztx("h",dx,dy,wx,wy1,wy2,5.0,0.5,0.5,label); if (lv && right) plztx("h",dx,dy,wx,wy1,wy2,-5.0,0.5,0.5,label); if (right && !lc) return; if (!right && !lb) return; if (ll) tick1 = 1.0; if (lt) pldtik(vmin,vmax,&tick1,&nsub1,&mode,&prec,&scal); if ( (li && !right) || (!li && right) ) { minor = -minor; major = -major; } gwm(&xscl,&xoff,&yscl,&yoff); dxm = dx * xscl; dym = dy * yscl; diag = sqrt(dxm*dxm + dym*dym); xminor = minor * dxm/diag; xmajor = major * dxm/diag; yminor = minor * dym/diag; ymajor = major * dym/diag; /* Draw the line */ movwor(wx,wy1); if (lt) { tp=tick1*floor(vmin/tick1); for(;;) { tn=tp+tick1; if (ls) { if (ll) { for (i=0; i <= 7; i++) { temp=tp+xlog[i]; if (BETW(temp,vmin,vmax)) { lambda = (temp-vmin)/(vmax-vmin); plstik(wcmmx(wx),wcmmy(wy1+lambda*dwy),xminor,yminor); } } } else { for (i=1; i<= nsub1-1; i++) { temp=tp+i*tick1/nsub1; if (BETW(temp,vmin,vmax)) { lambda = (temp-vmin)/(vmax-vmin); plstik(wcmmx(wx),wcmmy(wy1+lambda*dwy),xminor,yminor); } } } } temp=tn; if (!BETW(temp,vmin,vmax)) break; lambda = (temp-vmin)/(vmax-vmin); plstik(wcmmx(wx),wcmmy((wy1+lambda*dwy)),xmajor,ymajor); tp=tn; } } drawor(wx,wy2); /* Label the line */ if (ln && lt) { tp=tick1*floor(vmin/tick1); for(tn=tp+tick1; BETW(tn,vmin,vmax); tn+=tick1) { if (!ll) plform(tn,scal,prec,string); else sprintf(string,"10#u%d",round(tn)); pos=(tn-vmin)/(vmax-vmin); if (ln && !right) plztx("v",dx,dy,wx,wy1,wy2,0.5,pos,1.0,string); if (lm && right) plztx("v",dx,dy,wx,wy1,wy2,-0.5,pos,0.0,string); } if(!ll && mode) { sprintf(string,"E%+d",scal); if (ln && !right) plztx("v",dx,dy,wx,wy1,wy2,0.5,1.0,1.0,string); if (lm && right) plztx("v",dx,dy,wx,wy1,wy2,-0.5,1.0,0.0,string); } } }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.