home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / psgraph / part02 < prev    next >
Encoding:
Text File  |  1992-09-06  |  60.9 KB  |  2,699 lines

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