Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic TreeLayout Vertical links ? (Read 3237 times)
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
TreeLayout Vertical links ?
Jul 28th, 2014 at 9:24am
Print Post  
Hey Stoyan,

I have 2 queries which I think would make our diagrams appear much neater...

We are using a TreeLayout and actually allow the user to select the TreeLayoutLinkType, so, the solutions have to work for all 4 options! Our users drag components onto the diagram which consist of a "parent" node followed by any number of "child" nodes from 0 to n. This creates the tree structure which shows their strategy visually.

Attached is a pic of a possible diagram, as you can see, the "Stop" node is across the bottom but no links exist to it yet.
I have toyed with anchor points etc but what i'm trying to get are perfectly straight vertical links from the 5 nodes down to stop. I.e. Almost an anchor point in the exact places that the link would meet the Stop node if vertical. I hope that makes sense!

The second thing is regarding the creation of links. As mentioned before, I offer the TreeLayoutLinkType as a choice to the user and when I programatically create a link I get this before arranging the layout to pull in the type needed, however, if the user creates a link manually and the linkCreated event is fired, it's obviously not using this. I don't want to call tree.Arrange when the user creates a link (only when they add new nodes) so is there any way of me getting that link to draw in the correct layout type? Currently, it always defaults to curved irrelevant of the preference choice.

Sorry it's a long one! I hope it makes sense.

Cheers,

Rich Smiley
  

diagram_001.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout Vertical links ?
Reply #1 - Jul 28th, 2014 at 10:07am
Print Post  
Hi Rich,

After layout.Arrange completes, you could loop over stopNode.IncomingLinks and set link point positions to make them straight line centered at origin node:

Code
Select All
foreach (var link in stopNode.IncomingLinks)
{
	var originCenter = link.Origin.GetCenter();
	link.Shape = LinkShape.Polyline;
	link.SegmentCount = 1;
	link.StartPoint = new PointF(originCenter.X, link.Origin.Bounds.Bottom);
	link.EndPoint = new PointF(originCenter.X, stopNode.Bounds.Top);
} 



Call the TreeLayout.UpdateLink() method to apply the layout's current LinkType to the specified link.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: TreeLayout Vertical links ?
Reply #2 - Jul 28th, 2014 at 10:50am
Print Post  
Hi Stoyan,

That method works spot on providing that I call my organise code straight afterwards! The links are exactly how I want them Smiley. I still have a very slight issue, seen in the picture attached, where if I just create a new link and call the method you put before, the link is "broken"... The head of the link is in the correct place but the link itself seems to still aim for the centre of the destination node and appears as a cascading link. At this point, if I press to organise the diagram it draws it correctly. Is there any setting that could cause this? Perhaps one that specifically runs in the LinkCreated event and not a coded method?

The TreeLayout.UpdateLink() method worked a treat too! Cool

Rich
  

Broken_Link.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout Vertical links ?
Reply #3 - Jul 28th, 2014 at 11:01am
Print Post  
Hi Rich,

You should also call the link.UpdateFromPoints() method in the end. That method recalculates the arrowhead positions from current control point coordinates.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout Vertical links ?
Reply #4 - Jul 28th, 2014 at 11:03am
Print Post  
also if AutoRoute is enabled, try setting it to false before assigning link.SegmentCount = 1;
  
Back to top
 
IP Logged
 
Rich Cassell
Junior Member
**
Offline


I Love MindFusion!

Posts: 63
Joined: Sep 19th, 2012
Re: TreeLayout Vertical links ?
Reply #5 - Jul 28th, 2014 at 11:16am
Print Post  
Fantastic. Thanks Stoyan. Spot on as ever Smiley

Rich
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint