- Timestamp:
- 12/01/21 13:40:55 (3 years ago)
- 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 203 203 204 204 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))) { 206 206 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 207 207 } … … 250 250 } 251 251 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(); 255 255 constantTreeNode.Value = value; 256 256 return constantTreeNode; … … 297 297 VisualTreeNode<ISymbolicExpressionTreeNode> visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode); 298 298 299 if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {299 if (!(treeNode is NumberTreeNode) && nodeImpacts.ContainsKey(treeNode)) { 300 300 visualTree.ToolTip = visualTree.Content.ToString(); 301 301 double impact = nodeImpacts[treeNode]; … … 314 314 } 315 315 visualTree.ToolTip += Environment.NewLine + "Node impact: " + impact; 316 var constantReplacementNode = foldedNodes[treeNode] as ConstantTreeNode;316 var constantReplacementNode = foldedNodes[treeNode] as NumberTreeNode; 317 317 if (constantReplacementNode != null) { 318 318 visualTree.ToolTip += Environment.NewLine + "Replacement value: " + constantReplacementNode.Value; … … 324 324 if (changedNodes.ContainsKey(treeNode)) { 325 325 visualTree.LineColor = Color.DodgerBlue; 326 } else if (treeNode is ConstantTreeNode && foldedNodes.ContainsKey(treeNode)) {326 } else if (treeNode is NumberTreeNode && foldedNodes.ContainsKey(treeNode)) { 327 327 visualTree.LineColor = Color.DarkOrange; 328 328 } -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
r17180 r18100 104 104 var symbol = dialog.SelectedSymbol; 105 105 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); 109 109 } else if (node is VariableTreeNode) { 110 110 var variable = node as VariableTreeNode; … … 133 133 ISymbolicExpressionTreeNode newNode = null; 134 134 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)) { 137 137 dialog.ShowDialog(this); 138 138 newNode = dialog.NewNode; … … 200 200 // check if the copied/cut node (stored in the tempNode) can be inserted as a child of the current selected node 201 201 var node = currSelected.Content; 202 if (node is ConstantTreeNode || node is VariableTreeNode) return;202 if (node is NumberTreeNode || node is VariableTreeNode) return; 203 203 // check if the currently selected node can accept the copied node as a child 204 204 // 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 27 27 28 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 29 [View(" ConstantView")]30 [Content(typeof( Constant), true)]29 [View("Number View")] 30 [Content(typeof(Number), true)] 31 31 public partial class ConstantView : SymbolView { 32 public new ConstantContent {33 get { return ( Constant)base.Content; }32 public new Number Content { 33 get { return (Number)base.Content; } 34 34 set { base.Content = value; } 35 35 } -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.Designer.cs
r17180 r18100 21 21 22 22 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 23 partial class ConstantNodeEditDialog {23 partial class NumberNodeEditDialog { 24 24 /// <summary> 25 25 /// Required designer variable. … … 121 121 this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); 122 122 // 123 // ConstantNodeEditDialog123 // NumberNodeEditDialog 124 124 // 125 125 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); … … 138 138 this.MaximizeBox = false; 139 139 this.MinimizeBox = false; 140 this.Name = " ConstantNodeEditDialog";140 this.Name = "NumberNodeEditDialog"; 141 141 this.ShowIcon = false; 142 142 this.ShowInTaskbar = false; 143 143 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 144 144 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); 146 146 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 147 147 this.ResumeLayout(false); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs
r17180 r18100 28 28 29 29 namespace 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; } 34 34 set { 35 35 if (InvokeRequired) 36 Invoke(new Action<SymbolicExpressionTreeNode>(x => constantTreeNode = (ConstantTreeNode)x), value);36 Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (NumberTreeNode)x), value); 37 37 else 38 constantTreeNode = value;38 numberTreeNode = value; 39 39 } 40 40 } 41 41 42 public ConstantNodeEditDialog(ISymbolicExpressionTreeNode node) {42 public NumberNodeEditDialog(ISymbolicExpressionTreeNode node) { 43 43 InitializeComponent(); 44 44 oldValueTextBox.TabStop = false; // cannot receive focus using tab key 45 NewNode = ( ConstantTreeNode)node;45 NewNode = (NumberTreeNode)node; 46 46 InitializeFields(); 47 47 } … … 49 49 private void InitializeFields() { 50 50 if (NewNode == null) 51 throw new ArgumentException("Node is not a constant.");51 throw new ArgumentException("Node is not a number."); 52 52 else { 53 53 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(); 55 55 } 56 56 } … … 87 87 // proxy handler passing key strokes to the parent control 88 88 private void childControl_KeyDown(object sender, KeyEventArgs e) { 89 ConstantNodeEditDialog_KeyDown(sender, e);89 NumberNodeEditDialog_KeyDown(sender, e); 90 90 } 91 91 92 private void ConstantNodeEditDialog_KeyDown(object sender, KeyEventArgs e) {92 private void NumberNodeEditDialog_KeyDown(object sender, KeyEventArgs e) { 93 93 if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) { 94 94 if (!ValidateChildren()) return; … … 100 100 public event EventHandler DialogValidated; 101 101 private void OnDialogValidated(object sender, EventArgs e) { 102 if ( constantTreeNode == null) return;102 if (numberTreeNode == null) return; 103 103 var value = double.Parse(newValueTextBox.Text); 104 104 // 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; 106 106 107 constantTreeNode.Value = value;107 numberTreeNode.Value = value; 108 108 DialogResult = DialogResult.OK; 109 109 var dialogValidated = DialogValidated; -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs
r17180 r18100 52 52 this.variableNamesCombo = new System.Windows.Forms.ComboBox(); 53 53 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(); 56 56 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 57 57 this.okButton = new System.Windows.Forms.Button(); … … 121 121 this.variableWeightTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.variableWeightTextBox_Validating); 122 122 // 123 // constantValueTextBox124 // 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 // constantValueLabel134 // 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; 142 142 // 143 143 // errorProvider … … 187 187 this.Controls.Add(this.cancelButton); 188 188 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); 191 191 this.Controls.Add(this.variableWeightTextBox); 192 192 this.Controls.Add(this.variableNamesCombo); … … 211 211 private System.Windows.Forms.Label variableWeightLabel; 212 212 private System.Windows.Forms.Label variableNameLabel; 213 private System.Windows.Forms.Label constantValueLabel;213 private System.Windows.Forms.Label numberValueLabel; 214 214 private System.Windows.Forms.ErrorProvider errorProvider; 215 internal System.Windows.Forms.TextBox constantValueTextBox;215 internal System.Windows.Forms.TextBox numberValueTextBox; 216 216 internal System.Windows.Forms.TextBox variableWeightTextBox; 217 217 internal System.Windows.Forms.ComboBox variableNamesCombo; -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs
r17180 r18100 57 57 var combo = (ComboBox)sender; 58 58 var symbol = combo.Items[combo.SelectedIndex]; 59 if (symbol is Constant) {59 if (symbol is Number) { 60 60 // add controls to the dialog for changing the constant value 61 61 variableNameLabel.Visible = false; … … 63 63 variableWeightLabel.Visible = false; 64 64 variableWeightTextBox.Visible = false; 65 constantValueLabel.Visible = true;66 constantValueTextBox.Visible = true;65 numberValueLabel.Visible = true; 66 numberValueTextBox.Visible = true; 67 67 } else if (symbol is VariableBase) { 68 68 var variableSymbol = (VariableBase)symbol; … … 80 80 variableWeightLabel.Visible = true; 81 81 variableWeightTextBox.Visible = true; 82 constantValueLabel.Visible = false;83 constantValueTextBox.Visible = false;82 numberValueLabel.Visible = false; 83 numberValueTextBox.Visible = false; 84 84 // add controls to the dialog for changing the variable name or weight 85 85 } else { … … 88 88 variableWeightLabel.Visible = false; 89 89 variableWeightTextBox.Visible = false; 90 constantValueLabel.Visible = false;91 constantValueTextBox.Visible = false;90 numberValueLabel.Visible = false; 91 numberValueTextBox.Visible = false; 92 92 } 93 93 } … … 102 102 } 103 103 104 private void constantValueTextBox_Validating(object sender, CancelEventArgs e) {104 private void numberValueTextBox_Validating(object sender, CancelEventArgs e) { 105 105 string errorMessage; 106 if (ValidateDoubleValue( constantValueTextBox.Text, out errorMessage)) return;106 if (ValidateDoubleValue(numberValueTextBox.Text, out errorMessage)) return; 107 107 e.Cancel = true; 108 errorProvider.SetError( constantValueTextBox, errorMessage);109 constantValueTextBox.SelectAll();108 errorProvider.SetError(numberValueTextBox, errorMessage); 109 numberValueTextBox.SelectAll(); 110 110 } 111 111
Note: See TracChangeset
for help on using the changeset viewer.