Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/11 11:12:10 (13 years ago)
Author:
mkommend
Message:

#1479: Merged grammar editor branch into trunk.

Location:
trunk/sources
Files:
7 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj

    r5809 r6803  
    9999    <Reference Include="System.Drawing" />
    100100    <Reference Include="System.Windows.Forms" />
     101    <Reference Include="System.Windows.Forms.DataVisualization" />
    101102    <Reference Include="System.Xml.Linq">
    102103      <RequiredTargetFramework>3.5</RequiredTargetFramework>
     
    109110  </ItemGroup>
    110111  <ItemGroup>
     112    <Compile Include="SymbolicExpressionGrammarAllowedChildSymbolsControl.cs">
     113      <SubType>UserControl</SubType>
     114    </Compile>
     115    <Compile Include="SymbolicExpressionGrammarAllowedChildSymbolsControl.Designer.cs">
     116      <DependentUpon>SymbolicExpressionGrammarAllowedChildSymbolsControl.cs</DependentUpon>
     117    </Compile>
     118    <Compile Include="SymbolicExpressionGrammarEditorView.cs">
     119      <SubType>UserControl</SubType>
     120    </Compile>
     121    <Compile Include="SymbolicExpressionGrammarEditorView.Designer.cs">
     122      <DependentUpon>SymbolicExpressionGrammarEditorView.cs</DependentUpon>
     123    </Compile>
     124    <Compile Include="SymbolicExpressionGrammarSampleExpressionTreeView.cs">
     125      <SubType>UserControl</SubType>
     126    </Compile>
     127    <Compile Include="SymbolicExpressionGrammarSampleExpressionTreeView.Designer.cs">
     128      <DependentUpon>SymbolicExpressionGrammarSampleExpressionTreeView.cs</DependentUpon>
     129    </Compile>
    111130    <Compile Include="SymbolicExpressionGrammarView.cs">
    112131      <SubType>UserControl</SubType>
     
    142161    </Compile>
    143162    <Compile Include="VisualSymbolicExpressionTreeNode.cs" />
     163    <Compile Include="VisualSymbolicExpressionTreeNodeConnection.cs" />
    144164  </ItemGroup>
    145165  <ItemGroup>
     
    148168      <Name>HeuristicLab.Collections-3.3</Name>
    149169    </ProjectReference>
     170    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
     171      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
     172      <Name>HeuristicLab.Common.Resources-3.3</Name>
     173    </ProjectReference>
    150174    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    151175      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
     
    160184      <Name>HeuristicLab.Core-3.3</Name>
    161185    </ProjectReference>
     186    <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj">
     187      <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project>
     188      <Name>HeuristicLab.Data.Views-3.3</Name>
     189    </ProjectReference>
     190    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     191      <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
     192      <Name>HeuristicLab.Data-3.3</Name>
     193    </ProjectReference>
    162194    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
    163195      <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
     
    172204      <Name>HeuristicLab.MainForm-3.3</Name>
    173205    </ProjectReference>
     206    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
     207      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
     208      <Name>HeuristicLab.Operators-3.3</Name>
     209    </ProjectReference>
     210    <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj">
     211      <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project>
     212      <Name>HeuristicLab.Optimization.Views-3.3</Name>
     213    </ProjectReference>
     214    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
     215      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
     216      <Name>HeuristicLab.Optimization-3.3</Name>
     217    </ProjectReference>
    174218    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    175219      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    176220      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
     221    </ProjectReference>
     222    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     223      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
     224      <Name>HeuristicLab.Random-3.3</Name>
     225    </ProjectReference>
     226    <ProjectReference Include="..\..\HeuristicLab.Visualization.ChartControlsExtensions\3.3\HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj">
     227      <Project>{315BDA09-3F4F-49B3-9790-B37CFC1C5750}</Project>
     228      <Name>HeuristicLab.Visualization.ChartControlsExtensions-3.3</Name>
    177229    </ProjectReference>
    178230  </ItemGroup>
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLabEncodingsSymbolicExpressionTreeEncodingViewsPlugin.cs.frame

    r6548 r6803  
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3131  [PluginDependency("HeuristicLab.Common", "3.3")]
     32  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3233  [PluginDependency("HeuristicLab.Core", "3.3")]
    3334  [PluginDependency("HeuristicLab.Core.Views", "3.3")]
     
    3536  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3637  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
     38  [PluginDependency("HeuristicLab.Random","3.3")]
    3739  public class HeuristicLabEncodingsSymbolicExpressionTreeEncodingViewsPlugin : PluginBase {
    3840  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.Designer.cs

    r6109 r6803  
    4747      this.initialFrequencyLabel = new System.Windows.Forms.Label();
    4848      this.initialFrequencyTextBox = new System.Windows.Forms.TextBox();
     49      this.enabledCheckBox = new System.Windows.Forms.CheckBox();
     50      this.minimumArityLabel = new System.Windows.Forms.Label();
     51      this.maximumArityLabel = new System.Windows.Forms.Label();
     52      this.minimumArityTextBox = new System.Windows.Forms.TextBox();
     53      this.maximumArityTextBox = new System.Windows.Forms.TextBox();
    4954      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5055      this.SuspendLayout();
     
    7378      // initialFrequencyTextBox
    7479      //
    75       this.initialFrequencyTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    76                   | System.Windows.Forms.AnchorStyles.Right)));
     80      this.initialFrequencyTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     81            | System.Windows.Forms.AnchorStyles.Right)));
    7782      this.errorProvider.SetIconAlignment(this.initialFrequencyTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    7883      this.initialFrequencyTextBox.Location = new System.Drawing.Point(93, 26);
     
    8489      this.initialFrequencyTextBox.Validated += new System.EventHandler(this.initialFrequencyTextBox_Validated);
    8590      //
     91      // enabledCheckBox
     92      //
     93      this.enabledCheckBox.AutoSize = true;
     94      this.enabledCheckBox.Location = new System.Drawing.Point(93, 104);
     95      this.enabledCheckBox.Name = "enabledCheckBox";
     96      this.enabledCheckBox.Size = new System.Drawing.Size(65, 17);
     97      this.enabledCheckBox.TabIndex = 5;
     98      this.enabledCheckBox.Text = "Enabled";
     99      this.enabledCheckBox.UseVisualStyleBackColor = true;
     100      this.enabledCheckBox.CheckedChanged += new System.EventHandler(this.checkBoxEnabled_CheckedChanged);
     101      //
     102      // minimumArityLabel
     103      //
     104      this.minimumArityLabel.AutoSize = true;
     105      this.minimumArityLabel.Location = new System.Drawing.Point(3, 55);
     106      this.minimumArityLabel.Name = "minimumArityLabel";
     107      this.minimumArityLabel.Size = new System.Drawing.Size(74, 13);
     108      this.minimumArityLabel.TabIndex = 8;
     109      this.minimumArityLabel.Text = "Minimum Arity:";
     110      this.toolTip.SetToolTip(this.minimumArityLabel, "Relative frequency of the symbol in randomly created trees");
     111      //
     112      // maximumArityLabel
     113      //
     114      this.maximumArityLabel.AutoSize = true;
     115      this.maximumArityLabel.Location = new System.Drawing.Point(3, 81);
     116      this.maximumArityLabel.Name = "maximumArityLabel";
     117      this.maximumArityLabel.Size = new System.Drawing.Size(74, 13);
     118      this.maximumArityLabel.TabIndex = 6;
     119      this.maximumArityLabel.Text = "Maximum Arity";
     120      this.toolTip.SetToolTip(this.maximumArityLabel, "Relative frequency of the symbol in randomly created trees");
     121      //
     122      // minimumArityTextBox
     123      //
     124      this.minimumArityTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     125            | System.Windows.Forms.AnchorStyles.Right)));
     126      this.errorProvider.SetIconAlignment(this.minimumArityTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     127      this.minimumArityTextBox.Location = new System.Drawing.Point(93, 52);
     128      this.minimumArityTextBox.Name = "minimumArityTextBox";
     129      this.minimumArityTextBox.ReadOnly = true;
     130      this.minimumArityTextBox.Size = new System.Drawing.Size(227, 20);
     131      this.minimumArityTextBox.TabIndex = 9;
     132      //
     133      // maximumArityTextBox
     134      //
     135      this.maximumArityTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     136            | System.Windows.Forms.AnchorStyles.Right)));
     137      this.errorProvider.SetIconAlignment(this.maximumArityTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     138      this.maximumArityTextBox.Location = new System.Drawing.Point(93, 78);
     139      this.maximumArityTextBox.Name = "maximumArityTextBox";
     140      this.maximumArityTextBox.ReadOnly = true;
     141      this.maximumArityTextBox.Size = new System.Drawing.Size(227, 20);
     142      this.maximumArityTextBox.TabIndex = 7;
     143      //
    86144      // SymbolView
    87145      //
    88146      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    89147      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     148      this.Controls.Add(this.minimumArityTextBox);
     149      this.Controls.Add(this.minimumArityLabel);
     150      this.Controls.Add(this.maximumArityTextBox);
     151      this.Controls.Add(this.maximumArityLabel);
    90152      this.Controls.Add(this.initialFrequencyTextBox);
    91153      this.Controls.Add(this.initialFrequencyLabel);
     154      this.Controls.Add(this.enabledCheckBox);
    92155      this.Name = "SymbolView";
    93       this.Size = new System.Drawing.Size(320, 51);
     156      this.Size = new System.Drawing.Size(320, 123);
     157      this.Controls.SetChildIndex(this.enabledCheckBox, 0);
    94158      this.Controls.SetChildIndex(this.initialFrequencyLabel, 0);
    95159      this.Controls.SetChildIndex(this.initialFrequencyTextBox, 0);
     160      this.Controls.SetChildIndex(this.maximumArityLabel, 0);
     161      this.Controls.SetChildIndex(this.maximumArityTextBox, 0);
     162      this.Controls.SetChildIndex(this.minimumArityLabel, 0);
     163      this.Controls.SetChildIndex(this.minimumArityTextBox, 0);
    96164      this.Controls.SetChildIndex(this.infoLabel, 0);
    97165      this.Controls.SetChildIndex(this.nameLabel, 0);
     
    107175    protected System.Windows.Forms.Label initialFrequencyLabel;
    108176    protected System.Windows.Forms.TextBox initialFrequencyTextBox;
     177    private System.Windows.Forms.CheckBox enabledCheckBox;
     178    protected System.Windows.Forms.Label minimumArityLabel;
     179    protected System.Windows.Forms.Label maximumArityLabel;
     180    protected System.Windows.Forms.TextBox minimumArityTextBox;
     181    protected System.Windows.Forms.TextBox maximumArityTextBox;
    109182
    110183  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs

    r6233 r6803  
    5757    protected override void SetEnabledStateOfControls() {
    5858      base.SetEnabledStateOfControls();
    59       initialFrequencyTextBox.Enabled = Content != null;
     59      initialFrequencyTextBox.Enabled = Content != null || Locked;
    6060      initialFrequencyTextBox.ReadOnly = ReadOnly;
     61      enabledCheckBox.Enabled = Content != null || Locked || ReadOnly;
    6162    }
    6263
     
    9394      }
    9495    }
     96
     97    private void checkBoxEnabled_CheckedChanged(object sender, EventArgs e) {
     98      if (Content != null)
     99        Content.Enabled = enabledCheckBox.Checked;
     100    }
    95101    #endregion
    96102
     
    99105      if (Content == null) {
    100106        initialFrequencyTextBox.Text = string.Empty;
     107        minimumArityTextBox.Text = string.Empty;
     108        maximumArityTextBox.Text = string.Empty;
     109        enabledCheckBox.Checked = false;
    101110      } else {
    102111        initialFrequencyTextBox.Text = Content.InitialFrequency.ToString();
     112        minimumArityTextBox.Text = Content.MinimumArity.ToString();
     113        maximumArityTextBox.Text = Content.MaximumArity.ToString();
     114        enabledCheckBox.Checked = Content.Enabled;
    103115      }
    104116      SetEnabledStateOfControls();
    105117    }
    106118    #endregion
     119
    107120  }
    108121}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarView.cs

    r6233 r6803  
    3030namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3131  [View("Symbolic Expression Grammar View")]
    32   [Content(typeof(ISymbolicExpressionGrammar), true)]
     32  [Content(typeof(ISymbolicExpressionGrammar), false)]
    3333  public partial class SymbolicExpressionGrammarView : NamedItemView {
    3434    private CheckedItemList<ISymbol> symbols;
     
    9090          if (!(symbol is IReadOnlySymbol)) {
    9191            symbol.Changed += new EventHandler(symbol_Changed);
    92             symbols.Add(symbol, symbol.InitialFrequency > 0.0);
     92            symbols.Add(symbol, symbol.Enabled);
    9393          }
    9494        }
     
    101101    private void symbol_Changed(object sender, EventArgs e) {
    102102      ISymbol symbol = (ISymbol)sender;
    103       symbols.SetItemCheckedState(symbol, symbol.InitialFrequency > 0.0);
     103      symbols.SetItemCheckedState(symbol, symbol.Enabled);
    104104    }
    105105
    106106    private void symbols_CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbol>> e) {
    107107      ICheckedItemList<ISymbol> checkedItemList = (ICheckedItemList<ISymbol>)sender;
    108       foreach (var indexedItem in e.Items) {
    109         if (checkedItemList.ItemChecked(indexedItem.Value)) {
    110           indexedItem.Value.InitialFrequency = 1.0;
    111         } else {
    112           indexedItem.Value.InitialFrequency = 0.0;
    113         }
    114       }
     108      foreach (var indexedItem in e.Items)
     109        indexedItem.Value.Enabled = checkedItemList.ItemChecked(indexedItem.Value);
    115110    }
    116111    private void ClearSymbols() {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r6375 r6803  
    3131    private StringFormat stringFormat;
    3232    private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;
     33    private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines;
    3334
    3435    public SymbolicExpressionTreeChart() {
     
    9192        tree = value;
    9293        visualTreeNodes = new Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode>();
     94        visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection>();
    9395        if (tree != null) {
    94           foreach (SymbolicExpressionTreeNode node in tree.IterateNodesPrefix())
     96          foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) {
    9597            visualTreeNodes[node] = new VisualSymbolicExpressionTreeNode(node);
     98            if (node.Parent != null) visualLines[Tuple.Create(node.Parent, node)] = new VisualSymbolicExpressionTreeNodeConnection();
     99          }
    96100        }
    97101        Repaint();
     
    99103    }
    100104
     105    private bool suspendRepaint;
     106    public bool SuspendRepaint {
     107      get { return suspendRepaint; }
     108      set { suspendRepaint = value; }
     109    }
     110
    101111    protected override void OnPaint(PaintEventArgs e) {
     112      e.Graphics.DrawImage(image, 0, 0);
    102113      base.OnPaint(e);
    103       e.Graphics.DrawImage(image, 0, 0);
    104114    }
    105115    protected override void OnResize(EventArgs e) {
     
    113123
    114124    public void Repaint() {
    115       this.GenerateImage();
    116       this.Refresh();
     125      if (!suspendRepaint) {
     126        this.GenerateImage();
     127        this.Refresh();
     128      }
    117129    }
    118130
     
    133145        return visualTreeNodes[symbolicExpressionTreeNode];
    134146      return null;
     147    }
     148
     149    public VisualSymbolicExpressionTreeNodeConnection GetVisualSymbolicExpressionTreeNodeConnection(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {
     150      if (child.Parent != parent) throw new ArgumentException();
     151      var key = Tuple.Create(parent, child);
     152      VisualSymbolicExpressionTreeNodeConnection connection = null;
     153      visualLines.TryGetValue(key, out connection);
     154      return connection;
    135155    }
    136156
     
    196216    }
    197217
    198     private VisualSymbolicExpressionTreeNode FindVisualSymbolicExpressionTreeNodeAt(int x, int y) {
     218    public VisualSymbolicExpressionTreeNode FindVisualSymbolicExpressionTreeNodeAt(int x, int y) {
    199219      foreach (var visualTreeNode in visualTreeNodes.Values) {
    200220        if (x >= visualTreeNode.X && x <= visualTreeNode.X + visualTreeNode.Width &&
     
    228248
    229249      SolidBrush textBrush = new SolidBrush(visualTreeNode.TextColor);
    230       Pen linePen = new Pen(this.lineColor);
    231250      Pen nodeLinePen = new Pen(visualTreeNode.LineColor);
    232251      SolidBrush nodeFillBrush = new SolidBrush(visualTreeNode.FillColor);
     
    262281
    263282      //draw terminal node
    264       if (node.SubtreesCount == 0) {
     283      if (node.SubtreeCount == 0) {
    265284        graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
    266285        graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     
    275294
    276295      //draw connection line to parent node
    277       if (!connectionPoint.IsEmpty)
    278         graphics.DrawLine(linePen, connectionPoint, new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y));
     296      if (!connectionPoint.IsEmpty && node.Parent != null) {
     297        var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node.Parent, node);
     298        using (Pen linePen = new Pen(visualLine.LineColor)) {
     299          linePen.DashStyle = visualLine.DashStyle;
     300          graphics.DrawLine(linePen, connectionPoint, new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y));
     301        }
     302      }
    279303
    280304      //calculate areas for the subtrees according to their tree size and call drawFunctionTree
    281305      Point connectFrom = new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y + visualTreeNode.Height);
    282       int[] xBoundaries = new int[node.SubtreesCount + 1];
     306      int[] xBoundaries = new int[node.SubtreeCount + 1];
    283307      xBoundaries[0] = x;
    284       for (int i = 0; i < node.SubtreesCount; i++) {
     308      for (int i = 0; i < node.SubtreeCount; i++) {
    285309        xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.GetSubtree(i).GetLength()) / (node.GetLength() - 1));
    286310        DrawFunctionTree(node.GetSubtree(i), graphics, xBoundaries[i], y + height,
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/VisualSymbolicExpressionTreeNode.cs

    r5809 r6803  
    2323
    2424namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    25   public class VisualSymbolicExpressionTreeNode {
     25  public class VisualSymbolicExpressionTreeNode : object {
    2626    private static readonly Color defaultLineColor = Color.Black;
    2727    private static readonly Color defaultTextColor = Color.Black;
Note: See TracChangeset for help on using the changeset viewer.