Free cookie consent management tool by TermsFeed Policy Generator

Changeset 52 for trunk


Ignore:
Timestamp:
03/06/08 02:48:48 (17 years ago)
Author:
swagner
Message:

Worked on ticket #48

  • adapted CombinedOperator to offer a possibility for defining variable infos
Location:
trunk/sources/HeuristicLab.Operators
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators/CombinedOperator.cs

    r48 r52  
    7171          scope.AddVariable(new Variable(SubOperators[i].Name, SubOperators[i]));
    7272        }
     73
     74        foreach (IVariableInfo variableInfo in VariableInfos) {
     75          IItem value = GetVariableValue(variableInfo.FormalName, scope, true, true);
     76          if (scope.GetVariable(variableInfo.FormalName) != null)
     77            scope.RemoveVariable(variableInfo.FormalName);
     78          scope.AddVariable(new Variable(variableInfo.FormalName, value));
     79        }
     80
    7381        return new AtomicOperation(OperatorGraph.InitialOperator, scope);
    7482      } else {
  • trunk/sources/HeuristicLab.Operators/CombinedOperatorView.Designer.cs

    r2 r52  
    5656      this.descriptionTabPage = new System.Windows.Forms.TabPage();
    5757      this.descriptionTextBox = new System.Windows.Forms.TextBox();
     58      this.removeVariableInfoButton = new System.Windows.Forms.Button();
     59      this.addVariableInfoButton = new System.Windows.Forms.Button();
    5860      this.tabControl.SuspendLayout();
    5961      this.operatorGraphTabPage.SuspendLayout();
     
    101103      // variableInfosTabPage
    102104      //
     105      this.variableInfosTabPage.Controls.Add(this.removeVariableInfoButton);
     106      this.variableInfosTabPage.Controls.Add(this.addVariableInfoButton);
    103107      this.variableInfosTabPage.Controls.Add(this.operatorBaseVariableInfosView);
    104108      this.variableInfosTabPage.Location = new System.Drawing.Point(4, 22);
     
    112116      // operatorBaseVariableInfosView
    113117      //
     118      this.operatorBaseVariableInfosView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     119                  | System.Windows.Forms.AnchorStyles.Left)
     120                  | System.Windows.Forms.AnchorStyles.Right)));
    114121      this.operatorBaseVariableInfosView.Caption = "Operator";
    115       this.operatorBaseVariableInfosView.Dock = System.Windows.Forms.DockStyle.Fill;
    116122      this.operatorBaseVariableInfosView.Location = new System.Drawing.Point(3, 3);
    117123      this.operatorBaseVariableInfosView.Name = "operatorBaseVariableInfosView";
    118124      this.operatorBaseVariableInfosView.Operator = null;
    119       this.operatorBaseVariableInfosView.Size = new System.Drawing.Size(383, 303);
     125      this.operatorBaseVariableInfosView.Size = new System.Drawing.Size(383, 274);
    120126      this.operatorBaseVariableInfosView.TabIndex = 0;
     127      this.operatorBaseVariableInfosView.SelectedVariableInfosChanged += new System.EventHandler(this.operatorBaseVariableInfosView_SelectedVariableInfosChanged);
    121128      //
    122129      // variablesTabPage
     
    184191      this.descriptionTextBox.TabIndex = 0;
    185192      this.descriptionTextBox.Validated += new System.EventHandler(this.descriptionTextBox_Validated);
     193      //
     194      // removeVariableInfoButton
     195      //
     196      this.removeVariableInfoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     197      this.removeVariableInfoButton.Enabled = false;
     198      this.removeVariableInfoButton.Location = new System.Drawing.Point(84, 283);
     199      this.removeVariableInfoButton.Name = "removeVariableInfoButton";
     200      this.removeVariableInfoButton.Size = new System.Drawing.Size(75, 23);
     201      this.removeVariableInfoButton.TabIndex = 2;
     202      this.removeVariableInfoButton.Text = "&Remove";
     203      this.removeVariableInfoButton.UseVisualStyleBackColor = true;
     204      this.removeVariableInfoButton.Click += new System.EventHandler(this.removeVariableInfoButton_Click);
     205      //
     206      // addVariableInfoButton
     207      //
     208      this.addVariableInfoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     209      this.addVariableInfoButton.Location = new System.Drawing.Point(3, 283);
     210      this.addVariableInfoButton.Name = "addVariableInfoButton";
     211      this.addVariableInfoButton.Size = new System.Drawing.Size(75, 23);
     212      this.addVariableInfoButton.TabIndex = 1;
     213      this.addVariableInfoButton.Text = "&Add...";
     214      this.addVariableInfoButton.UseVisualStyleBackColor = true;
     215      this.addVariableInfoButton.Click += new System.EventHandler(this.addVariableInfoButton_Click);
    186216      //
    187217      // CombinedOperatorView
     
    216246    private HeuristicLab.Core.OperatorBaseVariablesView operatorBaseVariablesView;
    217247    private HeuristicLab.Core.ConstrainedItemBaseView constrainedItemBaseView;
     248    private System.Windows.Forms.Button removeVariableInfoButton;
     249    private System.Windows.Forms.Button addVariableInfoButton;
    218250
    219251  }
  • trunk/sources/HeuristicLab.Operators/CombinedOperatorView.cs

    r2 r52  
    7979      CombinedOperator.SetDescription(descriptionTextBox.Text);
    8080    }
     81
     82    private void operatorBaseVariableInfosView_SelectedVariableInfosChanged(object sender, EventArgs e) {
     83      removeVariableInfoButton.Enabled = operatorBaseVariableInfosView.SelectedVariableInfos.Count > 0;
     84    }
     85
     86    #region Click Events
     87    private void addVariableInfoButton_Click(object sender, EventArgs e) {
     88      AddVariableInfoDialog dialog = new AddVariableInfoDialog();
     89      if (dialog.ShowDialog(this) == DialogResult.OK) {
     90        if (CombinedOperator.GetVariableInfo(dialog.VariableInfo.FormalName) != null)
     91          Auxiliary.ShowErrorMessageBox("A variable info with the same formal name already exists.");
     92        else
     93          CombinedOperator.AddVariableInfo(dialog.VariableInfo);
     94      }
     95      dialog.Dispose();
     96    }
     97    private void removeVariableInfoButton_Click(object sender, EventArgs e) {
     98      IVariableInfo[] selected = new IVariableInfo[operatorBaseVariableInfosView.SelectedVariableInfos.Count];
     99      operatorBaseVariableInfosView.SelectedVariableInfos.CopyTo(selected, 0);
     100      for (int i = 0; i < selected.Length; i++)
     101        CombinedOperator.RemoveVariableInfo(selected[i].FormalName);
     102    }
     103    #endregion
    81104  }
    82105}
Note: See TracChangeset for help on using the changeset viewer.