Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to tell LayeredLayout to consider areas in the arrangement? (Read 4557 times)
Erwin Lackner
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Dec 10th, 2018
How to tell LayeredLayout to consider areas in the arrangement?
Dec 17th, 2018 at 1:44pm
Print Post  
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!
  

ProcessPlanArrangedByLayeredLayout.png ( 26 KB | 158 Downloads )
ProcessPlanArrangedByLayeredLayout.png
ProcessPlanArrangedAndLayoutByArea.png ( 36 KB | 162 Downloads )
ProcessPlanArrangedAndLayoutByArea.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #1 - Dec 18th, 2018 at 8:55am
Print Post  
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
Select All
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
  
Back to top
 
IP Logged
 
Adis
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: May 27th, 2019
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #2 - May 29th, 2019 at 7:17am
Print Post  
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 | 175 Downloads )
Screenshot_24.png
Screenshot_25.png ( 18 KB | 156 Downloads )
Screenshot_25.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #3 - May 29th, 2019 at 8:08am
Print Post  
Hi,

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

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Adis
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: May 27th, 2019
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #4 - May 29th, 2019 at 11:10am
Print Post  
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 | 146 Downloads )
Screenshot_26.png
Screenshot_27.png ( 10 KB | 145 Downloads )
Screenshot_27.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: How to tell LayeredLayout to consider areas in the arrangement?
Reply #5 - May 30th, 2019 at 9:19am
Print Post  
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
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint