Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Re-Calculating a link's ControlPoints (Read 3333 times)
MarkAGr
YaBB Newbies
*
Offline


New to it all, really
frustrating at the moment.

Posts: 29
Location: Europe
Joined: Nov 18th, 2017
Re-Calculating a link's ControlPoints
Jul 30th, 2018 at 10:19pm
Print Post  
I'm trying to draw a link ( programatically ).

The Link is a Bezier, with an array of 4 ControlPoint s.

[0] and [3] are at the edge of the Org and Dest nodes.
I therefore only really need to keep [1] and [2],
however when I re-draw them, [0] and [3] are not where I expect them,
they're located as if they're drawn on the edge of a node, on a straight line from the centre of the two nodes.

I really need them to be on the edge of the nodes like they were drawn with the Dynamic bool set to true.

How can I re-calculate points [0] and [3] as if they're drawn on the edge of the node as if they're drawn from the centre of the node org node to [1] and the centre of the dest node and [2]?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Re-Calculating a link's ControlPoints
Reply #1 - Jul 31st, 2018 at 1:24pm
Print Post  
Try placing points 0 & 3 at respective nodes' centers, then call link.UpdateIntersections() method - it should move them back to intersection point of node edge with current line segment, i.e. towards next-to-last points.

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


New to it all, really
frustrating at the moment.

Posts: 29
Location: Europe
Joined: Nov 18th, 2017
Re: Re-Calculating a link's ControlPoints
Reply #2 - Jul 31st, 2018 at 7:18pm
Print Post  
Cheers!
Another question perfectly dispatched!

8^)
Mark
  
Back to top
 
IP Logged
 
MarkAGr
YaBB Newbies
*
Offline


New to it all, really
frustrating at the moment.

Posts: 29
Location: Europe
Joined: Nov 18th, 2017
Re: Re-Calculating a link's ControlPoints
Reply #3 - Aug 1st, 2018 at 1:57pm
Print Post  
Oooh, but not for self references .... it falls down a bit then.
How do I do the sane for a node that links to itself?

8^)
Mark
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Re-Calculating a link's ControlPoints
Reply #4 - Aug 2nd, 2018 at 7:39am
Print Post  
Right, UpdateIntersections seems to ignore self-loops. Try this code for them -

Code
Select All
var l = diagram.Factory.CreateDiagramLink(n, n);
l.StartPoint = l.OriginConnection.GetIntersection(
	n.GetCenter(), l.ControlPoints[1]);
l.EndPoint = l.DestinationConnection.GetIntersection(
	n.GetCenter(), l.ControlPoints[l.ControlPoints.Count - 2]);
l.UpdateFromPoints(); 



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


New to it all, really
frustrating at the moment.

Posts: 29
Location: Europe
Joined: Nov 18th, 2017
Re: Re-Calculating a link's ControlPoints
Reply #5 - Aug 2nd, 2018 at 12:37pm
Print Post  
That works well at rest, however while things are being dragged it doesn't seem to change "dynamically" ... with 'Dynamic' set to true.

But this last point is just cosmetic ... it really doesn't matter.

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


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Re-Calculating a link's ControlPoints
Reply #6 - Aug 3rd, 2018 at 7:44am
Print Post  
You mean you want to override the path assigned by links' Dynamic property? Maybe try setting ControlPoints #1&2 of respective links from NodeModifying event handler, then if Dynamic is enabled it should align the end points to node edge on next redraw.

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


New to it all, really
frustrating at the moment.

Posts: 29
Location: Europe
Joined: Nov 18th, 2017
Re: Re-Calculating a link's ControlPoints
Reply #7 - Aug 3rd, 2018 at 5:01pm
Print Post  
OK ... Thanks Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint