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. 11
      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 @@ -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 occludedEdges = new List<TEdge>();
foreach (var edge in edges) {

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

@ -34,14 +34,21 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting @@ -34,14 +34,21 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting
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();
// 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

Loading…
Cancel
Save