Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/01/21 13:40:55 (3 years ago)
Author:
chaider
Message:

#3140

  • some more refactoring
  • added possibility to set value of num nodes in infix parser
  • changed displaying style of number
Location:
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r17579 r18100  
    203203
    204204        var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
    205         foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
     205        foreach (var pair in replacementValues.Where(pair => !(pair.Key is NumberTreeNode))) {
    206206          foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    207207        }
     
    250250    }
    251251
    252     private static ConstantTreeNode MakeConstantTreeNode(double value) {
    253       var constant = new Constant { MinValue = value - 1, MaxValue = value + 1 };
    254       var constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();
     252    private static NumberTreeNode MakeConstantTreeNode(double value) {
     253      var constant = new Number { MinValue = value - 1, MaxValue = value + 1 };
     254      var constantTreeNode = (NumberTreeNode)constant.CreateTreeNode();
    255255      constantTreeNode.Value = value;
    256256      return constantTreeNode;
     
    297297        VisualTreeNode<ISymbolicExpressionTreeNode> visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
    298298
    299         if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
     299        if (!(treeNode is NumberTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
    300300          visualTree.ToolTip = visualTree.Content.ToString();
    301301          double impact = nodeImpacts[treeNode];
     
    314314          }
    315315          visualTree.ToolTip += Environment.NewLine + "Node impact: " + impact;
    316           var constantReplacementNode = foldedNodes[treeNode] as ConstantTreeNode;
     316          var constantReplacementNode = foldedNodes[treeNode] as NumberTreeNode;
    317317          if (constantReplacementNode != null) {
    318318            visualTree.ToolTip += Environment.NewLine + "Replacement value: " + constantReplacementNode.Value;
     
    324324          if (changedNodes.ContainsKey(treeNode)) {
    325325            visualTree.LineColor = Color.DodgerBlue;
    326           } else if (treeNode is ConstantTreeNode && foldedNodes.ContainsKey(treeNode)) {
     326          } else if (treeNode is NumberTreeNode && foldedNodes.ContainsKey(treeNode)) {
    327327            visualTree.LineColor = Color.DarkOrange;
    328328          }
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs

    r17180 r18100  
    104104        var symbol = dialog.SelectedSymbol;
    105105        var node = symbol.CreateTreeNode();
    106         if (node is ConstantTreeNode) {
    107           var constant = node as ConstantTreeNode;
    108           constant.Value = double.Parse(dialog.constantValueTextBox.Text);
     106        if (node is NumberTreeNode) {
     107          var number = node as NumberTreeNode;
     108          number.Value = double.Parse(dialog.numberValueTextBox.Text);
    109109        } else if (node is VariableTreeNode) {
    110110          var variable = node as VariableTreeNode;
     
    133133      ISymbolicExpressionTreeNode newNode = null;
    134134      var result = DialogResult.Cancel;
    135       if (node is ConstantTreeNode) {
    136         using (var dialog = new ConstantNodeEditDialog(node)) {
     135      if (node is NumberTreeNode) {
     136        using (var dialog = new NumberNodeEditDialog(node)) {
    137137          dialog.ShowDialog(this);
    138138          newNode = dialog.NewNode;
     
    200200      // check if the copied/cut node (stored in the tempNode) can be inserted as a child of the current selected node
    201201      var node = currSelected.Content;
    202       if (node is ConstantTreeNode || node is VariableTreeNode) return;
     202      if (node is NumberTreeNode || node is VariableTreeNode) return;
    203203      // check if the currently selected node can accept the copied node as a child
    204204      // no need to check the grammar, an arity check will do just fine here
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/ConstantView.cs

    r17180 r18100  
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    29   [View("Constant View")]
    30   [Content(typeof(Constant), true)]
     29  [View("Number View")]
     30  [Content(typeof(Number), true)]
    3131  public partial class ConstantView : SymbolView {
    32     public new Constant Content {
    33       get { return (Constant)base.Content; }
     32    public new Number Content {
     33      get { return (Number)base.Content; }
    3434      set { base.Content = value; }
    3535    }
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.Designer.cs

    r17180 r18100  
    2121
    2222namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    23   partial class ConstantNodeEditDialog {
     23  partial class NumberNodeEditDialog {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    121121      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
    122122      //
    123       // ConstantNodeEditDialog
     123      // NumberNodeEditDialog
    124124      //
    125125      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     
    138138      this.MaximizeBox = false;
    139139      this.MinimizeBox = false;
    140       this.Name = "ConstantNodeEditDialog";
     140      this.Name = "NumberNodeEditDialog";
    141141      this.ShowIcon = false;
    142142      this.ShowInTaskbar = false;
    143143      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    144144      this.Text = "Edit constant value";
    145       this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ConstantNodeEditDialog_KeyDown);
     145      this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.NumberNodeEditDialog_KeyDown);
    146146      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    147147      this.ResumeLayout(false);
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs

    r17180 r18100  
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    30   public partial class ConstantNodeEditDialog : Form {
    31     private ConstantTreeNode constantTreeNode;
    32     public ConstantTreeNode NewNode {
    33       get { return constantTreeNode; }
     30  public partial class NumberNodeEditDialog : Form {
     31    private NumberTreeNode numberTreeNode;
     32    public NumberTreeNode NewNode {
     33      get { return numberTreeNode; }
    3434      set {
    3535        if (InvokeRequired)
    36           Invoke(new Action<SymbolicExpressionTreeNode>(x => constantTreeNode = (ConstantTreeNode)x), value);
     36          Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (NumberTreeNode)x), value);
    3737        else
    38           constantTreeNode = value;
     38          numberTreeNode = value;
    3939      }
    4040    }
    4141
    42     public ConstantNodeEditDialog(ISymbolicExpressionTreeNode node) {
     42    public NumberNodeEditDialog(ISymbolicExpressionTreeNode node) {
    4343      InitializeComponent();
    4444      oldValueTextBox.TabStop = false; // cannot receive focus using tab key
    45       NewNode = (ConstantTreeNode)node;
     45      NewNode = (NumberTreeNode)node;
    4646      InitializeFields();
    4747    }
     
    4949    private void InitializeFields() {
    5050      if (NewNode == null)
    51         throw new ArgumentException("Node is not a constant.");
     51        throw new ArgumentException("Node is not a number.");
    5252      else {
    5353        this.Text = "Edit constant";
    54         newValueTextBox.Text = oldValueTextBox.Text = Math.Round(constantTreeNode.Value, 4).ToString();
     54        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(numberTreeNode.Value, 4).ToString();
    5555      }
    5656    }
     
    8787    // proxy handler passing key strokes to the parent control
    8888    private void childControl_KeyDown(object sender, KeyEventArgs e) {
    89       ConstantNodeEditDialog_KeyDown(sender, e);
     89      NumberNodeEditDialog_KeyDown(sender, e);
    9090    }
    9191
    92     private void ConstantNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
     92    private void NumberNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {
    9393      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
    9494        if (!ValidateChildren()) return;
     
    100100    public event EventHandler DialogValidated;
    101101    private void OnDialogValidated(object sender, EventArgs e) {
    102       if (constantTreeNode == null) return;
     102      if (numberTreeNode == null) return;
    103103      var value = double.Parse(newValueTextBox.Text);
    104104      // we impose an extra validation condition: that the new value is different from the original value
    105       if (constantTreeNode.Value.Equals(value)) return;
     105      if (numberTreeNode.Value.Equals(value)) return;
    106106
    107       constantTreeNode.Value = value;
     107      numberTreeNode.Value = value;
    108108      DialogResult = DialogResult.OK;
    109109      var dialogValidated = DialogValidated;
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs

    r17180 r18100  
    5252      this.variableNamesCombo = new System.Windows.Forms.ComboBox();
    5353      this.variableWeightTextBox = new System.Windows.Forms.TextBox();
    54       this.constantValueTextBox = new System.Windows.Forms.TextBox();
    55       this.constantValueLabel = new System.Windows.Forms.Label();
     54      this.numberValueTextBox = new System.Windows.Forms.TextBox();
     55      this.numberValueLabel = new System.Windows.Forms.Label();
    5656      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    5757      this.okButton = new System.Windows.Forms.Button();
     
    121121      this.variableWeightTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.variableWeightTextBox_Validating);
    122122      //
    123       // constantValueTextBox
    124       //
    125       this.constantValueTextBox.Location = new System.Drawing.Point(101, 37);
    126       this.constantValueTextBox.Name = "constantValueTextBox";
    127       this.constantValueTextBox.Size = new System.Drawing.Size(127, 20);
    128       this.constantValueTextBox.TabIndex = 7;
    129       this.constantValueTextBox.Text = "0.0";
    130       this.constantValueTextBox.Visible = false;
    131       this.constantValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.constantValueTextBox_Validating);
    132       //
    133       // constantValueLabel
    134       //
    135       this.constantValueLabel.AutoSize = true;
    136       this.constantValueLabel.Location = new System.Drawing.Point(19, 40);
    137       this.constantValueLabel.Name = "constantValueLabel";
    138       this.constantValueLabel.Size = new System.Drawing.Size(34, 13);
    139       this.constantValueLabel.TabIndex = 8;
    140       this.constantValueLabel.Text = "Value";
    141       this.constantValueLabel.Visible = false;
     123      // numberValueTextBox
     124      //
     125      this.numberValueTextBox.Location = new System.Drawing.Point(101, 37);
     126      this.numberValueTextBox.Name = "numberValueTextBox";
     127      this.numberValueTextBox.Size = new System.Drawing.Size(127, 20);
     128      this.numberValueTextBox.TabIndex = 7;
     129      this.numberValueTextBox.Text = "0.0";
     130      this.numberValueTextBox.Visible = false;
     131      this.numberValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.numberValueTextBox_Validating);
     132      //
     133      // numberValueLabel
     134      //
     135      this.numberValueLabel.AutoSize = true;
     136      this.numberValueLabel.Location = new System.Drawing.Point(19, 40);
     137      this.numberValueLabel.Name = "numberValueLabel";
     138      this.numberValueLabel.Size = new System.Drawing.Size(34, 13);
     139      this.numberValueLabel.TabIndex = 8;
     140      this.numberValueLabel.Text = "Value";
     141      this.numberValueLabel.Visible = false;
    142142      //
    143143      // errorProvider
     
    187187      this.Controls.Add(this.cancelButton);
    188188      this.Controls.Add(this.okButton);
    189       this.Controls.Add(this.constantValueLabel);
    190       this.Controls.Add(this.constantValueTextBox);
     189      this.Controls.Add(this.numberValueLabel);
     190      this.Controls.Add(this.numberValueTextBox);
    191191      this.Controls.Add(this.variableWeightTextBox);
    192192      this.Controls.Add(this.variableNamesCombo);
     
    211211    private System.Windows.Forms.Label variableWeightLabel;
    212212    private System.Windows.Forms.Label variableNameLabel;
    213     private System.Windows.Forms.Label constantValueLabel;
     213    private System.Windows.Forms.Label numberValueLabel;
    214214    private System.Windows.Forms.ErrorProvider errorProvider;
    215     internal System.Windows.Forms.TextBox constantValueTextBox;
     215    internal System.Windows.Forms.TextBox numberValueTextBox;
    216216    internal System.Windows.Forms.TextBox variableWeightTextBox;
    217217    internal System.Windows.Forms.ComboBox variableNamesCombo;
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs

    r17180 r18100  
    5757      var combo = (ComboBox)sender;
    5858      var symbol = combo.Items[combo.SelectedIndex];
    59       if (symbol is Constant) {
     59      if (symbol is Number) {
    6060        // add controls to the dialog for changing the constant value
    6161        variableNameLabel.Visible = false;
     
    6363        variableWeightLabel.Visible = false;
    6464        variableWeightTextBox.Visible = false;
    65         constantValueLabel.Visible = true;
    66         constantValueTextBox.Visible = true;
     65        numberValueLabel.Visible = true;
     66        numberValueTextBox.Visible = true;
    6767      } else if (symbol is VariableBase) {
    6868        var variableSymbol = (VariableBase)symbol;
     
    8080        variableWeightLabel.Visible = true;
    8181        variableWeightTextBox.Visible = true;
    82         constantValueLabel.Visible = false;
    83         constantValueTextBox.Visible = false;
     82        numberValueLabel.Visible = false;
     83        numberValueTextBox.Visible = false;
    8484        // add controls to the dialog for changing the variable name or weight
    8585      } else {
     
    8888        variableWeightLabel.Visible = false;
    8989        variableWeightTextBox.Visible = false;
    90         constantValueLabel.Visible = false;
    91         constantValueTextBox.Visible = false;
     90        numberValueLabel.Visible = false;
     91        numberValueTextBox.Visible = false;
    9292      }
    9393    }
     
    102102    }
    103103
    104     private void constantValueTextBox_Validating(object sender, CancelEventArgs e) {
     104    private void numberValueTextBox_Validating(object sender, CancelEventArgs e) {
    105105      string errorMessage;
    106       if (ValidateDoubleValue(constantValueTextBox.Text, out errorMessage)) return;
     106      if (ValidateDoubleValue(numberValueTextBox.Text, out errorMessage)) return;
    107107      e.Cancel = true;
    108       errorProvider.SetError(constantValueTextBox, errorMessage);
    109       constantValueTextBox.SelectAll();
     108      errorProvider.SetError(numberValueTextBox, errorMessage);
     109      numberValueTextBox.SelectAll();
    110110    }
    111111
Note: See TracChangeset for help on using the changeset viewer.