home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / zsys / znode-12 / i / plot33.lbr / PLOT-DOC.3Z / PLOT-DOC.3
Encoding:
Text File  |  1993-06-12  |  21.6 KB  |  461 lines

  1.  
  2. The next file is called TEST.BAS. It is a sample program that 
  3. illustrates how to use the routines in GRAPH.BAS. To use TEST, 
  4. enter BASIC-80, then LOAD "GRAPH.BAS". MERGE "TEST.BAS", and RUN 
  5. it. The program can produce one or both of two plots. The first 
  6. is a polygon with all of the vertices connected to each other.  
  7. This provides a good test of the line drawing capabilities of 
  8. PLOT. The second plot is a graph of a damped sine wave. It 
  9. illustrates nearly the complete range of PLOT's capabilities.
  10.  
  11. Two programs, FILLS and UPLOAD, are an aid to experimenting with 
  12. the patterns used to represent colors by PLOT33. Both are to be 
  13. used with GRAPH.BAS in the same way as TEST.BAS. FILLS.BAS will 
  14. produce an array of blocks showing the stipple patterns used to 
  15. represent each "color". This makes an easy reference for future 
  16. plotting. UPLOAD.BAS is similar to FILLS.BAS, except that before 
  17. plotting the blocks, it Uploads new definitions for the patterns. 
  18. The dither matrix used is like the example used in the previous 
  19. section. The DATA statements of this program can be changed to 
  20. experiment with different definitions and then incorporated into 
  21. your applications.
  22.  
  23. The final program is HANDPLOT.BAS. This is a general purpose 
  24. program for manual plotting of data. The program uses a menu to 
  25. display the BASIC plot package settings and allow them to be 
  26. changed. Data can be typed in from the keyboard, saved in a disk 
  27. file, and plotted. A limited number of symbols are avalilable for 
  28. identifying data points and the points may optionally be 
  29. connected by straight lines. Plotting scales and axes may be 
  30. specified manually, or determined automatically from the range of 
  31. values in the data. To make it easy to enter this program 
  32. directly from the operating system command level, the routines in 
  33. GRAPH.BAS have already been included and no MERGE operation is 
  34. required.
  35.  
  36. When HANDPLOT is first entered, it prompts the user for the name 
  37. of the .VEC file, and for the dimensions of the data arrays. It 
  38. then displays the menu. The menu is divided into three parts 
  39. which are concerned with the data, the format of the graph, and 
  40. the activities that can be performed by the program. It will look 
  41. like this:
  42.  
  43. DATA SETTINGS
  44. No. of Variables  0               No. of Points  0
  45. 1> Data Entry KEYBOARD            2> Input File
  46.                                   3> Output File
  47. 4> X Variable                     5> Y Variable
  48. 6> Symbol NONE                    7> Connect points FALSE
  49.  
  50. GRAPHIC SETTINGS
  51. X Axis    8> Min  0                9> Max  1          10> DeltaX  1
  52.          11> Label Chars 0        12> Divisions  0
  53. Y Axis   13> Min  0               14> Max  1          15> DeltaY  1
  54.          16> Label Chars  0       17> Divisions  0
  55. Margins  18> Left  0              19> Right  0
  56.          20> Bottom  0            21> Top  0
  57. 22> Color Value  127              23> Auto-Scale  TRUE
  58. 24> Clear Plot Area First FALSE
  59. 25> Plot Output File Name JUNK.VEC
  60.  
  61. ACTIONS
  62. 26> Read New Data       27> Edit data            28> Write Data
  63. 29> Plot Graph Axes     30> Plot Data            31> Title Plot
  64. 32> Advance Page        33> End Program
  65.  
  66. Enter Number of SETTING or ACTION?
  67.  
  68. From here, the program is operated by giving all of the required 
  69. settings their correct value, and then selecting the desired 
  70. action. This is done by entering the number printed next to the 
  71. entry on the menu. Each setting will then prompt you for the data 
  72. that it needs, if any. Several settings, such as Data Entry, only 
  73. toggle between two values; in this case, KEYBOARD or DISK. The 
  74. settings may be entered in any order.
  75.  
  76. The first thing you will probably want to do is to enter some 
  77. data to be plotted. If the data is to be read from a disk file 
  78. instead, then enter 1 to toggle to DISK. You will then have to 
  79. enter 2 to have the program prompt you for the input file's name. 
  80. If the data is to be typed in, you are already to go. Now enter 
  81. 26, and the program will start to read the disk file, or prompt 
  82. you for the data. Once the data has been read in, it can be 
  83. changed using option 27, Edit Data. The data can also be stored 
  84. on disk using option 28. The output file name is handled in the 
  85. same way as the input file name.
  86.  
  87. Next you will want to indicate, using settings 4 and 5, which 
  88. variables are to be used for the X and Y axes and whether the 
  89. points should be plotted with one of the available symbols and/or 
  90. connected with straight lines.
  91.  
  92. If you are simply plotting a figure, you are ready to plot it 
  93. using option 30, Plot Data. If you are plotting a graph, then all 
  94. of the settings in the next section should be given their correct 
  95. value before plotting the axes with option 29.  Several sets of 
  96. data can be plotted on the same graph, simply by changing the X 
  97. and Y variables and symbol and plotting the data again. Strings 
  98. can be printed anywhere on the graph using Option 31.
  99.  
  100. The DeltaX and Divisions settings are linked to each other, as 
  101. are the DeltaY and Divisions setting for the Y axis.  When the 
  102. DeltaX or DeltaY setting is changed, the Divisions settings will 
  103. be reset to indicate the number of divisions between the Min and 
  104. Max values. If the Divisions setting is changed, the DeltaX or 
  105. DeltaY setting will be calculated to give a good engineering 
  106. value (multiples of 1, 2, 5, or 10), and the Divisions setting 
  107. will reflect the revised number of divisions. Thus the value you 
  108. enter into the Divisions setting will only be approximately the 
  109. value that will ultimately result. If your engineering esthetics 
  110. differ from the program's, you will have use the DeltaX and 
  111. DeltaY settings.
  112.  
  113. In a similar fashion, the Auto-Scale option will reset the Max 
  114. and Min values to include the actual range of the data, and will 
  115. use the Divsions settings to indicate the approximate number of 
  116. labels to use for each axis.
  117.  
  118. Advance Page will issue an Output command, clear the frame, and 
  119. set the color to black for further plotting. The frames will be 
  120. plotted one after the other with no space in between them. End 
  121. Program will issue an Output command, close out all files and, 
  122. return to the BASIC command level.
  123.  
  124. Several plots can be put on one page, simply by adjusting the 
  125. margin values between plotting each graph. If Clear Plot Area 
  126. First, setting 24, is TRUE, the area inside the margins will be 
  127. erased to white using the Fill command before the axes are 
  128. plotted. This is useful for plotting one graph as an inset within 
  129. a larger figure.
  130.  
  131. The data file has a simple format, and can be made using your 
  132. editor or another program, rather than laboriously entering all 
  133. the data with HANDPLOT. The first record contains the number of 
  134. variables, or fields, in the data records to follow. The next 
  135. entries are names, up to 20 characters long, for each of the 
  136. variables. These can be on the same line, separated by commas, or 
  137. each may be on a record by itself. The data values are next. One 
  138. value for each variable is read in turn, until the end of the 
  139. file is encountered. The values on any given line are separated 
  140. by commas, and each logical record (one value for each variable) 
  141. may be spread over several lines of data. A sample data file is 
  142. shown below:
  143.  
  144. 3                   <--- Three Variables
  145. X, Y, Z             <--- Names for each variable
  146. 123, 4.56, 78.9     <--- First record: X=123, Y=4.56, Z=78.9
  147. 10.11,1213,1516.17
  148. 18.0, 19.0, 20      <--- Last record
  149.  
  150. TURBO PASCAL Library
  151.  
  152. Turbo Pascal support is provided in the form of two "include" 
  153. files and one test program. GRAF1.PAS contains the global 
  154. declarations and lowest level routines. These provide direct 
  155. access to the commands in the .VEC file. It also provides 
  156. functions to do scale conversions. GRAF2.PAS uses these routines 
  157. to provide the additional capability to plot graphic characters, 
  158. plot axes, and do whole Cartesian grids.  Each routine and its 
  159. calling arguements are summarized in Table 2.
  160.  
  161. Plotting is initiated with the procedure GRINIT. This procedure 
  162. opens the disk file and initializes the plot, as discussed 
  163. previously. It also initializes all global variables. The GRFINI 
  164. routine writes the Output and Quit commands and closes the plot 
  165. file.
  166.  
  167. The following routines correspond directly to commands in the 
  168. plot file: COLOR, ERASE, FILL, GPRINT, GSTRNG, GMOVE, POINT, 
  169. SEGMNT, and VECTOR.
  170.  
  171. Scaling is accomplished by using RWINDO to set the real world 
  172. limits and SWINDO to map the real world limits to a specific area 
  173. on the page. In the interest of execution speed, no clipping is 
  174. done to ensure that the plotting is confined to either window. 
  175. The functions SX and SY are used to convert from the real world 
  176. coordinates to the normalized device, or "screen" coordinates. 
  177. The reverse conversion is performed by RX and RY.
  178.  
  179. GRAPH plots a complete grid given the range of data and area on 
  180. the page. AXIS can be used to make special graphs and DXDY will 
  181. calculate good engineering values for AXIS. The graphic 
  182. characters and strings are plotted by GCHAR and GWRITE, 
  183. respectively.
  184.  
  185.                              TABLE 2
  186.  
  187.                       TURBO PASCAL ROUTINES
  188.  
  189. Name   Inputs Outputs   Function
  190.  
  191. ----------------------------------------------------------------
  192.  
  193. color                   Sets color/pattern- sends Color command.
  194.         code            integer which selects color or pattern
  195.  
  196. erase                   Clears page- sends Erase command.
  197.  
  198. fill                    Fills trapezoidal area- sends Fill command.
  199.         x1              normalized X coordinate for start of segment
  200.         y1              normalized Y coordinate for start of segment
  201.         x2              normalized X coordinate for end   of segment
  202.         y2              normalized Y coordinate for end   of segment
  203.         yf              normalized Y coordinate for fill level
  204.  
  205. gmove                   "Pen up" move to point- sends Move command.
  206.         x               normalized X coordinate
  207.         y               normalized Y coordinate
  208.  
  209. gprint                  Prints picture- sends Output command.
  210.  
  211. grinit                  Initializes .VEC file
  212.         name            string specifying name of .VEC file
  213.  
  214. grfini                  Quits plotting, closes .VEC file
  215.  
  216. gstrng                  Prints string- sends String command.
  217.         x               normalized X coordinate for first character
  218.         y               normalized Y coordinate for first character
  219.         strng           string to be plotted (no <CR> at end)
  220.  
  221. point                   Plots point- sends Point command.
  222.         x               normalized X coordinate
  223.         y               normalized Y coordinate
  224.  
  225. segmnt                  Plots line segment- sends Draw command.
  226.         x1              normalized X coordinate for start of segment
  227.         y1              normalized Y coordinate for start of segment
  228.         x2              normalized X coordiante for end   of segment
  229.         y2              normalized Y coordinate for end   of segment
  230.  
  231. vector                  "Pen down" move- sends Increment command.
  232.          x               normalized X coordinate
  233.          y               normalized Y coordinate
  234.  
  235. Name   Inputs Outputs   Function
  236.  
  237. ----------------------------------------------------------------
  238.  
  239. rwindo                  Establishes real window for scaling.
  240.         xmini           real world value at left   side of window
  241.         xmaxi           real world value at right  side of window
  242.         ymini           real world value at bottom side of window
  243.         ymaxi           real world value at top    side of window
  244.  
  245. swindo                  Establishes window on page for scaling.
  246.         sxlti           normalized X coordinate for left   side
  247.         sxrti           normalized X coordinate for right  side
  248.         syboti          normalized Y coordinate for bottom side
  249.         sytopi          normalized Y coordinate for top    side
  250.  
  251. sx                      Converts from real world to normalized coord
  252.         rxi             real world X coordinate
  253.                sx       normalized X coordinate
  254.  
  255. sy                      Converts from real world to normalized coord
  256.         ryi             real world Y coordinate
  257.                sy       normalized Y coordinate
  258.  
  259. rx                      Converts from normalized to real world coord
  260.         sxi             normalized X coordinate
  261.                rx       real world X coordinate
  262.  
  263. ry                      Converts from normalized to real world coord
  264.         syi             normalized Y coordinate
  265.                ry       real world Y coordinate
  266.  
  267. axis                    Plots axis at arbitrary orientation.
  268.         r1              real world value at start of axis
  269.         r2              real world value at end   of axis
  270.         dri             real world increment for tic mark intervals
  271.         sx1             normalized X coordinate for start of axis
  272.         sy1             normalized Y coordinate for start of axis
  273.         sx2             normalized X coordinate for end   of axis
  274.         sy2             normalized Y coordinate for end   of axis
  275.         ticlen          normalized length of tic mark
  276.         ticang          CCW angle, in deg, from horiz. to tic mark
  277.         lblnum          integer number of char's in tic mark label
  278.         lbldec          integer number of char's after decimal pt.
  279.         lblang          CCW angle, in deg, from hor. to lbl X axis
  280.  
  281. Name   Inputs Outputs   Function
  282.  
  283. ----------------------------------------------------------------
  284.  
  285. graph                   Plots complete Cartesian grid.
  286.         xmini           real world value at left   side of graph
  287.         xmaxi           real world value at right  side of graph
  288.         nx              integer- approximate number of X intervals
  289.         ymini           real world value at bottom side of graph
  290.         ymaxi           real world value at top    side of graph
  291.         ny              integer- approximate number of Y intervals
  292.         sxl             normalized X coordinate for left   side
  293.         syb             normalized Y coordinate for bottom side
  294.         sxr             normalized X coordinate for right  side
  295.  
  296. chset                   Sets size and orientation of graphic char's
  297.         xsize           normalized width of character
  298.         ysize           normalized width of character
  299.         theta           CCW angle, in deg, to char X axis from hor.
  300.  
  301. gchar                   Plots graphic character.
  302.         cx              normalized X coord of bottom left corner
  303.         cy              normalized Y coord of bottom left corner
  304.         charin          ASCII character to be plotted
  305.  
  306. gwrite                  Plots string of graphic characters.
  307.         x               normalized X coord of bottom left corner
  308.         y               normalized Y coord of bottom left corner
  309.         chars           string to be plotted
  310.         nchar           integer number of characters to be plot
  311.  
  312. dxdy                    Calculates arguements for axis.
  313.         x1              real world value at start of axis
  314.         x2              real world value at end   of axis
  315.         nx              integer- approximate number of intervals
  316.                lblnum   integer number of char's in tic mark label
  317.                lbldec   integer number of char's rt. of decimal
  318.  
  319. posang                  Converts angle to range in 0 to 360 deg
  320.         angle           angle to be converted
  321.                posang   converted angle
  322.  
  323. ticend                  Calculates values for ends of axis
  324.         rmin            raw real world value for start of axis
  325.         rmax            raw real world value for end   of axis
  326.         dr              real world increment between intervals
  327.                pr1      converted real world value at start of axis
  328.                pr2      converted real world value at end   of axis
  329.  
  330. Name   Inputs Outputs   Function
  331.  
  332. -----------------------------------------------------------------
  333.  
  334. writecmd                Buffered output of command string to file.
  335.         cmd             output string
  336.         cmdlen          integer number of characters to be output
  337.  
  338. buffout                 Flushes buffer.
  339.         outunit         file variable specifying output file
  340.         outbuf          string of characters forming buffer
  341.         size            number of characters to be sent out
  342.  
  343. concat2                 Concatenates portions of strings.
  344.         strng1          first string to be concatenated
  345.         nchar1          number of characters from strng1
  346.         strng2          second string to be concatenated
  347.         nchar2          number of characters from strng2
  348.                strng3   string containing strng1 and strng2
  349.  
  350. FORTRAN Library
  351.  
  352. A collection of FORTRAN routines is also included in GRAF.FOR. 
  353. This file is the FORTRAN complement of the Turbo Pascal library. 
  354. The input and output requirements for the FORTRAN routines are 
  355. similar to those of the Pascal routines, and are fully documented 
  356. in the comments within them. They communicate with each other 
  357. through a labeled COMMON block.  These routines have been run 
  358. under Microsoft FORTRAN-80, but may require some modification for 
  359. other compilers.
  360.  
  361. PART 3. INSTALLATION INSTRUCTIONS
  362.  
  363. Sizing the memory map
  364.  
  365. PLOT33 has been designed to keep the printer driver program small 
  366. while providing the necessary primitive graphic operations for 
  367. producing most pictures and plots. The reason for the simplicity 
  368. of the of the command set is because the bit map for the picture 
  369. is LARGE. It can use as much memory as your computer can give it. 
  370. The size of the memory available for the bit-map, in conjunction 
  371. with the resoultion of your printer, sets the size of the plot 
  372. that can be made. The first step in installing the program is to 
  373. decide how large the memory area for the bit map can be. The 
  374. program itself occupies about 4K. Subtract this from the size of 
  375. the TPA, and reduce the result by a little more to provide a 
  376. conservative pad. The end result is the target size for the size 
  377. of the memory map.
  378.  
  379. Divide the target size by the printer resolution (dots per inch) 
  380. in the horizontal direction, and divide again by the printer's 
  381. vertical resolution. Multiply this result by 7 (7 dots are stored 
  382. in each byte). You now have the number of square inches that can 
  383. be plotted. Take the square root, and round down to a convenient 
  384. size for each side of the plot.
  385.  
  386. Now multiply the height of the plot by the printer's vertical 
  387. resolution and round down to the nearest multiple of 7. The 
  388. number of dots in the vertical direction should be a multiple of 
  389. 7 because seven dots are stored in each byte of the memory map. 
  390. PLOT33 has no provisions for handling a byte which is contains 
  391. bits that are part in and part out of the map. You now have the 
  392. total number of dots in the vertical direction, and dividing by 7 
  393. gives the number of lines that will be printed when the plot is 
  394. made. Finally, divide the number of dots in the vertical 
  395. direction by the vertical resolution to get the final size, in 
  396. inches, of the plot.
  397.  
  398. Multiply the final size of the plot by the horizontal resolution 
  399. to get the final number of dots accross the page.  The final map 
  400. size is the product of the number of dots horizontally multiplied 
  401. by the number of dots vertically, divided by 7.
  402.  
  403. As an example, consider a 56K CP/M system. Subtracting 4K for the 
  404. PLOT program and 100H for the start of the TPA:
  405.  
  406. Target Size = 57344 - 4096 - 256 = 52992 bytes
  407.  
  408. The Epson MX-80 has 60 dots per inch horizontal and 72 dots per 
  409. inch vertical resolution.
  410.  
  411. Target Size/ Hor. Res./ Vert. Res. * 7 =
  412.   52992    /   60     /    72      * 7 = 85.9 sq.in
  413.                                         ==> 9.2 in. per side
  414.  
  415. Since the MX-80 can only plot 8 inches horizontally, the plot is 
  416. limited by the physical limits of the printer, not by the memory 
  417. avalilable. Calculating the vertical number of dots for an 8 inch 
  418. plot:
  419.  
  420.  
  421.      8 * 72 = 576 dots ==> 82 lines @ 7 dots/line
  422.                        ==> 574 dots vertically
  423.  
  424. Since only 2 dots were lost due to truncating to the nearest 
  425. number of whole bytes, there is little point in trying to adjust 
  426. the horizontal size to keep the plot square. The horizontal size 
  427. is therefore:
  428.  
  429.     8 * 60 = 480 dots
  430.  
  431. The final map size is calculated as:
  432.  
  433.     480 * 574 / 7 = 39360
  434.  
  435. Printer settings
  436.  
  437. Once the plot has been sized, you are ready to modify the 
  438. settings in the assembly language source file (PLOT33.ASM). This 
  439. file is large, over 70K, so watch the disk space. If your editor 
  440. cannot handle a file this large, the CP/M standard editor, ED, 
  441. can. ED can also read from one disk and write to another, if 
  442. necessary. For each type of printer there is an associated flag 
  443. that controls the conditional assembly for that printer. Set the 
  444. flag for your printer to TRUE and set the others to FALSE. If 
  445. your printer is not listed, it may be similar to one that is. For 
  446. example, the Gemini-10 operates identically (for the purposes of 
  447. this program) with the Epson printers. The IDS printers use the 
  448. same method as the Okidata printers for their graphics, and the 
  449. NEC printers act the same as the C.Itoh printers.
  450.  
  451. Next, the settings for your printer must be changed or verified. 
  452. MAPSIZE should be set to the value calculated above. MAXX and 
  453. MAXY must be set to 1 less than the number of dots in the 
  454. horizontal and vertical directions. For the example above, 
  455. MAPSIZE becomes 39360, MAXX is set to 479, and MAXY to 573.
  456.  
  457. Once the settings are made for your printer, exit the editor and 
  458. assemble the program using ASM or another 8080 assembler. Use 
  459. LOAD to create the .COM file from the .HEX file, and the 
  460. installation is finished.
  461.