home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / crc_plot / part05 < prev    next >
Encoding:
Text File  |  1987-07-07  |  48.7 KB  |  2,178 lines

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i049:  CRC Plotting Package, Part05/06
  5. Message-ID: <608@uunet.UU.NET>
  6. Date: 9 Jul 87 01:14:42 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 2167
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: "Wombat" <rsk@j.cc.purdue.edu>
  12. Posting-Number: Volume 10, Issue 49
  13. Archive-name: crc_plot/Part05
  14.  
  15.  
  16.  
  17. #    This is a shell archive.
  18. #    Remove everything above and including the cut line.
  19. #    Then run the rest of the file through sh.
  20. #----cut here-----cut here-----cut here-----cut here----#
  21. #!/bin/sh
  22. # shar:    Shell Archiver
  23. #    Run the following text with /bin/sh to create:
  24. #    src
  25. mkdir src
  26. chdir src
  27. cat << \SHAR_EOF > crc.h
  28. #
  29. /*
  30.     crc.h - include file for the CRC graphics package
  31.  
  32.     Carl Crawford
  33.     Purdue University
  34.     W. Lafayette, IN 47907
  35.  
  36.     Jan. 1981
  37. */
  38.  
  39. #include <stdio.h>
  40. #include <math.h>
  41. #include <signal.h>
  42.  
  43. unsigned short *_pic;   /* pointer to bit plane */
  44. int     _xp,_yp;        /* integer position */
  45. float   _axp,_ayp;      /* real position */
  46. float   _xo,_yo;        /* current origin */
  47. int     _ud;            /* indicates up/down for pen */
  48. int     _error;         /* indicates error in plotting */
  49. float    _fac;        /* scale factor */
  50. float    _ipsz;        /* size of the internal file - 1 */
  51. float    _ipsz10;    /* ipsize / 10.0 */
  52. int     DEV;            /* major device number */
  53. char    DEVN;           /* minor device number */
  54. int    BLANK;        /* 1 = don't blank device before plotting */
  55. char    *STORE;        /* default storage file */
  56. char    *PLOTFILT;    /* Plot Filter Name */
  57. float    TICDIS;        /* distance between tic marks on the axis */
  58. float    HEIGHT;        /* char height in axis routines */
  59. int    DIGITS;        /* number of dec. digits + 1 in axis annotation */
  60. unsigned _bufsize;    /* size of point buffer */
  61. char    _abuf[100];    /* char buffer for anyone */
  62. char    *SITE;        /* site for gplp */ 
  63. FILE    *_pipe_fd;    /* file descriptor for pipes and pseudo pipes */
  64. int    (*_isig)();    /* save SIGINT signal */
  65. int    (*_qsig)();    /* save SIGQUIT signal */
  66. int    (*_hsig)();    /* save SIGHUP signal */
  67. int    _intty[3];    /* save current tty modes in here */
  68.  
  69. /*    control characters */
  70.  
  71. #define    NUL 0        /* <nul> */
  72. #define    SOH 1        /* <soh> */
  73. #define    STX 2        /* <stx> */
  74. #define    ETC 3        /* <etc> */
  75. #define ETX 3           /* <etx> */
  76. #define EOT 4           /* <eot> */
  77. #define ENQ 5           /* <enq> */
  78. #define ACK 6        /* <ack> */
  79. #define BEL 7        /* <bel> */
  80. #define BS 8            /* <bs> */
  81. #define HT 9        /* <ht> */
  82. #define LF 10           /* <lf> */
  83. #define VT 11           /* <vt> */
  84. #define FF 12           /* <ff> */
  85. #define CR 13           /* <cr> */
  86. #define SO 14           /* <so> */
  87. #define SI 15           /* <si> */
  88. #define DLE 16        /* <dle> */
  89. #define DC1 17        /* <dc1> */
  90. #define DC2 18        /* <dc2> */
  91. #define DC3 19        /* <dc3> */
  92. #define DC4 20        /* <dc4> */
  93. #define NAK 21        /* <nak> */
  94. #define    SYN 22        /* <syn> */
  95. #define ETB 23          /* <etb> */
  96. #define CAN 24        /* <can> */
  97. #define EM 25        /* <em> */
  98. #define SUB 26          /* <sub> */
  99. #define ESC 27          /* <esc> */
  100. #define    FS 28        /* <fs> */
  101. #define GS 29           /* <gs> */
  102. #define RS 30           /* <rs> */
  103. #define US 31           /* <us> */
  104.  
  105.  
  106.  
  107. /*      variables for HP and TEK */
  108.  
  109. int _CM;    /* current mode */
  110. int _X;        /* x position */
  111. int _Y;        /* y position */
  112. int _FILL;    /* number of fill characters */
  113.  
  114. #define    BINARY_FONT_FILE    "/usr/unsup/lib/crc/font.5x7"
  115. #define    PLOTBIN            "/usr/bin/plot"
  116.  
  117. #define    BIT    0    /* major device table */
  118. #define GOV    1
  119. #define IMAGE    2
  120. #define    GGOV    3
  121. #define    GIMAGE    4
  122. #define    PLOT    5
  123. #define    TEK    6
  124. #define HP    7
  125.  
  126. #define MBIT    4
  127. /* maximum device in bit plane mode */
  128.  
  129. /*
  130.     Major and minor device tables
  131.  
  132.     DEV     DEVN    dev     OUTPUT
  133.     0       0       0       file or standard output
  134.         1       8       Versatec through gp (I)
  135.         2       16      Printronix through gplp (I) and opr (I)
  136.  
  137.     1       0       1       Comtal graphics overlay 0(*)
  138.         1       9       Comtal graphics overlay 1(*)
  139.         2       17      Comtal graphics overlay 2(*)
  140.  
  141.  
  142.     2       0       2       Comtal image image displayed(*)
  143.         1       10      Comtal image 0(*)
  144.         2       18      Comtal image 1(*)
  145.         3       26      Comtal image 2(*)
  146.  
  147.     3       0       3       Grinnell graphics overlay 0(*)
  148.         1       11      Grinnell graphics overlay 1(*)
  149.         2       19      Grinnell graphics overlay 2(*)
  150.         3       27      Grinnell graphics overlay 3(*)
  151.  
  152.     4       0       4       Grinnell Image being Displayed (*)
  153.         1       12      Grinnell Image Plane 0(*)
  154.         2       20      Grinnell Image Plane 1(*)
  155.         3       28      Grinnell Image Plane 2(*)
  156.         4       36      Grinnell Image Plane 3(*)
  157.         5       44      Grinnell Image Plane 4(*)
  158.  
  159.     5    0    5    Plot Subroutines
  160.  
  161.     6       0       6       Tektronix through standard output
  162.         1    14    Retro-Graphics through standard output
  163.         2    22    Tektronix 4113
  164.  
  165.     7       0       7       HP through /u/lib/graphics/hpd
  166.  
  167. (*) - through /u/lib/graphics/gd
  168.  
  169. */
  170. SHAR_EOF
  171. cat << \SHAR_EOF > draw.f
  172. c
  173. c    draw - draw a line and set the hiding boundaries accorindingly
  174. c
  175.     subroutine draw(x1,y1,x2,y2)
  176.     parameter(maxstp=8000)
  177.     logical xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  178.     logical vertcl,hrzntl
  179.     dimension above(maxstp),below(maxstp)
  180.     common /b/ above,below
  181.     common /d/ zlen,nx,ny,numstp,dlmnsm,dm,dl,small
  182.     common /flag/ xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  183.     common /pos/ xpos,ypos
  184.     if( x1 .eq. x2 .and. y1 .eq. y2 ) return
  185. c        going left or right?
  186.     isign = 1
  187.     if ( x2 .lt. x1 ) isign = -1
  188.     xpos = x1
  189.     ypos = y1
  190.     hrzntl    = .false.
  191. c
  192. c        if the line is vertical increase the number of points
  193. c        in between.
  194. c
  195.     if ( abs(x2 - x1) .lt. dl ) then
  196.         vertcl    = .true.
  197.         dx    = (x2 - x1) / 30.0
  198.         dy    = (y2 - y1) / 30.0
  199.         if( abs(y2-y1) .lt. small ) hrzntl    = .true.
  200.     else
  201.         vertcl    = .false.
  202.         dx    = isign * dl
  203.         dy    = dl * (y2 - y1) / abs(x2 - x1)
  204.     endif
  205.     absdx    = abs( dx ) / 2.0 - small
  206.     absdy    = abs( dy ) / 2.0 - small
  207.     m    = ifix(x1*dm+1.01)
  208. c
  209. 10    continue
  210.         if ( abv ) then
  211. c
  212. c            if hitting the boundary while approaching from above 
  213. c            draw the line up to there.
  214. c
  215.         if ( y1 .lt. above(m) ) then
  216.             if( print ) write(6,*)"        hit from above draw ",
  217.      $                            "to x1,y1",x1,y1
  218.             call plot(xpos,ypos,3)
  219.             call plot(x1,y1,2)
  220.             abv    = .false.
  221.             if( y1 .le. below(m) ) then
  222. c                  when no axis both flags are true in the begining
  223.                 blw = .true.
  224.                 if( blw ) below(m) = y1
  225.             endif
  226.         endif
  227. c
  228. c            if hitting the boundary while approaching from above 
  229. c            draw the line up to there.
  230. c
  231.         elseif( .not. blw ) then
  232.         if( y1 .ge. above(m) ) then
  233.             if( print ) write(6,*)"        hit abv fr mid dr ",
  234.      $                            "fr x1,y1",x1,y1
  235.             xpos = x1
  236.             ypos = y1
  237.             abv    = .true.
  238.         endif
  239.         if( y1 .le. below(m) ) then
  240.             if( print ) write(6,*)"        hit blw fr mid dr ",
  241.      $                            "fr x1,y1",x1,y1
  242.             xpos = x1
  243.             ypos = y1
  244.             blw    = .true.
  245.         endif
  246. c                    on the bottom 
  247.         else
  248.         if ( y1 .gt. below(m) ) then
  249.             call plot(xpos,ypos,3)
  250.             call plot(x1,y1,2)
  251.             if( print ) write(6,*)"        hit from below ", 
  252.      $                        "draw to x1,y1",x1,y1
  253.             blw    = .false.
  254.             if( y1 .ge. above(m) ) abv = .true.
  255.         endif
  256.         endif
  257. c        if line is vertical, the hiding limits have been or will 
  258. c        be set by other segments below or above this segment,
  259. c        unless it hits a line in the middle.
  260.         if( .not. vertcl ) then
  261.         if( y1 .gt. above(m) ) then
  262.             above(m) = y1
  263.             abv    = .true.        
  264.         endif
  265.         if( y1 .lt. below(m) ) then
  266.             below(m) = y1
  267.             blw    = .true.
  268.         endif
  269.         m = m  +  isign
  270.         if( m .lt. 1 .or. m .gt. maxstp ) then
  271.             write(6,*)"exceeded the hiding boundary in draw.f"
  272.             write(6,*)"draw(",x1,",",y1,",",x2,",",y2,")"
  273.             stop
  274.         endif
  275.         endif
  276. c        JUST ADDED FOR TEST
  277.         if( .not. vertcl ) x1 = x1 + dx
  278.         y1 = y1 + dy
  279. c        if( vertcl ) then
  280. c        if( y1 .gt. above(m) ) then
  281. c            above(m) = y1
  282. c        endif
  283. c        if( y1 .lt. below(m) ) then
  284. c            below(m) = y1
  285. c        endif
  286. c        endif
  287. c            if the line is vertical, compare the y components
  288.         if( vertcl ) then
  289.         if( .not. hrzntl .and. abs(y2-y1) .gt. absdy ) go to 10
  290.         elseif( abs(x2 - x1) .gt. absdx ) then
  291.         go to 10
  292.         endif
  293. c
  294.     if (abv .or. blw ) then
  295.         if( print ) write(6,*)"        at end, draw to x1,y1",x2,y2
  296.         call plot(xpos,ypos,3)
  297.         call plot(x2,y2,2)
  298.     else
  299.         if( print ) write(6,*)"        at end, jump to x1,y1",x2,y2
  300.         xpos = x2
  301.         ypos = y2
  302.     endif
  303.     if( print ) then
  304.         if( abv ) write(6,*)"                exit above" 
  305.         if( blw ) write(6,*)"                exit below" 
  306.         if( .not. (abv .or. blw) ) then
  307.           write(6,*)"                    exit middle" 
  308.         endif
  309.     endif
  310.     return
  311.     end
  312. SHAR_EOF
  313. cat << \SHAR_EOF > newtru.f
  314. c
  315. c
  316. c    newtru - 3 dimentional plotting routine 
  317. c
  318. c    The CRC Graphics Package
  319. c
  320. c    An old routine rewritten by Mani Azimi
  321. c    12/9/83
  322. c
  323. c    This routine has been available for a long period in EE Dept.
  324. c    Malcolm Slaney provided an interface for it (plot3d.c) and 
  325. c    added some options to it. The major modifications were getting 
  326. c    the lines below the horizon to be plotted, drawing axes for all 
  327. c    the three directions and correcting the bugs in the old 
  328. c    routine. For finding about the many options available see the 
  329. c    manual for plot3d.
  330. c
  331. c    
  332.     subroutine newtru(z,x,y,inx,iny,nxdim,aphi1,aphi2
  333.      $        ,xlen,ylen,azlen,ixbyte,iybyte,izbyte
  334.      $        ,ixdig,iydig,izdig,xtic,ytic,ztic,xlbl,ylbl,zlbl,tl,bl
  335.      $        ,scfac,ixdir,iydir,azmax,azmin,izmin,abase,ixaxis,iyaxis,izaxis
  336.      $        ,resol,iprnt)
  337.     parameter(maxstp=8000)
  338.     logical xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  339.     dimension absx(512),absy(512),xold(512),yold(512)
  340.     dimension above(maxstp),below(maxstp)
  341.     dimension z(nxdim,1),x(1),y(1)
  342.     real xymin(2),xymax(2),tic(3)
  343.     real xcorn(2,2),ycorn(2,2),xcindx(2,2),ycindx(2,2)
  344.     integer ibyte(3),idig(3),ixlbl(3)
  345.     character*80 lbl(3),xlbl,ylbl,zlbl,tl,bl
  346.     common /a/ phi1,phi2,cphi1,sphi1,cphi2,s1s2,c1s2,zfct,absxs
  347.     common /b/ above,below
  348.     common /c/ xymin,xymax,tic,ibyte,idig,ixlbl,base,zbmax,zbmin,pi
  349.     common /d/ zlen,nx,ny,numstp,dlmnsm,dm,dl,small
  350.     common /e/ istrt1,iend1,istep1,istrt2,iend2,istep2
  351.     common /f/ xold,yold,absx,absy
  352.     common /pos/ xpos,ypos
  353.     common /flag/ xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  354. c
  355.     print = .false.
  356.     if(iprnt .eq. 1) print = .true.
  357.     nx = inx
  358.     ny = iny
  359.     zlen = 6.0 * azlen / 8.0
  360.     base = abase
  361.     zbmax = azmax
  362.     zbmin = azmin
  363.     phi1 = aphi1
  364.     phi2 = aphi2
  365.     xaxs = .false.
  366.     yaxs = .false.
  367.     zaxs = .false.
  368.     if( ixaxis .eq. 1 ) xaxs = .true.
  369.     if( iyaxis .eq. 1 ) yaxs = .true.
  370.     if( izaxis .eq. 1 ) zaxs = .true.
  371.     xdir = .false.
  372.     ydir = .false.
  373.     if( ixdir .eq. 1 ) xdir = .true.
  374.     if( iydir .eq. 1 ) ydir = .true.
  375.     ibyte(1)    = ixbyte
  376.     ibyte(2)    = iybyte
  377.     ibyte(3)    = izbyte
  378.     tic(1)    = xtic
  379.     tic(2)    = ytic
  380.     tic(3)    = ztic
  381.     idig(1)    = ixdig
  382.     idig(2)    = iydig
  383.     idig(3)    = izdig
  384.     lbl(1)(1:80) = xlbl(1:80)
  385.     lbl(2)(1:80) = ylbl(1:80)
  386.     lbl(3)(1:80) = zlbl(1:80)
  387. c        number of steps for line hiding
  388.     numstp    = ifix(resol*float(maxstp)/4.0)
  389.     do 10 i=1 , 3
  390.         ixlbl(i)    = index(lbl(i),'\0') - 1
  391. 10    continue
  392.     ixtl    = index(tl,'\0') - 1
  393.     ixbl    = index(bl,'\0') - 1
  394.     small    = 1.0e-7
  395.     alarge    = 1.0e25
  396.     pi    = 3.1415926535897932384626433
  397.     dm    = 150.0 * resol
  398.     dl    = 1.0 / dm
  399.     dlmnsm    = dl - small
  400.     arg1    = phi1 * pi / 180.0
  401.     arg2    = phi2 * pi / 180.0
  402.     sphi1    = sin(arg1)
  403.     cphi1    = cos(arg1)
  404.     sphi2    = sin(arg2)
  405.     cphi2    = cos(arg2)
  406.     s1s2    = sphi1 * sphi2
  407.     c1s2    = cphi1 * sphi2
  408. c
  409. c   determine min and max values
  410. c
  411.     xymin(1) = x(nx+1)
  412.     xymax(1) = x(nx+2)
  413.     xymin(2) = y(ny+1)
  414.     xymax(2) = y(ny+2)
  415.     do 5 i=1 , 2
  416.         if ( xymin(i) .ge. xymax(i) ) then
  417.         a      = xymin(i)
  418.         xymin(i)   = xymax(i)
  419.         xymax(i)   = a
  420.         endif
  421. 5    continue
  422. c
  423. c
  424. c        set the distance between the vertical lines in the front panels
  425. c
  426.     idxvrt = nx / 8
  427.     if ( nx .lt. 16 ) idxvrt = 1
  428.     idyvrt = ny / 8 
  429.     if ( ny .lt. 16 ) idyvrt = 1
  430. c
  431. c        select the the coordinates of the front edge depending on
  432. c        the direction of line drawing either (istrt1,istrt2) or
  433. c        (istrt2,istrt1).
  434. c
  435.     istrt1 = 1
  436.     istep1 = 1
  437.     istrt2 = 1
  438.     istep2 = 1
  439.     if( ydir ) then
  440.         if( phi1 .ge. 0.0 ) then
  441.             istrt1 = nx
  442.             iend1  = 1
  443.             istep1 = -1
  444.             iend2 = ny
  445.         else
  446.             iend1  = nx
  447.             iend2 = ny
  448.         endif
  449.     else
  450.         if( phi1 .ge. 0.0 ) then
  451.             iend1 = ny
  452.             istrt2 = nx
  453.             iend2  = 1
  454.             istep2 = -1
  455.         else
  456.             iend1 = ny
  457.             iend2  = nx
  458.         endif
  459.     endif
  460. c
  461. c        set base to the min (max) of the values on the edges
  462. c        depending on whether phi2 is positive (negative)
  463. c
  464.     if( base .gt. alarge ) then
  465.         if( phi2 .ge. 0.0 ) then
  466.             do 60 i=istrt1 , iend1 , istep1
  467.                 if( ydir) then
  468.                     dumz    = z(i,istrt2)
  469.                 else
  470.                     dumz    = z(istrt2,i)
  471.                 endif
  472.                 if( dumz .lt. base ) base = dumz 
  473. 60            continue
  474.             do 70 i=istrt2 , iend2 , istep2
  475.                 if( ydir ) then
  476.                     dumz    = z(istrt1,i)
  477.                 else
  478.                     dumz    = z(i,istrt1)
  479.                 endif
  480.                 if( dumz .lt. base ) base = dumz 
  481. 70            continue
  482.         else
  483.             base = - base
  484.             do 61 i=istrt1 , iend1 , istep1
  485.                 if( ydir ) then
  486.                     dumz    = z(i,istrt2)
  487.                 else
  488.                     dumz    = z(istrt2,i)
  489.                 endif
  490.                 if( dumz .gt. base ) base = dumz 
  491. 61            continue
  492.             do 71 i=istrt2 , iend2 , istep2
  493.                 if( ydir ) then
  494.                     dumz    = z(i,istrt2)
  495.                 else
  496.                     dumz    = z(istrt2,i)
  497.                 endif
  498.                 if( dumz .gt. base ) base = dumz 
  499. 71            continue
  500.         endif
  501.     endif
  502. c
  503. c        if no max set, set it to the max of z()
  504. c        if no min set, set it to the min of (min z()) and base
  505. c
  506.     if( izmin .ne. 1) zbmin = amin1(zbmin,base)
  507. c
  508.     shrink = 0.65
  509.     xlen    = xlen * shrink
  510.     ylen    = ylen * shrink
  511.     zlen    = zlen * shrink
  512. c
  513. c        normalize the x and y arrays for plotting
  514. c
  515.     xfct    = xlen / ( xymax(1) - xymin(1) )
  516.     yfct    = ylen / ( xymax(2) - xymin(2) )
  517.     do 20 i=1 , nx
  518.         x(i)    = ( x(i) - xymin(1) ) * xfct
  519. 20    continue
  520.     do 30 i=1 , ny
  521.         y(i)    = ( y(i) - xymin(2) ) * yfct
  522. 30    continue
  523.     zfct    = zlen / ( zbmax - zbmin )
  524. c
  525. c        setup proper origin on plotting page
  526. c
  527.     dumfct    = cphi2 * zfct
  528.     xadd    = - s1s2 * ( x(nx) - x(1) ) / float(nx-1)
  529.     yadd    =   c1s2 * ( y(ny) - y(1) ) / float(ny-1)
  530.     dzmax    = -1.0e30
  531.     dzmin    = 1.0e30
  532.     dumx    = - x(1) * s1s2 
  533.     do 980 ix=1 , nx
  534.         dumy    = y(1) * c1s2 
  535.         do 981 iy=1 , ny
  536.         dum    = dumfct * z(ix,iy) + dumx + dumy
  537.         if( dum .gt. dzmax ) dzmax = dum
  538.         if( dum .lt. dzmin ) dzmin = dum
  539.         dumy    = dumy + yadd
  540. 981        continue
  541.         dumx    = dumx + xadd
  542. 980    continue
  543.     xsize = cphi1 * xlen + abs(sphi1) * ylen
  544.     call factor(scfac)
  545.     call plot( 5.0-xsize/2.0 + 0.35 , 0.0 , -3 )
  546.     height    = 0.2
  547.     call alpha
  548.     if( ixtl .gt. 0 ) then
  549.         call symbol(xlen*0.66666-(3.0/7.0*float(ixtl)*height), 
  550.      $            9.5-height*0.5,height,tl(1:ixtl),0.0)
  551.     endif
  552.     if( ixbl .gt. 0 ) then
  553.         call symbol(xlen*0.66666-(3.0/7.0*float(ixbl)*height),
  554.      $            0.85+height*0.5,height,bl(1:ixbl),0.0)
  555.     endif
  556.     call plot( 0.0 , 5.0-(dzmax+dzmin)/2.0+0.5 , -3 )
  557. c    call plot( 5.0-xsize/2.0 + 0.4 , 5.0-(dzmax+dzmin)/2.0+0.5 , -3 )
  558. c
  559. c        absxs is the x coordinate of the origin relative to the 
  560. c        plot coordinates. In this way all the x components are positive.
  561. c
  562.     if( phi1 .ge. 0.0 ) then
  563.         absxs    = 0.0
  564.     else
  565. c        absxs    = sphi1 * y(ny) 
  566.         absxs    = sphi1 * ylen
  567.     endif
  568. c
  569.     do 120 i=1 , numstp
  570.         below(i)  = 20.0
  571.         above(i)  = -20.0
  572. 120    continue  
  573. c
  574. c        draw axis and set the boundary of hiding limits.
  575. c
  576.     if( xaxs .or. yaxs .or. zaxs ) call setaxs(xlen,ylen,lbl)
  577. c
  578. c        draw the vertical lines on the front panel 
  579. c        while the lines are plotted (if x-y axes are to be drawn)
  580. c
  581.     if( xaxs .or. yaxs ) then
  582.         xcindx(1,1) = x(1)
  583.         ycindx(1,1) = y(1)
  584.         xcindx(1,2) = x(nx)
  585.         ycindx(1,2) = y(1)
  586.         if( phi1 .ge. 0.0 ) then
  587.             xcindx(2,1) = x(nx)
  588.             xcindx(2,2) = x(nx)
  589.         else
  590.             xcindx(2,1) = x(1)
  591.             xcindx(2,2) = x(1)
  592.         endif
  593.         ycindx(2,1) = y(1)
  594.         ycindx(2,2) = y(ny)
  595.         if( xaxs .or. yaxs .or. zaxs ) then
  596.             do 90 i=1 , 2
  597.             iflag = 3 
  598.             do 80 j=1 , 2
  599.                 xcorn(i,j) = xcal(xcindx(i,j) , ycindx(i,j)) 
  600.                 ycorn(i,j) = ycal(xcindx(i,j) , ycindx(i,j) , base)
  601.                 if( xaxs .or. yaxs ) then
  602.                     if( iflag .eq. 3 ) then
  603.                 xpos = xcorn(i,j)
  604.                 ypos = ycorn(i,j)
  605.                 else
  606.                 call plot(xpos,ypos,3)
  607.                 call plot(xcorn(i,j),ycorn(i,j),iflag)
  608.                 endif
  609.             endif
  610.             iflag = 2
  611. 80            continue
  612. 90            continue
  613.         endif
  614.         call panel(x,y,z,nxdim)
  615.     endif
  616. c
  617. c        setup the first row depending on the direction options,
  618. c        either in x direction or y direction. absx and absy are
  619. c        the absolute coordinate sizes for plotting.
  620. c
  621. c
  622. c        main loop
  623. c
  624.     do 500 index1=istrt1 , iend1 , istep1
  625. c
  626. c           calculate the line coordinates for next row
  627. c        if last row no need for next row calculations
  628. c
  629.         do 215 i=istrt2 , iend2 , istep2
  630.         if( ydir ) then
  631.             absx(i) = float( ifix( xcal(x(index1),y(i)) *dm))*dl
  632.             absy(i) = ycal( x(index1),y(i),z(index1,i) )
  633.         else
  634.             absx(i) = float( ifix( xcal(x(i),y(index1)) *dm))*dl
  635.             absy(i) = ycal( x(i),y(index1),z(i,index1) )
  636.         endif
  637. 215        continue
  638.         if( index1 .ne. istrt1 ) then
  639.             if( xdir .and. ydir ) then
  640.             do 230 index2=istrt2 , iend2 , istep2
  641.             call perpen(index2)
  642. 230            continue
  643.         else
  644.             call perpen(istrt2)
  645.         endif
  646.         endif
  647.         x2    = absx(istrt2)
  648.         y2    = absy(istrt2)
  649.         m    = x2 * dm + 1.01
  650. c
  651. c        set the line hiding flags for the first point of line.
  652. c
  653.         abv    = .false.
  654.         blw    = .false.
  655.         if( y2 .gt. above(m) ) abv    = .true.
  656.         if( y2 .lt. below(m) ) blw = .true.
  657. c
  658. c            loop for drawing one complete line  
  659. c
  660.         do 600 index2=istrt2 , iend2-istep2 , istep2
  661.         x1    = x2
  662.         y1    = y2
  663.         x2    = absx(index2+istep2)
  664.         y2    = absy(index2+istep2)
  665.         if( print ) then
  666.             if( abv ) write(6,*)"                above"
  667.             if( blw ) write(6,*)"                below"
  668.             write(6,*)"-long: x1,y1,x2,y2",x1,y1,x2,y2
  669.         endif
  670.         call draw(x1,y1,x2,y2)
  671. 600        continue
  672.         if( index1 .ne. istrt1 .and. .not. (xdir .and. ydir) ) then
  673.         call perpen(iend2)
  674.         endif
  675. c
  676. c            store the line just drawn
  677. c
  678.         do 210 i=istrt2 , iend2 , istep2
  679.         xold(i) = absx(i)
  680.         yold(i) = absy(i)
  681. 210        continue
  682. c
  683. c        end of main loop
  684. c
  685. 500    continue
  686.     return
  687.     end
  688. SHAR_EOF
  689. cat << \SHAR_EOF > setaxs.f
  690. c
  691. c        draw base, axes and label coordinates
  692. c
  693.     subroutine setaxs(xlen,ylen,lbl)
  694.     parameter(maxstp=8000)
  695.     real xcorn(2,2),ycorn(2,2),xymin(2),xymax(2),tic(3)
  696.     integer ibyte(3),idig(3),ixlbl(3)
  697.     real xcindx(2,2),ycindx(2,2)
  698.     dimension above(maxstp),below(maxstp)
  699.     logical xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  700.     character*80 lbl(3)
  701.     common /a/ phi1,phi2,cphi1,sphi1,cphi2,s1s2,c1s2,zfct,absxs
  702.     common /b/ above,below
  703.     common /c/ xymin,xymax,tic,ibyte,idig,ixlbl,base,zbmax,zbmin,pi
  704.     common /d/ zlen,nx,ny,numstp,dlmnsm,dm,dl,small
  705.     common /pos/ xpos,ypos
  706.     common /flag/ xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  707. c
  708. c        CHANGE *********------+++++++********-----
  709. c    xcindx(i,*) and ycindx(i,*) are indices of the x and y coordinates of
  710. c    the i th axis (i=1 is the x axis and i=2 is the y axis)
  711. c    xcindx(*,1(2)) is the x comp of the first (last) point of the axis.
  712. c    ycindx(*,1(2)) is the y comp of the first (last) point of the axis.
  713. c    The direction of the axes is preserved.
  714. c    The two axes considered are the ones in front of the object and
  715. c    are also used for axes drawing.
  716. c
  717. c    xcindx(1,1) = xymin(1)
  718. c    ycindx(1,1) = xymin(2)
  719. c    xcindx(1,2) = xymax(1)
  720. c    ycindx(1,2) = xymin(2)
  721. c    if( phi1 .ge. 0.0 ) then
  722. c        xcindx(2,1) = xymax(1)
  723. c        xcindx(2,2) = xymax(1)
  724. c    else
  725. c        xcindx(2,1) = xymin(1)
  726. c        xcindx(2,2) = xymin(1)
  727. c    endif
  728. c    ycindx(2,1) = xymin(2)
  729. c    ycindx(2,2) = xymax(2)
  730.     xcindx(1,1) = 0.0
  731.     ycindx(1,1) = 0.0
  732.     xcindx(1,2) = xlen
  733.     ycindx(1,2) = 0.0
  734.     if( phi1 .ge. 0.0 ) then
  735.         xcindx(2,1) = xlen
  736.         xcindx(2,2) = xlen
  737.     else
  738.         xcindx(2,1) = 0.0
  739.         xcindx(2,2) = 0.0
  740.     endif
  741.     ycindx(2,1) = 0.0
  742.     ycindx(2,2) = ylen
  743.     if( xaxs .or. yaxs .or. zaxs ) then
  744.         do 90 i=1 , 2
  745.         iflag = 3 
  746.         do 80 j=1 , 2
  747.             xcorn(i,j) = xcal( xcindx(i,j) , ycindx(i,j) ) 
  748.             ycorn(i,j) = ycal( xcindx(i,j) , ycindx(i,j) , base )
  749. 80        continue
  750. 90        continue
  751.     endif
  752.     if( zaxs ) then
  753.          zaxisl    = cphi2 * zlen
  754.         call axisv(tic(3),idig(3))
  755. c
  756. c        decide which edge should the z-axis be on.
  757. c
  758.         if( phi1 .ge. 0.0 ) then
  759.         ixzedg = 1
  760.         iyzedg = 1
  761.         else
  762.         ixzedg = 2
  763.         iyzedg = 2
  764.         endif
  765.         x1 = xcorn(ixzedg,iyzedg)
  766.         y1 = ycorn(ixzedg,iyzedg) 
  767. c        draw the z axis from the min of z to max of z
  768.         if( base .gt. zbmin ) then
  769.         y1 = y1 - cphi2 * zlen * ( base - zbmin ) / ( zbmax - zbmin ) 
  770.         endif
  771.         call plot(x1,y1,3)
  772.         iflag = 1
  773.         if( ibyte(3) .eq. 5 ) iflag = 0
  774.         call axis(x1,y1,lbl(3)(1:ixlbl(3)),1,zaxisl,amin1(base,zbmin),zbmax
  775.      $                                    ,iflag)
  776.     endif
  777.     if (xaxs .or. yaxs) then
  778.         istrt    = 1
  779.         iend    = 2
  780.         if( .not. xaxs ) istrt = 2
  781.         if( .not. yaxs ) iend = 1
  782. c
  783.         do 110 i=istrt , iend
  784.         call plot(xcorn(i,1),ycorn(i,1),3)
  785.         ang = atan2( ycorn(i,2)-ycorn(i,1) , xcorn(i,2)-xcorn(i,1) ) 
  786.         dumsz =sqrt( (xcorn(i,2)-xcorn(i,1))**2 
  787.      $                    + (ycorn(i,2)-ycorn(i,1)) **2 ) 
  788.         x1 = xcorn(i,1)
  789.         y1 = ycorn(i,1)
  790.         dummin = xymin(i)
  791.         dummax = xymax(i)
  792.         sznew = dumsz
  793. c                if numbers are integer
  794.         if( ibyte(i) .eq. 3 ) then
  795.             dis = dumsz / ( xymax(i) - xymin(i) )
  796.             disnum = tic(i) / dis
  797. c                do not have steps of less than 1
  798.             if( disnum .le. 1.0 ) then
  799.             tic(i) = dis - small / 10.0
  800.             else
  801. c                modify tic size to suit integer values
  802.             atic = float( ifix( disnum + small / 10.0 ) * dis )
  803.             if( abs(tic(i)-atic) .gt. small ) tic(i) = atic - small
  804.             endif
  805.             dum = dumsz * float(ifix(dumsz/tic(i))) / (dumsz/tic(i))
  806.             if( abs(dumsz-dum) .gt. small ) sznew = dum + small / 10.0
  807.         endif
  808. c                do not put the number at the point where
  809. c                the z axis is drawn
  810.         dum = 1.001 * ( dumsz - sznew ) / tic(i)
  811.         if( i .eq. ixzedg .and. dum .lt. 0.4 ) sznew = sznew - tic(i)
  812.         diff = dumsz - sznew
  813.         if( abs(diff) .gt. small ) then
  814.             if( i .eq. ixzedg .and. iyzedg .eq. 1 ) then
  815.                 dumx = x1
  816.                 dumy = y1
  817.                 x1 = x1 + diff * cos(ang)
  818.                 y1 = y1 + diff * sin(ang)
  819.                 dummin = dummin + (xymax(i)-xymin(i)) * diff / dumsz
  820.             else
  821.                 dumx = x1 + sznew * cos(ang)
  822.                 dumy = y1 + sznew * sin(ang)
  823.                 dummax = dummax - (xymax(i)-xymin(i)) * diff / dumsz
  824.             endif
  825.             call plot(dumx,dumy,3)
  826.             dumx = dumx + diff * cos(ang)
  827.             dumy = dumy + diff * sin(ang)
  828.             call plot(dumx,dumy,2)
  829.             dumsz = sznew
  830.         endif
  831.         idir = 1
  832.         if( i .eq. 2 .and. phi1 .lt. 0.0 ) idir = - idir 
  833.         if( phi2 .lt. 0.0 ) idir = - idir
  834.         iflag = 0
  835.         if( ibyte(i) .eq. 3 ) iflag = 1
  836.         call axisv(tic(i),idig(i))
  837.         call draxis(x1,y1,lbl(i)(1:ixlbl(i)),ang*180.0/pi,idir,dumsz
  838.      $            ,dummin,dummax,iflag)
  839. 110        continue
  840.         do 150 ii=1 , 2
  841.         do 130 jj=1 , 2
  842.             xcorn(ii,jj) = float( ifix ( xcal( xcindx(ii,jj) 
  843.      $                , ycindx(ii,jj) ) * dm ) ) * dl 
  844.             ycorn(ii,jj) =ycal(xcindx(ii,jj),ycindx(ii,jj),base )
  845. 130        continue
  846. c            the direction of the y axis is different for phi1 < 0
  847.         if( ii .eq. 2 .and. phi1 .lt. 0.0 ) then
  848.             y1 = ycorn(ii,2)
  849.             y2 = ycorn(ii,1)
  850.             x1 = xcorn(ii,2)
  851.             x2 = xcorn(ii,1)
  852.         else
  853.             y1 = ycorn(ii,1)
  854.             y2 = ycorn(ii,2)
  855.             x1 = xcorn(ii,1)
  856.             x2 = xcorn(ii,2)
  857.         endif
  858. c            set the hiding lines. Since axes is drawn, everything
  859. c            below(above) the axes should be hided when phi2 is
  860. c            positive(negative).
  861.         if( x1 .ne. x2 ) then
  862.             y21x21 = ( y2 - y1 ) / ( x2 - x1 )
  863.             m = x1 * dm + 1.01
  864.             xdum    = x1
  865. 140            continue
  866.                 dum    = y1 + (xdum - x1) * y21x21 
  867.                 if( phi2 .ge. 0.0 ) then 
  868.                     above(m) = dum 
  869.                     below(m) = -20.0
  870.                 else
  871.                     above(m) = 20.0 
  872.                     below(m) = dum 
  873.                 endif
  874.                 xdum    = xdum + dl
  875.                 m    = m + 1
  876.                 if( abs(xdum-x2) .gt. dl/2.0 ) go to 140
  877.         else
  878. c                if the axis is vertical, it is simple!
  879.             above(m) = amax1(y1,y2) 
  880.             below(m) = amin1(y1,y2) 
  881.         endif
  882. 150        continue
  883.     endif
  884.     return
  885.     end
  886. SHAR_EOF
  887. cat << \SHAR_EOF > subr.f
  888. c
  889. c    panel - draw the vertical lines on the front panels.
  890. c
  891.     subroutine panel(x,y,z,nxdim)
  892.     dimension z(nxdim,1),x(1),y(1)
  893.     logical xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  894.     real xymin(2),xymax(2),tic(3)
  895.     integer ibyte(3),idig(3),ixlbl(3)
  896.     common /c/ xymin,xymax,tic,ibyte,idig,ixlbl,base,zbmax,zbmin,pi
  897.     common /d/ zlen,nx,ny,numstp,dlmnsm,dm,dl,small
  898.     common /e/ istrt1,iend1,istep1,istrt2,iend2,istep2
  899.     common /flag/ xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  900. c
  901. c        set the distance between the vertical lines in the front panels
  902. c
  903.     idxvrt = nx / 8
  904.     if ( nx .lt. 16 ) idxvrt = 1
  905.     idyvrt = ny / 8 
  906.     if ( ny .lt. 16 ) idyvrt = 1
  907. c
  908. c        select the the coordinates of the front edge depending on
  909. c        the direction of line drawing either (istrt1,istrt2) or
  910. c        (istrt2,istrt1).
  911. c
  912.     if( ydir ) then
  913.         idel1 = idxvrt
  914.         idel2 = idyvrt
  915.     else
  916.         idel1 = idyvrt
  917.         idel2 = idxvrt
  918.     endif
  919. c
  920. c        setup the first row depending on the direction options,
  921. c        either in x direction or y direction. absx and absy are
  922. c        the absolute coordinate sizes for plotting.
  923. c
  924.     idel    = idel2 * istep2
  925.     ilimit    = istrt2 + ( ( iend2 - istrt2 ) / idel ) * idel
  926.     do 215 i=istrt2 , iend2 , idel2*istep2
  927.         if( ydir ) then
  928.             xdum = float( ifix( xcal(x(istrt1),y(i)) *dm))*dl
  929.             if( ydir ) then
  930.             ydum = ycal( x(istrt1),y(i),z(istrt1,i) )
  931.             else
  932.             ydum = ycal( x(istrt1),y(i),z(i,istrt1) )
  933.             endif
  934.             ybase = ycal( x(istrt1) , y(i) , base )
  935.         else
  936.             xdum = float( ifix( xcal(x(i),y(istrt1)) *dm))*dl
  937.             if( ydir ) then
  938.             ydum = ycal( x(i),y(istrt1),z(istrt1,i) )
  939.             else
  940.             ydum = ycal( x(i),y(istrt1),z(i,istrt1) )
  941.             endif
  942.             ybase = ycal( x(i) , y(istrt1) , base )
  943.         endif
  944.         if( print ) write(6,*)"x1,y1,iflag",xdum,ydum,"3"
  945.         call plot(xdum,ydum,3)
  946.         if( print ) write(6,*)"alng: x1,y1,iflag",xdum,ybase,"2"
  947.         call plot(xdum,ybase,2)
  948.         if( i .eq. ilimit .and. i .ne. iend2 ) i = iend2 - idel2*istep2
  949. 215    continue
  950.     idel    = idel1 * istep1
  951.     ilimit    = istrt1 + ( ( iend1 - istrt1 ) / idel ) * idel
  952.     do 216 i=istrt1 , iend1 , idel1*istep1
  953.         if( .not. ydir ) then
  954.             xdum = float( ifix( xcal(x(istrt2),y(i)) *dm))*dl
  955.             if( ydir ) then
  956.             ydum = ycal( x(istrt2),y(i),z(i,istrt2) )
  957.             else
  958.             ydum = ycal( x(istrt2),y(i),z(istrt2,i) )
  959.             endif
  960.             ybase = ycal( x(istrt2) , y(i) , base )
  961.         else
  962.             xdum = float( ifix( xcal(x(i),y(istrt2)) *dm))*dl
  963.             if( ydir ) then
  964.             ydum = ycal( x(i),y(istrt2),z(i,istrt2) )
  965.             else
  966.             ydum = ycal( x(i),y(istrt2),z(istrt2,i) )
  967.             endif
  968.             ybase = ycal( x(i) , y(istrt2) , base )
  969.         endif
  970.         if( print ) write(6,*)"x1,y1,iflag",xdum,ydum,"3"
  971.         call plot(xdum,ydum,3)
  972.         if( print ) write(6,*)"alng: x1,y1,iflag",xdum,ybase,"2"
  973.         call plot(xdum,ybase,2)
  974.         if( i .eq. ilimit .and. i .ne. iend1 ) i = iend1 - idel1*istep1
  975. 216    continue
  976.     return
  977.     end
  978. c
  979. c    xcal - calculate the absolute x coordinate of a point 
  980. c
  981.     real function xcal(x,y) 
  982.     common /a/ phi1,phi2,cphi1,sphi1,cphi2,s1s2,c1s2,zfct,absxs
  983.     xcal = cphi1 * x + sphi1 * y -absxs
  984.     end
  985. c    
  986. c    ycal - calculate the absolute y coordinate of a point 
  987. c
  988.     real function ycal(x,y,z) 
  989.     common /a/ phi1,phi2,cphi1,sphi1,cphi2,s1s2,c1s2,zfct,absxs
  990.     ycal = - s1s2 * x + c1s2 * y + cphi2 * z * zfct
  991.     end
  992. c
  993. c    perpen - draws the small lines between two adjacent stripes
  994. c
  995.     subroutine perpen(iprpn) 
  996.     parameter(maxstp=8000)
  997.     dimension above(maxstp),below(maxstp)
  998.     dimension absx(512),absy(512),xold(512),yold(512)
  999.     logical xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  1000.     common /b/ above,below
  1001.     common /d/ zlen,nx,ny,numstp,dlmnsm,dm,dl,small
  1002.     common /e/ istrt1,iend1,istep1,istrt2,iend2,istep2
  1003.     common /f/ xold,yold,absx,absy
  1004.     common /flag/ xaxs,yaxs,zaxs,abv,blw,xdir,ydir,print
  1005.     x1 = xold(iprpn)
  1006.     y1 = yold(iprpn)
  1007.     x2 = absx(iprpn)
  1008.     y2 = absy(iprpn)
  1009. c
  1010. c    set the line hiding flags.
  1011. c
  1012.     m    = x1 * dm + 1.01
  1013.     abv    = .false.
  1014.     blw    = .false.
  1015.     if( y1 .gt. above(m) ) abv    = .true.
  1016.     if( y1 .lt. below(m) ) blw = .true.
  1017.     if( print ) then
  1018.       if( abv ) write(6,*)"                above"
  1019.       if( blw ) write(6,*)"                below"
  1020.       write(6,*)"-fredg: x1,y1,x2,y2",x1,y1,x2,y2
  1021.     endif
  1022.     call draw(x1,y1,x2,y2)
  1023.     return
  1024.     end
  1025. SHAR_EOF
  1026. cat << \SHAR_EOF > test.f
  1027.     dimension x(4),y(4)
  1028.     x(1)=2.
  1029.     x(2)=6.
  1030.     x(3)=0.
  1031.     x(4)=10.
  1032.     y(1)=1.
  1033.     y(2)=9.
  1034.     y(3)=0.
  1035.     y(4)=10.
  1036.     call plots(3,1)
  1037.     call factor(.3)
  1038.     call symbol(2.,7.,.3,"$G Functions",0.)
  1039.     call plot(2.,2.,-3)
  1040.     call laxis(0.,0.,"$|$a*f(x)$ dx",0,6.,0,1,0)
  1041.     call laxis(0.,3.,"$|$a*f(x)$ dx",2,6.,0,1,0)
  1042.     call laxis(0.,0.,"This is a test",1,3.,0,1,3)
  1043.     call laxis(6.,0.,"This is a test",3,3.,0,1,3)
  1044.     call line(x,y,2,0,6.,3.)
  1045.     call plot(1.,1.,-3)
  1046.     call axis(0.,0.,"$|$a*f(x)$ dx",0,6.,0.,10.,0)
  1047.     call axis(0.,3.,"$|$a*f(x)$ dx",2,6.,0.,10.,0)
  1048.     call axis(0.,0.,"This is a test",1,3.,0.,10.,3)
  1049.     call axis(6.,0.,"This is a test",3,3.,0.,10.,3)
  1050.     call newpen(3)
  1051.     call dline(x,y,2,.2,.2,1,6.,3.)
  1052.     call plot(0.,0.,999)
  1053.     stop
  1054.     end
  1055. SHAR_EOF
  1056. cat << \SHAR_EOF > axis.c
  1057. #include    "crc.h"
  1058. /*
  1059.     axis - interface to 'draxis'
  1060.  
  1061.     The CRC graphics package
  1062.  
  1063. */
  1064.  
  1065. axis(x,y,label,xy,size,xmin,xmax,idata)
  1066. float    x,y,size,xmin,xmax;
  1067. int    xy,idata;
  1068. char    *label;
  1069. {
  1070.     float angle;
  1071.     int xydum;
  1072.     angle = 0.0;
  1073.     xydum = 1;
  1074.     switch(xy){
  1075.         case 0:
  1076.             break;
  1077.         case 1:
  1078.             angle = 90.0;
  1079.             xydum = -1;
  1080.             break;
  1081.         case 2:
  1082.             xydum = -1;
  1083.             break;
  1084.         case 3:
  1085.             angle = 90.0;
  1086.             break;
  1087.     }    
  1088.     draxis(x,y,label,angle,xydum,size,xmin,xmax,idata);
  1089. }
  1090. SHAR_EOF
  1091. cat << \SHAR_EOF > axis_.c
  1092. /*
  1093.     axis_ - F77 interface to 'axis'
  1094.  
  1095.     The CRC graphics package
  1096.  
  1097.     Carl Crawford 
  1098.     Purdue University
  1099.     West Lafayette, IN 47901
  1100.  
  1101.     October 1981
  1102. */
  1103.  
  1104. #include    "crc.h"
  1105.  
  1106. axis_(x,y,label,xy,size,min,max,flag,labell)
  1107. float    *x;
  1108. float    *y;
  1109. char    *label;
  1110. long int    *xy;
  1111. float    *size;
  1112. float    *min;
  1113. float    *max;
  1114. long    int    *flag;
  1115. long    int    labell;
  1116. {
  1117.     axis(*x,*y,label,(int)*xy,*size,*min,*max,(int)*flag);
  1118. }
  1119. SHAR_EOF
  1120. cat << \SHAR_EOF > axisv_.c
  1121. #include    "crc.h"
  1122.  
  1123. /*
  1124.     axisv_ - f77 callable version of 'axisv'
  1125.  
  1126.     The CRC graphics package
  1127.  
  1128.     carl crawford
  1129.     purdue university
  1130.     west lafayette, indiana 47907
  1131.  
  1132.     april 1980
  1133. */
  1134.  
  1135. axisv_(ticdis,digits)
  1136. float    *ticdis;
  1137. long    int    *digits;
  1138. {
  1139.     axisv(*ticdis,(int) *digits);
  1140. }
  1141. SHAR_EOF
  1142. cat << \SHAR_EOF > crclabel.c
  1143. /*
  1144.   
  1145.       crclabel - program to label vectors
  1146.   
  1147.     The CRC graphics package
  1148.  
  1149.     Malcolm Slaney
  1150.       Purdue University
  1151.       W. Lafayette, Indiana
  1152.   
  1153.         compile with "cc -O crclabel.c -i -lG -lm"
  1154. */
  1155.  
  1156. #include    <stdio.h>
  1157. #include    <math.h>
  1158.  
  1159. #define    DevNum(Major,Minor)    ((Major) + (Minor)*8)
  1160.  
  1161. #define    BIT    0    /* major device table */
  1162. #define GOV    1
  1163. #define IMAGE    2
  1164. #define    GGOV    3
  1165. #define    GIMAGE    4
  1166. #define    TEK    6
  1167. #define HP    7
  1168.  
  1169. #define    STDOUT        0    /* Special Device Numbers */
  1170. #define    VERSATEC    8
  1171. #define    PRINTRONIX    16
  1172. #define    RETRO        14
  1173.  
  1174. float   scfac  = 1.0;   /* scale factor in plot */
  1175. float    xxs,yys;    /* starting locations for the graph */
  1176. int    spd = 36;    /* speed of hp plotter */
  1177. char    *tl;        /* top label */
  1178. char    *stfl;
  1179. char    *host;        /* host overide for all pipes */
  1180. float    height = 0.2;    /* character heights */
  1181. int     pen   = 1;      /* hp pen color */
  1182. char    *siten = "pl";  /* default site for gplp */
  1183. int    blank;        /* blank flag */
  1184. int     devn;           /* minor device number */
  1185. int     dev = PRINTRONIX;/* major device number */
  1186.  
  1187. int     size[] = {
  1188.         sizeof(char),   /* signed char */
  1189.         sizeof(char),   /* unsigned char */
  1190.         sizeof(short),  /* short integer */
  1191.         sizeof(int),    /* integer */
  1192.         sizeof(long),   /* long integer */
  1193.         sizeof(float),  /* float */
  1194.         sizeof(double), /* double */
  1195.     };
  1196.  
  1197. #define INT     0
  1198. #define FLOAT   1
  1199. #define LONG    2
  1200. #define CHAR    3
  1201.  
  1202. struct hash  {
  1203.     char    *label;
  1204.     int     type;
  1205.     char    **pointer;
  1206.     } table[] = {
  1207. /* 1 */         {"xp",FLOAT,(char **)&xxs},
  1208. /* 2 */        {"yp",FLOAT,(char **)&yys},
  1209. /* 3 */        {"pen",INT,(char **)&pen},
  1210. /* 4 */        {"scfac",FLOAT,(char **)&scfac},
  1211. /* 5 */        {"site",CHAR,&siten},
  1212. /* 6 */        {"speed",INT,(char **)&spd},
  1213. /* 7 */        {"tl",CHAR,&tl},
  1214. /* 8 */        {"op",CHAR,&host},
  1215. /* 9 */         {"g",CHAR,&stfl},
  1216.         {0,0,0}
  1217.     };
  1218.  
  1219. main(argc,argv)
  1220.     int    argc;
  1221.     char    **argv;
  1222. {
  1223.     FILE    *fd;
  1224.     float   xd[514],yd[514];
  1225.     int    cx,cy;
  1226.     long    atol();
  1227.     float    max(),min();
  1228.     register int    i,j;
  1229.     float    dx,xtmp,ytmp,sftmp;
  1230.     char    buf[10];
  1231.  
  1232.     if((fd = fopen("/etc/cpu","r")) != NULL){
  1233.         fgets(buf,10,fd);
  1234.         buf[strlen(buf) -1] = 0;
  1235.         if(strcmp(buf,"arpa") == 0)
  1236.             dev = DevNum(GOV,0);
  1237.         fclose(fd);
  1238.     }
  1239.     file();
  1240.     args();
  1241.     parse(argc,argv);
  1242.     
  1243.     if(dev == DevNum(GOV,0) || dev == DevNum(IMAGE,0) ||
  1244.         dev == DevNum(GGOV,0) || dev == DevNum(GIMAGE,0)){
  1245.         if(devn){
  1246.             devn -= '0';
  1247.             if(dev == DevNum(IMAGE,0) || dev == DevNum(GIMAGE,0))
  1248.                 devn += 1;
  1249.         }
  1250.         dev |= devn << 3;
  1251.     }
  1252.     strcpy(buf,"-");
  1253.     strcat(buf,siten);
  1254.     site(buf);
  1255.     fname(stfl);
  1256.     if(host)
  1257.         dev |= 0100;
  1258.     plots(dev,blank,host);
  1259.     newpen(pen);
  1260.     speed(spd);
  1261.     plot(xxs,yys,-3);
  1262.     factor(scfac);
  1263.     if(tl){        /* top label */
  1264.         symbol(0.0,0.0,height,tl,0.0);
  1265.     }
  1266.     plot(0.0,0.0,999);
  1267. }
  1268.  
  1269. err(s1,s2)
  1270.     char    *s1,*s2;
  1271. {
  1272.     fprintf(stderr,"%s%s\n",s1,s2);
  1273.     exit(1);
  1274. }
  1275.  
  1276. comm(s)
  1277.     char    *s;
  1278. {
  1279.     register    int    j,r;
  1280.     char    *p;
  1281.     struct hash *hp;
  1282.  
  1283.  
  1284.     for(hp=table;hp->label;hp++){
  1285.         for(j=0;(r=hp->label[j]) == s[j] && r;j++);
  1286.         if(r == 0 && s[j] == '=')
  1287.             if(!s[j+1]){
  1288.                 s[j] = 0;
  1289.                 err("empty string: ",s);
  1290.             }else{
  1291.                 switch(hp->type){
  1292.  
  1293.                 case CHAR:
  1294.                     *hp->pointer = s + j + 1;
  1295.                     break;
  1296.                 case INT:
  1297.                     *((int *)hp->pointer) = atoi(s+j+1);
  1298.                     break;
  1299.                 case FLOAT:
  1300.                     *((float *)hp->pointer) = atof(s+j+1);
  1301.                     break;
  1302.                 case LONG:
  1303.                     *((long *)hp->pointer) = atol(s+j+1);
  1304.                     break;
  1305.                 }
  1306.                 return(hp - table + 1);
  1307.             }
  1308.     }
  1309.     p = s;
  1310.     while(*p){
  1311.         if(*p == '='){
  1312.             *p = 0;
  1313.             break;
  1314.         }
  1315.         p++;
  1316.     }
  1317.     err("bad option: ",s);
  1318. }
  1319.  
  1320.  
  1321. parse(argc,argv)
  1322.     int    argc;
  1323.     char    **argv;
  1324. {
  1325.     char    c;
  1326.     int     i;
  1327.  
  1328.     while(argv++ , --argc){
  1329.         if(argv[0][0] == '-')while(c = *++*argv)switch(c){
  1330.  
  1331.             case '0':    /* device # */
  1332.             case '1':
  1333.             case '2':
  1334.             case '3':       /* grinell */
  1335.             case '4':
  1336.                 devn = c;
  1337.                 break;
  1338.             case 'G':
  1339.                 if (dev == IMAGE || dev == GIMAGE)
  1340.                     dev = GIMAGE;
  1341.                 else
  1342.                     dev = GGOV;
  1343.                 break;
  1344.             case 'g':    /* use graphics overlay */
  1345.                 if (dev == GGOV || dev == GIMAGE)
  1346.                     dev = GGOV;
  1347.                 else
  1348.                     dev = GOV;
  1349.                 break;
  1350.             case 'i':    /* use Image Plane */
  1351.                 if (dev == GGOV || dev == GIMAGE)
  1352.                     dev = GIMAGE;
  1353.                 else
  1354.                     dev = IMAGE;
  1355.                 break;
  1356.             case 'c':    /* use comtal */
  1357.                 if (dev == GOV || dev == GGOV)
  1358.                     dev = GOV;
  1359.                 else
  1360.                     dev = IMAGE;
  1361.                 break;
  1362.             case 'b':    /* don't blank display */
  1363.                 blank = 1;
  1364.                 break;
  1365.             case 'B':    /* blank display */
  1366.                 blank = 0;
  1367.                 break;
  1368.             case 't':    /* use tektronix */
  1369.                 dev = TEK;
  1370.                 break;
  1371.             case 'T':    /* use Retro-graphics */
  1372.                 dev = RETRO;
  1373.                 break;
  1374.             case 'h':    /* use hp plotter */
  1375.                 dev = HP;
  1376.                 break;
  1377.             case 'o':       /* g=stdout */
  1378.                 dev = STDOUT;
  1379.                 stfl = "-";
  1380.                 break;
  1381.             case 'v':       /* direct versatec mode */
  1382.                 dev = VERSATEC;
  1383.                 break;
  1384.             case 'p':       /* direct line printer mode */
  1385.                 dev = PRINTRONIX;
  1386.                 break;
  1387.             default:
  1388.                 fprintf(stderr,"bad flag: -%c\n",c);
  1389.                 exit(1);
  1390.             }
  1391.         else
  1392.             switch(i = comm(*argv)){
  1393.  
  1394.             case 9:    /* output file name */
  1395.                 dev = STDOUT;
  1396.                  break;
  1397.             case 3:        /* pen */
  1398.             case 6:        /* speed */
  1399.                 dev = HP;
  1400.                 break;
  1401.             case 5:            /* site */
  1402.                 dev = PRINTRONIX;
  1403.                 break;
  1404.             }
  1405.     }
  1406. }
  1407.  
  1408. args()
  1409. {
  1410.     char    *argv[20];
  1411.     int    argc;
  1412.     char    *s,*getenv(),*p;
  1413.  
  1414.     if((s=getenv("CRCLABELARGS")) == NULL)return;
  1415.  
  1416.     argv[0] = s;
  1417.     argc = 1;
  1418.     while(*s){
  1419.         while(*s == ' ')*s++ = 0;
  1420.         if(*s){
  1421.             if(*s != '"')argv[argc++] = s;
  1422.             else{
  1423.                 argv[argc++] = ++s;
  1424.                 while(*s){
  1425.                     if(*s != '"')s++;
  1426.                     else{
  1427.                         *s++ = 0;
  1428.                         break;
  1429.                     }
  1430.                 }
  1431.             }
  1432.         }
  1433.         while( (*s != ' ')  && *s){
  1434.             if(*s != '"')s++;
  1435.             else{
  1436.                 p = s;
  1437.                 while(*p){
  1438.                     *p = *(p+1);
  1439.                     p++;
  1440.                 }
  1441.                 while(*s){
  1442.                     if(*s != '"')s++;
  1443.                     else{
  1444.                         *s++ = 0;
  1445.                         break;
  1446.                     }
  1447.                 }
  1448.             }
  1449.         }
  1450.     }
  1451.     parse(argc,argv);
  1452. }
  1453.  
  1454. file()
  1455. {
  1456.     int    argc;
  1457.     char    *argv[20];
  1458.     static char buf[256];
  1459.     char    *b;
  1460.     char    *getenv(),*s;
  1461.     FILE    *dfd;
  1462.  
  1463.     if((s = getenv("HOME")) == NULL)return;
  1464.     strcpy(buf,s);
  1465.     strcat(buf,"/.crclabelargs");
  1466.     if((dfd = fopen(buf,"r")) == NULL)return;
  1467.     argc = 1;
  1468.     b = buf;
  1469.     while(fgets(b,256-((int)(b - buf)),dfd) != NULL){
  1470.         b[strlen(b)-1] = 0;
  1471.         argv[argc++] = b;
  1472.         b += strlen(b)+1;
  1473.         if(argc == 20)break;
  1474.     }
  1475.     parse(argc,argv);
  1476.     fclose(dfd);
  1477. }
  1478.  
  1479. SHAR_EOF
  1480. cat << \SHAR_EOF > draxis.c
  1481. #include    "crc.h"
  1482.  
  1483. /*
  1484.     draxis - draw numerically annotated axes for slant axes
  1485.  
  1486.     The CRC graphics package
  1487.  
  1488.     carl crawford
  1489.     purdue univeristy
  1490.     w. lafayette, in 47907
  1491.  
  1492.     may 1980
  1493. */
  1494. #define    PI    3.141592
  1495. #define SMALL    0.00000000001
  1496.  
  1497. draxis(x,y,label,angle,xy,size,xmin,xmax,idata)
  1498. /*        xy    =    1    clockwise
  1499.             =    -1    counter clockwise */
  1500. float    x,y,angle,size,xmin,xmax;
  1501. int    xy,idata;
  1502. char    *label;
  1503. {
  1504.     float    xt,yt,half,dumang,sang,cang;
  1505.     float    height,del,delx,dely,dticx,dticy;
  1506.     int    numt,i,j;
  1507.     int     n1,n2,fl,atic;
  1508.     char    *b,*c;
  1509.  
  1510.     angle = angle*PI/180.0;
  1511.     sang = sin(angle);
  1512.     cang = cos(angle);
  1513.     atic = 1;
  1514.     plot(x,y,3);
  1515.     height = HEIGHT;
  1516.     plot(x+size*cang,y+size*sang,2);
  1517.     if(TICDIS == 0.0)_err("axis error: ","ticdis zero");
  1518.     numt = floor(size/TICDIS+.5); 
  1519.     if(!numt) 
  1520.         numt = -1;
  1521.     plot(x,y,3);
  1522.     xt = x;    
  1523.     yt = y;
  1524.     dticx = 0.075*atic*cos(angle-xy*PI/2.0);
  1525.     dticy = 0.075*atic*sin(angle-xy*PI/2.0);
  1526.     del =  ( xmax - xmin ) / numt;
  1527.     delx = size*cang/numt;
  1528.     dely = size*sang/numt;
  1529.     numt++;
  1530.     for(i = 0;i<numt;i++){
  1531.         plot(xt+dticx,yt+dticy,2);
  1532.         xt += delx;
  1533.         yt += dely;
  1534.         plot(xt,yt,3);
  1535.     }
  1536.     if(idata >= 0)n1 = _axisl(xmin,xmax,idata,1);
  1537.  
  1538.     c = label;
  1539.     b = _abuf;
  1540. #ifdef sel
  1541.     strncpy(b, c, sizeof(_abuf));
  1542.     while(*b++ != NULL);
  1543. #else
  1544.     while(*b++ = *c++);
  1545. #endif
  1546.     if(n1 && idata >= 0){
  1547.         --b;
  1548.         *b++ = ' ';
  1549.         *b++ = '(';
  1550.         *b++ = 'X';
  1551.         *b++ = '1';
  1552.         *b++ = '0';
  1553.         *b++ = '$';
  1554.         *b++ = '{';
  1555.         if(n1 < 0){
  1556.             *b++ = '-';
  1557.             n1 = -n1;
  1558.         }
  1559.         if(n1 > 9){
  1560.             *b++ = '0' + (n1/10);
  1561.             n2 = n1/10;
  1562.             n1 -= n2*10;
  1563.         }
  1564.         *b++ = '0' + n1;
  1565.         *b++ = '$';
  1566.         *b++ = '}';
  1567.         *b++ = ')';
  1568.         *b = 0;
  1569.     }
  1570.     half = 6.0/7.0 * _ssize(_abuf) / 2.0 * height;
  1571.     dticx = 1.1*atic*cos(angle-xy*PI/2.0) + ( size/2.0-half ) * cang;
  1572.     dticy = 1.1*atic*sin(angle-xy*PI/2.0) + ( size/2.0-half ) * sang;
  1573.     if( fabs(angle-PI/2) < SMALL )
  1574.         symbol(x+(xy*atic * 1.2),y+(size/2.0) - half,height,_abuf,90.0);
  1575.     else if( fabs(angle) < SMALL ) 
  1576.         symbol(x+(size/2.0)-half,y-(xy*atic * .75),height,_abuf,0.0);
  1577.     else if( fabs(angle) <= PI/2.0 ){ 
  1578.       symbol(x+dticx,y+dticy,height,_abuf,angle*180.0/PI);
  1579.     }
  1580.     else{ 
  1581.       dumang = angle - PI;
  1582.       if( dumang < -PI)
  1583.         dumang += 2.0*PI;
  1584.       dticx += 2.0 * half * cang;
  1585.       dticy += 2.0 * half * sang;
  1586.       symbol(x+dticx,y+dticy,height,_abuf,dumang*180.0/PI);
  1587.     }
  1588.     if( idata < 0)return;
  1589.     height *= 2.8/4.0;
  1590.     plot(x,y,3);
  1591.     xt = x;    
  1592.     yt = y;
  1593.     for(i = 0; i <numt; i++){
  1594.         half = height * (6.0/7.0) * _axisl(xmin,del,idata,0);
  1595.         if( fabs(angle-PI/2) < SMALL )
  1596.         symbol(xt+xy*atic*(((xy<0)*half)+0.145),yt -(height/2.0),height,_abuf,0.0);
  1597.         else if( fabs(angle) < SMALL ) 
  1598.         symbol(xt-(half/2.0),yt-(xy*atic*(0.145 + height)),height,_abuf,0.0);
  1599.         else if( xy*angle > SMALL ) 
  1600.         symbol(xt+0.6*height+height*fabs(cang),yt-1.5*xy*height*cang,height,_abuf,0.0);
  1601.         else 
  1602.         symbol(xt-0.6*height-height*fabs(cang)-half,yt-xy*height*cang,height,_abuf,0.0);
  1603.         xmin += del;
  1604.         xt += delx;
  1605.         yt += dely;
  1606.     }
  1607. }
  1608.  
  1609. _axisl(a,b,iflag,opt)
  1610. float    a,b;
  1611. int    iflag,opt;
  1612. {
  1613.     double    d;
  1614.     double c;
  1615.     int    minus,dc,si,i;
  1616.     static    int    n,efl;
  1617.     int    n1,n2,n3;
  1618.     char    *ecvt(),*bu,*bb;
  1619.  
  1620.     if(opt){
  1621.         c = b - a;
  1622.         ecvt(fabs(a),DIGITS,&n1,&si);
  1623.         ecvt(fabs(b),DIGITS,&n2,&si);
  1624.         ecvt(fabs(c),DIGITS,&n3,&si);
  1625.         if(iabs(n1-n2) <= 1) n = (n1 > n2)? n1 : n2;
  1626.         else    if(iabs(n1-n3) <= 1) n = n3;
  1627.         else    if(iabs(n2-n3) <= 1) n = n2;
  1628.         efl = 0;
  1629.         if(n <= -2 || n >= (DIGITS + iflag)){
  1630.             efl = 1;
  1631.         }
  1632.         return(efl ? n-1 : 0);
  1633.     }
  1634.     else{
  1635.         if(iflag)d = floor(a + 0.5);
  1636.         else    d = a;
  1637.         minus = 0;
  1638.         if(d < 0){
  1639.             d = -d;
  1640.             minus = 1;
  1641.         }
  1642.         bu = ecvt(d,DIGITS,&dc,&si);
  1643.         if(d == 0.0)dc++;
  1644.         if(efl)dc -= n - 1;
  1645.         if(iflag && efl == 0){
  1646.             bu[dc] = 0;
  1647.             bb = _abuf;
  1648.             if(minus)*bb++ = '-';
  1649.             while( *bb++ = *bu++);
  1650.         }
  1651.         else{
  1652.             bb = _abuf;
  1653.             if(minus)*bb++ = '-';
  1654.             if(dc <= 0){
  1655.                 *bb++ = '.';
  1656.                 while(dc++)*bb++ = '0';
  1657.                 while(*bb++ = *bu++);
  1658.                 _abuf[DIGITS+1+minus] = 0;
  1659.             }
  1660.             else{
  1661.                 while(dc--)*bb++ = *bu++;
  1662.                 *bb++ = '.';
  1663.                 while(*bb++ = *bu++);
  1664.             }
  1665.         }
  1666.         return(_ssize(_abuf));
  1667.     }
  1668. }
  1669.  
  1670. iabs(i)
  1671. int    i;
  1672. {
  1673.     return((i>0)? i : -i);
  1674. }
  1675. SHAR_EOF
  1676. cat << \SHAR_EOF > genfont.c
  1677. /*
  1678.     genfont - generate character font files
  1679.  
  1680.     The CRC graphics package
  1681.  
  1682.     Carl Crawford 
  1683.     Purdue University
  1684.     W. Lafayette, IN 47907
  1685.  
  1686.     October 1981
  1687. */
  1688.  
  1689. /*
  1690.      The file generated by 'genfont' has the following format:
  1691.  
  1692. short  height     Default character height.
  1693. short  size       Bytes of core required to hold coordinates.
  1694. short  pnt[256]   Indexes to 1st coordinate of each symbol.
  1695. short  crd[size]  Coordinates of symbols
  1696.  
  1697. Where each crd[i] has the following format:
  1698.  
  1699.   EVSXXXXXXSYYYYYY   (a 'short' is assumed to be 16 bits)
  1700.   III     IIIIIIII
  1701.   III     I   I----- Y coordinate (sign magnitude format)
  1702.   IIIIIIIII
  1703.   II   I----- X coordinate (sign magnitude format)
  1704.   II----- Line segment visible flag (0=invisible, 1=visible)
  1705.   I----- 1=more coordinates; 0=last coordinate
  1706.  
  1707.  
  1708.   The file used as input to 'genfont' as the following format:
  1709.  
  1710.   \n/x0,y0,v0/x1,y1,v2/.../xm,ym,vm<cr>
  1711.   .
  1712.   .
  1713.   .
  1714.  
  1715.   where:
  1716.       'n' is the character in octal.
  1717.       xi, i=1,2,..m is the x coordinate of the i'th segment
  1718.       yi, i=1,2,..m is the x coordinate of the i'th segment
  1719.       vi, i=1,2,..m is the visible indicator of the i'th segment
  1720.         v = 0 => invisible
  1721.           = 1 => visible
  1722.  
  1723. */
  1724.  
  1725. #include <stdio.h>
  1726.  
  1727. FILE    *fd;        /* output file descriptor */
  1728. FILE    *ifd;        /* input file descriptor */
  1729. char    j[512];        /* input character buffer */
  1730. int    i1;        /* general integer */
  1731. int    i3;        /* position within file */
  1732. int    k1;        /* x position */
  1733. int    k2;        /* y position */
  1734. int    k3;        /* visib flag */
  1735. short    l;        /* formed coordinate */
  1736. int    n;        /* character number */
  1737. struct{            /* header structure */
  1738.     short  height;
  1739.     short  coordsz;
  1740.     short  pntr1st[256];
  1741. }fontcom;
  1742.  
  1743. main(argc, argv)
  1744.     int  argc;
  1745.     char  **argv;
  1746. {
  1747.  
  1748.     if(argc != 3)synerr();
  1749.     if((fd = fopen(argv[1],"w")) == NULL)err("can't create ",argv[1]);
  1750.     if(strcmp(argv[1],argv[2])==0){
  1751.         err("output and input files have the same name","");
  1752.     }
  1753.     if((ifd = fopen(argv[2],"r"))==NULL)err("can't open: ",argv[2]);
  1754.     for (i1=0; i1<256; i1++)fontcom.pntr1st[i1] = -1;
  1755.  
  1756.     /* get height of font */
  1757.  
  1758.     if(gread())err("can't read height","");
  1759.     fontcom.height = atoi(j);
  1760.  
  1761.     /* save space for header */
  1762.  
  1763.     fseek(fd,(long)sizeof(fontcom),0);
  1764.     
  1765.     /* loop through all the entries */
  1766.  
  1767.     while(!gread()){
  1768.         if (*j == '\\') {
  1769.             n = atoi(j+1);
  1770.             n = (n/100*64) + (((n/10)%10)*8) + n%10;
  1771.             if (n<0 || n>255)err("invalid character number ",j+1);
  1772.             fontcom.pntr1st[n] = i3;
  1773.  
  1774.             /* terminate previous character */
  1775.  
  1776.             fseek(fd,-(long)sizeof(l),1);
  1777.             l |= 0100000;
  1778.             fwrite(&l,sizeof(l),1,fd);
  1779.         }else{
  1780.             k1 = atoi(j);
  1781.             if(gread())err("incomplete coordinate specified","");
  1782.             k2 = atoi(j);
  1783.             if(gread())err("incomplete coordinate specified","");
  1784.             k3 = atoi(j)&&01;
  1785.             l = (k3<<14) | ((abs(k1)%128)<<7) | (abs(k2)%128);
  1786.             if(k1 < 0)l |= 0020000;
  1787.             if(k2 < 0)l |= 0100;
  1788.             fwrite(&l,sizeof(l),1,fd);
  1789.             fontcom.coordsz += sizeof(l);
  1790.             i3++;
  1791.         }
  1792.     }
  1793.  
  1794.     /* clean up last character */
  1795.  
  1796.     fseek(fd,-(long)sizeof(l),1);
  1797.     l |= 0100000;
  1798.     fwrite(&l,sizeof(l),1,fd);
  1799.  
  1800.     /* write header */
  1801.  
  1802.     fseek(fd,(long)0,0);
  1803.     fwrite(&fontcom,sizeof(fontcom),1,fd);
  1804.     exit(0);
  1805. }
  1806.  
  1807. gread()
  1808. {
  1809.     char    *c;
  1810.  
  1811.     c = j;
  1812.     while((*c = fgetc(ifd)) != EOF){
  1813.         if(*c == ',' || *c == '/' || *c == '\n')return(0);
  1814.         c++;
  1815.     }
  1816.     return(1);
  1817. }
  1818.  
  1819. err(s1,s2)
  1820.     char    *s1,*s2;
  1821. {
  1822.     fputs(s1,stderr);
  1823.     fputs(s2,stderr);
  1824.     fputc('\n',stderr);
  1825.     exit(1);
  1826. }
  1827.  
  1828. synerr(){
  1829.     err("syntax: genfont <output file> <input file>","");
  1830. }
  1831. SHAR_EOF
  1832. cat << \SHAR_EOF > scale.c
  1833. /*
  1834.     scale - find minimum and maximum of vector
  1835.  
  1836.     The CRC graphics package
  1837.  
  1838.     Carl Crawford 
  1839.     Purdue University
  1840.     West Lafayette, IN 47901
  1841.  
  1842.     October 1981
  1843. */
  1844.  
  1845. #include    "crc.h"
  1846.  
  1847. scale(a,n)
  1848. float *a;
  1849. int n;
  1850. {
  1851.     float ai,fmax,fmin;
  1852.     register    int i;
  1853.  
  1854.     fmax = fmin = *a;
  1855.     for(i=0;i<n;i++){
  1856.         ai=a[i];
  1857.         if(ai > fmax) fmax = ai;
  1858.         if(ai < fmin) fmin = ai;
  1859.     }
  1860.     a[n] = fmin;
  1861.     a[n+1] = fmax;
  1862. }
  1863. SHAR_EOF
  1864. cat << \SHAR_EOF > strip7.c
  1865. /*
  1866.     strip7 - strip byte counts from binary f77 writes
  1867.  
  1868.     The CRC graphics package
  1869.  
  1870.     carl crawford
  1871.     purdue university
  1872.     west lafayette, indiana 47907
  1873.  
  1874.     april 10, 1980
  1875.  
  1876.     Modified 11/2/82...to give it bigger buffer for plot3d
  1877.                         Malcolm
  1878.  
  1879.     syntax: strip7 [-r] file1 file2 ...
  1880. */
  1881.  
  1882. #include <stdio.h>
  1883. #include <signal.h>
  1884. #define    MAXBUF    30000
  1885.  
  1886. int    files;        /* 1 if multiple files present */
  1887. int    new;        /* 1 put stripped file in name.s7 */
  1888. int    ofile;        /* 1 open temp or output file */
  1889. char    name[50];    /* file name buffer */
  1890. char    buf[MAXBUF];
  1891.  
  1892. main(argc,argv)
  1893.     int    argc;
  1894.     char    **argv;
  1895. {
  1896.     FILE    *fdi,*fdo;
  1897.     int     i,j;
  1898.     int    rmtmp();
  1899.  
  1900.     if(argc > 1 && argv[1][0] == '-' && argv[1][1] == 'r'){
  1901.         new = 1;
  1902.         argc--;
  1903.         argv++;
  1904.     }
  1905.     if(argc == 1)err("usage: strip7 [-r] file1 ...","");
  1906.  
  1907.     signal(SIGHUP,rmtmp);
  1908.     signal(SIGINT,rmtmp);
  1909.     signal(SIGQUIT,rmtmp);
  1910.  
  1911.     if(argc > 2)files = 1;
  1912.     while(++argv,--argc){
  1913.         if((fdi = fopen(*argv,"r")) == NULL){
  1914.             err("can't open: ",*argv);
  1915.             goto nfile;
  1916.         }
  1917.         if(new){
  1918.             strcpy(name,*argv);
  1919.             strcat(name,".s7");
  1920.             if((fdo = fopen(name,"w")) == NULL){
  1921.                 err("can't create: ",name);
  1922.                 goto nfile;
  1923.             }
  1924.         }else{
  1925.             if((fdo = fopen("strip7.tmp","w")) == NULL){
  1926.                 err("can't create temp file\n","");
  1927.                 goto nfile;
  1928.             }
  1929.         }
  1930.         ofile = 1;
  1931.         while(fread(&i,sizeof(int),1,fdi) == 1){
  1932.             if(i <= 0 || i > MAXBUF){
  1933.                 bad(*argv);
  1934.                 goto nfile;
  1935.             }
  1936.             if(fread(buf,1,i,fdi) != i){
  1937.                 bad(*argv);
  1938.                 goto nfile;
  1939.             }
  1940.             fwrite(buf,1,i,fdo);
  1941.             if(fread(&j,sizeof(int),1,fdi) != 1){
  1942.                 bad(*argv);
  1943.                 goto nfile;
  1944.             }
  1945.             if(j != i){
  1946.                 bad(*argv);
  1947.                 goto nfile;
  1948.             }
  1949.         }
  1950.         fclose(fdi);
  1951.         fclose(fdo);
  1952.         if(!new){
  1953.             if(unlink(*argv) == -1){
  1954.                 err("can't unlink: ",*argv);
  1955.                 goto nfile;
  1956.             }
  1957.             if(link("strip7.tmp",*argv) == -1){
  1958.                 strcpy(buf,"cp strip7.tmp ");
  1959.                 strcat(buf,*argv);
  1960.                 system(buf);
  1961.             }
  1962.             unlink("strip7.tmp");
  1963.         }
  1964.         ofile = 0;
  1965. nfile:
  1966.     ;
  1967.     }
  1968. }
  1969. bad(s)
  1970. char    *s;
  1971. {
  1972.     if(files){
  1973.         fprintf(stderr,"%s:bad data structure\n",s);
  1974.     }else{
  1975.         fprintf(stderr,"bad data structure\n");
  1976.     }
  1977.     rmfiles();
  1978. }
  1979. err(s1,s2)
  1980.     char    *s1,*s2;
  1981. {
  1982.     fprintf(stderr,"%s%s\n",s1,s2);
  1983.     rmfiles();
  1984. }
  1985. rmfiles()
  1986. {
  1987.     if(!ofile)return;
  1988.     if(new){
  1989.         unlink(name);
  1990.     }else{
  1991.         unlink("strip7.tmp");
  1992.     }
  1993.     ofile = 0;
  1994. }
  1995.  
  1996. rmtmp()
  1997. {
  1998.     rmfiles();
  1999.     exit(1);
  2000. }
  2001. SHAR_EOF
  2002. cat << \SHAR_EOF > xyaxes.c
  2003. #include <stdio.h>
  2004.  
  2005. main(argc,argv)
  2006. int argc;
  2007. char **argv;
  2008. {
  2009.     int fd1, fd2, i, xaxis[6];
  2010.     double yaxis[50];
  2011.  
  2012.     fd1 = creat("xaxis", 0600);
  2013.     fd2 = creat("yaxis", 0600);
  2014.  
  2015.     for(i = 0; i < 6; i++){
  2016.         xaxis[i] = 30 * i;
  2017.     }
  2018.     for(i = 0; i < 50; i++){
  2019.         yaxis[i] = i / 100.0;
  2020.     }
  2021.  
  2022.     write(fd1, xaxis, 6 * sizeof (int));
  2023.     write(fd2, yaxis, 50 * sizeof (double));
  2024. }
  2025. SHAR_EOF
  2026. cat << \SHAR_EOF > Makefile
  2027. # crc/src Makefile
  2028. #
  2029. # $Header: /usr/src/unsup/bin/crc/src/RCS/Makefile,v 1.9 87/05/06 23:27:04 rsk Local $
  2030. #
  2031. #    Richard S. Kulawiec, Purdue University Computing Center
  2032. #    9/26/86
  2033. #
  2034.  
  2035. BIN=    ${DESTDIR}/usr/unsup/bin
  2036. LIB=    ${DESTDIR}/usr/unsup/lib/crc
  2037.  
  2038. GRAPHICSLIB=../lib/libG.a
  2039. OWNER = binary
  2040. GROUP = system
  2041. MODE = 751
  2042. SHMODE = 755
  2043. SUMODE = 4751
  2044. SGMODE = 2751
  2045. TXTMODE = 644
  2046.  
  2047. INCLUDE =
  2048. CDEFS =
  2049. CFLAGS = -O -n ${CDEFS} ${INCLUDE}
  2050.  
  2051. HDR =    
  2052. # Use this set if you want the drivers; it includes gd gp gplp hpd
  2053. # SRC =    qplot.c plot3d.c gd.c gp.c gplp.c hpd.c crclabel.c strip7.c \
  2054. #     axis.c axis_.c axisv_.c draxis.c plot3dres.c scale.c xyaxes.c genfont.c
  2055. SRC =    qplot.c plot3d.c crclabel.c strip7.c \
  2056.     axis.c axis_.c axisv_.c draxis.c plot3dres.c scale.c xyaxes.c genfont.c
  2057. FSRC =    draw.f newtru.f setaxs.f subr.f test.f
  2058. # See comment above.
  2059. # OBJ =    qplot.o plot3d.o gd.o gp.o gplp.o hpd.o crclabel.o strip7.o \
  2060. #    axis.o axis_.o axisv_.o draxis.o plot3dres.o scale.o xyaxes.o genfont.o
  2061. OBJ =    qplot.o plot3d.o crclabel.o strip7.o \
  2062.     axis.o axis_.o axisv_.o draxis.o plot3dres.o scale.o xyaxes.o genfont.o
  2063. FOBJ =    draw.o newtru.o setaxs.o subr.o test.o
  2064. SOURCE=    Makefile ${HDR} ${SRC} ${FSRC}
  2065.  
  2066. # all:    qplot plot3d gd gp gplp hpd crclabel strip7 font.5x7
  2067. all:    qplot plot3d crclabel strip7 font.5x7
  2068.  
  2069. qplot:    qplot.c $(GRAPHICSLIB)
  2070.     ${CC} -O qplot.c $(GRAPHICSLIB) -lm -o qplot
  2071.  
  2072. plot3d:    $(OBJS) $(FOBJ) $(GRAPHICSLIB)
  2073.     ${CC} $(CFLAGS) $(OBJS) $(FOBJ) -o plot3d $(GRAPHICSLIB) -lI77 -lU77 -lF77 -lm
  2074. # gd:    gd.c $(GRAPHICSLIB)
  2075. #     ${CC} -O gd.c $(GRAPHICSLIB) -lm -o gd
  2076. # gp:    gp.c $(GRAPHICSLIB)
  2077. #     ${CC} -O gp.c $(GRAPHICSLIB) -lm -o gp
  2078. # gplp:    gplp.c $(GRAPHICSLIB)
  2079. #     ${CC} -O gplp.c $(GRAPHICSLIB) -lm -o gplp
  2080. # hpd:    hpd.c $(GRAPHICSLIB)
  2081. #     ${CC} -O hpd.c $(GRAPHICSLIB) -lm -o hpd
  2082.  
  2083. crclabel:    crclabel.c $(GRAPHICSLIB)
  2084.     ${CC} -O crclabel.c $(GRAPHICSLIB) -lm -o crclabel
  2085.  
  2086. strip7:    strip7.c $(GRAPHICSLIB)
  2087.     ${CC} -O strip7.c $(GRAPHICSLIB) -lm -o strip7
  2088.  
  2089. font.5x7:    ifont.5x7 genfont
  2090.         ./genfont font.5x7 ifont.5x7
  2091.  
  2092. genfont:    genfont.c
  2093.         ${CC} $(CFLAGS) genfont.c -o genfont
  2094.  
  2095. $(GRAPHICSLIB): ../lib/libG.a
  2096.         cd ../lib;make all
  2097.  
  2098. clean:    FRC
  2099.     -rm -f Makefile.bak a.out core errs lint.errs *.o font.5x7 genfont \
  2100.     qplot plot3d gd gp gplp hpd crclabel strip7 font.5x7
  2101.  
  2102. depend:    ${HDR} ${SRC} FRC
  2103.     maketd -a ${CDEFS} ${INCLUDE} ${SRC}
  2104.  
  2105. install:    all  FRC
  2106.     -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s qplot ${BIN}
  2107.     -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s plot3d ${BIN}
  2108. #    -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s gd ${LIB}
  2109. #    -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s gp ${LIB}
  2110. #    -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s gplp ${LIB}
  2111. #    -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s hpd ${LIB}
  2112.     -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s crclabel ${LIB}
  2113.     -install -c -m ${MODE} -o ${OWNER} -g ${GROUP} -s strip7 ${BIN}
  2114.     -install -c -m ${TXTMODE} -o ${OWNER} -g ${GROUP} font.5x7 ${LIB}
  2115.  
  2116. lint: ${HDR} ${SRC} FRC
  2117.     lint -hnx ${CDEFS} ${INCLUDE} ${SRC}
  2118.  
  2119. print: source FRC
  2120.     lpr -J"crc/src source" ${SOURCE}
  2121.  
  2122. source: ${SOURCE}
  2123.  
  2124. spotless: clean 
  2125.     rcsclean Makefile ${HDR} ${SRC} ${FSRC}
  2126.  
  2127. tags: ${HDR} ${SRC}
  2128.     ctags -t ${HDR} ${SRC}
  2129.  
  2130. ${SOURCE}:
  2131.     co $@
  2132.  
  2133. FRC:
  2134.  
  2135. # DO NOT DELETE THIS LINE - make depend DEPENDS ON IT
  2136. I=/usr/include
  2137. S=/usr/include/sys
  2138.  
  2139. qplot.o: $I/math.h $I/stdio.h qplot.c
  2140.  
  2141. plot3d.o: $I/math.h $I/stdio.h plot3d.c
  2142.  
  2143. crclabel.o: $I/math.h $I/stdio.h crclabel.c
  2144.  
  2145. strip7.o: $I/signal.h $I/stdio.h strip7.c
  2146.  
  2147. axis.o: $I/math.h $I/signal.h $I/stdio.h axis.c crc.h
  2148.  
  2149. axis_.o: $I/math.h $I/signal.h $I/stdio.h axis_.c crc.h
  2150.  
  2151. axisv_.o: $I/math.h $I/signal.h $I/stdio.h axisv_.c crc.h
  2152.  
  2153. draxis.o: $I/math.h $I/signal.h $I/stdio.h crc.h draxis.c
  2154.  
  2155. plot3dres.o: $I/math.h $I/stdio.h plot3dres.c
  2156.  
  2157. scale.o: $I/math.h $I/signal.h $I/stdio.h crc.h scale.c
  2158.  
  2159. xyaxes.o: $I/stdio.h xyaxes.c
  2160.  
  2161. genfont.o: $I/stdio.h genfont.c
  2162.  
  2163. # *** Do not add anything here - It will go away. ***
  2164. SHAR_EOF
  2165. chdir ..
  2166. #    End of shell archive
  2167. exit 0
  2168.  
  2169. -- 
  2170.  
  2171. Rich $alz            "Anger is an energy"
  2172. Cronus Project, BBN Labs    rsalz@bbn.com
  2173. Moderator, comp.sources.unix    sources@uunet.uu.net
  2174.