Browse Source

When edges avoid nodes, they never go into negative coordinates (out of Canvas). They can still go out of the Canvas on the right or bottom side, but that is necessary in case they have no other way.

pull/15/head
mkonicek 15 years ago
parent
commit
a2250c771d
  1. 8
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/EdgeRouter.cs
  2. 9
      src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs

8
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/EdgeRouter.cs

@ -16,9 +16,13 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting
{ {
} }
public Dictionary<TEdge, RoutedEdge> RouteEdges<TEdge>(IEnumerable<IRect> nodes, IEnumerable<TEdge> edges) where TEdge : class, IEdge /// <summary>
/// Calculates routes for edges in a graph, so that they avoid nodes.
/// </summary>
public Dictionary<TEdge, RoutedEdge> RouteEdges<TEdge>(IEnumerable<IRect> nodes, IEnumerable<TEdge> edges)
where TEdge : class, IEdge
{ {
var routeGraph = RouteGraph.InitializeVertices(nodes, edges); var routeGraph = RouteGraph.InitializeVertices(nodes, edges, 0, 0);
var routedEdges = new Dictionary<TEdge, RoutedEdge>(); var routedEdges = new Dictionary<TEdge, RoutedEdge>();
var occludedEdges = new List<TEdge>(); var occludedEdges = new List<TEdge>();
foreach (var edge in edges) { foreach (var edge in edges) {

9
src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs

@ -34,16 +34,23 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting
pathFinder = new DijkstraShortestPathFinder(this); pathFinder = new DijkstraShortestPathFinder(this);
} }
public static RouteGraph InitializeVertices(IEnumerable<IRect> nodes, IEnumerable<IEdge> edges) /// <summary>
/// Initializes the RouteGraph by vertices close to node corners.
/// </summary>
/// <param name="boundX">X coordinates of vertices cannot be lower than this value (so that edges stay in boundaries).</param>
/// <param name="boundY">Y coordinates of vertices cannot be lower than this value (so that edges stay in boundaries).</param>
public static RouteGraph InitializeVertices(IEnumerable<IRect> nodes, IEnumerable<IEdge> edges, int boundX, int boundY)
{ {
var graph = new RouteGraph(); var graph = new RouteGraph();
// add vertices for node corners // add vertices for node corners
foreach (var node in nodes) { foreach (var node in nodes) {
graph.Boxes.Add(node); graph.Boxes.Add(node);
foreach (var vertex in GetRectCorners(node, boxPadding)) { foreach (var vertex in GetRectCorners(node, boxPadding)) {
if (vertex.X >= boundX && vertex.Y >= boundY) {
graph.Vertices.Add(vertex); graph.Vertices.Add(vertex);
} }
} }
}
// add vertices for egde endpoints // add vertices for egde endpoints
foreach (var multiEdgeGroup in edges.GroupBy(edge => GetStartEnd(edge))) { foreach (var multiEdgeGroup in edges.GroupBy(edge => GetStartEnd(edge))) {
int multiEdgeCount = multiEdgeGroup.Count(); int multiEdgeCount = multiEdgeGroup.Count();

Loading…
Cancel
Save