Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11150


Ignore:
Timestamp:
07/08/14 19:46:45 (10 years ago)
Author:
mkommend
Message:

#1763: Merged r9930, r11086, r11111, r11112, r11115, r11123 into stable (all other changes were already merged to the stable branch.

Location:
stable
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs

    r11144 r11150  
    4747    private void InitializeComponent() {
    4848      this.components = new System.ComponentModel.Container();
     49      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InteractiveSymbolicDataAnalysisSolutionSimplifierView));
    4950      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5051      this.splitContainer = new System.Windows.Forms.SplitContainer();
     
    5253      this.treeStatusValue = new System.Windows.Forms.Label();
    5354      this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
     55      this.btnSimplify = new System.Windows.Forms.Button();
    5456      this.btnOptimizeConstants = new System.Windows.Forms.Button();
    55       this.btnSimplify = new System.Windows.Forms.Button();
    56       this.treeStatusLabel = new System.Windows.Forms.Label();
    57       this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    5857      this.grpViewHost = new System.Windows.Forms.GroupBox();
     58      this.treeChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.InteractiveSymbolicExpressionTreeChart();
    5959      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    6060      this.splitContainer.Panel1.SuspendLayout();
     
    104104      this.grpSimplify.Controls.Add(this.treeStatusValue);
    105105      this.grpSimplify.Controls.Add(this.flowLayoutPanel);
    106       this.grpSimplify.Controls.Add(this.treeStatusLabel);
    107106      this.grpSimplify.Controls.Add(this.treeChart);
    108107      this.grpSimplify.Dock = System.Windows.Forms.DockStyle.Fill;
     
    116115      // treeStatusValue
    117116      //
     117      this.treeStatusValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    118118      this.treeStatusValue.AutoSize = true;
    119       this.treeStatusValue.BackColor = System.Drawing.Color.Transparent;
    120       this.treeStatusValue.ForeColor = System.Drawing.Color.Green;
    121       this.treeStatusValue.Location = new System.Drawing.Point(72, 16);
     119      this.treeStatusValue.BackColor = System.Drawing.Color.White;
     120      this.treeStatusValue.ForeColor = System.Drawing.Color.Red;
     121      this.treeStatusValue.Location = new System.Drawing.Point(6, 351);
    122122      this.treeStatusValue.Name = "treeStatusValue";
    123       this.treeStatusValue.Size = new System.Drawing.Size(30, 13);
     123      this.treeStatusValue.Size = new System.Drawing.Size(63, 13);
    124124      this.treeStatusValue.TabIndex = 3;
    125       this.treeStatusValue.Text = "Valid";
     125      this.treeStatusValue.Text = "Invalid Tree";
     126      this.treeStatusValue.Visible = false;
    126127      //
    127128      // flowLayoutPanel
     
    137138      this.flowLayoutPanel.WrapContents = false;
    138139      //
    139       // btnOptimizeConstants
    140       //       
    141       this.btnOptimizeConstants.AutoSize = true;
    142       this.btnOptimizeConstants.Enabled = false;
    143       this.btnOptimizeConstants.Image = HeuristicLab.Common.Resources.VSImageLibrary.Performance;
    144       this.btnOptimizeConstants.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
    145       this.btnOptimizeConstants.Location = new System.Drawing.Point(105, 3);
    146       this.btnOptimizeConstants.Name = "btnOptimizeConstants";
    147       this.btnOptimizeConstants.Size = new System.Drawing.Size(80, 24);
    148       this.btnOptimizeConstants.TabIndex = 2;
    149       this.btnOptimizeConstants.Text = "Optimize";
    150       this.btnOptimizeConstants.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    151       this.btnOptimizeConstants.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    152       this.btnOptimizeConstants.UseVisualStyleBackColor = true;
    153       this.btnOptimizeConstants.Click += new System.EventHandler(this.btnOptimizeConstants_Click);
    154       //
    155140      // btnSimplify
    156141      //
    157142      this.btnSimplify.AutoSize = true;
    158       this.btnSimplify.Enabled = true;
    159143      this.btnSimplify.Image = HeuristicLab.Common.Resources.VSImageLibrary.FormulaEvaluator;
    160       this.btnSimplify.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
    161144      this.btnSimplify.Location = new System.Drawing.Point(3, 3);
    162145      this.btnSimplify.Name = "btnSimplify";
     
    164147      this.btnSimplify.TabIndex = 1;
    165148      this.btnSimplify.Text = "Simplify";
    166       this.btnSimplify.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    167149      this.btnSimplify.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    168150      this.btnSimplify.UseVisualStyleBackColor = true;
    169151      this.btnSimplify.Click += new System.EventHandler(this.btnSimplify_Click);
    170152      //
    171       // treeStatusLabel
    172       //
    173       this.treeStatusLabel.AutoSize = true;
    174       this.treeStatusLabel.BackColor = System.Drawing.Color.Transparent;
    175       this.treeStatusLabel.Location = new System.Drawing.Point(6, 16);
    176       this.treeStatusLabel.Name = "treeStatusLabel";
    177       this.treeStatusLabel.Size = new System.Drawing.Size(68, 13);
    178       this.treeStatusLabel.TabIndex = 2;
    179       this.treeStatusLabel.Text = "Tree Status: ";
    180       //
    181       // treeChart
    182       //
    183       this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    184             | System.Windows.Forms.AnchorStyles.Left)
    185             | System.Windows.Forms.AnchorStyles.Right)));
    186       this.treeChart.BackgroundColor = System.Drawing.Color.White;
    187       this.treeChart.LineColor = System.Drawing.Color.Black;
    188       this.treeChart.Location = new System.Drawing.Point(6, 32);
    189       this.treeChart.Name = "treeChart";
    190       this.treeChart.Size = new System.Drawing.Size(201, 332);
    191       this.treeChart.Spacing = 5;
    192       this.treeChart.SuspendRepaint = false;
    193       this.treeChart.TabIndex = 0;
    194       this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
    195       this.treeChart.Tree = null;
    196       this.treeChart.SymbolicExpressionTreeNodeDoubleClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeDoubleClicked);
     153      // btnOptimizeConstants
     154      //
     155      this.btnOptimizeConstants.AutoSize = true;
     156      this.btnOptimizeConstants.Enabled = false;
     157      this.btnOptimizeConstants.Image = HeuristicLab.Common.Resources.VSImageLibrary.Performance;
     158      this.btnOptimizeConstants.Location = new System.Drawing.Point(89, 3);
     159      this.btnOptimizeConstants.Name = "btnOptimizeConstants";
     160      this.btnOptimizeConstants.Size = new System.Drawing.Size(80, 24);
     161      this.btnOptimizeConstants.TabIndex = 2;
     162      this.btnOptimizeConstants.Text = "Optimize";
     163      this.btnOptimizeConstants.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
     164      this.btnOptimizeConstants.UseVisualStyleBackColor = true;
     165      this.btnOptimizeConstants.Click += new System.EventHandler(this.btnOptimizeConstants_Click);
    197166      //
    198167      // grpViewHost
     
    206175      this.grpViewHost.TabStop = false;
    207176      this.grpViewHost.Text = "Details";
     177      //
     178      // treeChart
     179      //
     180      this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     181            | System.Windows.Forms.AnchorStyles.Left)
     182            | System.Windows.Forms.AnchorStyles.Right)));
     183      this.treeChart.BackgroundColor = System.Drawing.Color.White;
     184      this.treeChart.LineColor = System.Drawing.Color.Black;
     185      this.treeChart.Location = new System.Drawing.Point(6, 16);
     186      this.treeChart.ModifyTree = null;
     187      this.treeChart.Name = "treeChart";
     188      this.treeChart.Size = new System.Drawing.Size(201, 348);
     189      this.treeChart.Spacing = 5;
     190      this.treeChart.SuspendRepaint = false;
     191      this.treeChart.TabIndex = 0;
     192      this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
     193      this.treeChart.Tree = null;
     194      this.treeChart.SymbolicExpressionTreeNodeDoubleClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeDoubleClicked);
    208195      //
    209196      // InteractiveSymbolicDataAnalysisSolutionSimplifierView
     
    223210      this.grpSimplify.PerformLayout();
    224211      this.flowLayoutPanel.ResumeLayout(false);
     212      this.flowLayoutPanel.PerformLayout();
    225213      this.grpViewHost.ResumeLayout(false);
    226214      this.ResumeLayout(false);
     
    230218    #endregion
    231219
    232     private HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart treeChart;
     220    private HeuristicLab.Problems.DataAnalysis.Symbolic.Views.InteractiveSymbolicExpressionTreeChart treeChart;
    233221    private System.Windows.Forms.SplitContainer splitContainer;
    234222    private HeuristicLab.MainForm.WindowsForms.ViewHost viewHost;
     
    239227    protected System.Windows.Forms.Button btnOptimizeConstants;
    240228    private System.Windows.Forms.Label treeStatusValue;
    241     private System.Windows.Forms.Label treeStatusLabel;
    242229  }
    243230}
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r11146 r11150  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3333  public abstract partial class InteractiveSymbolicDataAnalysisSolutionSimplifierView : AsynchronousContentView {
    3434    private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes;
     35    private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes;
    3536    private Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts;
     37
    3638    private enum TreeState { Valid, Invalid }
    37 
    38     public InteractiveSymbolicDataAnalysisSolutionSimplifierView() {
     39    private TreeState treeState;
     40
     41    protected InteractiveSymbolicDataAnalysisSolutionSimplifierView() {
    3942      InitializeComponent();
    4043      foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
     44      changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
    4145      nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
    4246      this.Caption = "Interactive Solution Simplifier";
     47
     48      // initialize the tree modifier that will be used to perform edit operations over the tree
     49      treeChart.ModifyTree = Modify;
     50    }
     51
     52    /// <summary>
     53    /// Remove, Replace or Insert subtrees
     54    /// </summary>
     55    /// <param name="tree">The symbolic expression tree</param>
     56    /// <param name="parent">The insertion point (ie, the parent node who will receive a new child)</param>
     57    /// <param name="oldChild">The subtree to be replaced</param>
     58    /// <param name="newChild">The replacement subtree</param>
     59    /// <param name="removeSubtree">Flag used to indicate if whole subtrees should be removed (default behavior), or just the subtree root</param>
     60    private void Modify(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode parent,
     61      ISymbolicExpressionTreeNode oldChild, ISymbolicExpressionTreeNode newChild, bool removeSubtree = true) {
     62      if (oldChild == null && newChild == null)
     63        throw new ArgumentNullException("Cannot deduce operation type from the arguments. Please provide non null operands.");
     64      if (oldChild == null) {
     65        // insertion operation
     66        parent.AddSubtree(newChild);
     67        newChild.Parent = parent;
     68      } else if (newChild == null) {
     69        // removal operation
     70        parent.RemoveSubtree(parent.IndexOfSubtree(oldChild));
     71        if (!removeSubtree) {
     72          for (int i = oldChild.SubtreeCount - 1; i >= 0; --i) {
     73            var subtree = oldChild.GetSubtree(i);
     74            oldChild.RemoveSubtree(i);
     75            parent.AddSubtree(subtree);
     76          }
     77        }
     78      } else {
     79        // replacement operation
     80        var replacementIndex = parent.IndexOfSubtree(oldChild);
     81        parent.RemoveSubtree(replacementIndex);
     82        parent.InsertSubtree(replacementIndex, newChild);
     83        newChild.Parent = parent;
     84        if (changedNodes.ContainsKey(oldChild)) {
     85          changedNodes.Add(newChild, changedNodes[oldChild]); // so that on double click the original node is restored
     86          changedNodes.Remove(oldChild);
     87        } else {
     88          changedNodes.Add(newChild, oldChild);
     89        }
     90      }
     91      treeState = IsValid(tree) ? TreeState.Valid : TreeState.Invalid;
     92      switch (treeState) {
     93        case TreeState.Valid:
     94          this.grpViewHost.Enabled = true;
     95          UpdateModel(Content.Model.SymbolicExpressionTree);
     96          break;
     97        case TreeState.Invalid:
     98          this.grpViewHost.Enabled = false;
     99          break;
     100      }
     101    }
     102
     103    // the optimizer always assumes 2 children for multiplication and addition nodes
     104    // thus, we enforce that the tree stays valid so that the constant optimization won't throw an exception
     105    // by returning 2 as the minimum allowed arity for addition and multiplication symbols
     106    private readonly Func<ISymbol, int> GetMinArity = symbol => {
     107      var min = symbol.MinimumArity;
     108      if (symbol is Multiplication || symbol is Division) return Math.Max(2, min);
     109      return min;
     110    };
     111    private bool IsValid(ISymbolicExpressionTree tree) {
     112      treeChart.Tree = tree;
     113      treeChart.Repaint();
     114      bool valid = !tree.IterateNodesPostfix().Any(node => node.SubtreeCount < GetMinArity(node.Symbol) || node.SubtreeCount > node.Symbol.MaximumArity);
     115      if (valid) {
     116        btnOptimizeConstants.Enabled = true;
     117        btnSimplify.Enabled = true;
     118        treeStatusValue.Visible = false;
     119      } else {
     120        btnOptimizeConstants.Enabled = false;
     121        btnSimplify.Enabled = false;
     122        treeStatusValue.Visible = true;
     123      }
     124      this.Refresh();
     125      return valid;
    43126    }
    44127
     
    83166
    84167      var impactAndReplacementValues = CalculateImpactAndReplacementValues(tree);
    85       nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
    86168      var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
    87169      foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
    88170        foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    89171      }
     172      nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
    90173      PaintNodeImpacts();
    91174    }
     
    104187
    105188    private void treeChart_SymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
     189      if (treeState == TreeState.Invalid) return;
    106190      var visualNode = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender;
    107       if (visualNode.Content == null) { throw new Exception("Visual node content cannot be null."); }
     191      if (visualNode.Content == null) { throw new Exception("VisualNode content cannot be null."); }
    108192      var symbExprTreeNode = (SymbolicExpressionTreeNode)visualNode.Content;
    109       if (!foldedNodes.ContainsKey(symbExprTreeNode)) return; // constant nodes cannot be folded
     193      var tree = Content.Model.SymbolicExpressionTree;
    110194      var parent = symbExprTreeNode.Parent;
    111195      int indexOfSubtree = parent.IndexOfSubtree(symbExprTreeNode);
    112       SwitchNodeWithReplacementNode(parent, indexOfSubtree);
    113       UpdateModel(Content.Model.SymbolicExpressionTree);
     196      if (changedNodes.ContainsKey(symbExprTreeNode)) {
     197        // undo node change
     198        parent.RemoveSubtree(indexOfSubtree);
     199        var originalNode = changedNodes[symbExprTreeNode];
     200        parent.InsertSubtree(indexOfSubtree, originalNode);
     201        changedNodes.Remove(symbExprTreeNode);
     202      } else if (foldedNodes.ContainsKey(symbExprTreeNode)) {
     203        // undo node folding
     204        SwitchNodeWithReplacementNode(parent, indexOfSubtree);
     205      }
     206      UpdateModel(tree);
    114207    }
    115208
     
    130223      double max = impacts.Max();
    131224      double min = impacts.Min();
    132       foreach (var treeNode in Content.Model.SymbolicExpressionTree.IterateNodesPostfix()) {
     225      foreach (ISymbolicExpressionTreeNode treeNode in Content.Model.SymbolicExpressionTree.IterateNodesPostfix()) {
    133226        VisualTreeNode<ISymbolicExpressionTreeNode> visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
    134227
    135228        if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
    136           visualTree.ToolTip = visualTree.Content.ToString(); // to avoid duplicate tooltips
     229          visualTree.ToolTip = visualTree.Content.ToString();
    137230          double impact = nodeImpacts[treeNode];
    138231
     
    156249        }
    157250        if (visualTree != null)
    158           if (treeNode is ConstantTreeNode && foldedNodes.ContainsKey(treeNode)) {
     251          if (changedNodes.ContainsKey(treeNode)) {
     252            visualTree.LineColor = Color.DodgerBlue;
     253          } else if (treeNode is ConstantTreeNode && foldedNodes.ContainsKey(treeNode)) {
    159254            visualTree.LineColor = Color.DarkOrange;
    160255          }
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs

    r9456 r11150  
    5656      this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
    5757      this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     58      this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
     59      this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
    5860      this.SuspendLayout();
    5961      //
     
    6163      //
    6264      this.insertNodeToolStripMenuItem.Name = "insertNodeToolStripMenuItem";
    63       this.insertNodeToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
     65      this.insertNodeToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
    6466      this.insertNodeToolStripMenuItem.Text = "Insert Node";
    6567      this.insertNodeToolStripMenuItem.Click += new System.EventHandler(this.insertNodeToolStripMenuItem_Click);
     
    6870      //
    6971      this.changeNodeToolStripMenuItem.Name = "changeNodeToolStripMenuItem";
    70       this.changeNodeToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
     72      this.changeNodeToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
    7173      this.changeNodeToolStripMenuItem.Text = "Change Node";
    7274      this.changeNodeToolStripMenuItem.Click += new System.EventHandler(this.changeNodeToolStripMenuItem_Click);
     
    7577      //
    7678      this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
    77       this.cutToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
    78       this.cutToolStripMenuItem.Text = "Cut";
     79      this.cutToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
     80      this.cutToolStripMenuItem.Text = "Cut Subtree";
    7981      this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click);
    8082      //
     
    8587            this.removeSubtreeToolStripMenuItem});
    8688      this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
    87       this.removeToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
     89      this.removeToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
    8890      this.removeToolStripMenuItem.Text = "Remove";
    8991      this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeSubtreeToolStripMenuItem_Click);
     
    106108      //
    107109      this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
    108       this.pasteToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
    109       this.pasteToolStripMenuItem.Text = "Paste";
     110      this.pasteToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
     111      this.pasteToolStripMenuItem.Text = "Paste Subtree";
    110112      this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Clicked);
    111113      //
     
    118120      //
    119121      this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
    120       this.copyToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
    121       this.copyToolStripMenuItem.Text = "Copy";
     122      this.copyToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
     123      this.copyToolStripMenuItem.Text = "Copy Subtree";
    122124      this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
     125      //
     126      // toolStripSeparator1
     127      //
     128      this.toolStripSeparator1.Name = "toolStripSeparator1";
     129      this.toolStripSeparator1.Size = new System.Drawing.Size(162, 6);
     130      //
     131      // toolStripSeparator2
     132      //
     133      this.toolStripSeparator2.Name = "toolStripSeparator2";
     134      this.toolStripSeparator2.Size = new System.Drawing.Size(162, 6);
    123135      //
    124136      // contextMenuStrip
    125137      //
    126138      this.contextMenuStrip.Opened += this.contextMenuStrip_Opened;
    127       this.contextMenuStrip.Items.AddRange(new ToolStripItem[] { insertNodeToolStripMenuItem,
     139      this.contextMenuStrip.Items.AddRange(new ToolStripItem[] { toolStripSeparator1,
     140                                                                 insertNodeToolStripMenuItem,
     141                                                                 removeToolStripMenuItem,
    128142                                                                 changeNodeToolStripMenuItem,
     143                                                                 toolStripSeparator2,
    129144                                                                 copyToolStripMenuItem,
    130145                                                                 cutToolStripMenuItem,
    131                                                                  removeToolStripMenuItem,
    132146                                                                 pasteToolStripMenuItem });
    133147      //
     
    139153      this.Name = "InteractiveSymbolicExpressionTreeChart";
    140154      this.ResumeLayout(false);
    141 
    142155    }
    143156
     
    154167    private ToolStripSeparator toolStripSeparator;
    155168    private ToolStripMenuItem copyToolStripMenuItem;
     169    private ToolStripSeparator toolStripSeparator1;
     170    private ToolStripSeparator toolStripSeparator2;
    156171  }
    157172}
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs

    r11120 r11150  
    7676        pasteToolStripMenuItem.Visible = true;
    7777        pasteToolStripMenuItem.Enabled = tempNode != null && insertNodeToolStripMenuItem.Enabled
    78                                                           && !(lastOp == EditOp.CutSubtree
    79                                                                && tempNode.IterateNodesBreadth().Contains(currSelected.Content));
     78                                                          && !(lastOp == EditOp.CutSubtree && tempNode.IterateNodesBreadth().Contains(node))
     79                                                          && node.SubtreeCount < node.Symbol.MaximumArity;
    8080      }
    8181    }
     
    8383    protected override void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    8484      currSelected = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender; ;
    85       if (currSelected != null) {
    86         currSelected.LineColor = Color.FromArgb(130, currSelected.LineColor);
    87         RepaintNode(currSelected);
    88       }
    8985      base.OnSymbolicExpressionTreeNodeClicked(sender, e);
    90     }
    91 
    92     protected override void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {
    93       if (currSelected != null) {
    94         currSelected.LineColor = Color.FromArgb(255, currSelected.LineColor);
    95         RepaintNode(currSelected);
    96       }
    97       base.SymbolicExpressionTreeChart_MouseClick(sender, e);
    9886    }
    9987
     
    10896
    10997      using (var dialog = new InsertNodeDialog()) {
    110         dialog.SetAllowedSymbols(parent.Grammar.AllowedSymbols.Where(s => s.Enabled && s.InitialFrequency > 0.0 && !(s is ProgramRootSymbol || s is StartSymbol || s is Defun)));
     98        dialog.SetAllowedSymbols(parent.Grammar.Symbols.Where(s => !(s is ProgramRootSymbol || s is StartSymbol || s is Defun || s is GroupSymbol))); // allow everything
    11199        dialog.ShowDialog(this);
    112100        if (dialog.DialogResult != DialogResult.OK) return;
     
    172160        foreach (var subtree in tempNode.IterateNodesPostfix()) {
    173161          var visualNode = GetVisualSymbolicExpressionTreeNode(subtree);
    174           visualNode.LineColor = Color.FromArgb(255, visualNode.LineColor); // reset the alpha value to 255
    175           visualNode.TextColor = Color.FromArgb(255, visualNode.TextColor);
     162          visualNode.LineColor = Color.Black;
     163          visualNode.TextColor = Color.Black;
    176164          if (subtree.Parent != null) {
    177165            var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(subtree.Parent, subtree);
    178             visualLine.LineColor = Color.FromArgb(255, visualLine.LineColor);
     166            visualLine.LineColor = Color.Black;
    179167          }
    180168        }
     
    183171      foreach (var node in tempNode.IterateNodesPostfix()) {
    184172        var visualNode = GetVisualSymbolicExpressionTreeNode(node);
    185         visualNode.LineColor = Color.FromArgb(100, visualNode.LineColor);
    186         visualNode.TextColor = Color.FromArgb(100, visualNode.TextColor);
     173        visualNode.LineColor = Color.LightGray;
     174        visualNode.TextColor = Color.LightGray;
    187175        foreach (var subtree in node.Subtrees) {
    188176          var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node, subtree);
    189           visualLine.LineColor = Color.FromArgb(100, visualLine.LineColor);
    190         }
    191       }
    192       currSelected = null;
    193       Repaint();
     177          visualLine.LineColor = Color.LightGray;
     178        }
     179      }
     180      currSelected = null;
     181      RepaintNodes(); // no need to redo the layout and repaint everything since this operation does not change the tree
    194182    }
    195183    private void removeNodeToolStripMenuItem_Click(object sender, EventArgs e) {
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.Designer.cs

    r9456 r11150  
    6767      // oldValueTextBox
    6868      //
    69       this.oldValueTextBox.Location = new System.Drawing.Point(123, 6);
     69      this.oldValueTextBox.Location = new System.Drawing.Point(106, 6);
    7070      this.oldValueTextBox.Name = "oldValueTextBox";
    7171      this.oldValueTextBox.ReadOnly = true;
     
    7575      // newValueTextBox
    7676      //
    77       this.newValueTextBox.Location = new System.Drawing.Point(123, 42);
     77      this.newValueTextBox.Location = new System.Drawing.Point(106, 32);
    7878      this.newValueTextBox.Name = "newValueTextBox";
    7979      this.newValueTextBox.Size = new System.Drawing.Size(131, 20);
     
    8686      //
    8787      this.newValueLabel.AutoSize = true;
    88       this.newValueLabel.Location = new System.Drawing.Point(12, 45);
     88      this.newValueLabel.Location = new System.Drawing.Point(12, 35);
    8989      this.newValueLabel.Name = "newValueLabel";
    9090      this.newValueLabel.Size = new System.Drawing.Size(59, 13);
     
    101101      //
    102102      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    103       this.okButton.Location = new System.Drawing.Point(15, 79);
     103      this.okButton.Location = new System.Drawing.Point(81, 66);
    104104      this.okButton.Name = "okButton";
    105105      this.okButton.Size = new System.Drawing.Size(75, 23);
     
    113113      this.cancelButton.CausesValidation = false;
    114114      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    115       this.cancelButton.Location = new System.Drawing.Point(179, 79);
     115      this.cancelButton.Location = new System.Drawing.Point(162, 66);
    116116      this.cancelButton.Name = "cancelButton";
    117117      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     
    127127      this.AutoSize = true;
    128128      this.CancelButton = this.cancelButton;
    129       this.ClientSize = new System.Drawing.Size(269, 116);
     129      this.ClientSize = new System.Drawing.Size(248, 101);
    130130      this.ControlBox = false;
    131131      this.Controls.Add(this.cancelButton);
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs

    r9456 r11150  
    6363      //
    6464      this.nodeSymbolLabel.AutoSize = true;
    65       this.nodeSymbolLabel.Location = new System.Drawing.Point(13, 13);
     65      this.nodeSymbolLabel.Location = new System.Drawing.Point(19, 13);
    6666      this.nodeSymbolLabel.Name = "nodeSymbolLabel";
    6767      this.nodeSymbolLabel.Size = new System.Drawing.Size(41, 13);
     
    7373      this.allowedSymbolsCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    7474      this.allowedSymbolsCombo.FormattingEnabled = true;
    75       this.allowedSymbolsCombo.Location = new System.Drawing.Point(120, 10);
     75      this.allowedSymbolsCombo.Location = new System.Drawing.Point(101, 10);
    7676      this.allowedSymbolsCombo.Name = "allowedSymbolsCombo";
    77       this.allowedSymbolsCombo.Size = new System.Drawing.Size(108, 21);
     77      this.allowedSymbolsCombo.Size = new System.Drawing.Size(127, 21);
    7878      this.allowedSymbolsCombo.TabIndex = 1;
    7979      this.allowedSymbolsCombo.SelectedIndexChanged += new System.EventHandler(this.allowedSymbolsCombo_SelectedIndexChanged);
     
    8383      //
    8484      this.variableWeightLabel.AutoSize = true;
    85       this.variableWeightLabel.Location = new System.Drawing.Point(13, 44);
     85      this.variableWeightLabel.Location = new System.Drawing.Point(19, 40);
    8686      this.variableWeightLabel.Name = "variableWeightLabel";
    8787      this.variableWeightLabel.Size = new System.Drawing.Size(41, 13);
     
    9393      //
    9494      this.variableNameLabel.AutoSize = true;
    95       this.variableNameLabel.Location = new System.Drawing.Point(13, 74);
     95      this.variableNameLabel.Location = new System.Drawing.Point(19, 66);
    9696      this.variableNameLabel.Name = "variableNameLabel";
    9797      this.variableNameLabel.Size = new System.Drawing.Size(35, 13);
     
    104104      this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    105105      this.variableNamesCombo.FormattingEnabled = true;
    106       this.variableNamesCombo.Location = new System.Drawing.Point(120, 71);
     106      this.variableNamesCombo.Location = new System.Drawing.Point(101, 63);
    107107      this.variableNamesCombo.Name = "variableNamesCombo";
    108       this.variableNamesCombo.Size = new System.Drawing.Size(108, 21);
     108      this.variableNamesCombo.Size = new System.Drawing.Size(127, 21);
    109109      this.variableNamesCombo.TabIndex = 5;
    110110      this.variableNamesCombo.Visible = false;
     
    112112      // variableWeightTextBox
    113113      //
    114       this.variableWeightTextBox.Location = new System.Drawing.Point(120, 41);
     114      this.variableWeightTextBox.Location = new System.Drawing.Point(101, 37);
    115115      this.variableWeightTextBox.Name = "variableWeightTextBox";
    116       this.variableWeightTextBox.Size = new System.Drawing.Size(108, 20);
     116      this.variableWeightTextBox.Size = new System.Drawing.Size(127, 20);
    117117      this.variableWeightTextBox.TabIndex = 6;
    118118      this.variableWeightTextBox.Text = "0.0";
     
    122122      // constantValueTextBox
    123123      //
    124       this.constantValueTextBox.Location = new System.Drawing.Point(120, 41);
     124      this.constantValueTextBox.Location = new System.Drawing.Point(101, 37);
    125125      this.constantValueTextBox.Name = "constantValueTextBox";
    126       this.constantValueTextBox.Size = new System.Drawing.Size(108, 20);
     126      this.constantValueTextBox.Size = new System.Drawing.Size(127, 20);
    127127      this.constantValueTextBox.TabIndex = 7;
    128128      this.constantValueTextBox.Text = "0.0";
     
    133133      //
    134134      this.constantValueLabel.AutoSize = true;
    135       this.constantValueLabel.Location = new System.Drawing.Point(13, 44);
     135      this.constantValueLabel.Location = new System.Drawing.Point(19, 40);
    136136      this.constantValueLabel.Name = "constantValueLabel";
    137137      this.constantValueLabel.Size = new System.Drawing.Size(34, 13);
     
    149149      //
    150150      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    151       this.okButton.Location = new System.Drawing.Point(12, 112);
     151      this.okButton.Location = new System.Drawing.Point(72, 98);
    152152      this.okButton.Name = "okButton";
    153153      this.okButton.Size = new System.Drawing.Size(75, 23);
     
    160160      //
    161161      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    162       this.cancelButton.Location = new System.Drawing.Point(153, 112);
     162      this.cancelButton.Location = new System.Drawing.Point(153, 98);
    163163      this.cancelButton.Name = "cancelButton";
    164164      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     
    173173      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    174174      this.CancelButton = this.cancelButton;
    175       this.ClientSize = new System.Drawing.Size(240, 147);
     175      this.ClientSize = new System.Drawing.Size(241, 133);
    176176      this.ControlBox = false;
    177177      this.Controls.Add(this.cancelButton);
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeVariableNodeEditDialog.Designer.cs

    r9456 r11150  
    6161      //
    6262      this.originalValueLabel.AutoSize = true;
    63       this.originalValueLabel.Location = new System.Drawing.Point(12, 48);
     63      this.originalValueLabel.Location = new System.Drawing.Point(6, 42);
    6464      this.originalValueLabel.Name = "originalValueLabel";
    6565      this.originalValueLabel.Size = new System.Drawing.Size(72, 13);
     
    6969      // oldValueTextBox
    7070      //
    71       this.oldValueTextBox.Location = new System.Drawing.Point(123, 45);
     71      this.oldValueTextBox.Location = new System.Drawing.Point(101, 39);
    7272      this.oldValueTextBox.Name = "oldValueTextBox";
    7373      this.oldValueTextBox.ReadOnly = true;
     
    7777      // newValueTextBox
    7878      //
    79       this.newValueTextBox.Location = new System.Drawing.Point(123, 82);
     79      this.newValueTextBox.Location = new System.Drawing.Point(101, 65);
    8080      this.newValueTextBox.Name = "newValueTextBox";
    8181      this.newValueTextBox.Size = new System.Drawing.Size(131, 20);
     
    8888      //
    8989      this.newValueLabel.AutoSize = true;
    90       this.newValueLabel.Location = new System.Drawing.Point(12, 85);
     90      this.newValueLabel.Location = new System.Drawing.Point(6, 68);
    9191      this.newValueLabel.Name = "newValueLabel";
    9292      this.newValueLabel.Size = new System.Drawing.Size(59, 13);
     
    103103      //
    104104      this.variableNameLabel.AutoSize = true;
    105       this.variableNameLabel.Location = new System.Drawing.Point(12, 12);
     105      this.variableNameLabel.Location = new System.Drawing.Point(6, 15);
    106106      this.variableNameLabel.Name = "variableNameLabel";
    107107      this.variableNameLabel.Size = new System.Drawing.Size(76, 13);
     
    114114      this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    115115      this.variableNamesCombo.FormattingEnabled = true;
    116       this.variableNamesCombo.Location = new System.Drawing.Point(123, 9);
     116      this.variableNamesCombo.Location = new System.Drawing.Point(101, 12);
    117117      this.variableNamesCombo.Name = "variableNamesCombo";
    118118      this.variableNamesCombo.Size = new System.Drawing.Size(131, 21);
     
    126126      //
    127127      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    128       this.okButton.Location = new System.Drawing.Point(15, 119);
     128      this.okButton.Location = new System.Drawing.Point(75, 98);
    129129      this.okButton.Name = "okButton";
    130130      this.okButton.Size = new System.Drawing.Size(75, 23);
     
    138138      this.cancelButton.CausesValidation = false;
    139139      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    140       this.cancelButton.Location = new System.Drawing.Point(179, 119);
     140      this.cancelButton.Location = new System.Drawing.Point(156, 98);
    141141      this.cancelButton.Name = "cancelButton";
    142142      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     
    152152      this.AutoSize = true;
    153153      this.CancelButton = this.cancelButton;
    154       this.ClientSize = new System.Drawing.Size(269, 154);
     154      this.ClientSize = new System.Drawing.Size(244, 134);
    155155      this.ControlBox = false;
    156156      this.Controls.Add(this.cancelButton);
Note: See TracChangeset for help on using the changeset viewer.