Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10656


Ignore:
Timestamp:
03/26/14 01:52:16 (11 years ago)
Author:
bburlacu
Message:

#1772: Re-added old behavior: highlight received fragment when genealogy graph node is clicked.

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  
    2323        base.Content = value;
    2424        MakeTiles();
     25        Draw();
    2526      }
    2627    }
     
    3132      layoutEngine = new ReingoldTilfordLayoutEngine<TileLayoutNode>(n => n.Children);
    3233      symbolicExpressionEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees);
     34      tileDictionary = new Dictionary<IGenealogyGraphNode<IFragment<ISymbolicExpressionTreeNode>>, TileLayoutNode>();
    3335    }
    3436
    3537    private void MakeTiles() {
    3638      var chart = symbolicExpressionChartControl.Chart;
     39      tileDictionary.Clear();
    3740      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;
    4244        var tileNode = new TileLayoutNode {
    4345          Tile = tile
     
    5961      var root = tileDictionary[(IGenealogyGraphNode<IFragment<ISymbolicExpressionTreeNode>>)Content.Nodes[0]];
    6062      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();
    6171    }
    6272
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymboldDataAnalysisGenealogyView.cs

    r10655 r10656  
    8282      var tree = graphNode.Content;
    8383      symbolicExpressionTreeChart.Tree = tree;
     84
     85      if (graphNode.InArcs != null) {
     86        var fragment = (IFragment<ISymbolicExpressionTreeNode>)graphNode.InArcs.Last().Data;
     87        treeChart_HighlightSubtree(fragment.Root);
     88      }
    8489    }
    8590
     
    97102        // perform fragment tracing
    98103        var fragmentGraph = TraceSubtree(subtree);
     104        var fragmentGraphView = MainFormManager.CreateView(typeof(FragmentGraphView));
     105        fragmentGraphView.Content = fragmentGraph;
     106        fragmentGraphView.Show();
    99107
    100108        // open a FragmentGraphView displaying this fragmentGraph
     
    173181
    174182      var fragment = (IFragment<ISymbolicExpressionTreeNode>)graphNode.InArcs.Last().Data;
     183      if (fragment == null) return;
    175184      var fragmentLength = fragment.Root.GetLength();
    176185
     
    193202        fragmentGraph.AddVertex(node);
    194203
    195         graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs.Last().Source;
    196         subtree = graphNode.Content.IterateNodesPrefix().ToList()[fragment.OldIndex];
    197         Trace(graphNode, 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);
    198207      } else if (fragment.Index < index && index < fragment.Index + fragmentLength) {
    199208        // the fragment contains the selected subtree
     
    207216        fragmentGraph.AddVertex(node);
    208217
    209         graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs.Last().Source;
     218        var g = (IGenealogyGraphNode<ISymbolicExpressionTree>)graphNode.InArcs.Last().Source;
    210219        var i = fragment.Root.IterateNodesPrefix().ToList().IndexOf(subtree);
    211         subtree = graphNode.Content.IterateNodesPrefix().ToList()[fragment.OldIndex + i];
    212         Trace(graphNode, subtree, fragmentGraph, node);
     220        var s = g.Content.IterateNodesPrefix().ToList()[fragment.OldIndex + i];
     221        Trace(g, s, fragmentGraph, node);
    213222
    214223      } else if (index < fragment.Index && fragment.Index < index + length) {
    215224        // 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);
    228241
    229242        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);
    234261      }
    235262    }
Note: See TracChangeset for help on using the changeset viewer.