Pinning Nodes


Is there an easy way to pin a node, so that the the GoLayeredLayout autolayouts all nodes other than those ones that have been pinned to the view.


Create the GoLayoutNetwork explicitly (as shown in the GoLayout User Guide) and then call GoLayoutNetwork.DeleteNode(GoObject) for each of the nodes that you don’t want the layered-digraph autolayout to consider.
An alternative is to have only the nodes and links that you want to layout in a separate layer, and you initialize the GoLayoutNetwork with just that GoLayer instead of with the whole GoDocument. (That works because both GoLayer and GoDocument implement IGoCollection, which is the argument to GoLayoutNetwork.AddNodesAndLinksFromCollection.)


Hi Walter,
I really appreciate all the help, my apoligies for not looking over the golayout documentation well enough before posting. One quick question, I implemented the solution that you suggested, and it works really well for the most part. My only question is, is there a way, to make the layout take in to account all the nodes that arent part of the network. For instance, I have an orginizational chart type application going, well the user only wants nodes that have never been moved by the user layed out during an autolayout. So I create a network based on just these “untouched” nodes and lay them out, but they dont seem to layout below their parent nodes that cant be layed out, they kind of do their own layout. I know this is a goofy situation, but I was curious if you had a suggestion.
Thanks again Walter,


I’m not sure I understand what exactly you want to have happen.
If there are three nodes connected by two links, A --> B --> C, and the user manually moves B to be “above” or “before” A, where should A be positioned? And where should C go?
Or with the same A --> B --> C graph, what if the user swaps the positions of A and C. Where should B go?
Would performing a layout of the whole graph, followed by the restoration of the manually moved nodes’ positions, produce the effect that you seek?


Its actually really stupid Walter. In your example, if A --> B–> C are connected, and the user moves b anywhere, b can no longer be moved by the layout, only a and c can. So once the user moves the node just once, its position is set, and it can no longer be considered in the golayout network. I have found a somewhat easy work around, so thanks for the help. By the way, if I wanted to get a collection of all currently selected goobjects in a view, which property would I use? I was attempting to use the goview.Selection property, and iterating through the objects with the backwards enumerator, but I only seem to ever get one object in the selection collection regardless of how many objects I have selected. Should I override the GoToolSelecting.Selecting and GoToolSelecting.UnSelecting (or whatever the proper method names are) and maintain my own collection of currently selected goobjects? Or am I just missing something?


That’s odd–GoView.Selection is a GoSelection which indeed implements IGoCollection and should hold references to as many objects as the user has selected in that view.
There is a GoView.MaximumSelectionCount that GoSelection.Add observes to limit the number of objects that can be selected, but I assume that’s not the behavior you see.
What is the value of GoView.Selection.Count?
Are you modifying the collection while you are iterating? That would be a no-no, according to the .NET Framework standards (not just for GoDiagram collection enumerators).


Im not modifying the selection at all, just simply looking at some of each objects values as I iterate. The count is also always one. I really havent used the selection up unto this point, so I don’t believe that I’ve done anything elsewhere to mess up the selection collection. I actually only use the GoDraggingTool.EffectiveSelection for anything in my view. I guess I’ll have to review my code and figure out whats happening. Thanks


Alright, Im an idiot, I was checking the selection collection after an onobjectcontextclicked function. Which chooses just one object. Sorry to have bothered you.


By the way, if you want the context click to operate on a multiple selection, set GoToolContext.SingleSelection to false:
(aView.FindMouseTool(typeof(GoToolContext)) as GoToolContext).SingleSelection = false;