sdl.ps 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. %! SDL shapes for Graphviz/dot in PostScript output mode
  2. % FILE
  3. % sdl.ps - SDL shapes for Graphviz/dot in PostScript output mode
  4. %
  5. % USE
  6. % All procedures expect to be passed a rectangular bounding box in the
  7. % order [upper right, lower right, lower left, upper left, upper right].
  8. % All procedures expect to be used with "peripheries = 0".
  9. %
  10. % BUGS
  11. % The following shapes are currently not implemented:
  12. % - frame/system/block/process/procedure/service/procedure, and types thereof
  13. % - macro inlet/outlet/call
  14. % - exception handler/handle/raise
  15. % - decision (suggest use diamond)
  16. % - alternative (suggest use triangle)
  17. % - internal input/output (suggest stop using historical relics!)
  18. %
  19. % COPYRIGHT AND PERMISSION NOTICE
  20. % Copyright (C) 2005 Cambridge Silicon Radio Ltd.; all rights reserved.
  21. %
  22. % Permission is hereby granted, free of charge, to any person obtaining
  23. % a copy of this software and associated documentation files (the
  24. % "Software"), to deal in the Software without restriction, including
  25. % without limitation the rights to use, copy, modify, merge, publish,
  26. % distribute, sublicense, and/or sell copies of the Software, and to
  27. % permit persons to whom the Software is furnished to do so, subject to
  28. % the following conditions:
  29. %
  30. % The above copyright notice and this permission notice shall be
  31. % included in all copies or substantial portions of the Software.
  32. %
  33. % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  34. % EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  35. % MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  36. % NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  37. % LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  38. % OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  39. % WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  40. %
  41. % Except as contained in this notice, the name of a copyright holder
  42. % shall not be used in advertising or otherwise to promote the sale, use
  43. % or other dealings in the Software without prior written authorization
  44. % of the copyright holder.
  45. %
  46. % REVISION
  47. % #4
  48. /xdef {exch def} bind def
  49. % SDL task
  50. /sdl_task {
  51. 3 1 roll % put filled flag at end
  52. 4 ne { stop } if % sanity-check number of sides
  53. aload pop
  54. newpath
  55. moveto
  56. lineto
  57. lineto
  58. lineto
  59. pop pop
  60. closepath
  61. { fill } { stroke } ifelse
  62. } bind def
  63. % SDL input from right
  64. % The indent has lines at 45 degrees
  65. % There should be a few spaces at the end of this shape's label
  66. /sdl_input_from_right {
  67. 9 dict begin
  68. 3 1 roll % put filled flag at end
  69. 4 ne { stop } if % sanity-check number of sides
  70. aload pop
  71. /ury xdef /urx xdef
  72. /lry xdef /lrx xdef
  73. /lly xdef /llx xdef
  74. /uly xdef /ulx xdef
  75. /h2 ury lry sub 2 div def
  76. newpath
  77. moveto
  78. urx h2 sub ury h2 sub lineto
  79. lrx lry lineto
  80. llx lly lineto
  81. ulx uly lineto
  82. closepath
  83. { fill } { stroke } ifelse
  84. end
  85. } bind def
  86. % SDL input from left
  87. % Similar to SDL input from right
  88. % There should be a few spaces at the start of this shape's label
  89. /sdl_input_from_left {
  90. 9 dict begin
  91. 3 1 roll % put filled flag at end
  92. 4 ne { stop } if % sanity-check number of sides
  93. aload pop
  94. /ury xdef /urx xdef
  95. /lry xdef /lrx xdef
  96. /lly xdef /llx xdef
  97. /uly xdef /ulx xdef
  98. /h2 uly lly sub 2 div def
  99. newpath
  100. moveto
  101. lrx lry lineto
  102. llx lly lineto
  103. ulx h2 add ury h2 sub lineto
  104. ulx uly lineto
  105. closepath
  106. { fill } { stroke } ifelse
  107. end
  108. } bind def
  109. % SDL priority input from right
  110. % Similar to SDL input from right
  111. % The chevrons are displaced by an eighth of the shape height
  112. % The filled version is indistinguishable from a non-priority SDL input
  113. /sdl_priority_input_from_right {
  114. 9 dict begin
  115. 3 1 roll % put filled flag at end
  116. 4 ne { stop } if % sanity-check number of sides
  117. aload pop
  118. /ury xdef /urx xdef
  119. /lry xdef /lrx xdef
  120. /lly xdef /llx xdef
  121. /uly xdef /ulx xdef
  122. /h2 ury lry sub 2 div def
  123. newpath
  124. moveto
  125. urx h2 sub ury h2 sub lineto
  126. lrx lry lineto
  127. llx lly lineto
  128. ulx uly lineto
  129. closepath
  130. { fill } { stroke
  131. urx h2 4 div sub ury moveto
  132. urx h2 sub h2 4 div sub ury h2 sub lineto
  133. lrx h2 4 div sub lry lineto
  134. stroke } ifelse
  135. end
  136. } bind def
  137. % SDL priority input from left
  138. % Similar to SDL priority input from right
  139. /sdl_priority_input_from_left {
  140. 9 dict begin
  141. 3 1 roll % put filled flag at end
  142. 4 ne { stop } if % sanity-check number of sides
  143. aload pop
  144. /ury xdef /urx xdef
  145. /lry xdef /lrx xdef
  146. /lly xdef /llx xdef
  147. /uly xdef /ulx xdef
  148. /h2 uly lly sub 2 div def
  149. newpath
  150. moveto
  151. lrx lry lineto
  152. llx lly lineto
  153. ulx h2 add uly h2 sub lineto
  154. ulx uly lineto
  155. closepath
  156. { fill } { stroke
  157. llx h2 4 div add lly moveto
  158. ulx h2 add h2 4 div add uly h2 sub lineto
  159. ulx h2 4 div add uly lineto
  160. stroke } ifelse
  161. end
  162. } bind def
  163. % SDL start
  164. % The left and right sides are semicircles
  165. % This should be used with "label = " ""
  166. /sdl_start {
  167. 9 dict begin
  168. 3 1 roll % put filled flag at end
  169. 4 ne { stop } if % sanity-check number of sides
  170. aload pop
  171. /ury xdef /urx xdef
  172. /lry xdef /lrx xdef
  173. /lly xdef /llx xdef
  174. /uly xdef /ulx xdef
  175. pop pop
  176. /r ury lry sub 2 div def
  177. newpath
  178. urx r sub ury r sub r 90 -90 arcn
  179. ulx r add uly r sub r -90 90 arcn
  180. closepath
  181. { fill } { stroke } ifelse
  182. end
  183. } bind def
  184. % SDL procedure start
  185. % Similar to SDL start
  186. % The filled version is indistinguishable from an SDL start
  187. % This should be used with "label = " ""
  188. /sdl_procedure_start {
  189. 9 dict begin
  190. 3 1 roll % put filled flag at end
  191. 4 ne { stop } if % sanity-check number of sides
  192. aload pop
  193. /ury xdef /urx xdef
  194. /lry xdef /lrx xdef
  195. /lly xdef /llx xdef
  196. /uly xdef /ulx xdef
  197. pop pop
  198. /r ury lry sub 2 div def
  199. newpath
  200. urx r sub ury r sub r 90 -90 arcn
  201. ulx r add uly r sub r -90 90 arcn
  202. closepath
  203. { fill } { stroke
  204. lrx r sub lry moveto
  205. 0 r 2 mul rlineto
  206. llx r add lly moveto
  207. 0 r 2 mul rlineto
  208. stroke } ifelse
  209. end
  210. } bind def
  211. % SDL state/nextstate
  212. % The left and right sides are arcs
  213. /sdl_state {
  214. 12 dict begin
  215. 3 1 roll % put filled flag at end
  216. 4 ne { stop } if % sanity-check number of sides
  217. aload pop
  218. /ury xdef /urx xdef
  219. /lry xdef /lrx xdef
  220. /lly xdef /llx xdef
  221. /uly xdef /ulx xdef
  222. pop pop
  223. /h2 ury lry sub 2 div def
  224. /w2 h2 1.5 mul def % was urx ulx sub 2 div def but this made curvature width-dependent
  225. /r w2 def
  226. /th h2 r dup mul h2 dup mul sub sqrt atan def
  227. newpath
  228. urx w2 sub ury h2 sub r th th neg arcn
  229. ulx w2 add uly h2 sub r -180 th add -180 th sub arcn
  230. closepath
  231. { fill } { stroke } ifelse
  232. end
  233. } bind def
  234. % SDL output to right
  235. % The outdent has lines at 45 degrees
  236. % There should be a few spaces at the end of this shape's label
  237. /sdl_output_to_right {
  238. 9 dict begin
  239. 3 1 roll % put filled flag at end
  240. 4 ne { stop } if % sanity-check number of sides
  241. aload pop
  242. /ury xdef /urx xdef
  243. /lry xdef /lrx xdef
  244. /lly xdef /llx xdef
  245. /uly xdef /ulx xdef
  246. /h2 ury lry sub 2 div def
  247. newpath
  248. exch h2 sub exch moveto
  249. urx ury h2 sub lineto
  250. lrx h2 sub lry lineto
  251. llx lly lineto
  252. ulx uly lineto
  253. closepath
  254. { fill } { stroke } ifelse
  255. end
  256. } bind def
  257. % SDL output to left
  258. % Similar to SDL output to right
  259. % There should be a few spaces at the start of this shape's label
  260. /sdl_output_to_left {
  261. 9 dict begin
  262. 3 1 roll % put filled flag at end
  263. 4 ne { stop } if % sanity-check number of sides
  264. aload pop
  265. /ury xdef /urx xdef
  266. /lry xdef /lrx xdef
  267. /lly xdef /llx xdef
  268. /uly xdef /ulx xdef
  269. /h2 ury lry sub 2 div def
  270. newpath
  271. moveto
  272. lrx lry lineto
  273. llx h2 add lly lineto
  274. ulx ury h2 sub lineto
  275. ulx h2 add uly lineto
  276. closepath
  277. { fill } { stroke } ifelse
  278. end
  279. } bind def
  280. % SDL continuous signal/enabling condition
  281. % The chevrons have lines at 45 degrees
  282. % There should be a few spaces at the start and end of this shape's label
  283. /sdl_condition {
  284. 9 dict begin
  285. 3 1 roll % put filled flag at end
  286. 4 ne { stop } if % sanity-check number of sides
  287. aload pop
  288. /ury xdef /urx xdef
  289. /lry xdef /lrx xdef
  290. /lly xdef /llx xdef
  291. /uly xdef /ulx xdef
  292. /h2 ury lry sub 2 div def
  293. newpath
  294. exch h2 sub exch moveto
  295. urx ury h2 sub lineto
  296. lrx h2 sub lry lineto
  297. dup llx h2 add lly 3 -1 roll { lineto } { moveto } ifelse
  298. ulx uly h2 sub lineto
  299. ulx h2 add uly lineto
  300. { fill } { stroke } ifelse
  301. end
  302. } bind def
  303. % SDL save
  304. % The left and right edges are at about 60 degrees
  305. % There should be a few spaces at the start and end of this shape's label
  306. /sdl_save {
  307. 9 dict begin
  308. 3 1 roll % put filled flag at end
  309. 4 ne { stop } if % sanity-check number of sides
  310. aload pop
  311. /ury xdef /urx xdef
  312. /lry xdef /lrx xdef
  313. /lly xdef /llx xdef
  314. /uly xdef /ulx xdef
  315. /h3 ury lry sub 3 div def
  316. newpath
  317. moveto
  318. lrx h3 sub lry lineto
  319. llx lly lineto
  320. ulx h3 add uly lineto
  321. closepath
  322. { fill } { stroke } ifelse
  323. end
  324. } bind def
  325. % SDL stop
  326. % The width of the bounding box is ignored; the lines are set at 45 degrees
  327. % This shape cannot be filled
  328. % This should be used with "label = """ and "arrowhead = none, headclip = false"
  329. /sdl_stop {
  330. 7 dict begin
  331. { stop } if % make sure not asked to fill this
  332. 4 ne { stop } if % sanity-check number of sides
  333. aload pop
  334. pop pop
  335. /lry xdef /lrx xdef
  336. /lly xdef /llx xdef
  337. /uly xdef pop
  338. /h2 uly lly sub 2 div def
  339. /mx llx lrx add 2 div def
  340. newpath
  341. mx h2 add exch moveto pop
  342. mx h2 sub lly lineto
  343. mx h2 sub uly moveto
  344. mx h2 add lry lineto
  345. closepath
  346. stroke
  347. end
  348. } bind def
  349. % SDL return
  350. % The width of the bounding box is ignored; the lines are set at 45 degrees
  351. % The filled version is indistinguishable from an SDL connection
  352. /sdl_return {
  353. 9 dict begin
  354. 3 1 roll % put filled flag at end
  355. 4 ne { stop } if % sanity-check number of sides
  356. aload pop
  357. /ury xdef pop
  358. /lry xdef /lrx xdef
  359. /lly xdef /llx xdef
  360. /uly xdef pop
  361. pop pop
  362. /h2 uly lly sub 2 div 2 sqrt div def
  363. /mx llx lrx add 2 div def
  364. /my lry ury add 2 div def
  365. newpath
  366. mx my uly lly sub 2 div 0 360 arc
  367. { fill } { stroke
  368. mx h2 add my h2 add moveto
  369. mx h2 sub my h2 sub lineto
  370. mx h2 sub my h2 add moveto
  371. mx h2 add my h2 sub lineto
  372. stroke } ifelse
  373. end
  374. } bind def
  375. % SDL create
  376. % The extra lines are displaced by an eighth of the shape height
  377. % The filled version is indistinguishable from an SDL task
  378. /sdl_create {
  379. 9 dict begin
  380. 3 1 roll % put filled flag at end
  381. 4 ne { stop } if % sanity-check number of sides
  382. aload pop
  383. /ury xdef /urx xdef
  384. /lry xdef /lrx xdef
  385. /lly xdef /llx xdef
  386. /uly xdef /ulx xdef
  387. /h8 ury lry sub 8 div def
  388. newpath
  389. moveto
  390. lrx lry lineto
  391. llx lly lineto
  392. ulx uly lineto
  393. closepath
  394. { fill } { stroke
  395. ulx uly h8 sub moveto
  396. urx ury h8 sub lineto
  397. llx lly h8 add moveto
  398. lrx lry h8 add lineto
  399. stroke } ifelse
  400. end
  401. } bind def
  402. % SDL call
  403. % The extra lines are displaced by an eighth of the shape height
  404. % The filled version is indistinguishable from an SDL task
  405. % There should be a few spaces at the start and end of this shape's label
  406. /sdl_call {
  407. 9 dict begin
  408. 3 1 roll % put filled flag at end
  409. 4 ne { stop } if % sanity-check number of sides
  410. aload pop
  411. /ury xdef /urx xdef
  412. /lry xdef /lrx xdef
  413. /lly xdef /llx xdef
  414. /uly xdef /ulx xdef
  415. /h8 ury lry sub 8 div def
  416. newpath
  417. moveto
  418. lrx lry lineto
  419. llx lly lineto
  420. ulx uly lineto
  421. closepath
  422. { fill } { stroke
  423. urx h8 sub ury moveto
  424. lrx h8 sub lry lineto
  425. llx h8 add lly moveto
  426. ulx h8 add uly lineto
  427. stroke } ifelse
  428. end
  429. } bind def
  430. % SDL text symbol
  431. % The corner has a size of twice the H height
  432. /sdl_text {
  433. 10 dict begin
  434. 3 1 roll % put filled flag at end
  435. 4 ne { stop } if % sanity-check number of sides
  436. aload pop
  437. /ury xdef /urx xdef
  438. /lry xdef /lrx xdef
  439. /lly xdef /llx xdef
  440. /uly xdef /ulx xdef
  441. /h8 ury lry sub 8 div def
  442. newpath
  443. moveto
  444. /d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop 2 mul def
  445. newpath
  446. urx ury d sub moveto
  447. lrx lry lineto
  448. llx lly lineto
  449. ulx uly lineto
  450. urx d sub ury lineto
  451. closepath
  452. { fill } { stroke } ifelse
  453. urx ury d sub moveto
  454. d neg 0 rlineto
  455. 0 d rlineto
  456. stroke
  457. end
  458. } bind def
  459. % SDL text extension from left
  460. % This should be used with "rank = same"
  461. /sdl_text_extension_from_left {
  462. 3 1 roll % put filled flag at end
  463. 4 ne { stop } if % sanity-check number of sides
  464. aload pop
  465. pop pop
  466. moveto
  467. lineto
  468. lineto
  469. lineto
  470. { fill } { stroke } ifelse
  471. } bind def
  472. % SDL text extension from right
  473. % This should be used with "rank = same"
  474. /sdl_text_extension_from_right {
  475. 3 1 roll % put filled flag at end
  476. 4 ne { stop } if % sanity-check number of sides
  477. aload pop
  478. pop pop
  479. 8 4 roll
  480. moveto
  481. lineto
  482. lineto
  483. lineto
  484. { fill } { stroke } ifelse
  485. } bind def
  486. % SDL comment from left
  487. % This should be used with "style = dashed" and "rank = same"
  488. /sdl_comment_from_left { sdl_text_extension_from_left } bind def
  489. % SDL comment from right
  490. % This should be used with "style = dashed" and "rank = same"
  491. /sdl_comment_from_right { sdl_text_extension_from_right } bind def
  492. % SDL connector
  493. % The width of the bounding box is ignored
  494. /sdl_connector {
  495. 7 dict begin
  496. 3 1 roll % put filled flag at end
  497. 4 ne { stop } if % sanity-check number of sides
  498. aload pop
  499. pop pop
  500. /lry xdef /lrx xdef
  501. /lly xdef /llx xdef
  502. /uly xdef pop
  503. pop pop
  504. /h2 uly lly sub 2 div def
  505. /mx llx lrx add 2 div def
  506. newpath
  507. mx uly h2 sub h2 0 360 arc
  508. { fill } { stroke } ifelse
  509. end
  510. } bind def
  511. % SDL set (extension)
  512. % The hourglass has a size of twice the H height
  513. % There should be a few spaces at the start of this shape's label
  514. /sdl_set {
  515. 10 dict begin
  516. 3 1 roll % put filled flag at end
  517. 4 ne { stop } if % sanity-check number of sides
  518. aload pop
  519. /ury xdef /urx xdef
  520. /lry xdef /lrx xdef
  521. /lly xdef /llx xdef
  522. /uly xdef /ulx xdef
  523. /my uly lly add 2 div def
  524. newpath
  525. moveto
  526. /d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop def
  527. newpath
  528. llx d add my d add moveto
  529. ulx d add uly lineto
  530. urx ury lineto
  531. lrx lry lineto
  532. llx d add lly lineto
  533. llx d add my d sub lineto
  534. dup { closepath fill } { stroke } ifelse
  535. llx my d sub moveto
  536. d 2 mul dup rlineto
  537. d 2 mul neg 0 rlineto
  538. d 2 mul dup neg rlineto
  539. closepath
  540. { fill } { stroke } ifelse
  541. end
  542. } bind def
  543. % SDL reset (extension)
  544. % The cross has a size of twice the H height
  545. % There should be a few spaces at the start of this shape's label
  546. /sdl_reset {
  547. 10 dict begin
  548. 3 1 roll % put filled flag at end
  549. 4 ne { stop } if % sanity-check number of sides
  550. aload pop
  551. /ury xdef /urx xdef
  552. /lry xdef /lrx xdef
  553. /lly xdef /llx xdef
  554. /uly xdef /ulx xdef
  555. /my uly lly add 2 div def
  556. newpath
  557. moveto
  558. /d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop def
  559. newpath
  560. urx ury moveto
  561. lrx lry lineto
  562. llx d add lly lineto
  563. ulx d add uly lineto
  564. closepath
  565. { fill } { stroke } ifelse
  566. llx my d sub moveto
  567. d 2 mul dup rlineto
  568. llx d 2 mul add my d sub moveto
  569. d 2 mul dup neg exch rlineto
  570. stroke
  571. end
  572. } bind def
  573. % SDL export (extension)
  574. % The store has a width of twice the H height
  575. % There should be a few spaces at the start of this shape's label
  576. /sdl_export {
  577. 10 dict begin
  578. 3 1 roll % put filled flag at end
  579. 4 ne { stop } if % sanity-check number of sides
  580. aload pop
  581. /ury xdef /urx xdef
  582. /lry xdef /lrx xdef
  583. /lly xdef /llx xdef
  584. /uly xdef /ulx xdef
  585. /my uly lly add 2 div def
  586. newpath
  587. moveto
  588. /d (H) true charpath flattenpath pathbbox exch pop exch sub exch pop def
  589. newpath
  590. llx d add my d 2 div add moveto
  591. ulx d add uly lineto
  592. urx ury lineto
  593. lrx lry lineto
  594. llx d add lly lineto
  595. llx d add my d 2 div sub lineto
  596. { closepath fill } { stroke } ifelse
  597. llx my d 2 div sub moveto
  598. d 2 mul 0 rlineto
  599. llx my d 2 div add moveto
  600. d 2 mul 0 rlineto
  601. stroke
  602. end
  603. } bind def