Hi! On Friday 23 January 2009, Michael Quigley wrote: > All, > > I'm working on getting the basics together for a typical graph-structure > editor. I've borrowed some code from the "Elastic Nodes" example to serve > as the basis of my editor. I have a couple of issues that I'm hoping to > get some help with... >
[Lots of code removed] > Second (and related to the first issue), is there a more appropriate > technique for representing the edges in my scene? The position of the > edges are all "0, 0" and the bounding rectangles are all represented > relative to the scene positions of the center points of the nodes. This is > how the "elastic nodes" example worked. In general, is there a better way > to deal with graphics items that depend on the position of two other > graphics items, but there isn't a clear parent/child relationship? > I don't think that a more elegant method can exist. You need to express a vector between the positions of the two nodes of an edge and to do that you need the coordinates of both in a common frame of reference. And as far as I can see, you already calculate the position in the simplest frame of reference for your problem: the common parent for all your nodes, the untransformed coordinate system of the GraphicsView. I truely doubt that there is a better way. I've been having the same issue in the graph editor in Moonlight|3D and I remember that I felt like doing something quite inelegant at that point. :) I'm thinking about a new feature for QGraphicsLineItem: set line end points in coordinate systems of other nodes. The item would then remember and monitor the other node for transformations and update itself so that the end point stays at the same position relative to that node (in other words, at the same coordinates in that node's coordinate system). Maybe this stretching between nodes that arises from this feature could be generalized somehow, so any graphics items could exploit it in similar ways. > Third, is using the "itemChanged()" method on the node, and then calling a > method on the edge to recalculate its geometry, which in turn calls > Edge.update(), the right way to handle scene updates? > I think this is the right way. I'm using QGraphicsLineItems and only update the positions of the line endpoints, but I have to assume that this calls update() internally. As far as I remember, multiple calls to update() within Qt are not particularly bad because the redraw is lazy and multiple update() calls cause just one combined redraw. > Thanks in advance for any guidance anyone can offer! > > Michael > Regards, Gregor
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Qt-jambi-interest mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
