panthernet/GraphX

Edge with equal SourceConnectionPoint and TargetConnectionPoint

galakt opened this issue · 6 comments

WPF:
GraphX.Controls.EdgeControlBase.PrepareEdgePath method

We can place items when SourceConnectionPoint of edge equals TargetConnectionPoint of edge.
https://github.com/panthernet/GraphX/blob/PCL/GraphX.Controls/Controls/EdgeControlBase.cs#L778
That cause a little bit odd behavior of edge.

I think i can add check equal condition and change point little.

1
2

Hello, thanks for report. This scenarion wasn't the expected one :) I don't see much sense in assigning the same connetion point to surce and target. I'm in for not allowing to do so, will it be correct for your case?

My main goal is prevent showing alone arrow (in [0;0] point) when source and target points are equal (that can happen accidentally after manual graph generation and sometimes after dragging).
It is not cool, but now for a while i just added:

        if (p1 == p2)
        {
            p1.X = double.PositiveInfinity;
            p1.Y = double.PositiveInfinity;
            p2.X = double.PositiveInfinity;
            p2.Y = double.PositiveInfinity;
        }
        SourceConnectionPoint = p1;
        TargetConnectionPoint = p2;

I've checked how it works and it looks like self looped edge. If you have an edge where source and target vertices are the same then the self looped edge indicator will be drawn in the top left corner of the vertex. On the other side the code execution should not pass to the place you'd made the fix in if it is the self looped edge we talk about. Unless you'd changed something in original logic. Originally edge can't have equal source and target connection points.

I have made sample to show what i mean:
https://github.com/galakt/GraphXSample2

Thanks for the sample, unfortunately i'm quite busy right now. Can't promise much but will try to spare some time on the issue.

Fixed! That was an intersting case where vertices were so close together that edge were almost zero length making rotation calc return NaN value messing up the final pointer position. Also i've implemented the EdgeControlBase::HideEdgePointerOnVertexOverlap property which allows you to hide edge pointer in such cases (default) or display them at the edge pos if set to false.