Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Autoroute links (Read 4939 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Autoroute links
Jan 11th, 2012 at 11:16am
Print Post  
Hello. I have the some problem. I try to draw diagram automaticaly using the set of the some data. So in this case for the links I use the Route() method. And it works different in the same cases. In one case links are routed fine but in the another case they are stick together. Example in the attachment 1. But I need the behaviour as in the attachment 2. The fragment of the code is below
Code
Select All
foreach (TPDEDataObj obj in a_DataObjs)
                {
                    obj.ProcessId = nProcessId;
                    TPDEOperationData data = obj as TPDEOperationData;
                    if (data != null)
                    {
                        TPDEOperationNode node = new TPDEOperationNode();
                        node.Id = data.Id;
                        a_DiagramObj.LastAssignedId = node.Id;
                        node.Text = data.Operation.ItemName;
                        node.TextVerticalAlignment = AlignmentY.Center;
                        node.TextAlignment = TextAlignment.Center;
                        node.TextBrush = Brushes.Blue;
                        node.ToolTip = " ";
                        node.ToolTipOpening += a_DiagramObj.OnToolTipOpening;
                        node.ToolTipClosing += a_DiagramObj.OnToolTipClosing;
                        node.CustomDraw = CustomDraw.Additional2;
                        node.AnchorPattern = TPDEDiagram.CreateAnchorPattern(1, 1);
                        node.HandlesStyle = HandlesStyle.Custom;
                        dropPnt = new Point(dblWidthOffset, dblHeightOffset);
                        alignedPnt = a_DiagramObj.m_Diagram.AlignPointToGrid(dropPnt);
                        node.Bounds = new Rect(alignedPnt.X, alignedPnt.Y, nNodeWidth, nNodeHeight);
                        if (nOpInRowCt < OperationsInRows)
                        {
                            dblWidthOffset += nNodeWidth + 45;
                            nOpInRowCt++;
                        }
                        else
                        {
                            dblWidthOffset = 150;
                            dblHeightOffset += nNodeHeight + 30;
                            nOpInRowCt = 0;
                        }
                        a_DiagramObj.m_Diagram.Nodes.Add(node);
                        TPDEDiagramLink link = new TPDEDiagramLink(a_DiagramObj.m_Diagram, prevNode, node);
                        a_DiagramObj.m_Diagram.Links.Add(link);
                        link.Route();
                        prevNode = node;
                        data.Design.FillPropsByNode(node);
                        processData.Add(data.Id, data);
                    }
                    else
                    {
                        TPDEStepData stepData = obj as TPDEStepData;
                        if (stepData != null)
                            processData.Add(stepData.Id, stepData);
                    }
                }
 

  

Test_30_src.rar (Attachment deleted)
Test_30Nodes_modify.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Autoroute links
Reply #1 - Jan 11th, 2012 at 12:07pm
Print Post  
It might depend in what context you are calling Route. If the link router is suspended at that time (which is true when some events such as Modified are raised), then all links will be routed together when routing is resumed. In that case the router will consider all links in the same batch and pull them apart. Otherwise calling Route on individual links does not consider other links in the general case, and they might overlap. You might try either calling the Diagram.RouteAllLinks() method instead of Route() on individual links, or explicitly suspending the router before processing the links and resuming it afterwards (Diagram.LinkRouter.Suspend and ...Resume methods).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Autoroute links
Reply #2 - Jan 11th, 2012 at 12:30pm
Print Post  
Ok. Thanks. As for me in this case all links routed not fine but uniformly and they are not stick together
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Autoroute links
Reply #3 - Jan 11th, 2012 at 1:55pm
Print Post  
I'm not sure what that meant Smiley Is it ok now using RouteAllLinks?
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Autoroute links
Reply #4 - Jan 11th, 2012 at 2:36pm
Print Post  
Smiley Yes, possibly it is ok. I try to show you screenshots. When I use the RouteAllLinks() or Suspend and Resume methods() I see the picture as in the attachment 1. But from an aesthetic point of view screenshot int the attachment 2 looks like better. And I don't understand why link between 1st and 2nd rows looks like as in the attachment 2 but all other similar links (between 3rd and 4th rows, 4th and 5th rows and etc.) routed in the another case
  

screen1.jpg ( 109 KB | 177 Downloads )
screen1.jpg
screen2.jpg ( 106 KB | 176 Downloads )
screen2.jpg
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Autoroute links
Reply #5 - Jan 11th, 2012 at 6:04pm
Print Post  
You should get results as on the second screenshot with this code, however GridRouter might be awfully slow if you add hundreds of links:

Code
Select All
diagram.LinkRouter = new GridRouter();
diagram.RoutingOptions.LengthCost *= 4;
diagram.RouteAllLinks(); 



The problem is that the default QuickRouter does not consider link lengths, but only counts the number of leaves in some kind of spatial tree built for the diagram. It turns out that the number of leaves are the same for the lower and upper paths when you arrange nodes like that, and so the router arbitrarily selects the upper one. Our developer will see if it's possible to add some length detection to prevent that, without slowing down QuickRouter.

Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Autoroute links
Reply #6 - Jan 12th, 2012 at 8:57am
Print Post  
Thank you very much! You adviсe is very helpful. It will be very good if the QuickRouter will  route links as this code and in the same time quickly.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Autoroute links
Reply #7 - Jan 31st, 2012 at 3:00pm
Print Post  
Our developer improved handling of long links in QuickRouter. Could you check if this version works any better with your diagrams?

https://mindfusion.eu/_beta/wpfdiag_longroutes.zip

Only the 'normal granularity' mode has been improved, you can switch to it like this:

var router = (QuickRouter)diagram.LinkRouter;
router.Granularity = Granularity.Normal;

I hope that help,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint