CLIM mail archive


updating-output and recursive use of formatting-graph-from-root

I'm using CLIM 1.1 with Genera 8.1

This is a next try in my efforts of drawing a tree, where the user
can collapse or expand individual nodes in the display. (CF my last

To implement this, I want to use updating-output. Each subtree of the
tree (and the tree as a whole) is presented as an output-record with
updating-output. Therefore, I call format-graph-from-root recursively to
get one output-record for each subtree. 

This version works in first displaying the fully expanded tree. The user
can collapse individual nodes and the display is updated correctly (in
contrast to my version posted in the last message!). 

HOWEVER, if on node is expanded, the program runs into an infinite loop
(in the function layout-graph called by format-graph-from-root called
with the expanded node as the root-node-argument by the redisplay

Is what I'm doing wrong in principle, is there a bug in my code or a bug
in CLIM?

Lost in helplessness - Stefan B.

;;;What follows is the display method for the tree-pane:

(defmethod draw-tree-as-tree ((frame tree1) stream)
  (let ((tree (tree1-tree frame)))
      ((draw-subtree (subtree stream)
	 (let* ((inferior-producer #'(lambda (node)
				       ;; just return the direct inferiors
				       (and (eql node subtree) 
					    (tree-node-expanded node)
					    (tree-node-children node)))))
	   (updating-output (stream
			      :unique-id subtree
			      :cache-value (tree-node-tick-mark subtree)
			      :cache-test #'=)
	     (with-output-as-presentation (:stream stream
					   :object subtree
					   :type 'tree)
	       (cond ((and (tree-node-children subtree)
			   (tree-node-expanded subtree))	; we have to draw a tree
			  #'(lambda (node stream)
			      (if (eql node subtree)
				  (format stream "~A"	       ; draw root node
					  (tree-node-value node))
				  (draw-subtree node stream))) ; draw sons as trees
			  :stream stream))
		       (t			               ; we have to draw a leaf
			(format stream "~A" (tree-node-value subtree)))))))))
      (draw-subtree tree stream))))

Mail: Stefan Bernemann        ! Phone:  +49-231-9743-139
      c/o FhG IML Dortmund    ! Fax:    +49-231-9743-234
      Emil-Figge-Str. 75      ! Email:
      D-4600 Dortmund 50, FRG !         


Main Index | Thread Index