Node overlap in layout

Sorry, I think you have misunderstood.

User can drag and drop from 2 places

Case 1. Pallete - here user drags symbols from Pallete onto diagram which creates a record for Symbol in db and then he drags another one (which creates another record in db) then he links these 2 symbols together (which creates a link record in db for these 2 symbols)

Case 2. From Database - here symbols and connectivity is already described (you can think of it as dragging the record from db which would have been created as a result of previous operation in case 1)



In the situation that I showed in my previous post, there were no existing nodes or links in the diagram, everything was created with one single drag drop operation.

If you are explicitly performing diagram-level layouts, you probably need to make sure all Group layouts are performed first.

That’s normally done by the LayoutManager, but if you really want to construct and execute your own layout, then you’ll have to recursively do the Group.Layouts first.

How do I do “Group.Layouts” in code? and by recursively do you mean for a group within a group?

Just iterate over the Nodes of the Diagram, or the member Nodes of the Group, to look for Groups. Call DoLayout on each Group.Layout, passing it that Group’s member Nodes and member Links. Then do the layout for all of those nodes and links, including the groups which are now laid out.

I have added following code between bold lines of code (see previous post for full class)

ldLayout.ArrangementOrigin = diagram.LastMousePointInModel;

<br />foreach (var item in nodes) <br />{ <br /> if (item.IsSubGraph) <br /> { <br /> var groupNodesAndLinks = diagramModel.CreateDataCollection(); <br /> <br /> foreach (var node in nodes) <br /> { <br /> if (node.SubGraphKey == item.Key) <br /> groupNodesAndLinks.AddNode(node); <br /> } <br /> <br /> <br /> LayeredDigraphLayout gLayout = new LayeredDigraphLayout(); <br /> gLayout.LayerSpacing = 5; <br /> gLayout.ColumnSpacing = 0; <br /> gLayout.Direction = 90; <br /> gLayout.PackOption = LayeredDigraphPack.Straighten; <br /> <br /> Node groupNode = this.Diagram.PartManager.FindNodeForData(item, diagramModel); <br /> Group.SetLayout(groupNode.VisualElement, gLayout); <br /> gLayout.DoLayout(this.Diagram.PartManager.FindNodesForData(groupNodesAndLinks), this.Diagram.PartManager.FindLinksForData(groupNodesAndLinks)); <br /> } <br />} <br />

ldLayout.DoLayout(this.Diagram.PartManager.FindNodesForData(allNodesAndLinks), this.Diagram.PartManager.FindLinksForData(allNodesAndLinks));



and now i get this