Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic setDestination function do not attach to anchor point (Read 2226 times)
Gravity
Junior Member
**
Offline


I Love MindFusion!

Posts: 52
Joined: Sep 21st, 2016
setDestination function do not attach to anchor point
Sep 8th, 2017 at 6:59am
Print Post  
My question would be why setDestination function does not attach to anchor point?


Code (Javascript)
Select All
   var gatewayAnchorPoints = [new AnchorPoint(50, 0),
        new AnchorPoint(100, 50),
        new AnchorPoint(50, 100),
        new AnchorPoint(0, 50)];

    gateway.setAnchorPattern(gatewayAnchorPoints);

diagram.addItem(gateway);

destinationNode.incomingLinks[1].setDestination(gateway, gateway.getAnchorFromIndex(1));


diagram.routeAllLinks();

 



This kindof place link at correct anchor point, but does not attach to it. Maybe you would know why?

In documentaiton i can find "ReassignAnchorPoints" method, but can't find it in source...is this something that ought to be?

If links are reacreated it works just fine. Is there a method, to reatach link to node anchor point?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: setDestination function do not attach to anchor point
Reply #1 - Sep 8th, 2017 at 8:08am
Print Post  
That second argument seems to be for internal use (you have the code I guess). If you are using it, you'll need to also call link.destinationConnection.addLinkToNode();

Otherwise if you need to set explicit anchor point, try this -

link.setDestination(gateway);
link.setDestinationAnchor(1);

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Gravity
Junior Member
**
Offline


I Love MindFusion!

Posts: 52
Joined: Sep 21st, 2016
Re: setDestination function do not attach to anchor point
Reply #2 - Sep 8th, 2017 at 9:08am
Print Post  
Slavcho wrote on Sep 8th, 2017 at 8:08am:
That second argument seems to be for internal use (you have the code I guess). If you are using it, you'll need to also call link.destinationConnection.addLinkToNode();

Otherwise if you need to set explicit anchor point, try this -

link.setDestination(gateway);
link.setDestinationAnchor(1);

Regards,
Slavcho


Yeah you are right, but it seems here is some math problem....i got the desired behaviour modifying source...but can't find yet why it does attach near anchor point, but not on anchoir.


fix was, adding that method you mentioned, calling Shapes updateFromEndPoint, and invalidate();

but if they are attached to the same anchor point, they appear attached near that point (~5px apart)

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: setDestination function do not attach to anchor point
Reply #3 - Sep 8th, 2017 at 10:14am
Print Post  
routeAllLinks pulls apart link segments when they would overlap, maybe that's what adds the distance between end points. Try setting MindFusion.Diagramming.Router.prototype.pullLinksApart = function (links) {} to see if it helps.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Gravity
Junior Member
**
Offline


I Love MindFusion!

Posts: 52
Joined: Sep 21st, 2016
Re: setDestination function do not attach to anchor point
Reply #4 - Sep 8th, 2017 at 11:08am
Print Post  
Oh cool, thanks Slavcho! It works now like japanese train!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint