The MindFusion Forums
Flow Diagramming Components >> Windows Forms >> mark link branch
https://mindfusion.eu/Forum/YaBB.pl?num=1486979887

Message started by NiceGuy on Feb 13th, 2017 at 9:58am

Title: mark link branch
Post by NiceGuy on Feb 13th, 2017 at 9:58am
We are using your software since several years and we are really happy with it.

We would request a new feature or try to implement it ourself.

We draw a lot of links between nodes and use your flow chart similar to Matlab Simulink. When links cross each other we use the "cut links" to show that the links are not connected. But now we need the possibility to draw a round dot on branches where two links from the same source are splitting, or two links with the same destination are joining. We think, that you might have an easy possibility to do that because you already distinguish between overlapping lines an crossing lines in your "cut links" algorithm. May be it's easy for you to add this feature. I think a lot of your customers will appreciate ist. It makes data flow diagrams much more readable.

The second question is if you have an suggestion how to implement a routing were lines from the same source or with the same destination routed as long as possible above each other while all other lines are routed normally.

We also thought already about your ternary sample, but this is not the right solution for us, because we need links between nodes without any additionally help nodes.

best regards

Title: Re: mark link branch
Post by Slavcho on Feb 13th, 2017 at 10:50am
You can show branching dot with some custom-drawing like this -

Code (]
void diagram_DrawLink(object sender, DrawLinkEventArgs e)
{
    if (e.Shadow)
        return;
    var node = e.Link.Origin;
    var links = new List<DiagramLink>();

    foreach (var link in node.OutgoingLinks)
    {
        if (link.StartPoint == e.Link.StartPoint)
            links.Add(link);
    }

    if (links.Count < 2)
        return;

    links.Sort((l1, l2) =>
    {
        var s1 = l1.StartPoint;
        var e1 = l1.ControlPoints[1):

;
        var s2 = l2.StartPoint;
        var e2 = l2.ControlPoints[1];
        var d1 = Utilities.Distance(s1, e1);
        var d2 = Utilities.Distance(s2, e2);
        return d1.CompareTo(d2);
    });

    if (e.Link != links[links.Count - 1])
    {
         var ec = e.Points[1];
        using (var elipseBrush = new System.Drawing.SolidBrush(Color.Red))
        {
            e.Graphics.FillEllipse(
                elipseBrush, ec.X - 2, ec.Y - 2, 4, 4);
        }
    }
}


You might want to keep the point coordinates in some kind of cache data structure and update the cache from modify / create events. We'll have it in mind as a built-in feature for next release.

Best regards,
Slavcho
Mindfusion

Title: Re: mark link branch
Post by Slavcho on Feb 13th, 2017 at 11:02am
* that code assumes 'cascading' links and does not check if segments lie on same line apart from comparing first points. If you need same feature for polylines at arbitrary angles, you will also have to check for collinearity.

Title: Re: mark link branch
Post by NiceGuy on Feb 13th, 2017 at 5:27pm
Thank you for your help !

We implemented an tested your code. To make it work we changed the „node.OutgoingLinks“ with "node.GetAllOutgoingLinks()“ then it worked. The code snippet created the blue dots. One of them is correct. The one in the in the yellow circle is not. We need all the red dots. We think you already have all those positions, because it is identical to all points where two lines meet or branch and you do not draw the "cut links".

We have a lot of lines - thats why performance matters. When do you expect to release a version with this feature ?

What do you recommend for the second part of our question. We need a routing algorithm, where the links from the same source or with the same destination are routed as long as possible above each other while all other lines are routed normally.

Please see the attached image ...

Best regards an thank you
Links.png ( 3 KB | 156 Downloads )

Title: Re: mark link branch
Post by Slavcho on Feb 14th, 2017 at 8:08am
Right, we hadn't considered branching could happen further along the link path and code above was handling only first segments. This should look for common points in next segments too -


Code (]
int LastCommonPoint(DiagramLink l1, DiagramLink l2)
{
     int cpi = 1;
     while (
           l1.ControlPoints[cpi):

== l2.ControlPoints[cpi] &&
           cpi < l1.ControlPoints.Count - 1 &&
           cpi < l2.ControlPoints.Count - 1)
     {
           cpi++;
     }
     return cpi - 1;
}

