Changeset 6415
- Timestamp:
- 06/15/11 23:02:01 (13 years ago)
- Location:
- branches/GP.Grammar.Editor
- Files:
-
- 2 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj
r6403 r6415 110 110 </ItemGroup> 111 111 <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> 112 118 <Compile Include="SymbolicExpressionGrammarEditorView.cs"> 113 119 <SubType>UserControl</SubType> -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
r6403 r6415 28 28 this.grpSymbols = new System.Windows.Forms.GroupBox(); 29 29 this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 30 this.copyButton = new System.Windows.Forms.Button(); 30 31 this.showDetailsCheckBox = new System.Windows.Forms.CheckBox(); 31 32 this.removeButton = new System.Windows.Forms.Button(); 32 33 this.addButton = new System.Windows.Forms.Button(); 33 this.symbolsTreeView = new System.Windows.Forms.TreeView();34 this.symbolsTreeView = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.CheckBoxTreeView(); 34 35 this.imageList = new System.Windows.Forms.ImageList(this.components); 35 36 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 36 this.allowedChildSymbolsControl = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart(); 37 this.allowedChildSymbolsControl = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionGrammarAllowedChildSymbolsControl(); 38 this.symbolDetailsGroupBox = new System.Windows.Forms.GroupBox(); 37 39 this.symbolDetailsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 38 40 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); … … 46 48 this.splitContainer2.Panel2.SuspendLayout(); 47 49 this.splitContainer2.SuspendLayout(); 50 this.symbolDetailsGroupBox.SuspendLayout(); 48 51 this.SuspendLayout(); 49 52 // … … 79 82 // splitContainer1.Panel1 80 83 // 84 this.splitContainer1.Panel1.Controls.Add(this.copyButton); 81 85 this.splitContainer1.Panel1.Controls.Add(this.showDetailsCheckBox); 82 86 this.splitContainer1.Panel1.Controls.Add(this.removeButton); … … 91 95 this.splitContainer1.TabIndex = 0; 92 96 // 97 // copyButton 98 // 99 this.copyButton.Enabled = false; 100 this.copyButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Copy; 101 this.copyButton.Location = new System.Drawing.Point(33, 3); 102 this.copyButton.Name = "copyButton"; 103 this.copyButton.Size = new System.Drawing.Size(24, 24); 104 this.copyButton.TabIndex = 8; 105 this.toolTip.SetToolTip(this.copyButton, "Copy Symbol"); 106 this.copyButton.UseVisualStyleBackColor = true; 107 this.copyButton.Click += new System.EventHandler(this.copyButton_Click); 108 // 93 109 // showDetailsCheckBox 94 110 // … … 97 113 this.showDetailsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; 98 114 this.showDetailsCheckBox.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties; 99 this.showDetailsCheckBox.Location = new System.Drawing.Point( 63, 3);115 this.showDetailsCheckBox.Location = new System.Drawing.Point(93, 3); 100 116 this.showDetailsCheckBox.Name = "showDetailsCheckBox"; 101 117 this.showDetailsCheckBox.Size = new System.Drawing.Size(24, 24); … … 109 125 this.removeButton.Enabled = false; 110 126 this.removeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Remove; 111 this.removeButton.Location = new System.Drawing.Point( 33, 3);127 this.removeButton.Location = new System.Drawing.Point(63, 3); 112 128 this.removeButton.Name = "removeButton"; 113 129 this.removeButton.Size = new System.Drawing.Size(24, 24); 114 130 this.removeButton.TabIndex = 6; 115 this.toolTip.SetToolTip(this.removeButton, "Remove ");131 this.toolTip.SetToolTip(this.removeButton, "Remove Symbol"); 116 132 this.removeButton.UseVisualStyleBackColor = true; 117 133 this.removeButton.Click += new System.EventHandler(this.removeButton_Click); … … 124 140 this.addButton.Size = new System.Drawing.Size(24, 24); 125 141 this.addButton.TabIndex = 5; 126 this.toolTip.SetToolTip(this.addButton, "Add ");142 this.toolTip.SetToolTip(this.addButton, "Add Symbol"); 127 143 this.addButton.UseVisualStyleBackColor = true; 128 144 this.addButton.Click += new System.EventHandler(this.addButton_Click); … … 130 146 // symbolsTreeView 131 147 // 148 this.symbolsTreeView.AllowDrop = true; 132 149 this.symbolsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 133 150 | System.Windows.Forms.AnchorStyles.Left) 134 151 | System.Windows.Forms.AnchorStyles.Right))); 135 152 this.symbolsTreeView.CheckBoxes = true; 153 this.symbolsTreeView.HideSelection = false; 136 154 this.symbolsTreeView.ImageIndex = 0; 137 155 this.symbolsTreeView.ImageList = this.imageList; … … 144 162 this.symbolsTreeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.symbolsTreeView_ItemDrag); 145 163 this.symbolsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.symbolsTreeView_AfterSelect); 164 this.symbolsTreeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.symbolsTreeView_DragDrop); 165 this.symbolsTreeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.symbolsTreeView_DragEnter); 166 this.symbolsTreeView.DragOver += new System.Windows.Forms.DragEventHandler(this.symbolsTreeView_DragOver); 146 167 // 147 168 // imageList … … 164 185 // splitContainer2.Panel2 165 186 // 166 this.splitContainer2.Panel2.Controls.Add(this.symbolDetails ViewHost);187 this.splitContainer2.Panel2.Controls.Add(this.symbolDetailsGroupBox); 167 188 this.splitContainer2.Size = new System.Drawing.Size(568, 359); 168 189 this.splitContainer2.SplitterDistance = 165; … … 172 193 // 173 194 this.allowedChildSymbolsControl.AllowDrop = true; 174 this.allowedChildSymbolsControl.BackgroundColor = System.Drawing.Color.White;175 195 this.allowedChildSymbolsControl.Dock = System.Windows.Forms.DockStyle.Fill; 176 this.allowedChildSymbolsControl. LineColor = System.Drawing.Color.Black;196 this.allowedChildSymbolsControl.Grammar = null; 177 197 this.allowedChildSymbolsControl.Location = new System.Drawing.Point(0, 0); 178 198 this.allowedChildSymbolsControl.Name = "allowedChildSymbolsControl"; 179 199 this.allowedChildSymbolsControl.Size = new System.Drawing.Size(568, 165); 180 this.allowedChildSymbolsControl.S pacing = 5;200 this.allowedChildSymbolsControl.Symbol = null; 181 201 this.allowedChildSymbolsControl.TabIndex = 0; 182 this.allowedChildSymbolsControl.TextFont = new System.Drawing.Font("Times New Roman", 8F); 183 this.allowedChildSymbolsControl.Tree = null; 184 this.allowedChildSymbolsControl.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked); 185 this.allowedChildSymbolsControl.DragDrop += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragDrop); 186 this.allowedChildSymbolsControl.DragEnter += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragEnter); 187 this.allowedChildSymbolsControl.DragOver += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragOver); 188 this.allowedChildSymbolsControl.Paint += new System.Windows.Forms.PaintEventHandler(this.allowedChildSymbolsControl_Paint); 189 this.allowedChildSymbolsControl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolicExpressionTreeChart_KeyDown); 190 this.allowedChildSymbolsControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.allowedChildSymbolsControl_MouseDown); 202 // 203 // symbolDetailsGroupBox 204 // 205 this.symbolDetailsGroupBox.Controls.Add(this.symbolDetailsViewHost); 206 this.symbolDetailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 207 this.symbolDetailsGroupBox.Location = new System.Drawing.Point(0, 0); 208 this.symbolDetailsGroupBox.Name = "symbolDetailsGroupBox"; 209 this.symbolDetailsGroupBox.Size = new System.Drawing.Size(568, 190); 210 this.symbolDetailsGroupBox.TabIndex = 1; 211 this.symbolDetailsGroupBox.TabStop = false; 212 this.symbolDetailsGroupBox.Text = "Symbol Details"; 191 213 // 192 214 // symbolDetailsViewHost … … 196 218 this.symbolDetailsViewHost.Dock = System.Windows.Forms.DockStyle.Fill; 197 219 this.symbolDetailsViewHost.Enabled = false; 198 this.symbolDetailsViewHost.Location = new System.Drawing.Point( 0, 0);220 this.symbolDetailsViewHost.Location = new System.Drawing.Point(3, 16); 199 221 this.symbolDetailsViewHost.Name = "symbolDetailsViewHost"; 200 222 this.symbolDetailsViewHost.ReadOnly = false; 201 this.symbolDetailsViewHost.Size = new System.Drawing.Size(56 8, 190);202 this.symbolDetailsViewHost.TabIndex = 0;223 this.symbolDetailsViewHost.Size = new System.Drawing.Size(562, 171); 224 this.symbolDetailsViewHost.TabIndex = 1; 203 225 this.symbolDetailsViewHost.ViewsLabelVisible = true; 204 226 this.symbolDetailsViewHost.ViewType = null; … … 225 247 ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); 226 248 this.splitContainer2.ResumeLayout(false); 249 this.symbolDetailsGroupBox.ResumeLayout(false); 227 250 this.ResumeLayout(false); 228 251 this.PerformLayout(); … … 233 256 private System.Windows.Forms.GroupBox grpSymbols; 234 257 private System.Windows.Forms.SplitContainer splitContainer1; 235 private System.Windows.Forms.TreeView symbolsTreeView;258 private CheckBoxTreeView symbolsTreeView; 236 259 private System.Windows.Forms.SplitContainer splitContainer2; 237 private SymbolicExpressionTreeChart allowedChildSymbolsControl;238 private MainForm.WindowsForms.ViewHost symbolDetailsViewHost;239 260 private System.Windows.Forms.ImageList imageList; 240 261 protected System.Windows.Forms.CheckBox showDetailsCheckBox; 241 262 protected System.Windows.Forms.Button removeButton; 242 263 protected System.Windows.Forms.Button addButton; 264 private System.Windows.Forms.GroupBox symbolDetailsGroupBox; 265 private MainForm.WindowsForms.ViewHost symbolDetailsViewHost; 266 protected System.Windows.Forms.Button copyButton; 267 private SymbolicExpressionGrammarAllowedChildSymbolsControl allowedChildSymbolsControl; 243 268 } 244 269 } -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
r6409 r6415 25 25 using System.Linq; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Collections;28 27 using HeuristicLab.Common; 29 28 using HeuristicLab.Core.Views; … … 35 34 [Content(typeof(ISymbolicExpressionGrammar), false)] 36 35 public partial class SymbolicExpressionGrammarEditorView : NamedItemView { 37 private ObservableList<ISymbolicExpressionTreeNode> selectedSymbolicExpressionTreeNodes;38 39 36 public SymbolicExpressionGrammarEditorView() { 40 37 InitializeComponent(); 41 selectedSymbolicExpressionTreeNodes = new ObservableList<ISymbolicExpressionTreeNode>();42 38 } 43 39 … … 56 52 get { return (ISymbolicExpressionGrammar)base.Content; } 57 53 set { base.Content = value; } 54 } 55 56 protected override void SetEnabledStateOfControls() { 57 base.SetEnabledStateOfControls(); 58 addButton.Enabled = Content != null; 59 removeButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 60 copyButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 61 } 62 63 protected override void OnContentChanged() { 64 base.OnContentChanged(); 65 if (Content != null) { 66 symbolsTreeView.Nodes.Clear(); 67 UpdateSymbolsTreeView(); 68 symbolsTreeView.ExpandAll(); 69 allowedChildSymbolsControl.Grammar = Content; 70 allowedChildSymbolsControl.Symbol = null; 71 symbolDetailsViewHost.Content = null; 72 } else { 73 symbolsTreeView.Nodes.Clear(); 74 allowedChildSymbolsControl.Grammar = null; 75 symbolDetailsViewHost.Content = null; 76 } 58 77 } 59 78 … … 79 98 symbol = (ISymbol)symbolsTreeView.SelectedNode.Tag; 80 99 81 RebuildSymbolsTreeView(); 100 allowedChildSymbolsControl.Grammar = Content; 101 102 UpdateSymbolsTreeView(); 82 103 if (symbol != null && Content.ContainsSymbol(symbol)) { 83 BuildAllowedChildSymbolsTree(symbol);104 allowedChildSymbolsControl.Symbol = symbol; 84 105 symbolDetailsViewHost.Content = symbol; 85 106 symbolsTreeView.SelectedNode = IterateSymbolTreeNodes().Where(n => n.Tag == symbol).ToList().FirstOrDefault(); … … 88 109 #endregion 89 110 90 protected override void SetEnabledStateOfControls() { 91 base.SetEnabledStateOfControls(); 92 } 93 94 protected override void OnContentChanged() { 95 base.OnContentChanged(); 96 if (Content != null) { 97 RebuildSymbolsTreeView(); 98 allowedChildSymbolsControl.Tree = null; 99 symbolDetailsViewHost.Content = null; 100 } else { 101 symbolsTreeView.Nodes.Clear(); 102 allowedChildSymbolsControl.Tree = null; 103 symbolDetailsViewHost.Content = null; 104 } 111 private void UpdateSymbolsTreeView() { 112 var symbols = Content.Symbols.ToList(); 113 foreach (var treeNode in IterateSymbolTreeNodes().ToList()) { 114 var symbol = treeNode.Tag as ISymbol; 115 if (!symbols.Contains(symbol)) 116 treeNode.Remove(); 117 } 118 119 var groupSymbols = symbols.OfType<GroupSymbol>().ToList(); 120 var topLevelSymbols = Content.Symbols.Where(s => !groupSymbols.Any(g => g.Symbols.Contains(s))); 121 AddChildTreeNodes(symbolsTreeView.Nodes, topLevelSymbols); 122 123 RebuildImageList(); 105 124 } 106 125 107 126 private void AddChildTreeNodes(TreeNodeCollection collection, IEnumerable<ISymbol> symbols) { 108 127 foreach (ISymbol symbol in symbols) { 109 var node = new TreeNode(); 110 node.Name = symbol.Name; 111 node.Text = symbol.Name; 112 node.Tag = symbol; 113 node.Checked = symbol.Enabled; 114 collection.Add(node); 128 TreeNode node = collection.Cast<TreeNode>().Where(n => n.Tag == symbol).FirstOrDefault(); 129 if (node == null) { 130 node = new TreeNode(); 131 node.Name = symbol.Name; 132 node.Text = symbol.Name; 133 node.Tag = symbol; 134 node.Checked = symbol.Enabled; 135 collection.Add(node); 136 } 115 137 var groupSymbol = symbol as GroupSymbol; 116 138 if (groupSymbol != null) AddChildTreeNodes(node.Nodes, groupSymbol.Symbols); … … 122 144 var symbol = (ISymbol)e.Node.Tag; 123 145 symbolDetailsViewHost.Content = symbol; 124 selectedSymbolicExpressionTreeNodes.Clear(); 125 BuildAllowedChildSymbolsTree(symbol); 146 allowedChildSymbolsControl.Symbol = symbol; 126 147 } 127 148 removeButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 149 copyButton.Enabled = symbolsTreeView.SelectedNode != null && !(symbolsTreeView.SelectedNode.Tag is IReadOnlySymbol); 128 150 } 129 151 130 152 private void symbolsTreeView_AfterCheck(object sender, TreeViewEventArgs e) { 131 153 if (e.Action != TreeViewAction.Unknown) { 132 DeregisterContentEvents(); 154 Content.StartGrammarManipulation(); 155 allowedChildSymbolsControl.Symbol = null; 133 156 var symbol = (ISymbol)e.Node.Tag; 134 157 symbol.Enabled = e.Node.Checked; … … 138 161 if (symbolsTreeView.SelectedNode != null) { 139 162 symbol = (ISymbol)symbolsTreeView.SelectedNode.Tag; 140 selectedSymbolicExpressionTreeNodes.Clear(); 141 BuildAllowedChildSymbolsTree(symbol); 142 } 143 RegisterContentEvents(); 144 } 145 } 146 147 private void RebuildSymbolsTreeView() { 148 symbolsTreeView.Nodes.Clear(); 149 var symbols = Content.Symbols.ToList(); 150 var groupSymbols = symbols.OfType<GroupSymbol>().ToList(); 151 var topLevelSymbols = Content.Symbols.Where(s => !groupSymbols.Any(g => g.Symbols.Contains(s))); 152 AddChildTreeNodes(symbolsTreeView.Nodes, topLevelSymbols); 153 154 RebuildImageList(); 155 symbolsTreeView.ExpandAll(); 156 } 157 158 private void BuildAllowedChildSymbolsTree(ISymbol symbol) { 159 var tree = new SymbolicExpressionTree(new SymbolicExpressionTreeNode(symbol)); 160 161 allowedChildSymbolsControl.SuspendRepaint = true; 162 if (Content.GetMaximumSubtreeCount(symbol) > 0) { 163 for (int i = 0; i < Content.GetMaximumSubtreeCount(symbol); i++) { 164 var node = new DummySymbol("Subtree " + i).CreateTreeNode(); 165 foreach (var childSymbol in Content.GetAllowedChildSymbols(symbol, i)) { 166 node.AddSubtree(new SymbolicExpressionTreeNode(childSymbol)); 167 } 168 tree.Root.AddSubtree(node); 169 } 170 } 171 allowedChildSymbolsControl.Tree = tree; 172 173 foreach (var subtreeNode in tree.Root.Subtrees) { 174 foreach (var allowedChildNode in subtreeNode.Subtrees) { 175 var visualLine = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNodeConnection(subtreeNode, allowedChildNode); 176 visualLine.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; 177 } 178 } 179 180 for (int i = Content.GetMinimumSubtreeCount(symbol); i < Content.GetMaximumSubtreeCount(symbol); i++) { 181 var subtreeNode = tree.Root.GetSubtree(i); 182 var visualTreeNode = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNode(subtreeNode); 183 visualTreeNode.TextColor = Color.Gray; 184 visualTreeNode.LineColor = Color.LightGray; 185 186 var visualLine = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNodeConnection(tree.Root, subtreeNode); 187 visualLine.LineColor = Color.LightGray; 188 189 foreach (var allowedChildNode in subtreeNode.Subtrees) { 190 visualTreeNode = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNode(allowedChildNode); 191 visualTreeNode.TextColor = Color.Gray; 192 visualTreeNode.LineColor = Color.LightGray; 193 194 visualLine = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNodeConnection(subtreeNode, allowedChildNode); 195 visualLine.LineColor = Color.LightGray; 196 } 197 } 198 199 allowedChildSymbolsControl.SuspendRepaint = false; 200 allowedChildSymbolsControl.Repaint(); 201 UpdateSelectedSymbolicExpressionTreeNodes(); 202 } 203 204 private void symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 205 if ((Control.ModifierKeys & Keys.Control) == 0) 206 selectedSymbolicExpressionTreeNodes.Clear(); 207 208 VisualSymbolicExpressionTreeNode clickedNode = (VisualSymbolicExpressionTreeNode)sender; 209 var selectedNode = clickedNode.SymbolicExpressionTreeNode; 210 if (selectedNode.SubtreeCount == 0) { 211 if (!selectedSymbolicExpressionTreeNodes.Contains(selectedNode)) 212 selectedSymbolicExpressionTreeNodes.Add(selectedNode); 213 else 214 selectedSymbolicExpressionTreeNodes.Remove(selectedNode); 215 } 216 217 UpdateSelectedSymbolicExpressionTreeNodes(); 218 } 219 220 private void symbolicExpressionTreeChart_KeyDown(object sender, KeyEventArgs e) { 221 if (e.KeyCode == Keys.Delete) { 222 DeregisterContentEvents(); 223 var root = allowedChildSymbolsControl.Tree.Root; 224 foreach (var node in selectedSymbolicExpressionTreeNodes) { 225 int argIndex = root.IndexOfSubtree(node.Parent); 226 Content.RemoveAllowedChildSymbol(root.Symbol, node.Symbol, argIndex); 227 } 228 RegisterContentEvents(); 229 selectedSymbolicExpressionTreeNodes.Clear(); 230 BuildAllowedChildSymbolsTree(root.Symbol); 231 } 232 } 233 163 allowedChildSymbolsControl.Symbol = symbol; 164 } 165 Content.FinishedGrammarManipulation(); 166 } 167 } 168 169 #region drag & drop operations 170 private GroupSymbol parentOfDraggedSymbol; 234 171 private void symbolsTreeView_ItemDrag(object sender, ItemDragEventArgs e) { 235 172 if (!Locked) { 236 DataObject data = new DataObject(); 237 data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, ((TreeNode)e.Item).Tag); 238 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 239 } 240 } 173 var treeNode = e.Item as TreeNode; 174 if (treeNode.Parent != null) parentOfDraggedSymbol = treeNode.Parent.Tag as GroupSymbol; 175 var data = new DataObject(); 176 data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, treeNode.Tag); 177 validDragOperation = true; 178 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Move); 179 } 180 } 181 241 182 242 183 private bool validDragOperation; 243 private void symbol icExpressionTreeChart_DragEnter(object sender, DragEventArgs e) {184 private void symbolsTreeView_DragEnter(object sender, DragEventArgs e) { 244 185 validDragOperation = false; 186 if (Content == null) return; 187 245 188 var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 246 189 var symbol = data as ISymbol; 247 var symbols = data as IEnumerable<ISymbol>; 248 if (symbol != null && !(symbol is IReadOnlySymbol) && Content.ContainsSymbol(symbol)) validDragOperation = true; 249 else if (symbols != null && symbols.All(s => !(symbol is IReadOnlySymbol) && Content.ContainsSymbol(s))) validDragOperation = true; 250 } 251 252 private void symbolicExpressionTreeChart_DragOver(object sender, DragEventArgs e) { 190 if (symbol != null && !(symbol is IReadOnlySymbol)) validDragOperation = true; 191 } 192 private void symbolsTreeView_DragOver(object sender, DragEventArgs e) { 253 193 e.Effect = DragDropEffects.None; 254 194 if (validDragOperation) { 255 Point coordinates = allowedChildSymbolsControl.PointToClient(new Point(e.X, e.Y)); 256 var visualNode = allowedChildSymbolsControl.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y); 257 if (visualNode != null) { 258 var node = visualNode.SymbolicExpressionTreeNode; 259 var root = allowedChildSymbolsControl.Tree.Root; 260 if (root.Symbol is ProgramRootSymbol) return; 261 if (node == root || node.Parent == root) e.Effect = DragDropEffects.Copy; 262 } 263 } 264 } 265 266 private void symbolicExpressionTreeChart_DragDrop(object sender, DragEventArgs e) { 267 Point coordinates = allowedChildSymbolsControl.PointToClient(new Point(e.X, e.Y)); 268 var node = allowedChildSymbolsControl.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y); 269 var root = allowedChildSymbolsControl.Tree.Root; 270 271 var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 272 var symbol = data as ISymbol; 273 var symbols = data as IEnumerable<ISymbol>; 274 275 DeregisterContentEvents(); 276 if (node.SymbolicExpressionTreeNode == root) { 277 if (symbol != null) 278 Content.AddAllowedChildSymbol(root.Symbol, symbol); 279 else if (symbols != null) 280 foreach (var s in symbols) Content.AddAllowedChildSymbol(root.Symbol, s); 281 } else { 282 int argumentIndex = root.IndexOfSubtree(node.SymbolicExpressionTreeNode); 283 if (symbol != null) 284 Content.AddAllowedChildSymbol(root.Symbol, symbol, argumentIndex); 285 else if (symbols != null) 286 foreach (var s in symbols) Content.AddAllowedChildSymbol(root.Symbol, s, argumentIndex); 287 } 288 RegisterContentEvents(); 289 BuildAllowedChildSymbolsTree(root.Symbol); 290 } 291 292 private void UpdateSelectedSymbolicExpressionTreeNodes() { 293 foreach (var node in allowedChildSymbolsControl.Tree.IterateNodesPrefix()) { 294 var visualNode = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNode(node); 295 if (!selectedSymbolicExpressionTreeNodes.Contains(node)) visualNode.FillColor = Color.White; 296 else visualNode.FillColor = Color.LightSteelBlue; 297 298 } 299 allowedChildSymbolsControl.Repaint(); 300 } 301 302 private RectangleF increaseMinimumSubtreeCountRectangle; 303 private RectangleF decreaseMinimumSubtreeCountRectangle; 304 private RectangleF increaseMaximumSubtreeCountRectangle; 305 private RectangleF decreaseMaximumSubtreeCountRectangle; 306 private void allowedChildSymbolsControl_Paint(object sender, PaintEventArgs e) { 307 increaseMinimumSubtreeCountRectangle = RectangleF.Empty; 308 decreaseMinimumSubtreeCountRectangle = RectangleF.Empty; 309 increaseMaximumSubtreeCountRectangle = RectangleF.Empty; 310 decreaseMaximumSubtreeCountRectangle = RectangleF.Empty; 311 312 if (Content == null) return; 313 if (allowedChildSymbolsControl.Tree == null) return; 314 315 var rootNode = allowedChildSymbolsControl.Tree.Root; 316 var visualRootNode = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNode(rootNode); 317 var graphics = e.Graphics; 318 319 if (rootNode.Symbol is IReadOnlySymbol) return; 320 if (rootNode.Symbol.MinimumArity == rootNode.Symbol.MaximumArity) return; 321 322 using (Pen pen = new Pen(Color.Black)) { 323 using (Font font = new Font("Times New Roman", 8)) { 324 var stringFormat = new StringFormat(); 325 stringFormat.Alignment = StringAlignment.Center; 326 stringFormat.LineAlignment = StringAlignment.Center; 327 int spacing = 5; 328 int size = (visualRootNode.Height - spacing * 3) / 2; 329 330 increaseMinimumSubtreeCountRectangle = new RectangleF(visualRootNode.X - spacing - size, visualRootNode.Y + spacing, size, size); 331 decreaseMinimumSubtreeCountRectangle = new RectangleF(visualRootNode.X - spacing - size, visualRootNode.Y + size + 2 * spacing, size, size); 332 increaseMaximumSubtreeCountRectangle = new RectangleF(visualRootNode.X + visualRootNode.Width + spacing, visualRootNode.Y + spacing, size, size); 333 decreaseMaximumSubtreeCountRectangle = new RectangleF(visualRootNode.X + visualRootNode.Width + spacing, visualRootNode.Y + size + 2 * spacing, size, size); 334 335 pen.Color = Content.GetMaximumSubtreeCount(rootNode.Symbol) == Content.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black; 336 graphics.DrawString("+", font, pen.Brush, increaseMinimumSubtreeCountRectangle, stringFormat); 337 graphics.DrawRectangle(pen, Rectangle.Round(increaseMinimumSubtreeCountRectangle)); 338 if (pen.Color == Color.LightGray) increaseMinimumSubtreeCountRectangle = RectangleF.Empty; 339 340 pen.Color = Content.GetMinimumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MinimumArity ? Color.LightGray : Color.Black; 341 graphics.DrawString("-", font, pen.Brush, decreaseMinimumSubtreeCountRectangle, stringFormat); 342 graphics.DrawRectangle(pen, Rectangle.Round(decreaseMinimumSubtreeCountRectangle)); 343 if (pen.Color == Color.LightGray) decreaseMinimumSubtreeCountRectangle = RectangleF.Empty; 344 345 pen.Color = Content.GetMaximumSubtreeCount(rootNode.Symbol) == rootNode.Symbol.MaximumArity ? Color.LightGray : Color.Black; 346 graphics.DrawRectangle(pen, Rectangle.Round(increaseMaximumSubtreeCountRectangle)); 347 graphics.DrawString("+", font, pen.Brush, increaseMaximumSubtreeCountRectangle, stringFormat); 348 if (pen.Color == Color.LightGray) increaseMaximumSubtreeCountRectangle = RectangleF.Empty; 349 350 pen.Color = Content.GetMaximumSubtreeCount(rootNode.Symbol) == Content.GetMinimumSubtreeCount(rootNode.Symbol) ? Color.LightGray : Color.Black; 351 graphics.DrawRectangle(pen, Rectangle.Round(decreaseMaximumSubtreeCountRectangle)); 352 graphics.DrawString("-", font, pen.Brush, decreaseMaximumSubtreeCountRectangle, stringFormat); 353 if (pen.Color == Color.LightGray) decreaseMaximumSubtreeCountRectangle = RectangleF.Empty; 354 } 355 } 356 } 357 195 GroupSymbol groupSymbol = null; 196 Point mouse = symbolsTreeView.PointToClient(new Point(e.X, e.Y)); 197 TreeNode node = symbolsTreeView.GetNodeAt(mouse); 198 if (node != null) groupSymbol = node.Tag as GroupSymbol; 199 if (node != null && groupSymbol == null) groupSymbol = node.Parent.Tag as GroupSymbol; 200 var symbol = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 201 if (symbol == groupSymbol) return; 202 203 if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 204 } 205 } 206 private void symbolsTreeView_DragDrop(object sender, DragEventArgs e) { 207 var symbol = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as ISymbol; 208 209 GroupSymbol groupSymbol = null; 210 Point mouse = symbolsTreeView.PointToClient(new Point(e.X, e.Y)); 211 TreeNode node = symbolsTreeView.GetNodeAt(mouse); 212 if (node != null) groupSymbol = node.Tag as GroupSymbol; 213 if (node != null && groupSymbol == null) groupSymbol = node.Parent.Tag as GroupSymbol; 214 215 Content.StartGrammarManipulation(); 216 Cloner cloner = new Cloner(); 217 var clonedSymbol = cloner.Clone(symbol); 218 ChangeDuplicateSymbolNames(clonedSymbol); 219 220 if (groupSymbol != null) groupSymbol.SymbolsCollection.Add(clonedSymbol); 221 else Content.AddSymbol(clonedSymbol); 222 223 UpdateGrammerConstraintsForClonedSymbol(symbol, cloner); 224 Content.FinishedGrammarManipulation(); 225 } 226 #endregion 227 228 #region button events 358 229 private TypeSelectorDialog typeSelectorDialog; 359 230 private void addButton_Click(object sender, EventArgs e) { … … 367 238 try { 368 239 ISymbol symbol = (ISymbol)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 369 var originalSymbolName = symbol.Name; 370 int i = 1; 371 while (Content.ContainsSymbol(symbol)) { 372 symbol.Name = originalSymbolName + i; 373 i++; 374 } 240 ChangeDuplicateSymbolNames(symbol); 375 241 376 242 var selectedNode = symbolsTreeView.SelectedNode; 377 GroupSymbol groupSymbol = null; 378 while (selectedNode != null) { 379 groupSymbol = selectedNode.Tag as GroupSymbol; 380 if (groupSymbol != null && Content.ContainsSymbol(groupSymbol)) break; 381 selectedNode = selectedNode.Parent; 382 } 383 384 if (groupSymbol != null && Content.ContainsSymbol(groupSymbol)) groupSymbol.SymbolsCollection.Add(symbol); 243 GroupSymbol groupSymbol = selectedNode.Tag as GroupSymbol; 244 if (groupSymbol == null && selectedNode.Parent != null) groupSymbol = selectedNode.Parent.Tag as GroupSymbol; 245 246 if (groupSymbol != null) groupSymbol.SymbolsCollection.Add(symbol); 385 247 else Content.AddSymbol(symbol); 386 248 } … … 391 253 } 392 254 255 private void copyButton_Click(object sender, EventArgs e) { 256 var symbol = symbolsTreeView.SelectedNode.Tag as ISymbol; 257 if (symbol != null && !(symbol is IReadOnlySymbol)) { 258 allowedChildSymbolsControl.Symbol = null; 259 symbolDetailsViewHost.Content = null; 260 261 Content.StartGrammarManipulation(); 262 Cloner cloner = new Cloner(); 263 var clonedSymbol = cloner.Clone(symbol); 264 ChangeDuplicateSymbolNames(clonedSymbol); 265 266 GroupSymbol groupSymbol = null; 267 if (symbolsTreeView.SelectedNode.Parent != null) groupSymbol = symbolsTreeView.SelectedNode.Parent.Tag as GroupSymbol; 268 269 if (groupSymbol != null) groupSymbol.SymbolsCollection.Add(clonedSymbol); 270 else Content.AddSymbol(clonedSymbol); 271 272 UpdateGrammerConstraintsForClonedSymbol(symbol, cloner); 273 Content.FinishedGrammarManipulation(); 274 } 275 } 276 393 277 private void removeButton_Click(object sender, EventArgs e) { 394 278 var symbol = symbolsTreeView.SelectedNode.Tag as ISymbol; 395 if (symbol != null && !(symbol is IReadOnlySymbol)) 279 if (symbol != null && !(symbol is IReadOnlySymbol)) { 396 280 Content.RemoveSymbol(symbol); 397 removeButton.Enabled = false;398 allowedChildSymbolsControl.Tree= null;399 symbolDetailsViewHost.Content = null;281 allowedChildSymbolsControl.Symbol = null; 282 symbolDetailsViewHost.Content = null; 283 } 400 284 } 401 285 … … 403 287 splitContainer1.Panel2Collapsed = !showDetailsCheckBox.Checked; 404 288 } 289 #endregion 405 290 406 291 #region helpers 292 private void UpdateGrammerConstraintsForClonedSymbol(ISymbol symbol, Cloner cloner) { 293 foreach (var s in symbol.Flatten().Where(x => !(x is GroupSymbol))) { 294 if (!cloner.ClonedObjectRegistered(s)) throw new InvalidOperationException(); 295 var clone = cloner.Clone(s); 296 Content.SetSubtreeCount(clone, Content.GetMinimumSubtreeCount(s), Content.GetMaximumSubtreeCount(s)); 297 foreach (var childSymbol in Content.GetAllowedChildSymbols(s)) { 298 var newChildSymbol = childSymbol; 299 if (cloner.ClonedObjectRegistered(childSymbol)) newChildSymbol = cloner.Clone(childSymbol); 300 Content.AddAllowedChildSymbol(clone, newChildSymbol); 301 } 302 for (int i = 0; i < Content.GetMaximumSubtreeCount(s); i++) { 303 foreach (var childSymbol in Content.GetAllowedChildSymbols(s, i)) { 304 var newChildSymbol = childSymbol; 305 if (cloner.ClonedObjectRegistered(childSymbol)) newChildSymbol = cloner.Clone(childSymbol); 306 Content.AddAllowedChildSymbol(clone, newChildSymbol, i); 307 } 308 } 309 } 310 } 311 312 313 private void ChangeDuplicateSymbolNames(ISymbol symbol) { 314 foreach (var s in symbol.Flatten()) { 315 var originalSymbolName = s.Name; 316 int i = 1; 317 while (Content.ContainsSymbol(s)) { 318 s.Name = originalSymbolName + i; 319 i++; 320 } 321 } 322 } 323 407 324 private IEnumerable<TreeNode> IterateSymbolTreeNodes(TreeNode node = null) { 408 325 TreeNodeCollection nodes; … … 428 345 } 429 346 #endregion 430 431 private void allowedChildSymbolsControl_MouseDown(object sender, MouseEventArgs e) {432 if (Content == null) return;433 if (allowedChildSymbolsControl.Tree == null) return;434 435 var pointF = new PointF(e.X, e.Y);436 var rootSymbol = allowedChildSymbolsControl.Tree.Root.Symbol;437 int minimumSubtreeCount = Content.GetMinimumSubtreeCount(rootSymbol);438 int maximumSubtreecount = Content.GetMaximumSubtreeCount(rootSymbol);439 440 bool changed = true;441 DeregisterContentEvents();442 if (increaseMinimumSubtreeCountRectangle.Contains(pointF))443 Content.SetSubtreeCount(rootSymbol, minimumSubtreeCount + 1, maximumSubtreecount);444 else if (decreaseMinimumSubtreeCountRectangle.Contains(pointF))445 Content.SetSubtreeCount(rootSymbol, minimumSubtreeCount - 1, maximumSubtreecount);446 else if (increaseMaximumSubtreeCountRectangle.Contains(pointF))447 Content.SetSubtreeCount(rootSymbol, minimumSubtreeCount, maximumSubtreecount + 1);448 else if (decreaseMaximumSubtreeCountRectangle.Contains(pointF))449 Content.SetSubtreeCount(rootSymbol, minimumSubtreeCount, maximumSubtreecount - 1);450 else451 changed = false;452 453 if (changed) BuildAllowedChildSymbolsTree(rootSymbol);454 RegisterContentEvents();455 }456 347 } 457 348 458 [NonDiscoverableType] 459 internal class DummySymbol : Symbol { 460 private const int minimumArity = 1; 461 private const int maximumArity = byte.MaxValue; 462 463 public override int MinimumArity { 464 get { return minimumArity; } 465 } 466 public override int MaximumArity { 467 get { return maximumArity; } 468 } 469 470 public DummySymbol(DummySymbol original, Cloner cloner) : base(original, cloner) { } 471 public DummySymbol(string name) : base(name, "DummySymbol for views") { } 472 public override IDeepCloneable Clone(Cloner cloner) { return new DummySymbol(this, cloner); } 349 //this class is necessary to prevent double clicks which do not fire the checkbox checked event 350 internal class CheckBoxTreeView : TreeView { 351 protected override void WndProc(ref Message m) { 352 // Suppress WM_LBUTTONDBLCLK 353 if (m.Msg == 0x203) { m.Result = IntPtr.Zero; } else base.WndProc(ref m); 354 } 473 355 } 474 356 } -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammar.cs
r6284 r6415 45 45 46 46 void SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount); 47 48 void StartGrammarManipulation(); 49 void FinishedGrammarManipulation(); 47 50 } 48 51 } -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs
r6284 r6415 198 198 base.SetSubtreeCount(symbol, minimumSubtreeCount, maximumSubtreeCount); 199 199 } 200 201 private bool suppressEvents = false; 202 void ISymbolicExpressionGrammar.StartGrammarManipulation() { 203 suppressEvents = true; 204 } 205 void ISymbolicExpressionGrammar.FinishedGrammarManipulation() { 206 suppressEvents = false; 207 OnChanged(); 208 } 209 210 protected override void OnChanged() { 211 if (!suppressEvents) base.OnChanged(); 212 } 200 213 #endregion 201 214 } -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r6409 r6415 64 64 #endregion 65 65 66 pr otectedbool suppressEvents;66 private bool suppressEvents; 67 67 protected Dictionary<string, ISymbol> symbols; 68 68 protected Dictionary<string, Tuple<int, int>> symbolSubtreeCount; -
branches/GP.Grammar.Editor/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/GP.Grammar.Editor/HeuristicLab.PluginInfrastructure/3.3/Advanced/DeploymentService/ServiceClients.cs
r4722 r6415 2 2 // <auto-generated> 3 3 // This code was generated by a tool. 4 // Runtime Version:4.0.30319. 14 // Runtime Version:4.0.30319.225 5 5 // 6 6 // Changes to this file may cause incorrect behavior and will be lost if … … 9 9 //------------------------------------------------------------------------------ 10 10 11 namespace HeuristicLab.PluginInfrastructure.Advanced.DeploymentService { 12 13 14 [System.Diagnostics.DebuggerStepThroughAttribute()] 11 namespace HeuristicLab.PluginInfrastructure.Advanced.DeploymentService 12 { 13 using System.Runtime.Serialization; 14 15 16 [System.Diagnostics.DebuggerStepThroughAttribute()] 15 17 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] 16 18 [System.Runtime.Serialization.DataContractAttribute(Name="PluginDescription", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Deployment", IsReference=true)] -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs
r6387 r6415 51 51 protected override void UpdateModel(ISymbolicExpressionTree tree) { 52 52 Content.Model = new SymbolicDiscriminantFunctionClassificationModel(tree, Content.Model.Interpreter); 53 Content.SetClassDistibutionCutPointThresholds();54 53 } 55 54 -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolution.cs
r5809 r6415 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators; 29 using HeuristicLab.Parameters; 25 using HeuristicLab.Optimization; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 using System;33 27 34 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 69 63 Add(new Result(ModelLengthResultName, "Length of the symbolic classification model.", new IntValue())); 70 64 Add(new Result(ModelDepthResultName, "Depth of the symbolic classification model.", new IntValue())); 71 RecalculateResults();65 CalculateResults(); 72 66 } 73 67 … … 76 70 } 77 71 78 protected override void OnModelChanged(EventArgs e) {79 base. OnModelChanged(e);80 RecalculateResults();72 protected override void RecalculateResults() { 73 base.RecalculateResults(); 74 CalculateResults(); 81 75 } 82 76 83 private new void RecalculateResults() {77 private void CalculateResults() { 84 78 ModelLength = Model.SymbolicExpressionTree.Length; 85 79 ModelDepth = Model.SymbolicExpressionTree.Depth; -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationSolution.cs
r5975 r6415 20 20 #endregion 21 21 22 using System;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 67 66 Add(new Result(ModelLengthResultName, "Length of the symbolic classification model.", new IntValue())); 68 67 Add(new Result(ModelDepthResultName, "Depth of the symbolic classification model.", new IntValue())); 69 RecalculateResults();68 CalculateResults(); 70 69 } 71 70 … … 74 73 } 75 74 76 protected override void OnModelChanged(EventArgs e) {77 base. OnModelChanged(e);78 RecalculateResults();75 protected override void RecalculateResults() { 76 base.RecalculateResults(); 77 CalculateResults(); 79 78 } 80 79 81 private new void RecalculateResults() {80 private void CalculateResults() { 82 81 ModelLength = Model.SymbolicExpressionTree.Length; 83 82 ModelDepth = Model.SymbolicExpressionTree.Depth; -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r6387 r6415 20 20 #endregion 21 21 22 using System;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 63 62 Add(new Result(ModelLengthResultName, "Length of the symbolic regression model.", new IntValue())); 64 63 Add(new Result(ModelDepthResultName, "Depth of the symbolic regression model.", new IntValue())); 65 RecalculateResults();64 CalculateResults(); 66 65 } 67 66 … … 70 69 } 71 70 72 protected override void OnModelChanged(EventArgs e) {73 RecalculateResults();74 base.OnModelChanged(e);71 protected override void RecalculateResults() { 72 base.RecalculateResults(); 73 CalculateResults(); 75 74 } 76 75 77 pr otected new void RecalculateResults() {76 private void CalculateResults() { 78 77 ModelLength = Model.SymbolicExpressionTree.Length; 79 78 ModelDepth = Model.SymbolicExpressionTree.Depth; -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableView.cs
r6236 r6415 80 80 protected override void OnContentChanged() { 81 81 base.OnContentChanged(); 82 variableNamesView.Content.Clear();83 82 UpdateControl(); 84 83 } … … 105 104 private void variableNames_Changed(object sender, CollectionItemsChangedEventArgs<StringValue> args) { 106 105 if (Content != null) { 107 Content.Changed -= new EventHandler(Content_Changed);106 DeregisterContentEvents(); 108 107 Content.VariableNames = variableNamesView.Content.CheckedItems.Select(x => x.Value).ToList(); 109 Content.Changed += new EventHandler(Content_Changed);108 RegisterContentEvents(); 110 109 } 111 110 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionEstimatedClassValuesView.cs
r6255 r6415 86 86 StringMatrix matrix = null; 87 87 if (Content != null) { 88 string[,] values = new string[Content.ProblemData.Dataset.Rows, 5];88 string[,] values = new string[Content.ProblemData.Dataset.Rows, 4]; 89 89 90 90 double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs
r6184 r6415 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 66 65 Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue())); 67 66 Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue())); 68 RecalculateResults();67 CalculateResults(); 69 68 } 70 69 … … 73 72 } 74 73 75 protected override void OnProblemDataChanged(EventArgs e) { 76 base.OnProblemDataChanged(e); 77 RecalculateResults(); 74 protected override void RecalculateResults() { 75 CalculateResults(); 78 76 } 79 77 80 protected override void OnModelChanged(EventArgs e) { 81 base.OnModelChanged(e); 82 RecalculateResults(); 83 } 84 85 protected void RecalculateResults() { 78 private void CalculateResults() { 86 79 double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values 87 80 IEnumerable<double> originalTrainingClassValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs
r5942 r6415 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 27 using HeuristicLab.Data; 29 28 using HeuristicLab.Optimization; 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis { … … 89 89 Add(new Result(TrainingRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue())); 90 90 Add(new Result(TestRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue())); 91 SetAccuracyMaximizingThresholds(); 92 93 //mkommend: important to recalculate accuracy because during the calculation before no thresholds were present 94 base.RecalculateResults(); 95 CalculateResults(); 91 96 RegisterEventHandler(); 92 SetAccuracyMaximizingThresholds();93 RecalculateResults();94 97 } 95 98 … … 99 102 } 100 103 101 protected new void RecalculateResults() { 104 protected override void OnModelChanged(EventArgs e) { 105 DeregisterEventHandler(); 106 SetAccuracyMaximizingThresholds(); 107 RegisterEventHandler(); 108 base.OnModelChanged(e); 109 } 110 111 protected override void RecalculateResults() { 112 base.RecalculateResults(); 113 CalculateResults(); 114 } 115 116 private void CalculateResults() { 102 117 double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values 103 118 IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); … … 119 134 private void RegisterEventHandler() { 120 135 Model.ThresholdsChanged += new EventHandler(Model_ThresholdsChanged); 136 } 137 private void DeregisterEventHandler() { 138 Model.ThresholdsChanged -= new EventHandler(Model_ThresholdsChanged); 121 139 } 122 140 private void Model_ThresholdsChanged(object sender, EventArgs e) { … … 142 160 } 143 161 144 protected override void OnModelChanged(EventArgs e) {145 base.OnModelChanged(e);146 SetAccuracyMaximizingThresholds();147 RecalculateResults();148 }149 150 protected override void OnProblemDataChanged(EventArgs e) {151 base.OnProblemDataChanged(e);152 SetAccuracyMaximizingThresholds();153 RecalculateResults();154 }155 162 protected virtual void OnModelThresholdsChanged(EventArgs e) { 156 base.OnModelChanged(e);157 163 RecalculateResults(); 158 164 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringSolution.cs
r6184 r6415 45 45 } 46 46 47 protected override void RecalculateResults() { 48 } 49 47 50 #region IClusteringSolution Members 48 51 -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs
r5914 r6415 86 86 } 87 87 88 protected abstract void RecalculateResults(); 89 88 90 private void ProblemData_Changed(object sender, EventArgs e) { 89 91 OnProblemDataChanged(e); … … 92 94 public event EventHandler ModelChanged; 93 95 protected virtual void OnModelChanged(EventArgs e) { 96 RecalculateResults(); 94 97 var listeners = ModelChanged; 95 98 if (listeners != null) listeners(this, e); … … 98 101 public event EventHandler ProblemDataChanged; 99 102 protected virtual void OnProblemDataChanged(EventArgs e) { 103 RecalculateResults(); 100 104 var listeners = ProblemDataChanged; 101 105 if (listeners != null) listeners(this, e); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs
r6387 r6415 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 110 109 Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue())); 111 110 112 RecalculateResults();111 CalculateResults(); 113 112 } 114 113 … … 117 116 } 118 117 119 protected override void OnProblemDataChanged(EventArgs e) { 120 RecalculateResults(); 121 base.OnProblemDataChanged(e); 122 } 123 protected override void OnModelChanged(EventArgs e) { 124 RecalculateResults(); 125 base.OnModelChanged(e); 118 protected override void RecalculateResults() { 119 CalculateResults(); 126 120 } 127 121 128 pr otected void RecalculateResults() {122 private void CalculateResults() { 129 123 double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values 130 124 IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);
Note: See TracChangeset
for help on using the changeset viewer.