Consider there is a node and a link which is not connected to any node on the other side. Now if we move the node the link re-routes keeping the open end of the node at the same location.
I want to have a feature like if I move any node which has a unconnected link the whole link should move along with the node without rerouting.
You’ll note that if you select such Links, they will be moved along with the Node. So I think you just need to override DraggingTool.ComputeEffectiveCollection to include connected Links that are not connected to other Nodes.
Thanks for the suggestion. I tried using it but the location of the link and node are going in random location.
Could you provide some examples regarding the same ?
This is how it happens right now:
This is my node with unlinked connection
when I tried to select the node and drag the node and the links gets seperated:
How did you override DraggingTool.ComputeEffectiveCollection? Here’s an example override that includes a lot more than what you want, because it includes related Nodes:
public override Dictionary<Part, DraggingTool.Info> ComputeEffectiveCollection(IEnumerable<Part> parts) {
if (this.IsShiftKeyDown()) {
return base.ComputeEffectiveCollection(parts);
} else {
var map = new Dictionary<Part, DraggingTool.Info>();
if (parts == null) return map;
foreach (var n in parts) {
GatherConnecteds(map, n);
}
return map;
}
}
private void GatherConnecteds(Dictionary<Part, DraggingTool.Info> map, Part part) {
var node = part as Node;
if (node == null) return;
if (map.ContainsKey(node)) return;
// record the original Node location, for relative positioning and for cancellation
map[node] = new DraggingTool.Info() { Point = node.Location };
// now recursively collect all connected Nodes and the Links to them
foreach (var link in node.LinksConnected) {
map[link] = new DraggingTool.Info();
GatherConnecteds(map, link.GetOtherNode(node));
}
}
Note that for the Nodes that you want to include in the effective collection, which should include all selected Nodes, that the corresponding Dragging.Info needs to have their original Location.