From acc439575bda9b1d08051d9c5f2cbe23f7e32155 Mon Sep 17 00:00:00 2001 From: mkonicek Date: Sun, 13 Mar 2011 18:59:21 +0100 Subject: [PATCH] Object graph - added simple zoom slider. --- .../Debugger.AddIn/Debugger.AddIn.csproj | 2 +- .../PositionedGraphNodeControl.xaml.cs | 55 ------------------- .../SplineRouting/RouteGraph/RouteGraph.cs | 9 +-- ...inder.cs => DijkstraShortestPathFinder.cs} | 4 +- .../Graph/Layout/Tree/TreeLayout.cs | 9 ++- .../Visualizers/Graph/ObjectGraphControl.xaml | 18 +++--- 6 files changed, 23 insertions(+), 74 deletions(-) rename src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/{AStarShortestPathFinder.cs => DijkstraShortestPathFinder.cs} (94%) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj index 201da87e4d..01254d91f4 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj +++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj @@ -245,7 +245,7 @@ - + diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs index f9e9596b47..be24d03ffb 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Drawing/PositionedGraphNodeControl.xaml.cs @@ -60,43 +60,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing this.items = GetInitialItems(this.root); // data virtualization, ContentPropertyNode implements IEvaluate this.listView.ItemsSource = new VirtualizingObservableCollection(this.items); - - //AutoSizeColumns(); - - /*DispatcherTimer t = new DispatcherTimer(); - t.Interval = TimeSpan.FromMilliseconds(1000); - t.Start(); - t.Tick += (s, ee) => { AutoSizeColumns(); t.Stop(); };*/ - } - } - - public void AutoSizeColumns() - { - //listView.UpdateLayout(); - //listView.Measure(new Size(800, 800)); - //double sum = 0; - GridView gv = listView.View as GridView; - if (gv != null) - { - foreach (var c in gv.Columns) - { - //var header = c.Header as GridViewColumnHeader; - // Code below was found in GridViewColumnHeader.OnGripperDoubleClicked() event handler (using Reflector) - // i.e. it is the same code that is executed when the gripper is double clicked - //var uw = c.GetType().GetMethod("UpdateActualWidth", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic); - //uw.Invoke(c, new object[] { }); - //if (double.IsNaN(c.Width)) - { - c.Width = c.ActualWidth; - } - c.Width = double.NaN; - - /*var dw = c.GetType().GetProperty("DesiredWidth", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic); - double desired = (double)dw.GetValue(c, null); - c.Width = c.ActualWidth; // ActualWidth is not correct until GridViewRowPresenter gets measured - c.Width = double.NaN; - sum += c.Width;*/ - } } } @@ -154,7 +117,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing } PositionedNodeProperty property = clickedNode.Property; - //property.IsPropertyExpanded = !property.IsPropertyExpanded; // done by databinding clickedButton.Content = property.IsPropertyExpanded ? "-" : "+"; if (property.IsPropertyExpanded) @@ -172,7 +134,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing var clickedButton = (ToggleButton)e.Source; var clickedNode = (ContentNode)(clickedButton).DataContext; int clickedIndex = this.items.IndexOf(clickedNode); - //clickedNode.IsExpanded = !clickedNode.IsExpanded; // done by data binding clickedButton.Content = clickedNode.IsExpanded ? "-" : "+"; // could be done by a converter if (clickedNode.IsExpanded) @@ -184,7 +145,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing this.items.Insert(clickedIndex + i, childNode); i++; } - // insertChildren(clickedNode, this.view, clickedIndex); // TODO OnContentNodeExpanded(clickedNode); } else @@ -199,21 +159,6 @@ namespace Debugger.AddIn.Visualizers.Graph.Drawing } CalculateWidthHeight(); - - //AutoSizeColumns(); - - // set to Auto again to resize columns - /*var colName = (this.listView.View as GridView).Columns[0]; - var colValue = (this.listView.View as GridView).Columns[1]; - colName.Width = 300; - colName.Width = double.NaN; - colValue.Width = 300; - colValue.Width = double.NaN; - //this.view.Insert(0, new ContentNode()); - //this.view.RemoveAt(0); - this.listView.UpdateLayout(); - this.listView.Width = colName.ActualWidth + colValue.ActualWidth + 30; - this.listView.Width = double.NaN;*/ } ObservableCollection GetInitialItems(ContentNode root) 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 7b2cbf0d18..911fdeea21 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 @@ -15,7 +15,7 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting { static readonly double boxPadding = 15; //static readonly double boxSafetyMargin = 5; // inflate boxes for collision testing - static readonly double multiEdgeGap = 10; + static readonly double multiEdgeGap = 15; List boxes = new List(); public List Boxes { @@ -27,11 +27,11 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting get { return vertices; } } - AStarShortestPathFinder pathFinder; + DijkstraShortestPathFinder pathFinder; public RouteGraph() { - pathFinder = new AStarShortestPathFinder(this); + pathFinder = new DijkstraShortestPathFinder(this); } public static RouteGraph InitializeVertices(IEnumerable nodes, IEnumerable edges) @@ -104,7 +104,8 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting { if (edgeStart == null || edgeEnd == null) { // should not happen - return; + throw new System.Exception("edgeStart is null"); + //return; } var startPoint = new RouteVertex(edgeStart.Value.X, edgeStart.Value.Y); startPoint.IsEdgeEndpoint = true; diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/AStarShortestPathFinder.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/DijkstraShortestPathFinder.cs similarity index 94% rename from src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/AStarShortestPathFinder.cs rename to src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/DijkstraShortestPathFinder.cs index 75997ae054..a793b57d27 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/AStarShortestPathFinder.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/SplineRouting/ShortestPath/DijkstraShortestPathFinder.cs @@ -10,11 +10,11 @@ namespace Debugger.AddIn.Visualizers.Graph.SplineRouting /// /// Description of AStarShortestPathFinder. /// - public class AStarShortestPathFinder + public class DijkstraShortestPathFinder { RouteGraph graph; - public AStarShortestPathFinder(RouteGraph routeGraph) + public DijkstraShortestPathFinder(RouteGraph routeGraph) { this.graph = routeGraph; } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/TreeLayout.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/TreeLayout.cs index 2ee5a62928..baa503c06f 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/TreeLayout.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/TreeLayout.cs @@ -14,8 +14,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout /// public class TreeLayout { - private static readonly double NodeMarginH = 30; - private static readonly double NodeMarginV = 30; + static readonly double NodeMarginH = 30; + static readonly double NodeMarginV = 30; + static readonly double MarginTop = 0; + static readonly double MarginBottom = 0; + GraphEdgeRouter edgeRouter = new GraphEdgeRouter(); /// @@ -81,7 +84,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout // first layout pass CalculateSubtreeSizes(positionedGraph.Root, seenNodes, treeEdges); // second layout pass - CalculateNodePosRecursive(positionedGraph.Root, treeEdges, 0, 0); + CalculateNodePosRecursive(positionedGraph.Root, treeEdges, MarginTop, MarginBottom); } // determines which edges are tree edges, and calculates subtree size for each node diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml index c1f0ab9326..5143bbf507 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml @@ -27,25 +27,25 @@ Layout: - + + Zoom: + - + Error: - - - - - - - + + + + \ No newline at end of file