Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Is there any reason why link.OriginAnchor would not work? (Read 14513 times)
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Is there any reason why link.OriginAnchor would not work?
Jun 27th, 2013 at 9:28pm
Print Post  
Hi,

When I create links for my diagram I set both link.OriginAnchor and link.DestinationAnchor. These "seem" to work for the most part, but not always. Is there some action that I could be taking subsequent to making these settings that would cause them to be ignored?

If you look at the attached screenshot, you'll see that the the link coming out of the bottom of Task 1 is correct.
The link coming out of the right of Task 5 should also be coming out of the bottom of that task.

Any thoughts?

Thanks in advance.

Jim
  

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is there any reason why link.OriginAnchor would not work?
Reply #1 - Jun 28th, 2013 at 7:55am
Print Post  
If you need to keep anchor points to their initial values and running some layout algorithms, set layout.Anchoring = Keep. If using link auto-routing, also set RoutingOptions.Anchoring = Keep.

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: Is there any reason why link.OriginAnchor would not work?
Reply #2 - Sep 16th, 2013 at 5:00pm
Print Post  
Hi,

First off, we've renewed our license.

I'm still having issues with the anchors I'm setting not being used.
I have set swimLayout.Anchoring = Anchoring.Keep; as well as
diagram.RoutingOptions.Anchoring = Anchoring.Keep;

I'm setting the preferred anchor points for the source and target nodes as follows.
The returned value from this function is assigned to:
link.OriginAnchor or link.DestinationAnchor.

Code
Select All
    protected int getTaskAnchor(ShapeNode node, string side)
    {
        if (side == "left")
        {
            if (!node.AnchorPattern.Points[2].AllowIncoming)
            {
                node.AnchorPattern.Points[2].AllowIncoming = true;
                return 2;
            }
            if (!node.AnchorPattern.Points[1].AllowIncoming)
            {
                node.AnchorPattern.Points[1].AllowIncoming = true;
                return 1;
            }
            if (!node.AnchorPattern.Points[3].AllowIncoming)
            {
                node.AnchorPattern.Points[3].AllowIncoming = true;
                return 3;
            }
            if (!node.AnchorPattern.Points[0].AllowIncoming)
            {
                node.AnchorPattern.Points[0].AllowIncoming = true;
                return 0;
            }
            if (!node.AnchorPattern.Points[4].AllowIncoming)
            {
                node.AnchorPattern.Points[4].AllowIncoming = true;
                return 4;
            }
        }
        if (side == "right")
        {
            if (!node.AnchorPattern.Points[7].AllowOutgoing)
            {
                node.AnchorPattern.Points[7].AllowOutgoing = true;
                return 7;
            }
            if (!node.AnchorPattern.Points[6].AllowOutgoing)
            {
                node.AnchorPattern.Points[6].AllowOutgoing = true;
                return 6;
            }
            if (!node.AnchorPattern.Points[8].AllowOutgoing)
            {
                node.AnchorPattern.Points[8].AllowOutgoing = true;
                return 8;
            }
            if (!node.AnchorPattern.Points[5].AllowOutgoing)
            {
                node.AnchorPattern.Points[5].AllowOutgoing = true;
                return 5;
            }
            if (!node.AnchorPattern.Points[9].AllowOutgoing)
            {
                node.AnchorPattern.Points[9].AllowOutgoing = true;
                return 9;
            }
        }
        if (side == "bottom")
        {
            if (!node.AnchorPattern.Points[12].AllowIncoming)
            {
                node.AnchorPattern.Points[12].AllowIncoming = true;
                node.AnchorPattern.Points[12].AllowOutgoing = true;
                return 12;
            }
            if (!node.AnchorPattern.Points[11].AllowIncoming)
            {
                node.AnchorPattern.Points[11].AllowIncoming = true;
                node.AnchorPattern.Points[11].AllowOutgoing = true;
                return 11;
            }
            if (!node.AnchorPattern.Points[13].AllowIncoming)
            {
                node.AnchorPattern.Points[13].AllowIncoming = true;
                node.AnchorPattern.Points[13].AllowOutgoing = true;
                return 13;
            }
            if (!node.AnchorPattern.Points[10].AllowIncoming)
            {
                node.AnchorPattern.Points[10].AllowIncoming = true;
                node.AnchorPattern.Points[10].AllowOutgoing = true;
                return 10;
            }
            if (!node.AnchorPattern.Points[14].AllowIncoming)
            {
                node.AnchorPattern.Points[14].AllowIncoming = true;
                node.AnchorPattern.Points[14].AllowOutgoing = true;
                return 14;
            }
        }
        return 0; // Shouldn't get here, but this makes the compiler happy !
    }
 



The AnchorPattern being used is as follows:
Code
Select All
AnchorPattern taskAnchors2 =
            new AnchorPattern(new AnchorPoint[]
                {
                    new AnchorPoint(0, 16, false, false, MarkStyle.Rectangle, Color.Blue),
                    new AnchorPoint(0, 33, false, false, MarkStyle.Rectangle, Color.Blue),
                    new AnchorPoint(0, 50, false, false, MarkStyle.Rectangle, Color.Blue),
                    new AnchorPoint(0, 66, false, false, MarkStyle.Rectangle, Color.Blue),
                    new AnchorPoint(0, 83, false, false, MarkStyle.Rectangle, Color.Blue),
                    new AnchorPoint(100, 16, false, false, MarkStyle.Rectangle, Color.Green),
                    new AnchorPoint(100, 33, false, false, MarkStyle.Rectangle, Color.Green),
                    new AnchorPoint(100, 50, false, false, MarkStyle.Rectangle, Color.Green),
                    new AnchorPoint(100, 66, false, false, MarkStyle.Rectangle, Color.Green),
                    new AnchorPoint(100, 83, false, false, MarkStyle.Rectangle, Color.Green),
                    new AnchorPoint(16, 100, false, false, MarkStyle.Rectangle, Color.Red),
                    new AnchorPoint(33, 100, false, false, MarkStyle.Rectangle, Color.Red),
                    new AnchorPoint(50, 100, false, false, MarkStyle.Rectangle, Color.Red),
                    new AnchorPoint(66, 100, false, false, MarkStyle.Rectangle, Color.Red),
                    new AnchorPoint(83, 100, false, false, MarkStyle.Rectangle, Color.Red)
                }); 



