Changeset 6403 for branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Timestamp:
- 06/09/11 16:36:07 (13 years ago)
- Location:
- branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj
r6285 r6403 149 149 </Compile> 150 150 <Compile Include="VisualSymbolicExpressionTreeNode.cs" /> 151 <Compile Include="VisualSymbolicExpressionTreeNodeConnection.cs" /> 151 152 </ItemGroup> 152 153 <ItemGroup> -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.Designer.cs
r6299 r6403 47 47 this.initialFrequencyLabel = new System.Windows.Forms.Label(); 48 48 this.initialFrequencyTextBox = new System.Windows.Forms.TextBox(); 49 this.checkBoxEnabled = new System.Windows.Forms.CheckBox(); 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(); 50 54 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 51 55 this.SuspendLayout(); … … 85 89 this.initialFrequencyTextBox.Validated += new System.EventHandler(this.initialFrequencyTextBox_Validated); 86 90 // 87 // checkBoxEnabled91 // enabledCheckBox 88 92 // 89 this.checkBoxEnabled.AutoSize = true; 90 this.checkBoxEnabled.Location = new System.Drawing.Point(93, 52); 91 this.checkBoxEnabled.Name = "checkBoxEnabled"; 92 this.checkBoxEnabled.Size = new System.Drawing.Size(65, 17); 93 this.checkBoxEnabled.TabIndex = 5; 94 this.checkBoxEnabled.Text = "Enabled"; 95 this.checkBoxEnabled.UseVisualStyleBackColor = true; 96 this.checkBoxEnabled.CheckedChanged += new System.EventHandler(this.checkBoxEnabled_CheckedChanged); 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; 97 143 // 98 144 // SymbolView … … 100 146 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 101 147 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); 102 152 this.Controls.Add(this.initialFrequencyTextBox); 103 153 this.Controls.Add(this.initialFrequencyLabel); 104 this.Controls.Add(this. checkBoxEnabled);154 this.Controls.Add(this.enabledCheckBox); 105 155 this.Name = "SymbolView"; 106 this.Size = new System.Drawing.Size(320, 75);107 this.Controls.SetChildIndex(this. checkBoxEnabled, 0);156 this.Size = new System.Drawing.Size(320, 123); 157 this.Controls.SetChildIndex(this.enabledCheckBox, 0); 108 158 this.Controls.SetChildIndex(this.initialFrequencyLabel, 0); 109 159 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); 110 164 this.Controls.SetChildIndex(this.infoLabel, 0); 111 165 this.Controls.SetChildIndex(this.nameLabel, 0); … … 121 175 protected System.Windows.Forms.Label initialFrequencyLabel; 122 176 protected System.Windows.Forms.TextBox initialFrequencyTextBox; 123 private System.Windows.Forms.CheckBox checkBoxEnabled; 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; 124 182 125 183 } -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs
r6337 r6403 59 59 initialFrequencyTextBox.Enabled = Content != null || Locked; 60 60 initialFrequencyTextBox.ReadOnly = ReadOnly; 61 checkBoxEnabled.Enabled = Content != null || Locked || ReadOnly;61 enabledCheckBox.Enabled = Content != null || Locked || ReadOnly; 62 62 } 63 63 … … 97 97 private void checkBoxEnabled_CheckedChanged(object sender, EventArgs e) { 98 98 if (Content != null) 99 Content.Enabled = checkBoxEnabled.Checked;99 Content.Enabled = enabledCheckBox.Checked; 100 100 } 101 101 #endregion … … 105 105 if (Content == null) { 106 106 initialFrequencyTextBox.Text = string.Empty; 107 checkBoxEnabled.Checked = false; 107 minimumArityTextBox.Text = string.Empty; 108 maximumArityTextBox.Text = string.Empty; 109 enabledCheckBox.Checked = false; 108 110 } else { 109 111 initialFrequencyTextBox.Text = Content.InitialFrequency.ToString(); 110 checkBoxEnabled.Checked = Content.Enabled; 112 minimumArityTextBox.Text = Content.MinimumArity.ToString(); 113 maximumArityTextBox.Text = Content.MaximumArity.ToString(); 114 enabledCheckBox.Checked = Content.Enabled; 111 115 } 112 116 SetEnabledStateOfControls(); -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
r6377 r6403 28 28 this.grpSymbols = new System.Windows.Forms.GroupBox(); 29 29 this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 30 this.showDetailsCheckBox = new System.Windows.Forms.CheckBox(); 31 this.removeButton = new System.Windows.Forms.Button(); 32 this.addButton = new System.Windows.Forms.Button(); 30 33 this.symbolsTreeView = new System.Windows.Forms.TreeView(); 31 34 this.imageList = new System.Windows.Forms.ImageList(this.components); 32 35 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 36 this.allowedChildSymbolsControl = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart(); 33 37 this.symbolDetailsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 34 this.showDetailsCheckBox = new System.Windows.Forms.CheckBox();35 this.removeButton = new System.Windows.Forms.Button();36 this.addButton = new System.Windows.Forms.Button();37 this.allowedChildSymbolsControl = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();38 38 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 39 39 this.grpSymbols.SuspendLayout(); … … 90 90 this.splitContainer1.SplitterDistance = 191; 91 91 this.splitContainer1.TabIndex = 0; 92 // 93 // showDetailsCheckBox 94 // 95 this.showDetailsCheckBox.Appearance = System.Windows.Forms.Appearance.Button; 96 this.showDetailsCheckBox.Checked = true; 97 this.showDetailsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; 98 this.showDetailsCheckBox.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties; 99 this.showDetailsCheckBox.Location = new System.Drawing.Point(63, 3); 100 this.showDetailsCheckBox.Name = "showDetailsCheckBox"; 101 this.showDetailsCheckBox.Size = new System.Drawing.Size(24, 24); 102 this.showDetailsCheckBox.TabIndex = 7; 103 this.toolTip.SetToolTip(this.showDetailsCheckBox, "Show/Hide Details"); 104 this.showDetailsCheckBox.UseVisualStyleBackColor = true; 105 this.showDetailsCheckBox.CheckedChanged += new System.EventHandler(this.showDetailsCheckBox_CheckedChanged); 106 // 107 // removeButton 108 // 109 this.removeButton.Enabled = false; 110 this.removeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Remove; 111 this.removeButton.Location = new System.Drawing.Point(33, 3); 112 this.removeButton.Name = "removeButton"; 113 this.removeButton.Size = new System.Drawing.Size(24, 24); 114 this.removeButton.TabIndex = 6; 115 this.toolTip.SetToolTip(this.removeButton, "Remove"); 116 this.removeButton.UseVisualStyleBackColor = true; 117 this.removeButton.Click += new System.EventHandler(this.removeButton_Click); 118 // 119 // addButton 120 // 121 this.addButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Add; 122 this.addButton.Location = new System.Drawing.Point(3, 3); 123 this.addButton.Name = "addButton"; 124 this.addButton.Size = new System.Drawing.Size(24, 24); 125 this.addButton.TabIndex = 5; 126 this.toolTip.SetToolTip(this.addButton, "Add"); 127 this.addButton.UseVisualStyleBackColor = true; 128 this.addButton.Click += new System.EventHandler(this.addButton_Click); 92 129 // 93 130 // symbolsTreeView … … 132 169 this.splitContainer2.TabIndex = 0; 133 170 // 134 // symbolViewHost 135 // 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; 147 // 148 // showDetailsCheckBox 149 // 150 this.showDetailsCheckBox.Appearance = System.Windows.Forms.Appearance.Button; 151 this.showDetailsCheckBox.Checked = true; 152 this.showDetailsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; 153 this.showDetailsCheckBox.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties; 154 this.showDetailsCheckBox.Location = new System.Drawing.Point(63, 3); 155 this.showDetailsCheckBox.Name = "showDetailsCheckBox"; 156 this.showDetailsCheckBox.Size = new System.Drawing.Size(24, 24); 157 this.showDetailsCheckBox.TabIndex = 7; 158 this.toolTip.SetToolTip(this.showDetailsCheckBox, "Show/Hide Details"); 159 this.showDetailsCheckBox.UseVisualStyleBackColor = true; 160 this.showDetailsCheckBox.CheckedChanged += new System.EventHandler(this.showDetailsCheckBox_CheckedChanged); 161 // 162 // removeButton 163 // 164 this.removeButton.Enabled = false; 165 this.removeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Remove; 166 this.removeButton.Location = new System.Drawing.Point(33, 3); 167 this.removeButton.Name = "removeButton"; 168 this.removeButton.Size = new System.Drawing.Size(24, 24); 169 this.removeButton.TabIndex = 6; 170 this.toolTip.SetToolTip(this.removeButton, "Remove"); 171 this.removeButton.UseVisualStyleBackColor = true; 172 this.removeButton.Click += new System.EventHandler(this.removeButton_Click); 173 // 174 // addButton 175 // 176 this.addButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Add; 177 this.addButton.Location = new System.Drawing.Point(3, 3); 178 this.addButton.Name = "addButton"; 179 this.addButton.Size = new System.Drawing.Size(24, 24); 180 this.addButton.TabIndex = 5; 181 this.toolTip.SetToolTip(this.addButton, "Add"); 182 this.addButton.UseVisualStyleBackColor = true; 183 this.addButton.Click += new System.EventHandler(this.addButton_Click); 184 // 185 // symbolicExpressionTreeChart 171 // allowedChildSymbolsControl 186 172 // 187 173 this.allowedChildSymbolsControl.AllowDrop = true; … … 190 176 this.allowedChildSymbolsControl.LineColor = System.Drawing.Color.Black; 191 177 this.allowedChildSymbolsControl.Location = new System.Drawing.Point(0, 0); 192 this.allowedChildSymbolsControl.Name = " symbolicExpressionTreeChart";178 this.allowedChildSymbolsControl.Name = "allowedChildSymbolsControl"; 193 179 this.allowedChildSymbolsControl.Size = new System.Drawing.Size(568, 165); 194 180 this.allowedChildSymbolsControl.Spacing = 5; … … 200 186 this.allowedChildSymbolsControl.DragEnter += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragEnter); 201 187 this.allowedChildSymbolsControl.DragOver += new System.Windows.Forms.DragEventHandler(this.symbolicExpressionTreeChart_DragOver); 188 this.allowedChildSymbolsControl.Paint += new System.Windows.Forms.PaintEventHandler(this.allowedChildSymbolsControl_Paint); 202 189 this.allowedChildSymbolsControl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolicExpressionTreeChart_KeyDown); 190 this.allowedChildSymbolsControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.allowedChildSymbolsControl_MouseDown); 191 // 192 // symbolDetailsViewHost 193 // 194 this.symbolDetailsViewHost.Caption = "View"; 195 this.symbolDetailsViewHost.Content = null; 196 this.symbolDetailsViewHost.Dock = System.Windows.Forms.DockStyle.Fill; 197 this.symbolDetailsViewHost.Enabled = false; 198 this.symbolDetailsViewHost.Location = new System.Drawing.Point(0, 0); 199 this.symbolDetailsViewHost.Name = "symbolDetailsViewHost"; 200 this.symbolDetailsViewHost.ReadOnly = false; 201 this.symbolDetailsViewHost.Size = new System.Drawing.Size(568, 190); 202 this.symbolDetailsViewHost.TabIndex = 0; 203 this.symbolDetailsViewHost.ViewsLabelVisible = true; 204 this.symbolDetailsViewHost.ViewType = null; 203 205 // 204 206 // SymbolicExpressionGrammarEditorView -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
r6387 r6403 159 159 var tree = new SymbolicExpressionTree(new SymbolicExpressionTreeNode(symbol)); 160 160 161 allowedChildSymbolsControl.SuspendRepaint = true; 161 162 if (Content.GetMaximumSubtreeCount(symbol) > 0) { 162 163 for (int i = 0; i < Content.GetMaximumSubtreeCount(symbol); i++) { … … 169 170 } 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.Dash; 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(); 171 201 UpdateSelectedSymbolicExpressionTreeNodes(); 172 202 } … … 216 246 var symbol = data as ISymbol; 217 247 var symbols = data as IEnumerable<ISymbol>; 218 if (symbol != null && !(symbol is IReadOnlySymbol) && !Content.ContainsSymbol(symbol)) validDragOperation = true;248 if (symbol != null && !(symbol is IReadOnlySymbol) && Content.ContainsSymbol(symbol)) validDragOperation = true; 219 249 else if (symbols != null && symbols.All(s => !(symbol is IReadOnlySymbol) && Content.ContainsSymbol(s))) validDragOperation = true; 220 250 } … … 263 293 foreach (var node in allowedChildSymbolsControl.Tree.IterateNodesPrefix()) { 264 294 var visualNode = allowedChildSymbolsControl.GetVisualSymbolicExpressionTreeNode(node); 265 if (!selectedSymbolicExpressionTreeNodes.Contains(node)) { 266 visualNode.FillColor = Color.White; 267 visualNode.LineColor = Color.Black; 268 } else { 269 visualNode.FillColor = Color.WhiteSmoke; 270 visualNode.LineColor = Color.DarkOrange; 271 } 295 if (!selectedSymbolicExpressionTreeNodes.Contains(node)) visualNode.FillColor = Color.White; 296 else visualNode.FillColor = Color.LightSteelBlue; 297 272 298 } 273 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 } 274 356 } 275 357 … … 297 379 groupSymbol = selectedNode.Tag as GroupSymbol; 298 380 if (groupSymbol != null && Content.ContainsSymbol(groupSymbol)) break; 381 selectedNode = selectedNode.Parent; 299 382 } 300 383 … … 345 428 } 346 429 #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 else 451 changed = false; 452 453 if (changed) BuildAllowedChildSymbolsTree(rootSymbol); 454 RegisterContentEvents(); 455 } 347 456 } 348 457 -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r6387 r6403 31 31 private StringFormat stringFormat; 32 32 private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes; 33 private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines; 33 34 34 35 public SymbolicExpressionTreeChart() { … … 91 92 tree = value; 92 93 visualTreeNodes = new Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode>(); 94 visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection>(); 93 95 if (tree != null) { 94 foreach ( SymbolicExpressionTreeNode node in tree.IterateNodesPrefix())96 foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) { 95 97 visualTreeNodes[node] = new VisualSymbolicExpressionTreeNode(node); 98 if (node.Parent != null) visualLines[Tuple.Create(node.Parent, node)] = new VisualSymbolicExpressionTreeNodeConnection(); 99 } 96 100 } 97 101 Repaint(); … … 99 103 } 100 104 105 private bool suspendRepaint; 106 public bool SuspendRepaint { 107 get { return suspendRepaint; } 108 set { suspendRepaint = value; } 109 } 110 101 111 protected override void OnPaint(PaintEventArgs e) { 112 e.Graphics.DrawImage(image, 0, 0); 102 113 base.OnPaint(e); 103 e.Graphics.DrawImage(image, 0, 0);104 114 } 105 115 protected override void OnResize(EventArgs e) { … … 113 123 114 124 public void Repaint() { 115 this.GenerateImage(); 116 this.Refresh(); 125 if (!suspendRepaint) { 126 this.GenerateImage(); 127 this.Refresh(); 128 } 117 129 } 118 130 … … 133 145 return visualTreeNodes[symbolicExpressionTreeNode]; 134 146 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; 135 155 } 136 156 … … 228 248 229 249 SolidBrush textBrush = new SolidBrush(visualTreeNode.TextColor); 230 Pen linePen = new Pen(this.lineColor);231 250 Pen nodeLinePen = new Pen(visualTreeNode.LineColor); 232 251 SolidBrush nodeFillBrush = new SolidBrush(visualTreeNode.FillColor); … … 275 294 276 295 //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 } 279 303 280 304 //calculate areas for the subtrees according to their tree size and call drawFunctionTree -
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/VisualSymbolicExpressionTreeNode.cs
r5809 r6403 23 23 24 24 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { 25 public class VisualSymbolicExpressionTreeNode {25 public class VisualSymbolicExpressionTreeNode : object { 26 26 private static readonly Color defaultLineColor = Color.Black; 27 27 private static readonly Color defaultTextColor = Color.Black;
Note: See TracChangeset
for help on using the changeset viewer.