home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / unix / 272 < prev    next >
Encoding:
Text File  |  1992-09-08  |  61.1 KB  |  2,705 lines

  1. Newsgroups: comp.sources.unix
  2. Path: sparky!uunet!decwrl!pa.dec.com!vixie
  3. From: mogul@dec.com (Jeff Mogul)
  4. Subject: v26i073: psgraph - generate graph in Postscript, Part02/03
  5. Message-ID: <1992Sep8.005847.13515@PA.dec.com>
  6. Originator: vixie@cognition.pa.dec.com
  7. Sender: unix-sources-moderator@pa.dec.com
  8. Organization: DEC Palo Alto
  9. Date: Tue, 8 Sep 92 00:58:47 GMT
  10. Approved: vixie@pa.dec.com
  11. Lines: 2692
  12.  
  13. Submitted-By: mogul@dec.com (Jeff Mogul)
  14. Posting-Number: Volume 26, Issue 73
  15. Archive-Name: psgraph/part02
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 2 (of 3)."
  24. # Contents:  examples/long.plot grid.c output.c
  25. # Wrapped by tp@cognition.pa.dec.com on Mon Sep  7 16:47:35 1992
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'examples/long.plot' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'examples/long.plot'\"
  29. else
  30. echo shar: Extracting \"'examples/long.plot'\" \(17579 characters\)
  31. sed "s/^X//" >'examples/long.plot' <<'END_OF_FILE'
  32. X# Plot generated by plotsubs.c
  33. Xx size 6
  34. Xy size 4
  35. Xgrid 2
  36. Xmarker off
  37. Xtransparent
  38. Xline solid
  39. Xy label "SEQ number (bytes)"
  40. Xx label "time (seconds since start of connection)"
  41. X
  42. X# line starts
  43. Xbreak
  44. Xcolor orange
  45. Xmarker x
  46. X21.180183 3899392
  47. Xbreak
  48. Xmarker off
  49. Xcolor black
  50. X21.180183 3899392
  51. X21.181413 3900852
  52. X21.182853 3902312
  53. X21.184083 3903772
  54. X21.185313 3905232
  55. X21.186765 3906692
  56. X21.187995 3908152
  57. X21.189225 3909612
  58. X21.189225 3909612
  59. Xbreak
  60. Xcolor orange
  61. Xmarker x
  62. X21.189225 3909612
  63. Xbreak
  64. Xmarker off
  65. Xcolor black
  66. X21.189225 3909612
  67. X21.190612 3911072
  68. X21.402146 3912532
  69. X21.405647 3913992
  70. X21.407374 3915452
  71. X21.409519 3916912
  72. X21.411925 3918372
  73. X21.413293 3919832
  74. X21.416427 3921292
  75. X21.417181 3922752
  76. X21.418411 3923400
  77. X21.421282 3924860
  78. X21.425050 3926320
  79. X21.427492 3927780
  80. X21.428878 3929240
  81. X21.431234 3930700
  82. X21.812760 3899392
  83. X22.458742 3909612
  84. X22.558578 3932160
  85. X22.560061 3933620
  86. X22.659903 3935080
  87. X22.661608 3936540
  88. X22.662838 3938000
  89. X22.770121 3939460
  90. X22.771914 3940920
  91. X22.813915 3942380
  92. X22.877405 3943840
  93. X22.879399 3945300
  94. X22.999478 3946760
  95. X23.001056 3948220
  96. X23.002286 3949680
  97. X23.011295 3951140
  98. X23.107490 3952600
  99. X23.109185 3954060
  100. X23.165342 3955520
  101. X23.206334 3956980
  102. X23.209303 3958440
  103. X23.210967 3959900
  104. X23.212197 3961360
  105. X23.267716 3962820
  106. X23.352653 3964280
  107. X23.358423 3965740
  108. X23.359820 3967200
  109. X23.361186 3968660
  110. X23.406872 3970120
  111. X23.456990 3971580
  112. X23.458403 3973040
  113. X23.474585 3974500
  114. X23.476551 3975960
  115. X23.477781 3977420
  116. X23.561891 3978880
  117. X23.563290 3980340
  118. X23.585395 3981800
  119. X23.588110 3983260
  120. X23.589525 3984720
  121. X23.591976 3986180
  122. X23.695819 3987640
  123. X23.697049 3989100
  124. X23.698279 3990560
  125. X23.699509 3992020
  126. X23.709532 3993480
  127. X23.711105 3994940
  128. X23.712448 3996400
  129. X23.811072 3997860
  130. X23.812888 3999320
  131. X23.814423 4000780
  132. X23.825513 4002240
  133. X23.827103 4003700
  134. X23.872973 4005160
  135. X23.874458 4006620
  136. X23.953133 4008080
  137. X23.954719 4009540
  138. X23.956515 4011000
  139. X23.957745 4012460
  140. X23.986112 4013920
  141. X23.987597 4015380
  142. X24.060934 4016840
  143. X24.063791 4018300
  144. X24.089147 4019760
  145. X24.090577 4021220
  146. X24.126116 4022680
  147. X24.129941 4024140
  148. X24.131171 4025600
  149. X24.132401 4027060
  150. X24.203333 4028520
  151. X24.206473 4029980
  152. X24.248887 4031440
  153. X24.250874 4032900
  154. X24.252232 4034360
  155. X24.253462 4035820
  156. X24.304962 4037280
  157. X24.306327 4038740
  158. X24.364485 4040200
  159. X24.366859 4041660
  160. X24.369896 4043120
  161. X24.372329 4044580
  162. X24.373559 4046040
  163. X24.390397 4047500
  164. X24.392166 4048960
  165. X24.443463 4050420
  166. X24.556810 4051880
  167. X24.558074 4053340
  168. Xbreak
  169. X24.558074 4053340
  170. X24.560759 4054800
  171. X24.562051 4056260
  172. X24.566017 4057720
  173. X24.567752 4059180
  174. X24.594698 4060640
  175. X24.596043 4062100
  176. X24.604353 4063560
  177. X24.680708 4065020
  178. X24.683671 4066480
  179. X24.684901 4067940
  180. X24.768843 4069400
  181. X24.770598 4070860
  182. X24.773096 4072320
  183. X24.774326 4073780
  184. X24.777569 4075240
  185. X24.788789 4076700
  186. X24.790536 4078160
  187. X24.791838 4079620
  188. X24.796148 4081080
  189. X24.797679 4082540
  190. X24.880004 4084000
  191. X24.882203 4085460
  192. X24.886988 4086920
  193. X24.888584 4088380
  194. X24.906504 4089840
  195. X24.908291 4091300
  196. X24.930031 4092760
  197. X24.932538 4094220
  198. X24.937454 4095680
  199. X24.939007 4097140
  200. X24.991307 4098600
  201. X24.993493 4100060
  202. X24.998609 4101520
  203. X25.000368 4102980
  204. X25.001598 4104440
  205. X25.018169 4105900
  206. X25.019817 4107360
  207. X25.036365 4108820
  208. X25.038844 4110280
  209. X25.049387 4111740
  210. X25.050784 4113200
  211. X25.103672 4114660
  212. X25.106256 4116120
  213. X25.110274 4117580
  214. X25.112188 4119040
  215. X25.130100 4120500
  216. X25.132647 4121960
  217. X25.147042 4123420
  218. X25.154875 4124880
  219. X25.156742 4126340
  220. X25.158104 4127800
  221. X25.201390 4129260
  222. X25.215541 4130720
  223. X25.217330 4132180
  224. X25.223456 4133640
  225. X25.225211 4135100
  226. X25.226441 4136560
  227. X25.243855 4138020
  228. X25.246538 4139480
  229. X25.253444 4140940
  230. X25.255191 4142400
  231. X25.271626 4143860
  232. X25.273549 4145320
  233. X25.317417 4146780
  234. X25.318741 4148240
  235. X25.334938 4149700
  236. X25.336373 4151160
  237. X25.352751 4152620
  238. X25.354443 4154080
  239. X25.356275 4155540
  240. X25.358390 4157000
  241. X25.379415 4158460
  242. X25.381109 4159920
  243. X25.387971 4161380
  244. X25.391963 4162840
  245. X25.419355 4164300
  246. X25.424156 4165760
  247. X25.437667 4167220
  248. X25.439513 4168680
  249. X25.474046 4170140
  250. X25.476507 4171600
  251. X25.480568 4173060
  252. X25.482119 4174520
  253. X25.486027 4175980
  254. X25.499929 4177440
  255. X25.501422 4178900
  256. X25.512902 4180360
  257. X25.514519 4181820
  258. X25.519887 4183280
  259. X25.522305 4184740
  260. X25.540890 4186200
  261. X25.542363 4187660
  262. X25.585718 4189120
  263. X25.587159 4190580
  264. X25.593652 4192040
  265. X25.596180 4193500
  266. X25.614171 4194960
  267. X25.615456 4196420
  268. X25.626053 4197880
  269. X25.628097 4199340
  270. X25.644217 4200800
  271. Xbreak
  272. X25.644217 4200800
  273. X25.645524 4202260
  274. X25.659099 4203720
  275. X25.660623 4205180
  276. X25.690408 4206640
  277. X25.691819 4208100
  278. X25.702001 4209560
  279. X25.703410 4211020
  280. X25.718505 4212480
  281. X25.719886 4213940
  282. X25.730324 4215400
  283. X25.732372 4216860
  284. X25.733648 4218320
  285. X25.749787 4219780
  286. X25.751258 4221240
  287. X25.758938 4222700
  288. X25.760358 4224160
  289. X25.797037 4225620
  290. X25.798467 4227080
  291. X25.803343 4228540
  292. X25.815693 4230000
  293. X25.817222 4231460
  294. X25.835079 4232920
  295. X25.837497 4234380
  296. X25.844396 4235840
  297. X25.845746 4237300
  298. X25.875440 4238760
  299. X25.877919 4240220
  300. X25.879224 4241680
  301. X25.881878 4243140
  302. X25.895158 4244600
  303. X25.897905 4246060
  304. X25.909284 4247520
  305. X25.910666 4248980
  306. X25.927940 4250440
  307. X25.929246 4251900
  308. X25.942388 4253360
  309. X25.951368 4254820
  310. X25.962926 4256280
  311. X25.964440 4257740
  312. X26.010936 4259200
  313. X26.012403 4260660
  314. X26.013935 4262120
  315. X26.015744 4263580
  316. X26.016974 4265040
  317. X26.018652 4266500
  318. X26.019882 4267960
  319. X26.030770 4269420
  320. X26.032140 4270880
  321. X26.041210 4272340
  322. X26.042735 4273800
  323. X26.056294 4275260
  324. X26.059029 4276720
  325. X26.070460 4278180
  326. X26.073005 4279640
  327. X26.123387 4281100
  328. X26.124825 4282560
  329. X26.146761 4284020
  330. X26.148708 4285480
  331. X26.150059 4286940
  332. X26.151706 4288400
  333. X26.167186 4289860
  334. X26.169566 4291320
  335. X26.177128 4292780
  336. X26.178686 4294240
  337. X26.196715 4295700
  338. X26.198222 4297160
  339. X26.208103 4298620
  340. X26.210828 4300080
  341. X26.267886 4301540
  342. X26.269854 4303000
  343. X26.271084 4304460
  344. X26.272425 4305920
  345. X26.273655 4307380
  346. X26.275249 4308840
  347. X26.276515 4310300
  348. X26.288470 4311760
  349. X26.294675 4313220
  350. X26.296494 4314680
  351. X26.297724 4316140
  352. X26.315149 4317600
  353. X26.316506 4319060
  354. X26.320797 4320520
  355. X26.322208 4321980
  356. X26.375401 4323440
  357. X26.376900 4324900
  358. X26.379282 4326360
  359. X26.380733 4327820
  360. X26.406604 4329280
  361. X26.408289 4330740
  362. X26.409935 4332200
  363. X26.427050 4333660
  364. X26.428585 4335120
  365. X26.435415 4336580
  366. X26.436896 4338040
  367. X26.450107 4339500
  368. X26.451519 4340960
  369. X26.465896 4342420
  370. X26.467307 4343880
  371. X26.527582 4345340
  372. X26.530276 4346800
  373. X26.563675 4348260
  374. Xbreak
  375. X26.563675 4348260
  376. X26.565894 4349720
  377. X26.568764 4351180
  378. X26.570093 4352640
  379. X26.575103 4354100
  380. X26.576333 4355560
  381. X26.577176 4357020
  382. X26.579773 4357668
  383. X26.581173 4359128
  384. X26.588899 4360588
  385. X26.591246 4362048
  386. X26.614952 4363508
  387. X26.650127 4364968
  388. X26.651357 4366428
  389. X26.653040 4367888
  390. X26.654270 4369348
  391. X26.681057 4370808
  392. X26.682766 4372268
  393. X26.684394 4373728
  394. X26.685624 4375188
  395. X26.696920 4376648
  396. X26.698538 4378108
  397. X26.699925 4379568
  398. X26.737806 4381028
  399. X26.739430 4382488
  400. X26.741258 4383948
  401. X26.742488 4385408
  402. X26.745833 4386868
  403. X26.747244 4388328
  404. X26.799749 4389788
  405. X26.801317 4391248
  406. X26.881212 4392708
  407. X26.882784 4394168
  408. X26.884519 4395628
  409. X26.885749 4397088
  410. X26.887200 4398548
  411. X26.887998 4400008
  412. X26.892574 4400656
  413. X26.897903 4402116
  414. X26.899133 4403576
  415. X26.900366 4405036
  416. X26.901625 4406496
  417. X26.903213 4407956
  418. X26.905806 4409416
  419. X26.915238 4410876
  420. X26.916468 4412336
  421. X26.918157 4413796
  422. X26.919387 4415256
  423. X26.985012 4416716
  424. X26.986406 4418176
  425. X26.998998 4419636
  426. X27.004035 4421096
  427. X27.005646 4422556
  428. X27.049207 4424016
  429. X27.052013 4425476
  430. X27.053296 4426936
  431. X27.063555 4428396
  432. X27.065501 4429856
  433. X27.066731 4431316
  434. X27.067961 4432776
  435. X27.125993 4434236
  436. X27.128736 4435696
  437. X27.134237 4437156
  438. X27.136783 4438616
  439. X27.207924 4440076
  440. X27.209533 4441536
  441. X27.211308 4442996
  442. X27.214146 4444456
  443. X27.220997 4445916
  444. X27.222327 4446564
  445. X27.224019 4447688
  446. X27.225249 4449148
  447. X27.226855 4450608
  448. X27.228085 4452068
  449. X27.229315 4453528
  450. X27.230545 4454988
  451. X27.231775 4456448
  452. X27.233005 4457908
  453. X27.266738 4459368
  454. X27.268389 4460828
  455. X27.270980 4462288
  456. X27.279005 4463748
  457. X27.279808 4465208
  458. X27.337731 4465544
  459. X27.339301 4467004
  460. X27.341034 4468464
  461. X27.342264 4469924
  462. X27.357913 4471384
  463. X27.359445 4472844
  464. X27.362213 4474304
  465. X27.363865 4475764
  466. X27.365497 4477224
  467. X27.387357 4478684
  468. X27.389127 4480144
  469. X27.390393 4481604
  470. X27.390811 4483064
  471. X27.444573 4483376
  472. X27.446095 4484836
  473. X27.447817 4486296
  474. X27.449047 4487756
  475. X27.452404 4489216
  476. X27.454064 4490676
  477. Xbreak
  478. X27.454064 4490676
  479. X27.455698 4492136
  480. X27.521343 4493596
  481. X27.523829 4495056
  482. X27.545149 4496516
  483. X27.546756 4497976
  484. X27.548052 4499436
  485. X27.548497 4500896
  486. X27.553337 4501232
  487. X27.556189 4502692
  488. X27.557624 4504152
  489. X27.560070 4505612
  490. X27.561449 4507072
  491. X27.562679 4508532
  492. X27.563909 4509992
  493. X27.575002 4511452
  494. X27.576726 4512912
  495. X27.619364 4514372
  496. X27.621030 4515832
  497. X27.622482 4517292
  498. X27.622948 4518752
  499. X27.625275 4519064
  500. X27.672628 4520524
  501. X27.674422 4521984
  502. X27.705370 4523444
  503. X27.724313 4524904
  504. X27.726371 4526364
  505. X27.727601 4527824
  506. X27.728831 4529284
  507. X27.730206 4530744
  508. X27.731436 4532204
  509. X27.732666 4533664
  510. X27.734303 4535124
  511. X27.735533 4536584
  512. X27.736763 4538044
  513. X27.738089 4539504
  514. X27.739319 4540964
  515. X27.739319 4540964
  516. Xbreak
  517. Xcolor orange
  518. Xmarker x
  519. X27.739319 4540964
  520. Xbreak
  521. Xmarker off
  522. Xcolor black
  523. X27.739319 4540964
  524. X27.761375 4542424
  525. X27.763024 4543884
  526. X27.763584 4545344
  527. X27.764090 4545680
  528. X27.766948 4545992
  529. X27.825077 4547452
  530. X27.826307 4548912
  531. X27.827730 4550372
  532. X27.829483 4551832
  533. X27.841838 4553292
  534. X27.844337 4554752
  535. X27.846202 4556212
  536. X27.847444 4557672
  537. X27.863141 4559132
  538. X27.864517 4560592
  539. X27.909757 4562052
  540. X27.911552 4563512
  541. X27.912782 4564972
  542. X27.914015 4566432
  543. X27.915245 4567892
  544. X27.916475 4569352
  545. X28.458592 4540964
  546. X28.560915 4570812
  547. X28.562344 4572272
  548. X28.662031 4573732
  549. X28.663672 4575192
  550. X28.664902 4576652
  551. X28.768024 4578112
  552. X28.769693 4579572
  553. X28.770923 4581032
  554. X28.820042 4582492
  555. X28.821289 4583952
  556. X28.879204 4585412
  557. X28.880760 4586872
  558. X28.881990 4588332
  559. X28.935995 4589792
  560. X28.937636 4591252
  561. X28.938866 4592712
  562. X28.975232 4594172
  563. X28.978184 4595632
  564. X28.979414 4597092
  565. X28.986860 4598552
  566. X28.988671 4600012
  567. X28.995843 4601472
  568. X28.997640 4602932
  569. X29.059831 4604392
  570. X29.061570 4605852
  571. X29.063455 4607312
  572. X29.095877 4608772
  573. X29.097569 4610232
  574. X29.099132 4611692
  575. X29.101406 4613152
  576. X29.105077 4614612
  577. X29.106393 4616072
  578. X29.117041 4617532
  579. X29.118742 4618992
  580. X29.176136 4620452
  581. X29.177631 4621912
  582. X29.220433 4623372
  583. X29.222223 4624832
  584. X29.223540 4626292
  585. X29.248426 4627752
  586. X29.250480 4629212
  587. X29.252060 4630672
  588. X29.254486 4632132
  589. X29.301786 4633592
  590. X29.303551 4635052
  591. X29.317197 4636512
  592. X29.319012 4637972
  593. X29.342030 4639432
  594. X29.343952 4640892
  595. X29.345182 4642352
  596. X29.385772 4643812
  597. X29.387546 4645272
  598. X29.389138 4646732
  599. X29.391555 4648192
  600. X29.413796 4649652
  601. X29.422328 4651112
  602. X29.424639 4652572
  603. X29.453153 4654032
  604. X29.455638 4655492
  605. X29.458329 4656952
  606. X29.459606 4658412
  607. X29.487579 4659872
  608. X29.489686 4661332
  609. X29.502429 4662792
  610. X29.504020 4664252
  611. X29.564908 4665712
  612. X29.566439 4667172
  613. X29.568198 4668632
  614. X29.569520 4670092
  615. X29.598943 4671552
  616. X29.600709 4673012
  617. X29.602394 4674472
  618. X29.606584 4675932
  619. X29.609033 4677392
  620. X29.610286 4678852
  621. X29.654302 4680312
  622. X29.657226 4681772
  623. X29.659653 4683232
  624. X29.683268 4684692
  625. Xbreak
  626. X29.683268 4684692
  627. X29.684693 4686152
  628. X29.725728 4687612
  629. X29.727528 4689072
  630. X29.728758 4690532
  631. X29.730304 4691992
  632. X29.731534 4693452
  633. X29.732764 4694912
  634. X29.785407 4696372
  635. X29.786796 4697832
  636. X29.813566 4699292
  637. X29.814975 4700752
  638. X29.816205 4702212
  639. X29.817435 4703672
  640. X29.827697 4705132
  641. X29.829110 4706592
  642. X29.843338 4708052
  643. X29.844751 4709512
  644. X29.856754 4710972
  645. X29.862815 4712432
  646. X29.902156 4713892
  647. X29.904947 4715352
  648. X29.907402 4716812
  649. X29.931270 4718272
  650. X29.933741 4719732
  651. X29.936133 4721192
  652. X29.941800 4722652
  653. X29.977276 4724112
  654. X29.984095 4725572
  655. X29.985884 4727032
  656. X29.987146 4728492
  657. X29.988376 4729952
  658. X29.989606 4731412
  659. X30.022565 4732872
  660. X30.025250 4734332
  661. X30.075735 4735792
  662. X30.077320 4737252
  663. X30.079019 4738712
  664. X30.080249 4740172
  665. X30.105227 4741632
  666. X30.108082 4743092
  667. X30.110545 4744552
  668. X30.111886 4746012
  669. X30.117022 4747472
  670. X30.118481 4748932
  671. X30.144285 4750392
  672. X30.145698 4751852
  673. X30.198955 4753312
  674. X30.200445 4754772
  675. X30.202278 4756232
  676. X30.203508 4757692
  677. X30.242136 4759152
  678. X30.243791 4760612
  679. X30.245319 4762072
  680. X30.247423 4763532
  681. X30.249215 4764992
  682. X30.250805 4766452
  683. X30.252035 4767912
  684. X30.287516 4769372
  685. X30.290026 4770832
  686. X30.349562 4772292
  687. X30.351248 4773752
  688. X30.352884 4775212
  689. X30.354114 4776672
  690. X30.355732 4778132
  691. X30.356962 4779592
  692. X30.358508 4781052
  693. X30.359088 4782512
  694. X30.361727 4783160
  695. X30.399847 4784620
  696. X30.408191 4786080
  697. X30.409809 4787540
  698. X30.413565 4789000
  699. X30.414869 4790460
  700. X30.416387 4791920
  701. X30.417617 4793380
  702. X30.503428 4794840
  703. X30.504812 4796300
  704. X30.506612 4797760
  705. X30.507842 4799220
  706. X30.510234 4800680
  707. X30.512600 4802140
  708. X30.526424 4803600
  709. X30.527654 4805060
  710. X30.528884 4806520
  711. X30.539686 4807980
  712. X30.541148 4809440
  713. X30.555330 4810900
  714. X30.558373 4812360
  715. X30.592561 4813820
  716. X30.594010 4815280
  717. X30.668304 4816740
  718. X30.670129 4818200
  719. X30.673284 4819660
  720. X30.675213 4821120
  721. X30.677745 4822580
  722. X30.679121 4824040
  723. X30.680351 4825500
  724. X30.681277 4826960
  725. X30.693949 4827608
  726. X30.696426 4829068
  727. X30.702624 4830528
  728. Xbreak
  729. X30.702624 4830528
  730. X30.704405 4831988
  731. X30.705970 4833448
  732. X30.708327 4834908
  733. X30.717114 4836368
  734. X30.718541 4837828
  735. X30.809751 4839288
  736. X30.812458 4840748
  737. X30.814896 4842208
  738. X30.818859 4843668
  739. X30.823564 4845128
  740. X30.867355 4846588
  741. X30.868941 4848048
  742. X30.871956 4849508
  743. X30.873186 4850968
  744. X30.875177 4852428
  745. X30.876407 4853888
  746. X30.878280 4855348
  747. X30.879654 4856808
  748. X30.881351 4858268
  749. X30.883020 4859728
  750. X30.884369 4861188
  751. X30.984395 4862648
  752. X30.986629 4864108
  753. X30.988417 4865568
  754. X30.992566 4867028
  755. X30.996184 4868488
  756. X30.997845 4869948
  757. X30.999617 4871408
  758. X31.001097 4872868
  759. X31.002949 4874328
  760. X31.003529 4875788
  761. X31.054185 4876436
  762. X31.056158 4877896
  763. X31.057388 4879356
  764. X31.059566 4880816
  765. X31.062124 4882276
  766. X31.063354 4883736
  767. X31.105917 4885196
  768. X31.132693 4886656
  769. X31.134662 4888116
  770. X31.135947 4889576
  771. X31.137177 4891036
  772. X31.167856 4892496
  773. X31.170394 4893956
  774. X31.180074 4895416
  775. X31.182847 4896876
  776. X31.184077 4898336
  777. X31.185307 4899796
  778. X31.210451 4901256
  779. X31.212799 4902716
  780. X31.216798 4904176
  781. X31.218857 4905636
  782. X31.289523 4907096
  783. X31.291101 4908556
  784. X31.292331 4910016
  785. X31.312673 4911476
  786. X31.314305 4912936
  787. X31.316007 4914396
  788. X31.317652 4915856
  789. X31.338657 4917316
  790. X31.340103 4918776
  791. X31.343450 4920236
  792. X31.345068 4921696
  793. X31.346997 4923156
  794. X31.348252 4924616
  795. X31.348832 4926076
  796. X31.351389 4926724
  797. X31.371386 4928184
  798. X31.372772 4929644
  799. X31.401947 4931104
  800. X31.404201 4932564
  801. X31.406022 4934024
  802. X31.407252 4935484
  803. X31.484043 4936944
  804. X31.487131 4938404
  805. X31.490140 4939864
  806. X31.491375 4941324
  807. X31.525822 4942784
  808. X31.528314 4944244
  809. X31.534564 4945704
  810. X31.544507 4947164
  811. X31.546351 4948624
  812. X31.547581 4950084
  813. X31.548811 4951544
  814. X31.617329 4953004
  815. X31.621544 4954464
  816. X31.638539 4955924
  817. X31.642422 4957384
  818. X31.643866 4958844
  819. X31.645096 4960304
  820. X31.645676 4961764
  821. X31.664007 4962412
  822. X31.665504 4963872
  823. X31.666925 4965332
  824. X31.673845 4966792
  825. X31.684253 4968252
  826. X31.686098 4969712
  827. X31.686981 4971172
  828. X31.688211 4971976
  829. X31.735365 4973436
  830. X31.737199 4974896
  831. Xbreak
  832. X31.737199 4974896
  833. X31.738429 4976356
  834. X31.739060 4977816
  835. X31.740290 4978472
  836. X31.741520 4979932
  837. X31.788794 4981392
  838. X31.803095 4982852
  839. X31.805202 4984312
  840. X31.806432 4985772
  841. X31.807683 4987232
  842. X31.808913 4988692
  843. X31.810143 4990152
  844. X31.811810 4991612
  845. X31.813040 4993072
  846. X31.813040 4993072
  847. Xbreak
  848. Xcolor orange
  849. Xmarker x
  850. X31.813040 4993072
  851. Xbreak
  852. Xmarker off
  853. Xcolor black
  854. X31.813040 4993072
  855. X31.830372 4994532
  856. X31.832131 4995992
  857. X31.836501 4997452
  858. X31.838867 4998912
  859. X31.840295 5000372
  860. X31.844398 5001832
  861. X31.847478 5003292
  862. X31.871018 5004752
  863. X31.872402 5006212
  864. X31.887136 5007672
  865. X31.911570 5009132
  866. X31.913454 5010592
  867. X31.914684 5012052
  868. X31.924733 5013512
  869. X31.925963 5014972
  870. X31.937701 5016432
  871. X31.939133 5017892
  872. X31.974662 5019352
  873. X32.959439 4993072
  874. X33.060622 5020812
  875. X33.063063 5022272
  876. X33.162110 5023732
  877. X33.163839 5025192
  878. X33.165069 5026652
  879. X33.268478 5028112
  880. X33.269952 5029572
  881. X33.271228 5031032
  882. X33.369814 5032492
  883. X33.373572 5033952
  884. X33.387930 5035412
  885. X33.390698 5036872
  886. X33.392965 5038332
  887. X33.470099 5039792
  888. X33.472934 5041252
  889. X33.479845 5042712
  890. X33.491500 5044172
  891. X33.493015 5045632
  892. X33.494391 5047092
  893. X33.543102 5048552
  894. X33.544698 5050012
  895. X33.546361 5051472
  896. X33.599365 5052932
  897. X33.601057 5054392
  898. X33.602851 5055852
  899. X33.604081 5057312
  900. X33.605607 5058772
  901. X33.607379 5060232
  902. X33.608760 5061692
  903. X33.662300 5063152
  904. X33.665314 5064612
  905. X33.722446 5066072
  906. X33.723960 5067532
  907. X33.725845 5068992
  908. X33.728333 5070452
  909. X33.735470 5071912
  910. X33.743101 5073372
  911. X33.781906 5074832
  912. X33.783512 5076292
  913. X33.785241 5077752
  914. X33.786471 5079212
  915. X33.837037 5080672
  916. X33.838467 5082132
  917. X33.847616 5083592
  918. X33.849029 5085052
  919. X33.922117 5086512
  920. X33.924380 5087972
  921. X33.925669 5089432
  922. X33.927950 5090892
  923. X33.929232 5092352
  924. X33.973485 5093812
  925. X33.976127 5095272
  926. X33.987932 5096732
  927. X33.989707 5098192
  928. X33.990937 5099652
  929. X34.037661 5101112
  930. X34.039429 5102572
  931. X34.040659 5104032
  932. X34.041951 5105492
  933. X34.127166 5106952
  934. X34.129208 5108412
  935. X34.133945 5109872
  936. X34.135334 5111332
  937. X34.145631 5112792
  938. X34.147118 5114252
  939. X34.153588 5115712
  940. X34.156545 5117172
  941. X34.173646 5118632
  942. X34.175032 5120092
  943. X34.193376 5121552
  944. X34.194906 5123012
  945. X34.247829 5124472
  946. X34.249498 5125932
  947. X34.250728 5127392
  948. X34.251958 5128852
  949. X34.311708 5130312
  950. X34.313253 5131772
  951. X34.333933 5133232
  952. X34.335163 5134692
  953. X34.336629 5136152
  954. X34.338063 5137612
  955. X34.383383 5139072
  956. Xbreak
  957. X34.383383 5139072
  958. X34.385932 5140532
  959. X34.393667 5141992
  960. X34.394897 5143452
  961. X34.396127 5144912
  962. X34.422524 5146372
  963. X34.425135 5147832
  964. X34.466405 5149292
  965. X34.469321 5150752
  966. X34.470551 5152212
  967. X34.472887 5153672
  968. X34.524271 5155132
  969. X34.527542 5156592
  970. X34.528772 5158052
  971. X34.530002 5159512
  972. X34.532339 5160972
  973. X34.558145 5162432
  974. X34.559828 5163892
  975. X34.591312 5165352
  976. X34.603573 5166812
  977. X34.605002 5168272
  978. X34.606232 5169732
  979. X34.642327 5171192
  980. X34.644006 5172652
  981. X34.645663 5174112
  982. X34.646893 5175572
  983. X34.650684 5177032
  984. X34.652064 5178492
  985. X34.701857 5179952
  986. X34.703938 5181412
  987. X34.745956 5182872
  988. X34.747186 5184332
  989. X34.749514 5185792
  990. X34.751322 5187252
  991. X34.795021 5188712
  992. X34.797865 5190172
  993. X34.800564 5191632
  994. X34.802056 5193092
  995. X34.803286 5194552
  996. X34.804666 5196012
  997. X34.839035 5197472
  998. X34.841689 5198932
  999. X34.886768 5200392
  1000. X34.888920 5201852
  1001. X34.890150 5203312
  1002. X35.112314 5207692
  1003. X35.112314 5207692
  1004. Xbreak
  1005. Xcolor orange
  1006. Xmarker x
  1007. X35.112314 5207692
  1008. Xbreak
  1009. Xmarker off
  1010. Xcolor black
  1011. X35.112314 5207692
  1012. X35.112314 5207692
  1013. Xbreak
  1014. Xcolor magenta
  1015. Xmarker circle
  1016. X35.112314 5207692
  1017. Xbreak
  1018. Xmarker off
  1019. Xcolor black
  1020. X35.112314 5207692
  1021. X35.113544 5209152
  1022. X35.114774 5210612
  1023. X35.116116 5212072
  1024. X35.117346 5213532
  1025. X35.118576 5214992
  1026. X35.136432 5216452
  1027. X35.144966 5217912
  1028. X35.146196 5219372
  1029. X35.162142 5220832
  1030. X35.163372 5222292
  1031. Xbreak
  1032. END_OF_FILE
  1033. if test 17579 -ne `wc -c <'examples/long.plot'`; then
  1034.     echo shar: \"'examples/long.plot'\" unpacked with wrong size!
  1035. fi
  1036. # end of 'examples/long.plot'
  1037. fi
  1038. if test -f 'grid.c' -a "${1}" != "-c" ; then 
  1039.   echo shar: Will not clobber existing file \"'grid.c'\"
  1040. else
  1041. echo shar: Extracting \"'grid.c'\" \(18865 characters\)
  1042. sed "s/^X//" >'grid.c' <<'END_OF_FILE'
  1043. X/* $Header: grid.c,v 1.12 92/08/04 17:55:02 mogul Exp $ */
  1044. X
  1045. X/*
  1046. X *               Copyright 1989, 1992 Digital Equipment Corporation
  1047. X *                          All Rights Reserved
  1048. X * 
  1049. X * 
  1050. X * Permission to use, copy, and modify this software and its documentation
  1051. X * is hereby granted only under the following terms and conditions.  Both
  1052. X * the above copyright notice and this permission notice must appear in
  1053. X * all copies of the software, derivative works or modified versions, and
  1054. X * any portions threof, and both notices must appear in supporting
  1055. X * documentation.
  1056. X * 
  1057. X * Users of this software agree to the terms and conditions set forth
  1058. X * herein, and hereby grant back to Digital a non-exclusive, unrestricted,
  1059. X * royalty-free right and license under any changes, enhancements or
  1060. X * extensions made to the core functions of the software, including but
  1061. X * not limited to those affording compatibility with other hardware or
  1062. X * software environments, but excluding applications which incorporate
  1063. X * this software.  Users further agree to use their best efforts to return
  1064. X * to Digital any such changes, enhancements or extensions that they make
  1065. X * and inform Digital of noteworthy uses of this software.  Correspondence
  1066. X * should be provided to Digital at:
  1067. X * 
  1068. X *                       Director of Licensing
  1069. X *                       Western Research Laboratory
  1070. X *                       Digital Equipment Corporation
  1071. X *                       250 University Avenue
  1072. X *                       Palo Alto, California  94301  
  1073. X * 
  1074. X * This software may be distributed (but not offered for sale or
  1075. X * transferred for compensation) to third parties, provided such third
  1076. X * parties agree to abide by the terms and conditions of this notice.
  1077. X * 
  1078. X * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS
  1079. X * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
  1080. X * WARRANTIES OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL
  1081. X * EQUIPMENT CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  1082. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  1083. X * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1084. X * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1085. X * PERFORMANCE OF THIS SOFTWARE.
  1086. X */
  1087. X
  1088. X/* 
  1089. X * grid.c - Compute and generate grids and axes
  1090. X * 
  1091. X * Author:    Christopher A. Kent
  1092. X *         Western Research Laboratory
  1093. X *         Digital Equipment Corporation
  1094. X * Date:    Wed Jan  4 1989
  1095. X */
  1096. X
  1097. X/*
  1098. X * $Log:    grid.c,v $
  1099. X * Revision 1.12  92/08/04  17:55:02  mogul
  1100. X * undo RCS botch
  1101. X * 
  1102. X * Revision 1.11  1992/06/17  22:14:41  kent
  1103. X * Make axis specs with max < min work, fix some bugs with centering
  1104. X * and multiple args.
  1105. X *
  1106. X * Revision 1.10  1992/06/16  01:48:11  kent
  1107. X * Make y positioning and centering and such work right.
  1108. X *
  1109. X * Revision 1.9  1992/06/16  00:41:35  kent
  1110. X * Hokey fix for a bug where min and max of a scale end up the same.
  1111. X *
  1112. X * Revision 1.8  1992/04/15  22:24:34  kent
  1113. X * log Y label was being placed incorrectly
  1114. X *
  1115. X * Revision 1.7  1992/04/07  18:11:09  kent
  1116. X * Made log scales support datalabels.
  1117. X *
  1118. X * Revision 1.6  1992/04/07  18:01:19  kent
  1119. X * Can't draw the title until after the ticks are labelled, or the
  1120. X * placement isn't right.
  1121. X *
  1122. X * Revision 1.5  1992/04/02  00:45:01  kent
  1123. X * Changes to handle lots of points; when using dataticks, the axis
  1124. X * routines could get too big and overflow the operand stack. As
  1125. X * a result, the output PostScript code is even uglier.
  1126. X *
  1127. X * Revision 1.4  1992/04/01  23:27:34  kent
  1128. X * Added datalabel verb, fixed a bug in handling blank input lines.
  1129. X *
  1130. X * Revision 1.3  1992/03/31  23:13:12  kent
  1131. X * Added "dataticks" verb.
  1132. X *
  1133. X * Revision 1.2  1992/03/30  23:33:47  kent
  1134. X * Added halfopen, halfticks grid styles, range frames, and gray.
  1135. X *
  1136. X * Revision 1.1  1992/03/20  21:25:43  kent
  1137. X * Initial revision
  1138. X *
  1139. X * Revision 1.9  92/02/21  17:13:20  mogul
  1140. X * Added Digital license info
  1141. X * 
  1142. X * Revision 1.8  91/02/04  16:46:25  mogul
  1143. X * set variable "font" before using it, even when not labelling axes.
  1144. X * 
  1145. X * Revision 1.7  90/11/05  11:09:51  reid
  1146. X * Checking in Chris Kent's changes before I start making some.
  1147. X * 
  1148. X * Revision 1.6  89/01/27  15:54:19  kent
  1149. X * lint.
  1150. X * 
  1151. X * Revision 1.5  89/01/11  09:22:56  kent
  1152. X * Use floor() to properly handle axis limit computations.
  1153. X * 
  1154. X * Revision 1.4  89/01/09  22:18:24  kent
  1155. X * Added log scales.
  1156. X * 
  1157. X * Revision 1.3  89/01/04  17:30:24  kent
  1158. X * Made command line arguments override compiled-in defaults for
  1159. X * all plots in a run, not just the first one. 
  1160. X * 
  1161. X * Revision 1.2  89/01/04  15:21:52  kent
  1162. X * Massive renaming. No functional change.
  1163. X * 
  1164. X * Revision 1.1  89/01/04  13:57:40  kent
  1165. X * Initial revision
  1166. X * 
  1167. X */
  1168. X
  1169. Xstatic char rcs_ident[] = "$Header: grid.c,v 1.12 92/08/04 17:55:02 mogul Exp $";
  1170. X
  1171. X#include <stdio.h>
  1172. X
  1173. X#include "psgraph.h"
  1174. X
  1175. Xgrid_t
  1176. Xgridval(cp)
  1177. Xchar *cp;
  1178. X{
  1179. X    if ( isdigit(*cp)) {
  1180. X        switch(atoi(cp)) {
  1181. X        case 0: return NONE;
  1182. X        case 1:    return OPEN;
  1183. X        case 2: return TICKS;
  1184. X        case 3: return FULL;
  1185. X        case 4: return HALFOPEN;
  1186. X        case 5: return HALFTICKS;
  1187. X        default: return FULL;
  1188. X        }
  1189. X    } else if ( strcmp(cp,"none")==0 )
  1190. X        return NONE;
  1191. X    else if ( strcmp(cp,"open")==0 )
  1192. X        return OPEN;
  1193. X    else if ( strncmp(cp,"tick",4)==0 )
  1194. X        return TICKS;
  1195. X    else if ( strcmp(cp,"full")==0 )
  1196. X        return FULL;
  1197. X    else if ( strcmp(cp,"halfopen")==0 )
  1198. X        return HALFOPEN;
  1199. X    else if ( strncmp(cp,"halftick",8)==0 )
  1200. X        return HALFTICKS;
  1201. X    return FULL;
  1202. X}
  1203. X
  1204. Xlimargs(p,argc,argv,arg)
  1205. Xlimit_t    *p;
  1206. Xint    argc, arg;
  1207. Xchar    **argv;
  1208. X{
  1209. X    if ( arg < argc ** argv[arg] == 'l' ) {
  1210. X        p->tform = LOG10;
  1211. X        arg++;
  1212. X    }
  1213. X    if ( isfloat(argv[arg]) ) {
  1214. X        p->minflag = TRUE;
  1215. X        p->min = atof(argv[arg++]);
  1216. X        if ( isfloat(argv[arg]) ) {
  1217. X            p->maxflag = TRUE;
  1218. X            p->max = atof(argv[arg++]);
  1219. X            if ( isfloat(argv[arg]) ) {
  1220. X                p->distf = TRUE;
  1221. X                p->dist = atof(argv[arg++]);
  1222. X            }
  1223. X        }
  1224. X    }
  1225. X    return arg;
  1226. X}
  1227. X
  1228. X/*
  1229. X * draw the axes - define routines to draw the plot axes based on the
  1230. X * parameters.  Because we may want to do a translate (to center the graph)
  1231. X * based on the max and min, we can't just emit the commands here; because this
  1232. X * could get arbitrarily large and overflow the operand stack, we use a hack to
  1233. X * collapse that stack, at the cost of more obscure code.
  1234. X */
  1235. X
  1236. XsetupAxes()
  1237. X{
  1238. X    minX = 0;
  1239. X    minY = 0;
  1240. X    maxX = MAX(maxX, sx(Xaxis.gmax));
  1241. X    maxY = MAX(maxY, sy(Yaxis.gmax));
  1242. X}
  1243. X
  1244. XdoXaxis()
  1245. X{
  1246. X        int i, startTemp = CurrentTemp;
  1247. X    
  1248. X    startGridTemp();
  1249. X    
  1250. X    if (Xaxis.tform == IDENT)
  1251. X        linearX();
  1252. X    else
  1253. X        logX();
  1254. X
  1255. X    endGridTemp();
  1256. X    printf("/drawXaxis {\n");    /* hack hack */
  1257. X    for (i = startTemp; i < CurrentTemp; i++)
  1258. X        printf("\tgt%03d\n", i);
  1259. X    printf("}def\n");
  1260. X}
  1261. X
  1262. XdoYaxis()
  1263. X{
  1264. X        int i, startTemp = CurrentTemp;
  1265. X    
  1266. X    startGridTemp();
  1267. X    
  1268. X    if (Yaxis.tform == IDENT)
  1269. X        linearY();
  1270. X    else
  1271. X        logY();
  1272. X
  1273. X    endGridTemp();
  1274. X    printf("/drawYaxis {\n");    /* hack hack */
  1275. X    for (i = startTemp; i < CurrentTemp; i++)
  1276. X        printf("\tgt%03d\n", i);
  1277. X    printf("}def\n");
  1278. X}
  1279. X
  1280. XdoTitle()
  1281. X{
  1282. X    if (Title.title != NULL)
  1283. X        axisText(Title.title, NORTH, 
  1284. X            Title.font ? Title.font : TextFont);
  1285. X}
  1286. X
  1287. X#define    GT(a,b)        (argp->distg>0 ? ((a)-(b))>0 : ((a)-(b))<0)
  1288. X#define LT(a,b)        (argp->distg>0 ? ((a)-(b))<0 : ((a)-(b))>0)
  1289. X
  1290. XlinearX()
  1291. X{
  1292. X    register axis_t *argp;
  1293. X    char *font;
  1294. X    float x;
  1295. X    float amin, amax;
  1296. X    float agray, tgray;
  1297. X    int i;
  1298. X
  1299. X    argp = &Xaxis;
  1300. X    agray = argp->axisgray;
  1301. X    tgray = argp->tickgray;
  1302. X    font = argp->font ? argp->font : TextFont;
  1303. X    amin = argp->gmin; amax = argp->gmax;
  1304. X
  1305. X    /*
  1306. X     * Determine how much of the frame to draw
  1307. X     */
  1308. X    if (argp->rangeframe) {
  1309. X        amin = argp->min; amax = argp->max;
  1310. X    }
  1311. X    
  1312. X    /*
  1313. X     * Draw the frame 
  1314. X     */
  1315. X    if ( argp->gridtype != NONE ) {
  1316. X        gridLine(amin, Yaxis.gmin, amax, Yaxis.gmin, agray);
  1317. X        if (!argp->halfgrid)
  1318. X            gridLine(amin, Yaxis.gmax, amax, Yaxis.gmax, agray);
  1319. X    }
  1320. X
  1321. X    /*
  1322. X     * Label the endpoints
  1323. X     */
  1324. X    if (DoAxisLabels) {
  1325. X        tickText(Xaxis.gmin, Yaxis.gmin, Xaxis.gmin, SOUTH, font);
  1326. X        tickText(Xaxis.gmax, Yaxis.gmin, Xaxis.gmax, SOUTH, font);
  1327. X    }
  1328. X
  1329. X    /*
  1330. X     * Do data-only ticks
  1331. X     */
  1332. X    if (argp->datatick) {
  1333. X        for (i = 0; i < NumTokens; i++) {
  1334. X        if (Token[i].type != POINT)
  1335. X            continue;
  1336. X        x = Token[i].val[0];
  1337. X        if (argp->gridtype == FULL)
  1338. X            gridLine(x, Yaxis.gmin, x, Yaxis.gmax, tgray);
  1339. X        else {
  1340. X            tick(x, Yaxis.gmin, NORTH, TRUE, tgray);
  1341. X            if (!argp->halfgrid)
  1342. X            tick(x, Yaxis.gmax, SOUTH, TRUE, tgray);
  1343. X        }
  1344. X        if (argp->datalabel)
  1345. X            tickText(x, Yaxis.gmin, x, SOUTH, font);
  1346. X        }
  1347. X    }
  1348. X
  1349. X    /*
  1350. X     * Draw the ticks that will have labels on them (or just the labels
  1351. X     * in the case of dataticks, ugh)
  1352. X     */
  1353. X    x = argp->gmin;
  1354. X
  1355. X    while ( LT(x, argp->gmax) ) {
  1356. X        if ( GT(x, argp->gmin) ) {
  1357. X        if (!argp->datatick)
  1358. X            if ( argp->gridtype==FULL )
  1359. X            gridLine(x, Yaxis.gmin, x, Yaxis.gmax, tgray);
  1360. X            else if ( argp->gridtype==TICKS ) {
  1361. X            tick(x, Yaxis.gmin, NORTH, TRUE, tgray);
  1362. X            if (!argp->halfgrid)
  1363. X                tick(x, Yaxis.gmax, SOUTH, TRUE, tgray);
  1364. X            }
  1365. X        if ( DoAxisLabels )
  1366. X            tickText(x, Yaxis.gmin, x, SOUTH, font);
  1367. X        }
  1368. X        x += argp->distg;
  1369. X    }
  1370. X
  1371. X    /*
  1372. X     * Draw the "title" of the axis
  1373. X     */
  1374. X    if ( argp->label != NULL )
  1375. X        axisText(argp->label, SOUTH, font);
  1376. X
  1377. X    if (argp->datatick)
  1378. X        return;
  1379. X
  1380. X    /*
  1381. X     * Draw the ticks for the endpoints
  1382. X     */
  1383. X    if ( argp->gridtype == FULL ) {
  1384. X        gridLine(Xaxis.gmin, Yaxis.gmin, Xaxis.gmin, Yaxis.gmax, agray);
  1385. X        gridLine(Xaxis.gmax, Yaxis.gmin, Xaxis.gmax, Yaxis.gmax, agray);
  1386. X    } else if ( argp->gridtype==TICKS ) {
  1387. X        tick(Xaxis.gmin, Yaxis.gmin, NORTH, TRUE, tgray);
  1388. X        tick(Xaxis.gmax, Yaxis.gmin, NORTH, TRUE, tgray);
  1389. X        if (!argp->halfgrid) {
  1390. X        tick(Xaxis.gmin, Yaxis.gmax, SOUTH, TRUE, tgray);
  1391. X        tick(Xaxis.gmax, Yaxis.gmax, SOUTH, TRUE, tgray);
  1392. X        }
  1393. X    }
  1394. X
  1395. X    /*
  1396. X     * Draw the secondary ticks
  1397. X     */
  1398. X    if ( argp->tickflag ) {
  1399. X        if (argp->minflag && argp->distf)
  1400. X            x = argp->gmin;
  1401. X        else
  1402. X            x = argp->pmin;
  1403. X        while ( LT(x, argp->gmax) ) {
  1404. X            if ( GT(x, argp->gmin) ) {
  1405. X                tick(x, Yaxis.gmin, NORTH, FALSE, tgray);
  1406. X                if (!argp->halfgrid)
  1407. X                    tick(x, Yaxis.gmax, SOUTH, FALSE, tgray);
  1408. X            }
  1409. X            x += argp->tick;
  1410. X        }
  1411. X    }
  1412. X}
  1413. X
  1414. XlogX()
  1415. X{
  1416. X    register axis_t *argp;
  1417. X    char    *font;
  1418. X    float    x, d1, d2, dist;
  1419. X    float    amin, amax;
  1420. X    float agray, tgray;
  1421. X    int i;
  1422. X
  1423. X    argp = &Xaxis;
  1424. X    agray = argp->axisgray;
  1425. X    tgray = argp->tickgray;
  1426. X    font = argp->font ? argp->font : TextFont;
  1427. X    amin = argp->gmin; amax = argp->gmax;
  1428. X
  1429. X    if (argp->rangeframe) {
  1430. X        amin = argp->min; amax = argp->max;
  1431. X    }
  1432. X
  1433. X    if ( argp->gridtype != NONE ) {
  1434. X        gridLine(amin, Yaxis.gmin, amax, Yaxis.gmin, agray);
  1435. X        if (!argp->halfgrid)
  1436. X            gridLine(amin, Yaxis.gmax, amax, Yaxis.gmax, agray);
  1437. X    }
  1438. X    if (DoAxisLabels) {
  1439. X        tickText(argp->gmin, Yaxis.gmin, argp->gmin, SOUTH, font);
  1440. X        tickText(argp->gmax, Yaxis.gmin, argp->gmax, SOUTH, font);
  1441. X    }
  1442. X
  1443. X    if ( argp->gridtype == FULL ) {
  1444. X        gridLine(Xaxis.gmin, Yaxis.gmin, Xaxis.gmin, Yaxis.gmax, agray);
  1445. X        gridLine(Xaxis.gmax, Yaxis.gmin, Xaxis.gmax, Yaxis.gmax, agray);
  1446. X    } else if ( argp->gridtype==TICKS ) {
  1447. X        tick(Xaxis.gmin, Yaxis.gmin, NORTH, TRUE, tgray);
  1448. X        tick(Xaxis.gmax, Yaxis.gmin, NORTH, TRUE, tgray);
  1449. X        if (!argp->halfgrid) {
  1450. X        tick(Xaxis.gmin, Yaxis.gmax, SOUTH, TRUE, tgray);
  1451. X        tick(Xaxis.gmax, Yaxis.gmax, SOUTH, TRUE, tgray);
  1452. X        }
  1453. X    }
  1454. X
  1455. X    if (argp->datatick) {
  1456. X        for (i = 0; i < NumTokens; i++) {
  1457. X        if (Token[i].type != POINT)
  1458. X            continue;
  1459. X        x = Token[i].val[0];
  1460. X        if (argp->gridtype == FULL)
  1461. X            gridLine(x, Yaxis.gmin, x, Yaxis.gmax, tgray);
  1462. X        else {
  1463. X            tick(x, Yaxis.gmin, NORTH, TRUE, tgray);
  1464. X            if (!argp->halfgrid)
  1465. X            tick(x, Yaxis.gmax, SOUTH, TRUE, tgray);
  1466. X        }
  1467. X        if (argp->datalabel)
  1468. X            tickText(x, Yaxis.gmin, x, SOUTH, font);
  1469. X        }
  1470. X    }
  1471. X
  1472. X    if ( argp->label != NULL )
  1473. X        axisText(argp->label, SOUTH, font);
  1474. X
  1475. X    x = argp->gmin;
  1476. X
  1477. X    d1 = ipow(10.0, (int)floor(log10(x)));
  1478. X    while ( LT(d1, argp->gmax) ) {
  1479. X        d2 = (argp->distg > 0) ? 10.0 * d1 : d1 / 10.0;
  1480. X        if ( GT(d1, argp->gmin) ) {
  1481. X        if (!argp->datatick)
  1482. X            if ( argp->gridtype==FULL )
  1483. X            gridLine(d1, Yaxis.gmin, d1, Yaxis.gmax, tgray);
  1484. X            else if ( argp->gridtype==TICKS ) {
  1485. X            tick(d1, Yaxis.gmin, NORTH, TRUE, tgray);
  1486. X            if (!argp->halfgrid)
  1487. X                tick(d1, Yaxis.gmax, SOUTH, TRUE, tgray);
  1488. X            }
  1489. X        if ( DoAxisLabels )
  1490. X            tickText(d1, Yaxis.gmin, d1, SOUTH, font);
  1491. X        }
  1492. X        if ( argp->intervals && !argp->datatick ) {
  1493. X        dist = copysign(d2 / argp->intervals, argp->distg);
  1494. X        x = d1;
  1495. X        while (LT(x, d2) && LT(x, argp->gmax)) {
  1496. X            if ( GT(x, argp->gmin) ) {
  1497. X            tick(x, Yaxis.gmin, NORTH, FALSE, tgray);
  1498. X            if (!argp->halfgrid)
  1499. X                tick(x, Yaxis.gmax, SOUTH, FALSE, tgray);
  1500. X            }
  1501. X            x += dist;
  1502. X        }
  1503. X        }
  1504. X        d1 = d2;
  1505. X    }
  1506. X}
  1507. X
  1508. XlinearY()
  1509. X{
  1510. X    register axis_t *argp;
  1511. X    char *font;
  1512. X    float y;
  1513. X    float amin, amax;
  1514. X    float agray, tgray;
  1515. X    int i;
  1516. X
  1517. X    argp = &Yaxis;
  1518. X    font = argp->font ? argp->font : TextFont;
  1519. X    agray = argp->axisgray;
  1520. X    tgray = argp->tickgray;
  1521. X    amin = argp->gmin; amax = argp->gmax;
  1522. X
  1523. X    if (argp->rangeframe) {
  1524. X        amin = argp->min; amax = argp->max;
  1525. X    }
  1526. X
  1527. X    if ( argp->gridtype != NONE ) {
  1528. X        gridLine(Xaxis.gmin, amin, Xaxis.gmin, amax, agray);
  1529. X        if (!argp->halfgrid)
  1530. X            gridLine(Xaxis.gmax, amin, Xaxis.gmax, amax, agray);
  1531. X    }
  1532. X
  1533. X    if (DoAxisLabels) {
  1534. X        tickText(Xaxis.gmin, Yaxis.gmin, Yaxis.gmin, WEST, font);
  1535. X        tickText(Xaxis.gmin, Yaxis.gmax, Yaxis.gmax, WEST, font);
  1536. X    }
  1537. X
  1538. X    if (argp->datatick) {
  1539. X        for (i = 0; i < NumTokens; i++) {
  1540. X        if (Token[i].type != POINT)
  1541. X            continue;
  1542. X        y = Token[i].val[1];
  1543. X        if (argp->gridtype == FULL)
  1544. X            gridLine(Xaxis.gmin, y, Xaxis.gmax, y, tgray);
  1545. X        else {
  1546. X            tick(Xaxis.gmin, y, EAST, TRUE, tgray);
  1547. X            if (!argp->halfgrid)
  1548. X            tick(Xaxis.gmax, y, WEST, TRUE, tgray);
  1549. X        }
  1550. X        if (argp->datalabel)
  1551. X            tickText(Xaxis.gmin, y, y, WEST, font);
  1552. X        }
  1553. X    }
  1554. X
  1555. X    y = argp->gmin;
  1556. X    
  1557. X    while ( LT(y, argp->gmax) ) {
  1558. X        if ( GT(y, argp->gmin) ) {
  1559. X        if (!argp->datatick)
  1560. X            if ( argp->gridtype==FULL )
  1561. X            gridLine(Xaxis.gmin, y, Xaxis.gmax, y, tgray);
  1562. X            else if ( argp->gridtype==TICKS ) {
  1563. X            tick(Xaxis.gmin, y, EAST, TRUE, tgray);
  1564. X            if (!argp->halfgrid)
  1565. X                tick(Xaxis.gmax, y, WEST, TRUE, tgray);
  1566. X            }
  1567. X        if ( DoAxisLabels )
  1568. X            tickText(Xaxis.gmin, y, y, WEST, font);
  1569. X        }
  1570. X        y += argp->distg;
  1571. X    }
  1572. X
  1573. X    if (argp->label != NULL)
  1574. X        axisText(argp->label, WEST, font);
  1575. X    
  1576. X    if (argp->datatick)
  1577. X        return;
  1578. X
  1579. X    if ( argp->gridtype == FULL ) {
  1580. X        gridLine(Xaxis.gmin, Yaxis.gmin, Xaxis.gmax, Yaxis.gmin, agray);
  1581. X        gridLine(Xaxis.gmin, Yaxis.gmax, Xaxis.gmax, Yaxis.gmax, agray);
  1582. X    } else if ( argp->gridtype==TICKS ) {
  1583. X        tick(Xaxis.gmin, Yaxis.gmin, EAST, TRUE, tgray);
  1584. X        tick(Xaxis.gmin, Yaxis.gmax, EAST, TRUE, tgray);
  1585. X        if (!argp->halfgrid) {
  1586. X        tick(Xaxis.gmax, Yaxis.gmin, WEST, TRUE, tgray);
  1587. X        tick(Xaxis.gmax, Yaxis.gmax, WEST, TRUE, tgray);
  1588. X        }
  1589. X    }
  1590. X        
  1591. X    if ( argp->tickflag ) {
  1592. X        if ( argp->minflag && argp->distf )
  1593. X            y = argp->gmin;
  1594. X        else
  1595. X            y = argp->pmin;
  1596. X        while ( LT(y, argp->gmax) ) {
  1597. X            if ( GT(y, argp->gmin) ) {
  1598. X                tick(Xaxis.gmin, y, EAST, FALSE, tgray);
  1599. X                if (!argp->halfgrid)
  1600. X                    tick(Xaxis.gmax, y, WEST, FALSE, tgray);
  1601. X            }
  1602. X            y += argp->tick;
  1603. X        }
  1604. X    }
  1605. X}
  1606. X
  1607. XlogY()
  1608. X{
  1609. X    register axis_t *argp;
  1610. X    char *font;
  1611. X    float y, d1, d2, dist;
  1612. X    float    amin, amax;
  1613. X    float agray, tgray;
  1614. X    int i;
  1615. X
  1616. X    argp = &Yaxis;
  1617. X    agray = argp->axisgray;
  1618. X    tgray = argp->tickgray;
  1619. X    font = argp->font ? argp->font : TextFont;
  1620. X    amin = argp->gmin; amax = argp->gmax;
  1621. X
  1622. X    if (argp->rangeframe) {
  1623. X        amin = argp->min; amax = argp->max;
  1624. X    }
  1625. X
  1626. X    if ( argp->gridtype != NONE ) {
  1627. X        gridLine(Xaxis.gmin, amin, Xaxis.gmin, amax, agray);
  1628. X        if (!argp->halfgrid)
  1629. X            gridLine(Xaxis.gmax, amin, Xaxis.gmax, amax, agray);
  1630. X    }
  1631. X    if (DoAxisLabels) {
  1632. X        tickText(Xaxis.gmin, Yaxis.gmin, Yaxis.gmin, WEST, font);
  1633. X        tickText(Xaxis.gmin, Yaxis.gmax, Yaxis.gmax, WEST, font);
  1634. X    }
  1635. X
  1636. X    if ( argp->gridtype == FULL ) {
  1637. X        gridLine(Xaxis.gmin, Yaxis.gmin, Xaxis.gmax, Yaxis.gmin, agray);
  1638. X        gridLine(Xaxis.gmin, Yaxis.gmax, Xaxis.gmax, Yaxis.gmax, agray);
  1639. X    } else if ( argp->gridtype==TICKS ) {
  1640. X        tick(Xaxis.gmin, Yaxis.gmin, EAST, TRUE, tgray);
  1641. X        tick(Xaxis.gmin, Yaxis.gmax, EAST, TRUE, tgray);
  1642. X        if (!argp->halfgrid) {
  1643. X        tick(Xaxis.gmax, Yaxis.gmin, WEST, TRUE, tgray);
  1644. X        tick(Xaxis.gmax, Yaxis.gmax, WEST, TRUE, tgray);
  1645. X        }
  1646. X    }
  1647. X
  1648. X    if (argp->datatick) {
  1649. X        for (i = 0; i < NumTokens; i++) {
  1650. X        if (Token[i].type != POINT)
  1651. X            continue;
  1652. X        y = Token[i].val[1];
  1653. X        if (argp->gridtype == FULL)
  1654. X             gridLine(Xaxis.gmin, y, Xaxis.gmax, y, tgray);
  1655. X        else {
  1656. X            tick(Xaxis.gmin, y, EAST, TRUE, tgray);
  1657. X            if (!argp->halfgrid)
  1658. X            tick(Xaxis.gmax, y, WEST, TRUE, tgray);
  1659. X        }
  1660. X        if (argp->datalabel)
  1661. X            tickText(Xaxis.gmin, y, y, WEST, font);
  1662. X        }
  1663. X    }
  1664. X
  1665. X    if ( argp->label != NULL )
  1666. X        axisText(argp->label, WEST, font);
  1667. X
  1668. X    y = argp->gmin;
  1669. X        
  1670. X    d1 = ipow(10.0, (int)floor(log10(y)));
  1671. X    while (LT(d1, argp->gmax)) {
  1672. X        d2 = (argp->distg > 0) ? 10.0 * d1 : d1 / 10.0;
  1673. X        if ( GT(d1, argp->gmin) ) {
  1674. X        if (!argp->datatick)
  1675. X            if ( argp->gridtype==FULL )
  1676. X            gridLine(Xaxis.gmin, d1, Xaxis.gmax, d1, tgray);
  1677. X            else if ( argp->gridtype==TICKS ) {
  1678. X            tick(Xaxis.gmin, d1, EAST, TRUE, tgray);
  1679. X            if (!argp->halfgrid)
  1680. X                tick(Xaxis.gmax, d1, WEST, TRUE, tgray);
  1681. X            }
  1682. X        if ( DoAxisLabels )
  1683. X            tickText(Xaxis.gmin, d1, d1, WEST, font);
  1684. X        }
  1685. X        if ( argp->intervals && !argp->datatick ) {
  1686. X        dist = copysign(d2 / argp->intervals, argp->distg);
  1687. X        y = d1;
  1688. X        while ( LT(y, d2) && LT(y, argp->gmax)) {
  1689. X            if ( GT(y, argp->gmin) ) {
  1690. X            tick(Xaxis.gmin, y, EAST, FALSE, tgray);
  1691. X            if (!argp->halfgrid)
  1692. X                tick(Xaxis.gmax, y, WEST, FALSE, tgray);
  1693. X            }
  1694. X            y += dist;
  1695. X        }
  1696. X        }
  1697. X        d1 = d2;
  1698. X    }
  1699. X}
  1700. X
  1701. X/*
  1702. X *----------------------------------------------------------------------
  1703. X *
  1704. X * GRID COMPUTATION ROUTINES
  1705. X *
  1706. X * These routines are from ACM Collected Algorithms, Number 463.
  1707. X *
  1708. X * Author: C.R.Lewart
  1709. X */
  1710. X
  1711. Xfloat ipow(x,i)
  1712. Xfloat x;
  1713. Xint i;
  1714. X{
  1715. X    float    res;
  1716. X    
  1717. X    res = 1.0;
  1718. X    if ( i > 0 )
  1719. X        while ( i-- > 0 )
  1720. X            res *= x;
  1721. X    else
  1722. X        while ( i++ < 0 )
  1723. X            res /= x;
  1724. X    return res;
  1725. X}            
  1726. X
  1727. X/*
  1728. X * scale1
  1729. X *
  1730. X * Given data extremes xmin and xmax, and number of desired grid lines n
  1731. X * (advisory only), compute plot minimum and maximum xpmin and xpmax with
  1732. X * distance between grid lines dist.
  1733. X *
  1734. X * Translated from FORTRAN to C by Bob Brown.
  1735. X */
  1736. X
  1737. Xscale1(xmin, xmax, n, xpmin, xpmax, dist)
  1738. Xfloat    xmin, xmax;
  1739. Xint    n;
  1740. Xfloat    *xpmin, *xpmax, *dist;
  1741. X{
  1742. X    static float vint[] = { 1.0, 2.0, 5.0, 10.0 };
  1743. X    static float sqr[] = { 1.414213562373, 3.162277660168, 7.071067811865 };
  1744. X    static float del = 0.000001;
  1745. X    float a, al, b, fm;
  1746. X    int nal, m, i;
  1747. X
  1748. X    if (xmax == xmin)
  1749. X        xmax += 1.0;
  1750. X    a = fabs((xmax-xmin)/(float)n);
  1751. X    al = log10(a);
  1752. X    nal = (int)al;
  1753. X    if ( a < 1.0 )
  1754. X        nal -= 1;
  1755. X    b = a/ipow(10.0, nal);
  1756. X    for ( i=0 ; i<3 ; i++ )
  1757. X        if ( b < sqr[i] )
  1758. X            break;
  1759. X    *dist = copysign(vint[i] * ipow(10.0, nal), (xmax - xmin));
  1760. X    fm = xmin / *dist;
  1761. X    m = fm < 0.0 ? (int)fm - 1 : (int)fm;
  1762. X    if ( fabs((float)m+1.0-fm) < del )
  1763. X        m += 1;
  1764. X    *xpmin = *dist * (float)m;
  1765. X    fm = xmax / *dist;
  1766. X    m = fm < -1.0 ? (int)fm : (int)fm + 1;
  1767. X    if ( fabs(fm+1.0-(float)m) < del )
  1768. X        m -= 1;
  1769. X    *xpmax = *dist * (float)m;
  1770. X    if ( *xpmin > xmin )
  1771. X        *xpmin = xmin;
  1772. X    if ( *xpmax < xmax )
  1773. X        *xpmax = xmax;
  1774. X}
  1775. END_OF_FILE
  1776. if test 18865 -ne `wc -c <'grid.c'`; then
  1777.     echo shar: \"'grid.c'\" unpacked with wrong size!
  1778. fi
  1779. # end of 'grid.c'
  1780. fi
  1781. if test -f 'output.c' -a "${1}" != "-c" ; then 
  1782.   echo shar: Will not clobber existing file \"'output.c'\"
  1783. else
  1784. echo shar: Extracting \"'output.c'\" \(20906 characters\)
  1785. sed "s/^X//" >'output.c' <<'END_OF_FILE'
  1786. X/* $Header: output.c,v 1.10 92/08/04 17:55:10 mogul Exp $ */
  1787. X
  1788. X/*
  1789. X *               Copyright 1989, 1992 Digital Equipment Corporation
  1790. X *                          All Rights Reserved
  1791. X * 
  1792. X * 
  1793. X * Permission to use, copy, and modify this software and its documentation
  1794. X * is hereby granted only under the following terms and conditions.  Both
  1795. X * the above copyright notice and this permission notice must appear in
  1796. X * all copies of the software, derivative works or modified versions, and
  1797. X * any portions threof, and both notices must appear in supporting
  1798. X * documentation.
  1799. X * 
  1800. X * Users of this software agree to the terms and conditions set forth
  1801. X * herein, and hereby grant back to Digital a non-exclusive, unrestricted,
  1802. X * royalty-free right and license under any changes, enhancements or
  1803. X * extensions made to the core functions of the software, including but
  1804. X * not limited to those affording compatibility with other hardware or
  1805. X * software environments, but excluding applications which incorporate
  1806. X * this software.  Users further agree to use their best efforts to return
  1807. X * to Digital any such changes, enhancements or extensions that they make
  1808. X * and inform Digital of noteworthy uses of this software.  Correspondence
  1809. X * should be provided to Digital at:
  1810. X * 
  1811. X *                       Director of Licensing
  1812. X *                       Western Research Laboratory
  1813. X *                       Digital Equipment Corporation
  1814. X *                       250 University Avenue
  1815. X *                       Palo Alto, California  94301  
  1816. X * 
  1817. X * This software may be distributed (but not offered for sale or
  1818. X * transferred for compensation) to third parties, provided such third
  1819. X * parties agree to abide by the terms and conditions of this notice.
  1820. X * 
  1821. X * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS
  1822. X * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
  1823. X * WARRANTIES OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL
  1824. X * EQUIPMENT CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  1825. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  1826. X * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1827. X * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1828. X * PERFORMANCE OF THIS SOFTWARE.
  1829. X */
  1830. X
  1831. X/* 
  1832. X * output.c - Spit out the PostScript
  1833. X * 
  1834. X * Author:    Christopher A. Kent
  1835. X *         Western Research Laboratory
  1836. X *         Digital Equipment Corporation
  1837. X * Date:    Wed Jan  4 1989
  1838. X */
  1839. X
  1840. X/*
  1841. X * $Log:    output.c,v $
  1842. X * Revision 1.10  92/08/04  17:55:10  mogul
  1843. X * undo RCS botch
  1844. X * 
  1845. X * Revision 1.9  1992/07/16  20:07:09  cak
  1846. X * Fix markergray implementation so it doesn't blow away the effects of color.
  1847. X *
  1848. X * Revision 1.8  1992/06/17  22:14:41  kent
  1849. X * Make axis specs with max < min work, fix some bugs with centering
  1850. X * and multiple args.
  1851. X *
  1852. X * Revision 1.7  1992/06/16  01:48:11  kent
  1853. X * Make y positioning and centering and such work right.
  1854. X *
  1855. X * Revision 1.6  1992/04/06  21:14:03  kent
  1856. X * Broke the bounding box computation last time 'round. Fixed.
  1857. X *
  1858. X * Revision 1.5  1992/04/02  00:45:01  kent
  1859. X * Changes to handle lots of points; when using dataticks, the axis
  1860. X * routines could get too big and overflow the operand stack. As
  1861. X * a result, the output PostScript code is even uglier.
  1862. X *
  1863. X * Revision 1.4  1992/03/31  02:31:34  kent
  1864. X * Added markergray verb and fixed inverted gray values.
  1865. X *
  1866. X * Revision 1.3  1992/03/31  00:07:39  kent
  1867. X * Added markerscale verb.
  1868. X *
  1869. X * Revision 1.2  1992/03/30  23:33:47  kent
  1870. X * Added halfopen, halfticks grid styles, range frames, and gray.
  1871. X *
  1872. X * Revision 1.1  1992/03/20  21:25:43  kent
  1873. X * Initial revision
  1874. X *
  1875. X * Revision 1.16  92/02/21  17:13:23  mogul
  1876. X * Added Digital license info
  1877. X * 
  1878. X * Revision 1.15  91/02/04  17:03:22  mogul
  1879. X * Break up long sets of text commands to avoid producing
  1880. X * PostScript with excessively long lines (hard to email).
  1881. X * 
  1882. X * 
  1883. X * Revision 1.14  91/02/04  16:48:27  mogul
  1884. X * Don't emit color changes when not necessary (saves space in
  1885. X * output file).
  1886. X * 
  1887. X * Revision 1.13  91/02/04  16:31:05  mogul
  1888. X * fixed color support for text, markers
  1889. X * 
  1890. X * Revision 1.12  90/12/11  20:41:55  reid
  1891. X * Added support for new "color" and "linewidth" options.
  1892. X * 
  1893. X * Revision 1.11  90/11/05  11:11:44  reid
  1894. X * Checking in Chris Kent's changes of June 1989
  1895. X * 
  1896. X * Revision 1.10  89/03/01  10:44:40  kent
  1897. X * NORTH and WEST axis text must be adjusted based on point size, since the
  1898. X * code in the prologue "unadjusts" it based on the point size.
  1899. X * 
  1900. X * Revision 1.9  89/02/03  09:33:23  kent
  1901. X * Make splines work on log scales.
  1902. X * 
  1903. X * Revision 1.8  89/01/27  15:56:15  kent
  1904. X * Line style "off" has to be handled in code, since there's no way I can
  1905. X * cleanly use setdash to draw an "empty" line. Also fixed problems with
  1906. X * axisText on axes with non-zero origins.
  1907. X * 
  1908. X * Revision 1.7  89/01/11  09:14:27  kent
  1909. X * Removed some internal knowledge about the semantics of line types. This
  1910. X * is all in the PostScript now.
  1911. X * 
  1912. X * Revision 1.6  89/01/10  18:19:55  kent
  1913. X * Moved marker code to prolog, added error checking and messages.
  1914. X * 
  1915. X * Revision 1.5  89/01/09  22:18:45  kent
  1916. X * Added log scales.
  1917. X * 
  1918. X * Revision 1.4  89/01/04  17:40:56  kent
  1919. X * Moved font stuff from main.c to output.c.
  1920. X * newfont() sets PS fontsize variable so white background is the right size.
  1921. X * 
  1922. X * Revision 1.3  89/01/04  17:30:31  kent
  1923. X * Made command line arguments override compiled-in defaults for
  1924. X * all plots in a run, not just the first one. 
  1925. X * 
  1926. X * Revision 1.2  89/01/04  15:22:08  kent
  1927. X * Massive renaming. No functional change.
  1928. X * 
  1929. X * Revision 1.1  89/01/04  13:57:59  kent
  1930. X * Initial revision
  1931. X * 
  1932. X */
  1933. X
  1934. Xstatic char rcs_ident[] = "$Header: output.c,v 1.10 92/08/04 17:55:10 mogul Exp $";
  1935. X
  1936. X#include <stdio.h>
  1937. X#include <assert.h>
  1938. X
  1939. X#include "psgraph.h"
  1940. X
  1941. Xtypedef struct _plotpoint {
  1942. X    float x, y;
  1943. X}plotpoint_t;
  1944. X
  1945. X/*
  1946. X * doplot - generate all the output text for the plot.
  1947. X *
  1948. X * BUG: leaks storage if called multiple times.
  1949. X */
  1950. X
  1951. Xdoplot()
  1952. X{
  1953. X    int     i, numpoints, sizeofpoints;
  1954. X    plotpoint_t    *points;
  1955. X
  1956. X    CurrentPage++;
  1957. X    printf("%%%%Page: %d %d\n", CurrentPage, CurrentPage);
  1958. X    printf("StartPSGraph\n");
  1959. X    printf("/saveIt save def\ngsave\n/solid f\n");
  1960. X    TextFont = TEXTFONT;
  1961. X    CurrentFont = NULL;
  1962. X    newfont(TextFont);
  1963. X
  1964. X/**/
  1965. X
  1966. X    setupAxes();
  1967. X
  1968. X    doXaxis();
  1969. X
  1970. X    doYaxis();
  1971. X
  1972. X    printf("/drawTitle [\n");
  1973. X    doTitle();
  1974. X    printf("] cvx bind def\n");
  1975. X
  1976. X    if (Preview)
  1977. X        printf("1 1 translate\n");
  1978. X
  1979. X    if (Xcenter != 0.0) {        /* do centering */
  1980. X        printf("%f %f sub 2 div 0 translate\n", 
  1981. X            Xcenter, Xaxis.size);
  1982. X        /* must adjust bbox */
  1983. X        minX += (Xcenter - Xaxis.size) / 2.0;
  1984. X        maxX += (Xcenter - Xaxis.size) / 2.0;
  1985. X        /* move Y origin to 0 */
  1986. X        printf("0 %f translate\n", -minY);
  1987. X        maxY -= minY; minY = 0.0;
  1988. X    } else {
  1989. X        printf("%f %f translate\n",    /* move origin to 0,0 */
  1990. X            -minX, -minY);
  1991. X        maxX -= minX; minX = 0.0;
  1992. X        maxY -= minY; minY = 0.0;
  1993. X    }
  1994. X    printf("drawXaxis drawYaxis drawTitle\n");
  1995. X
  1996. X    MinX = MIN(minX, MinX);
  1997. X    MinY = MIN(minY, MinY);
  1998. X    MaxX = MAX(maxX, MaxX);
  1999. X    MaxY = MAX(maxY, MaxY);
  2000. X
  2001. X    sizeofpoints = 10;
  2002. X    points=(plotpoint_t *)calloc(10,sizeof(plotpoint_t));
  2003. X    numpoints = 0;
  2004. X    cliplimits(Xaxis.gmin-ClipDist/Xaxis.size*(Xaxis.gmax-Xaxis.gmin),
  2005. X           Yaxis.gmin-ClipDist/Yaxis.size*(Yaxis.gmax-Yaxis.gmin),
  2006. X           Xaxis.gmax+ClipDist/Xaxis.size*(Xaxis.gmax-Xaxis.gmin),
  2007. X           Yaxis.gmax+ClipDist/Yaxis.size*(Yaxis.gmax-Yaxis.gmin),
  2008. X           Xaxis.distg < 0, Yaxis.distg < 0);
  2009. X    for(i=0 ; i<NumTokens; i++) {
  2010. X        switch(Token[i].type) {
  2011. X        case TRANS:
  2012. X            if (numpoints > 0) {
  2013. X                dumppoints(points, numpoints);
  2014. X                numpoints = 0;
  2015. X            }
  2016. X            TransparentLabels = Token[i].ival;
  2017. X            break;
  2018. X        case BREAK:
  2019. X            if ( numpoints > 0 ) {
  2020. X                dumppoints(points,numpoints);
  2021. X                numpoints = 0;
  2022. X            }
  2023. X            break;
  2024. X        case LINETYPE:
  2025. X            if ( numpoints > 0 ) {
  2026. X                dumppoints(points,numpoints);
  2027. X                numpoints = 0;
  2028. X                UseSpline = FALSE;
  2029. X            }
  2030. X            if ( Token[i].label != NULL )
  2031. X                LineType = Token[i].label;
  2032. X            break;
  2033. X        case LINECOLOR:
  2034. X            if ( numpoints > 0 ) {
  2035. X                dumppoints(points,numpoints);
  2036. X                numpoints = 0;
  2037. X                UseSpline = FALSE;
  2038. X            }
  2039. X            if ( Token[i].label != NULL ) {
  2040. X                LineColor = Token[i].label;
  2041. X                TextColor = Token[i].label;
  2042. X                MarkColor = Token[i].label;
  2043. X                graymarker(0.0);
  2044. X            }
  2045. X            break;
  2046. X        case LINEWIDTH:
  2047. X            if ( numpoints > 0 ) {
  2048. X                dumppoints(points,numpoints);
  2049. X                numpoints = 0;
  2050. X                UseSpline = FALSE;
  2051. X            }
  2052. X            if ( Token[i].label != NULL )
  2053. X                LineWidth = Token[i].label;
  2054. X            break;
  2055. X        case MARKER:
  2056. X            UseMarker = Token[i].label;
  2057. X            setmarker(UseMarker);
  2058. X            break;
  2059. X        case MARKERSCALE:
  2060. X            scalemarker(Token[i].val[0]);
  2061. X            break;
  2062. X        case MARKERGRAY:
  2063. X            graymarker(Token[i].val[0]);
  2064. X            break;
  2065. X        case FONT:
  2066. X            if ( numpoints > 0 ) {
  2067. X                dumppoints(points,numpoints);
  2068. X                points[0] = points[numpoints-1];
  2069. X                numpoints = 1;
  2070. X            }
  2071. X            if ( Token[i].label != NULL ) {
  2072. X                newfont(Token[i].label);
  2073. X                TextFont = Token[i].label;
  2074. X            }
  2075. X            break;
  2076. X        case TEXT:
  2077. X            if ( numpoints > 0 ) {
  2078. X                dumppoints(points,numpoints);
  2079. X                numpoints = 0;
  2080. X            }
  2081. X            if ( code(Token[i].xval,Token[i].yval)==0 )
  2082. X                text(Token[i].label,sx(Token[i].xval),sy(Token[i].yval),"ljust");
  2083. X            break;
  2084. X        case SPLINE:
  2085. X            dumppoints(points,numpoints);
  2086. X            numpoints = 0;
  2087. X            UseSpline = TRUE;
  2088. X            break;
  2089. X        case POINT:
  2090. X            if ( numpoints >= sizeofpoints ) {
  2091. X                sizeofpoints += 10;
  2092. X                points = (plotpoint_t *)realloc((char *)points,sizeofpoints*sizeof(plotpoint_t));
  2093. X            }
  2094. X            points[numpoints].x = Token[i].val[0];
  2095. X            points[numpoints++].y = Token[i].val[1];
  2096. X            if ( Token[i].label != NULL ) {
  2097. X                if ( code(Token[i].xval,Token[i].yval)==0 )
  2098. X                    if (TransparentLabels)
  2099. X                        text(Token[i].label,
  2100. X                        sx(Token[i].val[0])+0.1,
  2101. X                        sy(Token[i].val[1]),"ljust");
  2102. X                    else
  2103. X                        wtext(Token[i].label,
  2104. X                        sx(Token[i].val[0])+0.1,
  2105. X                        sy(Token[i].val[1]),"ljust");
  2106. X                if (BreakAfterLabel && numpoints > 0) {
  2107. X                    dumppoints(points,numpoints);
  2108. X                    numpoints = 0;
  2109. X                }
  2110. X            }
  2111. X            if ( UseMarker != NULL )
  2112. X                domarker(Token[i].val[0],Token[i].val[1]);
  2113. X            break;
  2114. X        }
  2115. X    }
  2116. X    dumppoints(points,numpoints);
  2117. X    printf("grestore saveIt restore\n");
  2118. X    if (Preview)
  2119. X/*        printf("gsave showpage grestore\n");*/
  2120. X        printf("showpage\n");
  2121. X    /*
  2122. X     * bah ... these can be supplied with command line arguments, but
  2123. X     * they shouldn't leak through to a second graph...
  2124. X     */
  2125. X    
  2126. X    Title.title = NULL;
  2127. X    Title.font = NULL;
  2128. X}
  2129. X
  2130. X/*
  2131. X * dumppoints - generate the commands for the data stored in the points array.
  2132. X */
  2133. X
  2134. Xdumppoints(points, numpoints)
  2135. Xplotpoint_t *points;
  2136. Xint numpoints;
  2137. X{
  2138. X    int i;
  2139. X    float xs, ys, xe, ye;
  2140. X    float dxi, dyi, dxi1, dyi1;
  2141. X
  2142. X    if (numpoints < 2 ||
  2143. X        strcmp(LineType, "off") == 0 ||
  2144. X        strcmp(LineType, "none") == 0)
  2145. X        return;
  2146. X    if ( UseSpline ) {
  2147. X        i = 1;
  2148. X        while (!clip(points[i-1].x, points[i-1].y,
  2149. X                points[i].x, points[i].y,
  2150. X                &xs, &ys, &xe, &ye)) 
  2151. X            i++;        /* remove invisibles at beginning */
  2152. X
  2153. X        startline(xs, ys);
  2154. X        printf(" %f %f rlineto\n",
  2155. X            (SX(xe) - SX(xs))/2, (SY(ye) - SY(ys))/2);
  2156. X
  2157. X        for (; i < numpoints - 1; i++){
  2158. X            if ( clip(points[i-1].x, points[i-1].y,
  2159. X                  points[i].x, points[i].y,
  2160. X                  &xs, &ys, &xe, &ye)) {
  2161. X                dxi = SX(xe) - SX(xs);
  2162. X                dyi = SY(ye) - SY(ys);
  2163. X            } else {/* handle intermediate clipping */}
  2164. X            if ( clip(points[i].x, points[i].y,
  2165. X                  points[i+1].x, points[i+1].y,
  2166. X                  &xs, &ys, &xe, &ye)) {
  2167. X                dxi1 = SX(xe) - SX(xs);
  2168. X                dyi1 = SY(ye) - SY(ys);
  2169. X            } else {/* ditto. it's ugly */}
  2170. X            printf(" %f %f %f %f %f %f rcurveto\n",
  2171. X                dxi/3, dyi/3,
  2172. X                (3*dxi+dxi1)/6, (3*dyi+dyi1)/6,
  2173. X                (dxi+dxi1)/2, (dyi+dyi1)/2);
  2174. X        }
  2175. X        contline(xe, ye);        
  2176. X    } else for ( i=1 ; i<numpoints ; i++ ) {
  2177. X        if ( clip(points[i-1].x, points[i-1].y,
  2178. X              points[i].x,points[i].y, &xs, &ys, &xe, &ye)) {
  2179. X            if ( i==1 || xs!=points[i-1].x && ys!=points[i-1].y) {
  2180. X                if ( i != 1 )
  2181. X                    printf("\n");
  2182. X                startline(xs,ys);
  2183. X            }
  2184. X            contline(xe,ye);
  2185. X        }
  2186. X    }
  2187. X}
  2188. X
  2189. XstartGridTemp()
  2190. X{
  2191. X    assert(!TempOpen);
  2192. X    printf("/gt%03d[\n", CurrentTemp++);
  2193. X    TempOpen = TRUE;
  2194. X    LinesInTemp = 0;
  2195. X}
  2196. X
  2197. XendGridTemp()
  2198. X{
  2199. X    assert(TempOpen);
  2200. X    printf("]cvx bind def\n");
  2201. X    TempOpen = FALSE;
  2202. X}
  2203. X
  2204. XgridLine(x1, y1, x2, y2, g)
  2205. Xfloat    x1, y1, x2, y2, g;
  2206. X{
  2207. X        if (LinesInTemp > 50) { endGridTemp(); startGridTemp(); }
  2208. X    LinesInTemp++;
  2209. X        
  2210. X    putchar('{');
  2211. X    if (g != 0.0)
  2212. X        printf("gsave %f setgray ", g);
  2213. X    stroke(sx(x1), sy(y1), sx(x2), sy(y2));
  2214. X    if (g != 0.0)
  2215. X        printf("grestore");
  2216. X    printf("\t}EX\n");
  2217. X}
  2218. X
  2219. Xtick(x, y, d, big, g)
  2220. Xfloat    x, y, g;
  2221. Xdir_t    d;
  2222. Xbool    big;
  2223. X{
  2224. X    float    len;
  2225. X
  2226. X        if (LinesInTemp > 50) { endGridTemp(); startGridTemp(); }
  2227. X    LinesInTemp++;
  2228. X
  2229. X    len = big ? TickLen : Tick2Len;
  2230. X    printf("{ ");
  2231. X    if (g != 0.0)
  2232. X        printf("gsave %f setgray ", g);
  2233. X    switch(d) {
  2234. X    case    NORTH:
  2235. X        stroke(sx(x), sy(y), sx(x), sy(y) + len);
  2236. X        break;
  2237. X    case    EAST:
  2238. X        stroke(sx(x), sy(y), sx(x) + len, sy(y));
  2239. X        break;
  2240. X    case    SOUTH:
  2241. X        stroke(sx(x), sy(y) - len, sx(x), sy(y));
  2242. X        break;
  2243. X    case    WEST:
  2244. X        stroke(sx(x) - len, sy(y), sx(x), sy(y));
  2245. X        break;
  2246. X    }
  2247. X    if (g != 0.0)
  2248. X        printf("grestore");
  2249. X    printf("\t}EX\n");
  2250. X}
  2251. X
  2252. Xstatic int    maxWest = 0;    /* most char positions west */
  2253. X
  2254. XtickText(x, y, val, d, font)
  2255. Xfloat    x, y;
  2256. Xfloat    val;
  2257. Xdir_t    d;
  2258. Xchar    *font;
  2259. X{
  2260. X    char    buf[32];
  2261. X    int    len;
  2262. X
  2263. X        if (LinesInTemp > 50) { endGridTemp(); startGridTemp(); }
  2264. X    LinesInTemp++;
  2265. X
  2266. X    sprintf(buf, "%g", val);
  2267. X    printf("{ ");
  2268. X    newfont(font);
  2269. X    switch(d){
  2270. X    case SOUTH:
  2271. X        text(buf, sx(x), sy(y) - (0.8 * PointSize/72.0), "");
  2272. X        minY = MIN(minY, sy(Yaxis.gmin)-(0.8*PointSize/72.0));
  2273. X        break;
  2274. X    case WEST:
  2275. X        text(buf, sx(x) - 0.05, sy(y), "rjust");
  2276. X        len = strlen(buf);
  2277. X        maxWest = MAX(len, maxWest);
  2278. X        minX = MIN(minX, -(0.75 * len*PointSize/72.0));
  2279. X        break;
  2280. X    }
  2281. X    printf("\t}EX\n");
  2282. X}
  2283. X
  2284. XaxisText(buf, d, font)
  2285. Xchar    *buf;
  2286. Xdir_t    d;
  2287. Xchar    *font;
  2288. X{
  2289. X    float    xc, yc;
  2290. X
  2291. X    xc = sx(Xaxis.gmin) + (SX(Xaxis.gmax) - SX(Xaxis.gmin)) / 2.0;
  2292. X    yc = sy(Yaxis.gmin) + (SY(Yaxis.gmax) - SY(Yaxis.gmin)) / 2.0;
  2293. X
  2294. X    printf("{ ");
  2295. X    newfont(font);
  2296. X    switch(d) {
  2297. X    case NORTH:
  2298. X        printf("%f %f m (%s) /cjust t ", 
  2299. X            xc, sy(Yaxis.gmax) + 0.1 + 0.3 * PointSize/72.0,
  2300. X            buf);
  2301. X        maxY = MAX(maxY, sy(Yaxis.gmax) + 0.1 + 1.3*PointSize/72.0);
  2302. X        break;
  2303. X
  2304. X    case SOUTH:
  2305. X        printf("%f %f m (%s) /cjust t ",
  2306. X            xc, sy(Yaxis.gmin) - 1.8*PointSize/72.0, buf);
  2307. X        minY = MIN(minY, sy(Yaxis.gmin) - 2.0*PointSize/72.0);
  2308. X        break;
  2309. X
  2310. X    case WEST:
  2311. X        printf("%f %f m (%s) /vjust t ", 
  2312. X            sx(Xaxis.gmin) - (0.75*maxWest * PointSize/72.0
  2313. X                      + 0.1 + 0.3 * PointSize/72.0),
  2314. X            yc, 
  2315. X            buf);
  2316. X        minX = MIN(minX, sx(Xaxis.gmin) - 
  2317. X            (0.75*maxWest*PointSize/72.0 
  2318. X             + 0.1 + 1.3 * PointSize/72.0));
  2319. X        break;        
  2320. X    }
  2321. X    printf("\t}EX\n");
  2322. X}
  2323. X
  2324. X/*
  2325. X * Plot routines -
  2326. X *
  2327. X * These routines all assume that their input is already scaled to inches
  2328. X */
  2329. X
  2330. Xstroke(x1,y1,x2,y2)
  2331. Xfloat x1,y1,x2,y2;
  2332. X{
  2333. X    printf("%f %f %f %f l ", x1, y1, x2, y2);
  2334. X}
  2335. X
  2336. Xstartline(x,y)
  2337. Xfloat x,y;
  2338. X{
  2339. X    setcolor(LineColor);
  2340. X    if (LineType != NULL && strlen(LineType)>0)
  2341. X        printf("/%s f ", LineType);
  2342. X    else
  2343. X        printf("/solid f ");
  2344. X    if (LineWidth != NULL && strlen(LineType)>0)
  2345. X        printf(" %s fw ", LineWidth);
  2346. X    else
  2347. X        printf(" 0.6 setlinewidth ");
  2348. X    printf("%f %f m\n",sx(x),sy(y));
  2349. X}
  2350. X
  2351. Xcontline(x,y)
  2352. Xfloat x,y;
  2353. X{
  2354. X    printf(" %f %f n\n",sx(x),sy(y));
  2355. X}
  2356. X
  2357. Xtext(s,x,y,mod)
  2358. Xfloat x,y;
  2359. Xchar *s, *mod;
  2360. X{
  2361. X    setcolor(TextColor);
  2362. X    printf("%f %f m (%s) ", x, y, s);
  2363. X    if ((strlen(mod) == 0) || (mod == NULL))
  2364. X        printf("/cjust ");
  2365. X    else 
  2366. X        printf ("/%s ", mod);
  2367. X    printf("t\n");
  2368. X}
  2369. X
  2370. Xwtext(s,x,y,mod)
  2371. Xfloat x,y;
  2372. Xchar *s, *mod;
  2373. X{
  2374. X    setcolor(TextColor);
  2375. X    printf("%f %f m (%s) ", x, y, s);
  2376. X    if ((strlen(mod) == 0) || (mod == NULL))
  2377. X        printf("/cjust ");
  2378. X    else 
  2379. X        printf ("/%s ", mod);
  2380. X    printf("w\n");
  2381. X}
  2382. X
  2383. Xnewfont(font)
  2384. Xregister char *font;
  2385. X{
  2386. X    char name[100];
  2387. X    int size;
  2388. X    register char *np = name;
  2389. X    register char *s = font;
  2390. X    register fontName_t *fp;
  2391. X
  2392. X    while (isascii(*s) && (isalpha(*s) || (*s == '-')))
  2393. X        *np++ = *s++;
  2394. X    *np++ = NULL;
  2395. X    if (isascii(*s) && isdigit(*s)) {
  2396. X        size = 0;
  2397. X        do
  2398. X            size = size * 10 + *s++ - '0';
  2399. X        while ('0' <= *s && *s <= '9');
  2400. X    }
  2401. X    if (*s || !size || !name[0]) {
  2402. X        fprintf (stderr, "Poorly formed font name: \"%s\"\n", name);
  2403. X        return;
  2404. X    }
  2405. X    if (CurrentFont)
  2406. X        if (size == PointSize && !strcmp(CurrentFont->name, name))
  2407. X            return;        /* no change */
  2408. X    printf("/%s findfont %d scalefont setfont ", name, size);
  2409. X    printf("/fontsize %d def\n", size);
  2410. X    PointSize = size;
  2411. X
  2412. X    for (fp = FontList; fp; fp = fp->next)
  2413. X        if (!strcmp(fp->name, name)) {
  2414. X            CurrentFont = fp;
  2415. X            return;        /* already there */
  2416. X        }
  2417. X    fp = (fontName_t *) malloc(sizeof (fontName_t));
  2418. X    fp->name = newstr(name);
  2419. X    fp->next = FontList;
  2420. X    FontList = fp;
  2421. X    CurrentFont = fp;
  2422. X}
  2423. X
  2424. X/*
  2425. X * setmarker - set the current marker type
  2426. X */
  2427. X
  2428. Xsetmarker(m)
  2429. Xchar    *m;
  2430. X{
  2431. X    printf("/%s sm\n", m);
  2432. X}
  2433. X
  2434. X/*
  2435. X * domarker - print the marker at the given point.
  2436. X */
  2437. X
  2438. Xdomarker(x,y)
  2439. Xfloat    x,y;
  2440. X{
  2441. X    if ( code(x,y) )
  2442. X    return;
  2443. X    /*
  2444. X     * note that the marker gray stuff is done inside mk (in PS), so
  2445. X     * the color may not actually take effect.
  2446. X     */
  2447. X    setcolor(MarkColor);
  2448. X    printf("%f %f mk\n", sx(x), sy(y));
  2449. X}
  2450. X
  2451. X/*
  2452. X * graymarker - set the marker gray value
  2453. X */
  2454. X
  2455. Xgraymarker(s)
  2456. Xfloat s;
  2457. X{
  2458. X    printf("/mg %f def\n", s);
  2459. X}
  2460. X
  2461. X/*
  2462. X * scalemarker - set the marker scale value
  2463. X */
  2464. X
  2465. Xscalemarker(s)
  2466. Xfloat    s;
  2467. X{
  2468. X    printf("/ms %f def\n", s);
  2469. X}
  2470. X
  2471. X/*
  2472. X * setcolor - set current color; remembers what is already set
  2473. X */
  2474. X
  2475. Xchar *curColor = NULL;
  2476. X
  2477. Xsetcolor(color)
  2478. Xchar *color;
  2479. X{
  2480. X    if (curColor && color && (strcmp(curColor, color) == 0))
  2481. X        return;
  2482. X    curColor = color;
  2483. X    if (color != NULL && strlen(color)>0)
  2484. X        printf("/%s fc\n",color);
  2485. X    else
  2486. X        printf("/black fc\n");
  2487. X}
  2488. X
  2489. X/*
  2490. X *----------------------------------------------------------------------
  2491. X *
  2492. X * DATA CLIPPING ROUTINES
  2493. X *
  2494. X *    2D clipper     Cohen-Sutherland clipper from Newman and Sproull(pg 67).
  2495. X *
  2496. X */
  2497. X
  2498. X#define LEFT    0x1
  2499. X#define RIGHT   0x2
  2500. X#define BOTTOM  0x4
  2501. X#define TOP     0x8
  2502. X
  2503. Xfloat   Clipxl, Clipxr, Clipyb, Clipyt;
  2504. Xint    Clipxf, Clipyf;
  2505. Xunsigned int c;
  2506. X
  2507. X
  2508. Xcliplimits( xmin, ymin, xmax, ymax, xflip, yflip)
  2509. Xfloat xmin, ymin, xmax, ymax;
  2510. Xint   xflip, yflip;
  2511. X{
  2512. X    extern float Clipxl, Clipxr, CLipyb, Clipyt;
  2513. X
  2514. X    Clipxl = xmin;
  2515. X    Clipxr = xmax;
  2516. X    Clipxf = xflip;
  2517. X    Clipyb = ymin;
  2518. X    Clipyt = ymax;
  2519. X    Clipyf = yflip;
  2520. X}
  2521. X
  2522. X
  2523. Xcode( x, y )
  2524. Xfloat x,y; /* point to encode */
  2525. X
  2526. X{
  2527. X
  2528. X    c = 0;
  2529. X
  2530. X    if ( Clipxf ? x > Clipxl : x < Clipxl )
  2531. X        c = LEFT;
  2532. X    else if ( Clipxf ? x < Clipxr : x > Clipxr )
  2533. X        c = RIGHT;
  2534. X
  2535. X    if ( Clipyf ? y > Clipyb : y < Clipyb )
  2536. X        c = c | BOTTOM;
  2537. X    else if ( Clipyf ? y < Clipyt : y > Clipyt )
  2538. X        c = c | TOP;
  2539. X
  2540. X    return c;
  2541. X
  2542. X}
  2543. X
  2544. X
  2545. Xclip( x1, y1, x2, y2, xs, ys, xe, ye )
  2546. Xfloat x1, y1, x2, y2;      /* line to test against box */
  2547. Xfloat *xs, *ys, *xe, *ye;  /* returned line within region */ 
  2548. X/*
  2549. X *    Description:    Clips a line against the rectangular clipping region set by
  2550. X *            Cliplimits. 
  2551. X *
  2552. X *    Input:
  2553. X *            endpoints of a line to be tested. No order assumed.
  2554. X *
  2555. X *    Output:
  2556. X *            Returns the new endpoints of the line clipped to the edges
  2557. X *            of the box in xs, ys, xe, ye.
  2558. X *
  2559. X *        RETURNS:    0  if the the line does not pass through the clipping region.
  2560. X *                1  if the line passes through the clipping region.
  2561. X *
  2562. X */
  2563. X
  2564. X{
  2565. X    unsigned int c1,c2;
  2566. X    float x,y;
  2567. X
  2568. X    c1 = code( x1,y1 );
  2569. X    c2 = code( x2,y2 );
  2570. X
  2571. X    /*  if both c = 0, then both within window : trivial accept */
  2572. X    while ( (c1 != 0) || (c2 != 0) ) {
  2573. X            
  2574. X
  2575. X        /* if intersection of c1 and c2 is non-zero, then the line lies
  2576. X           completely off of the screen */
  2577. X        if ( c1 & c2 ) {
  2578. X            *xs = x1;
  2579. X            *ys = y1;
  2580. X            *xe = x2;
  2581. X            *ye = y2;
  2582. X            return FALSE;
  2583. X        }
  2584. X
  2585. X        c = c1;
  2586. X        if ( c == 0 ) c = c2;
  2587. X
  2588. X
  2589. X        if ( c & LEFT ) { /* crosses left edge */
  2590. X            y = y1 + (y2-y1) * (Clipxl - x1) / (x2-x1);
  2591. X            x = Clipxl;
  2592. X        } else if ( c & RIGHT ) { /* crosses right edge */
  2593. X            y = y1 + (y2-y1) * (Clipxr - x1) / (x2-x1);
  2594. X            x = Clipxr;
  2595. X        } else if ( c & BOTTOM ) { /* crosses bottom edge */
  2596. X            x = x1 + (x2-x1) * ( Clipyb - y1 ) / (y2-y1);
  2597. X            y = Clipyb;
  2598. X        } else if ( c & TOP ) { /* crosses top edge */
  2599. X            x = x1 + (x2-x1) * ( Clipyt - y1 ) / (y2-y1);        
  2600. X            y = Clipyt;
  2601. X        }
  2602. X
  2603. X        if ( c = c1 ) {
  2604. X            x1 = x;
  2605. X            y1 = y;
  2606. X            c1 = code(x,y);    
  2607. X        } else {
  2608. X            x2 = x;
  2609. X            y2 = y;
  2610. X            c2 = code(x,y);
  2611. X        }
  2612. X
  2613. X    } /* end while */
  2614. X
  2615. X    /* line is visible */
  2616. X
  2617. X    *xs = x1;
  2618. X    *ys = y1;
  2619. X    *xe = x2;
  2620. X    *ye = y2;
  2621. X    return TRUE;
  2622. X}
  2623. X
  2624. X/*
  2625. X * Scaling routines - these convert user data into inches
  2626. X */
  2627. X
  2628. Xfloat 
  2629. Xsx(x)
  2630. Xfloat x;
  2631. X{
  2632. X    register axis_t *argp = &Xaxis;
  2633. X
  2634. X    if (argp->tform == IDENT)
  2635. X        return (x-argp->gmin)/(argp->gmax-argp->gmin)*argp->size
  2636. X            + argp->offset;
  2637. X    else
  2638. X        return (log10(x)-argp->lgmin)/(argp->lgmax - argp->lgmin)
  2639. X            * argp->size + argp->offset;
  2640. X}
  2641. Xfloat
  2642. Xsy(y)
  2643. Xfloat y;
  2644. X{
  2645. X    register axis_t *argp = &Yaxis;
  2646. X
  2647. X    if (argp->tform == IDENT)
  2648. X        return (y-argp->gmin)/(argp->gmax-argp->gmin)*argp->size
  2649. X            + argp->offset;
  2650. X    else
  2651. X        return (log10(y)-argp->lgmin)/(argp->lgmax - argp->lgmin)
  2652. X            * argp->size + argp->offset;
  2653. X}
  2654. X
  2655. X/* these just scale, don't translate */
  2656. X
  2657. Xfloat 
  2658. XSX(x)
  2659. Xfloat x;
  2660. X{
  2661. X    register axis_t *argp = &Xaxis;
  2662. X
  2663. X    if (argp->tform == IDENT)
  2664. X        return (x)/(argp->gmax-argp->gmin)*argp->size;
  2665. X    else
  2666. X        return (log10(x)-argp->lgmin)/(argp->lgmax - argp->lgmin)
  2667. X            * argp->size;
  2668. X}
  2669. Xfloat 
  2670. XSY(y)
  2671. Xfloat y;
  2672. X{
  2673. X    register axis_t *argp = &Yaxis;
  2674. X
  2675. X    if (argp->tform == IDENT)
  2676. X        return (y)/(argp->gmax-argp->gmin)*argp->size;
  2677. X    else
  2678. X        return (log10(y)-argp->lgmin)/(argp->lgmax - argp->lgmin)
  2679. X            * argp->size;
  2680. X}
  2681. X
  2682. END_OF_FILE
  2683. if test 20906 -ne `wc -c <'output.c'`; then
  2684.     echo shar: \"'output.c'\" unpacked with wrong size!
  2685. fi
  2686. # end of 'output.c'
  2687. fi
  2688. echo shar: End of archive 2 \(of 3\).
  2689. cp /dev/null ark2isdone
  2690. MISSING=""
  2691. for I in 1 2 3 ; do
  2692.     if test ! -f ark${I}isdone ; then
  2693.     MISSING="${MISSING} ${I}"
  2694.     fi
  2695. done
  2696. if test "${MISSING}" = "" ; then
  2697.     echo You have unpacked all 3 archives.
  2698.     rm -f ark[1-9]isdone
  2699. else
  2700.     echo You still need to unpack the following archives:
  2701.     echo "        " ${MISSING}
  2702. fi
  2703. ##  End of shell archive.
  2704. exit 0
  2705.