Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically (Read 5214 times)
dossantos
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Mar 25th, 2013
Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Jul 10th, 2014 at 1:24pm
Print Post  
Hi all,

I call layout.Arrange(diagram) on a SpringLayout periodically from a worker thread (using diagramView.Invoke for safety), and this works really well! It's even possible to modify the diagram during this (setting LayoutTraits.Freeze on the modified node during its modification). This is so cool! Smiley

I noticed a strange behaviour, though. Here's a screencast showing the issue:  http://youtu.be/fkux7L_Kn1Q

Sometimes (not always), single nodes suddenly "jump" to a completely different location (see the linked screencast). I didn't interfer with the diagram in any way during the "jumps".

This looks like some computation error inside the layout algorithm or something...

Can you explain this behaviour?


Thanks,
  Tim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #1 - Jul 10th, 2014 at 1:47pm
Print Post  
Hi,

This might be a result of the MinimizeCrossings property, which kind-of shakes the graph at each 10th step to try if a different local configuration will decrease crossings. It is enabled by default, so try setting it to false.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #2 - Jul 10th, 2014 at 1:53pm
Print Post  
We have a similar AnimatedLayout example coming with WPF version of the control, and now I see that it explicitly sets layout.MinimizeCrossings = false; so that's it I suppose.
  
Back to top
 
IP Logged
 
dossantos
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Mar 25th, 2013
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #3 - Jul 10th, 2014 at 2:04pm
Print Post  
No, MinimizeCrossings doesn't seem to make a difference.

But, I noticed I still had EnableParallelism = true, so I deactivated that one and it seems to have solved the issue!

I'll let you know if it occurs again, but since I disabled parallelism, I didn't see jumpy nodes again.


Thanks,
  Tim
  
Back to top
 
IP Logged
 
dossantos
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Mar 25th, 2013
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #4 - Jul 10th, 2014 at 2:11pm
Print Post  
Well, it seems to still occur, even with no parallelism. sigh.

I'll investigate further.

I noticed, though, that it seems to happen only with the rightmost nodes - could it be some issue with the diagram's bounds?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #5 - Jul 10th, 2014 at 3:19pm
Print Post  
Try running with the code below copied from the sample project, or post your code with attached diagram file and our developer will check it.

Code
Select All
private void InitSpringLayout()
{
	layout = new SpringLayout();
	layout.NodeDistance *= 2.0 / 3;
	layout.IterationCount = 1200;
	layout.SplitGraph = false;
	layout.MinimizeCrossings = false;
	layout.LayoutMethod = SpringLayoutMethod.Classic;
	layout.BeginArrange(diagram, null);

	iteration = 0;
} 

  
Back to top
 
IP Logged
 
dossantos
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Mar 25th, 2013
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #6 - Jul 15th, 2014 at 7:06am
Print Post  
I'll try to prepare an isolated testcase and will send it to you. Until then, thanks so far Smiley
  
Back to top
 
IP Logged
 
dossantos
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Mar 25th, 2013
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #7 - Jul 15th, 2014 at 9:08am
Print Post  
I isolated the behaviour in a small test application. Please refer to the attached solution; I can reproduce the behaviour every time by running the program and checking the "animate" checkbox.

Please tell me if this is appropriate for debugging!

Thanks,
Tim
  

MindFusionTest.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes occasionally jump around weirdly if calling layout.Arrange(diagram) periodically
Reply #8 - Jul 15th, 2014 at 11:05am
Print Post  
That happens because when you call Arrange, SpringLayout calculates initial layout area based on number and size of nodes, and pulls all nodes inside it. After a few hundred Arrange calls the rightmost node gets outside the calculated area and you see it pulled back in.

You could use the built-in animation methods of SpringLayout (BeginArrange, Iterate, EndArrange), and the layout area check will be done only in the beginning:

Code
Select All
this.diagram1.LoadFromFile("test.diag");

var sl = new SpringLayout
{
	Anchoring = Anchoring.Ignore,
	IterationCount = 5,
	NodeDistance = 50,
	MinimizeCrossings = false,
	GrowToFit = false,
	EnableClusters = false,
	LinkType = SpringLayoutLinkType.Straight,
	//EnableParallelism = false,
	Randomize = false // nicht random, sondern die initiale Partitionierung (s.o.) beachten!
};
sl.BeginArrange(diagram1, null);
this.layout = sl;

private void HandlesAnimTimerTick(object sender, EventArgs args)
{
	var sl = this.layout as SpringLayout;
	if (sl != null)
		sl.Iterate(0, 5);  // this won't pull back nodes anymore
} 



Alternatively keep using Arrange, but set SpringLayout.LayoutArea to the GetContentBounds() rectangle inflated by some margin area before each Arrange call.

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