Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Incremental GridLayout (Read 3535 times)
Krumm
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Sep 15th, 2020
Incremental GridLayout
Sep 15th, 2020 at 1:05pm
Print Post  
Hello there,

I'm just evaluating the WPF Diagramming pack. I'm wondering though, is there anything that would allow for incremental layouts of the GridLayout?

Thanks.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Incremental GridLayout
Reply #1 - Sep 15th, 2020 at 1:18pm
Print Post  
Hi,

Do you mean adding new nodes to the layout without rearranging older nodes? That's not supported at this time.

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


I Love MindFusion!

Posts: 4
Joined: Sep 15th, 2020
Re: Incremental GridLayout
Reply #2 - Sep 15th, 2020 at 1:22pm
Print Post  
Yes that is it. That is unfortunate, but not too worry - shall continue evaluating. I don't suppose it is in the pipeline for development is it?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Incremental GridLayout
Reply #3 - Sep 15th, 2020 at 1:46pm
Print Post  
I'll add it to our feature requests list, but it's rather long at this time ... Depending on the kind of graphs you create, setting GridLayout's StartNode and EndNode might help keeping the layouts similar enough between runs. Alternatively, you might arrange some invisible nodes and toggle their visibility later instead of adding new ones

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


I Love MindFusion!

Posts: 4
Joined: Sep 15th, 2020
Re: Incremental GridLayout
Reply #4 - Sep 16th, 2020 at 12:57pm
Print Post  
Hello Slavcho,

I hope you don't mind me adding another question to this topic but rather than creating any number of topics I thought it best to keep it together. I'm just playing around with the LayeredLayout example and I've tried upping the node count generated to something such as 200 (line 45) and it's taking up to 20 seconds. This seems extraordinarily slow and I'm running not so extraordinarily slow hardware. Is there something in the example that is there for the purposes of the example that should not be there for normal development?

Thanks.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Incremental GridLayout
Reply #5 - Sep 16th, 2020 at 2:40pm
Print Post  
Hi,

Line 45 is an outer loop, if I change it to 200 iterations it creates about 1800 nodes + 2000 links. If you need to arrange that large diagrams, try using async version of the arrange method, or set a smaller SwapPairsIterations value than default 5.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Incremental GridLayout
Reply #6 - Sep 16th, 2020 at 3:08pm
Print Post  
Also if all these items are shown on screen due to zoom-to-fit or if using Overview control, it will create a huge WPF visual tree that takes some time to render. You could follow the hyperlinks from this thread for some older discussions about performance -
https://mindfusion.eu/Forum/YaBB.pl?num=1530528922/1#1
  
Back to top
 
IP Logged
 
Krumm
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Sep 15th, 2020
Re: Incremental GridLayout
Reply #7 - Sep 18th, 2020 at 2:13pm
Print Post  
Thank you. Yes after looking closer at the code I see that it is not the number of nodes generated - my apologies for that. I do hope you don't mind me polluting the topic with further questions:

DiagramNode.Obstacle being ignored?
I have modified the RandomGraph function of the LayeredLayout as follows (setting all new nodes as Obstacle = true):
Code
Select All
private void RandomGraph()
{
	diagram.ClearAll();

	for (int i = 0; i < 30; ++ i)
	{
		int c = diagram.Nodes.Count;
		int g = 2 + random.Next(10);
		for (int j = 0; j < g; ++j)
		{
			var node = diagram.Factory.CreateShapeNode(0, 0, 40, 40);

			//NEW LINE:
			node.Obstacle = true;

			node.AnchorPattern = AnchorPattern.TopInBottomOut;
			if (j > 0)
				diagram.Factory.CreateDiagramLink(diagram.Nodes[diagram.Nodes.Count - 2], node);
		}
		for (int j = 0; j < 1 + random.Next(3); ++j)
			diagram.Factory.CreateDiagramLink(
				diagram.Nodes[random.Next(c)],
				diagram.Nodes[c + random.Next(g)]);
	}
}
 



The documentation makes it clear that this should ensure that a node is considered an obstacle. However it takes a few runs of the algorithm, but I can still have links crossing nodes (see the NodeCrossing.jpg attachment). Is the Obstacle property nothing more than a recommendation?
  

NodeCrossing.jpg ( 56 KB | 107 Downloads )
NodeCrossing.jpg
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Incremental GridLayout
Reply #8 - Sep 21st, 2020 at 5:41am
Print Post  
Obstacle is only checked when searching routes for AutoRouted links or calling link.Route / diagram.RouteAll methods. Layout classes generally do not use the link router and apply their own link paths.

For these specific LayeredLayout settings, links could intersect nodes because bend points are aligned to center of same layer. You could realign bends to the top or bottom of respective layer, I believe that should prevent all crossings then -

Code
Select All
var nodeHeight = 40f;
foreach (var link in diagram.Links)
{
    if (link.SegmentCount > 2)
    {
        // align first bend with top of its layer
        var bendPoint = link.ControlPoints[1];
        bendPoint.Y -= nodeHeight / 2;
        link.ControlPoints[1] = bendPoint;

        // align second bend with bottom of its layer
        int l = link.ControlPoints.Count - 2;
        bendPoint = link.ControlPoints[l];
        bendPoint.Y += nodeHeight / 2;
        link.ControlPoints[l] = bendPoint;

        link.UpdateFromPoints();
    }
    else if (link.SegmentCount == 2)
    {
        // links crossing a single layer have just one bend
        var bendPoint = link.ControlPoints[1];
        bendPoint.Y -= nodeHeight / 2;
        link.ControlPoints[1] = bendPoint;

        // insert second bend at bottom of layer
        bendPoint.Y += nodeHeight;
        link.ControlPoints.Insert(2, bendPoint);

        link.UpdateFromPoints();
    }
} 



That makes first / last segments closer to each other, so you might want to set larger layer distance to improve legibility. You could as well insert extra bends a few pixels above / below end points to make arrowheads orthogonal to nodes to avoid them intersecting with node sides too.

Or if you prefer to keep layouts more compact and with fewer bends, maybe just leave the link paths as they are, but move them to bottom of Z order so they are behind nodes.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Incremental GridLayout
Reply #9 - Sep 21st, 2020 at 5:52am
Print Post  
Above code was assuming links going downwards. If your graphs are acyclic, links should all flow from top to bottom, but otherwise you'd need a separate case for upward links where second bend is placed above first bend; there just exchange subtraction and addition operations to align first bend to bottom of layer and second bend to top.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint