Last point in the route doesn't change leading to unexpected route


#1

Hi,

I have hosted diagram control in a tabbed control and also have unlinked connectors are valid.
The setup is such that once a node is dragged on any one of the diagram the others tabs (diagram objects) also will add the same node. This is perfectly working when I have all the diagrams in tabbed form

Now when I have dragged out a tab and pinned it to look side by side. When I drag a node and create a unlinked connection both the diagram objects will get same route as expected but when I drag the aggregate from one of the tabs and across the diagram and drop it. Please be noted that we have overridden Dragging Tool to include unconnected links to move along with the node. Now the route will change except the last point.

Ex: is Route points before dragging are {(10,10),(12,15),(18,25),(25,30),(32,45),(45,50)} after I drag and drop the routes will be {(12,12),(11,19),(13,27),(23,16),(22,15),(45,50)} The last Point always remains the same.

When I tabs side by side:
Before:

After I drag the node around:

Notice that all other route points got changed while the node was dragged except the last point and hence the link is pointing to the same place.

What I expect is that the route of the link not be changed and maintain the same shape but move to the new location as the node.

Suggestions awaited.


#2

That behavior is seen in the Draggable Link sample, when one moves a Node and the unconnected other end of a connected Link is not supposed to move.

It appears that Route.ComputePoints is being called. Presumably that is because the link route is being invalidated for some reason. But the DraggingTool explicitly suspends the routing of the Links in its collection of DraggingTool.DraggedParts, so I don’t understand how that could happen. Could you confirm that during the drag that DraggingTool.DraggedParts includes your partly-connected Link?


#3

this is the content from my draggingTool:

 public override Dictionary<Part, Info> ComputeEffectiveCollection(IEnumerable<Part> parts)
    {
        var map = new Dictionary<Part, Info>();

        if (parts == null)
        {
            return map;
        }

        foreach (var part in parts.OfType<Node>())
        {
            Node node = part as Node;
            map[node] = new Info() { Point = node.Location };
            if (node.LinksConnected.Any())
            {
                node.LinksConnected.ToList().ForEach(openLink => map[openLink] = new Info());
            }
        }
        return map;
    }

    protected override bool ConsiderDragOver(System.Windows.Point pt, Part p)
    {
        Link link = p as Link;
        if (link != null)
        {
            Dictionary<Part, Info> parts = this.CopiedParts ?? this.DraggedParts;
            if (parts == null)
            {
                return false;
            }

            if (parts.ContainsKey(p))
            {
                return false;
            }
        }
        return base.ConsiderDragOver(pt, p);
    }

#4

Your override of ComputeEffectiveCollection is going to include Links that are connected with a selected Node and are connected with an unselected Node.

Despite that I still don’t see what the problem is. How is your link template defined?


#5

Thanks for the suggestions Walter.

I had a look at Draggable link sample the behavior is not same. In sample app the if you select node and the open link and move them both will take up the location of the dropped location. If you select only the node and move it around the open end of the link stays at the same point.

But in my case when I select node and link and move it around both will move but when I drop it the node gets the new location but the open end of the link will get the same old location.

Its the same behavior if I select node alone.

Another point to mention is that if I have 2 diagram objects side by side docked I find this odd behavior rather if I have it in tabbed fashion it works fine as expected ( i.e. the link routes gets the updated to new location).

Could this be because of Diagram.Panel.ViewportBounds which is expected to be same in both diagram objects but its not same when I drag the tab out


#6

I am suspicious that the DiagramPanels are not the same size when you would expect them to be the same. Have you tried setting http://goxam.com/2.2/helpWPF/webframe.html#Northwoods.GoWPF~Northwoods.GoXam.Diagram~UnloadingClearsPartManager.html to false?

Have you checked that each Diagram is still the same after the reconfiguration? Is each Diagram.DraggingTool still an instance of your custom DraggingTool class with the same property values?


#7

UnloadingClearsPartManager is false otherwise it would actually clear all the parts from the model once tab would be dragged out.

Also I verified the DraggTool is the same object.


#8

Another Observation that i found was, Lets say I have 2 diagram objects side by side and lets say the one on left is Diagram1 and on the right is Diagram2. Now, When I drag a aggregate with unconnected link on Diagram1 “UpdateRouteDataPoints”(Overridden method) method from PartManager is called but for the Diagram2 object.

I expect Diagram1 object to be called first as the event of drag is happening on Diagram1. with a current Transaction in Undo Manager as “DelayRouting”


#9

We found a property called DefaultToPoint in Route. Is this creating problem?.


#10

Wait – are you saying that while the drag is within Diagram1, there were events happening in Diagram2? Or are you saying that events were happening in Diagram2 when the mouse had moved into Diagram2? The latter case is correct, but SkipsUndoManager will be true during the drag in Diagram2.

Yes, “DefaultToPoint” is an internal property used to implement the standard routing for partly disconnected links. But moving a Link (i.e. Route.MovePoints) will update all of the points of the route as well as the “DefaultToPoint”, so I don’t think that property is causing a problem.


#11

What I saw while debug is that when I dragged in Diagram1 the UpdateRouteDataPoints of Diagram2 was being called. I verified this using this.Diagram.DataContext. Also this behavior is only when the Diagram objects are side by side.

When they are as tabbed form UpdateRouteDataPoints is called for the same Diagram object on which I dragged.


#12

Hmmm, that’s surprising. I cannot explain it. That’s why I suggested that you make sure that all of the significant objects of each Diagram (including PartManager and DraggingTool) are distinct and have the property values that you initially set up and would expect to have.


#13

So I’ve had time to create a sample. I still don’t know about the situation that you are encountering.

But I do see how copying a Node and a connected Link from one Diagram to another causes problems, because the list of Points is copied but has points that are not where the node and link are being dropped. Setting the Link.Points causes it to remember the DefaultToPoint with the last Point of the List. But the new node causes the connected link to be re-routed, so that the new link route connects all the way from wherever the node was dropped to the DefaultToPoint. But that DefaultToPoint is actually the end point of the link in the source diagram, not where it should be in the destination diagram.