Changeset 8556


Ignore:
Timestamp:
09/03/12 15:09:52 (7 years ago)
Author:
bburlacu
Message:

#1772: Modified genealogy graph chart and view to reflect changes in the class hierarchy.

Location:
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.cs

    r8249 r8556  
    3232namespace HeuristicLab.EvolutionaryTracking.Views {
    3333  public partial class GenealogyGraphChart : ChartControl {
    34     private Dictionary<GenealogyGraphNode, List<VisualGenealogyGraphNode>> _visualNodeMap;
    35     private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> _visualArcMap;
     34    private Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode> visualNodeMap;
     35    private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> visualArcMap;
    3636    private const int Diameter = 20; // node diameter
    3737    private int x, y; // coordinates for positioning each node
    3838    private const int Cx = 30, Cy = 30; // position increments
    39     private VisualGenealogyGraphNode _selectedGenealogyGraphNode;
    40     public VisualGenealogyGraphNode SelectedGenealogyGraphNode { get { return _selectedGenealogyGraphNode; } }
    41     private Visualization.Rectangle _targetRectangle; // provides a  rectangle mark of the currently selected genealogy graph node
    42 
    43     private SymbolicExpressionTreeGenealogyGraph _graph;
     39    private VisualGenealogyGraphNode selectedGenealogyGraphNode;
     40    public VisualGenealogyGraphNode SelectedGenealogyGraphNode { get { return selectedGenealogyGraphNode; } }
     41    private Visualization.Rectangle targetRectangle; // provides a  rectangle mark of the currently selected genealogy graph node
     42
     43    private SymbolicExpressionTreeGenealogyGraph graph;
    4444    public SymbolicExpressionTreeGenealogyGraph Graph {
    45       get { return _graph; }
     45      get { return graph; }
    4646      internal set {
    47         _graph = value;
    48         _visualNodeMap = new Dictionary<GenealogyGraphNode, List<VisualGenealogyGraphNode>>();
    49         _visualArcMap = new Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc>();
     47        graph = value;
     48        visualNodeMap = new Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode>();
     49        visualArcMap = new Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc>();
    5050        DrawGraph();
    5151      }
     
    6565
    6666    public void DrawGraph() {
    67       if (_graph == null) return;
     67      if (graph == null) return;
    6868      Chart.UpdateEnabled = false;
    6969
    70       var genealogyGraphNodes = Graph.Values.ToList();
    71       var layers = genealogyGraphNodes.GroupBy(n => Graph[n].Ranks[0]).OrderBy(g => g.Key).Select(g => new { Rank = g.Key, Nodes = g.ToList() }).ToList();
    72       List<GenealogyGraphNode> currentLayer = null;
    73       List<GenealogyGraphNode> previousLayer = null;
    74 
    75       for (int i = 0; i != layers.Count(); ++i) {
    76         var layer = layers[i];
    77         double currentRank = layer.Rank;
    78         if (i > 0 && currentRank % 1 == 0) {
    79           previousLayer = currentLayer;
    80           currentLayer = layer.Nodes;
    81           int d = previousLayer.Count - currentLayer.Count;
    82           if (d > 0)
    83             currentLayer.AddRange(previousLayer.Take(d));
    84         } else {
    85           currentLayer = layer.Nodes;
    86         }
    87         currentLayer.Sort((b, a) => {
    88           if (Graph[a].Quality.Equals(Graph[b].Quality)) {
    89             if (Graph[a].IsElite) return 1;
    90             if (Graph[b].IsElite) return -1;
    91           }
    92           return Graph[a].Quality.CompareTo(Graph[b].Quality);
    93         }); // sort descending by quality (using comparison defined in GenealogyGraphNode class)
    94 
     70      var layers = Graph.Nodes.GroupBy(n => n.Ranks[0]).OrderBy(g => g.Key).Select(g => new { Rank = g.Key, Nodes = g.ToList() }).ToList();
     71      for (int i = 0; i != layers.Count; ++i) {
     72        // sort descending by quality (using comparison defined in GenealogyGraphNode class)
     73        layers[i].Nodes.Sort((b, a) => Graph.Compare(a, b));
    9574        x = 0; // reset horizontal coordinate
    9675        // start laying out visual nodes
    97         foreach (var node in currentLayer) {
     76        foreach (var node in layers[i].Nodes) {
    9877          var pen = new Pen(Color.LightGray);
    9978          var nl = Environment.NewLine;
     
    10180            Data = node,
    10281            ToolTipText = "Id: " + node.Label + nl +
    103                           "Ranks: " + string.Join(",", Graph[node].Ranks.Select(r => r.ToString())) + nl +
    104                           "Quality: " + String.Format("{0:0.0000}", Graph[node].Quality) + nl +
    105                           "IsElite: " + Graph[node].IsElite
     82                          "Ranks: " + string.Join(",", node.Ranks) + nl +
     83                          "Quality: " + String.Format("{0:0.0000}", node.Quality) + nl +
     84                          "IsElite: " + node.IsElite
    10685          };
    10786          Chart.Group.Add(visualNode);
    108           if (!_visualNodeMap.ContainsKey(node))
    109             _visualNodeMap[node] = new List<VisualGenealogyGraphNode>();
    110           _visualNodeMap[node].Add(visualNode);
     87          if (!visualNodeMap.ContainsKey(node))
     88            visualNodeMap[node] = visualNode;
    11189
    11290          x += Cx; // increment horizontal coordinate
     
    11492
    11593        y -= Cy; // decrement vertical coordinate (because the origin is upside down)
     94
     95        // connect elites from successive layers with visual arcs
     96        if (i > 0) {
     97          for (int m = 0; m != layers[i].Nodes.Count; ++m)
     98            for (int n = 0; n != layers[i - 1].Nodes.Count; ++n) {
     99              if (layers[i].Nodes[m].SymbolicExpressionTree == layers[i - 1].Nodes[n].SymbolicExpressionTree) {
     100                var v1 = visualNodeMap[layers[i].Nodes[m]];
     101                var v2 = visualNodeMap[layers[i - 1].Nodes[n]];
     102                var pen = new Pen(Color.LightGray);
     103                visualArcMap[Tuple.Create(v2, v1)] = AddArc(Chart, v2, v1, pen);
     104              }
     105            }
     106        }
    116107      }
    117108      // add arcs separately (to avoid some ordering problems)
    118       foreach (var node in _visualNodeMap.Keys) {
    119         var visualNode = _visualNodeMap[node][0];
     109      foreach (var node in visualNodeMap.Keys) {
     110        var visualNode = visualNodeMap[node];
    120111        if (node.InEdges == null) continue;
    121112
    122113        foreach (var arc in node.InEdges) {
    123           var visualParent = _visualNodeMap[arc.Target][0];
     114          var visualParent = visualNodeMap[arc.Target];
    124115          var pen = new Pen(Color.Transparent);
    125           _visualArcMap[Tuple.Create(visualParent, visualNode)] = AddArc(Chart, visualParent, visualNode, pen);
    126         }
    127       }
    128       // connect visual nodes representing the same elite individual with a line
    129       foreach (var list in _visualNodeMap.Values.Where(l => l.Count > 1)) {
    130         for (int i = 1; i != list.Count; ++i) {
    131           var pen = new Pen(Color.LightGray);
    132           _visualArcMap[Tuple.Create(list[i - 1], list[i])] = AddArc(Chart, list[i - 1], list[i], pen);
     116          visualArcMap[Tuple.Create(visualParent, visualNode)] = AddArc(Chart, visualParent, visualNode, pen);
    133117        }
    134118      }
     
    156140        var visualNodes = Chart.GetAllPrimitives(e.Location).Where(p => p is VisualGenealogyGraphNode).ToList();
    157141        if (visualNodes.Count > 0) {
    158           if (_selectedGenealogyGraphNode == visualNodes[0]) return;
    159           _selectedGenealogyGraphNode = visualNodes[0] as VisualGenealogyGraphNode;
    160           if (_selectedGenealogyGraphNode == null) return;
     142          if (selectedGenealogyGraphNode == visualNodes[0]) return;
     143          selectedGenealogyGraphNode = visualNodes[0] as VisualGenealogyGraphNode;
     144          if (selectedGenealogyGraphNode == null) return;
    161145          // new node has been selected, clean up
    162146          Chart.UpdateEnabled = false;
     
    164148          ClearAllNodes();
    165149          // use a rectangle to highlight the currently selected genealogy graph node
    166           var center = _selectedGenealogyGraphNode.Center;
    167           var size = _selectedGenealogyGraphNode.Size;
     150          var center = selectedGenealogyGraphNode.Center;
     151          var size = selectedGenealogyGraphNode.Size;
    168152          double x1 = center.X - size.Width / 2;
    169153          double x2 = x1 + size.Width;
    170154          double y1 = center.Y - size.Height / 2;
    171155          double y2 = y1 + size.Height;
    172           if (_targetRectangle == null) {
    173             _targetRectangle = new Visualization.Rectangle(Chart, x1, y1, x2, y2, new Pen(Color.Black), null);
    174             Chart.Group.Add(_targetRectangle);
     156          if (targetRectangle == null) {
     157            targetRectangle = new Visualization.Rectangle(Chart, x1, y1, x2, y2, new Pen(Color.Black), null);
     158            Chart.Group.Add(targetRectangle);
    175159          } else {
    176             _targetRectangle.SetPosition(x1, y1, x2, y2);
    177           }
    178           var gNode = _selectedGenealogyGraphNode.Data; // genealogy graph node (representing an individual in the population)
    179           double rank = Graph[gNode].Ranks[0];
     160            targetRectangle.SetPosition(x1, y1, x2, y2);
     161          }
     162          var gNode = selectedGenealogyGraphNode.Data; // genealogy graph node (representing an individual in the population)
     163          //          double rank = Graph[gNode].Ranks[0];
     164          double rank = ((SymbolicExpressionGenealogyGraphNode)gNode).Ranks[0];
    180165          // ancestors
    181           var ancestors = gNode.Ancestors().Where(n => Graph[n].Ranks.Last() < rank).ToList();
     166          var ancestors = gNode.Ancestors().Where(n => ((SymbolicExpressionGenealogyGraphNode)n).Ranks.Last() < rank).ToList();
    182167          ancestors.Add(gNode);
    183168          // descendants
    184           var descendants = gNode.Descendants().Where(n => Graph[n].Ranks.Last() > rank).ToList();
     169          var descendants = gNode.Descendants().Where(n => ((SymbolicExpressionGenealogyGraphNode)n).Ranks.Last() > rank).ToList();
    185170          descendants.Add(gNode);
    186171          // highlight ancestors
    187           foreach (var node in ancestors.Select(n => _visualNodeMap[n][0])) {
    188             node.Brush = new SolidBrush(Graph[node.Data].GetColor());
     172          foreach (var node in ancestors.Select(n => visualNodeMap[n])) {
     173            node.Brush = new SolidBrush(((SymbolicExpressionGenealogyGraphNode)node.Data).GetColor());
    189174            if (node.IncomingArcs != null)
    190175              foreach (var arc in node.IncomingArcs) {
    191                 // check if, in case of elites, the target node is the first visual representation of the elite
    192                 // (for purposes of display consistency)
    193                 bool isFirst = arc.Source == _visualNodeMap[arc.Source.Data][0];
    194                 if (arc.Source.Data == arc.Target.Data || !isFirst) continue;
    195176                var start = new Point((int)arc.Start.X, (int)arc.Start.Y);
    196177                var end = new Point((int)arc.End.X, (int)arc.End.Y);
    197                 arc.Pen.Brush = new LinearGradientBrush(start, end, Graph[arc.Source.Data].GetColor(), Graph[arc.Target.Data].GetColor());
     178                var srcNode = arc.Source.Data as SymbolicExpressionGenealogyGraphNode;
     179                var destNode = arc.Target.Data as SymbolicExpressionGenealogyGraphNode;
     180                arc.Pen.Brush = new LinearGradientBrush(start, end, srcNode.GetColor(), destNode.GetColor());
    198181              }
    199182          }
    200183          // highlight descendants
    201           foreach (var node in descendants.Select(n => _visualNodeMap[n][0])) {
    202             node.Brush = new SolidBrush(Graph[node.Data].GetColor());
     184          foreach (var node in descendants.Select(n => visualNodeMap[n])) {
     185            node.Brush = new SolidBrush((node.Data as SymbolicExpressionGenealogyGraphNode).GetColor());
    203186            if (node.OutgoingArcs != null)
    204187              foreach (var arc in node.OutgoingArcs) {
    205                 // check if, in case of elites, the target node is the first visual representation of the elite
    206                 // (for purposes of display consistency)
    207                 bool isFirst = arc.Target == _visualNodeMap[arc.Target.Data][0];
    208                 if (arc.Source.Data == arc.Target.Data || !isFirst) continue;
    209188                var start = new Point((int)arc.Start.X, (int)arc.Start.Y);
    210189                var end = new Point((int)arc.End.X, (int)arc.End.Y);
    211                 arc.Pen.Brush = new LinearGradientBrush(start, end, Graph[arc.Source.Data].GetColor(), Graph[arc.Target.Data].GetColor());
     190                var srcNode = arc.Source.Data as SymbolicExpressionGenealogyGraphNode;
     191                var destNode = arc.Target.Data as SymbolicExpressionGenealogyGraphNode;
     192                arc.Pen.Brush = new LinearGradientBrush(start, end, srcNode.GetColor(), destNode.GetColor());
    212193              }
    213194          }
    214195        } else {
    215           _selectedGenealogyGraphNode = null;
     196          selectedGenealogyGraphNode = null;
    216197        }
    217198        // update
    218199        Chart.UpdateEnabled = true;
    219200        Chart.EnforceUpdate();
    220         if (_selectedGenealogyGraphNode != null)
     201        if (selectedGenealogyGraphNode != null)
    221202          /* emit clicked event */
    222           OnGenealogyGraphNodeClicked(_selectedGenealogyGraphNode, e);
     203          OnGenealogyGraphNodeClicked(selectedGenealogyGraphNode, e);
    223204      }
    224205    }
     
    226207    public void ClearAllNodes() {
    227208      foreach (var primitive in Chart.Group.Primitives) {
    228         primitive.Brush = null;
    229209        if (primitive is VisualGenealogyGraphArc) {
    230210          var arc = primitive as VisualGenealogyGraphArc;
    231           if (arc.Source.Data != arc.Target.Data && primitive.Pen.Brush != null)
     211          var sourceData = (arc.Source.Data as SymbolicExpressionGenealogyGraphNode).SymbolicExpressionTree;
     212          var targetData = (arc.Target.Data as SymbolicExpressionGenealogyGraphNode).SymbolicExpressionTree;
     213          if (sourceData != targetData) {
    232214            primitive.Pen.Brush = new SolidBrush(Color.Transparent);
     215          } else {
     216            primitive.Pen.Brush = new SolidBrush(Color.LightGray);
     217          }
     218        } else {
     219          primitive.Brush = null;
    233220        }
    234221      }
     
    236223
    237224    public void HighlightLineage(IEnumerable<GenealogyGraphNode> nodes) {
    238       foreach (var node in nodes.SelectMany(n => _visualNodeMap[n])) {
    239         node.Brush = new SolidBrush(Graph[node.Data].GetColor());
    240         if (node.IncomingArcs == null || node != _visualNodeMap[node.Data][0]) continue;
     225      foreach (var node in nodes.Select(n => visualNodeMap[n])) {
     226        node.Brush = new SolidBrush((node.Data as SymbolicExpressionGenealogyGraphNode).GetColor());
     227        if (node.IncomingArcs == null || node != visualNodeMap[node.Data]) continue;
    241228        foreach (var arc in node.IncomingArcs) {
    242229          if (arc.Source.Data == node.Data) continue;
    243230          var start = new Point((int)arc.Start.X, (int)arc.Start.Y);
    244231          var end = new Point((int)arc.End.X, (int)arc.End.Y);
    245           arc.Pen.Brush = new LinearGradientBrush(start, end, Graph[arc.Source.Data].GetColor(), Graph[arc.Target.Data].GetColor());
    246         }
    247       }
    248     }
    249 
     232          var srcNode = arc.Source.Data as SymbolicExpressionGenealogyGraphNode;
     233          var destNode = arc.Target.Data as SymbolicExpressionGenealogyGraphNode;
     234          arc.Pen.Brush = new LinearGradientBrush(start, end, srcNode.GetColor(), destNode.GetColor());
     235        }
     236      }
     237    }
     238
     239    // TODO: optimize and reduce complexity of this method
    250240    public void HighlightNodes(IEnumerable<ISymbolicExpressionTree> trees, Color color) {
    251       foreach (var visualNode in trees.Select(tree => _visualNodeMap[Graph.GetNode(tree)]).SelectMany(vList => vList))
    252         visualNode.Brush = new SolidBrush(color);
     241      foreach (var tree in trees)
     242        foreach (var graphNode in Graph.Nodes) {
     243          if (graphNode.SymbolicExpressionTree == tree) {
     244            var visualNode = visualNodeMap[graphNode];
     245            visualNode.Brush = new SolidBrush(color);
     246          }
     247        }
     248    }
     249
     250    public void HighlightNode(SymbolicExpressionGenealogyGraphNode graphNode, Color color) {
     251      visualNodeMap[graphNode].Brush = new SolidBrush(color);
    253252    }
    254253
     
    256255      Chart.UpdateEnabled = false;
    257256      ClearAllNodes();
    258       var graphNodes = Graph.Values.ToList();
    259       double min = graphNodes.Min(x => x.InEdges == null ? 0 : x.InEdges.Count);
    260       double max = graphNodes.Max(x => x.InEdges == null ? 0 : x.InEdges.Count);
    261       foreach (var graphNode in graphNodes) {
    262         var visualNode = _visualNodeMap[graphNode][0];
     257      double max = Graph.Nodes.Max(x => x.InEdges == null ? 0 : x.InEdges.Count);
     258      foreach (var graphNode in Graph.Nodes) {
     259        var visualNode = visualNodeMap[graphNode];
    263260        double deg = graphNode.InEdges == null ? 0 : graphNode.InEdges.Count;
    264         var color = Color.FromArgb((int)(1 - deg / max) * 255, (int)(deg / max * 255), 100);
     261        int index = (int)(deg / max * ColorGradient.Colors.Count);
     262        if (index == ColorGradient.Colors.Count) --index;
     263        var color = ColorGradient.Colors[index];
    265264        visualNode.Brush = new SolidBrush(color);
    266265      }
     
    272271      Chart.UpdateEnabled = false;
    273272      ClearAllNodes();
    274       var graphNodes = Graph.Values.ToList();
    275       double min = graphNodes.Min(x => x.OutEdges == null ? 0 : x.OutEdges.Count);
     273      var graphNodes = Graph.Nodes;
    276274      double max = graphNodes.Max(x => x.OutEdges == null ? 0 : x.OutEdges.Count);
    277275      foreach (var graphNode in graphNodes) {
    278         var visualNode = _visualNodeMap[graphNode][0];
     276        var visualNode = visualNodeMap[graphNode];
    279277        double deg = graphNode.OutEdges == null ? 0 : graphNode.OutEdges.Count;
    280         int index = (int)(deg / max * ColorGradient.Colors.Count) - 1;
    281         if (index < 0) index = 0;
    282         visualNode.Brush = new SolidBrush(ColorGradient.Colors[index]);
     278        int index = (int)(deg / max * ColorGradient.Colors.Count);
     279        if (index == ColorGradient.Colors.Count) --index;
     280        var color = ColorGradient.Colors[index];
     281        visualNode.Brush = new SolidBrush(color);
    283282      }
    284283      Chart.UpdateEnabled = true;
     
    288287
    289288  internal static class Util {
    290     public static Color GetColor(this NodeMetadata nm) {
    291       var colorIndex = (int)(nm.Quality * ColorGradient.Colors.Count);
     289    public static Color GetColor(this SymbolicExpressionGenealogyGraphNode node) {
     290      var colorIndex = (int)(node.Quality * ColorGradient.Colors.Count);
    292291      if (colorIndex >= ColorGradient.Colors.Count) --colorIndex;
    293292      return ColorGradient.Colors[colorIndex];
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.Designer.cs

    r8213 r8556  
    2828      this.splitContainer = new System.Windows.Forms.SplitContainer();
    2929      this.genealogyTableLayout = new System.Windows.Forms.TableLayoutPanel();
     30      this.symbolicExpressionTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
     31      this.topControlBox = new System.Windows.Forms.GroupBox();
    3032      this.graphControlsPanel = new System.Windows.Forms.Panel();
     33      this.similarityModeLabel = new System.Windows.Forms.Label();
     34      this.similarityModeSelector = new System.Windows.Forms.ComboBox();
    3135      this.selectModeButton = new System.Windows.Forms.RadioButton();
    3236      this.moveModeButton = new System.Windows.Forms.RadioButton();
    3337      this.zoomModeButton = new System.Windows.Forms.RadioButton();
    34       this.symbolicExpressionTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    35       this.topControlBox = new System.Windows.Forms.GroupBox();
    36       this.similarityModeLabel = new System.Windows.Forms.Label();
    37       this.similarityModeSelector = new System.Windows.Forms.ComboBox();
    3838      this.genealogyGraphChart = new HeuristicLab.EvolutionaryTracking.Views.GenealogyGraphChart();
    39       this.inDegreeButton = new System.Windows.Forms.Button();
    40       this.outDegreeButton = new System.Windows.Forms.Button();
    4139      this.mainTableLayout.SuspendLayout();
    4240      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     
    4543      this.splitContainer.SuspendLayout();
    4644      this.genealogyTableLayout.SuspendLayout();
     45      this.topControlBox.SuspendLayout();
    4746      this.graphControlsPanel.SuspendLayout();
    48       this.topControlBox.SuspendLayout();
    4947      this.SuspendLayout();
    5048      //
     
    6260      this.mainTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
    6361      this.mainTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    64       this.mainTableLayout.Size = new System.Drawing.Size(528, 443);
     62      this.mainTableLayout.Size = new System.Drawing.Size(787, 584);
    6563      this.mainTableLayout.TabIndex = 6;
    6664      //
     
    8179      this.splitContainer.Panel2.Controls.Add(this.symbolicExpressionTreeChart);
    8280      this.splitContainer.Panel2MinSize = 50;
    83       this.splitContainer.Size = new System.Drawing.Size(522, 387);
    84       this.splitContainer.SplitterDistance = 241;
     81      this.splitContainer.Size = new System.Drawing.Size(781, 528);
     82      this.splitContainer.SplitterDistance = 360;
    8583      this.splitContainer.TabIndex = 7;
    8684      //
     
    9088      this.genealogyTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
    9189      this.genealogyTableLayout.Controls.Add(this.genealogyGraphChart, 0, 1);
    92       this.genealogyTableLayout.Controls.Add(this.graphControlsPanel, 0, 0);
    9390      this.genealogyTableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
    9491      this.genealogyTableLayout.Location = new System.Drawing.Point(0, 0);
     
    9794      this.genealogyTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle());
    9895      this.genealogyTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
    99       this.genealogyTableLayout.Size = new System.Drawing.Size(239, 385);
     96      this.genealogyTableLayout.Size = new System.Drawing.Size(358, 526);
    10097      this.genealogyTableLayout.TabIndex = 4;
    101       //
    102       // graphControlsPanel
    103       //
    104       this.graphControlsPanel.Controls.Add(this.outDegreeButton);
    105       this.graphControlsPanel.Controls.Add(this.inDegreeButton);
    106       this.graphControlsPanel.Controls.Add(this.selectModeButton);
    107       this.graphControlsPanel.Controls.Add(this.moveModeButton);
    108       this.graphControlsPanel.Controls.Add(this.zoomModeButton);
    109       this.graphControlsPanel.Location = new System.Drawing.Point(3, 3);
    110       this.graphControlsPanel.Name = "graphControlsPanel";
    111       this.graphControlsPanel.Size = new System.Drawing.Size(194, 30);
    112       this.graphControlsPanel.TabIndex = 0;
    113       //
    114       // selectModeButton
    115       //
    116       this.selectModeButton.Appearance = System.Windows.Forms.Appearance.Button;
    117       this.selectModeButton.AutoSize = true;
    118       this.selectModeButton.Location = new System.Drawing.Point(65, 3);
    119       this.selectModeButton.Name = "selectModeButton";
    120       this.selectModeButton.Size = new System.Drawing.Size(24, 23);
    121       this.selectModeButton.TabIndex = 5;
    122       this.selectModeButton.TabStop = true;
    123       this.selectModeButton.Text = "S";
    124       this.selectModeButton.UseVisualStyleBackColor = true;
    125       this.selectModeButton.CheckedChanged += new System.EventHandler(this.selectModeButton_CheckedChanged);
    126       //
    127       // moveModeButton
    128       //
    129       this.moveModeButton.Appearance = System.Windows.Forms.Appearance.Button;
    130       this.moveModeButton.AutoSize = true;
    131       this.moveModeButton.Location = new System.Drawing.Point(3, 3);
    132       this.moveModeButton.Name = "moveModeButton";
    133       this.moveModeButton.Size = new System.Drawing.Size(26, 23);
    134       this.moveModeButton.TabIndex = 3;
    135       this.moveModeButton.TabStop = true;
    136       this.moveModeButton.Text = "M";
    137       this.moveModeButton.UseVisualStyleBackColor = true;
    138       this.moveModeButton.CheckedChanged += new System.EventHandler(this.moveModeButton_CheckedChanged);
    139       //
    140       // zoomModeButton
    141       //
    142       this.zoomModeButton.Appearance = System.Windows.Forms.Appearance.Button;
    143       this.zoomModeButton.AutoSize = true;
    144       this.zoomModeButton.Location = new System.Drawing.Point(35, 3);
    145       this.zoomModeButton.Name = "zoomModeButton";
    146       this.zoomModeButton.Size = new System.Drawing.Size(24, 23);
    147       this.zoomModeButton.TabIndex = 4;
    148       this.zoomModeButton.TabStop = true;
    149       this.zoomModeButton.Text = "Z";
    150       this.zoomModeButton.UseVisualStyleBackColor = true;
    151       this.zoomModeButton.CheckedChanged += new System.EventHandler(this.zoomModeButton_CheckedChanged);
    15298      //
    15399      // symbolicExpressionTreeChart
     
    158104      this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(0, 0);
    159105      this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";
    160       this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(275, 385);
     106      this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(415, 526);
    161107      this.symbolicExpressionTreeChart.Spacing = 5;
    162108      this.symbolicExpressionTreeChart.SuspendRepaint = false;
     
    167113      // topControlBox
    168114      //
     115      this.topControlBox.Controls.Add(this.graphControlsPanel);
    169116      this.topControlBox.Controls.Add(this.similarityModeLabel);
    170117      this.topControlBox.Controls.Add(this.similarityModeSelector);
     
    172119      this.topControlBox.Location = new System.Drawing.Point(3, 3);
    173120      this.topControlBox.Name = "topControlBox";
    174       this.topControlBox.Size = new System.Drawing.Size(522, 44);
     121      this.topControlBox.Size = new System.Drawing.Size(781, 44);
    175122      this.topControlBox.TabIndex = 6;
    176123      this.topControlBox.TabStop = false;
    177124      this.topControlBox.Text = "Controls";
     125      //
     126      // graphControlsPanel
     127      //
     128      this.graphControlsPanel.Controls.Add(this.selectModeButton);
     129      this.graphControlsPanel.Controls.Add(this.moveModeButton);
     130      this.graphControlsPanel.Controls.Add(this.zoomModeButton);
     131      this.graphControlsPanel.Location = new System.Drawing.Point(246, 14);
     132      this.graphControlsPanel.Name = "graphControlsPanel";
     133      this.graphControlsPanel.Size = new System.Drawing.Size(93, 30);
     134      this.graphControlsPanel.TabIndex = 2;
    178135      //
    179136      // similarityModeLabel
     
    199156      this.similarityModeSelector.SelectedIndexChanged += new System.EventHandler(this.similarityModeSelector_SelectedIndexChanged);
    200157      //
     158      // selectModeButton
     159      //
     160      this.selectModeButton.Appearance = System.Windows.Forms.Appearance.Button;
     161      this.selectModeButton.Location = new System.Drawing.Point(63, 3);
     162      this.selectModeButton.Name = "selectModeButton";
     163      this.selectModeButton.Size = new System.Drawing.Size(24, 24);
     164      this.selectModeButton.TabIndex = 11;
     165      this.selectModeButton.TabStop = true;
     166      this.selectModeButton.UseVisualStyleBackColor = true;
     167      this.selectModeButton.CheckedChanged += new System.EventHandler(this.selectModeButton_CheckedChanged);
     168      //
     169      // moveModeButton
     170      //
     171      this.moveModeButton.Appearance = System.Windows.Forms.Appearance.Button;
     172      this.moveModeButton.Location = new System.Drawing.Point(3, 3);
     173      this.moveModeButton.Name = "moveModeButton";
     174      this.moveModeButton.Size = new System.Drawing.Size(24, 24);
     175      this.moveModeButton.TabIndex = 9;
     176      this.moveModeButton.TabStop = true;
     177      this.moveModeButton.UseVisualStyleBackColor = true;
     178      this.moveModeButton.CheckedChanged += new System.EventHandler(this.moveModeButton_CheckedChanged);
     179      //
     180      // zoomModeButton
     181      //
     182      this.zoomModeButton.Appearance = System.Windows.Forms.Appearance.Button;
     183      this.zoomModeButton.Location = new System.Drawing.Point(33, 3);
     184      this.zoomModeButton.Name = "zoomModeButton";
     185      this.zoomModeButton.Size = new System.Drawing.Size(24, 24);
     186      this.zoomModeButton.TabIndex = 10;
     187      this.zoomModeButton.TabStop = true;
     188      this.zoomModeButton.UseVisualStyleBackColor = true;
     189      this.zoomModeButton.CheckedChanged += new System.EventHandler(this.zoomModeButton_CheckedChanged);
     190      //
    201191      // genealogyGraphChart
    202192      //
    203193      this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
    204194      this.genealogyGraphChart.Dock = System.Windows.Forms.DockStyle.Fill;
    205       this.genealogyGraphChart.Location = new System.Drawing.Point(3, 39);
     195      this.genealogyGraphChart.Location = new System.Drawing.Point(3, 3);
    206196      this.genealogyGraphChart.Name = "genealogyGraphChart";
    207197      this.genealogyGraphChart.ScaleOnResize = true;
    208       this.genealogyGraphChart.Size = new System.Drawing.Size(233, 343);
     198      this.genealogyGraphChart.Size = new System.Drawing.Size(352, 520);
    209199      this.genealogyGraphChart.TabIndex = 2;
    210       //
    211       // inDegreeButton
    212       //
    213       this.inDegreeButton.AutoSize = true;
    214       this.inDegreeButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
    215       this.inDegreeButton.Location = new System.Drawing.Point(95, 3);
    216       this.inDegreeButton.Name = "inDegreeButton";
    217       this.inDegreeButton.Size = new System.Drawing.Size(28, 23);
    218       this.inDegreeButton.TabIndex = 6;
    219       this.inDegreeButton.Text = "IN";
    220       this.inDegreeButton.UseVisualStyleBackColor = true;
    221       this.inDegreeButton.Click += new System.EventHandler(this.inDegreeButton_Click);
    222       //
    223       // outDegreeButton
    224       //
    225       this.outDegreeButton.AutoSize = true;
    226       this.outDegreeButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
    227       this.outDegreeButton.Location = new System.Drawing.Point(129, 3);
    228       this.outDegreeButton.Name = "outDegreeButton";
    229       this.outDegreeButton.Size = new System.Drawing.Size(40, 23);
    230       this.outDegreeButton.TabIndex = 7;
    231       this.outDegreeButton.Text = "OUT";
    232       this.outDegreeButton.UseVisualStyleBackColor = true;
    233       this.outDegreeButton.Click += new System.EventHandler(this.outDegreeButton_Click);
    234200      //
    235201      // GenealogyGraphView
     
    239205      this.Controls.Add(this.mainTableLayout);
    240206      this.Name = "GenealogyGraphView";
    241       this.Size = new System.Drawing.Size(528, 443);
     207      this.Size = new System.Drawing.Size(787, 584);
    242208      this.mainTableLayout.ResumeLayout(false);
    243209      this.splitContainer.Panel1.ResumeLayout(false);
     
    246212      this.splitContainer.ResumeLayout(false);
    247213      this.genealogyTableLayout.ResumeLayout(false);
    248       this.graphControlsPanel.ResumeLayout(false);
    249       this.graphControlsPanel.PerformLayout();
    250214      this.topControlBox.ResumeLayout(false);
    251215      this.topControlBox.PerformLayout();
     216      this.graphControlsPanel.ResumeLayout(false);
    252217      this.ResumeLayout(false);
    253218
     
    268233    private System.Windows.Forms.RadioButton moveModeButton;
    269234    private System.Windows.Forms.RadioButton zoomModeButton;
    270     private System.Windows.Forms.Button inDegreeButton;
    271     private System.Windows.Forms.Button outDegreeButton;
    272235
    273236  }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs

    r8248 r8556  
    3636  [Content(typeof(SymbolicExpressionTreeGenealogyGraph), IsDefaultView = true)]
    3737  public sealed partial class GenealogyGraphView : ItemView {
    38     private VisualSymbolicExpressionTreeNode _selectedVisualSymbolicExpressionTreeNode;
    39 
     38    private VisualSymbolicExpressionTreeNode selectedVisualSymbExprTreeNode;
    4039    public new SymbolicExpressionTreeGenealogyGraph Content {
    4140      get { return (SymbolicExpressionTreeGenealogyGraph)base.Content; }
     
    4342    }
    4443
     44    private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> clonedNodeMap;
     45
    4546    public GenealogyGraphView()
    4647      : base() {
    4748      InitializeComponent();
     49      // set button icons here because if set in the designer file, they get overwritten
     50      this.moveModeButton.Image = Common.Resources.VSImageLibrary.Pointer;
     51      this.zoomModeButton.Image = Common.Resources.VSImageLibrary.Zoom;
     52      this.selectModeButton.Image = Common.Resources.VSImageLibrary.Object;
     53
     54
    4855      similarityModeSelector.SelectedIndex = 0; // set default similarity mode to "exact"
    4956    }
     
    6168      genealogyGraphChart.GenealogyGraphNodeClicked += graphChart_GenealogyGraphNodeClicked;
    6269      symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += treeChart_SymbolicExpressionTreeNodeClicked;
     70      symbolicExpressionTreeChart.SymbolicExpressionTreeNodeDoubleClicked += treeChart_SymbolicExpressionTreeNodeDoubleClicked;
    6371    }
    6472
     
    7179      else {
    7280        genealogyGraphChart.Graph = Content;
    73         var best = Content.Values.OrderByDescending(x => genealogyGraphChart.Graph[x].Quality).First();
    74         symbolicExpressionTreeChart.Tree = (ISymbolicExpressionTree)best.Data;
     81        var best = Content.Nodes.OrderByDescending(x => x.Quality).First();
     82        symbolicExpressionTreeChart.Tree = best.SymbolicExpressionTree;
    7583      }
    7684    }
     
    9199      // the type hierarchy goes like this: VisualGenealogyGraphNode --> GenealogyGraphNode --> symbolicExpressionTree
    92100      var visualGenealogyGraphNode = (VisualGenealogyGraphNode)sender;
    93       var genealogyGraphNode = (GenealogyGraphNode)visualGenealogyGraphNode.Data;
    94       symbolicExpressionTreeChart.Tree = (ISymbolicExpressionTree)genealogyGraphNode.Data;
     101      var genealogyGraphNode = (SymbolicExpressionGenealogyGraphNode)visualGenealogyGraphNode.Data;
     102      symbolicExpressionTreeChart.Tree = genealogyGraphNode.SymbolicExpressionTree;
    95103      // highlight the relevant fragment in the symbolic expression tree
    96       if (_selectedVisualSymbolicExpressionTreeNode != null) {
     104      selectedVisualSymbExprTreeNode = null;
     105
     106      bool repaint = false;
     107
     108      // paint highlighted nodes in symbolic expression tree
     109      if (selectedVisualSymbExprTreeNode != null) {
     110        // clear selected subtree from the tree chart
    97111        var nodes = symbolicExpressionTreeChart.Tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    98         var fragments = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    99         int index = SymbolicExpressionTreeMatching.FindMatch(nodes, fragments, similarityModeSelector.SelectedIndex);
     112        var fragments = selectedVisualSymbExprTreeNode.SymbolicExpressionTreeNode.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
     113        var similarityLevel = Enum.GetNames(typeof(SimilarityLevel))[similarityModeSelector.SelectedIndex];
     114        int index = SymbolicExpressionTreeMatching.FindMatch(nodes, fragments, (SimilarityLevel)Enum.Parse(typeof(SimilarityLevel), similarityLevel));
    100115        if (index != -1) {
    101           _selectedVisualSymbolicExpressionTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(nodes[index]);
    102           var subtree = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode;
    103           foreach (var visualNode in subtree.IterateNodesBreadth().Select(node => symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node))) {
    104             visualNode.FillColor = Color.LightBlue;
    105           }
    106           symbolicExpressionTreeChart.Repaint();
     116          selectedVisualSymbExprTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(nodes[index]);
     117          var subtree = selectedVisualSymbExprTreeNode.SymbolicExpressionTreeNode;
     118          foreach (var node in subtree.IterateNodesBreadth()) {
     119            var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     120            visualNode.LineColor = Color.Blue;
     121          }
     122          repaint = true;
    107123        }
    108124      }
     125      // paint graph nodes
    109126      var tree = symbolicExpressionTreeChart.Tree;
    110       var graphNode = Content.GetNode(tree);
    111       if (graphNode.InEdges != null) {
    112         var arc = graphNode.InEdges.Find(a => a.Data != null);
    113         if (arc != null) {
    114           var fragment = arc.Data as ISymbolicExpressionTreeNode;
    115           foreach (var node in fragment.IterateNodesBreadth()) {
    116             var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
    117             if (visualNode == null)
    118               continue;
    119             visualNode.FillColor = Color.LightGreen;
    120           }
    121           symbolicExpressionTreeChart.Repaint();
    122         }
    123       }
     127      var graphNodes = Content.Nodes.Where(n => n.SymbolicExpressionTree == tree).ToList();
     128      if (graphNodes.Count > 0) {
     129        foreach (var graphNode in graphNodes)
     130          if (graphNode != null && graphNode.InEdges != null) {
     131            var arc = graphNode.InEdges.Find(a => a.Data != null);
     132            if (arc != null) {
     133              var fragment = arc.Data as ISymbolicExpressionTreeNode;
     134              foreach (var node in fragment.IterateNodesBreadth()) {
     135                var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     136                if (visualNode == null)
     137                  continue;
     138                visualNode.LineColor = Color.Orange;
     139              }
     140            }
     141            repaint = true;
     142          }
     143      }
     144      if (repaint)
     145        symbolicExpressionTreeChart.Repaint();
    124146    }
    125147
     
    140162
    141163    private void treeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    142       _selectedVisualSymbolicExpressionTreeNode = (VisualSymbolicExpressionTreeNode)sender;
    143       // find out which individuals in the genealogy graph contain this specific subtree
    144       var treeNode = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode;
     164      ISymbolicExpressionTreeNode selectedSubtree = null;
     165      genealogyGraphChart.Chart.UpdateEnabled = false;
     166      switch (e.Button) {
     167        case MouseButtons.Left: {
     168            selectedVisualSymbExprTreeNode = (VisualSymbolicExpressionTreeNode)sender;
     169            if (selectedVisualSymbExprTreeNode == null) return;
     170            // find out which individuals in the genealogy graph contain this specific subtree
     171            selectedSubtree = selectedVisualSymbExprTreeNode.SymbolicExpressionTreeNode;
     172            // clone every node in the selected subtree so that edit operations are possible without altering the original subtree
     173            // save the originalNode-->clone mapping to make it easier to work with subtrees
     174            if (clonedNodeMap == null)
     175              clonedNodeMap = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
     176            clonedNodeMap.Clear();
     177            var selectedSubtreeClone = selectedSubtree.Clone() as SymbolicExpressionTreeNode;
     178            var subtreeNodes = selectedSubtree.IterateNodesPostfix().ToList();
     179            var cloneNodes = selectedSubtreeClone.IterateNodesPostfix().ToList();
     180            for (int i = 0; i != subtreeNodes.Count; ++i)
     181              clonedNodeMap.Add(subtreeNodes[i], cloneNodes[i]);
     182            // highlight subtree nodes in the tree chart
     183            foreach (var node in symbolicExpressionTreeChart.Tree.IterateNodesPostfix()) {
     184              var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     185              visualNode.FillColor = Color.Transparent;
     186            }
     187            selectedSubtree.ForEachNodePostfix(node => {
     188              symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node).FillColor = Color.LightBlue;
     189            });
     190          }
     191          break;
     192        case MouseButtons.Middle: {
     193            var visualNode = (VisualSymbolicExpressionTreeNode)sender;
     194            if (selectedVisualSymbExprTreeNode == null || selectedVisualSymbExprTreeNode == visualNode)
     195              return;
     196            selectedSubtree = clonedNodeMap[selectedVisualSymbExprTreeNode.SymbolicExpressionTreeNode];
     197            var selectedNode = visualNode.SymbolicExpressionTreeNode;
     198            if (clonedNodeMap.ContainsKey(selectedNode)) {
     199              var selected = clonedNodeMap[selectedNode];
     200              var parent = selected.Parent;
     201              parent.RemoveSubtree(parent.IndexOfSubtree(selected));
     202              selectedNode.ForEachNodePostfix(node => {
     203                symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node).FillColor = Color.Transparent;
     204                clonedNodeMap.Remove(node);
     205              });
     206            }
     207          }
     208          break;
     209      }
     210      // update visual graph nodes that contain matching trees
    145211      Color[] colors = { Color.LightSkyBlue, Color.PaleGreen, Color.Tan };
    146       // update visual graph nodes
    147       genealogyGraphChart.Chart.UpdateEnabled = false;
    148212      genealogyGraphChart.ClearAllNodes(); // clear node colors
    149       // color each graph node according to the degree to which it matches the selected tree fragment
    150       foreach (var i in Enum.GetValues(typeof(SymbolicExpressionTreeMatching.SimilarityLevel)).Cast<int>().Reverse()) {
    151         var owners = genealogyGraphChart.Graph.TraceFragment(treeNode, i).ToList();
    152         if (owners.Any()) genealogyGraphChart.HighlightNodes(owners, colors[i]); // highlight matching individuals from the genealogy
     213      // color each graph node according to the degree to which it matches the selected tree fragment
     214      var similarityValues = Enum.GetValues(typeof(SimilarityLevel)).Cast<SimilarityLevel>().ToList();
     215      foreach (var graphNode in genealogyGraphChart.Graph.Nodes) {
     216        var tree = graphNode.SymbolicExpressionTree;
     217        for (int i = 0; i != similarityValues.Count; ++i) {
     218          if (tree.ContainsFragment(selectedSubtree, similarityValues[i])) {
     219            genealogyGraphChart.HighlightNode(graphNode, colors[i]);
     220            break;
     221          }
     222        }
    153223      }
    154224      genealogyGraphChart.Chart.UpdateEnabled = true;
    155225      genealogyGraphChart.Chart.EnforceUpdate();
    156 
    157       // highlight subtree nodes in the tree chart
    158       foreach (var visualNode in symbolicExpressionTreeChart.Tree.IterateNodesPostfix().Select(node => symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node)))
    159         visualNode.FillColor = Color.Transparent;
    160 
    161       foreach (var visualNode in treeNode.IterateNodesPostfix().Select(node => symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node)))
    162         visualNode.FillColor = Color.LightBlue;
    163 
    164226      // refresh the tree chart
    165227      symbolicExpressionTreeChart.Repaint();
    166228    }
    167229
     230    private void treeChart_SymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
     231    }
     232
    168233    private void similarityModeSelector_SelectedIndexChanged(object sender, EventArgs e) {
    169       if (_selectedVisualSymbolicExpressionTreeNode == null) return;
    170       var treeNode = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode;
    171       var owners = genealogyGraphChart.Graph.TraceFragment(treeNode, similarityModeSelector.SelectedIndex).ToList();
     234      if (selectedVisualSymbExprTreeNode == null) return;
     235      var treeNode = selectedVisualSymbExprTreeNode.SymbolicExpressionTreeNode;
     236      var similarityLevel = Enum.GetNames(typeof(SimilarityLevel))[similarityModeSelector.SelectedIndex];
     237      var owners = genealogyGraphChart.Graph.TraceFragment(treeNode, (SimilarityLevel)Enum.Parse(typeof(SimilarityLevel), similarityLevel)).ToList();
    172238      if (owners.Any()) {
    173239        genealogyGraphChart.Chart.UpdateEnabled = false;
    174240        genealogyGraphChart.ClearAllNodes(); // clear the fill color of all nodes
    175         genealogyGraphChart.HighlightNodes(owners, Color.LightSkyBlue); // highlight matching individuals from the genealogy
     241        genealogyGraphChart.HighlightNodes(owners, Color.LightSkyBlue);
     242        // highlight matching individuals from the genealogy
    176243        genealogyGraphChart.Chart.UpdateEnabled = true;
    177244      }
    178245      genealogyGraphChart.Chart.EnforceUpdate();
    179246      // highlight subtree nodes in the tree chart
    180       foreach (var visualNode in symbolicExpressionTreeChart.Tree.IterateNodesPostfix().Select(node => symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node)))
     247      foreach (var node in symbolicExpressionTreeChart.Tree.IterateNodesPostfix()) {
     248        var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
    181249        visualNode.FillColor = Color.Transparent;
    182       foreach (var visualNode in treeNode.IterateNodesPostfix().Select(node => symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node)))
     250      }
     251      foreach (var node in treeNode.IterateNodesPostfix()) {
     252        var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
    183253        visualNode.FillColor = Color.LightBlue;
     254      }
    184255    }
    185256    #endregion
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/HeuristicLab.EvolutionaryTracking.Views-3.4.csproj

    r8213 r8556  
    4141      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
    4242    </Reference>
     43    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    4344    <Reference Include="HeuristicLab.Core-3.3">
    4445      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/VisualGenealogyGraphNode.cs

    r8248 r8556  
    2727namespace HeuristicLab.EvolutionaryTracking.Views {
    2828  public class VisualGenealogyGraphNode : Ellipse {
    29     public GenealogyGraphNode Data { get; internal set; }
     29    public IGenealogyGraphNode Data { get; internal set; }
    3030    private List<VisualGenealogyGraphArc> _incomingArcs = new List<VisualGenealogyGraphArc>();
    3131    private List<VisualGenealogyGraphArc> _outgoingArgs = new List<VisualGenealogyGraphArc>();
     
    7474      get { return new PointD((LowerLeft.X + UpperRight.X) / 2, (LowerLeft.Y + UpperRight.Y) / 2); }
    7575    }
     76
     77    public override void Draw(Graphics graphics) {
     78      Point p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height));
     79      Size s = Chart.TransformWorldToPixel(Size);
     80      if (Brush != null)
     81        graphics.FillEllipse(Brush, p.X, p.Y, s.Width, s.Height);
     82      graphics.DrawEllipse(Pen, p.X, p.Y, s.Width, s.Height);
     83      if (((SymbolicExpressionGenealogyGraphNode)Data).IsElite) {
     84        graphics.DrawEllipse(Pen, p.X + 2, p.Y + 2, s.Width - 4, s.Height - 4);
     85      }
     86    }
    7687  }
    7788}
Note: See TracChangeset for help on using the changeset viewer.