void diagram_DrawLink(object sender, DrawLinkEventArgs e)
{
     if (e.Shadow)
           return;
     var node = e.Link.Origin;
     var links = new List<DiagramLink>();

     foreach (var link in node.OutgoingLinks)
     {
           if (link.StartPoint == e.Link.StartPoint)
                 links.Add(link);
     }

     if (links.Count < 2)
           return;

     links.Sort((l1, l2) =>
     {
           return l1.Length.CompareTo(l2.Length);
     });

     var longest = links[links.Count - 1];
     if (e.Link != longest)
     {
           int cpi = LastCommonPoint(e.Link, longest);
           var cp1 = e.Link.ControlPoints;
           var cp2 = longest.ControlPoints;
           if (cpi < cp1.Count - 1)
           {
                 var dx1 = cp1[cpi + 1].X - cp1[cpi].X;
                 var dy1 = cp1[cpi + 1].Y - cp1[cpi].Y;
                 var dx2 = cp2[cpi + 1].X - cp2[cpi].X;
                 var dy2 = cp2[cpi + 1].Y - cp2[cpi].Y;
                 var ec = Math.Sign(dx1) == Math.Sign(dx2) && Math.Sign(dy1) == Math.Sign(dy2) ?
                       cp1[cpi + 1] : cp1[cpi];
                 using (var elipseBrush = new System.Drawing.SolidBrush(Color.Red))
                 {
                       e.Graphics.FillEllipse(
                             elipseBrush, ec.X - 2, ec.Y - 2, 4, 4);
                 }
           }
     }
}


I guess we could add some post-processing step for routing algorithm that pulls together segments of links from same origin. We'll need to think of some criteria for whether such link go in same general direction to do that.

Title: Re: mark link branch
Post by NiceGuy on Feb 14th, 2017 at 10:48am
Thank you. We will be able to implement the point algorithm in our code. Can you please answer our other two questions.

- When do you think will this feature be released in a new version ?

- What are your suggestions in relation to the routing

(copied from older post)
What do you recommend for the second part of our question. We need a routing algorithm, where the links from the same source or with the same destination are routed as long as possible above each other while all other lines are routed normally.

Thank you again for your help...

Title: Re: mark link branch
Post by Slavcho on Feb 14th, 2017 at 1:33pm
From reply above
Quote:
I guess we could add some post-processing step for routing algorithm that pulls together segments of links from same origin. We'll need to think of some criteria for whether such link go in same general direction to do that.


you could implement it as post-routing step of some kind too if you can think of good way to determine for how long links should overlap. I guess it could be based on distance of segments from each other after routing - set first elements of ControlPoints to same coordinates until the initial routes diverge too far by some threshold value.

Title: Re: mark link branch
Post by NiceGuy on Feb 15th, 2017 at 9:28am
Thank you for your reply!  Sorry also, that i missed your hint for the routing.

We think routing is not so easy especially in our case with a lot of links. Thats why we hope you could integrate this feature. We searched a lo in the forum and we think any customer, who uses your software for information or dataflow routing will greatly benefit from it.

What do you think ?

Best regards & thank you.


Title: Re: mark link branch
Post by Slavcho on Feb 15th, 2017 at 12:53pm
Yes, we'll have in mind both branching indication and merged routes for link with same StartPoint for next release.

Title: Re: mark link branch
Post by NiceGuy on Feb 16th, 2017 at 2:02am
Thats really good news - thank you very much !!!

Can you give us a hint when you expect your next release. We don't want to push you, but we need it for our internal planning.

Best regards and Thank you very much !

Title: Re: mark link branch
Post by Slavcho on Feb 16th, 2017 at 10:22am
In 2-3 months; we might have a preview / beta build earlier.

Title: Re: mark link branch
Post by NiceGuy on Feb 16th, 2017 at 10:27am
Thank you! That would be great !
We are looking forward to it.

May be we can get an early version and support you by testing it.

Best regards...

Title: Re: mark link branch
Post by Slavcho on Apr 11th, 2017 at 1:25pm
Try the LinkBranchIndicator, BranchIndicatorSize and BranchIndicatorColor properties here -
https://mindfusion.eu/_beta/fcnet_branchind.zip

These work only for Cascading link shape. Setting diagram.LinkBranchIndicator to BranchIndicator.Arrow looks like this -


