- Timestamp:
- 03/26/14 01:52:16 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/FragmentGraphView.cs
r10655 r10656 23 23 base.Content = value; 24 24 MakeTiles(); 25 Draw(); 25 26 } 26 27 } … … 31 32 layoutEngine = new ReingoldTilfordLayoutEngine<TileLayoutNode>(n => n.Children); 32 33 symbolicExpressionEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees); 34 tileDictionary = new Dictionary<IGenealogyGraphNode<IFragment<ISymbolicExpressionTreeNode>>, TileLayoutNode>(); 33 35 } 34 36 35 37 private void MakeTiles() { 36 38 var chart = symbolicExpressionChartControl.Chart; 39 tileDictionary.Clear(); 37 40 foreach (var node in Content.Nodes.Cast<IGenealogyGraphNode<IFragment<ISymbolicExpressionTreeNode>>>()) { 38 var tile = new SymbolicExpressionTreeTile(chart) { 39 Root = node.Content.Root, 40 LayoutEngine = symbolicExpressionEngine 41 }; 41 var tile = new SymbolicExpressionTreeTile(chart); 42 tile.LayoutEngine = symbolicExpressionEngine; 43 tile.Root = node.Content.Root; 42 44 var tileNode = new TileLayoutNode { 43 45 Tile = tile … … 59 61 var root = tileDictionary[(IGenealogyGraphNode<IFragment<ISymbolicExpressionTreeNode>>)Content.Nodes[0]]; 60 62 var visualNodes = layoutEngine.CalculateLayout(root); 63 64 symbolicExpressionChartControl.UpdateEnabled = false; 65 foreach (var visualNode in visualNodes) { 66 var tile = visualNode.Content.Tile; 67 symbolicExpressionChartControl.Add(tile); 68 } 69 symbolicExpressionChartControl.UpdateEnabled = true; 70 symbolicExpressionChartControl.EnforceUpdate(); 61 71 } 62 72 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymboldDataAnalysisGenealogyView.cs
r10655 r10656 82 82 var tree = graphNode.Content; 83 83 symbolicExpressionTreeChart.Tree = tree; 84 85 if (graphNode.InArcs != null) { 86 var fragment = (IFragment<ISymbolicExpressionTreeNode>)graphNode.InArcs.Last().Data; 87 treeChart_HighlightSubtree(fragment.Root); 88 } 84 89 } 85 90 … … 97 102 // perform fragment tracing 98 103 var fragmentGraph = TraceSubtree(subtree); 104 var fragmentGraphView = MainFormManager.CreateView(typeof(FragmentGraphView)); 105 fragmentGraphView.Content = fragmentGraph; 106 fragmentGraphView.Show(); 99 107 100 108 // open a FragmentGraphView displaying this fragmentGraph … … 173 181 174 182 var fragment = (IFragment<ISymbolicExpressionTreeNode>)graphNode.InArcs.Last().Data; 183 if (fragment == null) return; 175 184 var fragmentLength = fragment.Root.GetLength(); 176 185 … … 193 202 fragmentGraph.AddVertex(node); 194 203 195 graphNode= (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs.Last().Source;196 subtree = graphNode.Content.IterateNodesPrefix().ToList()[fragment.OldIndex];197 Trace(g raphNode, subtree, fragmentGraph, node);204 var g = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs.Last().Source; 205 var s = g.Content.IterateNodesPrefix().ToList()[fragment.OldIndex]; 206 Trace(g, s, fragmentGraph, node); 198 207 } else if (fragment.Index < index && index < fragment.Index + fragmentLength) { 199 208 // the fragment contains the selected subtree … … 207 216 fragmentGraph.AddVertex(node); 208 217 209 graphNode= (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs.Last().Source;218 var g = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs.Last().Source; 210 219 var i = fragment.Root.IterateNodesPrefix().ToList().IndexOf(subtree); 211 subtree = graphNode.Content.IterateNodesPrefix().ToList()[fragment.OldIndex + i];212 Trace(g raphNode, subtree, fragmentGraph, node);220 var s = g.Content.IterateNodesPrefix().ToList()[fragment.OldIndex + i]; 221 Trace(g, s, fragmentGraph, node); 213 222 214 223 } else if (index < fragment.Index && fragment.Index < index + length) { 215 224 // the selected subtree contains the fragment 216 if (fragmentLength >= length) throw new Exception("Subtree contains fragment, so fragment length should be less than the subtree length."); 217 218 var node = new FragmentNode { Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, Rank = graphNode.Rank }; 219 220 if (parentNode != null) { 221 AddChild(parentNode, node); 222 } 223 fragmentGraph.AddVertex(node); 224 225 var graphNode0 = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs[0].Source; 226 var subtree0 = graphNode0.Content.IterateNodesPrefix().ToList()[index]; 227 Trace(graphNode0, subtree0, fragmentGraph, node); 225 if (fragmentLength >= length) 226 throw new Exception("Subtree contains fragment, so fragment length should be less than the subtree length."); 227 228 var node = new FragmentNode { 229 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, 230 Rank = graphNode.Rank 231 }; 232 233 if (parentNode != null) { 234 AddChild(parentNode, node); 235 } 236 fragmentGraph.AddVertex(node); 237 238 var g0 = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs[0].Source; 239 var s0 = g0.Content.IterateNodesPrefix().ToList()[index]; 240 Trace(g0, s0, fragmentGraph, node); 228 241 229 242 if (graphNode.InArcs.Count > 1) { 230 var graphNode1 = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs[1].Source; 231 var subtree1 = graphNode1.Content.IterateNodesPrefix().ToList()[fragment.OldIndex]; 232 Trace(graphNode1, subtree1, fragmentGraph, node); 233 } 243 var g1 = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs[1].Source; 244 var s1 = g1.Content.IterateNodesPrefix().ToList()[fragment.OldIndex]; 245 Trace(g1, s1, fragmentGraph, node); 246 } 247 } else { 248 // fragment and subtree are completely distinct, therefore we will track the subtree 249 var node = new FragmentNode { 250 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, 251 Rank = graphNode.Rank 252 }; 253 254 if (parentNode != null) { 255 AddChild(parentNode, node); 256 } 257 fragmentGraph.AddVertex(node); 258 var g = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs[0].Source; 259 var s = graphNode.Content.IterateNodesPrefix().ToList()[index]; 260 Trace(g, s, fragmentGraph, node); 234 261 } 235 262 }
Note: See TracChangeset
for help on using the changeset viewer.