grtree.old 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. (FILECREATED "15-JAN-83 16:03:58" {DSK}GRTREE.LSP;11 7426
  2. changes to: (FNS STRINGDATA-DRAW TREEELEMENT-DRAWIN BOXTYPE-DRAW BOXTYPE-ERASE DRAWRECTANGLE
  3. GRAPHICSBOX-DRAWIN GRAPHICSBOX-ERASEIN MATCHTREE RECTANGLESIZE
  4. BOXTYPE-SETSIZE GRAPHICSTREE-BOXTYPE GRAPHICSTREE-WIDTH)
  5. (VARS GRTREECOMS GRAPHICSBOXTYPES)
  6. (PROPS (RECTANGLE SIZEPROGRAM)
  7. (RECTANGLE DRAWPROGRAM))
  8. previous date: "13-JAN-83 10:32:08" {DSK}GRTREE.LSP;1)
  9. (PRETTYCOMPRINT GRTREECOMS)
  10. (RPAQQ GRTREECOMS [(GLISPOBJECTS BOXTYPE GRAPHICSBOX GRAPHICSTREE LISPGRAPHICSTREE LISPNODEDISPLAY
  11. TREEELEMENT)
  12. (FNS BOXTYPE-DRAW BOXTYPE-ERASE BOXTYPE-SETSIZE DRAWRECTANGLE GRAPHICSBOX-DRAWIN
  13. GRAPHICSBOX-ERASEIN MATCHTREE RECTANGLESIZE STRINGDATA-DRAW
  14. TREEELEMENT-DRAWIN)
  15. (GLISPGLOBALS GRAPHICSBOXTYPES)
  16. (PROP DRAWPROGRAM RECTANGLE)
  17. (PROP SIZEPROGRAM RECTANGLE)
  18. (VARS GRAPHICSBOXTYPES)
  19. (GLOBALVARS GRAPHICSBOXTYPES)
  20. (P (LOAD? (QUOTE VECTOR.LSP])
  21. [GLISPOBJECTS
  22. (BOXTYPE
  23. (ATOM (PROPLIST (DRAWPROGRAM ATOM)
  24. (SIZEPROGRAM ATOM)))
  25. MSG ((DRAW BOXTYPE-DRAW OPEN T)
  26. (ERASE BOXTYPE-ERASE OPEN T)
  27. (SETSIZE BOXTYPE-SETSIZE OPEN T)) )
  28. (GRAPHICSBOX
  29. (LISTOBJECT (BOXTYPE BOXTYPE)
  30. (START VECTOR)
  31. (SIZE VECTOR)
  32. (CONTENTSOFFSET VECTOR)
  33. (DISPLAYCONTENTS ANYTHING)
  34. (CONTENTSSIZE VECTOR))
  35. MSG [(DRAWIN GRAPHICSBOX-DRAWIN OPEN T)
  36. (ERASEIN GRAPHICSBOX-ERASEIN OPEN T)
  37. (SETSIZE ((SEND BOXTYPE SETSIZE self]
  38. SUPERS (REGION) )
  39. (GRAPHICSTREE
  40. ANYTHING
  41. PROP ((BOXTYPE (BOXTYPENAME)
  42. RESULT BOXTYPE))
  43. MSG ((MAKEGRAPHICSTREE MATCHTREE)
  44. (DRAW GRAPHICSTREE-DRAW)
  45. (TERMINAL? (self IS TERMINAL))) )
  46. (LISPGRAPHICSTREE
  47. (LISTOBJECT (EXPR ANYTHING))
  48. PROP ((BOXTYPENAME ((QUOTE RECTANGLE)))
  49. [BOXCONTENTS ((IF EXPR IS ATOMIC THEN EXPR ELSE (CAR EXPR]
  50. (BOXDISPLAYCONTENTS ((A LISPNODEDISPLAY WITH CONTENTS = BOXCONTENTS)))
  51. (SUCCESSORS [(IF EXPR IS ATOMIC THEN NIL ELSE (FOR X IN (CDR EXPR)
  52. COLLECT
  53. (A LISPGRAPHICSTREE WITH EXPR = X]
  54. RESULT
  55. (LISTOF LISPGRAPHICSTREE)))
  56. ADJ ((TERMINAL (EXPR IS ATOMIC)))
  57. SUPERS (GRAPHICSTREE) )
  58. (LISPNODEDISPLAY
  59. (LISTOBJECT (CONTENTS ANYTHING))
  60. PROP [(DISPLAYSIZE ((A VECTOR WITH X = (NCHARS CONTENTS)
  61. *8 Y = 12]
  62. MSG ((DRAW STRINGDATA-DRAW)) )
  63. (TREEELEMENT
  64. (LISTOBJECT (BOX GRAPHICSBOX)
  65. (ORIGINALNODE ANYTHING)
  66. (SUCCESSORS (LISTOF TREEELEMENT))
  67. (DISPLAYSIZE VECTOR))
  68. PROP ((DISPLAYWIDTH (DISPLAYSIZE:X))
  69. (DISPLAYHEIGHT (DISPLAYSIZE:Y)))
  70. MSG ((DRAWIN TREEELEMENT-DRAWIN)) )
  71. ]
  72. (DEFINEQ
  73. (BOXTYPE-DRAW
  74. (GLAMBDA (BOXTYPE:BOXTYPE BOX:GRAPHICSBOX W:WINDOW) (* GSN "14-JAN-83 12:58")
  75. (APPLY* BOXTYPE:DRAWPROGRAM BOX (QUOTE PAINT)
  76. W)))
  77. (BOXTYPE-ERASE
  78. (GLAMBDA (BOXTYPE:BOXTYPE BOX:GRAPHICSBOX W:WINDOW) (* GSN "14-JAN-83 12:58")
  79. (APPLY* BOXTYPE:DRAWPROGRAM BOX (QUOTE ERASE)
  80. W)))
  81. (BOXTYPE-SETSIZE
  82. (GLAMBDA (BOXTYPE:BOXTYPE BOX:GRAPHICSBOX) (* GSN "14-JAN-83 09:52")
  83. (BOX:CONTENTSSIZE _(SEND BOX:DISPLAYCONTENTS DISPLAYSIZE))
  84. (APPLY* BOXTYPE:SIZEPROGRAM BOX)))
  85. (DRAWRECTANGLE
  86. (GLAMBDA (BOX:GRAPHICSBOX DSPOP:ATOM W:WINDOW) (* GSN "14-JAN-83 13:01")
  87. (PROG (OLDDS)
  88. (OLDDS _(CURRENTDISPLAYSTREAM W))
  89. (DSPOPERATION DSPOP)
  90. (MOVETO BOX:LEFT BOX:BOTTOM)
  91. (DRAWTO BOX:LEFT BOX:TOP)
  92. (DRAWTO BOX:RIGHT BOX:TOP)
  93. (DRAWTO BOX:RIGHT BOX:BOTTOM)
  94. (DRAWTO BOX:LEFT BOX:BOTTOM)
  95. (CURRENTDISPLAYSTREAM OLDDS))))
  96. (GRAPHICSBOX-DRAWIN
  97. (GLAMBDA (BOX:GRAPHICSBOX W:WINDOW) (* GSN "14-JAN-83 12:55")
  98. (SEND BOX:BOXTYPE DRAW BOX W)))
  99. (GRAPHICSBOX-ERASEIN
  100. (GLAMBDA (BOX:GRAPHICSBOX W:WINDOW) (* GSN "14-JAN-83 12:55")
  101. (SEND BOX:BOXTYPE ERASE BOX W)))
  102. (MATCHTREE
  103. (GLAMBDA (TR) (* GSN "14-JAN-83 10:46")
  104. (* Build a TREEELEMENT structure to match the given tree
  105. TR.)
  106. (RESULT TREEELEMENT)
  107. (PROG (TE SUM)
  108. [TE _(A TREEELEMENT WITH ORIGINALNODE = TR BOX =(A GRAPHICSBOX WITH BOXTYPE =(SEND
  109. TR BOXTYPE)
  110. DISPLAYCONTENTS =(SEND TR
  111. BOXDISPLAYCONTENTS))
  112. SUCCESSORS =(FOR X IN (SEND TR SUCCESSORS) COLLECT (SEND X MAKEGRAPHICSTREE]
  113. (SEND TE:BOX SETSIZE)
  114. (TE:DISPLAYWIDTH _(IF (SEND TR TERMINAL?)
  115. THEN TE:BOX:WIDTH + 10
  116. ELSE (SUM_0)
  117. (FOR X IN TE:SUCCESSORS DO SUM_+X:DISPLAYWIDTH)
  118. (MAX (TE:BOX:WIDTH + 10)
  119. SUM)))
  120. [TE:DISPLAYHEIGHT _(IF (SEND TR TERMINAL?)
  121. THEN TE:BOX:HEIGHT
  122. ELSE TE:BOX:HEIGHT + 20 +(APPLY (FUNCTION MAX)
  123. (FOR X IN TE:SUCCESSORS
  124. COLLECT X:BOX:HEIGHT]
  125. (RETURN TE))))
  126. (RECTANGLESIZE
  127. (GLAMBDA (BOX:GRAPHICSBOX) (* GSN "14-JAN-83 10:28")
  128. (BOX:SIZE _ BOX:CONTENTSSIZE +(A VECTOR WITH X = 10 Y = 10))
  129. (BOX:CONTENTSOFFSET _(A VECTOR WITH X = 5 Y = 5))))
  130. (STRINGDATA-DRAW
  131. (GLAMBDA (self:LISPNODEDISPLAY POS:VECTOR W:WINDOW) (* GSN "14-JAN-83 14:35")
  132. (SEND W PRINTAT self:CONTENTS POS)))
  133. (TREEELEMENT-DRAWIN
  134. [GLAMBDA (TREE:TREEELEMENT AREA:REGION W:WINDOW) (* GSN "14-JAN-83 14:42")
  135. (* Draw the subtree beginning with TREE inside area AREA
  136. in window W.)
  137. (PROG (NEWX NEWY SUM FSPN (TB TREE:BOX))
  138. (IF TREE:DISPLAYSIZE>AREA:SIZE
  139. THEN (ERROR "Area is too small for tree."))
  140. (TB:START _(A VECTOR WITH X =(AREA:LEFT + AREA:RIGHT - TB:SIZE:X)/2 Y = AREA:TOP -
  141. TB:SIZE:Y))
  142. (SEND TB DRAWIN W)
  143. (SEND TB:DISPLAYCONTENTS DRAW TB:START+TB:CONTENTSOFFSET W)
  144. (* Now compute positions for successors of top node.)
  145. (IF TREE:SUCCESSORS
  146. THEN (NEWY _ AREA:TOP - TB:SIZE:Y - 20)
  147. (SUM_0)
  148. (FOR S IN TREE:SUCCESSORS DO SUM_+S:DISPLAYSIZE:X)
  149. (* Calculate free space for each box.)
  150. (FSPN _(AREA:SIZE:X - SUM)/(LENGTH SUCCESSORS))
  151. (NEWX _ AREA:START:X + FSPN/2) (* Draw each subtree.)
  152. (FOR S IN TREE:SUCCESSORS
  153. DO (* Draw arc to new subtree.)
  154. (SEND W DRAWLINE TB:BOTTOMCENTER
  155. (A VECTOR WITH X = NEWX+S:DISPLAYSIZE:X/2 Y = NEWY))
  156. (SEND S DRAWIN
  157. (AN AREA WITH START =(A VECTOR WITH X = NEWX Y = AREA:START:Y)
  158. SIZE =(A VECTOR WITH X = S:DISPLAYSIZE:X Y = NEWY -
  159. AREA:START:Y))
  160. W)
  161. (NEWX_+S:DISPLAYSIZE:X+FSPN])
  162. )
  163. [GLISPGLOBALS
  164. (GRAPHICSBOXTYPES (LISTOF BOXTYPE) )
  165. ]
  166. (PUTPROPS RECTANGLE DRAWPROGRAM DRAWRECTANGLE)
  167. (PUTPROPS RECTANGLE SIZEPROGRAM RECTANGLESIZE)
  168. (RPAQQ GRAPHICSBOXTYPES (RECTANGLE))
  169. (DECLARE: DOEVAL@COMPILE DONTCOPY
  170. (ADDTOVAR GLOBALVARS GRAPHICSBOXTYPES)
  171. )
  172. (LOAD? (QUOTE VECTOR.LSP))
  173. (DECLARE: DONTCOPY
  174. (FILEMAP (NIL (2714 7091 (BOXTYPE-DRAW 2724 . 2892) (BOXTYPE-ERASE 2894 . 3063) (BOXTYPE-SETSIZE 3065
  175. . 3278) (DRAWRECTANGLE 3280 . 3715) (GRAPHICSBOX-DRAWIN 3717 . 3867) (GRAPHICSBOX-ERASEIN 3869 . 4021
  176. ) (MATCHTREE 4023 . 5126) (RECTANGLESIZE 5128 . 5358) (STRINGDATA-DRAW 5360 . 5512) (
  177. TREEELEMENT-DRAWIN 5514 . 7089)))))
  178. STOP