Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/15 23:17:56 (9 years ago)
Author:
bburlacu
Message:

#1772: Added some useful functionality to the GenealogyGraphView.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.cs

    r11817 r11852  
    2525using System.Linq;
    2626using System.Windows.Forms;
     27using HeuristicLab.Common;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
     
    7273      var visualNode = (VisualGenealogyGraphNode)sender;
    7374      var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)visualNode.Data;
     75
     76      if (openNew_CheckBox.Checked) {
     77        // get the ancestors into a new view
     78        var cloner = new Cloner();
     79
     80        var graph = new GenealogyGraph<ISymbolicExpressionTree>();
     81        var ancestors = new[] { graphNode }.Concat(graphNode.Ancestors);
     82        var cloned = ancestors.ToDictionary(x => x, x => cloner.Clone(x));
     83        graph.AddVertices(cloned.Values);
     84        foreach (var arc in cloned.Keys.SelectMany(x => x.InArcs)) {
     85          graph.AddArc(cloner.Clone(arc));
     86        }
     87        //        graph.AddVertices(graphNode.Ancestors);
     88        MainFormManager.MainForm.ShowContent(graph);
     89      }
     90
    7491      if (graphNode.InArcs.Any()) {
    7592        var fragment = graphNode.InArcs.Last().Data as IFragment<ISymbolicExpressionTreeNode>;
     
    92109      var visualNode = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender;
    93110      var subtree = visualNode.Content;
    94 
    95111      // highlight the selected subtree inside the displayed tree on the right hand side
    96112      treeChart_ClearColors();
     
    103119        var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode;
    104120        var subtreeIndex = graphNode.Data.IterateNodesPrefix().ToList().IndexOf(subtree);
    105         //        var fragmentGraph = SymbolicDataAnalysisExpressionTracing.TraceSubtree(graphNode, subtreeIndex);
    106121        var traceGraph = TraceCalculator.TraceSubtree(graphNode, subtreeIndex);
    107 
    108122        if (traceGraph.Vertices.Any()) {
     123          genealogyGraphChart.UpdateEnabled = false;
     124          genealogyGraphChart.ClearArcs();
     125          //          genealogyGraphChart.ClearPrimitives();
    109126          var genealogyNodes = traceGraph.Vertices.Select(v => Content.GetByContent(v.Data));
    110           genealogyGraphChart.HighlightNodes(genealogyNodes);
    111           foreach (var a in traceGraph.Arcs) {
    112             genealogyGraphChart.HighlightArc(Content.GetByContent(a.Target.Data), Content.GetByContent(a.Source.Data));
    113           }
     127          //          genealogyGraphChart.HighlightNodes(graphNode.Ancestors, Color.Gray, false);
     128          genealogyGraphChart.HighlightNodes(genealogyNodes, Color.Black, false);
     129          //          foreach (var a in traceGraph.Arcs) {
     130          //            genealogyGraphChart.HighlightArc(Content.GetByContent(a.Target.Data), Content.GetByContent(a.Source.Data));
     131          //          }
     132          genealogyGraphChart.UpdateEnabled = true;
     133          genealogyGraphChart.EnforceUpdate();
    114134          MainFormManager.MainForm.ShowContent(traceGraph); // display the fragment graph on the screen
    115135        }
     
    121141
    122142        var matchingVertices = matchingTrees.Select(x => Content.GetByContent(x));
    123         graphChart_highlightMatchingVertices(matchingVertices);
     143        graphChart_HighlightMatchingVertices(matchingVertices);
    124144      }
    125145    }
    126146
    127     private void graphChart_highlightMatchingVertices(IEnumerable<IGenealogyGraphNode> vertices) {
     147    private void graphChart_HighlightMatchingVertices(IEnumerable<IGenealogyGraphNode> vertices) {
    128148      genealogyGraphChart.Chart.UpdateEnabled = false;
    129149      genealogyGraphChart.ClearPrimitives();
Note: See TracChangeset for help on using the changeset viewer.