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.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking
Files:
2 deleted
2 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.Designer.cs

    r11816 r11817  
    2020#endregion
    2121
    22 using System.Drawing;
    2322
    2423namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    25   partial class SymboldDataAnalysisGenealogyView {
     24  partial class SymbolicDataAnalysisGenealogyGraphView {
    2625    /// <summary>
    2726    /// Required designer variable.
     
    4140
    4241    #region Component Designer generated code
    43 
    4442    /// <summary>
    4543    /// Required method for Designer support - do not modify
     
    4846    private void InitializeComponent() {
    4947      this.components = new System.ComponentModel.Container();
    50       this.splitContainer1 = new System.Windows.Forms.SplitContainer();
    51       this.symbolicExpressionTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    52       this.groupBox1 = new System.Windows.Forms.GroupBox();
    53       this.hotPaths_button = new System.Windows.Forms.Button();
    54       this.simpleLineages_checkBox = new System.Windows.Forms.CheckBox();
    55       this.lockGraph_checkBox = new System.Windows.Forms.CheckBox();
    56       this.trace_checkBox = new System.Windows.Forms.CheckBox();
    57       this.genealogyGraphChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.SymbolicDataAnalysisExpressionGenealogyGraphChart();
    58       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
    59       this.splitContainer1.Panel1.SuspendLayout();
    60       this.splitContainer1.Panel2.SuspendLayout();
    61       this.splitContainer1.SuspendLayout();
    62       this.groupBox1.SuspendLayout();
    6348      this.SuspendLayout();
    6449      //
    65       // splitContainer1
    66       //
    67       this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    68             | System.Windows.Forms.AnchorStyles.Left)
    69             | System.Windows.Forms.AnchorStyles.Right)));
    70       this.splitContainer1.Location = new System.Drawing.Point(0, 57);
    71       this.splitContainer1.Name = "splitContainer1";
    72       //
    73       // splitContainer1.Panel1
    74       //
    75       this.splitContainer1.Panel1.Controls.Add(this.genealogyGraphChart);
    76       //
    77       // splitContainer1.Panel2
    78       //
    79       this.splitContainer1.Panel2.Controls.Add(this.symbolicExpressionTreeChart);
    80       this.splitContainer1.Size = new System.Drawing.Size(1244, 695);
    81       this.splitContainer1.SplitterDistance = 605;
    82       this.splitContainer1.TabIndex = 0;
    83       //
    84       // symbolicExpressionTreeChart
    85       //
    86       this.symbolicExpressionTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    87             | System.Windows.Forms.AnchorStyles.Left)
    88             | System.Windows.Forms.AnchorStyles.Right)));
    89       this.symbolicExpressionTreeChart.BackgroundColor = System.Drawing.Color.White;
    90       this.symbolicExpressionTreeChart.LineColor = System.Drawing.Color.Black;
    91       this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(0, 0);
    92       this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";
    93       this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(635, 692);
    94       this.symbolicExpressionTreeChart.Spacing = 5;
    95       this.symbolicExpressionTreeChart.SuspendRepaint = false;
    96       this.symbolicExpressionTreeChart.TabIndex = 0;
    97       this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font("Microsoft Sans Serif", 10F);
    98       this.symbolicExpressionTreeChart.Tree = null;
    99       //
    100       // groupBox1
    101       //
    102       this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    103             | System.Windows.Forms.AnchorStyles.Right)));
    104       this.groupBox1.Controls.Add(this.hotPaths_button);
    105       this.groupBox1.Controls.Add(this.simpleLineages_checkBox);
    106       this.groupBox1.Controls.Add(this.lockGraph_checkBox);
    107       this.groupBox1.Controls.Add(this.trace_checkBox);
    108       this.groupBox1.Location = new System.Drawing.Point(3, 3);
    109       this.groupBox1.Name = "groupBox1";
    110       this.groupBox1.Size = new System.Drawing.Size(1241, 48);
    111       this.groupBox1.TabIndex = 4;
    112       this.groupBox1.TabStop = false;
    113       this.groupBox1.Text = "Controls";
    114       //
    115       // hotPaths_button
    116       //
    117       this.hotPaths_button.Location = new System.Drawing.Point(263, 15);
    118       this.hotPaths_button.Name = "hotPaths_button";
    119       this.hotPaths_button.Size = new System.Drawing.Size(75, 23);
    120       this.hotPaths_button.TabIndex = 7;
    121       this.hotPaths_button.Text = "Hot paths";
    122       this.hotPaths_button.UseVisualStyleBackColor = true;
    123       this.hotPaths_button.Click += new System.EventHandler(this.hotPaths_button_Click);
    124       //
    125       // simpleLineages_checkBox
    126       //
    127       this.simpleLineages_checkBox.AutoSize = true;
    128       this.simpleLineages_checkBox.Location = new System.Drawing.Point(94, 19);
    129       this.simpleLineages_checkBox.Name = "simpleLineages_checkBox";
    130       this.simpleLineages_checkBox.Size = new System.Drawing.Size(103, 17);
    131       this.simpleLineages_checkBox.TabIndex = 6;
    132       this.simpleLineages_checkBox.Text = "Simple Lineages";
    133       this.simpleLineages_checkBox.UseVisualStyleBackColor = true;
    134       this.simpleLineages_checkBox.CheckedChanged += new System.EventHandler(this.simpleLineages_checkBox_CheckedChanged);
    135       //
    136       // lockGraph_checkBox
    137       //
    138       this.lockGraph_checkBox.AutoSize = true;
    139       this.lockGraph_checkBox.Location = new System.Drawing.Point(6, 19);
    140       this.lockGraph_checkBox.Name = "lockGraph_checkBox";
    141       this.lockGraph_checkBox.Size = new System.Drawing.Size(82, 17);
    142       this.lockGraph_checkBox.TabIndex = 5;
    143       this.lockGraph_checkBox.Text = "Lock Graph";
    144       this.lockGraph_checkBox.UseVisualStyleBackColor = true;
    145       this.lockGraph_checkBox.CheckedChanged += new System.EventHandler(this.lockGraph_checkBox_CheckedChanged);
    146       //
    147       // trace_checkBox
    148       //
    149       this.trace_checkBox.AutoSize = true;
    150       this.trace_checkBox.Location = new System.Drawing.Point(203, 19);
    151       this.trace_checkBox.Name = "trace_checkBox";
    152       this.trace_checkBox.Size = new System.Drawing.Size(54, 17);
    153       this.trace_checkBox.TabIndex = 4;
    154       this.trace_checkBox.Text = "Trace";
    155       this.trace_checkBox.UseVisualStyleBackColor = true;
    156       this.trace_checkBox.CheckedChanged += new System.EventHandler(this.trace_checkBox_CheckedChanged);
    157       //
    158       // genealogyGraphChart
    159       //
    160       this.genealogyGraphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    161             | System.Windows.Forms.AnchorStyles.Left)
    162             | System.Windows.Forms.AnchorStyles.Right)));
    163       this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
    164       this.genealogyGraphChart.GenealogyGraph = null;
    165       this.genealogyGraphChart.Location = new System.Drawing.Point(-5, 0);
    166       this.genealogyGraphChart.LockGenealogy = false;
    167       this.genealogyGraphChart.Name = "genealogyGraphChart";
    168       this.genealogyGraphChart.ScaleOnResize = true;
    169       this.genealogyGraphChart.SimpleLineages = false;
    170       this.genealogyGraphChart.Size = new System.Drawing.Size(607, 692);
    171       this.genealogyGraphChart.TabIndex = 0;
    172       this.genealogyGraphChart.TraceFragments = false;
    173       //
    174       // SymboldDataAnalysisGenealogyView
     50      // SymbolicDataAnalysisGenealogyGraphView
    17551      //
    17652      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    17753      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    178       this.Controls.Add(this.groupBox1);
    179       this.Controls.Add(this.splitContainer1);
    180       this.Name = "SymboldDataAnalysisGenealogyView";
     54      this.Name = "SymbolicDataAnalysisGenealogyGraphView";
    18155      this.Size = new System.Drawing.Size(1247, 755);
    182       this.splitContainer1.Panel1.ResumeLayout(false);
    183       this.splitContainer1.Panel2.ResumeLayout(false);
    184       ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
    185       this.splitContainer1.ResumeLayout(false);
    186       this.groupBox1.ResumeLayout(false);
    187       this.groupBox1.PerformLayout();
    18856      this.ResumeLayout(false);
    189 
    19057    }
    19158
    19259    #endregion
    193 
    194     private System.Windows.Forms.SplitContainer splitContainer1;
    195     private SymbolicDataAnalysisExpressionGenealogyGraphChart genealogyGraphChart;
    196     private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart symbolicExpressionTreeChart;
    197     private System.Windows.Forms.GroupBox groupBox1;
    198     private System.Windows.Forms.CheckBox simpleLineages_checkBox;
    199     private System.Windows.Forms.CheckBox lockGraph_checkBox;
    200     private System.Windows.Forms.CheckBox trace_checkBox;
    201     private System.Windows.Forms.Button hotPaths_button;
    202 
    20360  }
    20461}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.cs

    r11744 r11817  
    2525using System.Linq;
    2626using System.Windows.Forms;
    27 using HeuristicLab.Core.Views;
    2827using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2928using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
     
    3332
    3433namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    35   [View("SymboldDataAnalysisGenealogyView")]
     34  [View("SymbolicDataAnalysisGenealogyGraphView")]
    3635  [Content(typeof(IGenealogyGraph<ISymbolicExpressionTree>), IsDefaultView = true)]
    37   public partial class SymboldDataAnalysisGenealogyView : ItemView {
     36  public partial class SymbolicDataAnalysisGenealogyGraphView : SymbolicDataAnalysisGenealogyGraphViewDesignable {
    3837    private readonly ISymbolicExpressionTreeNodeSimilarityComparer comparer;
    3938
    40     public SymboldDataAnalysisGenealogyView() {
     39    public SymbolicDataAnalysisGenealogyGraphView() {
    4140      InitializeComponent();
    42 
    4341      comparer = new SymbolicExpressionTreeNodeSimilarityComparer();
     42      viewHost.ViewType = typeof(GraphicalSymbolicExpressionTreeView);
    4443    }
    45 
    46     public new IGenealogyGraph<ISymbolicExpressionTree> Content {
    47       get { return (IGenealogyGraph<ISymbolicExpressionTree>)base.Content; }
    48       set { base.Content = value; }
    49     }
    50 
    5144    #region event handlers
    52 
    5345    protected override void OnContentChanged() {
    5446      base.OnContentChanged();
    55       if (Content != null) {
    56         genealogyGraphChart.GenealogyGraph = Content;
     47      if (Content != null) { genealogyGraphChart.GenealogyGraph = Content; }
     48    }
     49    #endregion
     50
     51    public SymbolicExpressionTreeChart SymbolicExpressionTreeChart {
     52      get {
     53        var view = (GraphicalSymbolicExpressionTreeView)base.viewHost.ActiveView;
     54        return view == null ? null : view.SymbolicExpressionTreeChart;
    5755      }
    5856    }
    5957
    60     #endregion
    61 
    6258    protected override void RegisterContentEvents() {
    63       genealogyGraphChart.GenealogyGraphNodeClicked += graphChart_GenealogyGraphNodeClicked;
    64       genealogyGraphChart.GenealogyGraphNodeDoubleClicked += graphChart_GenealogyGraphNodeDoubleClicked;
    65       symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += treeChart_SymbolicExpressionNodeClicked;
    6659      base.RegisterContentEvents();
     60      if (SymbolicExpressionTreeChart != null)
     61        SymbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += treeChart_SymbolicExpressionTreeNodeClicked;
    6762    }
    6863
    6964    protected override void DeregisterContentEvents() {
     65      if (SymbolicExpressionTreeChart != null)
     66        SymbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked -= treeChart_SymbolicExpressionTreeNodeClicked;
    7067      base.DeregisterContentEvents();
    71       genealogyGraphChart.GenealogyGraphNodeClicked -= graphChart_GenealogyGraphNodeClicked;
    72       symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked -= treeChart_SymbolicExpressionNodeClicked;
    7368    }
    7469
    75     public void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) {
     70    public override void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) {
     71      base.graphChart_GenealogyGraphNodeClicked(sender, args);
    7672      var visualNode = (VisualGenealogyGraphNode)sender;
    7773      var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)visualNode.Data;
    78       var tree = graphNode.Data;
    79       symbolicExpressionTreeChart.Tree = tree;
    8074      if (graphNode.InArcs.Any()) {
    8175        var fragment = graphNode.InArcs.Last().Data as IFragment<ISymbolicExpressionTreeNode>;
     
    9589    }
    9690
    97     public void graphChart_GenealogyGraphNodeDoubleClicked(object sender, MouseEventArgs arcs) {
    98       var visualNode = (VisualGenealogyGraphNode)sender;
    99       var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)visualNode.Data;
    100       //      var tree = graphNode.Data;
    101       //      var model = new RegressionModel();
    102       //      var solution = new RegressionSolution()
    103       //      MainFormManager.MainForm.ShowContent(tree);
    104     }
    105 
    106     public void treeChart_SymbolicExpressionNodeClicked(object sender, MouseEventArgs args) {
     91    public void treeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs args) {
    10792      var visualNode = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender;
    10893      var subtree = visualNode.Content;
     
    11297      treeChart_HighlightSubtree(subtree);
    11398
    114       bool trace = genealogyGraphChart.TraceFragments; // check whether the mode is 'trace' or 'match'
     99      bool trace = genealogyGraphChart.TraceFragments; // check whether we are in 'trace' or 'match' mode
    115100
    116101      if (trace) {
     
    118103        var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode;
    119104        var subtreeIndex = graphNode.Data.IterateNodesPrefix().ToList().IndexOf(subtree);
    120         var fragmentGraph = SymbolicDataAnalysisExpressionTracing.TraceSubtree(graphNode, subtreeIndex);
     105        //        var fragmentGraph = SymbolicDataAnalysisExpressionTracing.TraceSubtree(graphNode, subtreeIndex);
     106        var traceGraph = TraceCalculator.TraceSubtree(graphNode, subtreeIndex);
    121107
    122         if (fragmentGraph.Vertices.Any()) {
    123           var genealogyNodes = fragmentGraph.Vertices.Select(v => Content.GetByContent(v.Data));
     108        if (traceGraph.Vertices.Any()) {
     109          var genealogyNodes = traceGraph.Vertices.Select(v => Content.GetByContent(v.Data));
    124110          genealogyGraphChart.HighlightNodes(genealogyNodes);
    125           foreach (var a in fragmentGraph.Arcs) {
     111          foreach (var a in traceGraph.Arcs) {
    126112            genealogyGraphChart.HighlightArc(Content.GetByContent(a.Target.Data), Content.GetByContent(a.Source.Data));
    127113          }
    128           MainFormManager.MainForm.ShowContent(fragmentGraph); // display the fragment graph on the screen
     114          MainFormManager.MainForm.ShowContent(traceGraph); // display the fragment graph on the screen
    129115        }
    130116      } else {
     
    148134
    149135    private void treeChart_ClearColors() {
    150       foreach (var node in symbolicExpressionTreeChart.Tree.IterateNodesPrefix()) {
    151         var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     136      foreach (var node in SymbolicExpressionTreeChart.Tree.IterateNodesPrefix()) {
     137        var visualNode = SymbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
    152138        if (visualNode != null) {
    153139          visualNode.LineColor = Color.Black;
     
    155141        }
    156142      }
    157       symbolicExpressionTreeChart.RepaintNodes();
     143      SymbolicExpressionTreeChart.RepaintNodes();
    158144    }
    159145
    160146    private void treeChart_HighlightSubtree(ISymbolicExpressionTreeNode subtree, Color? color = null) {
    161       Color myColor = color == null ? Color.RoyalBlue : (Color)color;
     147      Color myColor = color ?? Color.RoyalBlue;
    162148      foreach (var s in subtree.IterateNodesPrefix()) {
    163         var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(s);
     149        var visualNode = SymbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(s);
    164150        visualNode.LineColor = myColor;
    165151        //        visualNode.FillColor = myColor;
    166152
    167153        foreach (var c in s.Subtrees) {
    168           var visualArc = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(s, c);
     154          var visualArc = SymbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNodeConnection(s, c);
    169155          visualArc.LineColor = myColor;
    170156        }
    171157      }
    172       symbolicExpressionTreeChart.RepaintNodes();
    173     }
    174 
    175     #region events for configuring the behavior of the genealogy chart (trace/match, simple lineages, etc)
    176     private void trace_checkBox_CheckedChanged(object sender, System.EventArgs e) {
    177       genealogyGraphChart.TraceFragments = trace_checkBox.Checked;
    178     }
    179 
    180     private void simpleLineages_checkBox_CheckedChanged(object sender, System.EventArgs e) {
    181       genealogyGraphChart.SimpleLineages = simpleLineages_checkBox.Checked;
    182     }
    183 
    184     private void lockGraph_checkBox_CheckedChanged(object sender, System.EventArgs e) {
    185       genealogyGraphChart.LockGenealogy = lockGraph_checkBox.Checked;
    186     }
    187     #endregion
    188 
    189     private void hotPaths_button_Click(object sender, System.EventArgs e) {
    190       genealogyGraphChart.HighlightHotPaths();
     158      SymbolicExpressionTreeChart.RepaintNodes();
    191159    }
    192160  }
     161
     162  public class SymbolicDataAnalysisGenealogyGraphViewDesignable : GenealogyGraphView<ISymbolicExpressionTree> { }
    193163}
Note: See TracChangeset for help on using the changeset viewer.