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


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
"Funky" link when connecting shape to itself
Dec 7th, 2013 at 6:24pm
Print Post  
Hi,

Have a look at the attached screenshot.
There are 2 shapes which have links that should (and do) come out of the right and into the left of themselves.

I was expecting the links to look much like they do for the other shapes on the diagram (straight segments with rounded corners), but instead I got these rather strange looking links.

Is there any particular setting/property I need to correct this odd appearance?

I've also included my diagram settings below.

Thanks in advance.

Jim

Code
Select All
diagram.DrawLink += OnDrawLink; // Add an event handler to draw images on links if they exist
		diagram.EnableShadowEffects = true;
		diagram.ShowGrid = false;
		diagram.GridColor = Color.LightGray;
		diagram.GridStyle = GridStyle.Lines;
		diagram.AlignToGrid = true;
		diagram.MeasureUnit = GraphicsUnit.Millimeter;
		diagram.LinkStyle = LinkStyle.Cascading;
		diagram.LinkCascadeOrientation = Orientation.Auto;
		diagram.DynamicLinks = false;  // recommendation from MF to set to false - see http://mindfusion.eu/Forum/YaBB.pl?num=1372368535
		diagram.EnableLanes = true;
		diagram.GridOffsetX = 4;
		diagram.GridOffsetY = 4;
		//diagram.Bounds = new RectangleF(0, 0, 500, 400);
		diagram.LinkCrossings = LinkCrossings.Arcs;
		diagram.EnableStyledText = true;
		diagram.PolygonalTextLayout = true;
		diagram.LinkSegments = 2;
		diagram.SnapToAnchor = SnapToAnchor.OnCreateOrModify;
		diagram.LinkEndsMovable = true;
		diagram.DefaultShape = Shapes.RoundRect;
		diagram.LinkTextStyle = LinkTextStyle.OverLongestSegment;
		diagram.RoundedLinks = true;
		diagram.ShowAnchors = ShowAnchors.Selected;
		diagram.AutoResize = AutoResize.RightAndDown;
		diagram.ContainersFoldable = true;
		diagram.LinkCascadeOrientation = Orientation.Auto;
		diagram.LinkRouter = new GridRouter();
		//diagram.LinkRouter = new QuickRouter();
		diagram.RouteLinks = true;
		diagram.RoutingOptions.Anchoring = Anchoring.Keep;
		diagram.RoutingOptions.CrossingCost = 50;
		diagram.RoutingOptions.LengthCost = 10;
		diagram.RoutingOptions.NodeVicinityCost = 5;
		diagram.RoutingOptions.TurnCost = 10;

		diagram.EnableLanes = true;
		diagram.LinkHeadShape = ArrowHeads.Triangle;
		diagram.LinkHeadShapeSize = 4;
		diagram.BackBrush = new MindFusion.Drawing.SolidBrush(Color.White); 

  

Self_Loopback_Link_Issue_-_07Dec2013.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 #1 - Dec 9th, 2013 at 7:16am
Print Post  
Hi,

Self-loop links' shape automatically changes to Bezier. You could add a handler to the Diagram.SetSelfLoopShape event, set e.Handled, and reset link.Shape to Cascading from the handler method to avoid that.

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 #2 - Dec 9th, 2013 at 5:25pm
Print Post  
Hi,

This sounds like the solution I need, but SetSelfLoopShape does appear as an event I can select for the diagram object.

See the attached screenshot.

My Webfroms.dll version is 4.2.1.15465

Jim
  

SetSelfLoopShape.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 #3 - Dec 9th, 2013 at 6:37pm
Print Post  
If by any chance you are using a custom node class, you should be able to do the same in v4.2.1 by overriding the DiagramNode.SetReflexive(DiagramLink) method. Otherwise you'll have to reset link.Shape from LinkCreated and LinkModified events when you detect that Origin == Destination.

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 #4 - Dec 9th, 2013 at 7:45pm
Print Post  
Hi,

I tried to use the LinkCreated and LinkModified events, but neither seem to fire.  I put breaks in the event handler and it never received control.

Here's the relevant pieces of my code:

Code
Select All
diagram.DrawLink += OnDrawLink; // Add an event handler to draw images on links if they exist
        diagram.LinkCreated += OnLinkCreated; // Add an event handler to change the bezier curve to cascade for self loopbacks
        diagram.LinkModified += OnLinkCreated;

...

protected void OnLinkCreated(object sender, LinkEventArgs e)
    {
        DiagramLink link = e.Link;
        if (link.Origin == link.Destination)
        {
            link.Style = LinkStyle.Cascading; // The default for self loopbacks is Bezier ("funky")
        }
    }
 



The DrawLink event fires just fine.
I noticed in my code that I had to include the following statement to get this event to fire:

link.CustomDraw = CustomDraw.Additional;

Is there something similar that I need to do to get the LinkCreated event to fire?

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 #5 - Dec 9th, 2013 at 9:28pm
Print Post  
Me again,

I have also discovered that there is an OnLinkCreated property on the DiagramView control.  I tried specifying this and copying my event handler code to the code behind for this page (and commenting it out in my diagram render class).  But it does not fire either.

Confused as usual.

Jim
  
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 #6 - Dec 10th, 2013 at 6:43am
Print Post  
Hi,

In ASP.NET version you should handle the LinkCreated and LinkModified events of DiagramView. However they are raised only for links drawn interactively by user. If you create these links programmatically, reset their Shape to Cascading immediately after calling Factory.CreateDiagramLink(same_node, same_node).

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 #7 - Dec 10th, 2013 at 12:57pm
Print Post  
Hi,

I tried to do as you suggested, but I'm still getting bezier curves.
I assume that you meant Style, not Shape.  Here's my code:

DiagramLink link = factory.CreateDiagramLink(sourceNode, targetNode);
link.Style = LinkStyle.Cascading;

Any other suggestions?

Thanks

Jim
  
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 #8 - Dec 10th, 2013 at 1:10pm
Print Post  
Hi,

It's called Shape in newer versions, where the DiagramItem.Style property is used for appearance styling. Try setting link.SegmentCount = 3 before changing Shape to Cascading.

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 #9 - Dec 10th, 2013 at 2:24pm
Print Post  
Hi,

Well, we're getting closer.
I set the segment count to 3 as you suggested.
See the results in the attached screenshot.
The resulting link goes straight through the shape, not around it.
The red line is what I'm trying to achieve.

What next?
Thanks for the help.

Jim
  

Self_Loopback_Link_Issue_-_10Dec2013.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 #10 - Dec 10th, 2013 at 3:07pm
Print Post  
Call link.Route(), or try the code from http://mindfusion.eu/Forum/YaBB.pl?num=1238435923/5#5
  
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 #11 - Dec 10th, 2013 at 3:29pm
Print Post  
Hi,

Well, some good progress, but not quite there yet.
Two issues.  See screenshot.

1. Only the RoundRect shape works; the Decision shape does not
2. The link that does work looks like a polyline, not cascading (although I could live with that).

Any ideas?

Thanks

Jim
  

Self_Loopback_Link_Issue2_-_10Dec2013.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 #12 - Dec 10th, 2013 at 6:50pm
Print Post  
If you are using the code from http://mindfusion.eu/Forum/YaBB.pl?num=1238435923/5#5, move SegmentCount assignment in front of Style.Cascading assignment. Otherwise the link might remain a Bezier, which expects a different number of points per segment and setting the new points might fail.

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 #13 - Dec 10th, 2013 at 7:37pm
Print Post  
Hi,

Things are definitely getting better.
I am not using the code in the referenced post.
I did set the number of segments to 3 just before setting the link style to cascading.
I do use a common method to create all of my connectors.
The rounded rectangle now looks pretty good, but the link for the decision shape did not change - see attached.

Also, the link for the rounded rectangle dips into the adjacent swim lane.  Is there any way to avoid that?

This has been a great dialog.
I appreciate the help.

Jim
  

Self_Loopback_Link_Issue3_-_10Dec2013.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 #14 - Dec 12th, 2013 at 7:27am
Print Post  
Hi,

I assume you are calling Route then. The auto-routing function treats all nodes as rectangular obstacles, so decision nodes' shape should not matter. Check if you aren't processing decisions' links later in some way that would reset them to a single segment.

You cannot limit auto-routes to a single lane at this time, so try setting the link points yourself. The sample code from the post above connected top to bottom center points. To connect right to left centers, change it to this:

Code
Select All
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)); 



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