From 0681775b630d0208f14aee4a21c4a9ce704f443a Mon Sep 17 00:00:00 2001 From: mkonicek Date: Sun, 13 Mar 2011 19:28:19 +0100 Subject: [PATCH] Object graph - fixed a small bug in multiple edge spacing. --- .../Graph/Layout/SplineRouting/Point2D.cs | 5 +++++ .../Layout/SplineRouting/RouteGraph/RouteGraph.cs | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/Point2D.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/Point2D.cs index 1d694f0c7a..2decadf61b 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/Point2D.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/Point2D.cs @@ -20,5 +20,10 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting public double X { get; set; } public double Y { get; set; } + + public override string ToString() + { + return string.Format("[Point2D X={0}, Y={1}]", X, Y); + } } } 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 911fdeea21..0166ecf0ed 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 @@ -104,8 +104,7 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting { if (edgeStart == null || edgeEnd == null) { // should not happen - throw new System.Exception("edgeStart is null"); - //return; + throw new System.Exception("The line between box centers does not intersect the boxes!"); } var startPoint = new RouteVertex(edgeStart.Value.X, edgeStart.Value.Y); startPoint.IsEdgeEndpoint = true; @@ -209,12 +208,17 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting static double GetMultiEdgeSpan(double space, int multiEdgeCount, double multiEdgeGap) { - if ((multiEdgeCount + 1) * multiEdgeGap < space) + if (multiEdgeCount <= 1) { + // 1 edge, no spacing needed + return 0; + } + if ((multiEdgeCount + 1) * multiEdgeGap < space) { // the edges fit, maintain the gap return (multiEdgeCount - 1) * multiEdgeGap; - else + } else { // there are too many edges, we have to make smaller gaps to fit edges into given space return space - multiEdgeGap; + } } } }