Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic IgnoreLayout question (Read 2558 times)
jcaron
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Jul 23rd, 2019
IgnoreLayout question
Sep 25th, 2019 at 1:39pm
Print Post  
Hi,

I have a diagram that is originally generated automatically. I allow the user to move nodes and would want to keep the positions of those nodes when I reapply the automatic layout (I use the Fractal layout). I tried using the Ignorelayout property that I assigned to true during the NodeModified event. Unfortunately, the positions are not maintained when I reapply the automatic layout. Am I missing something?
Thanks!
Jean
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: IgnoreLayout question
Reply #1 - Sep 26th, 2019 at 3:48am
Print Post  
Hi,

I've tried this modification of FractalLayout example and the printed position is the fixed one -

Code
Select All
RandomTree(root, 5, 4);
Arrange(root);

if (ignored != null)
    Debug.WriteLine(ignored.Bounds);
.....

DiagramNode ignored = null;

void RandomTree(DiagramNode node, int depth, int minChildren)
{
        .....
        if (diagram.Nodes.Count == 10)
        {
            child.Move(42, 42);
            child.IgnoreLayout = true;
            ignored = child;
        }
        .....
} 



I guess apparent position on screen could change if you use some form of auto-resizing and Diagram.Bounds' origin changes. In that case you could record relative positions of ignored nodes in a Dictionary<DiagramNode, PointF> and reapply the offset back after the origin changes. Or if DiagramNode.Bounds is really not preserved for you, then you could store and restore positions via a Dictionary<DiagramNode, RectangleF> map.

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


I Love MindFusion!

Posts: 7
Joined: Jul 23rd, 2019
Re: IgnoreLayout question
Reply #2 - Sep 26th, 2019 at 8:06pm
Print Post  
Good day Slavcho,

Thanks for the quick answer, I readjusted a few things in my code and got it to work.

I have yet to try with the other layouts, but the Fractal version does not seem to take the position of the fixes diagram items into consideration - it almost seem as if it ignores those nodes from its calculation of the positions of connected nodes.

Would you know if the other layout algorithm would behave the same?

Or options to make the layout calculations to consider the fixed nodes as a constraint in their evaluation?

Thanks and regards,
Jean
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: IgnoreLayout question
Reply #3 - Sep 27th, 2019 at 6:45am
Print Post  
Hi,

That's what IgnoreLayout does, the layout code doesn't know ignored nodes exist at all. This option is to keep decorative / background or group subordinate items at their original locations (relative to the group for latter ones). If you need fixed nodes that exert influence on other ones but don't move themselves, try SpringLayout with the SpringLayoutTraits.Frozen option.

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


I Love MindFusion!

Posts: 7
Joined: Jul 23rd, 2019
Re: IgnoreLayout question
Reply #4 - Oct 2nd, 2019 at 8:33pm
Print Post  
Thanks Slavcho for your explanations. I am experimenting with the Springlayout and the Frozen trait, it is slower than the Fractal, but results are much better visually - at least for the diagram I use for testing.

Thanks for the good support!
Regards,
Jean
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint