Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Link between overlapping nodes (Read 1965 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Link between overlapping nodes
Oct 20th, 2009 at 10:32am
Print Post  
Hi Stoyan,

I have two nodes in the diagram with link between them.

When two nodes are not overlapping,link between two nodes is straight arrow with ends just touching both nodes.

But when nodes are overlapping,link overlaps over the two nodes.

But I want that link should not overlap any node. It can be represented in the form of curved arrow  or by dot ,in case nodes are overlapping.

I am sending image for the same,have a look into that.

Regards,
Anshul.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link between overlapping nodes
Reply #1 - Oct 20th, 2009 at 3:56pm
Print Post  
You could do something like:

Code
Select All
DiagramNode node1 = link.Origin;
DiagramNode node2 = link.Destination;
if (node1.Bounds.IntersectsWith(node2.Bounds))
{
	link.ControlPoints[0] = GetTopCenter(node1);
	link.ControlPoints[link.ControlPoints - 1] = GetTopCenter(node2);
	link.Style = LinkStyle.Bezier;
	link.Route();
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Link between overlapping nodes
Reply #2 - Oct 23rd, 2009 at 9:05am
Print Post  
Hi Stoyan,

Its not working as expected.

And also in addition to this,

When 2 nodes are connected and if there is a third node inbetween them - the link should not go through that node.

Please suggest for this.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link between overlapping nodes
Reply #3 - Oct 27th, 2009 at 2:01pm
Print Post  
Hi,

Ok, first change the style and then call Route(), otherwise the Style setter moves the points back to the node centers when the nodes intersect.

Code
Select All
Point GetTopCenter(DiagramNode node)
{
	Rect r = node.Bounds;
	return new Point(r.X + r.Width / 2, r.Y);
}

private void OnLinkCreated(object sender, LinkEventArgs e)
{
	var link = e.Link;
	DiagramNode node1 = link.Origin;
	DiagramNode node2 = link.Destination;
	if (node1.Bounds.IntersectsWith(node2.Bounds))
	{
		link.Style = LinkStyle.Bezier;
		link.ControlPoints[0] = GetTopCenter(node1);
		link.ControlPoints[link.ControlPoints.Count - 1] = GetTopCenter(node2);
		link.Route();
	}
} 



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