Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) "Funky" link when connecting shape to itself (Read 15496 times)
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: "Funky" link when connecting shape to itself
Reply #15 - Dec 13th, 2013 at 4:51pm
Print Post  
Hi,

Almost there!  Thanks for the code.
The last segment (or two?) does not render - see attached screenshot.

Here's my code (well mostly yours):

Code
Select All
protected void createSelfLoopback(ShapeNode node, DiagramLink link)
    {
        RectangleF r = node.Bounds;
        float centerx = (float)(r.Left + r.Width / 2);
        float centerY = (float)(r.Top + r.Height / 2);
        float dist = 6;

        SetLinkPoints(link,
            new PointF(r.Right, centerY),
            new PointF(r.Right + dist, centerY),
            new PointF(r.Right + dist, r.Top - dist),
            new PointF(r.Left - dist, r.Top - dist),
            new PointF(r.Left - dist, centerY),
            new PointF(r.Left, centerY));
    }

    protected void SetLinkPoints(DiagramLink link, params PointF[] points)
    {
        link.AutoRoute = false;
        link.Style = LinkStyle.Cascading;
        link.SegmentCount = (short)(points.Length - 1);
        link.ControlPoints.Clear();
        link.ControlPoints.AddRange(points);
        link.UpdateFromPoints();
    } 



Any idea why the missing segment(s)?

Thanks

Jim
  

Self_Loopback_Link_Issue4_-_13Dec2013.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: "Funky" link when connecting shape to itself
Reply #16 - Dec 16th, 2013 at 7:58am
Print Post  
Hi,

I have this SetLinkPoints version in my test project and it seems to work fine, try it instead:

Code
Select All
void SetLinkPoints(DiagramLink link, params PointF[] points)
{
	link.AutoRoute = false;
	link.Shape = LinkShape.Cascading;
	link.ControlPoints.Clear();
	link.ControlPoints.AddRange(points);
	link.UpdateFromPoints(false, true);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: "Funky" link when connecting shape to itself
Reply #17 - Dec 16th, 2013 at 4:00pm
Print Post  
Hi Stoyan,

This latest code works just fine.
Many thanks.

Jim
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: "Funky" link when connecting shape to itself
Reply #18 - Jan 7th, 2014 at 4:06pm
Print Post  
Hi again,

This was working just fine, but since upgrading to 5.0.3 the self-loopback connector is broken.  See the attached screenshot. 
I've included my latest code (that worked in 4.2) below.  I'm taking the Else path which should cause the link to come out of the top and back into the top.

Any suggestions?

Thanks

Jim

The Code:
Code
Select All
protected void createSelfLoopback(ShapeNode node, DiagramLink link)
    {
        RectangleF r = node.Bounds;
        float dist = 6;

        if (node.Shape != Shapes.RoundRect)
        {
            float centerx = (float)(r.Left + r.Width / 2);
            float centerY = (float)(r.Top + r.Height / 2);

            SetLinkPoints(link,
                new PointF(r.Right, centerY),
                new PointF(r.Right + dist, centerY),
                new PointF(r.Right + dist, r.Top - dist),
                new PointF(r.Left - dist, r.Top - dist),
                new PointF(r.Left - dist, centerY),
                new PointF(r.Left, centerY));
        }
        else
        {
            SetLinkPoints(link,
                new PointF(r.Right - 2, r.Top),
                new PointF(r.Right - 2, r.Top - 6),
                new PointF(r.Left + 2, r.Top - 6),
                new PointF(r.Left + 2, r.Top));
        }
    }

    protected void SetLinkPoints(DiagramLink link, params PointF[] points)
    {
        link.AutoRoute = false;
        link.Shape = LinkShape.Cascading;
        link.ControlPoints.Clear();
        link.ControlPoints.AddRange(points);
        link.UpdateFromPoints(false, true);
    } 

  

Self_Loopback_Link_Issue_-_After_503.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: "Funky" link when connecting shape to itself
Reply #19 - Jan 7th, 2014 at 5:27pm
Print Post  
Hi,

I can reproduce that if the node has anchor points at the left/right center points. Try also detaching the link from its anchor points before aplpying SwimlaneLayout:
Code
Select All
protected void createSelfLoopback(ShapeNode node, DiagramLink link)
{
	link.OriginAnchor = link.DestinationAnchor = -1;
 



Version 4.2 might be ignoring anchor points for self loops, and it seems the new version does not.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: "Funky" link when connecting shape to itself
Reply #20 - Jan 7th, 2014 at 7:13pm
Print Post  
Stoyan,

That did it!
Thanks

Jim
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint