This is hprint.c in view mode; [Download] [Up]
/*
* hippoprint.c - line printer display for hippo package.
*
* Copyright (C) 1991 The Board of Trustees of The Leland Stanford
* Junior University. All Rights Reserved.
*
* $Id: hprint.c,v 5.0 1993/08/17 21:56:28 rensing Exp $
*
* by jonas karlsson, at SLAC, August 1990
* split up by Paul Rensing, Feb 28,1991
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifndef THINK_C
#include <string.h>
#endif
#include "hippo.h"
#include "hutil.h"
GLOB_QUAL const char hippoprint_c_rcsid[] =
"$Id: hprint.c,v 5.0 1993/08/17 21:56:28 rensing Exp $";
#define SCREENWIDTH 50
#define BININDEX(x, y, z, xs, ys) ((xs) * (ys) * (z) + (x) * (ys) + y)
static void print1D(display disp, FILE *file);
static void print2D(display disp, FILE *file);
static void print3D(display disp, FILE *file);
void h_fprint(display disp, FILE *file)
{
if (h_bin(disp) != 0) return;
switch (disp->dim) {
case 1:
print1D(disp, file);
break;
case 2:
print2D(disp, file);
break;
case 3:
print3D(disp, file);
break;
default:
break;
}
}
static void print1D(display disp, FILE *file)
{
int dim, i, j, nchar=0, bi;
float binedge, bw=0.0;
float ylow=0.0, range=0.0;
float csize;
int zeropt;
char string[80];
double d1,d2;
dim = disp->binding.x;
if (disp->title != NULL)
fprintf(file,"%s\n\n",
h_expandLabel( string, disp->title, 80, disp));
if (disp->xAxis.label != NULL)
fprintf(file,"X Axis label \"%s\"\n",
h_expandLabel( string, disp->xAxis.label, 80, disp));
fprintf(file,"%d bins, from %f to %f\n\n", disp->bins.xAxis.nBins,
disp->xAxis.low, disp->xAxis.high);
fprintf(file," bin xlow content\n");
range = disp->bins.binMax - disp->bins.binMin;
if (range <= 0.0) range = 1.0;
ylow = disp->bins.binMin - 0.1*range;
csize = (float)SCREENWIDTH / (1.2*range);
zeropt = -ylow*csize;
if (zeropt < 0) zeropt = 0;
binedge = disp->xAxis.low;
bw = ((float) (disp->xAxis.high - disp->xAxis.low)) /
(float) disp->bins.xAxis.nBins;
for (i = 0; i < disp->bins.xAxis.nBins; i++) {
bi = BININDEX(i, 0, 0, disp->bins.xAxis.nBins, 1);
fprintf(file,"\n%4d:%11.4g%11.4g ",
i, binedge, disp->bins.data[bi]);
binedge += bw;
if (disp->bins.data[bi] >= 0)
{
for (j = 0; j < zeropt; j++) {
putc(' ', file);
}
nchar = (disp->bins.data[bi] - ylow) * csize - zeropt;
for (j = 0; j < nchar; j++) {
putc('X', file);
}
if (nchar <= 0) putc('|', file);
}
else
{
nchar = (disp->bins.data[bi] - ylow) * csize;
for (j = 0; j < nchar; j++) {
putc(' ', file);
}
for (j = 0; j < zeropt - nchar; j++) {
putc('X', file);
}
if ((zeropt - nchar) <= 0) putc('|', file);
}
}
d1 = disp->bins.totals[0][0];
d2 = disp->bins.totals[2][0];
fprintf(file,"\nunderflow:%g overflow:%g\n",d1,d2);
/*
disp->bins.totals[0][0],
disp->bins.totals[2][0]);
*/
return;
}
static void print2D(display disp, FILE *file)
{
fprintf(file, "2D printer output is not yet implemented\n");
return;
}
static void print3D(display disp, FILE *file)
{
fprintf(file, "3D printer output is not yet implemented\n");
return;
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.