This is plenv.c in view mode; [Download] [Up]
/* Simple interface for defining viewport and window. If "just"=1, */ /* X and Y scales will be the same, otherwise they are scaled */ /* independently. The "axis" parameter is interpreted as follows: */ /* axis=-2 : draw no box, axis or labels */ /* axis=-1 : draw box only */ /* axis= 0 : Draw box and label with coordinates */ /* axis= 1 : Also draw the coordinate axes */ /* axis= 2 : Draw a grid at major tick positions */ /* axis=10 : Logarithmic X axis, L!=r Y axis, No X=0 axis */ /* axis=11 : Logarithmic X axis, L!=r Y axis, X=0 axis */ /* axis=20 : L!=r X axis, Logarithmic Y axis, No Y=0 axis */ /* axis=21 : L!=r X axis, Logarithmic Y axis, Y=0 axis */ /* axis=30 : Logarithmic X and Y axes */ #include "plplot.h" #include <stdio.h> #include <math.h> void plenv(xmin,xmax,ymin,ymax,just,axis) int just,axis; double xmin, xmax, ymin, ymax; { int level; double chrdef, chrht; double lb, rb, tb, bb, dx, dy; double xsize, ysize, xscale, yscale; double spxmin, spxmax, spymin, spymax; double vpxmin, vpxmax, vpymin, vpymax; double scale; glev(&level); if (level < 1) plexit("Please call plstar before plenv."); if (xmin == xmax) plexit("Invalid xmin and xmax arguments in plenv"); if (ymin == ymax) plexit("Invalid ymin and ymax arguments in plenv"); if ((just != 0) && (just != 1)) plexit("Invalid just option in plenv"); pladv(0); if (just == 0) plvsta(); else { gchr(&chrdef,&chrht); lb = 8.0 * chrht; rb = 5.0 * chrht; tb = 5.0 * chrht; bb = 5.0 * chrht; dx = ABS(xmax-xmin); dy = ABS(ymax-ymin); plgspa(&spxmin,&spxmax,&spymin,&spymax); xsize = spxmax - spxmin; ysize = spymax - spymin; xscale = dx/(xsize - lb - rb); yscale = dy/(ysize - tb - bb); scale = MAX(xscale,yscale); vpxmin = MAX(lb,0.5*(xsize - dx/scale)); vpxmax = vpxmin + (dx/scale); vpymin = MAX(bb,0.5*(ysize - dy/scale)); vpymax = vpymin + (dy/scale); plsvpa(vpxmin,vpxmax,vpymin,vpymax); } plwind(xmin,xmax,ymin,ymax); if (axis == -2) ; else if (axis == -1) plbox("bc",0.0,0,"bc",0.0,0); else if (axis == 0) plbox("bcnst",0.0,0,"bcnstv",0.0,0); else if (axis == 1) plbox("abcnst",0.0,0,"abcnstv",0.0,0); else if (axis == 2) plbox("abcgnst",0.0,0,"abcgnstv",0.0,0); else if (axis == 10) plbox("bclnst",0.0,0,"bcnstv",0.0,0); else if (axis == 11) plbox("bclnst",0.0,0,"abcnstv",0.0,0); else if (axis == 20) plbox("bcnst",0.0,0,"bclnstv",0.0,0); else if (axis == 21) plbox("bcnst",0.0,0,"abclnstv",0.0,0); else if (axis == 30) plbox("bclnst",0.0,0,"bclnstv",0.0,0); else fprintf(stderr,"Invalid axis argument in plenv.\n"); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.