From a2250c771d9e6d5efb9080dc221349bdc421cf48 Mon Sep 17 00:00:00 2001 From: mkonicek Date: Wed, 16 Mar 2011 21:18:10 +0100 Subject: [PATCH] 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. --- .../Graph/Layout/SplineRouting/EdgeRouter.cs | 8 ++++++-- .../Layout/SplineRouting/RouteGraph/RouteGraph.cs | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/EdgeRouter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/EdgeRouter.cs index 9cec3b0919..4215983829 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/EdgeRouter.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/EdgeRouter.cs @@ -16,9 +16,13 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting { } - public Dictionary RouteEdges(IEnumerable nodes, IEnumerable edges) where TEdge : class, IEdge + /// + /// Calculates routes for edges in a graph, so that they avoid nodes. + /// + public Dictionary RouteEdges(IEnumerable nodes, IEnumerable edges) + where TEdge : class, IEdge { - var routeGraph = RouteGraph.InitializeVertices(nodes, edges); + var routeGraph = RouteGraph.InitializeVertices(nodes, edges, 0, 0); var routedEdges = new Dictionary(); var occludedEdges = new List(); foreach (var edge in edges) { diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs index 0166ecf0ed..007faed4fa 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/RouteGraph/RouteGraph.cs @@ -34,14 +34,21 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting pathFinder = new DijkstraShortestPathFinder(this); } - public static RouteGraph InitializeVertices(IEnumerable nodes, IEnumerable edges) + /// + /// Initializes the RouteGraph by vertices close to node corners. + /// + /// X coordinates of vertices cannot be lower than this value (so that edges stay in boundaries). + /// Y coordinates of vertices cannot be lower than this value (so that edges stay in boundaries). + public static RouteGraph InitializeVertices(IEnumerable nodes, IEnumerable edges, int boundX, int boundY) { var graph = new RouteGraph(); // add vertices for node corners foreach (var node in nodes) { graph.Boxes.Add(node); foreach (var vertex in GetRectCorners(node, boxPadding)) { - graph.Vertices.Add(vertex); + if (vertex.X >= boundX && vertex.Y >= boundY) { + graph.Vertices.Add(vertex); + } } } // add vertices for egde endpoints