home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / SOURCES / IPL / PART11.Z / PART11
Encoding:
Text File  |  1998-07-24  |  23.9 KB  |  1,075 lines

  1. Subject:  v21i042:  2D graphic system with table beautifier, Part11/14
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: f0f1f3af 00cbabeb 54d53a34 80732457
  5.  
  6. Submitted-by: Steve Grubb <uunet!lsr-vax!scg>
  7. Posting-number: Volume 21, Issue 42
  8. Archive-name: ipl/part11
  9.  
  10. # ipl part11
  11. #    This is a shell archive.
  12. #    Remove everything above and including the cut line.
  13. #    Then run the rest of the file through sh.
  14. #---------------------- cut here -----------------------------
  15. #!/bin/sh
  16. # shar:    Shell Archiver
  17. #    Run the following text with /bin/sh to create:
  18. #        src/util.c
  19. #        src/vbargraph.c
  20. #        src/vector.c
  21. #        src/viplmenu.c
  22. #        src/vrangebar.c
  23. #        examples/absunits.g
  24. #        examples/areadef1.g
  25. #        examples/areadef2.g
  26. #        examples/arrow.g
  27. #        examples/bargraph1.g
  28. cat << \SHAR_EOF > src/util.c
  29. #include "gdp.x"
  30.  
  31. extern char *getlogin();
  32.  
  33. /* ============== */
  34. /* save_spec() can be called to save current proc specification in file s. */
  35. save_parms( s )
  36. char s[];
  37. {
  38. char fnm[PATHNAME_LEN];
  39. FILE *fp;
  40. int i;
  41.  
  42. sprintf( fnm, "%s/ipl%s%d.%s", TEMPDIR, getlogin(), getpid(), s );
  43. fp = fopen( fnm, "w" );
  44. if( fp == NULL ) { fprintf( stderr, "Can't w open inherit file %s.\n", fnm ); gdp_exit(); }
  45. for( i = 0; i < Clines; i++ ) fprintf( fp, "%s", Chunk[i] );
  46. fclose( fp );
  47. }
  48.  
  49. /* =============== */
  50. /* load_spec() can be called to use parameters from file s as defaults. */
  51. load_parms( s )
  52. char s[];
  53. {
  54. char fnm[PATHNAME_LEN];
  55. FILE *fp;
  56.  
  57. if( strlen( s ) < 1 ) { Ilines = 0; return( 1 ); }
  58. sprintf( fnm, "%s/ipl%s%d.%s", TEMPDIR, getlogin(), getpid(), s );
  59. fp = fopen( fnm, "r" );
  60. if( fp == NULL ) { fprintf( stderr, "Can't open inheritance file %s.\n", fnm ); gdp_exit(); }
  61. Ilines = 0;
  62. while( fgets( Ichunk[ Ilines ], INWIDTH, fp ) != NULL ) Ilines++;
  63. fclose( fp );
  64. }
  65.  
  66. /* ============== */
  67. /* gdp_exit() can be used by application to explicitly do a clean exit */
  68. gdp_exit()
  69. {
  70. char com[80];
  71. sprintf( com, "rm %s/ipl%s%d* 2> /dev/null", TEMPDIR, getlogin(), getpid() );
  72. system( com );
  73. proc_call( "Exit" );
  74. exit();
  75. }
  76.  
  77. /* =============
  78.    ============= */
  79. /* The following are utilities for dealing with multi-line responses */
  80. /* ========= */
  81. /* getln() returns successive portions of s as separated by \n */
  82.  
  83. char *getln( s )
  84. char s[];
  85. {
  86. static char rtn[INWIDTH];
  87. static int c = 0;
  88. int l, start;
  89.  
  90. /* a null argument resets */
  91. if( strlen( s ) < 1 ) {
  92.     c = 0;
  93.     return( "" );
  94.     }
  95. start = c;
  96. for( ; c < strlen( s ); c++ ) if( s[c] == '\n' ) break;
  97. strncpy( rtn, &s[start], c-start );
  98. rtn[ c-start ] = '\0';
  99. c++;
  100. return( rtn );
  101. }
  102.  
  103.  
  104. /* ======= */
  105. /* countln() returns number of \n separated lines in s */
  106.  
  107. countln( s )
  108. char s[];
  109. {
  110. int i, nnl;
  111. if( strlen( s ) < 1 ) return( 0 );
  112. nnl = 0;
  113. for( i = 0; i < strlen( s ) -1; i++ ) if( s[i] == '\n' ) nnl++;
  114. nnl++;
  115. return( nnl );
  116. }
  117.  
  118. /* ======== */
  119. /* text_tofile() places text s into file f */
  120.  
  121. text_tofile( s, f )
  122. char s[], f[];
  123. {
  124. FILE *fp;
  125.  
  126. fp = fopen( f, "w" );
  127. if( fp == NULL ) { fprintf( stderr, "text_tofile: can't open Tempfile.\n" ); exit(); }
  128. fprintf( fp, "%s\n", s );
  129. fclose( fp );
  130. }
  131.  
  132.  
  133. /* ============ */
  134. /* main program for testing these routines. */
  135. /* main() 
  136. {
  137. char s[30];
  138. char *getln();
  139. strcpy( s, "Hello\nworld\nhello\n" );
  140. printf( "%d\n", countln( s ) );
  141. printf( "%s\n", getln( s ) );
  142. printf( "%s\n", getln( s ) );
  143. printf( "%s\n", getln( s ) );
  144. strcpy( s, "Hello\nworld\nhello" );
  145. printf( "%d\n", countln( s ) );
  146. printf( "%s\n", getln( s ) );
  147. printf( "%s\n", getln( s ) );
  148. printf( "%s\n", getln( s ) );
  149. text_tofile( s, "/usr/tmp/testutil001" );
  150. }
  151. */
  152. SHAR_EOF
  153. ############################
  154.  
  155. cat << \SHAR_EOF > src/vbargraph.c
  156. #include "ipl.x"
  157. #define STACK    0
  158. #define CLUSTER 1
  159.  
  160.  
  161. Vbargraph( )
  162. {
  163. int     k[8], 
  164.     idf[8],
  165.     format,
  166.     label,
  167.     n,
  168.     nc,
  169.     i, j, jj,
  170.     p,
  171.     start,
  172.     yset,
  173.     yfld,
  174.     outline;
  175.  
  176. double s[8],
  177.     accum,
  178.     zer,
  179.     cury,
  180.     yspace,
  181.     subspace,
  182.     x,
  183.     x2,
  184.     f,
  185.     lblpos,
  186.     sep,
  187.     msep = 0.03;
  188. char str[10];
  189.  
  190.  
  191. /* get the data field list */
  192. gget( Buf, "Field" ); 
  193. n = 0;
  194. while( n < 1 ) { 
  195.     n = sscanf( Buf, "%d %d %d %d %d %d %d %d", &k[0], &k[1], &k[2], &k[3], &k[4], &k[5], &k[6], &k[7] );
  196.     if( N_d_fields == 1 ) strcpy( Buf, "1" );
  197.     else if( n < 1 ) { fprintf( stderr, "Field bad\n" ); gdp_exit(); }
  198.     }
  199. for( i = 0; i < n; i++ ) 
  200.     if( k[i] < 1 || k[i] > N_d_fields ) { fprintf( stderr, "Field out of range" ); gdp_exit(); }
  201.  
  202. /* get the label field list, if any */
  203. gget( Buf, "Idfield" ); 
  204. if( strlen( Buf ) > 0 ) { 
  205.     label = YES;
  206.     sscanf( Buf, "%d %d %d %d %d %d %d %d", &idf[0], &idf[1], &idf[2], &idf[3], &idf[4], &idf[5], &idf[6], &idf[7] );
  207.     for( i = 0; i < n; i++ ) 
  208.         if( idf[i] < 1 || idf[i] > N_d_fields ) { fprintf( stderr, "Idfield bad.\n" ); gdp_exit(); }
  209.     }
  210. else label = NO;
  211.  
  212.  
  213. gget( Buf, "Format" );  
  214. if( strcmp( Buf, "stack" )==0 ) format = STACK;
  215. else format = CLUSTER;
  216.  
  217. DYtic = 1.0;
  218.  
  219. /* get bar shades */
  220. gget( Buf, "Shade" ); 
  221. sscanf( Buf, "%lf %lf %lf %lf %lf %lf %lf %lf", &s[0], &s[1], &s[2], &s[3], &s[4], &s[5], &s[6], &s[7] );
  222.  
  223. /* get zero line */
  224. gget( Buf, "Zeroat" ); 
  225. if( goodnum( Buf, &p )) zer = atof( Buf );
  226. else zer = DXlo;
  227.  
  228. /* get label size */
  229. if( label ) { gget( Buf, "Idfield.size" ); NTptsize( atof( Buf ) ) };
  230.  
  231. /* distance of label from bar top */
  232. if( label ) { gget( Buf, "Idfield.position" ); lblpos = atof( Buf ); }
  233.  
  234. /* outline or not */
  235. gget( Buf, "Outlinebars" ); if( Buf[0] == 'y' ) outline = YES; else outline = NO;
  236.  
  237. /* x distance between major bar spaces */
  238. gget( Buf, "Separation" ); sep = atof( Buf );
  239.  
  240. gget( Buf, "Separation.sub" ); msep = atof( Buf );
  241.  
  242.  
  243. yspace = ( (Yhi-Ylo)/((DYhi-DYlo)+1) ) - (sep*Scale_y);
  244.  
  245. if( format == CLUSTER ) nc = n; else nc = 1;
  246.  
  247. gget( Buf, "Killwild" ); /* option for aborting plot if any values out of range */
  248. if( atof( Buf ) != 0 ) {
  249.     for( i = 1; i <= N_d_rows; i++ ) {
  250.         if( atof( D[i-1][ k[0] -1 ] ) > atof( Buf ) ) {
  251.             fprintf( stderr, "Note: This Vbargraph terminated due to a value of %s.\n", D[i-1][k[0]-1] );
  252.             return( 0 );
  253.             }
  254.         }
  255.     }
  256.  
  257. gget( Buf, "Yfield" ); /* allow placement of bars by a data field */
  258. if( strlen( Buf ) > 0 ) {
  259.     yset = 1;
  260.     yfld = atoi( Buf );
  261.     if( yfld < 1 || yfld > N_d_fields ) { fprintf( stderr, "Yfield bad.\n" ); gdp_exit(); }
  262.     }
  263. else yset = 0;
  264.  
  265. gget( Buf, "Ystart.0or1" ); /* allow starting at 0 or 1 */
  266. if( Buf[0] == '0' ) { start = 0; }
  267. else { start = 1; }
  268.  
  269. for( i = 1; i <= N_d_rows; i++ ) {
  270.     if( yset ) cury = da_y( atof( D[i-1][yfld-1] ) ) - (yspace/2);
  271.     else cury = da_y((double)(DYlo+i+(start-1))) - (yspace/2);
  272.     subspace = ( yspace / nc );
  273.     for( j = 0; j < nc; j++ ) {
  274.         if( !goodnum( D[i-1][ k[j]-1 ], &p )) {
  275.             fprintf( stderr, "Warning: row %d, field %d, is bad (%s)\n", i, k[j], D[i-1][ k[j]-1] );
  276.             cury += subspace;
  277.             continue;
  278.             }
  279.         x = atof(D[i-1][ k[j]-1 ]);
  280.         if( x != DXlo )
  281.             ab_rect( da_x(zer), cury, da_x(x), cury+(subspace-msep), s[j], (s[j]==1)?1:outline );
  282.         if( label ) {
  283.             if( x < zer || format == STACK ) f = (-lblpos)-Chh; else f = lblpos;
  284.             strcpy( str, D[i-1][ idf[j]-1 ] );
  285.             NTmov( da_x(x)+f, cury );
  286.             NTtext( str ); /* will change */
  287.             }
  288.         if( format == STACK ) for( jj = 1; jj < n; jj++ ) {
  289.             if( !goodnum( D[i-1][ k[jj] -1 ], &p ) ) {
  290.                 fprintf( stderr, "Warning: row %d, field %d, is bad (%s)\n", i, k[jj], D[i-1][k[jj]-1] );
  291.                 continue;
  292.                 }
  293.             x2 = x + atof( D[i-1][ k[jj] -1 ] );
  294.             if( x2 != DXlo )
  295.                ab_rect( da_x(x), cury,  da_x(x2), cury+(subspace-msep), s[jj], (s[jj]==1)?1:outline );
  296.             if( label ) {
  297.                 if( x2 < zer || format == STACK ) f = (-lblpos)-Chh; else f = lblpos;
  298.                 NTmov( da_x(x2)+f, cury );
  299.                 strcpy( str, D[i-1][ idf[jj]-1 ] );
  300.                 NTtext( str );
  301.                 }
  302.             x = x2;
  303.             }
  304.  
  305.         cury += subspace;
  306.         }
  307.     }
  308.  
  309. gget( Buf, "Segment" );
  310. if( Buf[0] == 'y' ) 
  311.     for( f = DXlo+DXtic; f < DXhi; f += DXtic ) 
  312.         rect(  f-(DXhi*0.003), DYlo + 0.2, f+(DXhi*0.004), DYhi - 0.2, (double)WHITE, 0 );
  313. }
  314. SHAR_EOF
  315. ############################
  316.  
  317. cat << \SHAR_EOF > src/vector.c
  318. #include "ipl.x"
  319.  
  320. Vector( )
  321. {
  322. int i, fx1, fy1, fx2, fy2;
  323. double hl, hw, hs;
  324.  
  325. gget( Buf, "Point1fields" ); sscanf( Buf, "%d %d", &fx1, &fy1 );
  326. gget( Buf, "Point2fields" ); sscanf( Buf, "%d %d", &fx2, &fy2 );
  327. gget( Buf, "Headlength" ); hl = atof( Buf );
  328. gget( Buf, "Headwidth" ); hw = atof( Buf );
  329. gget( Buf, "Headshade" ); hs = atof( Buf );
  330.  
  331. for( i = 0; i < N_d_rows; i++ ) {
  332.     arr( da_x( atof( D[i][fx1-1] ) ), da_y( atof( D[i][fy1-1] ) ),
  333.          da_x( atof( D[i][fx2-1] ) ), da_y( atof( D[i][fy2-1] ) ),
  334.         hw, hl, hs );
  335.     }
  336. }
  337. SHAR_EOF
  338. ############################
  339.  
  340. cat << \SHAR_EOF > src/viplmenu.c
  341. /* Vipl allows addition of text, arrows, etc. */
  342.  
  343. #include "ipl.x"
  344.  
  345. FILE *hfp, *ofp;
  346. char holdingfile[80], outfile[80], dispfile[80];
  347.  
  348. vipl_sequence( cfile )
  349. char cfile[];
  350. {
  351. char buf[2000], command[30], area[30];
  352. double x, y, x2, y2;
  353. int i, size;
  354. FILE *fp;
  355. char textsize[40], textfont[40], linethick[40], linedash[40], dashsize[40];
  356. strcpy( textsize, "10" );
  357. strcpy( textfont, "/Helvetica" );
  358. strcpy( linethick, "0.8" );
  359. strcpy( linedash, "0" );
  360. strcpy( dashsize, "3" );
  361.  
  362.  
  363.  
  364.  
  365. /* open holding file */
  366. sprintf( holdingfile, "%s/%siplhold%05d", INSTALL_TMP, getlogin(), getpid() );
  367. hfp = fopen( holdingfile, "w" );
  368. if( hfp == NULL ) { fprintf( stderr, "Cannot open holding file\n" ); gdp_exit(); }
  369.  
  370. /* get dispfile name */
  371. sprintf( dispfile, "%s/%sipldisp%05d", INSTALL_TMP, getlogin(), getpid() );
  372.  
  373. /* initialize ofp */
  374. sprintf( outfile, "%s/%siplout%05d", INSTALL_TMP, getlogin(), getpid() );
  375. ofp = fopen( outfile, "w" );
  376. if( ofp == NULL ) { fprintf( stderr, "Cannot open output file\n" ); gdp_exit(); }
  377. fclose( ofp );
  378.  
  379. libdisplay( "viplstartup.g", 1 );
  380.  
  381. fp = fopen( cfile, "r" );
  382. if( fp == NULL ) { message( cfile, "doen't exist.", "", "Creating a new plot.." ); sleep( 1 ); }
  383. else fclose( fp );
  384. fp = fopen( cfile, "a" );
  385. if( fp == NULL ) { message( "NOTE:", "This file is READ-ONLY", "", "" ); sleep( 1 ); }
  386. else fclose( fp );
  387.  
  388. /* copy user's control file to output file to start off.. */
  389. sprintf( buf, "cp %s %s 2> /dev/null", cfile, outfile );
  390. system( buf );
  391.  
  392. getpick( buf, "Start", 1, 1 );
  393. userdisplay( 1 );
  394.  
  395. while( 1 ) {
  396.  
  397.     message( "", "Main menu.", "", "" );
  398.  
  399.     /* find out the graph type.. */
  400.     getpick( command, "Text Arrow Line Box Bullet Set_parms Dataclick Redraw Print Quit", 1, 1 );
  401.  
  402.     if( strcmp( command, "Redraw" )==0 ) userdisplay( 1 );
  403.  
  404.     else if( strcmp( command, "Dataclick" )==0 ) {
  405.         message( "Coordinates can optionally",
  406.              "be saved in a file.", 
  407.              "Enter a file name, or",
  408.              "just press enter." );
  409.         get_string_box( buf, "> ", 8.0, 9.5, 11.0, 9.8 );
  410.         dataclick( buf );
  411.         }
  412.  
  413.     else if( strcmp( command, "Set_parms" )==0 ) {
  414.         while( 1 ) {
  415.             message( "Select a parameter:", "", "The current value", " is in parentheses." );
  416.             sprintf( buf, "1.Text_size(%s) 2.Font(%s) 3.Line_thickness(%s) 4.Line_dash(%s)\
  417.                 5.Dash_size(%s) Exit - - - -", textsize, textfont, linethick, linedash, dashsize );
  418.             getpick( buf, buf, 1, 1 );
  419.             if( buf[0] == '1' ) {
  420.                 message( "Select size in points..", "", "Current size is:", textsize );
  421.                 getpick( textsize, "6 7 10 11 12 14 16 18 24 -", 1, 1 );
  422.                 }
  423.             else if( buf[0] == '2' ) { 
  424.                 message( "Select font..", "", "Current font is:", textfont );
  425.                 getpick( textfont, "fonts.mu", 1, 1 ); 
  426.                 userdisplay( 1 ); 
  427.                 }
  428.             else if( buf[0] == '3' ) {
  429.                 libdisplay( "linethick.g" );
  430.                 message( "Click on the thickness", "of your choice..", "", "" );
  431.                 getpick( linethick, "linethick.mu", 1, 0 );
  432.                 }
  433.             else if( buf[0] == '4' ) {
  434.                 libdisplay( "linetype.g" );
  435.                 message( "Click on the line dash", "style of your choice..", "", "" );
  436.                  getpick( linedash, "linetype.mu", 1, 0 );
  437.                 }
  438.             else if( buf[0] == '5' ) {
  439.                 libdisplay( "dashsize.g" );
  440.                 message( "Click on the dash size", "of your choice..", "", "" );
  441.                  getpick( dashsize, "linedash.mu", 1, 0 );
  442.                 }
  443.             else break;
  444.             }
  445.         userdisplay( 1 );
  446.         }
  447.     else if( strcmp( command, "Text" )==0 ) {
  448.             while( 1 ) {
  449.             message( "Point to place where", "text should start.", "", "" );
  450.             get_point( &x, &y );
  451.             message( "Enter text..", "Press control-d when done.", "", "" );
  452.             NTptsize( atof( textsize ) );
  453.             y -= Chh*0.4;
  454.             get_text_box_tp( buf, "", x-0.2, y-2.0, x+4.0, y );
  455.             fprintf( hfp, "\nProc Text:\nFont: %s\nSize: %s\nPosition: %6.2f %6.2f\nText: %s", 
  456.                 textfont, textsize, x, y, buf );
  457.             userdisplay( 1 );
  458.             if( commit() ) break;
  459.             }
  460.         }
  461.  
  462.     else if( strcmp( command, "Arrow" )==0 ) {
  463.         while( 1 ) {
  464.             message( "Point to place where", "arrowhead should be", "", "" );
  465.             get_point( &x, &y );
  466.             message( "", "", "Point to place where", "other end should be" );
  467.             get_point( &x2, &y2 );
  468.             fprintf( hfp, "\nProc Arrow:\nPoints: %4.2f %4.2f %4.2f %4.2f\n", x2, y2, x, y );
  469.             userdisplay( 1 );
  470.             if( commit() ) break;
  471.             }
  472.         }
  473.  
  474.     else if( strcmp( command, "Line" )==0 ) {
  475.         while( 1 ) {
  476.             getpick( buf, "Horizontal Vertical Unconstrained - - - - - - -", 1, 1 );
  477.             message( "", "", "Point to place where", "one end should be" );
  478.             get_point( &x2, &y2 );
  479.             message( "Point to place where", "other end should be", "", "" );
  480.             get_point( &x, &y );
  481.             fprintf( hfp, "\nProc Draw:\nLinetype: %s\nLinethick: %s\nLinetype.magnify: %s\n",
  482.                 linedash, linethick, dashsize );
  483.             if( buf[0] == 'U' )fprintf( hfp, "Points: %4.2f %4.2f %4.2f %4.2f\n", x2, y2, x, y );
  484.             if( buf[0] == 'H' )fprintf( hfp, "Points: %4.2f %4.2f %4.2f %4.2f\n", x2, y2, x, y2 );
  485.             if( buf[0] == 'V' )fprintf( hfp, "Points: %4.2f %4.2f %4.2f %4.2f\n", x2, y2, x2, y );
  486.             userdisplay( 1 );
  487.             if( commit() ) break;
  488.             }
  489.         }
  490.             
  491.     else if( strcmp( command, "Box" )==0 ) {
  492.         while( 1 ) {
  493.             message( "", "", "Point to place where", "lower-left of box should be" );
  494.             get_point( &x2, &y2 );
  495.             message( "Point to place where", "upper-right of box should be", "", "" );
  496.             get_point( &x, &y );
  497.             fprintf( hfp, "\nProc Draw:\nLinetype: %s\nLinethick: %s\nLinetype.magnify: %s\n",
  498.                 linedash, linethick, dashsize );
  499.             fprintf( hfp, "Points: %4.2f %4.2f %4.2f %4.2f\n %4.2f %4.2f\n %4.2f %4.2f\n %4.2f %4.2f\n",
  500.               x2, y2, x2, y, x, y, x, y2, x2, y2 );
  501.             userdisplay( 1 );
  502.             if( commit() ) break;
  503.             }
  504.         }
  505.  
  506.     else if( strcmp( command, "Bullet" )==0 ) {
  507.         while( 1 ) {
  508.             message( "Point to place where", "you want the bullet", "", "" );
  509.             get_point( &x, &y );
  510.             fprintf( hfp, "\nProc Point:\nMark: sym6n\nPosition: %4.2f %4.2f\n", x, y );
  511.             userdisplay( 1 );
  512.             if( commit() ) break;
  513.             }
  514.         }
  515.  
  516.     else if( strcmp( command, "Print" )==0 ) {
  517.         message( "Postscript image", "being sent to printer..", "", "" );
  518.         sprintf( buf, "pipl %s", outfile );
  519.         system( buf );
  520.         }
  521.     else if( strcmp( command, "Quit" ) ==0 ) {
  522.         libdisplay( "clear.g", 1 );
  523.         getpick( buf, "Resave Save_as Quit", 1, 1 );
  524.         if( smember( buf, "Resave Save_as" )) {
  525.             if( strcmp( buf, "Save_as" )==0 ) {
  526.                 get_string_box( dispfile, "Save as: ", 4.0, 6.0, 8.0, 6.4 );
  527.                 message( "Saved as:", dispfile, "", "" );
  528.                 sleep( 1 );
  529.                 }
  530.             else if( strcmp( buf, "Resave" )==0 ) {
  531.                 strcpy( dispfile, cfile );
  532.                 message( dispfile, "Control file resaved.", "", "" );
  533.                 sleep( 1 );
  534.                 }
  535.             sprintf( buf, "cp %s %s", outfile, dispfile );
  536.             system( buf );
  537.             }
  538.         else gdp_exit();
  539.         break;
  540.         }
  541.     }
  542. }
  543.  
  544.  
  545.  
  546. /* ========================================== */
  547. libdisplay( f, new )
  548. char f[];
  549. int new;
  550. {
  551. char fnm[80];
  552. if( Dev == 'm' ) return( 1 );
  553. sprintf( fnm, "%s/%s", TEMPLATE_PATH, f );
  554. if( new )ab_rect( 0.0, 0.0, 11.0, 11.0, 1.0, 0 );
  555. restart( fnm );
  556. display();
  557. }
  558.  
  559. /* ========================================== */
  560. filedisplay( f, new )
  561. char f[];
  562. int new;
  563. {
  564. if( Dev == 'm' ) return( 1 );
  565. if( new ) ab_rect( 0.0, 0.0, 11.0, 11.0, 1.0, 0 );
  566. restart( f );
  567. display();
  568. }
  569. /* ========================================== */
  570. userdisplay( new )
  571. int new;
  572. {
  573. char buf[150];
  574. if( Dev == 'm' ) return( 1 );
  575. if( hfp != NULL )fclose( hfp );
  576. if( new ) ab_rect( 0.0, 0.0, 11.0, 11.0, 1.0, 0 );
  577. sprintf( buf, "cat %s %s > %s", outfile, holdingfile, dispfile );
  578. system( buf );
  579. restart( dispfile );
  580. display();
  581. hfp = fopen( holdingfile, "a" );
  582. }
  583. /* ========================================== */
  584. commit( prompt )
  585. char prompt[];
  586. {
  587. static char buf[150];
  588.  
  589.  
  590. getpick( buf, "Keep Re-do Cancel", 1, 1 );
  591. if( strcmp( buf, "Keep" )==0 ) { 
  592.     if( hfp != NULL )fclose( hfp );
  593.     sprintf( buf, "cat %s >> %s", holdingfile, outfile );
  594.     system( buf );
  595.     hfp = fopen( holdingfile, "w" );
  596.     return( 1 );
  597.     }
  598.  
  599. else if( strcmp( buf, "Re-do" )==0 ) {
  600.     if( hfp != NULL )fclose( hfp );
  601.     hfp = fopen( holdingfile, "w" ); /* null out holding file */
  602.     userdisplay( 1 );
  603.     return( 0 );
  604.     }
  605.  
  606. else if( strcmp( buf, "Cancel" )==0 ) {
  607.     if( hfp != NULL )fclose( hfp );
  608.     hfp = fopen( holdingfile, "w" ); /* null out holding file */
  609.     userdisplay( 1 );
  610.     return( 1 );
  611.     }
  612. }
  613.  
  614. SHAR_EOF
  615. ############################
  616.  
  617. cat << \SHAR_EOF > src/vrangebar.c
  618. #include "ipl.x"
  619. Vrangebar( )
  620. {
  621. int f[8], row, i, doends, nf, nv, ir, mlrightonly, label, yf;
  622. double val[8];
  623. double w, y, shade, lblpos, mlw;
  624.  
  625. gget( Buf, "Nval" );
  626. nv = atoi( Buf );
  627.  
  628. gget( Buf, "Field" );
  629. if( nv == 1 ) { nf = sscanf( Buf, "%d", &f[1] ); f[2] = f[3] = f[1]; f[4] = f[5] = f[1]; }
  630. else if( nv == 2 ) { nf = sscanf( Buf, "%d %d", &f[1], &f[4] ); f[2] = f[3] = f[1]; f[5] = f[4]; }
  631. else if( nv == 3 ) { nf = sscanf( Buf, "%d %d %d", &f[1], &f[3], &f[5] ); f[2] = f[1]; f[4] = f[5]; }
  632. else if( nv == 4 ) { nf = sscanf( Buf, "%d %d %d %d", &f[1], &f[2], &f[4], &f[5] ); f[3] = f[4]; }
  633. else if( nv == 5 ) { nf = sscanf( Buf, "%d %d %d %d %d", &f[1], &f[2], &f[3], &f[4], &f[5] ); }
  634. if( nf != nv ) { fprintf( stderr, "Expecting %d Field values.\n", nv ); gdp_exit(); }
  635.  
  636.  
  637. gget( Buf, "Width" ); w = atof( Buf );
  638.  
  639. gget( Buf, "Linethick" );
  640. NTlinetype( "0", atof( Buf ), 1.0 );
  641.  
  642. label = 0;
  643. gget( Buf, "Idfield" );
  644. f[0] = atoi( Buf );
  645. if( f[0] > 0 ) {
  646.     label = 1;
  647.     gget( Buf, "Label.size" );
  648.     if( atoi( Buf ) > 0 ) NTptsize( atoi( Buf ) );
  649.  
  650.     gget( Buf, "Label.position" );
  651.     lblpos = atof( Buf );
  652.  
  653.     }
  654.  
  655. doends = 0;
  656. if( nf == 4 || nf == 5 ) {
  657.     gget( Buf, "Ends" );
  658.     if( Buf[0] == 'y' ) doends = 1;
  659.     }
  660.  
  661. mlw = w;
  662. mlrightonly = 0;
  663. if( nf == 3 || nf == 5 ) {
  664.     gget( Buf, "Midlinewidth" );
  665.     if( atof( Buf ) > 0 )mlw = atof( Buf );
  666.     gget( Buf, "Midlineright" );
  667.     if( Buf[0] == 'y' ) mlrightonly = 1;
  668.     }
  669.  
  670. gget( Buf, "Shade" );
  671. shade = atof( Buf );
  672.  
  673. gget( Buf, "Yfield" );
  674. yf = atoi( Buf );
  675.  
  676.  
  677. y = DYlo;
  678. for( ir = 0; ir < N_d_rows; ir++ ) {
  679.     for( i = 1; i <= 5; i++ ) val[i] = atof( D[ ir ][ f[i]-1 ] );
  680.     if( nv == 1 ) { val[1] = val[2] = 0; }
  681.     if( yf > 0 ) y = atof( D[ir][ yf-1 ] );
  682.     else y++;
  683.  
  684.     NTm( val[2], y-(w/2) ); /* lower edge of box */
  685.     NTp( val[2], y+(w/2) );
  686.     NTp( val[4], y+(w/2) );
  687.     NTp( val[4], y-(w/2) );
  688.     NTp( val[2], y-(w/2) ); /* upper edge */
  689.     NTshade( shade );
  690.     
  691.     NTm( val[1], y ); /* lower tail */
  692.     NTl( val[2], y );
  693.     if( doends ) { NTm( val[1], y-(w/2.7) ); NTl( val[1], y+(w/2.7) ); }
  694.     
  695.     NTm( val[2], y-(w/2) ); /* lower edge of box */
  696.     NTl( val[2], y+(w/2) );
  697.     NTl( val[4], y+(w/2) );
  698.     NTl( val[4], y-(w/2) );
  699.     NTl( val[2], y-(w/2) ); /* upper edge */
  700.     
  701.     NTm( val[4], y );
  702.     NTl( val[5], y ); /* upper tail */
  703.     if( doends ) { NTm( val[5], y-(w/2.7) ); NTl( val[5], y+(w/2.7) ); }
  704.     
  705.     if( mlrightonly )NTm( val[3], y-(w/2) ); /* median line */
  706.     else NTm( val[3], y-(mlw/2) ); 
  707.     NTl( val[3], y+(mlw/2) );
  708.     
  709.     if( label ) {
  710.         NTmov( da_x(lblpos)-1, da_y(y) );  /* print label */
  711.         sprintf( Buf, "%s", D[ir][f[0]-1 ] );
  712.         NTcentext( Buf, 2 );
  713.         }
  714.     
  715.     }
  716. NTnormline();
  717. }
  718. SHAR_EOF
  719. ############################
  720.  
  721. cat << \SHAR_EOF > examples/absunits.g
  722. Proc Page:
  723. Title:  Absolute units (inches), Paperway = portrait
  724. Paperway: portrait
  725.  
  726. Proc Areadef:
  727. Area.rectangle: 0 0 11 11
  728. Xmin: 0
  729. Xmax: 11
  730. Xinc: 1
  731. Ymin: 0
  732. Ymax: 11
  733. Yinc: 1
  734. Xstub.grid: line
  735. Xstub.yofs: -1.5
  736. Ystub.grid: line
  737. Ystub.xofs: -1.5
  738.  
  739. Proc Pagebreak:
  740.  
  741. Proc Page:
  742. Title:  Absolute units (inches), Paperway = landscape
  743. Paperway: landscape
  744.  
  745. Proc Areadef:
  746. Area.rectangle: 0 0 11 11
  747. Xmin: 0
  748. Xmax: 11
  749. Xinc: 1
  750. Ymin: 0
  751. Ymax: 11
  752. Yinc: 1
  753. Xstub.grid: line
  754. Xstub.yofs: -1.5
  755. Ystub.grid: line
  756. Ystub.xofs: -1.5
  757.  
  758. SHAR_EOF
  759. ############################
  760.  
  761. cat << \SHAR_EOF > examples/areadef1.g
  762. Proc Page:
  763. Title: Areadef examples
  764. Standard.font: /Helvetica-Oblique
  765.  
  766. Proc Areadef:
  767. Area: 4nw
  768. Subtitle: Figure 1
  769. Subtitle.above: 0.2
  770. Ymin: 0
  771. Ymax: 1000
  772. Yinc: 100
  773. Xmin: 0
  774. Xmax: 10
  775. Xinc: 1
  776. Saveas: A
  777.  
  778. Proc Areadef:
  779. Clone: A
  780. Area: 4ne
  781. Subtitle: Figure 2
  782. Ystub.grid: wline
  783. Shade: 0.95
  784. Xmax: 18
  785. Xstub: month
  786. Xstub.startmonth: 10
  787. Xstub.startyear: 86
  788. Xstart.0or1: 1
  789. Xstub.tics: none
  790. Ystub.tics: none
  791.  
  792. Proc Areadef:
  793. Clone: A
  794. Area: 4sw
  795. Subtitle: Figure 3
  796. Xstub.grid: line
  797. Xmax: 5
  798. Xstub: Sun
  799.     DEC
  800.     Silicon~Graphics
  801.     IBM
  802. Xstart.0or1: 1
  803. Ymin: -300
  804. Ystub.ticlen: -0.1
  805. Ystub.tics: both
  806. Frame: single
  807.  
  808. Proc Areadef:
  809. Clone: A
  810. Area: 4se
  811. Subtitle: Figure 4
  812. Subtitle.above: 0.4
  813. Ymin: 0
  814. Ymax: 1
  815. Yinc: 0.2
  816. Yticfmt: %3.1f
  817. Ystub.minor: 10
  818. Ystub.tics: both
  819. Ystub.stubs: both
  820. Ystub.grid: line
  821. Xmin: 0
  822. Xmax: 1
  823. Xinc: 0.2
  824. Xstub.grid: line
  825. Xstub.stubs: both
  826. Xstub.tics: both
  827. Xstub.minor: 10
  828. Xticfmt: %3.1f
  829.  
  830. SHAR_EOF
  831. ############################
  832.  
  833. cat << \SHAR_EOF > examples/areadef2.g
  834. Proc Page:
  835. Title: More areadef examples
  836.  
  837. Proc Areadef:
  838. Area: 4nw
  839. Ymin: 0
  840. Ymax: 1000
  841. Yinc: 100
  842. Xmin: 0
  843. Xmax: 10
  844. Xinc: 1
  845. Subtitle: Figure 5
  846. Ystub: Virginia
  847.     Pennsylvania
  848.     Ohio
  849.     New Jersey
  850.     New York
  851.     Massachussetts
  852.     Maryland
  853.     Delaware
  854.     Connecticut
  855. Ystart.0or1: 1
  856. Ystub.tics: none
  857. Xstub.tics: none
  858. Saveas: A
  859.     
  860. Proc Areadef:
  861. Clone: A
  862. Area: 4ne
  863. Subtitle: Figure 6
  864. Ystub.stubs: none
  865. Xstub.tics: none
  866. Xlabel: Standard A units
  867. Xlabel.position: 0.3
  868. Xlabel.size: 7
  869. #
  870. Proc Draw:
  871. System: data
  872. Points: 0 400 10 400
  873. Linetype: 2
  874. Linethick: 0.5
  875. Linetype.magnify: 3
  876. Saveas: B
  877. Proc Draw:
  878. Clone: B
  879. Points: 0 500 10 500
  880. Linetype: 3
  881. Proc Draw:
  882. Clone: B
  883. Points: 0 600 10 600
  884. Linetype: 6
  885. #
  886. Proc Areadef:
  887. Clone: A
  888. Subtitle: Figure 6
  889. Yaxis: none
  890. Area: 4ne
  891. Xmin: -30
  892. Xmax: 40
  893. Xinc: 10
  894. Xstub.yofs: 0.5
  895. Xstub.tics: none
  896. Xlabel: Standard G units
  897. Xlabel.size: 7
  898.  
  899. Proc Areadef:
  900. Clone: A
  901. Area: 4sw
  902. Subtitle: Figure 7
  903. Ymin: -16
  904. Ymax: 14
  905. Yinc: 2
  906. Ystub.size: 6
  907. Ylabel: Change in acuity
  908. Xmin: 0
  909. Xmax: 30
  910. Xinc: 3
  911. Ystub: num
  912. Xstub: 0
  913.     3
  914.     6
  915.  
  916.     12
  917.  
  918.  
  919.  
  920.     24
  921. Xlabel: Time in months
  922. Xstub.nolonetics: y
  923.  
  924. Proc Polygon:
  925. Rectangle: 4.15 0.6 8.1 5
  926. Shade: 0.95
  927.  
  928. Proc Areadef:
  929. Clone: A
  930. Subtitle: Figure 8
  931. Area: 4se
  932. Shade: 1.0
  933. Xmin: 0
  934. Xmax: 10
  935. Xinc: 1
  936. Ymin: 0
  937. Ymax: 10
  938. Yinc: 1
  939. Ystub: num
  940. Ystub.grid: line
  941. Xstub.grid: line
  942. Ystub.stubs: none
  943. Xstub.stubs: none
  944. Xstub.tics: none
  945. Ystub.tics: none
  946. SHAR_EOF
  947. ############################
  948.  
  949. cat << \SHAR_EOF > examples/arrow.g
  950. Proc Page:
  951. Title: Absolute units (inches)
  952.     and arrows
  953. Title.size: 15
  954. Title.belowtop: 3
  955.  
  956. Proc Areadef:
  957. Area.rectangle: 0 0 9 11
  958. Xstub.grid: line
  959. Ystub.grid: line
  960. Xmin: 0
  961. Xmax: 9
  962. Xinc: 1
  963. Ymin: 0
  964. Ymax: 11
  965. Yinc: 1
  966. Xstub.yofs: -1.5
  967. Xstub.size: 12
  968. Xstub.stubs: both
  969. Ystub.xofs: -1.5
  970. Ystub.size: 12
  971. Ystub.stubs: both
  972.  
  973. Proc Arrow:
  974. Points: 1 1 2 2
  975.  
  976. Proc Arrow:
  977. Points: 3 3 6 1
  978.  
  979. Proc Arrow:
  980. Points: 4 6 2 4
  981.  
  982. Proc Arrow:
  983. Points: 6 5 4 7
  984. SHAR_EOF
  985. ############################
  986.  
  987. cat << \SHAR_EOF > examples/bargraph1.g
  988. Proc Page:
  989. Title: Bargraph examples
  990.  
  991. Proc Getdata:
  992. Data:
  993. 01         0      1      0      6     10      1     11     10      2     -41
  994. 02         3      5      0      2      6      2      3     11      3     35
  995. 03         1      3.4    0      1      2      0      5      7      1     20
  996. 04         2      4.8    3     11     24      9     20     11     29     -13
  997. 05         0      3.3    1      1      4      0      8      3      2     -22
  998. 06         2      2      0      2      7      1      6      4      4     -28
  999. 07         1      3      0      1      6      1     24     22      3     31
  1000. 08         3      0.8    0      0      2      0      7      3      0     -15
  1001. 09         3      2.2    0      2      5      0      1      1      2     16
  1002. 10         4      8      1      6     10      1     12      2      4     48
  1003.  
  1004. Proc Areadef:
  1005. Area: 4nw
  1006. Subtitle: Fig. 1
  1007.     Single format, segmented
  1008. Subtitle.above: 0.3
  1009. Ymax: 40
  1010. Yinc: 10
  1011. # The following parameter makes the first stub move over one position
  1012. Xstart.0or1: 1
  1013. # Xmax must be set to at least one greater than the number of data rows
  1014. Xmax: 11
  1015. # Use the 1st data field for X stubs
  1016. Xstub:    @1
  1017. Saveas: A
  1018.  
  1019. Proc Bargraph:
  1020. Format: single
  1021. Field: 8
  1022. Shade: 0.8
  1023. Segment: y
  1024.  
  1025.  
  1026. Proc Areadef:
  1027. Clone: A
  1028. Area: 4ne
  1029. Subtitle: Fig. 2
  1030.     Stack format 
  1031. Ymax: 100
  1032.  
  1033. Proc Bargraph:
  1034. Format: stack
  1035. Field: 6 8 9
  1036. Shade: .5 .8 1
  1037. Outlinebars: n
  1038.  
  1039. Proc Areadef:
  1040. Clone: A
  1041. Area.rectangle: 1 3 8 5
  1042. Subtitle: Fig. 3
  1043.     Cluster format
  1044.  
  1045. Proc Bargraph:
  1046. Format: cluster
  1047. Separation: 0.2
  1048. Separation.sub: 0.0
  1049. Field: 6 8 9
  1050. Shade: .5 .8 1
  1051.  
  1052. Proc Areadef:
  1053. Clone: A
  1054. Area.rectangle: 1 0.5 8 2
  1055. Subtitle: Fig. 4
  1056.     Adjustable "Zero" line, values shown
  1057. Ymax:  50
  1058. Ymin: -50
  1059. Yinc: 10
  1060.  
  1061. Proc Bargraph:
  1062. Format: single
  1063. Field: 11
  1064. Shade: .5 .8 1
  1065. Idfield: 11
  1066. Zeroat: 0
  1067.  
  1068. Proc Draw:
  1069. Points: 0 0 11 0
  1070. System: data
  1071. SHAR_EOF
  1072. ############################
  1073.  
  1074.  
  1075.