CLIM mail archive

[Prev][Next][Index][Thread]

Re: Dragging nodes of a formatting graph



   Date: Thu, 12 Nov 92 10:23:38 PST
   From: Brian Anderson <bha@atc.boeing.com>
   ...
   | somewhat different.  Mine uses format-graph-from-root, which you
   | didn't want. 
   Even when you redraw things at specific coordinates (as a result of
   the user having moved stuff around)?
No, in my version (unlike Bill's, I think), I maintain the
parent-child realtionships, which are changed when nodes are moved to
different parents, but then format-graph from root is used to redraw
the whole tree.  
   ...
   | position, allowing the user to drag it in the window.
   Animation would be cool.
   ...
   I hope that I have stated my requirements correctly.  I think that you
   understand but from some of the responses on the mail-list, I'm not
   sure that everyone does.  Let me try again just to make sure:

     1.  I want to perform an initial layout of a graph.
	 I would guess that format-graph-from-root would be a likely
	 candidate for doing this.
     2.  Once I have the layout, I want the user to be able to reposition
	 graph nodes.  The idea would be a drag and drop with animation
	 technique.  Of course, arcs would be repositioned also.
1. As with what I described, you CAN use FORMAT-GRAPH to begin with, and
you can implement a drag routine such that nodes can be dragged to a
different parent.  In redrawing using F-G-F-R, new arcs would of
course be drawn between new parent-child relationships.  I DON'T know,
however, how to use updating-output to do this.  I've been working on
it and still can't get that to work.

     3.  Now that I have a user modified layout, I want to gather the
	 coordinates of the nodes and arcs.  Maybe this should be done in
	 some unitless and/or normalized coordinate system?
2. When the nodes are drawn, a) save the output record produced by a
CLIM:PRESENT call, or produce an output record explicitly using
with-new-output-record or some similar function; b) you can convert
the coordinates of the output record to the coordinate-system of the
window using CONVERT-FROM-DESCENDANT-TO-ANCESTOR-COORDINATES; c) you
could save these output records either in the node structures
themselves or in a separate data structure.

     4.  Next, I want to "checkpoint" the current state of the layout in
	 some external representation.  This would involve gathering the
	 set of nodes, their coordinates and the application object that
	 these nodes represent and the set of arcs that comprise the
	 graph and writing some sexp to a file.
You've already got the nodes, I just talked  about how to acquire and
save the coordinates, and I'm assuming the arcs are part of the nodes'
structures.

     5.  Finally, I want to reinstantiate the graph from the external
	 representation.  This involves recreating the application
	 objects and drawing the graph at the coordinates specified
	 (rather than automagically doing the layout).  Now, a user
	 should be able to further modify the layout and repeat steps 3-5.

   The questions are:

     1.  Is format-graph-from-root the best starting point for the
	 initial layout of the graph?
Probably, at least to avoid having to do your own graph space-layout
routine, except that as I mentioned, I can't get UPDATING-OUTPUT to work.

     2.  How do I drag and drop nodes, have them redrawn and their
	 respective arcs redrawn?  This is what Bill's and your code
	 does(?).
You can use CLIM:TRACKING-POINTER or CLIM:DRAGGING-OUTPUT, either one.
I use something like the following:

(let ((rec (with-new-output-record (win) (draw node win startx starty)))
      (old-win win)
      (old-x startx)
      (old-y starty)
      (new-rec)
      (target)
      )
      (clim:tracking-pointer
       (win :multiple-window nil)
	;;; null the target because we've moved off, and redraw
       (:pointer-motion (window x y)
			(setq target nil)
                        ;;; if it's moved enough to matter...
			(when (or (not (eql old-win window))
				  (> (abs (- x old-x)) 5)
				  (< (abs (- y old-y)) 5))
	                  ;;; draw the new picture
			  (setq new-rec (clim:with-new-output-record (window)
					  (draw node window x y)))
                          ;;; erase the old one
			  (when rec
			    (clim:erase-output-record rec old-win))
			  (setq rec new-rec)
			  (setq old-win window old-x x old-y y)
			  ))
If you don't want to do so much of this yourself you should use
CLIM:DRAGGING-OUTPUT.

     3.  How do I gather coordinates?  How should they be "normalized."
Paragraph 2 above.  I don't know how you want them normalized, so I
can't really answer that.  Using CONVERT- will give you coordinates
with respect to the window origin if you use the window top-level
output record (CLIM:OUTPUT-RECORDING-STREAM-OUTPUT-RECORD WINDOW)) as
the second argument.

     4.  What do I use to redraw the graph from a specification of node
	 and arc coordinates?  Can I get formatting-graph-from-root to
	 redraw from a specific set of coordinates rather than computing
	 the "best" coordinates for me as is its typical behavior?
I don't believe F-G-F-R can be used to do this.  However, it shouldn't
be difficult to write a drawing routine if you know where the nodes
belong.  The hard part is figuring out where to put them.

     5.  I presume that I can grab the application object behind the
	 scenes of each node in the graph.  I just haven't looked into
	 this but I presume its straight forward.
The object can be gotten from the presentation with
CLIM:PRESENTATION-OBJECT.

     6.  I eventually need to deal with directed cyclic graphs.
Then you can't use F-G-F-R and you may have to write your own routine.

     7.  Should I wait for CLIM 2.0.  I am on the queue to get 2.0beta
	 from Franz "real soon now."  Would 2.0's
	 formatting-graph-from-roots be better?
I don't know.  Bill?  Scott?

   Brian H. Anderson
   Boeing Commercial Airplane
   (206) 234-0881
   bha@gumby.boeing.com

Jeffrey
-----------------------------------------------------------------------------
jclose@ads.com: ADS BA&H/1953 Gallows Rd #600/Vienna, VA 22182 703-902-7150

Anarchists don't believe in rules.  Surrealists make up their own.




0,,


Main Index | Thread Index