home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / cad / atk1ibm.arj / GEDPS.PS < prev    next >
Text File  |  1991-03-24  |  6KB  |  237 lines

  1. % This is a prologue for DFD files sent to the laser printer
  2. % NOTE: A rotation is normally done for LANDSCAPE style printing.
  3. % If this rotation is not desired, orientation is defined to PORTRAIT.
  4. % THE ORIENTATION CAN BE CHANGED BY CHANGING THE DEFINITION OF ORIENTATION
  5. % AND BY FIXING THE BoundingBox COMMENT (FOR EPS COMPATIBILITY)
  6. % For LANDSCAPE, %%BoundingBox: 0 0 612 796, is proper
  7. % For PORTRAIT,  %%BoundingBox: 0 0 612 492, is proper.
  8. orientation LANDSCAPE eq {      % Set up based on orientation definition
  9. 90 rotate 36 -36 translate    % landscape - origin in UL corner
  10. 10.0 72 mul 11000 div dup scale    % scale to 11000 for 10 inches across page
  11. 20 setlinewidth            % Same as 1 pixel on screen
  12. }
  13. {
  14. 36 440 translate                % portrait - origin in UL corner of DFD
  15. 7.5 72 mul 11000 div dup scale  % scale to 11000 for 7.5 inches across page
  16. 16 setlinewidth                 % Same as 1 pixel on screen
  17. }
  18. ifelse                          % Set up for LANDSCAPE or PORTRAIT
  19. /myscale { 11000 80 div } def
  20. /Helvetica findfont myscale scalefont setfont    % 80 chars across page (now:x10)
  21.  
  22. % The x coordinate is the same as in DFDs, the Y coordinate is negative
  23. /doProcess    % Gets Pno Ptext Rad Xc Yc
  24. {
  25.   /Yc exch def
  26.   /Xc exch def
  27.   /Rad exch def
  28.   /Ptext exch def
  29.  
  30.   Xc Yc neg Rad add myscale sub placetext    % Pno is still on the stack
  31.   Ptext Xc Yc neg placetext
  32.   Xc Yc neg Rad 0 360 arc stroke
  33. } def
  34.  
  35. /doExternal    % Gets: Etext Xc Yc Xdis Ydis
  36. {
  37.   /Ydis exch def
  38.   /Xdis exch def
  39.   /Yc   exch def
  40.   /Xc   exch def
  41.  
  42.   Xc Yc neg placetext    % Etext is still on the stack
  43.   Xc Yc neg Xdis Ydis box
  44. } def
  45.  
  46. /doFile        % Gets: Ftext Xc Yc Xdis Ydis SingDoub
  47. {
  48.   /SingDoub exch def
  49.   /Ydis    exch def
  50.   /Xdis exch def
  51.   /Yc exch def
  52.   /Xc exch def
  53.  
  54.   Xc Yc neg placetext    % Ftext is already on the stack
  55.   Xc Yc neg Xdis Ydis
  56.   SingDoub 0 eq        % Checks if Single line file
  57.   { singlelinefile }    %  If single line
  58.   { doublelinefile }    %  If double line
  59.   ifelse
  60. } def
  61.  
  62. /doFlow        % Gets: [[X1 Y1] ... [Xm Ym]] Xn Yn Name Arrows?
  63. {
  64.   /Doub exch def        % Single or double headed: 
  65.   /Ftext exch def
  66.   /Yn exch def
  67.   /Xn exch def
  68.   /RouteArray exch def
  69.   RouteArray PolyLine % Draw the path, Sans arrowheads and Text
  70.   
  71.   RouteArray 0 get aload pop /Ys exch def /Xs exch def
  72.  
  73.   Doub 1 and 0 ne           % Arrowhead at beginning!
  74.   {
  75.     RouteArray 1 get aload pop /Ytmp exch def /Xtmp exch def
  76.     Xs Ys neg moveto
  77.     Xs Xtmp sub Ys Ytmp sub atan arrowhead
  78.     gsave stroke grestore
  79.     newpath
  80.   }
  81.   if 
  82.  
  83.   Doub 2 and 0 ne           % Arrowhead at end!
  84.   {
  85.     /tmpCount RouteArray length def
  86.     RouteArray tmpCount 1 sub get aload pop /Ye exch def /Xe exch def
  87.     RouteArray tmpCount 2 sub get aload pop /Ytmp exch def /Xtmp exch def
  88.     Xe Ye neg moveto
  89.     Xe Xtmp sub Ye Ytmp sub atan arrowhead
  90.     gsave stroke grestore
  91.     newpath
  92.   }
  93.   if
  94.  
  95.   Xn Yn neg moveto
  96.   
  97.   Ftext 
  98.   dup BlankUnder
  99.   Xn Yn neg                     % Text still on stack
  100.   placetext
  101. } def
  102.  
  103. /doDescription            % Gets Dtext Xl Yl
  104. {
  105.   neg moveto
  106.   gsave
  107.     dup stringwidth pop 2 div 0 rmoveto
  108.     dup BlankUnder
  109.   grestore
  110.   show
  111. } def
  112.  
  113. %
  114. %% Other functions
  115. %
  116. /placetext         % stack: text xcenter ycenter
  117.   moveto        % Absolute move to center of new text
  118.   dup stringwidth pop    % puts x width on stack after copy of string
  119.   2 div neg         % puts -1/2 x on stack 
  120.   0            % puts 0 y-char height on stack
  121.   rmoveto        % movck halfway
  122.   show            % Only string was on stack now
  123.   newpath        % Clear any current path from the moveto
  124. } def
  125.  
  126. /box    % items on stack: xcenter ycenter xdis ydis: For externals
  127. {  /ydis exch def
  128.    /xdis exch def
  129.    /ycenter exch def
  130.    /xcenter exch def
  131.  
  132.    newpath
  133.    xcenter xdis add ycenter ydis add moveto
  134.    0 ydis neg ydis neg add rlineto
  135.    xdis neg xdis neg add 0 rlineto
  136.    0 ydis ydis add rlineto
  137.    closepath stroke
  138. } def
  139.  
  140. /singlelinefile    % items on stack: same as for externals
  141. {  /ydis exch def
  142.    /xdis exch def
  143.    /ycenter exch def
  144.    /xcenter exch def
  145.    newpath
  146.    xcenter xdis add ycenter ydis add moveto
  147.    xdis neg xdis neg add 0 rlineto
  148.    stroke
  149. } def
  150.  
  151. /doublelinefile    % items on stack: same as for externals
  152. {  /ydis exch def
  153.    /xdis exch def
  154.    /ycenter exch def
  155.    /xcenter exch def
  156.    newpath
  157.    xcenter xdis add ycenter ydis add moveto
  158.    xdis neg xdis neg add 0 rlineto
  159.    stroke newpath
  160.    xcenter xdis add ycenter ydis neg add moveto
  161.    xdis neg xdis neg add 0 rlineto
  162.    stroke
  163. } def
  164.  
  165. /average         % Gets: Two numbers to average
  166. {
  167.   add 2 div 
  168. } def
  169.  
  170. /arrowhead        % Gets: angle as input
  171. {
  172.   gsave            % Save current origin & rotation
  173.     currentpoint        % Get the current position
  174.     translate        % Make it the origin
  175.     rotate        % Use the angle argument
  176.     triangle        % Draw the triangle
  177.   grestore        % Restore origin and rotation
  178. } def
  179.  
  180. /triangle        % Draws a dull, black triangle at the origin
  181. {
  182.   gsave            % Preserve our dullness (gray scale)
  183.     0 setgray
  184.     0 0 moveto
  185.       50 100 lineto
  186.     -100   0 rlineto
  187.     closepath
  188.     fill
  189.   grestore        % Restore our dullness
  190. } def
  191.  
  192. /PolyLine % Array of 2-int arrays on stack
  193. {
  194.   /Array exch def
  195.   Array 0 get aload pop /Ys exch def /Xs exch def
  196.   Xs Ys neg moveto
  197.   1 1 Array length 1 sub
  198.   {
  199.     Array exch get aload pop /Ye exch def /Xe exch def
  200.     Xe Ye neg lineto
  201.     /Xs Xe def
  202.     /Ys Ye def
  203.   }
  204.   for
  205.   gsave stroke grestore
  206.   newpath
  207. } def
  208.  
  209. % Note: This is font specific.  For Helvetica, the Font Box
  210. % descends 22% below point size and extends above 94% point size
  211. /BlankUnder     % text-item
  212. {
  213.   stringwidth pop    % How wide is it
  214.   dup 0 gt
  215.   {            % If width is > 0
  216.     dup 2 div neg         % Half of the string width wide
  217.     myscale rmoveto        % Move to -1/2 stringwidth, myscale
  218.     dup 0 rlineto        % Move to 1/2 stringwidth, myscale
  219.     0 myscale 1.25 mul neg rlineto    % Move to 1/2 stringwidth, -.25 myscale
  220.     neg 0 rlineto        % Move to -1/2 stringwidth, -.25 myscale
  221.     %myscale 1.2 mul rmoveto    % And 1.2 char height high
  222.     %dup 0 rlineto 0 myscale 1.2 mul 1.2 mul neg rlineto
  223.     %neg 0 rlineto
  224.     closepath
  225.     gsave            % Save current gray level
  226.     1 setgray fill
  227.     grestore newpath        % Reset the gray level
  228.   }
  229.   {            % width is 0
  230.     pop            % pop off extra stringwidth
  231.   }
  232.   ifelse
  233. } def
  234.  
  235. %%EndProlog
  236.