Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/07/11 12:49:03 (13 years ago)
Author:
mkommend
Message:

#1479: Merged trunk changes into branch.

Location:
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs

    r6337 r6377  
    3131      this.imageList = new System.Windows.Forms.ImageList(this.components);
    3232      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
    33       this.symbolViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     33      this.symbolDetailsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    3434      this.showDetailsCheckBox = new System.Windows.Forms.CheckBox();
    3535      this.removeButton = new System.Windows.Forms.Button();
    3636      this.addButton = new System.Windows.Forms.Button();
    37       this.symbolicExpressionTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
     37      this.allowedChildSymbolsControl = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    3838      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3939      this.grpSymbols.SuspendLayout();
     
    6060      // grpSymbols
    6161      //
    62       this.grpSymbols.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    63             | System.Windows.Forms.AnchorStyles.Left) 
     62      this.grpSymbols.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     63            | System.Windows.Forms.AnchorStyles.Left)
    6464            | System.Windows.Forms.AnchorStyles.Right)));
    6565      this.grpSymbols.Controls.Add(this.splitContainer1);
     
    9393      // symbolsTreeView
    9494      //
    95       this.symbolsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    96             | System.Windows.Forms.AnchorStyles.Left) 
     95      this.symbolsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     96            | System.Windows.Forms.AnchorStyles.Left)
    9797            | System.Windows.Forms.AnchorStyles.Right)));
    9898      this.symbolsTreeView.CheckBoxes = true;
     
    123123      // splitContainer2.Panel1
    124124      //
    125       this.splitContainer2.Panel1.Controls.Add(this.symbolicExpressionTreeChart);
     125      this.splitContainer2.Panel1.Controls.Add(this.allowedChildSymbolsControl);
    126126      //
    127127      // splitContainer2.Panel2
    128128      //
    129       this.splitContainer2.Panel2.Controls.Add(this.symbolViewHost);
     129      this.splitContainer2.Panel2.Controls.Add(this.symbolDetailsViewHost);
    130130      this.splitContainer2.Size = new System.Drawing.Size(568, 359);
    131131      this.splitContainer2.SplitterDistance = 165;
     
    134134      // symbolViewHost
    135135      //
    136       this.symbolViewHost.Caption = "View";
    137       this.symbolViewHost.Content = null;
    138       this.symbolViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    139       this.symbolViewHost.Enabled = false;
    140       this.symbolViewHost.Location = new System.Drawing.Point(0, 0);
    141       this.symbolViewHost.Name = "symbolViewHost";
    142       this.symbolViewHost.ReadOnly = false;
    143       this.symbolViewHost.Size = new System.Drawing.Size(568, 190);
    144       this.symbolViewHost.TabIndex = 0;
    145       this.symbolViewHost.ViewsLabelVisible = true;
    146       this.symbolViewHost.ViewType = null;
     136      this.symbolDetailsViewHost.Caption = "View";
     137      this.symbolDetailsViewHost.Content = null;
     138      this.symbolDetailsViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     139      this.symbolDetailsViewHost.Enabled = false;
     140      this.symbolDetailsViewHost.Location = new System.Drawing.Point(0, 0);
     141      this.symbolDetailsViewHost.Name = "symbolViewHost";
     142      this.symbolDetailsViewHost.ReadOnly = false;
     143      this.symbolDetailsViewHost.Size = new System.Drawing.Size(568, 190);
     144      this.symbolDetailsViewHost.TabIndex = 0;
     145      this.symbolDetailsViewHost.ViewsLabelVisible = true;
     146      this.symbolDetailsViewHost.ViewType = null;
    147147      //
    148148      // showDetailsCheckBox
     
    151151      this.showDetailsCheckBox.Checked = true;
    152152      this.showDetailsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
    153       this.showDetailsCheckBox.Image = ((System.Drawing.Image)(resources.GetObject("showDetailsCheckBox.Image")));
     153      this.showDetailsCheckBox.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties;
    154154      this.showDetailsCheckBox.Location = new System.Drawing.Point(63, 3);
    155155      this.showDetailsCheckBox.Name = "showDetailsCheckBox";
     
    163163      //
    164164      this.removeButton.Enabled = false;
    165       this.removeButton.Image = ((System.Drawing.Image)(resources.GetObject("removeButton.Image")));
     165      this.removeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Remove;
    166166      this.removeButton.Location = new System.Drawing.Point(33, 3);
    167167      this.removeButton.Name = "removeButton";
     
    174174      // addButton
    175175      //
    176       this.addButton.Image = ((System.Drawing.Image)(resources.GetObject("addButton.Image")));
     176      this.addButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Add;
    177177      this.addButton.Location = new System.Drawing.Point(3, 3);
    178178      this.addButton.Name = "addButton";
     
    185185      // symbolicExpressionTreeChart
    186186      //
    187       this.symbolicExpressionTreeChart.AllowDrop = true;
    188       this.symbolicExpressionTreeChart.BackgroundColor = System.Drawing.Color.White;
    189       this.symbolicExpressionTreeChart.Dock = System.Windows.Forms.DockStyle.Fill;
    190       this.symbolicExpressionTreeChart.LineColor = System.Drawing.Color.Black;
    191       this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(0, 0);
    192       this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";
    193       this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(568, 165);
    194       this.symbolicExpressionTreeChart.Spacing = 5;
    195       this.symbolicExpressionTreeChart.TabIndex = 0;
    196       this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
    197       this.symbolicExpressionTreeChart.Tree = null;
    198       this.symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked);
    199       this.symbolicExpressionTreeChart.DragDrop += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragDrop);
    200       this.symbolicExpressionTreeChart.DragEnter += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragEnter);
    201       this.symbolicExpressionTreeChart.DragOver += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragOver);
    202       this.symbolicExpressionTreeChart.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolicExpressionTreeChart_KeyDown);
     187      this.allowedChildSymbolsControl.AllowDrop = true;
     188      this.allowedChildSymbolsControl.BackgroundColor = System.Drawing.Color.White;
     189      this.allowedChildSymbolsControl.Dock = System.Windows.Forms.DockStyle.Fill;
     190      this.allowedChildSymbolsControl.LineColor = System.Drawing.Color.Black;
     191      this.allowedChildSymbolsControl.Location = new System.Drawing.Point(0, 0);
     192      this.allowedChildSymbolsControl.Name = "symbolicExpressionTreeChart";
     193      this.allowedChildSymbolsControl.Size = new System.Drawing.Size(568, 165);
     194      this.allowedChildSymbolsControl.Spacing = 5;
     195      this.allowedChildSymbolsControl.TabIndex = 0;
     196      this.allowedChildSymbolsControl.TextFont = new System.Drawing.Font("Times New Roman", 8F);
     197      this.allowedChildSymbolsControl.Tree = null;
     198      this.allowedChildSymbolsControl.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked);
     199      this.allowedChildSymbolsControl.DragDrop += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragDrop);
     200      this.allowedChildSymbolsControl.DragEnter += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragEnter);
     201      this.allowedChildSymbolsControl.DragOver += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragOver);
     202      this.allowedChildSymbolsControl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolicExpressionTreeChart_KeyDown);
    203203      //
    204204      // SymbolicExpressionGrammarEditorView
     
    233233    private System.Windows.Forms.TreeView symbolsTreeView;
    234234    private System.Windows.Forms.SplitContainer splitContainer2;
    235     private SymbolicExpressionTreeChart symbolicExpressionTreeChart;
    236     private MainForm.WindowsForms.ViewHost symbolViewHost;
     235    private SymbolicExpressionTreeChart allowedChildSymbolsControl;
     236    private MainForm.WindowsForms.ViewHost symbolDetailsViewHost;
    237237    private System.Windows.Forms.ImageList imageList;
    238238    protected System.Windows.Forms.CheckBox showDetailsCheckBox;
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs

    r6337 r6377  
    8282      if (symbol != null && Content.ContainsSymbol(symbol)) {
    8383        BuildAllowedChildSymbolsTree(symbol);
    84         symbolViewHost.Content = symbol;
     84        symbolDetailsViewHost.Content = symbol;
    8585        symbolsTreeView.SelectedNode = IterateSymbolTreeNodes().Where(n => n.Tag == symbol).ToList().FirstOrDefault();
    8686      }
     
    9696      if (Content != null) {
    9797        RebuildSymbolsTreeView();
    98         symbolicExpressionTreeChart.Tree = null;
    99         symbolViewHost.Content = null;
     98        allowedChildSymbolsControl.Tree = null;
     99        symbolDetailsViewHost.Content = null;
    100100      } else {
    101101        symbolsTreeView.Nodes.Clear();
    102         symbolicExpressionTreeChart.Tree = null;
    103         symbolViewHost.Content = null;
     102        allowedChildSymbolsControl.Tree = null;
     103        symbolDetailsViewHost.Content = null;
    104104      }
    105105    }
     
    121121      if (e.Action != TreeViewAction.Unknown) {
    122122        var symbol = (ISymbol)e.Node.Tag;
    123         symbolViewHost.Content = symbol;
     123        symbolDetailsViewHost.Content = symbol;
    124124        selectedSymbolicExpressionTreeNodes.Clear();
    125125        BuildAllowedChildSymbolsTree(symbol);
     
    168168        }
    169169      }
    170       symbolicExpressionTreeChart.Tree = tree;
     170      allowedChildSymbolsControl.Tree = tree;
    171171      UpdateSelectedSymbolicExpressionTreeNodes();
    172172    }
     
    191191      if (e.KeyCode == Keys.Delete) {
    192192        DeregisterContentEvents();
    193         var root = symbolicExpressionTreeChart.Tree.Root;
     193        var root = allowedChildSymbolsControl.Tree.Root;
    194194        foreach (var node in selectedSymbolicExpressionTreeNodes) {
    195195          int argIndex = root.IndexOfSubtree(node.Parent);
     
    216216      var symbol = data as ISymbol;
    217217      var symbols = data as IEnumerable<ISymbol>;
    218       if (symbol != null && Content.ContainsSymbol(symbol)) validDragOperation = true;
    219       else if (symbols != null && symbols.All(s => Content.ContainsSymbol(s))) validDragOperation = true;
    220     }
    221 
     218      if (symbol != null && !(symbol is IReadOnlySymbol) && !Content.ContainsSymbol(symbol)) validDragOperation = true;
     219      else if (symbols != null && symbols.All(s => !(symbol is IReadOnlySymbol) && Content.ContainsSymbol(s))) validDragOperation = true;
     220    }
    222221
    223222    private void symbolicExpressionTreeChart_DragOver(object sender, DragEventArgs e) {
    224223      e.Effect = DragDropEffects.None;
    225224      if (validDragOperation) {
    226         Point coordinates = symbolicExpressionTreeChart.PointToClient(new Point(e.X, e.Y));
    227         var visualNode = symbolicExpressionTreeChart.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y);
     225        Point coordinates = allowedChildSymbolsControl.PointToClient(new Point(e.X, e.Y));
     226        var visualNode = allowedChildSymbolsControl.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y);
    228227        if (visualNode != null) {
    229228          var node = visualNode.SymbolicExpressionTreeNode;
    230           var root = symbolicExpressionTreeChart.Tree.Root;
     229          var root = allowedChildSymbolsControl.Tree.Root;
     230          if (root.Symbol is ProgramRootSymbol) return;
    231231          if (node == root || node.Parent == root) e.Effect = DragDropEffects.Copy;
    232232        }
     
    235235
    236236    private void symbolicExpressionTreeChart_DragDrop(object sender, DragEventArgs e) {
    237       Point coordinates = symbolicExpressionTreeChart.PointToClient(new Point(e.X, e.Y));
    238       var node = symbolicExpressionTreeChart.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y);
    239       var root = symbolicExpressionTreeChart.Tree.Root;
     237      Point coordinates = allowedChildSymbolsControl.PointToClient(new Point(e.X, e.Y));
     238      var node = allowedChildSymbolsControl.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y);
     239      var root = allowedChildSymbolsControl.Tree.Root;
    240240
    241241      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     
    261261
    262262    private void UpdateSelectedSymbolicExpressionTreeNodes() {
    263       foreach (var node in symbolicExpressionTreeChart.Tree.IterateNodesPrefix()) {
    264         var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     263      foreach (var node in allowedChildSymbolsControl.Tree.IterateNodesPrefix()) {
     264        var visualNode = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNode(node);
    265265        if (!selectedSymbolicExpressionTreeNodes.Contains(node)) {
    266266          visualNode.FillColor = Color.White;
     
    271271        }
    272272      }
    273       symbolicExpressionTreeChart.Repaint();
     273      allowedChildSymbolsControl.Repaint();
    274274    }
    275275
     
    291291            i++;
    292292          }
    293           Content.AddSymbol(symbol);
     293
     294          var selectedNode = symbolsTreeView.SelectedNode;
     295          GroupSymbol groupSymbol = null;
     296          while (selectedNode != null) {
     297            groupSymbol = selectedNode.Tag as GroupSymbol;
     298            if (groupSymbol != null && Content.ContainsSymbol(groupSymbol)) break;
     299          }
     300
     301          if (groupSymbol != null && Content.ContainsSymbol(groupSymbol)) groupSymbol.SymbolsCollection.Add(symbol);
     302          else Content.AddSymbol(symbol);
    294303        }
    295304        catch (Exception ex) {
     
    304313        Content.RemoveSymbol(symbol);
    305314      removeButton.Enabled = false;
     315      allowedChildSymbolsControl.Tree = null;
     316      symbolDetailsViewHost.Content = null;
    306317    }
    307318
  • branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r6337 r6377  
    2424using System.Drawing;
    2525using System.Drawing.Imaging;
    26 using System.Linq;
    2726using System.Windows.Forms;
    2827
     
    263262
    264263      //draw terminal node
    265       if (node.Subtrees.Count() == 0) {
     264      if (node.SubtreesCount == 0) {
    266265        graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
    267266        graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     
    281280      //calculate areas for the subtrees according to their tree size and call drawFunctionTree
    282281      Point connectFrom = new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y + visualTreeNode.Height);
    283       int[] xBoundaries = new int[node.Subtrees.Count() + 1];
     282      int[] xBoundaries = new int[node.SubtreesCount + 1];
    284283      xBoundaries[0] = x;
    285       for (int i = 0; i < node.Subtrees.Count(); i++) {
    286         xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.Subtrees.ElementAt(i).GetLength()) / (node.GetLength() - 1));
    287         DrawFunctionTree(node.Subtrees.ElementAt(i), graphics, xBoundaries[i], y + height,
     284      for (int i = 0; i < node.SubtreesCount; i++) {
     285        xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.GetSubtree(i).GetLength()) / (node.GetLength() - 1));
     286        DrawFunctionTree(node.GetSubtree(i), graphics, xBoundaries[i], y + height,
    288287          xBoundaries[i + 1] - xBoundaries[i], height, connectFrom);
    289288      }
Note: See TracChangeset for help on using the changeset viewer.