home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume14 / vplot / part15 < prev    next >
Text File  |  1988-03-31  |  45KB  |  1,479 lines

  1. Subject:  v14i020:  Device-independant graphics system, with drivers
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Joe Dellinger <joe@hanauma.STANFORD.EDU>
  7. Posting-number: Volume 14, Issue 20
  8. Archive-name: vplot/part15
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 15 (of 24)."
  17. # Wrapped by rsalz@fig.bbn.com on Fri Mar 25 11:47:25 1988
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'Virtual_device/vplib/vppen.mn' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'Virtual_device/vplib/vppen.mn'\"
  21. else
  22. echo shar: Extracting \"'Virtual_device/vplib/vppen.mn'\" \(9204 characters\)
  23. sed "s/^X//" >'Virtual_device/vplib/vppen.mn' <<'END_OF_FILE'
  24. X.TH Vppen 9 "February 12 1988"
  25. X.SH NAME
  26. vppen \- VPLOT filter for VPLOT
  27. X.PP
  28. X.SH SYNOPSIS
  29. vppen  plot_file1 [plot_file2 ...] [options] > vplot_out
  30. X.PP
  31. Seplib version: Vppen < Plot1.h [Plot2.h ...] [options] > Vplot_out.h
  32. X.PP
  33. X.SH DESCRIPTION
  34. All
  35. X.B pen
  36. filters accept input in the
  37. X.B vplot
  38. graphical metalanguage.
  39. X.B Vppen
  40. is the filter for the ``virtual vplot device''.
  41. Both its input and output are vplot. Why is this useful?
  42. The full set of pen options allows you
  43. to rotate, combine, clip, scale, shift, etc, plots. At some point you may
  44. make something on your screen using these options which
  45. you would really like to have as a single
  46. file. How to do this? Simply use the same set of options with vppen.
  47. Vppen will draw the same picture, but will save the picture as a vplot file.
  48. You can then rotate, combine, clip, etc this new plot.
  49. X.PP
  50. Vppen also has options to do useful things such as centering, making
  51. arrays of plots, and finding plot statistics.
  52. X.PP
  53. X.SH VIRTUAL DEVICE DESCRIPTION
  54. The virtual vplot device has a screen 10.24 inches (STANDARD_HEIGHT in <vplot.h>)
  55. high, with a height/width ratio of 3/4 (SCREEN_RATIO in <vplot.h>). It has
  56. X600 pixels to the inch (RPERIN), and has 256 colors, all settable.
  57. It knows how to do its own clipping and has ``hardware text'', etc.
  58. This is the device that vppen ``plots'' on.
  59. X.PP
  60. Ideally vplot coming into
  61. vppen with no options set should be passed on through completely unchanged.
  62. This is true (except for a few exceptions like polygon fill patterns and such)
  63. if both the input and output are absolute style. (If you don't know what
  64. terms like ``absolute style'' mean, read the other vplot documentation.)
  65. For this reason, vppen by default uses ``size=absolute'' and outputs absolute style
  66. output. This is convenient if you are repeatedly sending files through
  67. vppen, but you may want to override it otherwise.
  68. X.PP
  69. X.SH GENERIC OPTIONS
  70. X.PP
  71. For a list of all generic
  72. pen options, which also apply to vppen, do ``man pen''.
  73. Generic options that you may find particularly useful are:
  74. X.PP
  75. X.TP
  76. X.B erase
  77. The erase=once option is useful when combining several plots into one.
  78. X(Otherwise you're likely to have the entire screen cleared before each plot.)
  79. X.PP
  80. X.TP
  81. X.B xshift, yshift
  82. These options are useful for positioning a plot.
  83. X.PP
  84. X.TP
  85. X.B scale
  86. The scale options are useful in getting a plot the right size.
  87. X.PP
  88. X.TP
  89. X.B frame
  90. Useful for putting a box around the edge of the clipping window.
  91. X.PP
  92. X.TP
  93. X.B xwmin, xwmax, ywmin, ywmax
  94. Useful for clipping out just the part of the plot you want.
  95. X.PP
  96. X.TP
  97. X.B rotate
  98. Useful for rotating a plot, usually by 90 degrees.
  99. X.PP
  100. Remember that ALL generic pen options apply, not just the ones listed
  101. above.
  102. Only vppen-specific options will be covered in the next section.
  103. X.PP
  104. X.SH VPPEN-SPECIFIC OPTIONS
  105. X.PP
  106. X.TP 
  107. X.B gridnum=0 gridsize= grid=-1
  108. These commands are provided as a quick way to make a grid of plots.
  109. Gridnum=X,Y divides the output screen into X rectangles
  110. horizontally and Y rectangles vertically. If Y is not specified, then
  111. it is set equal to X. If X is zero, then gridding is not done.
  112. Gridsize=X,Y sets the X and Y dimensions of each rectangle
  113. in inches.
  114. If the gridsize is not set, then the array of rectangles will be sized to
  115. fill the screen.
  116. Grid sets the fatness of a white border drawn around each rectangle.
  117. If it is negative, no border will be drawn.
  118. Each rectangle is its own miniature device screen. Clipping is set
  119. to the edges of this screen just as it is for the full-sized screen.
  120. All generic commands such as rotate, xshift, etc, will apply to each
  121. rectangle and NOT to the plot as a whole.
  122. Each rectangle contains one (or zero) plot. When an erase command is received,
  123. nothing will be erased but instead plotting will begin in the next rectangle,
  124. and a ``break'' command will be output.
  125. The rectangles are filled left to right and then top to bottom. It is not
  126. an error to have more plots that you have room for, the rectangles will
  127. march right off the bottom of the page, but they will still be there.
  128. If you have less plots than you have room for some of the rectangles will
  129. be empty. Normally the generic pen option ``size'' defaults to ``absolute''
  130. in vppen, as it does on most hardcopy devices. This doesn't work very well
  131. if your screen is a few inches on a side, so if the gridnum option is used
  132. X``size'' will instead default to the normal screen-device default ``relative''.
  133. For similar reasons, the gridnum option will also change the default options
  134. to ``big=n'' and ``vpstyle=n''.
  135. You may find it useful to use size=relative when plotting a gridded vplot file.
  136. X.PP
  137. X.TP
  138. X.B big=y
  139. If big=y, the output screen is expanded to the entire range of possible
  140. vplot coordinates, -54.6 to +54.6 inches (VP_MAX in <vplot.h>) in each
  141. direction. A coordinate shift is thrown in to move the origin back to (0,0)
  142. where it belongs. This has some good effects and some bad effects.
  143. The chief good effect is that nothing is clipped at the edge of the
  144. screen, since the ``screen'' contains all possible vplot coordinates.
  145. X(It is still possible for things to be clipped, but only at
  146. the edge of the vplot coordinate system.)
  147. The chief bad effect is that rotated style objects will be positioned at the
  148. top of the expanded screen, which is to say 54 inches away from the origin
  149. and right at the edge of the largest coordinates vplot can handle.
  150. Thus big=y with rotated style input is an all around bad idea; the
  151. solution is to make one pass through vppen with big=n to turn it
  152. into non-rotated style. Another bad thing to do is to try to mix big=y
  153. with size=relative. You get a very big plot indeed!
  154. X.PP
  155. X.TP
  156. X.B stat=n
  157. If stat=y, no vplot will be written to standard out. Instead vppen will find
  158. the largest and smallest coordinates used in each input file and print
  159. out a summary of the height, width, etc, information. Statistics are also
  160. kept for all the input plots together as a whole.
  161. X.PP
  162. X.TP
  163. X.B align=uu
  164. This option is used to left, right, top, bottom, or center justify a plot.
  165. The format is align=xy, where ``x'' controls the left-right justification
  166. and ``y'' controls the up-down justification. ``X'' is one of:
  167. X.br
  168. X    l    for left justified
  169. X.br
  170. X    r    for right justified
  171. X.br
  172. X    c    for centered
  173. X.br
  174. X    u    for unaligned, (no shifting done)
  175. X.br
  176. and ``Y'' is one of:
  177. X.br
  178. X    b    for bottom justified
  179. X.br
  180. X    t    for top justified
  181. X.br
  182. X    c    for centered
  183. X.br
  184. X    u    for unaligned, (no shifting done)
  185. X.br
  186. X
  187. The align point is set to have coordinate (0,0). Note that points shifted
  188. into negative coordinates are still there, they just may be off the
  189. screen. (Use the big=y option to avoid clipping problems.)
  190. The ``xcenter=0, ycenter=0'' option is very handy to use when
  191. plotting ``aligned'' files.
  192. X.PP
  193. X.TP
  194. X.B vpstyle=y
  195. Normally vppen inserts a ``set style absolute'' vplot command at the beginning
  196. of every plot frame. If vpstyle=n, it does not do this.
  197. X.PP
  198. X.TP
  199. X.B dumb=n
  200. If dumb=y, then all output will be digested down to the bare essentials -
  201. color changes, erases, moves, draws, and nothing else.
  202. X.PP
  203. X.TP
  204. X.B blast=y bit=0
  205. If blast=n, then raster output will be compacted as much as possible as it
  206. is being written. This is slower, but the resulting file may be substantially
  207. smaller. If bit=integer > 0, then bit raster will be used, with the integer
  208. giving the color number of the ``on'' pixels.
  209. X.PP
  210. X.SH COMMENTS
  211. X.PP
  212. Some options (stat, align) will not work with piped input, as they involve
  213. making repeated passes through the input vplot files.
  214. X.PP
  215. Beware letting vppen dump raw binary vplot to your screen!
  216. X.PP
  217. Vppen outputs an initial erase only if an initial erase is forced from the
  218. command line (erase=yes (the default) or erase=once).
  219. X.PP
  220. Set the text font, precision, etc, that you want on your first pass
  221. through vppen, because it will be hardwired after that.
  222. X.PP
  223. Some vplot commands as yet have no corresponding command in libvplot, and
  224. so vppen currently eats these. Provisions are made in the code for the
  225. day when these commands will exist; they just have to be uncommented out.
  226. X.PP
  227. Vppen has four uses. One is as a sort of cheap vplot editor. The second
  228. is as a filter for digesting complicated things into the bare essential
  229. moves and draws. The third is that it provides a library of routines
  230. that can be linked into other vplot filters (perhaps an interactive vplot
  231. editor), so that they can easily ``dump a hardcopy of the screen''.
  232. X(The code has been carefully written with this in mind.)
  233. Lastly, it provides an example of how to do several tricky things:
  234. First, how to support a device that can do
  235. EVERYTHING in ``hardware'', and so needs to have the highest possible
  236. level of support. Second, how to do multiple passes through the vplot
  237. input (again something paving the way for a vplot editor).
  238. Third, how to find the length of
  239. a text string without actually drawing it.
  240. X.PP
  241. X.SH SEE ALSO
  242. pen, libvplot, vplot
  243. X.PP
  244. X.SH COPYRIGHT
  245. The Vplot source is copyrighted. Please read the copyright which can be
  246. found in the accompanying Vplot manual page.
  247. X.PP
  248. X.SH AUTHOR
  249. Joe Dellinger
  250. X.PP
  251. X.SH BUGS
  252. It is not clear how options such as ``stat'', ``align'', and ``gridnum''
  253. behave when used in combination. Absolute sizing can be a pain.
  254. There are still rotated style plots in common use, which have problems
  255. with big=y.
  256. END_OF_FILE
  257. if test 9204 -ne `wc -c <'Virtual_device/vplib/vppen.mn'`; then
  258.     echo shar: \"'Virtual_device/vplib/vppen.mn'\" unpacked with wrong size!
  259. fi
  260. # end of 'Virtual_device/vplib/vppen.mn'
  261. fi
  262. if test -f 'Vplot_Kernel/Documentation/vplotraster.mn' -a "${1}" != "-c" ; then 
  263.   echo shar: Will not clobber existing file \"'Vplot_Kernel/Documentation/vplotraster.mn'\"
  264. else
  265. echo shar: Extracting \"'Vplot_Kernel/Documentation/vplotraster.mn'\" \(9882 characters\)
  266. sed "s/^X//" >'Vplot_Kernel/Documentation/vplotraster.mn' <<'END_OF_FILE'
  267. X.TH vplot_raster 9 "4 June 1987"
  268. X.SH "NAME"
  269. vplot raster \- A guide to using raster plotting commands in vplot graphics
  270. X
  271. X.SH "DESCRIPTION"
  272. Despite the name
  273. X.B vplot
  274. X(where the `v' once stood for `vector')
  275. the vplot metalanguage includes raster plotting capability.
  276. This document describes more detailed aspects of raster plotting
  277. than are included in the
  278. X.B vplot
  279. manual page.
  280. X.PP
  281. A raster is a rectangular array of bytes.
  282. The value stored in each byte
  283. determines the number of the color that is to be displayed
  284. at the corresponding location in the raster.
  285. The mapping of array values to colors
  286. is set up by the programmer by calling the
  287. X.B vp_coltab()
  288. routine, which may be found in
  289. X.B libvplot.a.
  290. To define a color using
  291. X.B vp_coltab(),
  292. the red, green, and blue components of the color are each specified
  293. as floats from 0. to 1., with 1. being fully on and 0. being fully off.
  294. The corresponding `grey level' for grey-scale
  295. devices is given by the formula
  296. floor((4 * green + 2 * red + blue + 6)/7).
  297. X.PP
  298. Each device has a number of settable colors (call this number N).
  299. Calling
  300. X.B vp_coltab()
  301. for colors 0 through N-1 will redefine the desired color.
  302. If you attempt to define a color X outside of the range 0 through N-1,
  303. X.B vplot
  304. will pick the color number in the range 0 through N-1 that is closest
  305. to color X in color and map all requests for color X to that color number. 
  306. Whenever any color in the range 0 through N-1 is changed,
  307. all the mappings will be recalculated
  308. X(although of course what is already drawn cannot be changed).
  309. Note that color 0 is the background color.
  310. Other colors will be mapped to color 0 only if the match is exact.
  311. X.PP
  312. As an example, consider the common case where an eight bit per pixel
  313. raster is to be displayed using a grey scale, ranging from black to white,
  314. and various colors are to be used to display labels on the plot.
  315. The calling program should call
  316. X.B vp_coltab
  317. to allocate the first few color numbers to the label colors,
  318. then fill the remainder of the lower half of the color scale
  319. X(up to color 255)
  320. with the needed grey scale colors.
  321. Because different devices have different numbers of settable colors,
  322. it is important to order the grey scale colors so that the most important
  323. ones such as black (0, 0, 0), white (1, 1, 1), and medium grey
  324. X(.5, .5, .5) come first.
  325. Then whatever the number of settable colors,
  326. the raster reproduction will be as good as possible.
  327. More explicitly,
  328. the calling program should repeatedly cover the 0 to 1 range
  329. with a decreasing step size,
  330. taking care not to repeat colors, i.e.,
  331. X(0, 0, 0),
  332. X(1, 1, 1),
  333. X(.5, .5, .5),
  334. X(.25, .25, .25),
  335. X(.75, .75, .75),
  336. X(.125, .125, .125),
  337. X(.375, .375, .375),
  338. etc.
  339. Then in the upper half of the color scale (colors 256 through 511),
  340. the calling program can define the grey scale colors
  341. corresponding to the raster array values,
  342. setting, for example,
  343. color 256 to (0, 0, 0),
  344. color 257 to (1./255., 1./255., 1./255.),
  345. color 258 to (2./255., 2./255., 2./255.),..., and
  346. color 511 to (1, 1, 1).
  347. The 
  348. X.B offset
  349. parameter in
  350. X.B vp_raster
  351. is used to reference these colors.
  352. For this example,
  353. X.B offset=256
  354. would be the appropriate specification.
  355. Then for each value in the raster array,
  356. X.B vplot
  357. adds 256 to it to find the grey scale color defined for that value,
  358. then (using the mapping to available colors) uses the available color
  359. that best matches the requested color to plot that raster element.
  360. X.PP
  361. Monochrome devices such as plotters are unable to give a good
  362. representation of grey rasters because of the lack of definable colors.
  363. For such devices,
  364. X.B vplot
  365. can dither the image to simulate a grey or continuous-tone image.
  366. Briefly, dithering methods represent
  367. a continuous-tone image on a bilevel display
  368. by varying the threshold value that determines
  369. whether a given output pixel is set to `on' or `off'
  370. given its value on input. 
  371. Consider the above example of an eight bit per pixel raster.
  372. This means that, on an appropriate graphics display,
  373. each pixel can take on any of 256 different intensity levels.
  374. The task of dithering is to represent such an image
  375. on a device that has only two different intensity levels.
  376. A crude way of transforming from continuous-tone to bilevel form
  377. would be to divide the continuous-tone intensity range in half,
  378. and set input intensities 0-.5 to `off' and .5-1 to `on'. 
  379. But this would neglect most of the continuous-tone information.
  380. Vplot has four better ways of performing this transformation built in.
  381. X.PP
  382. X.B Random dither
  383. randomly selects a threshold value for determining whether a given output
  384. pixel is set to `on' or `off'.
  385. This preserves much of the continuous-tone information,
  386. but gives a rather `noisy' image,
  387. since within a constant-intensity region of the raster,
  388. some pixels will be set to both `on' and `off' due to the random thresholds.
  389. X.PP
  390. X.B Ordered dither
  391. applies a sixteen by sixteen matrix of threshold values to the input
  392. image in checkerboard fashion.
  393. This gives a much more regular appearance on output. 
  394. X.PP
  395. The
  396. X.B minimized average error method 
  397. or
  398. X.B Floyd-Steinberg algorithm 
  399. takes the `error' in converting a single pixel to bilevel form
  400. into account when converting neighbors,
  401. with the goal of minimizing the difference
  402. between the continuous-tone and bilevel images.
  403. This method generally produces the best representation of the original image,
  404. though it is the slowest of the four algorithms.
  405. X.PP
  406. X.B Digital halftoning
  407. is an ordered-dither scheme that is designed for images that are
  408. going to be reproduced photographically. The high-frequency alternation
  409. of black and white samples that is used to produce grey levels in
  410. ordered dither is not reproduced faithfully by photocopiers.
  411. This algorithm uses lower-frequency alternation of samples to produce
  412. the same grey level. While the resulting image has a coarser texture,
  413. it will be reproduced accurately. This method is only recommended for
  414. images that will be reproduced photographically.
  415. X.PP
  416. The dithering method can be selected by use of the 
  417. X.B dither 
  418. parameter with any
  419. X.B pen
  420. filter.
  421. The available dithering methods are:
  422. X.br
  423. X             0    No dither (0=off, anything else=on)
  424. X.br
  425. X             1    Random Dither
  426. X.br
  427. X             2    Ordered Dither
  428. X.br
  429. X             3    Minimized Average Error Method
  430. X.br
  431. X             4    Digital Halftoning
  432. X.PP
  433. Dithered output can be displayed on polytone or color devices by specifying 
  434. X.B mono=y 
  435. in the
  436. X.B pen
  437. filter call.
  438. X.PP
  439. On a typical graphics display, a linear grey scale has a nonlinear
  440. appearance.  The transition from black to white is more rapid than expected,
  441. leaving the scale clipped at both ends.  This perceived nonlinearity is
  442. due to the characteristics of the human eye, which sees a linear change
  443. in brightness as a logarithmic change, as well as to the display characteristics
  444. of the device being used.  When a grey scale is displayed on paper using
  445. the dithering methods described above, the nonlinearity is no longer
  446. present.  Such images seem to have a washed out appearance because of
  447. the relative scarcity of pure black and white shades.  The nonlinearity
  448. of display devices seems to be a useful feature that one might wish to
  449. duplicate on paper.  The pen filter parameter
  450. X.B greyc
  451. X(short for `grey correction') modifies the grey scale used to display a
  452. raster to simulate the nonlinearity of displays.  The grey scale is
  453. multiplied by a cubic polynomial with greyc determining the exact shape
  454. of the polynomial.  The function has been constructed such that the ends
  455. and middle of the grey scale are left undisturbed, but on either side of
  456. the middle the grey scale is skewed towards the end of the scale (black or
  457. white).  Greyc=1. leaves the grey scale undisturbed, and values smaller than
  458. X1. skew the scale as described above.  We have found greyc=-0.5 to yield
  459. plots on our Imagen laser printer that are very similar to images displayed
  460. on our Rastertek graphics display.  Some experimentation is undoubtedly
  461. required for other devices.  Once a desirable value has been obtained for
  462. a particular device, that value should be made the default for the particular
  463. device.
  464. X.PP
  465. A further complication with plotting raster images is the dot size used
  466. by the plotter.  In displaying a linear grey scale on our laser printer,
  467. we found the result to be much darker than expected, especially in the
  468. darker half of the scale.  Our hypothesis is that the plotter causes
  469. adjacent dots to overlap.  When the image is mostly white (as in the white
  470. end of the grey scale), this overlap is not very important, since it is
  471. rare that a given empty spot is surrounded by black dots.  However, in the
  472. black half of the grey scale, white places in the plotted
  473. image are usually surrounded by black dots, and the overlap causes the
  474. white space to be much smaller than expected.  Hence the plot is darker
  475. than expected. 
  476. X.PP
  477. From this hypothesis, we have constructed a function that alters the
  478. grey scale to compensate for dot or pixel overlap.  The
  479. X.B pixc
  480. X(short for `pixel correction') parameter controls this alteration of the
  481. grey scale.  Pixc=1. leaves the grey scale undisturbed.  Values smaller
  482. than 1. shift all the grey values toward white in such a way as to
  483. compensate for the
  484. darkening that results from pixel overlap.  The shift is larger for the
  485. dark half of the grey scale, since (from the above discussion) it is more
  486. seriously affected by pixel overlap.  We have found pixc=0.6 to be an
  487. appropriate value for our Imagen laser printer.  This value gives accurate
  488. reproduction of a linear grey scale.
  489. X.PP
  490. As with the greyc parameter, once a suitable value has been obtained for
  491. a particular printer, the appropriate value should be made the default
  492. for that device.
  493. X.SH COPYRIGHT
  494. The Vplot source code is copyrighted. Please read the copyright notice which
  495. can be found in the Vplot manual page.
  496. X.SH "SEE ALSO"
  497. pen vplotlib vplot vplothacker
  498. X.SH "AUTHOR"
  499. Joe Dellinger and Steve Cole
  500. END_OF_FILE
  501. if test 9882 -ne `wc -c <'Vplot_Kernel/Documentation/vplotraster.mn'`; then
  502.     echo shar: \"'Vplot_Kernel/Documentation/vplotraster.mn'\" unpacked with wrong size!
  503. fi
  504. # end of 'Vplot_Kernel/Documentation/vplotraster.mn'
  505. fi
  506. if test -f 'Vplot_Kernel/util/plas.c' -a "${1}" != "-c" ; then 
  507.   echo shar: Will not clobber existing file \"'Vplot_Kernel/util/plas.c'\"
  508. else
  509. echo shar: Extracting \"'Vplot_Kernel/util/plas.c'\" \(11419 characters\)
  510. sed "s/^X//" >'Vplot_Kernel/util/plas.c' <<'END_OF_FILE'
  511. X/*
  512. X * Copyright 1987 the Board of Trustees of the Leland Stanford Junior
  513. X * University. Official permission to use this software is included in
  514. X * the documentation. It authorizes you to use this file for any
  515. X * non-commercial purpose, provided that this copyright notice is not
  516. X * removed and that any modifications made to this file are commented
  517. X * and dated in the style of my example below.
  518. X */
  519. X
  520. X/*
  521. X *
  522. X *  source file:   ./util/plas.c
  523. X *
  524. X * Joe Dellinger (SEP), June 11 1987
  525. X *    Inserted this sample edit history entry.
  526. X *    Please log any further modifications made to this file:
  527. X */
  528. X
  529. char           *documentation[] =
  530. X{
  531. X "",
  532. X "",
  533. X "NAME",
  534. X "        plas     (PLot ASsembler) -- deformat vector plot commands",
  535. X "SYNOPSIS",
  536. X "        plas < asciifile > binaryfile",
  537. X "------------------------------------------------------------------------",
  538. X "    Reads stdin; writes stdout.  Complement to 'pldb'.",
  539. X "    Converts vplot-language files in ascii (human-readable) form",
  540. X "    into the hybrid ascii/binary form that the 'pen' filters understand.",
  541. X "",
  542. X "   A backslash at the end of a line of text allows multi-line text strings.",
  543. X "Options",
  544. X "      -v: Use vplot units (the default)",
  545. X "      -i: Use inches",
  546. X "      -c: Use centimeters",
  547. X "  Note that these options apply to ALL geometric attributes,",
  548. X "  including line width and character height scale factors.",
  549. X "",
  550. X "The default may be set within the file by having as the first line",
  551. X "#plas: X",
  552. X "where X is one of V, C, or I for Vplot, Cm, or Inches",
  553. X "SEE ALSO",
  554. X "    manual entries for vplot, pen;  self-documentation for pldb."
  555. X};
  556. int             doclength =
  557. X{
  558. X sizeof documentation / sizeof documentation[0]
  559. X};
  560. X
  561. X#include    <stdio.h>
  562. X#include    <sys/ioctl.h>
  563. X#include    <sgtty.h>
  564. X#include    <ctype.h>
  565. X#include    <vplot.h>
  566. X#include    "params.h"
  567. X#include    "round.h"
  568. X
  569. X#define MAXLINE 24*84
  570. X#define NL  '\n'
  571. X
  572. struct sgttyb   ttystat;
  573. FILE           *
  574. fopen (), *fdopen ();
  575. X
  576. main (argc, argv)
  577. X    int             argc;
  578. X    char           *argv[];
  579. X{
  580. int             xargc;
  581. char          **xargv;
  582. char           *cptr;
  583. char            c, a;
  584. int             npat, ix, iy, iz, npts, mtype, orient, col_tab_no, maskx, masky, col;
  585. int             nmul, nx, ny, ipat, i, j;
  586. float           x, y, msize, size, fat, red, green, blue, off, rep;
  587. float           xmin, ymin, xmax, ymax;
  588. int             piped_in;
  589. char            line[MAXLINE];
  590. float           scale, txvecscale, txscale, fatscale, colscale, hscale;
  591. float           xcor, ycor, xvplot, yvplot;
  592. int             count;
  593. int             xpix, ypix, num_pat, num_byte;
  594. int             ibyte, byte, num_rep;
  595. int             ras_offset, ras_orient;
  596. int             line_count;
  597. X
  598. X    npat = 0;
  599. X
  600. X    /*
  601. X     * If no arguments, and not in a pipeline, self document 
  602. X     */
  603. X    piped_in = ioctl ((fileno (stdin)), TIOCGETP, &ttystat);
  604. X    if (argc == 1 && !piped_in)
  605. X    {
  606. X    for (i = 0; i < doclength; i++)
  607. X        printf ("%s\n", documentation[i]);
  608. X    exit (0);
  609. X    }
  610. X
  611. X/*
  612. X * Default to vplot units
  613. X */
  614. X    fatscale = 1.;
  615. X    txvecscale = 1.;
  616. X    txscale = 1.;
  617. X    scale = 1.;
  618. X    colscale = 1.;
  619. X    hscale = 1.;
  620. X
  621. X    xargc = argc;
  622. X    xargv = argv;
  623. X    for (xargc--, xargv++; xargc; xargc--, xargv++)
  624. X    {
  625. X    cptr = *xargv;
  626. X    if (*cptr == '-')
  627. X    {
  628. X        while (*(++cptr))
  629. X        {
  630. X        switch (*cptr)
  631. X        {
  632. X        case 'v':
  633. X/*
  634. X * Vplot units
  635. X */
  636. X            fatscale = 1.;
  637. X            txvecscale = 1.;
  638. X            txscale = 1.;
  639. X            scale = 1.;
  640. X            colscale = 1.;
  641. X            hscale = 1;
  642. X            break;
  643. X        case 'c':
  644. X/*
  645. X * Centimeters
  646. X */
  647. X            fatscale = FATPERIN / 2.54;
  648. X            txvecscale = TEXTVECSCALE;
  649. X            txscale = TXPERIN / 2.54;
  650. X            scale = RPERIN / 2.54;
  651. X            colscale = MAX_GUN;
  652. X            hscale = RPERIN / 2.54;
  653. X            break;
  654. X        case 'i':
  655. X/*
  656. X * Inches
  657. X */
  658. X            fatscale = FATPERIN;
  659. X            txvecscale = TEXTVECSCALE;
  660. X            txscale = TXPERIN;
  661. X            scale = RPERIN;
  662. X            colscale = MAX_GUN;
  663. X            hscale = RPERIN;
  664. X            break;
  665. X        default:
  666. X            break;
  667. X        }
  668. X        }
  669. X    }
  670. X    }
  671. X
  672. X/* main switch loop    */
  673. X
  674. X    line_count = 0;
  675. X    while (fgets (line, MAXLINE, stdin) != NULL)
  676. X    {
  677. X    c = line[0];
  678. X    line_count++;
  679. X    switch (c)
  680. X    {
  681. X    case '#':
  682. X        if (line_count == 1)
  683. X        {
  684. X        if (strncmp (line, "#plas: ", 7) == 0)
  685. X        {
  686. X            switch (line[7])
  687. X            {
  688. X            case 'V':
  689. X            case 'v':
  690. X            fatscale = 1.;
  691. X            txvecscale = 1.;
  692. X            txscale = 1.;
  693. X            scale = 1.;
  694. X            colscale = 1.;
  695. X            hscale = 1;
  696. X            break;
  697. X            case 'I':
  698. X            case 'i':
  699. X            fatscale = FATPERIN;
  700. X            txvecscale = TEXTVECSCALE;
  701. X            txscale = TXPERIN;
  702. X            scale = RPERIN;
  703. X            colscale = MAX_GUN;
  704. X            hscale = RPERIN;
  705. X            break;
  706. X            case 'C':
  707. X            case 'c':
  708. X            fatscale = FATPERIN / 2.54;
  709. X            txvecscale = TEXTVECSCALE;
  710. X            txscale = TXPERIN / 2.54;
  711. X            scale = RPERIN / 2.54;
  712. X            colscale = MAX_GUN;
  713. X            hscale = RPERIN / 2.54;
  714. X            break;
  715. X            }
  716. X        }
  717. X        }
  718. X        break;
  719. X    case VP_MESSAGE:
  720. X        putc (c, stdout);
  721. X        text ();
  722. X        break;
  723. X    case VP_SETSTYLE:
  724. X        sscanf (line, "%*c %c", &a);
  725. X        putc (c, stdout);
  726. X        putc (a, stdout);
  727. X        break;
  728. X    case VP_ERASE:
  729. X    case VP_PURGE:
  730. X    case VP_BREAK:
  731. X    case VP_NOOP:
  732. X        putc (c, stdout);
  733. X        break;
  734. X    case VP_TXALIGN:
  735. X        putc (c, stdout);
  736. X        sscanf (line, "%*c %d %d", &ix, &iy);
  737. X        puth (ix, stdout);
  738. X        puth (iy, stdout);
  739. X        break;
  740. X    case VP_ORIGIN:
  741. X    case VP_MOVE:
  742. X    case VP_DRAW:
  743. X        putc (c, stdout);
  744. X        sscanf (line, "%*c %f %f", &x, &y);
  745. X        puth (ROUND (x * scale), stdout);
  746. X        puth (ROUND (y * scale), stdout);
  747. X        break;
  748. X    case VP_TXFONTPREC:
  749. X        putc (c, stdout);
  750. X        sscanf (line, "%*c %d %d %d", &ix, &iy, &iz);
  751. X        puth (ix, stdout);
  752. X        puth (iy, stdout);
  753. X        puth (iz, stdout);
  754. X        break;
  755. X    case VP_PLINE:
  756. X    case VP_SETDASH:
  757. X        putc (c, stdout);
  758. X        sscanf (line, "%*c %d", &npts);
  759. X        puth (npts, stdout);
  760. X        while (npts--)
  761. X        {
  762. X        gets (line);
  763. X        sscanf (line, "%f %f", &x, &y);
  764. X        puth (ROUND (x * scale), stdout);
  765. X        puth (ROUND (y * scale), stdout);
  766. X        }
  767. X        break;
  768. X    case VP_PMARK:
  769. X        putc (c, stdout);
  770. X        sscanf (line, "%*c %d %d %f", &npts, &mtype, &msize);
  771. X        puth (npts, stdout);
  772. X        puth (mtype, stdout);
  773. X        puth (ROUND (msize * txscale), stdout);
  774. X        while (npts--)
  775. X        {
  776. X        gets (line);
  777. X        sscanf (line, "%f %f", &x, &y);
  778. X        puth (ROUND (x * scale), stdout);
  779. X        puth (ROUND (y * scale), stdout);
  780. X        }
  781. X        break;
  782. X    case VP_BEGIN_GROUP:
  783. X        putc (c, stdout);
  784. X        text ();
  785. X        break;
  786. X    case VP_END_GROUP:
  787. X        putc (c, stdout);
  788. X        break;
  789. X    case VP_OLDTEXT:
  790. X    case VP_TEXT:
  791. X        putc ((char) VP_TEXT, stdout);
  792. X        sscanf (line, "%*c %f %d", &size, &orient);
  793. X        puth (ROUND (size * txscale), stdout);
  794. X        if (c == VP_OLDTEXT)
  795. X        orient *= 90;
  796. X        puth (orient, stdout);
  797. X        text ();
  798. X        break;
  799. X    case VP_GTEXT:
  800. X        putc (c, stdout);
  801. X        sscanf (line, "%*c %f %f %f %f", &x, &y, &xcor, &ycor);
  802. X        puth (ROUND (x * scale * txvecscale), stdout);
  803. X        puth (ROUND (y * scale * txvecscale), stdout);
  804. X        puth (ROUND (xcor * scale * txvecscale), stdout);
  805. X        puth (ROUND (ycor * scale * txvecscale), stdout);
  806. X        text ();
  807. X        break;
  808. X    case VP_COLOR:
  809. X    case VP_OVERLAY:
  810. X        putc (c, stdout);
  811. X        sscanf (line, "%*c %d", &ix);
  812. X        puth (ix, stdout);
  813. X        break;
  814. X    case VP_SET_COLOR_TABLE:
  815. X        putc (c, stdout);
  816. X        sscanf (line, "%*c %d %f %f %f",
  817. X            &col_tab_no, &red, &green, &blue);
  818. X        puth (col_tab_no, stdout);
  819. X        puth (ROUND (red * colscale), stdout);
  820. X        puth (ROUND (green * colscale), stdout);
  821. X        puth (ROUND (blue * colscale), stdout);
  822. X        break;
  823. X    case VP_FAT:
  824. X        putc (c, stdout);
  825. X        sscanf (line, "%*c %f", &fat);
  826. X        puth (ROUND (fat * fatscale), stdout);
  827. X        break;
  828. X    case VP_WINDOW:
  829. X        putc (c, stdout);
  830. X        sscanf (line, "%*c %f %f %f %f", &xmin, &ymin, &xmax, &ymax);
  831. X        puth (ROUND (scale * xmin), stdout);
  832. X        puth (ROUND (scale * ymin), stdout);
  833. X        puth (ROUND (scale * xmax), stdout);
  834. X        puth (ROUND (scale * ymax), stdout);
  835. X        break;
  836. X    case VP_OLDAREA:
  837. X        putc (c, stdout);
  838. X        sscanf (line, "%*c %d", &npts);
  839. X        fgets (line, MAXLINE, stdin);
  840. X        sscanf (line, "%f %d %d", &fat, &maskx, &masky);
  841. X        puth (npts, stdout);
  842. X        puth (ROUND (fat * fatscale), stdout);
  843. X        puth (maskx, stdout);
  844. X        puth (masky, stdout);
  845. X        for (i = 0; i < npts; i++)
  846. X        {
  847. X        fgets (line, MAXLINE, stdin);
  848. X        sscanf (line, "%f %f", &x, &y);
  849. X        puth (ROUND (x * scale), stdout);
  850. X        puth (ROUND (y * scale), stdout);
  851. X        }
  852. X        break;
  853. X    case VP_AREA:
  854. X        putc (c, stdout);
  855. X        sscanf (line, "%*c %d", &npts);
  856. X        puth (npts, stdout);
  857. X        for (i = 0; i < npts; i++)
  858. X        {
  859. X        fgets (line, MAXLINE, stdin);
  860. X        sscanf (line, "%f %f", &x, &y);
  861. X        puth (ROUND (scale * x), stdout);
  862. X        puth (ROUND (scale * y), stdout);
  863. X        }
  864. X        break;
  865. X    case VP_PATLOAD:
  866. X        npat++;
  867. X        ipat = 0;
  868. X        sscanf (line, "%*c %d %d %d %d", &nmul, &nx, &ny, &ipat);
  869. X        putc (c, stdout);
  870. X        puth (nmul, stdout);
  871. X        puth (nx, stdout);
  872. X        puth (ny, stdout);
  873. X        if (ipat == 0)
  874. X        {
  875. X        ipat = npat;
  876. X        }
  877. X        puth (ipat, stdout);
  878. X
  879. X        if (nx != -1)
  880. X        {
  881. X        for (i = 0; i < nx; i++)
  882. X        {
  883. char           *ptr;
  884. X            fgets (line, MAXLINE, stdin);
  885. X
  886. X            for (j = 0, ptr = line; j < ny; j++, *ptr++)
  887. X            {
  888. X            if (*ptr == NULL || *ptr == NL)
  889. X                fprintf (stderr, "null/nl");
  890. X            if (*ptr >= '0' && *ptr <= '9')
  891. X            {
  892. X                ipat = (*ptr) - '0';
  893. X            }
  894. X            else
  895. X            {
  896. X                ipat = (*ptr) - 'A' + 10;
  897. X            }
  898. X            puth (ipat, stdout);
  899. X            }
  900. X        }
  901. X        }
  902. X        else
  903. X        {
  904. X        for (i = 0; i < ny * 2; i++)
  905. X        {
  906. X            fgets (line, MAXLINE, stdin);
  907. X            sscanf (line, "%f %d %f %f", &fat, &col, &off, &rep);
  908. X            puth (ROUND (fat * fatscale), stdout);
  909. X            puth (col, stdout);
  910. X            puth (ROUND (off * hscale), stdout);
  911. X            puth (ROUND (rep * hscale), stdout);
  912. X        }
  913. X        }
  914. X        break;
  915. X    case VP_BYTE_RASTER:
  916. X    case VP_BIT_RASTER:
  917. X        {
  918. X
  919. X        sscanf (line, "%*c %d %d", &ras_orient, &ras_offset);
  920. X        putc (c, stdout);
  921. X        puth (ras_orient, stdout);
  922. X        puth (ras_offset, stdout);
  923. X        fgets (line, MAXLINE, stdin);
  924. X        sscanf (line, "%f %f", &xcor, &ycor);
  925. X        puth (ROUND (xcor * scale), stdout);
  926. X        puth (ROUND (ycor * scale), stdout);
  927. X        fgets (line, MAXLINE, stdin);
  928. X        sscanf (line, "%f %f", &xvplot, &yvplot);
  929. X        puth (ROUND (scale * xvplot), stdout);
  930. X        puth (ROUND (scale * yvplot), stdout);
  931. X        fgets (line, MAXLINE, stdin);
  932. X        sscanf (line, "%d %d", &xpix, &ypix);
  933. X        puth (xpix, stdout);
  934. X        puth (ypix, stdout);
  935. X
  936. X        for (j = 0; j < ypix;)
  937. X        {
  938. X            count = 0;
  939. X            fgets (line, MAXLINE, stdin);
  940. X            count = 0;
  941. X            sscanf (line, "%d", &num_rep);
  942. X            if (num_rep < 1)
  943. X            fprintf (stderr, "Bad Raster repetition factor\n");
  944. X            puth (num_rep, stdout);
  945. X        more_line:fgets (line, MAXLINE, stdin);
  946. X            sscanf (line, "%d %d", &num_pat, &num_byte);
  947. X            puth (num_pat, stdout);
  948. X            puth (num_byte, stdout);
  949. X            for (i = 0; i < num_byte; i++)
  950. X            {
  951. X            fgets (line, MAXLINE, stdin);
  952. X            sscanf (line, "%d", &byte);
  953. X            if (c == VP_BYTE_RASTER)
  954. X            {
  955. X                putc ((char) byte, stdout);
  956. X            }
  957. X            else
  958. X            {
  959. X                if (i % 8 == 0)
  960. X                ibyte = 0;
  961. X                ibyte |= ((byte != 0) << (7 - (i % 8)));
  962. X                if (i % 8 == 7 || i == num_byte - 1)
  963. X                putc ((char) ibyte, stdout);
  964. X            }
  965. X            }
  966. X            count += num_byte * num_pat;
  967. X            if (count < xpix)
  968. X            goto more_line;
  969. X            j += num_rep;
  970. X        }
  971. X        }
  972. X        break;
  973. X    default:
  974. X        ;            /* Treat unknown charactors as comments */
  975. X    }
  976. X    }
  977. X}
  978. X
  979. text ()
  980. X{
  981. char            c;
  982. X    do
  983. X    {
  984. X    c = getc (stdin);
  985. X    if (c == '\\')
  986. X    {
  987. X        if ((c = getc (stdin)) != '\n')
  988. X        {
  989. X        putc ('\\', stdout);
  990. X        }
  991. X        else
  992. X        continue;
  993. X    }
  994. X    else
  995. X    if (c == '\n')
  996. X        break;
  997. X    putc (c, stdout);
  998. X    } while (1);
  999. X    putc ('\0', stdout);
  1000. X}
  1001. END_OF_FILE
  1002. if test 11419 -ne `wc -c <'Vplot_Kernel/util/plas.c'`; then
  1003.     echo shar: \"'Vplot_Kernel/util/plas.c'\" unpacked with wrong size!
  1004. fi
  1005. # end of 'Vplot_Kernel/util/plas.c'
  1006. fi
  1007. if test -f 'Vplot_Kernel/util/pldb.c' -a "${1}" != "-c" ; then 
  1008.   echo shar: Will not clobber existing file \"'Vplot_Kernel/util/pldb.c'\"
  1009. else
  1010. echo shar: Extracting \"'Vplot_Kernel/util/pldb.c'\" \(10150 characters\)
  1011. sed "s/^X//" >'Vplot_Kernel/util/pldb.c' <<'END_OF_FILE'
  1012. X/*
  1013. X * Copyright 1987 the Board of Trustees of the Leland Stanford Junior
  1014. X * University. Official permission to use this software is included in
  1015. X * the documentation. It authorizes you to use this file for any
  1016. X * non-commercial purpose, provided that this copyright notice is not
  1017. X * removed and that any modifications made to this file are commented
  1018. X * and dated in the style of my example below.
  1019. X */
  1020. X
  1021. X/*
  1022. X *
  1023. X *  source file:   ./util/pldb.c
  1024. X *
  1025. X * Joe Dellinger (SEP), June 11 1987
  1026. X *    Inserted this sample edit history entry.
  1027. X *    Please log any further modifications made to this file:
  1028. X */
  1029. X
  1030. char           *documentation[] =
  1031. X{
  1032. X "",
  1033. X "",
  1034. X "NAME",
  1035. X "         pldb -- (PLot DeBugger) ",
  1036. X "SYNOPSIS",
  1037. X "        pldb < binaryfile > asciifile",
  1038. X "-------------------------------------------------------------------------",
  1039. X "    Reads the standard input stream, writes standard out",
  1040. X "",
  1041. X "    Input:     vplot metafile format (mixed ASCII and binary)",
  1042. X "    Output:    Human-readable representations of vplot vector plot",
  1043. X "        commands",
  1044. X "    plas returns pldb output to vplot format.",
  1045. X "    Useful with pen output filters.",
  1046. X "OPTIONS:",
  1047. X "      -v: use vplot units (default)",
  1048. X "      -i: use inches",
  1049. X "      -c: use centimeters",
  1050. X "  Note that these options apply to ALL geometric attributes,",
  1051. X "  including line width and character height.",
  1052. X "SEE ALSO",
  1053. X "     manual entries for 'vplot' and 'pen'; selfdoc for 'plas'."
  1054. X};
  1055. int             doclength =
  1056. X{
  1057. X sizeof documentation / sizeof documentation[0]
  1058. X};
  1059. X
  1060. X/*
  1061. X *  Various portions of this program were written by
  1062. X *  Jon Claerbout (Long long ago!),
  1063. X *  Jeff Thorson (1980-81?),  Michel Debiche (1982-84),
  1064. X *  Chuck Karish (1985),  and Joe Dellinger (1986-1987)
  1065. X *  of the Stanford University
  1066. X *  Departments of Geophysics and Geology.
  1067. X *
  1068. X *  Anybody want to clean this mess up?
  1069. X */
  1070. X
  1071. X#include    <stdio.h>
  1072. X#include    <sys/ioctl.h>
  1073. X#include    <sgtty.h>
  1074. X#include    <ctype.h>
  1075. X#include    <vplot.h>
  1076. X#include    "params.h"
  1077. X
  1078. struct sgttyb   ttystat;
  1079. FILE           *
  1080. fopen (), *fdopen ();
  1081. X
  1082. main (argc, argv)
  1083. X    int             argc;
  1084. X    char           *argv[];
  1085. X{
  1086. int             xargc;
  1087. char          **xargv;
  1088. char           *cptr;
  1089. char            c, a;
  1090. int             ix, iy, iz, npts, mtype, orient, col_tab_no, xmask, ymask, col;
  1091. int             nmul, nx, ny, ipat, i, j, ii, key, pos, bit;
  1092. float           x, y, msize, size, fat, red, green, blue, off, rep;
  1093. float           xmin, ymin, xmax, ymax;
  1094. int             piped_in;
  1095. float           scale, txvecscale, txscale, fatscale, colscale, hscale;
  1096. float           xcor, ycor, xvplot, yvplot;
  1097. int             xpix, ypix, num_pat, num_byte;
  1098. int             ibyte, byte, num_rep;
  1099. int             ras_offset, ras_orient;
  1100. int             which_units;
  1101. int             retstat = 0;
  1102. X
  1103. X    /*
  1104. X     * If no arguments, and not in a pipeline, self document 
  1105. X     */
  1106. X    piped_in = ioctl ((fileno (stdin)), TIOCGETP, &ttystat);
  1107. X    if (argc == 1 && !piped_in)
  1108. X    {
  1109. X    for (i = 0; i < doclength; i++)
  1110. X        printf ("%s\n", documentation[i]);
  1111. X    exit (0);
  1112. X    }
  1113. X
  1114. X/*
  1115. X * Default to vplots
  1116. X */
  1117. X    fatscale = 1.;
  1118. X    txvecscale = 1.;
  1119. X    txscale = 1.;
  1120. X    scale = 1.;
  1121. X    colscale = 1.;
  1122. X    hscale = 1.;
  1123. X    which_units = 'v';
  1124. X
  1125. X    xargc = argc;
  1126. X    xargv = argv;
  1127. X    for (xargc--, xargv++; xargc; xargc--, xargv++)
  1128. X    {
  1129. X    cptr = *xargv;
  1130. X    if (*cptr == '-')
  1131. X    {
  1132. X        while (*(++cptr))
  1133. X        {
  1134. X        switch (*cptr)
  1135. X        {
  1136. X        case 'v':
  1137. X/*
  1138. X * Vplot units
  1139. X */
  1140. X            fatscale = 1.;
  1141. X            txvecscale = 1.;
  1142. X            txscale = 1.;
  1143. X            scale = 1.;
  1144. X            colscale = 1.;
  1145. X            hscale = 1;
  1146. X            which_units = 'v';
  1147. X            break;
  1148. X        case 'c':
  1149. X/*
  1150. X * Centimeters
  1151. X */
  1152. X            fatscale = 1. / (FATPERIN / 2.54);
  1153. X            txvecscale = 1. / TEXTVECSCALE;
  1154. X            txscale = 1. / (TXPERIN / 2.54);
  1155. X            scale = 1. / (RPERIN / 2.54);
  1156. X            colscale = 1. / MAX_GUN;
  1157. X            hscale = 1. / (RPERIN / 2.54);
  1158. X            which_units = 'c';
  1159. X            break;
  1160. X        case 'i':
  1161. X/*
  1162. X * Inches
  1163. X */
  1164. X            fatscale = 1. / FATPERIN;
  1165. X            txvecscale = 1. / TEXTVECSCALE;
  1166. X            txscale = 1. / TXPERIN;
  1167. X            scale = 1. / RPERIN;
  1168. X            colscale = 1. / MAX_GUN;
  1169. X            hscale = 1. / RPERIN;
  1170. X            which_units = 'i';
  1171. X            break;
  1172. X        default:
  1173. X            break;
  1174. X        }
  1175. X        }
  1176. X    }
  1177. X    }
  1178. X
  1179. X    switch (which_units)
  1180. X    {
  1181. X    case 'v':
  1182. X    printf ("#plas: Vplot units used in this file\n");
  1183. X    break;
  1184. X    case 'c':
  1185. X    printf ("#plas: Centimeters used in this file\n");
  1186. X    break;
  1187. X    case 'i':
  1188. X    printf ("#plas: Inches used in this file\n");
  1189. X    break;
  1190. X    }
  1191. X
  1192. X    /* main switch statement */
  1193. X
  1194. X    while ((c = getc (stdin)) != EOF)
  1195. X    {
  1196. X    switch (c)
  1197. X    {
  1198. X    case VP_MESSAGE:
  1199. X        printf ("%c\n", c);
  1200. X        text ();
  1201. X        break;
  1202. X    case VP_SETSTYLE:
  1203. X        a = getchar ();
  1204. X        printf ("%c %c\n", c, a);
  1205. X        break;
  1206. X    case VP_ERASE:
  1207. X    case VP_BREAK:
  1208. X    case VP_PURGE:
  1209. X    case VP_NOOP:
  1210. X        printf ("%c\n", c);
  1211. X        break;
  1212. X    case VP_ORIGIN:
  1213. X    case VP_MOVE:
  1214. X    case VP_DRAW:
  1215. X        x = scale * geth (stdin);
  1216. X        y = scale * geth (stdin);
  1217. X        printf ("%c %g %g\n", c, x, y);
  1218. X        break;
  1219. X    case VP_TXALIGN:
  1220. X        ix = geth (stdin);
  1221. X        iy = geth (stdin);
  1222. X        printf ("%c %d %d\n", c, ix, iy);
  1223. X        break;
  1224. X    case VP_TXFONTPREC:
  1225. X        ix = geth (stdin);
  1226. X        iy = geth (stdin);
  1227. X        iz = geth (stdin);
  1228. X        printf ("%c %d %d %d\n", c, ix, iy, iz);
  1229. X        break;
  1230. X    case VP_PLINE:
  1231. X    case VP_SETDASH:
  1232. X        npts = geth (stdin);
  1233. X        printf ("%c %d\n", c, npts);
  1234. X        while (npts--)
  1235. X        {
  1236. X        x = scale * geth (stdin);
  1237. X        y = scale * geth (stdin);
  1238. X        printf ("%g %g\n", x, y);
  1239. X        }
  1240. X        break;
  1241. X    case VP_PMARK:
  1242. X        npts = geth (stdin);
  1243. X        mtype = geth (stdin);
  1244. X        msize = txscale * geth (stdin);
  1245. X        printf ("%c %d %d %g\n", c, npts, mtype, msize);
  1246. X        while (npts--)
  1247. X        {
  1248. X        x = scale * geth (stdin);
  1249. X        y = scale * geth (stdin);
  1250. X        printf ("%g %g\n", x, y);
  1251. X        }
  1252. X        break;
  1253. X    case VP_BEGIN_GROUP:
  1254. X        printf ("%c\n", c);
  1255. X        text ();
  1256. X        break;
  1257. X    case VP_END_GROUP:
  1258. X        printf ("%c\n", c);
  1259. X        break;
  1260. X    case VP_GTEXT:
  1261. X        x = scale * txvecscale * geth (stdin);
  1262. X        y = scale * txvecscale * geth (stdin);
  1263. X        xcor = scale * txvecscale * geth (stdin);
  1264. X        ycor = scale * txvecscale * geth (stdin);
  1265. X        printf ("%c %g %g %g %g\n", c, x, y, xcor, ycor);
  1266. X        text ();
  1267. X        break;
  1268. X    case VP_OLDTEXT:
  1269. X        key = geth (stdin);
  1270. X        size = txscale * (key & 037);
  1271. X        orient = (key & 0140) >> 5;
  1272. X        printf ("%c %g %d\n", VP_TEXT, size, 90 * orient);
  1273. X        text ();
  1274. X        break;
  1275. X    case VP_TEXT:
  1276. X        size = txscale * geth (stdin);
  1277. X        orient = geth (stdin);
  1278. X        printf ("%c %g %d\n", c, size, orient);
  1279. X        text ();
  1280. X        break;
  1281. X    case VP_OVERLAY:
  1282. X    case VP_COLOR:
  1283. X        ix = geth (stdin);
  1284. X        printf ("%c %d\n", c, ix);
  1285. X        break;
  1286. X    case VP_SET_COLOR_TABLE:
  1287. X        col_tab_no = geth (stdin);
  1288. X        red = colscale * geth (stdin);
  1289. X        green = colscale * geth (stdin);
  1290. X        blue = colscale * geth (stdin);
  1291. X        printf ("%c %d %g %g %g\n", c, col_tab_no, red, green, blue);
  1292. X        break;
  1293. X    case VP_FAT:
  1294. X        fat = fatscale * geth (stdin);
  1295. X        printf ("%c %g\n", c, fat);
  1296. X        break;
  1297. X    case VP_WINDOW:
  1298. X        xmin = scale * geth (stdin);
  1299. X        ymin = scale * geth (stdin);
  1300. X        xmax = scale * geth (stdin);
  1301. X        ymax = scale * geth (stdin);
  1302. X        printf ("%c %g %g %g %g\n", c, xmin, ymin, xmax, ymax);
  1303. X        break;
  1304. X    case VP_BIT_RASTER:
  1305. X    case VP_BYTE_RASTER:
  1306. X        ras_orient = geth (stdin);
  1307. X        ras_offset = geth (stdin);
  1308. X        printf ("%c %d %d\n", c, ras_orient, ras_offset);
  1309. X        xcor = scale * geth (stdin);
  1310. X        ycor = scale * geth (stdin);
  1311. X        printf ("%g %g\n", xcor, ycor);
  1312. X        xvplot = scale * geth (stdin);
  1313. X        yvplot = scale * geth (stdin);
  1314. X        printf ("%g %g\n", xvplot, yvplot);
  1315. X        xpix = geth (stdin);
  1316. X        ypix = geth (stdin);
  1317. X        printf ("%d %d\n", xpix, ypix);
  1318. X        for (i = 0; i < ypix; i += num_rep)
  1319. X        {
  1320. X        pos = 0;
  1321. X        num_rep = geth (stdin);
  1322. X        printf ("     %d  ------ lines %d to %d\n",
  1323. X            num_rep, i, i + num_rep - 1);
  1324. X    new_line:num_pat = geth (stdin);
  1325. X        num_byte = geth (stdin);
  1326. X        printf ("%d %d  -- start byte %d in y_line %d\n",
  1327. X            num_pat, num_byte, pos, i);
  1328. X        if (num_pat < 0 || num_byte < 0)
  1329. X        {
  1330. X            fprintf (stderr, "Error in raster field\n");
  1331. X            exit (1);
  1332. X        }
  1333. X        pos += num_byte * num_pat;
  1334. X        if (pos > xpix)
  1335. X        {
  1336. X            fprintf (stderr, "Error in raster field\n");
  1337. X            exit (1);
  1338. X        }
  1339. X
  1340. X        if (c == VP_BYTE_RASTER)
  1341. X        {
  1342. X            for (ii = 0; ii < num_byte; ii++)
  1343. X            {
  1344. X            byte = (int) getc (stdin);
  1345. X            if (byte == EOF)
  1346. X            {
  1347. X                fprintf (stderr, "Error in raster field\n");
  1348. X                exit (1);
  1349. X            }
  1350. X            printf ("%d\n", byte);
  1351. X            }
  1352. X        }
  1353. X        else
  1354. X        {
  1355. X            for (ii = 0; ii < num_byte; ii++)
  1356. X            {
  1357. X            if (ii % 8 == 0)
  1358. X            {
  1359. X                ibyte = (int) getc (stdin);
  1360. X            }
  1361. X            else
  1362. X            {
  1363. X                ibyte <<= 1;
  1364. X            }
  1365. X            printf ("%d\n", ((ibyte >> 7) & 001));
  1366. X            }
  1367. X        }
  1368. X        if (pos < xpix)
  1369. X            goto new_line;
  1370. X        }
  1371. X        break;
  1372. X    case VP_AREA:
  1373. X        {
  1374. X        npts = geth (stdin);
  1375. X        printf ("%c %d\n", c, npts);
  1376. X        for (i = 0; i < npts; i++)
  1377. X        {
  1378. X            x = scale * geth (stdin);
  1379. X            y = scale * geth (stdin);
  1380. X            printf ("%g %g\n", x, y);
  1381. X        }
  1382. X        }
  1383. X        break;
  1384. X    case VP_PATLOAD:
  1385. X        nmul = geth (stdin);
  1386. X        nx = geth (stdin);
  1387. X        ny = geth (stdin);
  1388. X        ipat = geth (stdin);
  1389. X        printf ("%c %d %d %d %d\n",
  1390. X            c, nmul, nx, ny, ipat);
  1391. X        if (nx == -1)
  1392. X        {
  1393. X        for (i = 0; i < ny * 2; i++)
  1394. X        {
  1395. X            fat = fatscale * geth (stdin);
  1396. X            col = geth (stdin);
  1397. X            off = hscale * geth (stdin);
  1398. X            rep = hscale * geth (stdin);
  1399. X            printf ("%g %d %g %g\n",
  1400. X                fat, col, off, rep);
  1401. X        }
  1402. X        }
  1403. X        else
  1404. X        {
  1405. X        for (i = 0; i < nx; i++)
  1406. X        {
  1407. X            for (j = 0; j < ny; j++)
  1408. X            {
  1409. X            bit = geth (stdin);
  1410. X            if (bit >= 0 && bit <= 9)
  1411. X            {
  1412. X                putc (bit + '0', stdout);
  1413. X            }
  1414. X            else
  1415. X            {
  1416. X                putc (bit + 'A' - 10, stdout);
  1417. X            }
  1418. X            }
  1419. X            putc ('\n', stdout);
  1420. X        }
  1421. X        }
  1422. X        break;
  1423. X    case VP_OLDAREA:
  1424. X        {
  1425. X        npts = geth (stdin);
  1426. X        printf ("%c %d\n", c, npts);
  1427. X        fat = fatscale * geth (stdin);
  1428. X        xmask = geth (stdin);
  1429. X        ymask = geth (stdin);
  1430. X        printf ("%g %d %d\n", fat, xmask, ymask);
  1431. X        for (i = 0; i < npts; i++)
  1432. X        {
  1433. X            x = scale * geth (stdin);
  1434. X            y = scale * geth (stdin);
  1435. X            printf ("%g %g\n", x, y);
  1436. X        }
  1437. X        }
  1438. X        break;
  1439. X    default:
  1440. X        printf ("******unknown command %c %o\n", c, c);
  1441. X        retstat = 1;
  1442. X    }
  1443. X    }
  1444. X    exit (retstat);
  1445. X}
  1446. X
  1447. text ()
  1448. X{
  1449. char            c;
  1450. X
  1451. X    while ((c = getc (stdin)))
  1452. X    printf ("%c", c);
  1453. X    printf ("\n");
  1454. X}
  1455. END_OF_FILE
  1456. if test 10150 -ne `wc -c <'Vplot_Kernel/util/pldb.c'`; then
  1457.     echo shar: \"'Vplot_Kernel/util/pldb.c'\" unpacked with wrong size!
  1458. fi
  1459. # end of 'Vplot_Kernel/util/pldb.c'
  1460. fi
  1461. echo shar: End of archive 15 \(of 24\).
  1462. cp /dev/null ark15isdone
  1463. MISSING=""
  1464. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ; do
  1465.     if test ! -f ark${I}isdone ; then
  1466.     MISSING="${MISSING} ${I}"
  1467.     fi
  1468. done
  1469. if test "${MISSING}" = "" ; then
  1470.     echo You have unpacked all 24 archives.
  1471.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1472. else
  1473.     echo You still need to unpack the following archives:
  1474.     echo "        " ${MISSING}
  1475. fi
  1476. ##  End of shell archive.
  1477. exit 0
  1478.