Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/15 00:31:03 (9 years ago)
Author:
bburlacu
Message:

#1772: Refactored genealogy graph views. Added an additional class specializing GenealogyGraphView<ISymbolicExpressionTree> for the sole purpose of making the SymbolicDataAnalysisGenealogyGraphView work with the designer. Added property to expose the SymbolicExpressionTreeChart in the GraphicalSymbolicExpressionTreeView in order to be able to wire mouse click events.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4
Files:
3 edited

Legend:

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

    r11506 r11817  
    9494    }
    9595
    96     public GenealogyGraphChart()
    97       : base() {
     96    public GenealogyGraphChart() {
    9897      InitializeComponent();
    9998
     
    198197        return;
    199198      }
    200       var visualNodes = Chart.GetAllPrimitives(e.Location).Where(p => p is VisualGenealogyGraphNode).ToList();
    201       if (!visualNodes.Any()) {
     199      var primitive = Chart.GetAllPrimitives(e.Location).FirstOrDefault(p => p is VisualGenealogyGraphNode);
     200      if (primitive == null) {
    202201        SelectedVisualNode = null;
    203202        return;
    204203      }
    205       if (SelectedVisualNode == visualNodes[0]) return;
    206       SelectedVisualNode = visualNodes[0] as VisualGenealogyGraphNode;
     204      if (SelectedVisualNode == primitive) return;
     205      SelectedVisualNode = primitive as VisualGenealogyGraphNode;
    207206      if (SelectedVisualNode == null) return;
    208207
     
    259258      var arcs = GenealogyGraph.Vertices.SelectMany(n => n.InArcs).ToList();
    260259      foreach (var arc in arcs) { arc.Weight = 1.0; } // reset weights
    261       var rank = GenealogyGraph.Ranks.Keys.Max();
    262       foreach (var ggn in GenealogyGraph.Ranks[rank]) {
    263         foreach (var ancestor in ggn.Ancestors) {
     260      var rank = GenealogyGraph.Ranks.Max(x => x.Key);
     261      foreach (var graphNode in GenealogyGraph.GetByRank(rank)) {
     262        foreach (var ancestor in graphNode.Ancestors) {
    264263          foreach (var arc in ancestor.InArcs) {
    265264            arc.Weight++;
     
    357356  internal static class Util {
    358357    public static Color GetColor(this IGenealogyGraphNode node) {
     358      if (double.IsNaN(node.Quality))
     359        return ColorGradient.Colors[0];
    359360      var colorIndex = (int)Math.Round(node.Quality * ColorGradient.Colors.Count);
    360361      if (colorIndex >= ColorGradient.Colors.Count) return ColorGradient.Colors.Last();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.Designer.cs

    r11506 r11817  
    11
    22namespace HeuristicLab.EvolutionTracking.Views {
    3   partial class GenealogyGraphView {
     3  partial class GenealogyGraphView<T> {
    44    /// <summary>
    55    /// Required designer variable.
     
    2626    private void InitializeComponent() {
    2727      this.splitContainer = new System.Windows.Forms.SplitContainer();
     28      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     29      this.groupBox = new System.Windows.Forms.GroupBox();
     30      this.lockGraph_checkBox = new System.Windows.Forms.CheckBox();
     31      this.simpleLineages_checkBox = new System.Windows.Forms.CheckBox();
     32      this.trace_checkBox = new System.Windows.Forms.CheckBox();
    2833      this.genealogyGraphChart = new HeuristicLab.EvolutionTracking.Views.GenealogyGraphChart();
    29       this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    3034      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    3135      this.splitContainer.Panel1.SuspendLayout();
    3236      this.splitContainer.Panel2.SuspendLayout();
    3337      this.splitContainer.SuspendLayout();
     38      this.groupBox.SuspendLayout();
    3439      this.SuspendLayout();
    3540      //
    3641      // splitContainer
    3742      //
    38       this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
    39       this.splitContainer.Location = new System.Drawing.Point(0, 0);
     43      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     44            | System.Windows.Forms.AnchorStyles.Left)
     45            | System.Windows.Forms.AnchorStyles.Right)));
     46      this.splitContainer.Location = new System.Drawing.Point(3, 55);
    4047      this.splitContainer.Name = "splitContainer";
    4148      //
     
    4754      //
    4855      this.splitContainer.Panel2.Controls.Add(this.viewHost);
    49       this.splitContainer.Size = new System.Drawing.Size(894, 678);
    50       this.splitContainer.SplitterDistance = 417;
     56      this.splitContainer.Size = new System.Drawing.Size(1394, 742);
     57      this.splitContainer.SplitterDistance = 694;
    5158      this.splitContainer.TabIndex = 0;
     59      //
     60      // viewHost
     61      //
     62      this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     63            | System.Windows.Forms.AnchorStyles.Left)
     64            | System.Windows.Forms.AnchorStyles.Right)));
     65      this.viewHost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     66      this.viewHost.Caption = "View";
     67      this.viewHost.Content = null;
     68      this.viewHost.Enabled = false;
     69      this.viewHost.Location = new System.Drawing.Point(0, 0);
     70      this.viewHost.Name = "viewHost";
     71      this.viewHost.ReadOnly = false;
     72      this.viewHost.Size = new System.Drawing.Size(697, 743);
     73      this.viewHost.TabIndex = 0;
     74      this.viewHost.ViewsLabelVisible = true;
     75      this.viewHost.ViewType = null;
     76      //
     77      // groupBox
     78      //
     79      this.groupBox.Controls.Add(this.lockGraph_checkBox);
     80      this.groupBox.Controls.Add(this.simpleLineages_checkBox);
     81      this.groupBox.Controls.Add(this.trace_checkBox);
     82      this.groupBox.Location = new System.Drawing.Point(3, 4);
     83      this.groupBox.Name = "groupBox";
     84      this.groupBox.Size = new System.Drawing.Size(411, 44);
     85      this.groupBox.TabIndex = 1;
     86      this.groupBox.TabStop = false;
     87      this.groupBox.Text = "Genealogy Options";
     88      //
     89      // lockGraph_checkBox
     90      //
     91      this.lockGraph_checkBox.Appearance = System.Windows.Forms.Appearance.Button;
     92      this.lockGraph_checkBox.AutoSize = true;
     93      this.lockGraph_checkBox.Location = new System.Drawing.Point(157, 15);
     94      this.lockGraph_checkBox.Name = "lockGraph_checkBox";
     95      this.lockGraph_checkBox.Size = new System.Drawing.Size(73, 23);
     96      this.lockGraph_checkBox.TabIndex = 0;
     97      this.lockGraph_checkBox.Text = "Lock Graph";
     98      this.lockGraph_checkBox.UseVisualStyleBackColor = true;
     99      this.lockGraph_checkBox.CheckedChanged += new System.EventHandler(this.lockGraph_checkBox_CheckedChanged);
     100      //
     101      // simpleLineages_checkBox
     102      //
     103      this.simpleLineages_checkBox.Appearance = System.Windows.Forms.Appearance.Button;
     104      this.simpleLineages_checkBox.AutoSize = true;
     105      this.simpleLineages_checkBox.Location = new System.Drawing.Point(57, 15);
     106      this.simpleLineages_checkBox.Name = "simpleLineages_checkBox";
     107      this.simpleLineages_checkBox.Size = new System.Drawing.Size(94, 23);
     108      this.simpleLineages_checkBox.TabIndex = 0;
     109      this.simpleLineages_checkBox.Text = "Simple Lineages";
     110      this.simpleLineages_checkBox.UseVisualStyleBackColor = true;
     111      this.simpleLineages_checkBox.CheckedChanged += new System.EventHandler(this.simpleLineages_checkBox_CheckedChanged);
     112      //
     113      // trace_checkBox
     114      //
     115      this.trace_checkBox.Appearance = System.Windows.Forms.Appearance.Button;
     116      this.trace_checkBox.AutoSize = true;
     117      this.trace_checkBox.Location = new System.Drawing.Point(6, 15);
     118      this.trace_checkBox.Name = "trace_checkBox";
     119      this.trace_checkBox.Size = new System.Drawing.Size(45, 23);
     120      this.trace_checkBox.TabIndex = 0;
     121      this.trace_checkBox.Text = "Trace";
     122      this.trace_checkBox.UseVisualStyleBackColor = true;
     123      this.trace_checkBox.CheckedChanged += new System.EventHandler(this.trace_checkBox_CheckedChanged);
    52124      //
    53125      // genealogyGraphChart
    54126      //
     127      this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     128            | System.Windows.Forms.AnchorStyles.Left)
     129            | System.Windows.Forms.AnchorStyles.Right)));
    55130      this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
    56       this.genealogyGraphChart.Dock = System.Windows.Forms.DockStyle.Fill;
    57131      this.genealogyGraphChart.GenealogyGraph = null;
    58132      this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
     
    61135      this.genealogyGraphChart.ScaleOnResize = true;
    62136      this.genealogyGraphChart.SimpleLineages = false;
    63       this.genealogyGraphChart.Size = new System.Drawing.Size(417, 678);
    64       this.genealogyGraphChart.TabIndex = 2;
     137      this.genealogyGraphChart.Size = new System.Drawing.Size(689, 738);
     138      this.genealogyGraphChart.TabIndex = 0;
    65139      this.genealogyGraphChart.TraceFragments = false;
    66       //
    67       // viewHost
    68       //
    69       this.viewHost.Caption = "View";
    70       this.viewHost.Content = null;
    71       this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    72       this.viewHost.Enabled = false;
    73       this.viewHost.Location = new System.Drawing.Point(0, 0);
    74       this.viewHost.Name = "viewHost";
    75       this.viewHost.ReadOnly = false;
    76       this.viewHost.Size = new System.Drawing.Size(473, 678);
    77       this.viewHost.TabIndex = 0;
    78       this.viewHost.ViewsLabelVisible = true;
    79       this.viewHost.ViewType = null;
    80140      //
    81141      // GenealogyGraphView
     
    83143      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    84144      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     145      this.Controls.Add(this.groupBox);
    85146      this.Controls.Add(this.splitContainer);
    86147      this.Name = "GenealogyGraphView";
    87       this.Size = new System.Drawing.Size(894, 678);
     148      this.Size = new System.Drawing.Size(1400, 800);
    88149      this.splitContainer.Panel1.ResumeLayout(false);
    89150      this.splitContainer.Panel2.ResumeLayout(false);
    90151      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    91152      this.splitContainer.ResumeLayout(false);
     153      this.groupBox.ResumeLayout(false);
     154      this.groupBox.PerformLayout();
    92155      this.ResumeLayout(false);
    93156
     
    99162    protected MainForm.WindowsForms.ViewHost viewHost;
    100163    protected GenealogyGraphChart genealogyGraphChart;
     164    private System.Windows.Forms.GroupBox groupBox;
     165    protected System.Windows.Forms.CheckBox trace_checkBox;
     166    protected System.Windows.Forms.CheckBox simpleLineages_checkBox;
     167    protected System.Windows.Forms.CheckBox lockGraph_checkBox;
    101168
    102169  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.cs

    r11253 r11817  
    11using System.Windows.Forms;
    2 using HeuristicLab.Common;
     2using HeuristicLab.Core;
    33using HeuristicLab.Core.Views;
    44using HeuristicLab.MainForm;
     
    66namespace HeuristicLab.EvolutionTracking.Views {
    77  [View("GenealogyGraphView")]
    8   [Content(typeof(IGenealogyGraph), IsDefaultView = false)]
    9   public partial class GenealogyGraphView : ItemView {
    10     public new IGenealogyGraph Content {
    11       get { return (IGenealogyGraph)base.Content; }
     8  [Content(typeof(IGenealogyGraph<>), IsDefaultView = false)]
     9  public partial class GenealogyGraphView<T> : ItemView where T : class,IItem {
     10    public new IGenealogyGraph<T> Content {
     11      get { return (IGenealogyGraph<T>)base.Content; }
    1212      set { base.Content = value; }
    1313    }
     
    2020      // TODO: Deregister your event handlers here
    2121      genealogyGraphChart.GenealogyGraphNodeClicked -= graphChart_GenealogyGraphNodeClicked;
     22      genealogyGraphChart.GenealogyGraphNodeDoubleClicked -= graphChart_GenealogyGraphNodeDoubleClicked;
    2223      base.DeregisterContentEvents();
    2324    }
     
    2728      // TODO: Register your event handlers here
    2829      genealogyGraphChart.GenealogyGraphNodeClicked += graphChart_GenealogyGraphNodeClicked;
     30      genealogyGraphChart.GenealogyGraphNodeDoubleClicked += graphChart_GenealogyGraphNodeDoubleClicked;
    2931    }
    3032
     
    4547    // TODO: Put event handlers of child controls here.
    4648    public virtual void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) {
    47       var content = ((VisualGenealogyGraphNode)sender).Data.Data;
    48       if (content != null) {
    49         viewHost.Content = (IContent)content;
    50       }
     49      var visualNode = (VisualGenealogyGraphNode)sender;
     50      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;
     55    }
     56    public virtual void graphChart_GenealogyGraphNodeDoubleClicked(object sender, MouseEventArgs arcs) {
     57    }
     58    #endregion
     59
     60    #region events for configuring the behavior of the genealogy chart (trace/match, simple lineages, etc)
     61    private void trace_checkBox_CheckedChanged(object sender, System.EventArgs e) {
     62      genealogyGraphChart.TraceFragments = trace_checkBox.Checked;
     63    }
     64
     65    private void simpleLineages_checkBox_CheckedChanged(object sender, System.EventArgs e) {
     66      genealogyGraphChart.SimpleLineages = simpleLineages_checkBox.Checked;
     67    }
     68
     69    private void lockGraph_checkBox_CheckedChanged(object sender, System.EventArgs e) {
     70      genealogyGraphChart.LockGenealogy = lockGraph_checkBox.Checked;
    5171    }
    5272    #endregion
Note: See TracChangeset for help on using the changeset viewer.