microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.34k stars 301 forks source link

MSAGL - how to set orthogonal edges with simple corners #365

Closed lukasLata closed 3 months ago

lukasLata commented 4 months ago

Hi, I'm trying to set it up Microsoft auto graph layout to calculate edge segments with simple 90°degree corner. But layout is still calculated with a lot of curve segments. This is my configuration:

GeometryGraph graph = new GeometryGraph();
graph.Nodes!.Add(new Node(CurveFactory.CreateRectangle(80, 60, new Point(100, 100)), null));
graph.Nodes!.Add(new Node(CurveFactory.CreateRectangle(80, 60, new Point(94, 80)), null));
graph.Edges!.Add(new Edge(graph.Nodes[0], graph.Nodes[1]) {
    Weight = 1,
    UserData = null
});
        LayoutHelpers.CalculateLayout(graph,
            new FastIncrementalLayoutSettings {
                EdgeRoutingSettings = {
                    EdgeRoutingMode = EdgeRoutingMode.Rectilinear,
                    CornerRadius = 90
                },
                NodeSeparation = 50, // Minimum space between nodes
                AvoidOverlaps = true,

            }, null);
graph.UpdateBoundingBox();
graph.Translate(new Point(-graph.Left, -graph.Bottom));

But result look likes this: image

I need Orthogonal Edge with 90°degree corner. Any ideas how to update my settings please?

levnach commented 4 months ago

One thing to try is to set CornerRadius to 0, or to a smaller than 90 number.

lukasLata commented 4 months ago

One thing to try is to set CornerRadius to 0, or to a smaller than 90 number.

A try to change CornerRadius to '0' or '50', but still I have not 90°degrees corner...Corner is still the same...

levnach commented 4 months ago

I am not seeing the call that calculates layout in your example. Can you provide a full example?

lukasLata commented 4 months ago

LayoutHelpers.CalculateLayout

Hi, I call calculate layout here: 'LayoutHelpers.CalculateLayout'.

levnach commented 4 months ago

I think I fixed it with the last commit.

lukasLata commented 4 months ago

I think I fixed it with the last commit.

Hi, i tried your new code and when I set 'CornerRadius = 0' the result is now fine :) image