Changeset 15561


Ignore:
Timestamp:
12/29/17 16:43:29 (12 months ago)
Author:
bburlacu
Message:

#1772: Refactor SymbolicDataAnalysisGenealogyGraphView

Location:
branches/HeuristicLab.EvolutionTracking
Files:
7 edited

Legend:

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

    r13877 r15561  
    3232  public partial class GenealogyGraphChart : ChartControl {
    3333    private IGenealogyGraph genealogyGraph;
    34     private const double XIncrement = 30;
    35     private const double YIncrement = 30;
     34    private const double XIncrement = 25;
     35    private const double YIncrement = 25;
    3636    private const double Diameter = 20;
    3737    private readonly Brush defaultBrush;
     
    4444    public bool SimpleLineages { get; set; }
    4545    public bool LockGenealogy { get; set; }
    46     public bool TraceFragments { get; set; }
     46    public Func<IGenealogyGraphNode, Color> ColorSelector { get; set; }
    4747    #endregion
    4848
     
    9898    }
    9999
    100     public GenealogyGraphChart() : base(new Chart(0, 0, 800, 600)) {
     100    public GenealogyGraphChart() : base(new GridlessChart(0, 0, 800, 600)) {
    101101      InitializeComponent();
    102102      AddChartModes(new PanChartMode(this), new ZoomInChartMode(this), new ZoomOutChartMode(this), new SelectChartMode(this));
    103103      defaultBrush = new SolidBrush(Color.Transparent);
    104104      defaultPen = new Pen(Color.DarkGray);
     105
     106      ColorSelector = node => ColorGradient.Colors[(int)Math.Round(node.Quality * 255)];
    105107    }
    106108
     
    114116
    115117      foreach (var rank in ranks) {
     118        var rect = new Visualization.Rectangle(Chart, new PointD(x, y), new PointD(x + diameter, y + diameter));
     119        var font = new Font(FontFamily.GenericSansSerif, 12);
     120        var genLabel = new LabeledPrimitive(rect, rank.Rank.ToString(), font);
     121        Chart.Group.Add(genLabel);
     122
     123        x += xIncrement;
     124
    116125        var nodes = rank.Nodes.ToList();
    117126        nodes.Sort((a, b) => b.CompareTo(a)); // sort descending by quality
     
    119128
    120129        foreach (var node in nodes) {
    121           var brush = new SolidBrush(node.GetColor());
     130          var brush = new SolidBrush(ColorSelector(node));
    122131          var visualNode = new VisualGenealogyGraphNode(Chart, x, y, x + diameter, y + diameter, defaultPen, brush) {
    123132            Data = node,
     
    199208        var visualNode = GetMappedNode(graphNode);
    200209
    201         DrawLineage(visualNode, n => SimpleLineages ? n.IncomingArcs.Take(1) : n.IncomingArcs, a => a.Source);
     210        DrawLineage(visualNode, n => SimpleLineages ? n.IncomingArcs.Take(1) : n.IncomingArcs, a => a.Source, ColorSelector);
    202211        ((SolidBrush)visualNode.Brush).Color = Color.Transparent;
    203         DrawLineage(visualNode, n => n.OutgoingArcs, a => a.Target);
     212        DrawLineage(visualNode, n => n.OutgoingArcs, a => a.Target, ColorSelector);
    204213      }
    205214
     
    212221
    213222    #region drawing routines
    214     private static void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) {
     223    private static void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector, Func<IGenealogyGraphNode, Color> getNodeColor) {
    215224      var brush = (SolidBrush)node.Brush;
    216225      if (brush.Color != Color.Transparent) return; // this lineage was already drawn (avoid redrawing common ancestors)
    217       brush.Color = node.Data.GetColor();
     226      brush.Color = getNodeColor(node.Data);
    218227      var arcs = arcSelector(node);
    219228      var pen = new Pen(Color.Transparent);
     
    224233        var end = new Point((int)arc.End.X, (int)arc.End.Y);
    225234        arc.Pen = pen;
    226         arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
    227         DrawLineage(nodeSelector(arc), arcSelector, nodeSelector);
     235        arc.Pen.Brush = new LinearGradientBrush(start, end, getNodeColor(source), getNodeColor(target));
     236        DrawLineage(nodeSelector(arc), arcSelector, nodeSelector, getNodeColor);
    228237      }
    229238    }
     
    287296      foreach (var node in nodes) {
    288297        var graphNode = GetMappedNode(node);
    289         graphNode.Brush = new SolidBrush(node.GetColor());
     298        graphNode.Brush = new SolidBrush(ColorSelector(node));
    290299      }
    291300    }
     
    302311    public void HighlightAll() {
    303312      foreach (var visualNode in nodeMap.Values) {
    304         visualNode.Brush = new SolidBrush(visualNode.Data.GetColor());
    305       }
     313        visualNode.Brush = new SolidBrush(ColorSelector(visualNode.Data));
     314        Chart.IntoForeground(visualNode);
     315      }
     316      // draw arcs first and then nodes
    306317      foreach (var arc in arcMap.Values) {
    307318        var source = arc.Source.Data;
     
    309320        var start = new Point((int)arc.Start.X, (int)arc.Start.Y);
    310321        var end = new Point((int)arc.End.X, (int)arc.End.Y);
    311         arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
     322        arc.Pen = new Pen(new LinearGradientBrush(start, end, ColorSelector(source), ColorSelector(target)));
     323        Chart.IntoBackground(arc);
    312324      }
    313325    }
     
    319331      var end = new Point((int)arc.End.X, (int)arc.End.Y);
    320332      arc.Pen = new Pen(Color.Transparent);
    321       arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
     333      arc.Pen = new Pen(new LinearGradientBrush(start, end, ColorSelector(source), ColorSelector(target)));
     334      Chart.IntoBackground(arc);
    322335    }
    323336    #endregion
    324   }
    325 
    326   internal static class Util {
    327     public static Color GetColor(this IGenealogyGraphNode node) {
    328       if (double.IsNaN(node.Quality))
    329         return ColorGradient.Colors[0];
    330       var colorIndex = (int)Math.Round(node.Quality * ColorGradient.Colors.Count);
    331       if (colorIndex >= ColorGradient.Colors.Count) return ColorGradient.Colors.Last();
    332       return ColorGradient.Colors[colorIndex];
     337
     338    // workaround to disable the chart grid
     339    private class GridlessChart : Chart {
     340      public GridlessChart(PointD lowerLeft, PointD upperRight) : base(lowerLeft, upperRight) {
     341        Grid = null;
     342      }
     343
     344      public GridlessChart(double x1, double y1, double x2, double y2) : this(new PointD(x1, y1), new PointD(x2, y2)) { }
    333345    }
    334346  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.Designer.cs

    r13061 r15561  
    2626    private void InitializeComponent() {
    2727      this.splitContainer = new System.Windows.Forms.SplitContainer();
     28      this.genealogyGraphChart = new HeuristicLab.EvolutionTracking.Views.GenealogyGraphChart();
    2829      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    29       this.groupBox = new System.Windows.Forms.GroupBox();
    30       this.openNew_CheckBox = new System.Windows.Forms.CheckBox();
    31       this.lockGraph_checkBox = new System.Windows.Forms.CheckBox();
    32       this.simpleLineages_checkBox = new System.Windows.Forms.CheckBox();
    33       this.trace_checkBox = new System.Windows.Forms.CheckBox();
    34       this.genealogyGraphChart = new HeuristicLab.EvolutionTracking.Views.GenealogyGraphChart();
    3530      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    3631      this.splitContainer.Panel1.SuspendLayout();
    3732      this.splitContainer.Panel2.SuspendLayout();
    3833      this.splitContainer.SuspendLayout();
    39       this.groupBox.SuspendLayout();
    4034      this.SuspendLayout();
    4135      //
     
    4539            | System.Windows.Forms.AnchorStyles.Left)
    4640            | System.Windows.Forms.AnchorStyles.Right)));
    47       this.splitContainer.Location = new System.Drawing.Point(3, 55);
     41      this.splitContainer.Location = new System.Drawing.Point(3, 3);
    4842      this.splitContainer.Name = "splitContainer";
    4943      //
     
    5549      //
    5650      this.splitContainer.Panel2.Controls.Add(this.viewHost);
    57       this.splitContainer.Size = new System.Drawing.Size(1394, 742);
    58       this.splitContainer.SplitterDistance = 694;
     51      this.splitContainer.Size = new System.Drawing.Size(1404, 794);
     52      this.splitContainer.SplitterDistance = 698;
    5953      this.splitContainer.TabIndex = 0;
     54      //
     55      // genealogyGraphChart
     56      //
     57      this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     58            | System.Windows.Forms.AnchorStyles.Left)
     59            | System.Windows.Forms.AnchorStyles.Right)));
     60      this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
     61      this.genealogyGraphChart.GenealogyGraph = null;
     62      this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
     63      this.genealogyGraphChart.LockGenealogy = false;
     64      this.genealogyGraphChart.Mode = null;
     65      this.genealogyGraphChart.Name = "genealogyGraphChart";
     66      this.genealogyGraphChart.ScaleOnResize = true;
     67      this.genealogyGraphChart.SelectedGraphNode = null;
     68      this.genealogyGraphChart.ShowToolBar = true;
     69      this.genealogyGraphChart.SimpleLineages = false;
     70      this.genealogyGraphChart.Size = new System.Drawing.Size(693, 790);
     71      this.genealogyGraphChart.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
     72      this.genealogyGraphChart.TabIndex = 0;
    6073      //
    6174      // viewHost
     
    7184      this.viewHost.Name = "viewHost";
    7285      this.viewHost.ReadOnly = false;
    73       this.viewHost.Size = new System.Drawing.Size(697, 743);
     86      this.viewHost.Size = new System.Drawing.Size(703, 795);
    7487      this.viewHost.TabIndex = 0;
    7588      this.viewHost.ViewsLabelVisible = true;
    7689      this.viewHost.ViewType = null;
    77       //
    78       // groupBox
    79       //
    80       this.groupBox.Controls.Add(this.openNew_CheckBox);
    81       this.groupBox.Controls.Add(this.lockGraph_checkBox);
    82       this.groupBox.Controls.Add(this.simpleLineages_checkBox);
    83       this.groupBox.Controls.Add(this.trace_checkBox);
    84       this.groupBox.Location = new System.Drawing.Point(3, 4);
    85       this.groupBox.Name = "groupBox";
    86       this.groupBox.Size = new System.Drawing.Size(602, 44);
    87       this.groupBox.TabIndex = 1;
    88       this.groupBox.TabStop = false;
    89       this.groupBox.Text = "Genealogy Options";
    90       //
    91       // openNew_CheckBox
    92       //
    93       this.openNew_CheckBox.AutoSize = true;
    94       this.openNew_CheckBox.Location = new System.Drawing.Point(485, 19);
    95       this.openNew_CheckBox.Name = "openNew_CheckBox";
    96       this.openNew_CheckBox.Size = new System.Drawing.Size(111, 17);
    97       this.openNew_CheckBox.TabIndex = 1;
    98       this.openNew_CheckBox.Text = "Open in new view";
    99       this.openNew_CheckBox.UseVisualStyleBackColor = true;
    100       //
    101       // lockGraph_checkBox
    102       //
    103       this.lockGraph_checkBox.Appearance = System.Windows.Forms.Appearance.Button;
    104       this.lockGraph_checkBox.AutoSize = true;
    105       this.lockGraph_checkBox.Location = new System.Drawing.Point(157, 15);
    106       this.lockGraph_checkBox.Name = "lockGraph_checkBox";
    107       this.lockGraph_checkBox.Size = new System.Drawing.Size(73, 23);
    108       this.lockGraph_checkBox.TabIndex = 0;
    109       this.lockGraph_checkBox.Text = "Lock Graph";
    110       this.lockGraph_checkBox.UseVisualStyleBackColor = true;
    111       this.lockGraph_checkBox.CheckedChanged += new System.EventHandler(this.lockGraph_checkBox_CheckedChanged);
    112       //
    113       // simpleLineages_checkBox
    114       //
    115       this.simpleLineages_checkBox.Appearance = System.Windows.Forms.Appearance.Button;
    116       this.simpleLineages_checkBox.AutoSize = true;
    117       this.simpleLineages_checkBox.Location = new System.Drawing.Point(57, 15);
    118       this.simpleLineages_checkBox.Name = "simpleLineages_checkBox";
    119       this.simpleLineages_checkBox.Size = new System.Drawing.Size(94, 23);
    120       this.simpleLineages_checkBox.TabIndex = 0;
    121       this.simpleLineages_checkBox.Text = "Simple Lineages";
    122       this.simpleLineages_checkBox.UseVisualStyleBackColor = true;
    123       this.simpleLineages_checkBox.CheckedChanged += new System.EventHandler(this.simpleLineages_checkBox_CheckedChanged);
    124       //
    125       // trace_checkBox
    126       //
    127       this.trace_checkBox.Appearance = System.Windows.Forms.Appearance.Button;
    128       this.trace_checkBox.AutoSize = true;
    129       this.trace_checkBox.Location = new System.Drawing.Point(6, 15);
    130       this.trace_checkBox.Name = "trace_checkBox";
    131       this.trace_checkBox.Size = new System.Drawing.Size(45, 23);
    132       this.trace_checkBox.TabIndex = 0;
    133       this.trace_checkBox.Text = "Trace";
    134       this.trace_checkBox.UseVisualStyleBackColor = true;
    135       this.trace_checkBox.CheckedChanged += new System.EventHandler(this.trace_checkBox_CheckedChanged);
    136       //
    137       // genealogyGraphChart
    138       //
    139       this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    140             | System.Windows.Forms.AnchorStyles.Left)
    141             | System.Windows.Forms.AnchorStyles.Right)));
    142       this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
    143       this.genealogyGraphChart.GenealogyGraph = null;
    144       this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
    145       this.genealogyGraphChart.LockGenealogy = false;
    146       this.genealogyGraphChart.Name = "genealogyGraphChart";
    147       this.genealogyGraphChart.ScaleOnResize = true;
    148       this.genealogyGraphChart.SelectedGraphNode = null;
    149       this.genealogyGraphChart.SimpleLineages = false;
    150       this.genealogyGraphChart.Size = new System.Drawing.Size(689, 738);
    151       this.genealogyGraphChart.TabIndex = 0;
    152       this.genealogyGraphChart.TraceFragments = false;
    15390      //
    15491      // GenealogyGraphView
     
    15693      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    15794      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    158       this.Controls.Add(this.groupBox);
    15995      this.Controls.Add(this.splitContainer);
    16096      this.Name = "GenealogyGraphView";
    161       this.Size = new System.Drawing.Size(1400, 800);
     97      this.Size = new System.Drawing.Size(1410, 800);
    16298      this.splitContainer.Panel1.ResumeLayout(false);
    16399      this.splitContainer.Panel2.ResumeLayout(false);
    164100      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    165101      this.splitContainer.ResumeLayout(false);
    166       this.groupBox.ResumeLayout(false);
    167       this.groupBox.PerformLayout();
    168102      this.ResumeLayout(false);
    169103
     
    175109    protected MainForm.WindowsForms.ViewHost viewHost;
    176110    protected GenealogyGraphChart genealogyGraphChart;
    177     private System.Windows.Forms.GroupBox groupBox;
    178     protected System.Windows.Forms.CheckBox trace_checkBox;
    179     protected System.Windows.Forms.CheckBox simpleLineages_checkBox;
    180     protected System.Windows.Forms.CheckBox lockGraph_checkBox;
    181     protected System.Windows.Forms.CheckBox openNew_CheckBox;
    182111
    183112  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.cs

    r12225 r15561  
    77  [View("GenealogyGraphView")]
    88  [Content(typeof(IGenealogyGraph<>), IsDefaultView = false)]
    9   public partial class GenealogyGraphView<T> : ItemView where T : class,IItem {
     9  public partial class GenealogyGraphView<T> : ItemView where T : class, IItem {
    1010    public new IGenealogyGraph<T> Content {
    1111      get { return (IGenealogyGraph<T>)base.Content; }
     
    4949      var visualNode = (VisualGenealogyGraphNode)sender;
    5050      var graphNode = (IGenealogyGraphNode<T>)visualNode.Data;
    51       if (graphNode == null) return;
    52       var content = graphNode.Data;
    53       if (content == null) return;
    54       viewHost.Content = content;
     51      if (graphNode == null || graphNode.Data == null) return;
     52      viewHost.Content = graphNode.Data;
    5553    }
    5654    public virtual void graphChart_GenealogyGraphNodeDoubleClicked(object sender, MouseEventArgs arcs) {
     
    6058    #region events for configuring the behavior of the genealogy chart (trace/match, simple lineages, etc)
    6159    private void trace_checkBox_CheckedChanged(object sender, System.EventArgs e) {
    62       genealogyGraphChart.TraceFragments = trace_checkBox.Checked;
     60      //genealogyGraphChart.TraceFragments = trace_checkBox.Checked;
    6361    }
    6462
    6563    private void simpleLineages_checkBox_CheckedChanged(object sender, System.EventArgs e) {
    66       genealogyGraphChart.SimpleLineages = simpleLineages_checkBox.Checked;
     64      //genealogyGraphChart.SimpleLineages = simpleLineages_checkBox.Checked;
    6765    }
    6866
    6967    private void lockGraph_checkBox_CheckedChanged(object sender, System.EventArgs e) {
    70       genealogyGraphChart.LockGenealogy = lockGraph_checkBox.Checked;
     68      //genealogyGraphChart.LockGenealogy = lockGraph_checkBox.Checked;
    7169    }
    7270    #endregion
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj

    r15351 r15561  
    9797  </ItemGroup>
    9898  <ItemGroup>
    99     <Compile Include="GenealogyGraphChart.cs" />
     99    <Compile Include="GenealogyGraphChart.cs">
     100      <SubType>UserControl</SubType>
     101    </Compile>
    100102    <Compile Include="GenealogyGraphChart.Designer.cs">
    101103      <DependentUpon>GenealogyGraphChart.cs</DependentUpon>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.Designer.cs

    r12406 r15561  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.groupBox1 = new System.Windows.Forms.GroupBox();
    48       this.nodeWeightLabel = new System.Windows.Forms.Label();
    49       this.nodeWeightLabelLabel = new System.Windows.Forms.Label();
     47      this.selectedNodeStatusStrip = new System.Windows.Forms.StatusStrip();
     48      this.colorModeLabel = new System.Windows.Forms.Label();
     49      this.nodeColorsComboBox = new System.Windows.Forms.ComboBox();
     50      this.traceCheckBox = new System.Windows.Forms.CheckBox();
     51      this.createNewViewCheckBox = new System.Windows.Forms.CheckBox();
    5052      this.navigateRightButton = new System.Windows.Forms.Button();
    5153      this.navigateLeftButton = new System.Windows.Forms.Button();
    52       this.nodeDegreeLabel = new System.Windows.Forms.Label();
    53       this.nodeDegreeLabelLabel = new System.Windows.Forms.Label();
    54       this.nodeRankLabel = new System.Windows.Forms.Label();
    55       this.nodeRankLabelLabel = new System.Windows.Forms.Label();
    56       this.nodeQualityLabel = new System.Windows.Forms.Label();
    57       this.nodeQualityLabelLabel = new System.Windows.Forms.Label();
    58       this.matchingModeButton = new System.Windows.Forms.CheckBox();
     54      this.lockCheckBox = new System.Windows.Forms.CheckBox();
    5955      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    6056      this.splitContainer.Panel1.SuspendLayout();
    6157      this.splitContainer.Panel2.SuspendLayout();
    6258      this.splitContainer.SuspendLayout();
    63       this.groupBox1.SuspendLayout();
    6459      this.SuspendLayout();
    6560      //
    6661      // splitContainer
    6762      //
    68       this.splitContainer.Size = new System.Drawing.Size(1241, 700);
     63      this.splitContainer.Location = new System.Drawing.Point(3, 31);
     64      //
     65      // splitContainer.Panel1
     66      //
     67      this.splitContainer.Panel1.Controls.Add(this.selectedNodeStatusStrip);
     68      this.splitContainer.Size = new System.Drawing.Size(1241, 721);
    6969      this.splitContainer.SplitterDistance = 617;
    7070      //
    7171      // viewHost
    7272      //
    73       this.viewHost.Size = new System.Drawing.Size(617, 697);
     73      this.viewHost.Size = new System.Drawing.Size(617, 770);
    7474      //
    7575      // genealogyGraphChart
    7676      //
    77       this.genealogyGraphChart.Size = new System.Drawing.Size(614, 697);
    78       //
    79       // groupBox1
    80       //
    81       this.groupBox1.Controls.Add(this.matchingModeButton);
    82       this.groupBox1.Controls.Add(this.nodeWeightLabel);
    83       this.groupBox1.Controls.Add(this.nodeWeightLabelLabel);
    84       this.groupBox1.Controls.Add(this.navigateRightButton);
    85       this.groupBox1.Controls.Add(this.navigateLeftButton);
    86       this.groupBox1.Controls.Add(this.nodeDegreeLabel);
    87       this.groupBox1.Controls.Add(this.nodeDegreeLabelLabel);
    88       this.groupBox1.Controls.Add(this.nodeRankLabel);
    89       this.groupBox1.Controls.Add(this.nodeRankLabelLabel);
    90       this.groupBox1.Controls.Add(this.nodeQualityLabel);
    91       this.groupBox1.Controls.Add(this.nodeQualityLabelLabel);
    92       this.groupBox1.Location = new System.Drawing.Point(624, 4);
    93       this.groupBox1.Name = "groupBox1";
    94       this.groupBox1.Size = new System.Drawing.Size(617, 44);
    95       this.groupBox1.TabIndex = 2;
    96       this.groupBox1.TabStop = false;
    97       this.groupBox1.Text = "Current Node";
    98       //
    99       // nodeWeightLabel
    100       //
    101       this.nodeWeightLabel.AutoSize = true;
    102       this.nodeWeightLabel.Location = new System.Drawing.Point(285, 20);
    103       this.nodeWeightLabel.Name = "nodeWeightLabel";
    104       this.nodeWeightLabel.Size = new System.Drawing.Size(0, 13);
    105       this.nodeWeightLabel.TabIndex = 8;
    106       //
    107       // nodeWeightLabelLabel
    108       //
    109       this.nodeWeightLabelLabel.AutoSize = true;
    110       this.nodeWeightLabelLabel.Location = new System.Drawing.Point(241, 20);
    111       this.nodeWeightLabelLabel.Name = "nodeWeightLabelLabel";
    112       this.nodeWeightLabelLabel.Size = new System.Drawing.Size(44, 13);
    113       this.nodeWeightLabelLabel.TabIndex = 7;
    114       this.nodeWeightLabelLabel.Text = "Weight:";
     77      this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     78      this.genealogyGraphChart.Dock = System.Windows.Forms.DockStyle.Fill;
     79      this.genealogyGraphChart.Size = new System.Drawing.Size(617, 699);
     80      //
     81      // selectedNodeStatusStrip
     82      //
     83      this.selectedNodeStatusStrip.Location = new System.Drawing.Point(0, 699);
     84      this.selectedNodeStatusStrip.Name = "selectedNodeStatusStrip";
     85      this.selectedNodeStatusStrip.Size = new System.Drawing.Size(617, 22);
     86      this.selectedNodeStatusStrip.TabIndex = 1;
     87      this.selectedNodeStatusStrip.Text = "statusStrip1";
     88      //
     89      // colorModeLabel
     90      //
     91      this.colorModeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     92      this.colorModeLabel.AutoSize = true;
     93      this.colorModeLabel.Location = new System.Drawing.Point(453, 9);
     94      this.colorModeLabel.Name = "colorModeLabel";
     95      this.colorModeLabel.Size = new System.Drawing.Size(39, 13);
     96      this.colorModeLabel.TabIndex = 1;
     97      this.colorModeLabel.Text = "Colors:";
     98      //
     99      // nodeColorsComboBox
     100      //
     101      this.nodeColorsComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     102      this.nodeColorsComboBox.FormattingEnabled = true;
     103      this.nodeColorsComboBox.Items.AddRange(new object[] {
     104            "Quality",
     105            "Weight"});
     106      this.nodeColorsComboBox.Location = new System.Drawing.Point(498, 6);
     107      this.nodeColorsComboBox.Name = "nodeColorsComboBox";
     108      this.nodeColorsComboBox.Size = new System.Drawing.Size(62, 21);
     109      this.nodeColorsComboBox.TabIndex = 2;
     110      this.nodeColorsComboBox.Text = "Quality";
     111      this.nodeColorsComboBox.SelectedIndexChanged += new System.EventHandler(this.nodeColorsComboBox_SelectedIndexChanged);
     112      //
     113      // traceCheckBox
     114      //
     115      this.traceCheckBox.AutoSize = true;
     116      this.traceCheckBox.Location = new System.Drawing.Point(3, 8);
     117      this.traceCheckBox.Name = "traceCheckBox";
     118      this.traceCheckBox.Size = new System.Drawing.Size(54, 17);
     119      this.traceCheckBox.TabIndex = 3;
     120      this.traceCheckBox.Text = "Trace";
     121      this.traceCheckBox.UseVisualStyleBackColor = true;
     122      //
     123      // createNewViewCheckBox
     124      //
     125      this.createNewViewCheckBox.AutoSize = true;
     126      this.createNewViewCheckBox.Location = new System.Drawing.Point(63, 8);
     127      this.createNewViewCheckBox.Name = "createNewViewCheckBox";
     128      this.createNewViewCheckBox.Size = new System.Drawing.Size(105, 17);
     129      this.createNewViewCheckBox.TabIndex = 4;
     130      this.createNewViewCheckBox.Text = "Create new view";
     131      this.createNewViewCheckBox.UseVisualStyleBackColor = true;
    115132      //
    116133      // navigateRightButton
    117134      //
     135      this.navigateRightButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    118136      this.navigateRightButton.Image = global::HeuristicLab.Problems.DataAnalysis.Symbolic.Views.Properties.Resources.LargeLeftDiagonal_235;
    119       this.navigateRightButton.Location = new System.Drawing.Point(589, 14);
     137      this.navigateRightButton.Location = new System.Drawing.Point(595, 4);
    120138      this.navigateRightButton.Name = "navigateRightButton";
    121       this.navigateRightButton.Size = new System.Drawing.Size(22, 22);
    122       this.navigateRightButton.TabIndex = 6;
     139      this.navigateRightButton.Size = new System.Drawing.Size(23, 23);
     140      this.navigateRightButton.TabIndex = 5;
    123141      this.navigateRightButton.UseVisualStyleBackColor = true;
    124142      this.navigateRightButton.Click += new System.EventHandler(this.navigateRightButton_Click);
     
    126144      // navigateLeftButton
    127145      //
     146      this.navigateLeftButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    128147      this.navigateLeftButton.Image = global::HeuristicLab.Problems.DataAnalysis.Symbolic.Views.Properties.Resources.LargeRightDiagonal_238;
    129       this.navigateLeftButton.Location = new System.Drawing.Point(561, 14);
     148      this.navigateLeftButton.Location = new System.Drawing.Point(566, 4);
    130149      this.navigateLeftButton.Name = "navigateLeftButton";
    131       this.navigateLeftButton.Size = new System.Drawing.Size(22, 22);
     150      this.navigateLeftButton.Size = new System.Drawing.Size(23, 23);
    132151      this.navigateLeftButton.TabIndex = 6;
    133152      this.navigateLeftButton.UseVisualStyleBackColor = true;
    134153      this.navigateLeftButton.Click += new System.EventHandler(this.navigateLeftButton_Click);
    135154      //
    136       // nodeDegreeLabel
    137       //
    138       this.nodeDegreeLabel.AutoSize = true;
    139       this.nodeDegreeLabel.Location = new System.Drawing.Point(205, 20);
    140       this.nodeDegreeLabel.Name = "nodeDegreeLabel";
    141       this.nodeDegreeLabel.Size = new System.Drawing.Size(0, 13);
    142       this.nodeDegreeLabel.TabIndex = 5;
    143       //
    144       // nodeDegreeLabelLabel
    145       //
    146       this.nodeDegreeLabelLabel.AutoSize = true;
    147       this.nodeDegreeLabelLabel.Location = new System.Drawing.Point(154, 20);
    148       this.nodeDegreeLabelLabel.Name = "nodeDegreeLabelLabel";
    149       this.nodeDegreeLabelLabel.Size = new System.Drawing.Size(45, 13);
    150       this.nodeDegreeLabelLabel.TabIndex = 4;
    151       this.nodeDegreeLabelLabel.Text = "Degree:";
    152       //
    153       // nodeRankLabel
    154       //
    155       this.nodeRankLabel.AutoSize = true;
    156       this.nodeRankLabel.Location = new System.Drawing.Point(123, 20);
    157       this.nodeRankLabel.Name = "nodeRankLabel";
    158       this.nodeRankLabel.Size = new System.Drawing.Size(0, 13);
    159       this.nodeRankLabel.TabIndex = 3;
    160       //
    161       // nodeRankLabelLabel
    162       //
    163       this.nodeRankLabelLabel.AutoSize = true;
    164       this.nodeRankLabelLabel.Location = new System.Drawing.Point(81, 20);
    165       this.nodeRankLabelLabel.Name = "nodeRankLabelLabel";
    166       this.nodeRankLabelLabel.Size = new System.Drawing.Size(36, 13);
    167       this.nodeRankLabelLabel.TabIndex = 2;
    168       this.nodeRankLabelLabel.Text = "Rank:";
    169       //
    170       // nodeQualityLabel
    171       //
    172       this.nodeQualityLabel.AutoSize = true;
    173       this.nodeQualityLabel.Location = new System.Drawing.Point(54, 20);
    174       this.nodeQualityLabel.Name = "nodeQualityLabel";
    175       this.nodeQualityLabel.Size = new System.Drawing.Size(0, 13);
    176       this.nodeQualityLabel.TabIndex = 1;
    177       //
    178       // nodeQualityLabelLabel
    179       //
    180       this.nodeQualityLabelLabel.AutoSize = true;
    181       this.nodeQualityLabelLabel.Location = new System.Drawing.Point(6, 20);
    182       this.nodeQualityLabelLabel.Name = "nodeQualityLabelLabel";
    183       this.nodeQualityLabelLabel.Size = new System.Drawing.Size(42, 13);
    184       this.nodeQualityLabelLabel.TabIndex = 0;
    185       this.nodeQualityLabelLabel.Text = "Quality:";
    186       //
    187       // matchingModeButton
    188       //
    189       this.matchingModeButton.AutoSize = true;
    190       this.matchingModeButton.Checked = true;
    191       this.matchingModeButton.CheckState = System.Windows.Forms.CheckState.Checked;
    192       this.matchingModeButton.Location = new System.Drawing.Point(455, 18);
    193       this.matchingModeButton.Name = "matchingModeButton";
    194       this.matchingModeButton.Size = new System.Drawing.Size(100, 17);
    195       this.matchingModeButton.TabIndex = 9;
    196       this.matchingModeButton.Text = "Exact Matching";
    197       this.matchingModeButton.UseVisualStyleBackColor = true;
     155      // lockCheckBox
     156      //
     157      this.lockCheckBox.AutoSize = true;
     158      this.lockCheckBox.Location = new System.Drawing.Point(174, 8);
     159      this.lockCheckBox.Name = "lockCheckBox";
     160      this.lockCheckBox.Size = new System.Drawing.Size(50, 17);
     161      this.lockCheckBox.TabIndex = 7;
     162      this.lockCheckBox.Text = "Lock";
     163      this.lockCheckBox.UseVisualStyleBackColor = true;
     164      this.lockCheckBox.CheckedChanged += new System.EventHandler(this.lockCheckBox_CheckedChanged);
    198165      //
    199166      // SymbolicDataAnalysisGenealogyGraphView
     
    201168      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    202169      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    203       this.Controls.Add(this.groupBox1);
     170      this.Controls.Add(this.lockCheckBox);
     171      this.Controls.Add(this.navigateLeftButton);
     172      this.Controls.Add(this.navigateRightButton);
     173      this.Controls.Add(this.createNewViewCheckBox);
     174      this.Controls.Add(this.traceCheckBox);
     175      this.Controls.Add(this.nodeColorsComboBox);
     176      this.Controls.Add(this.colorModeLabel);
    204177      this.Name = "SymbolicDataAnalysisGenealogyGraphView";
    205178      this.Size = new System.Drawing.Size(1247, 755);
    206179      this.Controls.SetChildIndex(this.splitContainer, 0);
    207       this.Controls.SetChildIndex(this.groupBox1, 0);
     180      this.Controls.SetChildIndex(this.colorModeLabel, 0);
     181      this.Controls.SetChildIndex(this.nodeColorsComboBox, 0);
     182      this.Controls.SetChildIndex(this.traceCheckBox, 0);
     183      this.Controls.SetChildIndex(this.createNewViewCheckBox, 0);
     184      this.Controls.SetChildIndex(this.navigateRightButton, 0);
     185      this.Controls.SetChildIndex(this.navigateLeftButton, 0);
     186      this.Controls.SetChildIndex(this.lockCheckBox, 0);
    208187      this.splitContainer.Panel1.ResumeLayout(false);
     188      this.splitContainer.Panel1.PerformLayout();
    209189      this.splitContainer.Panel2.ResumeLayout(false);
    210190      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    211191      this.splitContainer.ResumeLayout(false);
    212       this.groupBox1.ResumeLayout(false);
    213       this.groupBox1.PerformLayout();
    214192      this.ResumeLayout(false);
     193      this.PerformLayout();
    215194
    216195    }
    217196
    218197    #endregion
    219 
    220     private System.Windows.Forms.GroupBox groupBox1;
    221     private System.Windows.Forms.Label nodeQualityLabelLabel;
    222     private System.Windows.Forms.Label nodeQualityLabel;
    223     private System.Windows.Forms.Label nodeRankLabelLabel;
    224     private System.Windows.Forms.Label nodeRankLabel;
    225     private System.Windows.Forms.Label nodeDegreeLabel;
    226     private System.Windows.Forms.Label nodeDegreeLabelLabel;
     198    private System.Windows.Forms.StatusStrip selectedNodeStatusStrip;
     199    private System.Windows.Forms.Label colorModeLabel;
     200    private System.Windows.Forms.ComboBox nodeColorsComboBox;
     201    private System.Windows.Forms.CheckBox traceCheckBox;
     202    private System.Windows.Forms.CheckBox createNewViewCheckBox;
    227203    private System.Windows.Forms.Button navigateRightButton;
    228204    private System.Windows.Forms.Button navigateLeftButton;
    229     private System.Windows.Forms.Label nodeWeightLabelLabel;
    230     private System.Windows.Forms.Label nodeWeightLabel;
    231     private System.Windows.Forms.CheckBox matchingModeButton;
     205    private System.Windows.Forms.CheckBox lockCheckBox;
    232206  }
    233207}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.cs

    r13892 r15561  
    103103      lastTd = null;
    104104
    105       nodeQualityLabel.Text = string.Format("{0:0.000}", graphNode.Quality);
    106       nodeRankLabel.Text = string.Format("{0:0.0}", graphNode.Rank);
    107       nodeDegreeLabel.Text = string.Format("{0} / {1}", graphNode.InDegree, graphNode.OutDegree);
    108       nodeWeightLabel.Text = string.Format("{0:0.00}", graphNode.Weight);
     105      selectedNodeStatusStrip.Text = string.Format("Quality: {0:0.00}, Rank: {1:0.0}, Degree: {2}/{3}, Weight: {4:0.00}",
     106        graphNode.Quality, graphNode.Rank, graphNode.InDegree, graphNode.OutDegree, graphNode.Weight);
    109107
    110108      // update the righthand side tree view when another genealogy graph node is selected
     
    113111      if (!graphNode.InArcs.Any()) return; // node has no ancestors, nothing to do
    114112
    115       if (openNew_CheckBox.Checked) {
     113      if (createNewViewCheckBox.Checked) {
    116114        // get the ancestors into a new view
    117115        var cloner = new Cloner();
     
    169167    private void OnTreeNodeLeftClicked(ISymbolicExpressionTreeNode node) {
    170168      SelectedSubtree = node;
    171       bool trace = genealogyGraphChart.TraceFragments;
     169      bool trace = traceCheckBox.Checked;
    172170
    173171      // check whether we are in 'trace' or 'match' mode
     
    183181        genealogyGraphChart.SuspendRendering();
    184182        genealogyGraphChart.ClearPrimitives(); // clear everything
    185         var rankMaximums = new Dictionary<double, double>();
    186 
    187         if (openNew_CheckBox.Checked) {
     183        bool newView = createNewViewCheckBox.Checked;
     184        if (newView) {
    188185          MainFormManager.MainForm.ShowContent(traceGraph);
    189186        } else {
    190         }
    191         // fill each vertex in the graph with a grayscale color according to average subtree weight
    192 
    193         /*
    194                 var colorGradient = ColorGradient.GrayscaledColors;
    195                 var colorCount = colorGradient.Count - 1;
    196                 foreach (var r in Content.Ranks) {
    197                   var vertices = r.Value.Cast<IGenealogyGraphNode<ISymbolicExpressionTree>>().ToList();
    198                   var averages = vertices.Select(x => x.Data.IterateNodesPrefix().Average(n => n.NodeWeight)).ToList();
    199                   var max = averages.Max();
    200                   rankMaximums.Add(r.Key, max);
    201                   if (max.IsAlmost(0.0)) continue;
    202                   for (int i = 0; i < vertices.Count; ++i) {
    203                     var color = colorGradient[(int)Math.Round(averages[i] / max * colorCount)];
    204                     var vNode = genealogyGraphChart.GetMappedNode(vertices[i]);
    205                     vNode.Brush = new SolidBrush(color);
    206                   }
    207                 }
    208                 // fill vertices that are part of the trace with a rgb color according to average subtree weight
    209                 if (traceGraph.Vertices.Any()) {
    210                   var ranks = traceGraph.Vertices.Select(x => Content.GetByContent(x.Data)).GroupBy(x => x.Rank);
    211                   foreach (var g in ranks) {
    212                     var vertices = g.ToList();
    213                     var averages = vertices.Select(x => x.Data.IterateNodesPrefix().Average(n => n.NodeWeight)).ToList();
    214                     double max = rankMaximums[g.Key];
    215                     if (max.IsAlmost(0.0)) continue;
    216                     for (int i = 0; i < vertices.Count; ++i) {
    217                       var vNode = genealogyGraphChart.GetMappedNode(vertices[i]);
    218                       // use a grayscale gradient
    219                       var color = colorGradient[(int)Math.Round(averages[i] / max * colorCount)];
    220                       vNode.Brush = new SolidBrush(color);
    221                     }
    222                   }
    223                   */
    224 
    225         //          if (openNew_CheckBox.Checked) {
    226         //            MainFormManager.MainForm.ShowContent(traceGraph); // display the fragment graph on the screen
    227         //          }
    228         //        }
    229         genealogyGraphChart.ResumeRendering();
     187          genealogyGraphChart.SuspendRendering();
     188          genealogyGraphChart.HighlightNodes(traceGraph.Vertices);
     189          genealogyGraphChart.ResumeRendering();
     190        }
    230191      } else {
    231192        // perform matching like it was done before
    232193        // currently there is no possibility to specify the subtree matching criteria
    233194        var trees = Content.Vertices.Select(x => x.Data);
    234         comparer.MatchVariableWeights = matchingModeButton.Checked;
    235         comparer.MatchConstantValues = matchingModeButton.Checked;
     195        //comparer.MatchVariableWeights = matchingModeButton.Checked;
     196        //comparer.MatchConstantValues = matchingModeButton.Checked;
    236197        var matchingTrees = trees.Where(x => x.Root.ContainsSubtree(node, comparer));
    237198
     
    251212
    252213      var trees = Content.Vertices.Select(x => x.Data);
    253       comparer.MatchVariableWeights = comparer.MatchConstantValues = matchingModeButton.Checked;
     214      //comparer.MatchVariableWeights = comparer.MatchConstantValues = matchingModeButton.Checked;
    254215      var matchingTrees = trees.Where(x => x.Root.ContainsSubtree(clonedSubtree, comparer));
    255216
     
    281242    #endregion
    282243
    283 
    284 
    285244    private void graphChart_HighlightMatchingVertices(IEnumerable<IGenealogyGraphNode> vertices) {
    286245      genealogyGraphChart.SuspendRendering();
     
    290249    }
    291250
     251    #region treechart methods
    292252    private void treeChart_ClearColors() {
    293253      foreach (var node in SymbolicExpressionTreeChart.Tree.IterateNodesPrefix()) {
     
    319279      SymbolicExpressionTreeChart.RepaintNodes();
    320280    }
     281    #endregion
    321282
    322283    #region navigate the genealogy / trace graph
     
    372333         });
    373334        }
    374 
    375 
    376335      }
    377336      if (arc == null) return;
    378337      lastTd = arc.Data as TraceData;
    379338      genealogyGraphChart.SelectedGraphNode = arc.Source;
    380       UpdateTreeChart((IGenealogyGraphNode<ISymbolicExpressionTree>)arc.Source);
     339      graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)arc.Source;
     340      UpdateTreeChart(graphNode);
     341
     342      var inDegreeDistinct = graphNode.InArcs.Select(x => x.Source).Distinct().Count();
     343      var outDegreeDistinct = graphNode.OutArcs.Select(x => x.Target).Distinct().Count();
     344
     345      selectedNodeStatusStrip.Text = string.Format("Quality: {0:0.00}, Rank: {1:0.0}, Degree: {2}/{3}, Weight: {4:0.00}",
     346        graphNode.Quality, graphNode.Rank, inDegreeDistinct, outDegreeDistinct, graphNode.Weight);
    381347    }
    382348
     
    412378      lastTd = arc.Data as TraceData;
    413379      genealogyGraphChart.SelectedGraphNode = arc.Source;
    414       UpdateTreeChart((IGenealogyGraphNode<ISymbolicExpressionTree>)arc.Source);
     380      graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)arc.Source;
     381      UpdateTreeChart(graphNode);
     382
     383      var inDegreeDistinct = graphNode.InArcs.Select(x => x.Source).Distinct().Count();
     384      var outDegreeDistinct = graphNode.OutArcs.Select(x => x.Target).Distinct().Count();
     385
     386      selectedNodeStatusStrip.Text = string.Format("Quality: {0:0.00}, Rank: {1:0.0}, Degree: {2}/{3}, Weight: {4:0.00}",
     387        graphNode.Quality, graphNode.Rank, inDegreeDistinct, outDegreeDistinct, graphNode.Weight);
     388    }
     389
     390    private void nodeColorsComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     391      switch (nodeColorsComboBox.SelectedIndex) {
     392        case 0: // color by quality
     393          genealogyGraphChart.ColorSelector = node => ColorGradient.Colors[(int)Math.Round(node.Quality * 255)];
     394          genealogyGraphChart.SuspendRendering();
     395          genealogyGraphChart.HighlightAll();
     396          genealogyGraphChart.ResumeRendering();
     397          break;
     398        case 1: // color by weight
     399          var weights = Content.Vertices.ToDictionary(v => (IGenealogyGraphNode)v, v => v.Data.IterateNodesPrefix().Average(x => x.NodeWeight));
     400          var max = weights.Values.Max();
     401          genealogyGraphChart.ColorSelector = node => ColorGradient.GrayscaledColors[(int)Math.Round(weights[node] / max * 255)];
     402          genealogyGraphChart.SuspendRendering();
     403          genealogyGraphChart.HighlightAll();
     404          genealogyGraphChart.ResumeRendering();
     405          break;
     406        default:
     407          break;
     408      }
     409    }
     410
     411    private void lockCheckBox_CheckedChanged(object sender, EventArgs e) {
     412      genealogyGraphChart.LockGenealogy = lockCheckBox.Checked;
    415413    }
    416414  }
Note: See TracChangeset for help on using the changeset viewer.