- Welcome, Guest. Please Login or Register
MindFusion  
  We are soon releasing MindFusion.JavaScript pack. Initial version includes chart, diagram, calendar, map, virtual keyboard, gauge and UI components. Here are the beta version and live demo for anyone interested.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
How to tell LayeredLayout to consider areas in the arrangement?
Read 583 times

Erwin Lackner   Offline
YaBB Newbies
*
Posts: 1
I Love MindFusion!


   
     
 
How to tell LayeredLayout to consider areas in the arrangement?
Dec 17th, 2018 at 1:44pm
 
Hello,
we are currently evaluating a purchase of MF 6.5.3 to automatically layout process plans based on given connection data.

Once we had looked at and tried out the various layout variants available, we chose LayeredLayout for our example. That looks quite reasonable.  (see screenshot ProcessPlanArrangedByLayeredLayout.png).

Additionally it is necessary to partition the process plan (respectively its nodes) into certain areas (see screenshot ProcessPlanArrangedAndLaoyutByArea.png).

But this causes us difficulties at the moment, because we don't find a way to tell the LayeredLayout that it considers this partitioning/placing of nodes to certain areas.


Can you give us a hint how to solve this problem?

Thanks in advance!
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1702
Gender: male
tech.support


   
     
 
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #1 - Dec 18th, 2018 at 8:55am
 
Hi,

There's nothing built into LayeredLayout to allow partitions. You could try SwimlaneLayout, or otherwise some post-processing for LayeredLayout to move nodes into areas preserving their relative placement from the layout and only changing Y:

Code:
var ll = new LayeredLayout();
ll.Orientation = MindFusion.Diagramming.Layout.Orientation.Horizontal;
ll.EnforceLinkFlow = true;
ll.Arrange(diagram);

var columns = new Dictionary<int, List<DiagramNode>>();
foreach (var node in diagram.Nodes)
{
    if (!ll.Statistics.NodeLayerIndices.ContainsKey(node))
        continue;
    var l = ll.Statistics.NodeLayerIndices[node];
    if (!columns.ContainsKey(l))
        columns[l] = new List<DiagramNode>();
    columns[l].Add(node);
}

foreach (var column in columns.Values)
{
    column.Sort((n1, n2) =>
        {
            int area1 = (int)n1.Tag;
            int area2 = (int)n2.Tag;
            int areaComparison = area1.CompareTo(area2);
            if (areaComparison != 0)
                return areaComparison;
            return n1.Bounds.Y.CompareTo(n2.Bounds.Y);
        });

    float y = diagram.Bounds.Top + 10;
    for (int i = 0; i < column.Count; i++)
    {
        var node = column[i];
        int area = (int)node.Tag;
        float minAreaY = area * 70; // replace this with your area definitions
        if (y < minAreaY)
            y = minAreaY;
        node.Move(node.Bounds.X, y);
        y += node.Bounds.Height + 10;
    }
}

//diagram.RouteAllLinks(); 



Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     

Adis   Offline
YaBB Newbies
*
Posts: 5
I Love MindFusion!


   
     
 
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #2 - May 29th, 2019 at 8:17am
 
Hello,

After we implemented given code, moving nodes to desired lanes worked perfectly. But then one weird problem occurred, after calling diagram.RouteAllLinks(); method. I have attached 2 images, one is before calling the mentioned method, and another after. Node links between 6th and 7th node and 10th and 11th node should be same, but the link between 10th an 11th node is weirdly drawn.

Do you maybe have a hint what could cause this?

Best regards
 
 

Screenshot_24.png (18 KB | 8 )
Screenshot_24.png
Screenshot_25.png (18 KB | 6 )
Screenshot_25.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1702
Gender: male
tech.support


   
     
 
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #3 - May 29th, 2019 at 9:08am
 
Hi,

Try setting diagram.LinkRouter to a GridRouter instance, and set larger bend costs in RoutingOptions if necessary.

Regards,
Slavcho
 
 
 
IP Logged    
 
     

Adis   Offline
YaBB Newbies
*
Posts: 5
I Love MindFusion!


   
     
 
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #4 - May 29th, 2019 at 12:10pm
 
This solved problem on this diagram, but on some other I noticed again something similar. Please look at attached images. With QuickRouter links were drawn as expected, but now with GridRouter it's weird. I have tried manipulating TurnCost, CrossingCost, NodeVicinityCost properties but didn't help.
 
 

Screenshot_26.png (9 KB | 5 )
Screenshot_26.png
Screenshot_27.png (10 KB | 5 )
Screenshot_27.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1702
Gender: male
tech.support


   
     
 
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #5 - May 30th, 2019 at 10:19am
 
Maybe try a bit smaller RoutingOptions.GridSize, or otherwise align node positions and sizes to multiple of current size. The first link bend will always be at least one grid tile outside of grid area occupied by node, with an added RoutingOptions.EndPointsOffset - try setting latter to 0 too if it's larger now.

Regards,
Slavcho
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print