Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/08/14 17:23:51 (10 years ago)
Author:
bburlacu
Message:

#1772: Improved FragmentGraphView.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs

    r10729 r10730  
    3838    public int PreferredNodeHeight { get; set; }
    3939
     40    private Size size;
    4041    public Size Size {
    41       get {
    42         int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
    43 
    44         foreach (var p in Primitives.OfType<RectangularPrimitiveBase>()) {
    45           if (xmin > p.LowerLeft.X) xmin = (int)Math.Floor(p.LowerLeft.X);
    46           if (xmax < p.UpperRight.X) xmax = (int)Math.Ceiling(p.UpperRight.X);
    47           if (ymin > p.LowerLeft.Y) ymin = (int)Math.Floor(p.LowerLeft.Y);
    48           if (ymax < p.UpperRight.Y) ymax = (int)Math.Ceiling(p.UpperRight.Y);
    49         }
    50 
    51         return new Size(xmax - xmin, ymax - ymin);
    52       }
     42      private set { size = value; }
     43      get { return size; }
    5344    }
    5445
     
    123114      LayoutEngine.NodeHeight = PreferredNodeHeight;
    124115
    125       var visualNodes = LayoutEngine.CalculateLayout(actualRoot);
     116      var visualNodes = LayoutEngine.CalculateLayout(actualRoot).ToList();
    126117
    127118      var font = new Font(FontFamily.GenericSansSerif, 10, GraphicsUnit.Pixel);
     
    157148        }
    158149      }
    159 
    160       // add a bounding rectangle and flip primitives vertically
     150      int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
     151      foreach (var rpb in Primitives.OfType<RectangularPrimitiveBase>()) {
     152        if (xmin > rpb.LowerLeft.X) xmin = (int)Math.Floor(rpb.LowerLeft.X);
     153        if (xmax < rpb.UpperRight.X) xmax = (int)Math.Ceiling(rpb.UpperRight.X);
     154        if (ymin > rpb.LowerLeft.Y) ymin = (int)Math.Floor(rpb.LowerLeft.Y);
     155        if (ymax < rpb.UpperRight.Y) ymax = (int)Math.Ceiling(rpb.UpperRight.Y);
     156      }
     157      Size = new Size(xmax - xmin, ymax - ymin);
     158      var width = Size.Width;
     159      var height = Size.Height;
    161160      // draw a rectangle to mark the countour of this tile
    162       var size = this.Size;
    163       var height = size.Height;
    164       var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(size.Width, size.Height)) {
     161      var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(width, height)) {
    165162        Pen = new Pen(Color.Gray),
    166163        Brush = new SolidBrush(Color.Transparent)
     
    168165      this.Add(rectangle);
    169166
     167      // flip primitives vertically
    170168      foreach (var primitive in Primitives) {
    171169        var rpb = primitive as RectangularPrimitiveBase;
    172170        if (rpb != null) {
    173171          rpb.SetPosition(rpb.LowerLeft.X, height - rpb.UpperRight.Y, rpb.UpperRight.X, height - rpb.LowerLeft.Y);
     172
    174173        } else {
    175174          var line = primitive as LinearPrimitiveBase;
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r10650 r10730  
    196196        // new node has been selected, clean up
    197197        Chart.UpdateEnabled = false;
    198         if (ModifierKeys != Keys.Shift)
     198        if (ModifierKeys != Keys.Shift) {
    199199          // clear colors
    200200          ClearPrimitives();
     201        }
    201202        // use a rectangle to highlight the currently selected genealogy graph node
    202203        var gNode = SelectedVisualNode.Data;
     
    222223    #endregion
    223224
    224     private void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) {
     225    private static void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) {
    225226      if (node.Brush != null) return;
    226227      node.Brush = new SolidBrush(node.Data.GetColor());
    227       var arcs = arcSelector(node);
    228       if (arcs == null) return;
    229 
     228      var arcs = arcSelector(node).ToList();
    230229      foreach (var arc in arcs) {
    231230        var source = arc.Source.Data;
     
    235234        arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
    236235        arc.Pen.Color = Color.Transparent;
    237         //        arc.Pen.FontBrush = new SolidBrush(Color.DarkGray);
     236        //        if (arc == arcs[0]) { arc.Pen.Width = 2; } // mark connection to the root parent
    238237        DrawLineage(nodeSelector(arc), arcSelector, nodeSelector);
    239238      }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/VisualGenealogyGraphNode.cs

    r10271 r10730  
    7070    }
    7171
    72     public override void SetPosition(PointD lowLeft, PointD upRight) {
    73       base.SetPosition(lowLeft, upRight);
     72    public override void SetPosition(PointD lowerLeft, PointD upperRight) {
     73      base.SetPosition(lowerLeft, upperRight);
    7474      foreach (var a in IncomingArcs) a.UpdatePosition();
    7575      foreach (var a in OutgoingArcs) a.UpdatePosition();
     
    8383      Point p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height));
    8484      Size s = Chart.TransformWorldToPixel(Size);
    85       if (Brush != null)
     85      if (Brush != null) {
    8686        graphics.FillEllipse(Brush, p.X, p.Y, s.Width, s.Height);
    87       graphics.DrawEllipse(Pen, p.X, p.Y, s.Width, s.Height);
    88       if (Data.IsElite) {
    89         graphics.DrawEllipse(Pen, p.X + 2, p.Y + 2, s.Width - 4, s.Height - 4);
     87        graphics.DrawEllipse(Pen, p.X, p.Y, s.Width, s.Height);
     88        if (Data.IsElite) {
     89          graphics.DrawEllipse(Pen, p.X + 2, p.Y + 2, s.Width - 4, s.Height - 4);
     90        }
    9091      }
    9192    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/FragmentGraphView.cs

    r10729 r10730  
    77using HeuristicLab.EvolutionTracking;
    88using HeuristicLab.MainForm;
     9using HeuristicLab.Visualization;
    910
    1011namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
     
    5960
    6061    private void Draw() {
    61       var root = Content.Nodes.First();
    62 
     62      var chart = symbolicExpressionChartControl.Chart;
     63      var nodes = Content.Nodes.ToList();
     64      var root = nodes[0];
    6365      var fragmentRoot = tileDictionary[root];
    6466      int maxTileWidth = 0, maxTileHeight = 0;
    65       foreach (var tile in Content.Nodes.Select(x => tileDictionary[x].Tile)) {
     67      var tiles = nodes.Select(x => tileDictionary[x].Tile).ToList();
     68
     69      foreach (var tile in tiles) {
    6670        var size = tile.Size;
    6771        if (maxTileWidth < size.Width) maxTileWidth = size.Width;
     
    8084        tile.Position = new Point(visualNode.X, visualNode.Y);
    8185        symbolicExpressionChartControl.Add(tile);
     86      }
     87
     88      // add connections between the tiles
     89      foreach (var node in nodes) {
     90        var aTile = tileDictionary[node].Tile;
     91        var aSize = aTile.Size;
     92        var aPos = aTile.Position;
     93
     94        var lowerLeftMarker = new FixedSizeCircle(chart, aTile.Position, 5, new Pen(Color.Red), new SolidBrush(Color.Transparent));
     95        var upperRightMarker = new FixedSizeCircle(chart, new PointD(aPos.X + aSize.Width, aPos.Y + aSize.Height), 5,
     96          new Pen(Color.Blue), new SolidBrush(Color.Transparent));
     97        symbolicExpressionChartControl.Add(lowerLeftMarker); symbolicExpressionChartControl.Add(upperRightMarker);
     98
     99        foreach (var child in node.Children) {
     100          var bTile = tileDictionary[child].Tile;
     101          var bSize = bTile.Size;
     102          var bPos = bTile.Position;
     103
     104          var line = new Line(chart, new PointD(aPos.X + aSize.Width / 2.0, aPos.Y + aSize.Height), new PointD(bPos.X + bSize.Width / 2.0, bPos.Y));
     105          symbolicExpressionChartControl.Add(line);
     106        }
    82107      }
    83108      //      symbolicExpressionChartControl.FlipVertical();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymboldDataAnalysisGenealogyView.cs

    r10725 r10730  
    8282      symbolicExpressionTreeChart.Tree = tree;
    8383
    84       if (graphNode.InArcs != null) {
     84      if (graphNode.InArcs.Any()) {
    8585        var fragment = (IFragment<ISymbolicExpressionTreeNode>)graphNode.InArcs.Last().Data;
    8686        treeChart_HighlightSubtree(fragment.Root);
Note: See TracChangeset for help on using the changeset viewer.