As you can see I have disabled all anchor points, and only enable them as I need them.

I get the same incorrect results whether I use diagram.RouteAllLinks(); or not.

Here's my diagram settings:
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 = true;
        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); 



Any suggestions on what to try next?
Thanks again for all your help.

Jim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is there any reason why link.OriginAnchor would not work?
Reply #3 - Sep 16th, 2013 at 6:39pm
Print Post  
Try disabling the DynamicLinks option, it changes anchor points of links too when their adjacent node moves. If you need such links for user interaction after the layout is applied, you could loop over the diagram's links and enable Dynamic for each one after all layout code completes.

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: Is there any reason why link.OriginAnchor would not work?
Reply #4 - Sep 17th, 2013 at 12:54am
Print Post  
Hi,

I have set diagram.DynamicLinks = false; but with the same results.
Any other ideas?
Is there anything else I can provide you that would help?

Jim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is there any reason why link.OriginAnchor would not work?
Reply #5 - Sep 17th, 2013 at 7:01am
Print Post  
Hi,

Have you drawn and arranged a new diagram after that, or loaded one from a file? Dynamic will be enabled again if you load from file. Also check if link.Dynamic isn't set somewhere in the code for individual links. Attach a test project showing all layout code you are using and our developer will check it.

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: Is there any reason why link.OriginAnchor would not work?
Reply #6 - Sep 17th, 2013 at 1:37pm
Print Post  
Hi,

Creating a test project is next to impossible, but I have attached the class that renders the diagram.
It's big (and probably ugly), and it's database driven.
The method that creates the links is called "createConnector" and you can see where the origin and destination anchors are being set at lines 1512 and 1513.
The anchor points that are not working are for "task shapes" and are provided by method "getTaskAnchor". The AnchorPattern for these shapes is "taskAnchors2".
I have verified that this method is in fact returning the desired values.

The swimlane layout is applied at line 297 and the mainline code ends at line 346.

I hope your developer can gleam something from this.

Thanks in advance.

Jim
  

create_CFFD.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is there any reason why link.OriginAnchor would not work?
Reply #7 - Sep 17th, 2013 at 4:42pm
Print Post  
Hi,

There's some code in the SortRoutedLinksTaskRight method that changes links' OriginAnchor. Could you check if that's what gives you the unexpected results? Otherwise please call SaveToXml just before applying SwimlaneLayout and attach the file so we can trace the code with it.

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: Is there any reason why link.OriginAnchor would not work?
Reply #8 - Sep 17th, 2013 at 9:50pm
Print Post  
Hi,

Yes, I thought about that and commented the call to that method out, but with the same incorrect results.

I have attached a copy of the XML file as requested.
Please note this is for a different diagram  than I originally reported in this post (that one has since been deleted).
So, I've attached a screenshot of part of the diagram showing the origin anchorpoint numbers that were assigned to the shape titled "5.1 CT1".

Jim
« Last Edit: Sep 17th, 2013 at 11:45pm by jlj30 »  

CFFD.zip (Attachment deleted)
Anchor_Issue_-_17Sep2013.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is there any reason why link.OriginAnchor would not work?
Reply #9 - Sep 18th, 2013 at 11:24am
Print Post  
Hi,

SwimlaneLayout disregards Anchoring and resets your anchor point positions. We'll fix this for next release in a few days. For the time being, you could move your code that assigns anchor points to the end of the layout code.

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: Is there any reason why link.OriginAnchor would not work?
Reply #10 - Sep 18th, 2013 at 12:59pm
Print Post  
Hi,

Great news.
Any idea when I could expect to see the release?
We're in a bit of a crunch right now and would like to get our app ready for system testing by Sep 27th.  Getting the code before then would be great.

Thanks

Jim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is there any reason why link.OriginAnchor would not work?
Reply #11 - Sep 18th, 2013 at 1:40pm
Print Post  
We'll have beta tests for several weeks before releasing. Since you have the code, we could send you updated layout.cs file for you to rebuild the control. Or our developer could compile it if you wish - let me know what version number you are currently using.
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Is there any reason why link.OriginAnchor would not work?
Reply #12 - Sep 18th, 2013 at 3:23pm
Print Post  
Hi,

I would prefer if your developer compiled it.
According to the properties, my MindFusion.Common.dll is at 1.3.0.20523 dated 3/13/2012 5:24 PM, and MindFusion.Diagramming.dll is at 5.8.0.17138 3/13/2012 5:24 PM.

Jim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is there any reason why link.OriginAnchor would not work?
Reply #13 - Sep 18th, 2013 at 3:41pm
Print Post  
What is the MindFusion.Diagramming.WebForms.dll version number? That should also correspond to what you see in the help file and readme as NetDiagram version.
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Is there any reason why link.OriginAnchor would not work?
Reply #14 - Sep 18th, 2013 at 3:45pm
Print Post  
Hi,

Looks like 4.2.
The WebForms.dll shows 4.2.0.30899.

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