Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/15/21 17:00:28 (3 years ago)
Author:
dpiringe
Message:

#3136

  • modified the StructureTemplateView to enable colorful tree nodes of type SubFunctionTreeNode
  • refactored SubFunctionTreeNode, SubFunction and StructureTemplate
Location:
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.Designer.cs

    r18067 r18068  
    3030      this.expressionInput = new System.Windows.Forms.TextBox();
    3131      this.parseButton = new System.Windows.Forms.Button();
    32       this.errorLabel = new System.Windows.Forms.Label();
    33       this.symRegTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView();
     32      this.infoLabel = new System.Windows.Forms.Label();
    3433      this.templateStructureGroupBox = new System.Windows.Forms.GroupBox();
    3534      this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    3635      this.splitContainer = new System.Windows.Forms.SplitContainer();
     36      this.detailsGroupBox = new System.Windows.Forms.GroupBox();
    3737      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    3838      this.templateStructureGroupBox.SuspendLayout();
     
    4141      this.splitContainer.Panel2.SuspendLayout();
    4242      this.splitContainer.SuspendLayout();
     43      this.detailsGroupBox.SuspendLayout();
    4344      this.SuspendLayout();
    4445      //
     
    5152      this.expressionInput.Size = new System.Drawing.Size(288, 20);
    5253      this.expressionInput.TabIndex = 1;
    53       this.expressionInput.TextChanged += new System.EventHandler(this.expressionInput_TextChanged);
     54      this.expressionInput.TextChanged += new System.EventHandler(this.ExpressionInputTextChanged);
    5455      //
    5556      // parseButton
     
    6162      this.parseButton.Text = "Parse";
    6263      this.parseButton.UseVisualStyleBackColor = true;
    63       this.parseButton.Click += new System.EventHandler(this.parseButton_Click);
     64      this.parseButton.Click += new System.EventHandler(this.ParseButtonClick);
    6465      //
    6566      // errorLabel
    6667      //
    67       this.errorLabel.AutoSize = true;
    68       this.errorLabel.Location = new System.Drawing.Point(155, 50);
    69       this.errorLabel.Name = "errorLabel";
    70       this.errorLabel.Size = new System.Drawing.Size(54, 13);
    71       this.errorLabel.TabIndex = 4;
    72       this.errorLabel.Text = "errorLabel";
    73       //
    74       // symRegTreeChart
    75       //
    76       this.symRegTreeChart.AllowDrop = true;
    77       this.symRegTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    78             | System.Windows.Forms.AnchorStyles.Right)));
    79       this.symRegTreeChart.Caption = "Graphical SymbolicExpressionTree View";
    80       this.symRegTreeChart.Content = null;
    81       this.symRegTreeChart.Location = new System.Drawing.Point(6, 74);
    82       this.symRegTreeChart.Name = "symRegTreeChart";
    83       this.symRegTreeChart.ReadOnly = false;
    84       this.symRegTreeChart.Size = new System.Drawing.Size(288, 153);
    85       this.symRegTreeChart.TabIndex = 6;
     68      this.infoLabel.AutoSize = true;
     69      this.infoLabel.Location = new System.Drawing.Point(155, 50);
     70      this.infoLabel.Name = "errorLabel";
     71      this.infoLabel.Size = new System.Drawing.Size(54, 13);
     72      this.infoLabel.TabIndex = 4;
     73      this.infoLabel.Text = "errorLabel";
    8674      //
    8775      // templateStructureGroupBox
    8876      //
    8977      this.templateStructureGroupBox.Controls.Add(this.treeChart);
    90       this.templateStructureGroupBox.Controls.Add(this.symRegTreeChart);
    9178      this.templateStructureGroupBox.Controls.Add(this.parseButton);
    92       this.templateStructureGroupBox.Controls.Add(this.errorLabel);
     79      this.templateStructureGroupBox.Controls.Add(this.infoLabel);
    9380      this.templateStructureGroupBox.Controls.Add(this.expressionInput);
    9481      this.templateStructureGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     
    10289      // treeChart
    10390      //
    104       this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     91      this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     92            | System.Windows.Forms.AnchorStyles.Left)
    10593            | System.Windows.Forms.AnchorStyles.Right)));
    10694      this.treeChart.BackgroundColor = System.Drawing.Color.White;
    10795      this.treeChart.LineColor = System.Drawing.Color.Black;
    108       this.treeChart.Location = new System.Drawing.Point(6, 233);
     96      this.treeChart.Location = new System.Drawing.Point(6, 74);
    10997      this.treeChart.MinimumHorizontalDistance = 30;
    11098      this.treeChart.MinimumHorizontalPadding = 20;
     
    114102      this.treeChart.PreferredNodeHeight = 46;
    115103      this.treeChart.PreferredNodeWidth = 70;
    116       this.treeChart.Size = new System.Drawing.Size(288, 150);
     104      this.treeChart.Size = new System.Drawing.Size(288, 320);
    117105      this.treeChart.SuspendRepaint = false;
    118106      this.treeChart.TabIndex = 7;
     
    134122      // splitContainer.Panel2
    135123      //
    136       this.splitContainer.Panel2.Controls.Add(this.viewHost);
     124      this.splitContainer.Panel2.Controls.Add(this.detailsGroupBox);
    137125      this.splitContainer.Panel2MinSize = 5;
    138126      this.splitContainer.Size = new System.Drawing.Size(600, 400);
    139127      this.splitContainer.SplitterDistance = 300;
    140128      this.splitContainer.TabIndex = 10;
     129      //
     130      // detailsGroupBox
     131      //
     132      this.detailsGroupBox.Controls.Add(this.viewHost);
     133      this.detailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     134      this.detailsGroupBox.Location = new System.Drawing.Point(0, 0);
     135      this.detailsGroupBox.Name = "detailsGroupBox";
     136      this.detailsGroupBox.Size = new System.Drawing.Size(296, 400);
     137      this.detailsGroupBox.TabIndex = 9;
     138      this.detailsGroupBox.TabStop = false;
     139      this.detailsGroupBox.Text = "Details";
    141140      //
    142141      // viewHost
     
    146145      this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    147146      this.viewHost.Enabled = false;
    148       this.viewHost.Location = new System.Drawing.Point(0, 0);
     147      this.viewHost.Location = new System.Drawing.Point(3, 16);
    149148      this.viewHost.Name = "viewHost";
    150149      this.viewHost.ReadOnly = false;
    151       this.viewHost.Size = new System.Drawing.Size(296, 400);
     150      this.viewHost.Size = new System.Drawing.Size(290, 381);
    152151      this.viewHost.TabIndex = 8;
    153152      this.viewHost.ViewsLabelVisible = true;
     
    167166      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    168167      this.splitContainer.ResumeLayout(false);
     168      this.detailsGroupBox.ResumeLayout(false);
    169169      this.ResumeLayout(false);
    170170
     
    174174    private System.Windows.Forms.TextBox expressionInput;
    175175    private System.Windows.Forms.Button parseButton;
    176     private System.Windows.Forms.Label errorLabel;
    177     private Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView symRegTreeChart;
     176    private System.Windows.Forms.Label infoLabel;
    178177    private System.Windows.Forms.GroupBox templateStructureGroupBox;
    179178    private System.Windows.Forms.SplitContainer splitContainer;
    180179    private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart treeChart;
    181180    private MainForm.WindowsForms.ViewHost viewHost;
     181    private System.Windows.Forms.GroupBox detailsGroupBox;
    182182  }
    183183}
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.cs

    r18067 r18068  
    2424    public StructureTemplateView() {
    2525      InitializeComponent();
    26       errorLabel.Text = "";
    27       treeChart.SymbolicExpressionTreeNodeClicked += TreeChart_SymbolicExpressionTreeNodeClicked;
     26      infoLabel.Text = "";
     27      treeChart.SymbolicExpressionTreeNodeClicked += SymbolicExpressionTreeNodeClicked;
     28     
    2829    }
    2930
    30     private void TreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
     31    private void SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    3132      var visualTreeNode = sender as VisualTreeNode<ISymbolicExpressionTreeNode>;
    3233      if(visualTreeNode != null) {
    3334        var subFunctionTreeNode = visualTreeNode.Content as SubFunctionTreeNode;
    34         viewHost.Content = subFunctionTreeNode?.SubFunction;
     35        if(Content.SubFunctions.TryGetValue(subFunctionTreeNode.Name, out SubFunction subFunction))
     36          viewHost.Content = subFunction;
    3537      }
    3638    }
     
    3941      base.OnContentChanged();
    4042      if (Content == null) return;
    41 
    4243      expressionInput.Text = Content.Template;
    43       symRegTreeChart.Content = Content.Tree;
    44 
    45       treeChart.Tree = Content.Tree;
    46 
    47       errorLabel.Text = "";
    48      
     44      PaintTree();
     45      infoLabel.Text = "";
    4946    }
    5047
    51     private void parseButton_Click(object sender, EventArgs e) {
     48    private void ParseButtonClick(object sender, EventArgs e) {
    5249      if(!string.IsNullOrEmpty(expressionInput.Text)) {
    5350        try {
    5451          Content.Template = expressionInput.Text;
    55           symRegTreeChart.Content = Content.Tree;
    56           treeChart.Tree = Content.Tree;
    57 
    58           errorLabel.Text = "Template structure successfully parsed.";
    59           errorLabel.ForeColor = Color.DarkGreen;
     52          PaintTree();
     53          infoLabel.Text = "Template structure successfully parsed.";
     54          infoLabel.ForeColor = Color.DarkGreen;
    6055        } catch (Exception ex) {
    61           errorLabel.Text = ex.Message;
    62           errorLabel.ForeColor = Color.DarkRed;
     56          infoLabel.Text = ex.Message;
     57          infoLabel.ForeColor = Color.DarkRed;
    6358        }
    6459      }
    6560    }
    6661
    67     private void expressionInput_TextChanged(object sender, EventArgs e) {
    68       errorLabel.Text = "Unparsed changes! Press parse button to save changes.";
    69       errorLabel.ForeColor = Color.DarkOrange;
     62    private void ExpressionInputTextChanged(object sender, EventArgs e) {
     63      infoLabel.Text = "Unparsed changes! Press parse button to save changes.";
     64      infoLabel.ForeColor = Color.DarkOrange;
    7065    }
    7166
     67
     68    private void PaintTree() {
     69      if(Content != null && Content.Tree != null) {
     70        treeChart.Tree = Content.Tree;
     71        foreach (var n in Content.Tree.IterateNodesPrefix()) {
     72          if (n.Symbol is SubFunctionSymbol) {
     73            var visualNode = treeChart.GetVisualSymbolicExpressionTreeNode(n);
     74            visualNode.FillColor = Color.LightCyan;
     75            visualNode.LineColor = Color.SlateGray;
     76          }
     77        }
     78        treeChart.RepaintNodes();
     79      }
     80    }
    7281  }
    7382}
Note: See TracChangeset for help on using the changeset viewer.