This is hplotUP.c in view mode; [Download] [Up]
/* * hippowrapsUP.cc -- Graphics end for Hippo histogramming package. * $Id: hplotUP.c,v 5.0 1993/08/17 21:56:00 rensing Exp $ * * Copyright (C) 1991 The Board of Trustees of The Leland Stanford * Junior University. All Rights Reserved. * * Provides the equivalent of: * hippowraps.psw - histogramming package postscript wraps. * by william shipley, at SLAC, august 1990 * * modified/maintained by mike gravina. * * updated to match new psw - Apr 30, 1991 Paul Rensing */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <ctype.h> #include "hplotUP.h" const char hippoplotUP_c_rcsid[] = "$Id: hplotUP.c,v 5.0 1993/08/17 21:56:00 rensing Exp $"; const char hippoplotUP_h_rcsid[] = HIPPOPLOTUP_H_RCSID; #define WIND_SIZE 3120 /* for 4014 terminal */ #define TICKHEIGHT 40 #define LABELPAD 10 static struct { float xScale; float yScale; float xMarg; float yMarg; float xOrig; float yOrig; float xMax; float yMax; } data, window; #define XData(x) ( (int) (((x)-data.xOrig)*data.xScale)+data.xMarg ) #define YData(y) ( (int) (((y)-data.yOrig)*data.yScale)+data.yMarg ) #define XWind(x) ( (int) ((((x)-window.xOrig)*window.xScale)+window.xMarg) ) #define YWind(y) ( (int) ((((y)-window.yOrig)*window.yScale)+window.yMarg) ) static FILE *outfile = stdout; static FILE stdout_save; int initDrvr_UP( FILE *file ) { outfile = file; return 0; } int initPlot_UP( rectangle *draw, rectangle *margin, rectangle *user) { if (outfile != stdout) { memcpy(&stdout_save,stdout,sizeof(FILE)); memcpy(stdout,outfile,sizeof(FILE)); } openpl(); space(0,0,WIND_SIZE,WIND_SIZE); erase(); window.xScale = WIND_SIZE/draw->size.width; window.yScale = WIND_SIZE/draw->size.height; window.xMarg = 0.0; window.yMarg = 0.0; window.xOrig = 0.0; window.yOrig = 0.0; window.xMax = draw->size.width; window.yMax = draw->size.height; data.xScale = margin->size.width/ user->size.width*window.xScale; data.yScale = margin->size.height/ user->size.height*window.yScale; data.xMarg = margin->origin.x*window.xScale; data.yMarg = margin->origin.y*window.yScale; data.xOrig = user->origin.x; data.yOrig = user->origin.y; data.xMax = user->origin.x + user->size.width; data.yMax = user->origin.y + user->size.height; return 0; } int endPlot_UP(void ) { if (outfile != stdout) { memcpy(stdout,&stdout_save,sizeof(FILE)); } return 0; } /* * Put text at the specified point */ int drawText_UP(char *message, float x, float y, float fontSize, float rotation, char xAlign, char yAlign ) { int x1 = XWind(x); int y1 = YWind(y); move( x1, y1 ); /* fontsize( (int) (fontSize*0.62) );*/ if (isupper(xAlign)) xAlign = tolower(xAlign); if (isupper(yAlign)) yAlign = tolower(yAlign); rotate(x1,x1,(int)rotation); /* first 2 args are junk */ alabel(xAlign,yAlign,message); rotate(x1,x1,0); return 0; } int drawXTicks_UP(float *x, int nticks, float tickWidth, int side ) { int i; int tickw = tickWidth*window.xScale; int ticklow; int x2; if (side == 0) ticklow = data.yMarg; else ticklow = YData(data.yMax) - tickw; for (i=0; i<nticks; i++) { x2 = XData(x[i]); line(x2, ticklow, x2, ticklow+tickw); } return 0; } int drawYTicks_UP( float *y, int nt, float tickwidth, int side ) { int i; int tickw = tickwidth*window.xScale; int ticklow; int y1; if (side == 0) ticklow = data.xMarg; else ticklow = XData(data.xMax)-tickw; for (i=0; i<nt; i++) { y1 = YData(y[i]); line(ticklow, y1, ticklow+tickw, y1); } return 0; } int drawMag_UP( float x, float y, int mag, float fontSize ) { char str[10]; move( XWind(x), YWind(y) ); sprintf(str,"x10^%d",mag); alabel('l','b',str); return 0; } int drawPoints_UP(float *xy, int npts, int symbol, float ptsize) { int i; int x1, y1; int sz; sz = ptsize*window.xScale; if (sz > 0) { for (i=0; i<npts; i++) { x1 = XData(*xy++); y1 = YData(*xy++); circle( x1, y1, sz/2 ); } } else { for (i=0; i<npts; i++) { x1 = XData(*xy++); y1 = YData(*xy++); point( x1, y1 ); } } return 0; } int drawLine_UP(float *xy, int npts, linestyle_t ls) { int i; int x,y; switch (ls) { default: case SOLID: linemod("solid"); break; case DASH: linemod("longdashed"); break; case DOT: linemod("dotted"); break; case DOTDASH: linemod("dotdashed"); break; } x = XData(*xy++); y = YData(*xy++); move(x, y ); for ( i=1; i<npts; i++) { x = XData(*xy++); y = YData(*xy++); cont(x, y ); } return 0; } int drawYError_UP(float *xy, float *err, int npts) { #define CAPWIDTH 10.0 float halfCapWidth = CAPWIDTH/2.0 / data.xScale; int i; int y1,y2,x1; for ( i=0; i<npts; i++) { x1 = XData(*xy++); xy++; y1 = YData(*err++); y2 = YData(*err++); line( x1, y1, x1, y2 ); line( x1-halfCapWidth, y1, (x1+halfCapWidth), y1 ); line( (x1-halfCapWidth), y2, (x1+halfCapWidth), y2 ); } return 0; } int drawXError_UP(float *xy, float *err, int npts) { float halfCapWidth = CAPWIDTH/2.0 / data.yScale; int i; int y1,x2,x1; for ( i=0; i<npts; i++) { xy++; y1 = XData(*xy++); x1 = YData(*err++); x2 = YData(*err++); line( x1, y1, x2, y1 ); line( x1, (y1-halfCapWidth), x1, (y1+halfCapWidth) ); line( x2, (y1+halfCapWidth), x2, (y1+halfCapWidth) ); } return 0; } int drawColor2D_UP(int nXBins, int nYBins, float binMin, float binMax, float *data, int useColor ) { move(WIND_SIZE/2.0,WIND_SIZE/2.0); alabel('c','c',"GrayScales Not Implemented"); return 0; } int drawLego2D_UP(display disp) { move(WIND_SIZE/2.0,WIND_SIZE/2.0); alabel('c','c',"2D Lego Not Implemented"); return 0; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.