home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
126_01
/
facsplot.c
< prev
next >
Wrap
Text File
|
1985-03-11
|
24KB
|
854 lines
/*********************************************************************\
** .---------------------------------------------------------------. **
** | | **
** | | **
** | Copyright (c) 1981, 1982, 1983 by Eric Martz. | **
** | | **
** | | **
** | Permission is hereby granted to use this source | **
** | code only for non-profit purposes. Publication of | **
** | all or any part of this source code, as well as | **
** | use for business purposes is forbidden without | **
** | written permission of the author and copyright | **
** | holder: | **
** | | **
** | Eric Martz | **
** | POWER TOOLS | **
** | 48 Hunter's Hill Circle | **
** | Amherst MA 01002 USA | **
** | | **
** | | **
** `---------------------------------------------------------------' **
\*********************************************************************/
/*------------------------------------------------------------------*/
/* This source provides an example of how HIPLOT.C has been used
in producing actual plots. The application concerns distributions
of 256 integers, each representing a count in a channel, from an
instrument called a flow cytofluorometer, or
fluorescence-activated cell sorter. Since use of the facsplot
program as it stands is hardware dependent, you will not be able
to run this program (or even compile and link it in its present
form). However, it provides some functions which may serve as
useful models for anyone wishing to write a more general purpose
plotting package. In particular, see
axis() which draws an axis
axis_scale() which puts tick marks and numbers on it
tick()
vlabel() and hlabel() which write labels next to the vertical
and horizontal axes
scalepoint()
*/
/*------------------------------------------------------------------*/
#include "bdscio.h"
#define NIOBUFS 1
#include "fio1.h"
/* FACS */
#define STDERR 1
#define NDISTS 5 /* NUMBER OF DISTRIBUTION BUFFERS IN MEMORY */
#define DISTLEN 255
char Buf[MAXLINE], **Pp[32];
char Memdist[NDISTS+1][(DISTLEN+1)*5]; /* BDSC LACKS 3-DIMENSIONAL ARRAYS */
char Dfinmem[NDISTS+1][16]; /* NAMES OF DISTRIBUTION FILES IN MEMORY */
char Tot[NDISTS+1][5], Av[NDISTS+1][5], Max[NDISTS+1][5],
Condist[NDISTS+1][15+1], Pos[NDISTS+1][5];
int Location; /* INDEX LOCATION OF CURRENT DISTRIBUTION IN MEMORY */
int Nexttogo; /* NEXT MEMORY ARRAY TO BE REFILLED BY NEEDED DISTRIBUTION */
int Verbose;
char *Arr; /* POINTER TO CURRENT DISTRIBUTION IN MEMORY */
char Fpone[5], Fpzero[5], Fpmone[5],
Fphundred[5], Fpthousand[5]; /* FLOAT */
char F1[5], F2[5], F3[5], F4[5]; /* FLOAT */
FILE *Fpin, *Fpout;
/* MOSC */
int Begregn, Endregn;
*/
/*------------------------------------------------------------------*/
/* FACS PLOT */
#define LABEL 2
#define SCALE 2
#define REBUF 4000
#define VHALF 755
#define HHALF 1015
char Hmin_f[5], Vmin_f[5], Hfact_f[5], Vfact_f[5];
char Xmin_f[5], Ymin_f[5];
char Buf_repeat[REBUF], *At_repeat;
int Lsize, Nsize; /* SIZES OF CHARACTERS FOR LABEL, SCALE */
int Fill_repeat;
/*------------------------------------------------------------------*/
#define FACSPLOT 1
/*------------------------------------------------------------------*/
main(argc, argv)
int argc;
char **argv;
{
int option;
#include "fio2.h"
if (0) putchar('a');
if (0) getchar();
if (0) fopen("x",'r');
if (0) fclose(Fpin);
if (argc >1) Verbose = YES;
else Verbose = NO;
init_facs();
option = '1';
FOREVER {
/* fprintf(STDERR,
"\n\t1. MOSC\n%s%s%s%s%s",
"\t2. Regions\n",
"\t3. Display statistics\n",
"\t4. List distribution\n",
"\t5. Normalize\n",
"\t6. Quit\n\n");
option = charq("Option","123456");
*/
switch(option) {
case '1':
fplot();
break;
case '2':
break;
case '3':
break;
case '4':
exit(0);
}
if (!ynq("Another plot")) exit(0);
}
}
/*------------------------------------------------------------------*/
init_facs() {
int i;
for (i=1; i <=NDISTS; i++)
Dfinmem[i][0] = NULL;
itof(Fpone,1);
itof(Fpzero,0);
itof(Fpmone,-1);
itof(Fphundred,100);
itof(Fpthousand,1000);
Nexttogo = 1;
}
/*------------------------------------------------------------------*/
#include "fio3.h"
/*------------------------------------------------------------------*/
/* END OF FACS.C */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
fplot() {
int i, qmax, max, h, v, more, check, nofile, dstyle, atdist,
left_margin, bottom_margin, distcnt, logplot;
char dnames[128];
int line_type[10];
int curve_thickness[10];
set4baud(1, 300);
while(!ynq("Is paper ready in plotter (1200 BAUD)"));
init_plot();
/* SELECT PLOT SIZE */
Pp[1] = "\t-------------\n";
fprintf(STDERR,"\n%s\t| 1 | 2 |\n%s\t| 3 | 4 |\n%s\n",
Pp[1],Pp[1],Pp[1]);
checkint("\nQuarter page position 1-4 (Default is full page)? ",
&i, Buf, 0, 4, 0);
init_quarter();
switch(i) {
case 0:
init_full();
break;
case 1:
Vmin = VHALF;
break;
case 2:
Hmin = HHALF;
Vmin = VHALF;
break;
case 3:
break;
case 4:
Hmin = HHALF;
break;
}
fix_origin();
/* DEFAULT STYLE? */
dstyle = ynq("\nDefault style");
/* CHANGE LINE THICKNESS OR CHARACTER SIZE? */
if (!dstyle AND !ynq("Use default character sizes and line thickness")) {
checkint("Curve thickness (default %d)? ",&Plot_thickness,
Buf, 1, 10, 1);
checkint("Offset (default %d)? ",&Offset,
Buf, 1, 3, 2);
checkint("Character size:\n\tfor axis labels (default %d)? ",&Lsize,
Buf, 1, 5, Lsize);
checkint("\tfor scale numbers (default %d)? ",&Nsize,
Buf, 1, 5, Nsize);
if (Lsize EQ Nsize) {
checkint("Character thickness (default %d)? ",
&Cthick[Lsize], Buf, 1, 10, Cthick[Lsize]);
}
else {
checkint(
"Character thickness:\n\tfor axis labels (default %d)? ",
&Cthick[Lsize], Buf, 1, 10, Cthick[Lsize]);
checkint("\tfor scale numbers (default %d)? ",
&Cthick[Nsize], Buf, 1, 10, Cthick[Nsize]);
}
}
/* ALLOW SPACE FOR LABELS, SCALES, AND AXES */
/* RAISE BOTTOM TO ALLOW FOR 1 LINE OF LABEL, 1 BLANK LINE,
1 LINE OF SCALE, AND ONE BETLIN BELOW AXIS */
bottom_margin = (2 * Cheight[Lsize]) + Cheight[Nsize] + Cbetlin[Nsize];
Vmin += bottom_margin;
/* SHIFT TO RIGHT TO ALLOW FOR:
1 HEIGHT FOR LABEL,
1 BLANK HEIGHT BETWEEN LABEL AND SCALE,
4 WIDTHS FOR SCALE,
0.5 BLANK WIDTHS BETWEEN SCALE AND AXIS. */
left_margin = (2 * Cheight[Lsize]) +
(4 * Cwidth[Lsize]) + (Cwidth[Lsize]/2);
Hmin += left_margin;
/* GET LIST OF DISTRIBUTIONS TO BE PLOTTED */
distcnt = 0;
while (!distcnt)
distcnt = getwrds(
"List on one line distributions to be plotted, separated by commas.\n",
dnames, Pp);
/* GET CURVE THICKNESS AND LINE TYPES */
for (i=1; i <= distcnt; i++) {
line_type[i] = 0;
curve_thickness[i] = Plot_thickness;
}
if (ynq("Vary line type or curve thickness")) {
fprintf(STDERR,
"Line types:\n\t0 Solid\n\t2 Broken, fine\n\t4 Broken, medium\n%s",
"\t6 Broken, coarse\n");
for (i=1; i <= distcnt; i++) {
fprintf(STDERR,"\nCurve %s:\n",Pp[i]);
checkint("\tLine type (default %d)? ",
&line_type[i], Buf, 0, 8, 0);
checkint("\tThickness (default %d)? ",
&curve