home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-07-24 | 27.3 KB | 1,614 lines |
- Subject: v21i039: 2D graphic system with table beautifier, Part08/14
- Newsgroups: comp.sources.unix
- Approved: rsalz@uunet.UU.NET
- X-Checksum-Snefru: de71aa39 73281d78 1ddd9ea2 6a83a709
-
- Submitted-by: Steve Grubb <uunet!lsr-vax!scg>
- Posting-number: Volume 21, Issue 39
- Archive-name: ipl/part08
-
- # ipl part08
- # This is a shell archive.
- # Remove everything above and including the cut line.
- # Then run the rest of the file through sh.
- #---------------------- cut here -----------------------------
- #!/bin/sh
- # shar: Shell Archiver
- # Run the following text with /bin/sh to create:
- # src/main.c
- # src/map.c
- # src/mapdata.h
- # src/nicetab.c
- cat << \SHAR_EOF > src/main.c
- /* GDP - Goal Driven Parameter mechanism.
- This reads a user-supplied control file, fills Chunk[][] with the text
- for an entire proc, may look for an inheritance file and fill Ichunk[][]
- with that text. It then sends control to application via proc_call().
- The application then accesses paramters through the gget() call.
- Gget looks first in Chunk, then in Ichunk, and finally in the Template
- text to find a value.
- Also calls proc_call() for certain situations as follows:
- Does a proc_call( "Initialize" ) at the very beginning;
- Does a proc_call( "Endoffile" ) on end-of-file (control file);
- Does a proc_call( "Exit" ) as its last action;
- */
- #include <signal.h>
- #include "gdp.h"
-
- main( argc, argv )
- int argc;
- char *argv[];
- {
- int i;
- int gdp_exit();
-
- /* handle ^C */
- signal( SIGINT, gdp_exit );
-
-
- /* put args in globally-accessable structure */
- Argc = argc;
- if( argc > MAXARGS ) { fprintf( stderr, "Too many command line args (max=%d)\n", MAXARGS ); exit(); }
- for( i = 0; i < argc; i++ ) {
- if( strlen( argv[i] ) > ARGLEN )
- { fprintf( stderr, "Arg %d too long (max len=%d)\n", i, ARGLEN ); exit(); }
-
- strcpy( Arg[i], argv[i] );
- }
-
-
- Do_cons_check = 0;
-
- proc_call( "Initialize" ); /* note, vipl and mipl never return */
-
- display();
- gdp_exit();
- }
-
-
-
-
- /* ===================================================== */
- /* Run display based on file descriptor Sfp. Returns on eof */
- display()
- {
-
- int i,
- first, /* 1 during first line of control file, 0 otherwise */
- inheritflag; /* 1 if cloning, 0 otherwise. Used to make sure clones don't get cloned. */
- char line[INWIDTH+5], /* input line buffer */
- a[80], /* first token from input line */
- b[80], /* second token from input line */
- proc[30], /* current proc name */
- ans[10],
- clone[30]; /* clone or save name */
-
-
-
- first = 1;
- inheritflag = 0;
- Clines = 0;
-
-
- if( Sfp == NULL ) { fprintf( stderr, "Control file could not be found and/or opened.\n" ); exit(); }
-
- /* loop on lines in control file.. */
- while( 1 ) {
- a[0] = '\0'; b[0] = '\0'; /* null out tokens */
- if( fgets( line, INWIDTH+1, Sfp ) == NULL ) {
- if( strlen( line ) > INWIDTH ) {
- fprintf( stderr, "Control file line too long (max=%d).\n", INWIDTH );
- exit();
- }
- strcpy( a, "Proc" ); /* indicates last line to code below.. */
- fclose( Sfp );
- Sfp = NULL;
- }
- else sscanf( line, "%s %s", a, b );
- if( a[0] == '#' || a[0] == ':' ) continue; /* comments */
-
-
- if( strcmp( a, "Proc" )==0 ) { /* we have reached the end of proc, Chunk should be complete.. */
-
- if( !first ) { /* process the proc whose text is now in Chunk */
-
- Ilines = 0;
- gget( clone, "Clone" ); /* get inheritance, if any */
- if( strlen( clone ) > 0 ) {
- inheritflag = 1;
- load_parms( clone ); /* fill Ichunk */
- }
- else {
- inheritflag = 0;
- load_parms( "" );
- }
-
- proc_call( proc ); /* call routines that do the work */
-
-
- if( !inheritflag ) { /* save parms if desired, and if this is not a clone.. */
- gget( clone, "Saveas" );
- if( strlen( clone ) > 0 ) save_parms( clone ); /* write Ichunk out to a file */
- }
- }
-
- if( b[0] == '\0' ) { /* the fgets above returned NULL.. */
- proc_call( "Endoffile" );
- if( Sfp == NULL )break; /* normal exit */
- else { first = 1; continue; } /* user chose to restart */
- }
-
-
- Clines = 0; /* initialize chunk */
- strcpy( proc, b );
- proc[ strlen( proc )-1 ] = '\0';
- first = 0;
- }
- strcpy( Chunk[ Clines++ ], line ); /* add line to chunk */
- }
- return( 1 );
- }
-
- SHAR_EOF
- ############################
-
- cat << \SHAR_EOF > src/map.c
- /* usa and canada map, with state distributions expressed by shading */
- #include "ipl.x"
- #include "mapdata.h"
- #define USA_ONLY 1
- #define USA_CANADA 2
- #define CANADA_ONLY 3
-
- Map( )
- {
- int i, j, k, slot;
- int valfield, statefield;
- int nt, ns;
- int start, stop;
- int ctry;
- double t[15], s[15];
- double stab[50], ptab[12];
- double sshade[50], pshade[12];
- double thick, y;
- FILE *fp;
- char ans[10];
-
- gget( Buf, "Country" );
- if( strcmp( Buf, "usa" )==0 ) ctry = USA_ONLY;
- if( strcmp( Buf, "usa+canada" )==0 ) ctry = USA_CANADA;
- if( strcmp( Buf, "canada" )==0 ) ctry = CANADA_ONLY;
-
- NTm( usa[0], usa[1] );
- for( i = 0; i < nusa*2; i+=2 ) NTp( usa[i], usa[i+1] );
- NTshade( 1.0 );
- NTm( canada[0], canada[1] );
- for( i = 0; i < ncanada*2; i+=2 ) NTp( canada[i], canada[i+1] );
- NTshade( 1.0 );
-
- gget( Buf, "Mode" );
- if( strcmp( Buf, "country" )==0 ) goto COUNTRY_OUTLINE;
- else if( strcmp( Buf, "state" )==0 ) goto STATE_OUTLINE;
- /* else mode should be state-distribution */
-
- gget( Buf, "Valfield" );
- if( Buf[0] == '\0' ) valfield = 0;
- else valfield = atoi( Buf );
-
- gget( Buf, "Statefield" );
- if( strlen( Buf ) < 1 ) { fprintf( stderr, "Statefield (containing state abreviations) is missing.\n" ); gdp_exit(); }
- statefield = atoi( Buf );
-
- /* add up data */
- for( i = 0; i < nsi; i++ ) stab[i] = 0;
- for( i = 0; i < npi; i++ ) ptab[i] = 0;
-
- /* NTclip_on(); */
-
- /* for each row of data.. */
- for( i = 0; i < N_d_rows; i++ ) {
-
- /* check state list */
- for( j = 0; j < nsi*2; j+=2 ) if( strcmp( D[ i ][ statefield-1 ], sindex[ j+1 ] )==0 ) break;
-
- if( j >= (nsi*2) ) { /* not a state, check provinces */
- for( j = 0; j < npi*2; j+=2 ) if( strcmp( D[i][ statefield-1 ], pindex[j+1 ] ) == 0 ) break;
- if( j >= (npi*2) ) {
- fprintf( stderr, "Warning: row %d, bad state or province code (%s).\n", i, D[i][statefield-1] );
- continue;
- }
- slot = j / 2;
- /* increment counter */
- if( valfield > 0 ) ptab[ slot ] += atof( D[ i ][ valfield-1 ] );
- else if( valfield == 0 ) ptab[ slot ] += 1.0;
- }
- else {
- slot = j / 2;
- /* increment counter */
- if( valfield > 0 ) stab[ slot ] += atof( D[ i ][ valfield-1 ] );
- else if( valfield == 0 ) stab[ slot ] += 1.0;
- }
- }
-
- gget( Buf, "Threshold" );
- nt = sscanf( Buf, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",&t[0],&t[1],&t[2],&t[3],&t[4],&t[5],&t[6],&t[7],&t[8],&t[9] );
- gget( Buf, "Shade" );
- ns = sscanf( Buf, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",&s[0],&s[1],&s[2],&s[3],&s[4],&s[5],&s[6],&s[7],&s[8],&s[9] );
-
- /* assign shades */
- for( i = 0; i < nsi; i++ ) {
- for( j = 0; j < nt; j++ )
- if( stab[i] < t[j] ) { sshade[i] = s[j]; break; }
- if( j == nt ) sshade[i] = s[ns-1];
- }
-
- for( i = 0; i < npi; i++ ) {
- for( j = 0; j < nt; j++ )
- if( ptab[i] < t[j] ) { pshade[i] = s[j]; break; }
- if( j == nt ) pshade[i] = s[ns-1];
- }
-
-
- /* shade in states */
- for( i = 0; i < nsi*2; i+=2 ) {
- start = atoi( sindex[i] )*2;
- stop = atoi( sindex[i+2] )*2;
- NTm( states[ start ], states[ start+1 ] );
- for( j = start; j < stop; j+=2 ) NTp( states[ j ], states[ j+1 ] );
- NTshade( sshade[ i / 2 ] );
- }
-
-
- /* shade in provinces */
- for( i = 0; i < npi*2; i+=2 ) {
- start = atoi( pindex[i] )*2;
- stop = atoi( pindex[i+2] )*2;
- NTm( provinces[ start ], provinces[ start+1 ] );
- for( j = start; j < stop; j+=2 ) NTp( provinces[ j ], provinces[ j+1 ] );
- NTshade( pshade[ i / 2 ] );
- }
-
- /* label the blocks */
- NTfont( "/Helvetica" ); NTptsize( 6 );
- NTm( 1, 1 ); NTtext( "DC" );
- NTm( 4, 1 ); NTtext( "AK" );
- NTm( 7, 1 ); NTtext( "HI" );
-
- /* do list */
- gget( Buf, "List" );
- if( Buf[0] == 'y' ) {
- fp = fopen( Tempfile, "w" );
- for( i = 0; i < nsi; i++ ) fprintf( fp, "%s: %3.0f\n", sname[i], stab[i] );
- for( i = 0; i < npi; i++ ) fprintf( fp, "%s: %3.0f\n", pname[i], ptab[i] );
- fclose( fp );
- sprintf( Buf, "sort %s", Tempfile );
- fp = popen( Buf, "r" );
- y = 38.8;
- NTfont( "/Helvetica" ); NTptsize( 6 );
- while( fgets( Buf, 100, fp ) != NULL ) {
- NTm( 40.4, y );
- NTtext( Buf );
- y-= 0.6;
- }
- fclose( fp );
- }
-
-
- STATE_OUTLINE:
- gget( Buf, "State.linethick" ); thick = atof( Buf );
- NTlinetype( "0", thick, 1 );
- /* outline states */
- for( i = 0; i < nsi*2; i+=2 ) {
- start = atoi( sindex[i] )*2;
- stop = atoi( sindex[i+2] )*2;
- NTm( states[ start ], states[ start+1 ] );
- for( j = start; j < stop; j+=2 ) NTl( states[ j ], states[ j+1 ] );
- }
- /* outline provinces */
- for( i = 0; i < npi*2; i+=2 ) {
- start = atoi( pindex[i] )*2;
- stop = atoi( pindex[i+2] )*2;
- NTm( provinces[ start ], provinces[ start+1 ] );
- for( j = start; j < stop; j+=2 ) NTl( provinces[ j ], provinces[ j+1 ] );
- }
-
-
- COUNTRY_OUTLINE:
- gget( Buf, "Country.linethick" ); thick = atof( Buf );
- NTlinetype( "0", thick, 1 );
- NTm( usa[0], usa[1] );
- for( i = 0; i < nusa*2; i+=2 ) NTl( usa[i], usa[i+1] );
- NTm( canada[0], canada[1] );
- for( i = 0; i < ncanada*2; i+=2 ) NTl( canada[i], canada[i+1] );
-
-
- /* NTclip_off(); */
- }
- SHAR_EOF
- ############################
-
- cat << \SHAR_EOF > src/mapdata.h
- float usa[ 220 ] = {
- 3.5,23,
- 3.5,22,
- 3,21.6,
- 3.2,22.3,
- 2.4,22.8,
- 2.4,21.6,
- 2.2,20.8,
- 2,19.8,
- 1,18.1,
- 1,17.2,
- .4,16,
- .25,13.6,
- 1,13.3,
- .7,13,
- 1.4,11.1,
- 1.4,10.4,
- 3.6,8,
- 5.4,7.7,
- 8.1,6,
- 10.5,6,
- 10.5,6.2,
- 11.6,6.2,
- 13,4.8,
- 13,4.1,
- 14,3.8,
- 14.5,4.2,
- 15.4,4.2,
- 16.3,2.8,
- 17.2,1,
- 19,0.8,
- 18.8,2.3,
- 21.3,4.2,
- 23,4.2,
- 24,3.8,
- 25.2,3.9,
- 24.6,4.4,
- 27.6,5,
- 28.2,4.7,
- 29.2,5,
- 30.4,4.2,
- 30.8,2.7,
- 32.2,1.2,
- 32.9,1.35,
- 33,2.5,
- 31,5.5,
- 30.9,6.6,
- 31.2,7.5,
- 32.5,9,
- 34.3,11.3,
- 33.5,12,
- 33.1,13.5,
- 33.6,13,
- 34,12.5,
- 34.3,14.3,
- 34,14.4,
- 33.8,15.4,
- 34.5,15.5,
- 35,16,
- 34.4,16.2,
- 35.6,16.7,
- 37,17,
- 36.5,17.4,
- 36,18,
- 36.6,19.5,
- 36.7,20,
- 37.7,20.2,
- 37.5,20.8,
- 36.8,21.2,
- 36.5,22.3,
- 35.5,22.2,
- 35,20,
- 32.8,19.4,
- 32.2,18.5,
- 32,17.2,
- 30.3,17,
- 30.2,16.4,
- 28.4,15.2,
- 27.9,15.3,
- 28.4,16.5,
- 28,17,
- 28.2,17.5,
- 27.8,18.6,
- 26.4,18.9,
- 25.8,17.7,
- 26,16.2,
- 25.9,15.2,
- 25.2,15,
- 24.9,16.6,
- 25.3,18.7,
- 26.3,19.2,
- 24.3,19.3,
- 24.3,19.7,
- 23,19,
- 22.8,19.4,
- 22.1,19.1,
- 23,20,
- 23.7,20.4,
- 20.5,21,
- 20.3,21.4,
- 20.1,21.3,
- 20,21,
- 14.7,21.15,
- 7.6,22.1,
- 6.8,22.2,
- 3.5,23 };
-
- float canada[200] = {
- 40,21.5,
- 39.5,20,
- 38.4,19.5,
- 38,20,
- 38.6,21.4,
- 38.3,21.6,
- 37.5,20.8,
- 36.8,21.2,
- 36.5,22.3,
- 35.5,22.2,
- 35,20,
- 32.8,19.4,
- 32.2,18.5,
- 30.5,17.8,
- 30.2,17,
- 28.7,16.4,
- 29.3,18.8,
- 26.8,19.5,
- 25.8,21,
- 24.3,21,
- 23.7,20.4,
- 20.5,21,
- 20.3,21.4,
- 20.1,21.3,
- 20,21,
- 14.7,21.15,
- 7.6,22.1,
- 6.8,22.2,
- 3.5,23,
- 2.5,24.2,
- 3.5,22.8,
- 2.4,23,
- 1.1,25,
- 1.4,25.1,
- 2.3,24.4,
- 1.7,26,
- 1.5,26.8,
- 1.8,26.9,
- 1.7,27.3,
- 1,28,
- 1.3,29,
- 0,30,
- 0,40,
- 21,40,
- 21.5,38,
- 22.7,38.5,
- 23,40,
- 36,40,
- 37,38.5,
- 35.5,38,
- 37,37,
- 35.6,35.6,
- 33,37,
- 29.6,37.5,
- 30.5,38.5,
- 28.5,40,
- 26,40,
- 26.7,38,
- 25,36.3,
- 28,36,
- 28.3,35,
- 25,34.5,
- 24.3,35.5,
- 21.7,32,
- 21,30.5,
- 22.5,28,
- 24,28.5,
- 27.5,27.5,
- 28.7,26,
- 29,24.5,
- 29.3,24.4,
- 29.7,23.5,
- 30,24,
- 30.4,25.5,
- 30,27,
- 31,27,
- 32,29,
- 32.2,30,
- 31.5,30.5,
- 31.7,31.5,
- 32.3,31.8,
- 31.2,36,
- 32.2,36.2,
- 34.5,33.5,
- 34.3,32.2,
- 35,32,
- 36,33,
- 37,34,
- 38,34,
- 38.7,33,
- 39.1,32.8,
- 40,31.4,
- 40,21.5 };
-
- float states[1000] = {
- 3.5,23,/*-WA*/
- 3.5,22,
- 3,21.6,
- 3.2,22.3,
- 2.4,22.8,
- 2.4,21.6,
- 2.2,20.8,
- 3,20.6,
- 3.2,20,
- 6.3,19.5,
- 6.8,22.2,
- 3.5,23,
- 6.3,19.5,/*-OR*/
- 3.2,20,
- 3,20.6,
- 2.2,20.8,
- 2,19.8,
- 1,18.1,
- 1,17.2,
- 3.6,16.5,
- 6,16,
- 6.2,18.2,
- 6.6,19,
- 6.3,19.5,
- 3.6,16.5,/*-CA*/
- 1,17.2,
- .4,16,
- .25,13.6,
- 1,13.3,
- .7,13,
- 1.4,11.1,
- 1.4,10.4,
- 3.6,8,
- 5.4,7.7,
- 6.4,9.5,
- 6,10,
- 3,13.8,
- 3.6,16.5,
- 3.6,16.5,/*-NV*/
- 3,13.8,
- 6,10,
- 6.2,10.5,
- 6.6,10.4,
- 6.7,11.1,
- 7.5,15.7,
- 6,16,
- 3.6,16.5,
- 6.7,11.1,/*-AZ*/
- 6.6,10.4,
- 6.2,10.5,
- 6,10,
- 6.4,9.5,
- 5.4,7.7,
- 8.1,6,
- 9.8,6,
- 10.1,10.8,
- 6.7,11.1,
- 7.5,15.7,/*-UT*/
- 6.7,11.1,
- 10.1,10.8,
- 10.5,14.5,
- 9.5,14.6,
- 9.6,15.5,
- 7.5,15.7,
- 7.6,22.1,/*-ID*/
- 6.8,22.2,
- 6.3,19.5,
- 6.6,19,
- 6.2,18.2,
- 6,16,
- 7.5,15.7,
- 9.6,15.5,
- 9.8,17.8,
- 9,17.6,
- 8.5,18.6,
- 7.9,18.6,
- 7.8,19.8,
- 7.3,20.2,
- 7.4,22.15,
- 14.7,21.15,/*-MT*/
- 7.4,22.15,
- 7.3,20.2,
- 7.8,19.8,
- 7.9,18.6,
- 8.5,18.6,
- 9,17.6,
- 9.8,17.8,
- 9.7,18.2,
- 14.4,17.8,
- 14.5,18.3,
- 14.7,21.15,
- 14.4,17.8,/*-WY*/
- 9.7,18.2,
- 9.8,17.8,
- 9.6,15.5,
- 9.5,14.6,
- 10.5,14.5,
- 14.2,14.2,
- 14.3,15.8,
- 14.4,17.8,
- 14.2,14.2,/*-CO*/
- 10.5,14.5,
- 10.1,10.8,
- 14.3,10.7,
- 15.1,10.65,
- 15.2,13.2,
- 15.25,14.2,
- 14.2,14.2,
- 14.3,10.7,/*-NM*/
- 10.1,10.8,
- 9.8,6,
- 10.5,6,
- 10.5,6.2,
- 11.6,6.2,
- 14.2,6.2,
- 14.3,10.7,
- 14.3,10.2,/*-TX*/
- 14.2,6.2,
- 11.6,6.2,
- 11.6,6.2,
- 13,4.8,
- 13,4.1,
- 14,3.8,
- 14.5,4.2,
- 15.4,4.2,
- 16.3,2.8,
- 17.2,1,
- 19,0.8,
- 18.8,2.3,
- 21.3,4.2,
- 21.2,5.8,
- 21,7.1,
- 20.9,7.9,
- 18.4,7.7,
- 16.7,8.1,
- 16.8,10.2,
- 14.3,10.2,
- 14.3,10.7,/*-OK*/
- 14.3,10.2,
- 16.8,10.2,
- 16.7,8.1,
- 18.4,7.7,
- 20.9,7.9,
- 20.8,10.3,
- 20.8,10.6,
- 15.1,10.65,
- 14.3,10.7,
- 15.2,13.2,/*-KS*/
- 15.1,10.65,
- 20.8,10.6,
- 20.6,12.4,
- 20,13.15,
- 15.2,13.2,
- 14.3,15.8,/*-NE*/
- 14.2,14.2,
- 15.25,14.2,
- 15.2,13.2,
- 20,13.15,
- 19,15.5,
- 17.6,15.8,
- 14.3,15.8,
- 14.5,18.3,/*-SD*/
- 14.4,17.8,
- 14.3,15.8,
- 17.6,15.8,
- 19,15.5,
- 19.4,16.3,
- 19.4,18.2,
- 14.5,18.3,
- 14.7,21.15,/*-ND*/
- 14.5,18.3,
- 19.4,18.2,
- 19,21.05,
- 14.7,21.15,
- 21.3,4.2,/*-LA*/
- 23,4.2,
- 24,3.8,
- 25.2,3.9,
- 24.6,4.4,
- 24.3,5.1,
- 22.9,5.1,
- 23.1,7.1,
- 21,7.1,
- 21.2,5.8,
- 20.8,10.3,/*-AK*/
- 20.9,7.9,
- 21,7.1,
- 23.1,7.1,
- 23,8,
- 23.6,9,
- 24,10,
- 23.2,10,
- 23.5,10.4,
- 20.8,10.3,
- 20,13.15,/*-MO*/
- 20.6,12.4,
- 20.8,10.6,
- 20.8,10.3,
- 23.5,10.4,
- 23.2,10,
- 24,10,
- 24.3,10.5,
- 24.4,10.8,
- 22.4,13.8,
- 19.68,13.8,
- 20,13.15,
- 19,15.5,/*-IO*/
- 19.68,13.8,
- 22.4,13.8,
- 23.2,14.9,
- 22.8,16.3,
- 19.4,16.3,
- 19,15.5,
- 19,21.05,/*-MN*/
- 19.4,18.2,
- 19.4,16.3,
- 22.8,16.3,
- 21.7,17.6,
- 22.1,19.1,
- 23,20,
- 23.7,20.4,
- 20.5,21,
- 20.3,21.4,
- 20.1,21.3,
- 20,21,
- 19,21.05,
- 23.6,9,/*MS*/
- 23,8,
- 23.1,7.1,
- 22.9,5.1,
- 24.3,5.1,
- 24.6,4.4,
- 25.5,4.6,
- 25.3,9.1,
- 23.6,9,
- 25.3,9.1,/*-AL*/
- 25.5,4.6,
- 26.3,4.75,
- 26.3,5.5,
- 28.2,5.6,
- 27,9.3,
- 25.3,9.1,
- 28.2,5.6,/*-FL*/
- 26.3,5.5,
- 26.3,4.75,
- 27.6,5,
- 28.2,4.7,
- 29.2,5,
- 30.4,4.2,
- 30.8,2.7,
- 32.2,1.2,
- 32.9,1.35,
- 33,2.5,
- 31,5.5,
- 30.95,6.3,
- 30.5,6.3,
- 30.1,5.7,
- 28.2,5.6,
- 27,9.3,/*-GA*/
- 28.2,5.6,
- 30.1,5.7,
- 30.5,6.3,
- 30.95,6.3,
- 30.9,6.6,
- 31.2,7.5,
- 29,9.4,
- 28,9.3,
- 27,9.3,
- 23,15.6,/*-IL*/
- 23.2,14.9,
- 22.4,13.8,
- 24.4,10.8,
- 25,11,
- 25.2,11.5,
- 25.3,12.5,
- 25.2,15,
- 25.1,15.6,
- 23,15.6,
- 21.7,17.6,/*-WI*/
- 22.8,16.3,
- 23,15.6,
- 25.1,15.6,
- 24.9,16.6,
- 25.3,18.7,
- 23,19,
- 22.8,19.4,
- 22.1,19.1,
- 21.7,17.6,
- 26.4,18.9,/*-MI*/
- 25.8,17.7,
- 26,16.2,
- 25.9,15.2,
- 26.8,15.25,
- 27.9,15.3,
- 28.4,16.5,
- 28,17,
- 28.2,17.5,
- 27.8,18.6,
- 26.4,18.9, /*break */
- 26.3,19.2,
- 24.3,19.3,
- 24.3,19.7,
- 23,19,
- 25.3,18.7,
- 26.3,19.2,
- 26.4,18.9,
- 25.9,15.2,/*-IN*/
- 25.2,15,
- 25.3,12.5,
- 25.2,11.5,
- 26.6,12,
- 27.2,13,
- 26.8,15.25,
- 25.9,15.2,
- 26.8,15.25,/*-OH*/
- 27.2,13,
- 28.9,12.7,
- 29.8,13.7,
- 30,14.6,
- 29.65,16,
- 28.4,15.2,
- 27.9,15.3,
- 26.8,15.25,
- 29,9.4,/*-SC*/
- 31.2,7.5,
- 32.6,9.1,
- 31.1,9.65,
- 30.7,9.55,
- 30.6,9.8,
- 29.5,9.75,
- 29,9.4,
- 28.9,12.7,/*-KY*/
- 27.2,13,
- 26.6,12,
- 25.2,11.5,
- 25,11,
- 24.4,10.8,
- 24.3,10.5,
- 28.5,10.8,
- 29.5,11.7,
- 28.9,12.7,
- 24.3,10.5,/*-TE*/
- 24,10,
- 23.6,9,
- 25.3,9.1,
- 27,9.3,
- 28,9.3,
- 29.8,11,
- 28.5,10.8,
- 24.3,10.5,
- 29.8,11,/*-NC*/
- 28,9.3,
- 29,9.4,
- 29.5,9.75,
- 30.6,9.8,
- 30.7,9.55,
- 31.1,9.65,
- 32.6,9.1,
- 34.3,11.3,
- 33.85,11.6,
- 29.8,11,
- 29.5,11.7,/*-VA*/
- 28.5,10.8,
- 29.8,11,
- 33.85,11.6,
- 33.5,12,
- 33.35,12.4,
- 32.3,13.7,
- 31.7,13.8,
- 30.6,11.75,
- 29.5,11.7,
- 30,14.6,/*-WV*/
- 29.8,13.7,
- 28.9,12.7,
- 29.5,11.7,
- 30.6,11.75,
- 31.7,13.8,
- 30.8,13.2,
- 30.7,14,
- 30.3,13.85,
- 30,14.6,
- 29.65,16,/*-PA*/
- 30,14.6,
- 30.3,13.85,
- 30.7,14,
- 33.2,14.5,
- 33.3,15,
- 32.9,15.6,
- 33.2,16.2,
- 32.9,16.5,
- 30.4,16,
- 30.2,16.4,
- 29.65,16,
- 30.7,14,/*-MD*/
- 30.8,13.2,
- 31.7,13.8,
- 32.3,13.7,
- 33.35,12.4,
- 33.1,13.5,
- 33.6,13,
- 34,12.5,
- 33.2,14.5,
- 30.7,14,
- 33.2,14.5,/*-DE*/
- 34,12.5,
- 34.17,13.8,
- 33.2,14.5,
- 33.2,16.2,/*-NJ*/
- 32.9,15.6,
- 33.3,15,
- 33.2,14.5,
- 34.17,13.8,
- 34.3,14.3,
- 34,14.4,
- 33.8,15.4,
- 34,15.4,
- 33.2,16.2,
- 32.8,19.4,/*-NY*/
- 32.2,18.5,
- 32,17.2,
- 30.3,17,
- 30.2,16.4,
- 30.4,16,
- 32.9,16.5,
- 33.2,16.2,
- 34,15.4,
- 34.5,15.5,
- 35,16,
- 34.4,16.2,
- 34.1,19.73,
- 32.8,19.4,
- 34.4,16.2,/*-CT*/
- 35.6,16.7,
- 35.6,17.7,
- 34.3,17.7,
- 34.4,16.2,
- 35.6,17.7,/*-RI*/
- 35.6,16.7,
- 36.3,16.85,
- 36,17.6,
- 35.6,17.7,
- 34.3,17.7,/*-MA*/
- 35.6,17.7,
- 36,17.6,
- 36.3,16.85,
- 37,17,
- 36.5,17.4,
- 36,18,
- 36.2,18.35,
- 34.8,18.1,
- 34.2,18,
- 34.3,17.7,
- 34.1,19.73,/*-VT*/
- 34.2,18,
- 34.8,18.1,
- 35,20,
- 34.1,19.73,
- 35,20,/*-NH*/
- 34.8,18.1,
- 36,18.3,
- 35.15,20.35,
- 35,20,
- 35.15,20.35,/*-ME*/
- 36,18.3,
- 36.12,18.35,
- 36.6,19.5,
- 36.7,20,
- 37.7,20.2,
- 37.5,20.8,
- 36.8,21.2,
- 36.5,22.3,
- 35.5,22.2,
- 35.15,20.35,
- 0, 0, /* dc */
- 3, 0,
- 3, 3,
- 0, 3,
- 3, 0, /* alaska */
- 6, 0,
- 6, 3,
- 3, 3,
- 6, 0, /* hawaii */
- 9, 0,
- 9, 3,
- 6, 3, };
-
- float provinces[350] = {
- 0,40,/*-YK*/
- 0,34.8,
- 3.6,33.2,
- 4.5,35.6,
- 3,40,
- 0,40,
- 0,34.8,/*-BC*/
- 0,30,
- 1.3,29,
- 1,28,
- 1.7,27.3,
- 1.8,26.9,
- 1.5,26.8,
- 1.7,26,
- 2.3,24.4,
- 1.4,25.1,
- 1.1,25,
- 2.4,23,
- 3.5,22.8,
- 2.5,24.2,
- 3.5,23,
- 6.8,22.2,
- 7.6,22.1,
- 8.9,22,
- 8.8,22.9,
- 6.7,24.4,
- 6.7,26.3,
- 5.6,27.9,
- 7,32,
- 3.6,33.2,
- 0,34.8,
- 7,32,/*-AB*/
- 5.6,27.9,
- 6.7,26.3,
- 6.7,24.4,
- 8.8,22.9,
- 8.9,22,
- 11.8,21.58,
- 13,31,
- 7,32,
- 13,31,/*-SK*/
- 11.8,21.62,
- 14.7,21.15,
- 16,21.13,
- 16.7,30.6,
- 13,31,
- 16.7,30.6,/*-MB*/
- 16,21.13,
- 20,21,
- 20.1,21.3,
- 20.3,21.4,
- 20.6,24.3,
- 20.3,25.2,
- 23.3,27.4,
- 23.3,28.35,
- 22.5,28,
- 21,30.5,
- 16.7,30.6,
- 23.3,28.35,/*-ON*/
- 23.3,27.4,
- 20.3,25.2,
- 20.6,24.3,
- 20.3,21.4,
- 20.5,21,
- 23.7,20.4,
- 24.3,21,
- 25.8,21,
- 26.8,19.5,
- 29.3,18.8,
- 28.7,16.4,
- 30.2,17,
- 30.5,17.8,
- 32.2,18.5,
- 32.8,19.4,
- 33.2,19.6,
- 33.15,20,
- 30.4,20.8,
- 31,22.3,
- 30,24,
- 29.7,23.5,
- 29.3,24.4,
- 29,24.5,
- 28.7,26,
- 27.5,27.5,
- 24,28.5,
- 23.3,28.35,
- 31,22.3,/*-QE*/
- 30.4,20.8,
- 33.15,20,
- 33.2,19.6,
- 35,20,
- 35.5,22.2,
- 36.5,22.3,
- 37.3,23.7,
- 40,25,
- 40,27,
- 39,26.6,
- 37.4,27.9,
- 38,28.6,
- 37.3,32.3,
- 37,34,
- 36,33,
- 35,32,
- 34.3,32.2,
- 34.5,33.5,
- 32.2,36.2,
- 31.2,36,
- 32.3,31.8,
- 31.7,31.5,
- 31.5,30.5,
- 32.2,30,
- 32,29,
- 31,27,
- 30,27,
- 30.4,25.5,
- 30,24,
- 31,22.3,
- 40,25,/*-NB*/
- 37.3,23.7,
- 36.5,22.3,
- 36.8,21.2,
- 37.5,20.8,
- 38.3,21.6,
- 38.6,21.4,
- 38,20,
- 38.4,19.5,
- 39.5,20,
- 40,21.5,
- 40,25,
- 40,31.4,/*-NF*/
- 39.1,32.8,
- 38.7,33,
- 38,34,
- 37,34,
- 37.3,32.3,
- 38,28.6,
- 37.4,27.9,
- 39,26.6,
- 40,27,
- 40,31.4,
- 3,40,/*-NW*/
- 4.5,35.6,
- 3.6,33.2,
- 7,32,
- 13,31,
- 16.7,30.6,
- 21,30.5,
- 21.7,32,
- 24.3,35.5,
- 25,34.5,
- 28.3,35,
- 28,36,
- 25,36.3,
- 26.7,38,
- 26,40,
- 28.5,40,
- 30.5,38.5,
- 29.6,37.5,
- 33,37,
- 35.6,35.6,
- 37,37,
- 35.5,38,
- 37,38.5,
- 36,40,
- 23,40,
- 22.7,38.5,
- 21.5,38,
- 21,40,
- 3,40 };
-
- char sindex[110][3] = {
- "0", "wa",
- "12", "or",
- "24", "ca",
- "38", "nv",
- "47", "az",
- "57", "ut",
- "64", "id",
- "79", "mt",
- "91", "wy",
- "100", "co",
- "108", "nm",
- "116", "tx",
- "137", "ok",
- "147", "ks",
- "153", "ne",
- "161", "sd",
- "169", "nd",
- "174", "la",
- "184", "ar",
- "194", "mo",
- "206", "ia",
- "213", "mn",
- "226", "ms",
- "235", "al",
- "242", "fl",
- "258", "ga",
- "268", "il",
- "278", "wi",
- "288", "mi",
- "306", "in",
- "314", "oh",
- "323", "sc",
- "331", "ky",
- "341", "tn",
- "350", "nc",
- "361", "va",
- "371", "wv",
- "381", "pa",
- "393", "md",
- "403", "de",
- "407", "nj",
- "417", "ny",
- "431", "ct",
- "436", "ri",
- "441", "ma",
- "452", "vt",
- "457", "nh",
- "462", "me",
- "473", "dc",
- "477", "ak",
- "481", "hi",
- "485" };
-
- char pindex[26][3] = {
- "0", "yk",
- "6", "bc",
- "31", "ab",
- "40", "sa",
- "46", "mb",
- "58", "on",
- "86", "qu",
- "117", "nb",
- "129", "nf",
- "140", "nw",
- "169" };
-
- int nusa = 105;
- int ncanada = 93;
- int nstates = 485;
- int nprovinces = 169;
- int nsi = 51;
- int npi = 10;
-
- char *sname[55] = {
- "Washington",
- "Oregon",
- "California",
- "Nevada",
- "Arizona",
- "Utah",
- "Idaho",
- "Montana",
- "Wyoming",
- "Colorado",
- "New Mexico",
- "Texas",
- "Oklahoma",
- "Kansas",
- "Nebraska",
- "S Dakota",
- "N Dakota",
- "Louisiana",
- "Arkansas",
- "Missouri",
- "Iowa",
- "Minnesota",
- "Mississippi",
- "Alabama",
- "Florida",
- "Georgia",
- "Illinois",
- "Wisconsin",
- "Michigan",
- "Indiana",
- "Ohio",
- "S Carolina",
- "Kentucky",
- "Tennessee",
- "N Carolina",
- "Virginia",
- "W Virginia",
- "Pennsylvania",
- "Maryland",
- "Delaware",
- "New Jersey",
- "New York",
- "Connecticut",
- "Rhode Island",
- "Massachusetts",
- "Vermont",
- "New Hampshire",
- "Maine",
- "Dist. of Columbia",
- "Alaska",
- "Hawaii" };
-
- char *pname[12] = {
- "Yukon",
- "Brit. Columbia",
- "Alberta",
- "Saskatchewan",
- "Manitoba",
- "Ontario",
- "Quebec",
- "New Brunswick",
- "Newfoundland",
- "Northwest Terr." };
-
- SHAR_EOF
- ############################
-
- cat << \SHAR_EOF > src/nicetab.c
- /* Nicetab() - takes an ascii table an sets it up in a proportional font */
- #include <ctype.h>
- #include "ipl.x"
- #define MAX_ROW 132
- #define MAX_COL 132
-
- #define LINE 0
- #define TWO_BLANK 1
-
- #define LEFT 0
- #define CENTER 1
- #define RIGHT 2
- #define ROW 3
-
- extern char *Areacoords[];
- extern int Nareas;
-
-
- Nicetab( )
- {
-
- int i, iln, j, k, r, c, nrows, n; /* counters, row, col */
- int isnum; /* true if token is a number */
- int p; /* position of decimal point in number */
- int nblank; /* blank line counter */
- int first; /* first time thru */
- int more; /* more pages to do? */
- int maxc; /* max number of chars on any one line */
- int coord[4]; /* returned by getphrase(),
- holds col position of string left, center, and right, and row */
- char t[MAX_COL][MAX_ROW]; /* text matrix */
- int shadeblocks; /* table row shading option */
- int shade; /* shade flag */
- char area[60]; /* paper area */
- FILE *fp;
-
-
- Scale_discipline_x = LINEAR; /* either LINEAR or LOG */
- Scale_discipline_y = LINEAR; /* either LINEAR or LOG */
- /* get file containing ascii table, running it through expand to change tabs to spaces */
- gget( area, "File" );
- if( area[0] == '-' ) {
- area[0] = '\0';
- }
- sprintf( Buf, "expand %s > %s", area, Tempfile );
- system( Buf );
- fp = fopen( Tempfile, "r" );
- if( fp == NULL ) { fprintf( stderr, "Can't open %s.", Tempfile ); gdp_exit(); }
-
- /* read ascii file into t array, converting tabs to spaces */
- more = 0; r = 0; maxc = 0;
- /* initialize storage */
- for( i = 0; i < 132; i++ ) {
- for( j = 0; j < 132; j++ ) t[i][j] = ' ';
- t[i][131] = '\0';
- }
- while( fgets( Buf, 512, fp ) != NULL ) {
- c = 0;
- if( strlen( Buf ) >= MAX_COL || r >= MAX_ROW )
- fprintf( stderr, "Sorry, ascii table size limit %d rows x %d cols", MAX_ROW, MAX_COL );
- for( i = 0; i < strlen( Buf ); i++ ) {
- if( Buf[i] == '\t' ) for( ; c % 8 != 0; c++ ) t[ r ][ c ] = ' ';/* handle tabs */
- else t[ r ][ c++ ] = Buf[ i ];
- }
- if( c > maxc ) maxc = c;
- r++;
- }
- fclose( fp );
- Ymax = r;
- nrows = r;
-
- /* set up an area (supercedes areadef because table dimensions aren't known
- ahead of time) */
- gget( area, "Area.rectangle" );
- if( strlen( area ) > 0 ) {
- n = sscanf( area, "%lf %lf %lf %lf", &Xlo, &Ylo, &Xhi, &Yhi );
- }
- else {
- gget( area, "Area" );
- for( i = 0; i < Nareas; i++ ) if( strncmp( area, Areacoords[i], strlen( area )) ==0 ) break;
- if( i == Nareas ) { fprintf( stderr, "Can't find preset area '%s'.\n", area ); gdp_exit(); }
- if( Paper == 0 ) /* portrait */
- n = sscanf( Areacoords[i], "%*s %lf %lf %lf %lf", &Xlo, &Ylo, &Xhi, &Yhi );
- else n = sscanf( Areacoords[i], "%*s %*s %*s %*s %*s %lf %lf %lf %lf", &Xlo, &Ylo, &Xhi, &Yhi );
- if( n != 4 ) { fprintf( stderr, "Error in area presets.\n" ); gdp_exit(); }
- }
-
- /* set scaling based on longest line and number of rows */
- setscale_x( Xlo, Xhi, 0.0, (double) maxc );
- setscale_y( Ylo, Yhi, 0.0, Ymax );
-
- /* title assumed to be everything until at least 2 blank lines encountered */
- gget( Buf, "Title.font" );
- NTfont( Buf );
- gget( Buf, "Title.size" );
- NTptsize( atof(Buf) );
- gget( Buf, "Body.only" );
- if( Buf[0] == 'y' ) { r = 0; goto BODY; }
-
- nblank = -999;
- for( r = 0; r < nrows ; r++ ) {
- /* count blank lines */
- if( sscanf( t[r], "%s", Buf ) < 1 ) {
- nblank++;
- if( nblank >= 2 ) break;
- else continue;
- }
- else nblank = 0;
- getphrase( Buf, t[r], coord, &c, LINE );
- coord[ROW] = r;
- center( Buf, coord );
- }
- if( r > 15 ) fprintf( stderr, "Warning: use at least two blank lines to separate table title from body.\n" );
-
-
- /* do BODY of table */
- BODY:
- gget( Buf, "Body.font" );
- NTfont( Buf );
- gget( Buf, "Body.size" );
- NTptsize( atof(Buf) );
-
- shadeblocks = NO;
- shade = NO;
- for( ; r < nrows; r++ ) {
- c = 0;
-
- /* special operators */
- if( t[r][0] == '@' ) {
- if( strncmp( t[r], "@shadeblocks-on", 15 )==0 ) { shadeblocks = YES; iln = -1; }
- else if( strncmp( t[r], "@shadeblocks-off", 16 )==0 ) { shadeblocks = NO; shade = NO; }
- else if( strncmp( t[r], "@shade-on", 9 )==0 ) shade = YES;
- else if( strncmp( t[r], "@shade-off", 10 )==0 ) shade = NO;
-
- continue;
- }
-
- if( shadeblocks ) {
- iln++;
- if( ( iln / 3 ) % 2 == 0 ) shade = YES;
- else shade = NO;
- }
-
- if( shade ) rect( 0.0,(double)((Ymax-r)-.15), (double)(maxc),(double)((Ymax-r)+.85), 0.98, NO );
-
-
- if( sscanf( t[r], "%s", Buf ) < 1 ) continue; /* don't mess with blank lines */
-
- first = 1;
- while( 1 ) {
-
- /* get a phrase, and position of beginning and end.. */
- getphrase( Buf, t[r], coord, &c, TWO_BLANK, first );
- coord[ROW] = r;
- if( Buf[0] == '\0' ) break;
-
-
- /* see if its a number */
- isnum = goodnum( Buf, &p );
-
- /* horizontal rulings (entire token must be -,_,or =) */
- for( i = 0; i < strlen( Buf ); i++ ) if( !member( Buf[i], "-_=" )) break;
-
- if( strlen( Buf ) > 2 && i == strlen( Buf )) ruler( Buf, coord );
-
- /* vertical rulings */
- else if( Buf[0] == '|' ) vert_ruler( coord, nrows, t );
-
- /* if phrase is 1st thing on line (within 8 chars), left justify */
- else if( first && coord[LEFT] < 10 ) ljust( Buf, coord );
-
- /* if phrase is alpha and longer than 2 chars and not near the top, left justify (?) */
- else if( strlen( Buf ) > 2 && isalpha( Buf[0] ) && r > 10 ) ljust( Buf, coord );
-
- /* numbers.. right-just */
- else if( isnum ) rjust( Buf, coord );
-
- /* everything else gets centered */
- else center( Buf, coord );
-
- first = 0;
- }
- }
- }
-
-
- /* ====================================== */
- getphrase( out, line, coord, c, mode, first )
- char out[], /* returned phrase */
- line[]; /* input line */
- int coord[4]; /* returned location */
- int *c; /* position in line */
- int mode; /* tells if phrases are
- 1) == LINE everything on a line;
- 2) == TWO_BLANK delimited by 2 spaces or 1 tab
- */
- int first; /* behaves differently if getting 1st phrase on a line. */
- {
- int i;
-
- if( mode == LINE ) { /* working with whole line */
- if( sscanf( line, "%s", out ) < 1 ) { out[0] = '\0'; return( 0 ); } /* blank line */
- for( i = 0; ; i++ ) if( !member( line[i], "\t \n" ) ) break; /* skip white space on left */
- for( (*c) = strlen( line ); ; (*c)-- ) if( !member( line[i], "\t \n" ) ) break; /* skip white space on right */
- }
-
- else if( mode == TWO_BLANK ) {
- if( sscanf( &line[ (*c) ], "%s", out ) < 1 ) { out[0] = '\0'; return( 0 ); }
- for( i = (*c); i < strlen( line ) ; i++ )
- if( !member( line[i], "\t \n" ) ) break; /* skip white space on left */
- /* go until we hit a stopping rule */
- for( (*c) = i; (*c)<strlen( line ) ; (*c)++ ) {
- if( line[ (*c) ] == ' ' && line[ (*c)-1 ] == ' ' ) break;
- else if( first ) continue;
- else if( member( line[ (*c) ], "()[]<>|" ) && (*c)==i ) { (*c)++; break; } /* first token-- return it */
- else if( member( line[ (*c) ], "()[]<>|\t" ) ) break; /* not first token, return and get it next time */
- }
- }
-
- strncpy( out, &line[i], (*c)-i );
- for( ; ; (*c)-- ) if( ! member( out[ ((*c)-i)-1 ], " \t\n" ) ) break;
- out[ (*c)-i ] = '\0';
-
- coord[ LEFT ] = i; coord[ CENTER ] = ((*c) + i ) / 2; coord[ RIGHT ] = (*c);
-
- }
- /* ====================================== */
- center( str, coord )
- char str[];
- int coord[4];
- {
- NTm( coord[LEFT], Ymax-coord[ROW] );
- NTcentext( str, da_x( (double)coord[RIGHT] )-da_x( (double)coord[LEFT] ) );
- }
- /* ====================================== */
- center_float( str, coord )
- char str[];
- int coord[4];
- {
-
- }
- /* ====================================== */
- ljust( str, coord )
- char str[];
- int coord[4];
- {
- NTm( coord[LEFT], Ymax-coord[ROW] );
- NTtext( str );
- }
- /* ====================================== */
- rjust( str, coord )
- char str[];
- int coord[4];
- {
- NTm( coord[LEFT], Ymax-coord[ROW] );
- NTrightjust( str, da_x( (double)coord[RIGHT] ) - da_x( (double) coord[LEFT]) );
- }
- /* ================================== */
- ruler( str, coord )
- char str[];
- int coord[4];
- {
- NTm( coord[LEFT], Ymax-coord[ROW]+.5 );
- NTl( coord[RIGHT], Ymax-coord[ROW]+.5 );
- }
-
- /* ================================= */
- vert_ruler( coord, nrows, t )
- int coord[4], nrows;
- char t[][MAX_ROW];
- {
- int i;
- NTm( coord[LEFT]+.5, (Ymax-coord[ROW])+1 );
- for( i = coord[ROW]+1; i < nrows; i++ )
- if( t[i][ coord[LEFT] ] == '|' ) { NTl( coord[LEFT]+.5, (Ymax-i) ); return( 1 ); }
- }
- SHAR_EOF
- ############################
-
-
-