Layout just a subset of nodes and other questions

Hello,

I’m evaluating GoXam and have a few questions.

  1. I was trying to programatically add some nodes and links then just have them be rearranged on the diagram semi-intelligently. I tried to modify the logic circuit to do this but couldn’t get it to work. I added the nodes fine and I call myDiagram.LayoutDiagram(Which should reroute all the nodes/ links which I don’t really want) but it doesn’t do anything. What am I missing to make this work?

  2. Is there a way to make nodes/links you paste into the diagram keep the formatting it had before you copied it? Such as temporary turn of the routing when you paste.

  3. When you drag a new node over the diagram it add a temporary node(aka the one your dragging) to the diagram then after you drop it removes that node and adds a permanent one. In the OnNodeAdded event in part manager is there a way to tell the difference between the two?

Thanks
-Devon

Let’s start with the first question. You can layout a subset of the nodes and links in your diagram by first setting the Diagram.Layout property, for example:

<go:Diagram . . .>
go:Diagram.Layout
<go:TreeLayout . . . />
</go:Diagram.Layout>
</go:Diagram>

and then calling the doLayout(IEnumerable nodes, IEnumverable links) method on the Layout object. Note that you’ll want to set the Diagram.Layout.Network to null before calling doLayout.

However, that being said, you probably don’t really want to do that. Laying out a subset of the diagram without considering the locations of all the nodes and links in the diagram will likely result in sections of the newly laid out subset overlapping with other sections of the diagram. You can work try to work around that by writing code to make room for the newly laid out subset, but that can get complicated and error prone.

Instead, one typically does a layout of the entire diagram. By the way, you can also apply separate layouts to Groups within the diagram, so you can apply layouts to subset of the diagram that way, while still considering all the nodes in the diagram so that the resulting diagram doesn’t have overlapping sections.

Also, one typically does not programmatically call doLayout to perform the layout. Instead it’s easier and more reliable to let GoXam handle the events and perform the layout whenever it’s necessary. Each DiagramLayout has a Conditions property that governs which LayoutChanges will cause a re-layout, but the default is to perform a layout whenever any node or link is added or removed, which is typically what you want.

Please take a look at the Layout section of the GoXamIntro.pdf document for more info.

Regarding question 2, copy and paste is simply making a copy of the Data for the for the parts being copied.

If you’ve bound the link route Routing property to one of your data fields, copy and paste will make a faithful copy of that. In particular, if the routing property is “AvoidsNodes”, then new newly copied node will also have AvoidsNodes set. Any time a link with the AvoidsNodes property is repositioned, the link route is recalculated, so it will not necessarily preserve the previous link routing.

You could perhaps override PartManager.CopyParts and make changes to the copied data. The link points are stored in Link.Route.Points and you could copy those points to the new links and change the routing property so it wouldn’t automatically recalculate the route, but I’m not sure you want to get into that.

Regarding question 3, you can distinguish between the 2 cases by looking at what layer the node is in:

  protected override void OnNodeAdded(Node node)
  {
      if (!node.Layer.Id.Equals("Tool"))
      {
          // This is a real drop
      }
  }

Or better yet, lookat the type of tool that is Diagram.CurrentTool.