Title: Re: mark link branch
Post by NiceGuy on May 12th, 2017 at 9:49am
Hi, thanks for your support.

Your current beta works pretty well, except the positioning of the dot. We expect the dot on the junction of two lines, but it appears on the edge above. Please see the image attached.

Best regards
Question.png ( 26 KB | 149 Downloads )

Title: Re: mark link branch
Post by Slavcho on May 12th, 2017 at 5:01pm
Hi,

It actually only looks for branch points where links diverge, not junction ones where they merge. We'll add separate properties for junctions in a few days.

Regards,
Slavcho

Title: Re: mark link branch
Post by Slavcho on May 18th, 2017 at 4:21pm
Try LinkMergeIndicator, MergeIndicatorColor, MergeIndicatorSize properties here -
https://mindfusion.eu/_temp/fcnet_merge.zip

Regards,
Slavcho
Untitled_002.png ( 8 KB | 157 Downloads )

Title: Re: mark link branch
Post by NiceGuy on Jun 21st, 2017 at 1:52pm
Hi, thanks for your beta. But here are unfortunately a few inconsistencies.

Best regards.
Dots.png ( 15 KB | 172 Downloads )

Title: Re: mark link branch
Post by Slavcho on Jun 22nd, 2017 at 8:32am
Does it show an adjustment handle there is you select the links?

Title: Re: mark link branch
Post by NiceGuy on Jun 23rd, 2017 at 5:50am
Hello, the black dots are the ones we would expect.
Dots_001.png ( 10 KB | 128 Downloads )

Title: Re: mark link branch
Post by Slavcho on Jun 28th, 2017 at 11:48am
This build should fix it -
https://mindfusion.eu/_temp/fcnet_merge.zip

Regards,
Slavcho

Title: Re: mark link branch
Post by NiceGuy on Jul 6th, 2017 at 12:32pm
Hi, yes the points are right, very good work. However, I can not affect the size of the points correctly. Can it be that the size internally is still influenced?

Title: Re: mark link branch
Post by Slavcho on Jul 6th, 2017 at 1:45pm
There's a separate MergeIndicatorSize property for merger points, have you set it?

Regards,
Slavcho

Title: Re: mark link branch
Post by NiceGuy on Jul 6th, 2017 at 2:08pm
Yes I have made, but starting from a certain size, this is no longer used, I need the points smaller. If I enter 10 or 0.5 the point always has the same size.

Title: Re: mark link branch
Post by Slavcho on Jul 6th, 2017 at 2:13pm
So it was using merge size for branch points and the other way around. This should fix it -
https://mindfusion.eu/_temp/fcnet_merge.zip

[code]
diagram.MergeIndicatorSize = 20;
diagram.MergeIndicatorColor = Color.Red;

diagram.BranchIndicatorSize = 15;
diagram.BranchIndicatorColor = Color.Green;[/code]


Regards,
Slavcho

Title: Re: mark link branch
Post by NiceGuy on Jul 6th, 2017 at 3:18pm
Wonderful, it works. Many Thanks  :)

Title: Re: mark link branch
Post by NiceGuy on Aug 22nd, 2017 at 6:00pm
Hello, I have another question.
Can you provide me a way to attach to the drawing routine? It would be best to get coordinates for each circle (branch and merge indicator).

I need a way to make the circle look different, unfortunately it is not enough to influence only the size and color.

Best regards

Title: Re: mark link branch
Post by Slavcho on Aug 24th, 2017 at 8:36am
Hi,

This adds Custom element to BranchIndicator enumeration -
https://mindfusion.eu/_beta/fcnet65.zip

Assign it to LinkMergeIndicator and / or LinkBranchIndicator and the diagram will raise DrawBranchIndicator event -
[code]
void OnDrawBranchIndicator(object sender, DrawBranchIndicatorEventArgs e)
{
     e.Graphics.DrawRectangle(
           e.Merge ? Pens.Red : Pens.Green,
           e.Position.X - 1, e.Position.Y - 1, 2, 2);
}[/code]

Regards,
Slavcho

Title: Re: mark link branch
Post by NiceGuy on Aug 26th, 2017 at 4:05pm
Thank you very much for the fantastic work, you saved my day.  :)

Best regards

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.