This is plxybx.c in view mode; [Download] [Up]
/* This draws a sloping line from (wx1,wy1) to (wx2,wy2) */
/* which represents an axis of a 3-d graph with data values from */
/* "vmin" to "vmax". Depending on "opt", vertical 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: Draw box boundary */
/* I: Inverts tick marks (i.e. drawn downwards) */
/* L: Logarithmic axes, major ticks at decades, minor ticks at units */
/* N: Write numeric label */
/* T: Draw major tick marks */
/* S: Draw minor tick marks */
/* U: Write label on line */
#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 plxybx(opt,label,wx1,wy1,wx2,wy2,vmin,vmax,tick,nsub,nolast)
char *opt, *label;
double wx1, wy1, wx2, wy2, vmin, vmax, tick;
int nsub, nolast;
{
static char string[40];
int lb,li,ll,ln,ls,lt,lu;
int major, minor, mode, prec, scal;
int i, i1, i2, i3, i4;
int nsub1;
double xpmm, ypmm, defmaj, defmin, htmaj, htmin, tick1;
double pos, tn, tp, temp;
double dwx, dwy, lambda;
dwx = wx2 - wx1;
dwy = wy2 - wy1;
/* Tick and subtick sizes in device coords */
gpixmm(&xpmm,&ypmm);
gmaj(&defmaj,&htmaj);
gmin(&defmin,&htmin);
major=MAX(round(htmaj*ypmm),1);
minor=MAX(round(htmin*ypmm),1);
tick1=tick;
nsub1=nsub;
lb=stsearch(opt,'b');
li=stsearch(opt,'i');
ll=stsearch(opt,'l');
ln=stsearch(opt,'n');
ls=stsearch(opt,'s');
lt=stsearch(opt,'t');
lu=stsearch(opt,'u');
if (lu) plxytx(wx1,wy1,wx2,wy2,3.2,0.5,0.5,label);
if (!lb) return;
if (ll) tick1 = 1.0;
if (lt) pldtik(vmin,vmax,&tick1,&nsub1,&mode,&prec,&scal);
if (li) {
i1 = minor;
i2 = 0;
i3 = major;
i4 = 0;
}
else {
i1 = 0;
i2 = minor;
i3 = 0;
i4 = major;
}
/* Draw the line */
movwor(wx1,wy1);
if (lt) {
tp=tick1*floor(vmin/tick1);
lab2:
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);
plxtik(wcpcx(wx1+lambda*dwx),wcpcy(wy1+lambda*dwy),i1,i2);
}
}
}
else {
for(i=1; i <= nsub1-1; i++) {
temp=tp+i*(tn-tp)/nsub1;
if (BETW(temp,vmin,vmax)) {
lambda = (temp-vmin)/(vmax-vmin);
plxtik(wcpcx(wx1+lambda*dwx),wcpcy(wy1+lambda*dwy),i1,i2);
}
}
}
}
temp=tn;
if (BETW(temp,vmin,vmax)) {
lambda = (temp-vmin)/(vmax-vmin);
plxtik(wcpcx(wx1+lambda*dwx),wcpcy(wy1+lambda*dwy),i3,i4);
tp=tn;
goto lab2;
}
}
drawor(wx2,wy2);
/* Label the line */
if (ln && lt) {
tp=tick1*floor(vmin/tick1);
lab82:
tn=tp+tick1;
if (nolast && !BETW(tn+tick1,vmin,vmax)) return;
if (BETW(tn,vmin,vmax)) {
if (!ll)
plform(tn,scal,prec,string);
else
sprintf(string,"10#u%-d",round(tn));
pos=(tn-vmin)/(vmax-vmin);
plxytx(wx1,wy1,wx2,wy2,1.5,pos,0.5,string);
tp=tn;
goto lab82;
}
if(!ll && mode) {
sprintf(string,"E%+d",scal);
plxytx(wx1,wy1,wx2,wy2,1.5,1.0,0.5,string);
}
}
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.