Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InteractiveEdgeRouter does not appear to be respecting BoundaryCurves of square nodes #260

Open
SMTStuck opened this issue Sep 18, 2020 · 1 comment

Comments

@SMTStuck
Copy link

SMTStuck commented Sep 18, 2020

This code is adapted from the EdgeRoutingSample DemoRoutingFromPortToPort and DrawEdgeWithPort methods. However, I notice that the nodes within that particular example are ellipses which appear to make the difference.

The nodes are simple squares, but it seems that the inner InteractiveEdgeRouter is not respecting the boundary curves of the square nodes. The boundary curves passed into the InteractiveEdgeRouter are however correct:

private void DoLayout(GeometryGraph geometryGraph)
{
	IEnumerable<GeometryGraph> subGraphs = GraphConnectedComponents.CreateComponents(geometryGraph.Nodes, geometryGraph.Edges);

	SugiyamaLayoutSettings layoutSettings = new SugiyamaLayoutSettings();
	layoutSettings.EdgeRoutingSettings.EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.Rectilinear;
	layoutSettings.NodeSeparation = 120;
	layoutSettings.LayerSeparation = 120;
	layoutSettings.Transformation = PlaneTransformation.Rotation(Math.PI);

	foreach (GeometryGraph subgraph in subGraphs)
	{
		LayeredLayout layout = new LayeredLayout(subgraph, layoutSettings);
		subgraph.Margins = layoutSettings.NodeSeparation + 200;
		layout.Run();
	}

	InteractiveEdgeRouter portRouter = new InteractiveEdgeRouter(geometryGraph.Nodes.Select(n => n.BoundaryCurve), 0, 0, 0);
	portRouter.Run();
	foreach (Edge tEdge in geometryGraph.Edges)
	{
		FloatingPort port1 = new FloatingPort(null, new Microsoft.Msagl.Core.Geometry.Point(tEdge.Source.BoundingBox.Center.X, tEdge.Source.BoundingBox.Bottom - 10));
		FloatingPort port2 = new FloatingPort(null, new Microsoft.Msagl.Core.Geometry.Point(tEdge.Target.BoundingBox.Center.X, tEdge.Target.BoundingBox.Top + 10));
		ICurve spline = portRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(port1, port2, false, out _);

		Arrowheads.TrimSplineAndCalculateArrowheads(tEdge.EdgeGeometry,
			tEdge.Source.BoundaryCurve,
			tEdge.Target.BoundaryCurve,
			spline, true, false);

		DrawSpline(tEdge, spline);
	}

}

NodeBoundaries

I am aware that the ports appear backwards - i.e. exit at the top and entry at the bottom. This is a deliberate setup to test MSAGL.

@levnach
Copy link
Contributor

levnach commented Sep 29, 2020

Can you try to move the ports closer to their node bounding boxes and see if the trimming happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants