Changeset 11205 for branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
- Timestamp:
- 07/18/14 13:44:53 (10 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 33 33 internal sealed partial class InteractiveSymbolicExpressionTreeChart : SymbolicExpressionTreeChart { 34 34 private ISymbolicExpressionTreeNode tempNode; // node in clipboard (to be cut/copy/pasted etc) 35 private Visual SymbolicExpressionTreeNodecurrSelected; // currently selected node35 private VisualTreeNode<ISymbolicExpressionTreeNode> currSelected; // currently selected node 36 36 private enum EditOp { NoOp, CopySubtree, CutSubtree } 37 37 private EditOp lastOp = EditOp.NoOp; … … 65 65 pasteToolStripMenuItem.Visible = false; 66 66 } else { 67 var node = currSelected. SymbolicExpressionTreeNode;67 var node = currSelected.Content; 68 68 insertNodeToolStripMenuItem.Visible = true; 69 69 changeNodeToolStripMenuItem.Visible = true; … … 76 76 pasteToolStripMenuItem.Visible = true; 77 77 pasteToolStripMenuItem.Enabled = tempNode != null && insertNodeToolStripMenuItem.Enabled 78 && !(lastOp == EditOp.CutSubtree 79 && tempNode.IterateNodesBreadth().Contains(currSelected.SymbolicExpressionTreeNode));78 && !(lastOp == EditOp.CutSubtree && tempNode.IterateNodesBreadth().Contains(node)) 79 && node.SubtreeCount < node.Symbol.MaximumArity; 80 80 } 81 81 } 82 82 83 83 protected override void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 84 currSelected = (VisualSymbolicExpressionTreeNode)sender; ; 85 if (currSelected != null) { 86 currSelected.LineColor = Color.FromArgb(130, currSelected.LineColor); 87 RepaintNode(currSelected); 88 } 84 currSelected = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender; ; 89 85 base.OnSymbolicExpressionTreeNodeClicked(sender, e); 90 86 } 91 87 92 protected override void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {93 if (currSelected != null) {94 currSelected.LineColor = Color.FromArgb(255, currSelected.LineColor);95 RepaintNode(currSelected);96 }97 base.SymbolicExpressionTreeChart_MouseClick(sender, e);98 }99 100 88 protected override void OnSymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) { 101 89 currSelected = null; … … 104 92 105 93 private void insertNodeToolStripMenuItem_Click(object sender, EventArgs e) { 106 if (currSelected == null || currSelected. SymbolicExpressionTreeNodeis SymbolicExpressionTreeTerminalNode) return;107 var parent = currSelected. SymbolicExpressionTreeNode;94 if (currSelected == null || currSelected.Content is SymbolicExpressionTreeTerminalNode) return; 95 var parent = currSelected.Content; 108 96 109 97 using (var dialog = new InsertNodeDialog()) { 110 dialog.SetAllowedSymbols(parent.Grammar. AllowedSymbols.Where(s => s.Enabled && s.InitialFrequency > 0.0 && !(s is ProgramRootSymbol || s is StartSymbol || s is Defun)));98 dialog.SetAllowedSymbols(parent.Grammar.Symbols.Where(s => !(s is ProgramRootSymbol || s is StartSymbol || s is Defun || s is GroupSymbol))); // allow everything 111 99 dialog.ShowDialog(this); 112 100 if (dialog.DialogResult != DialogResult.OK) return; … … 138 126 if (currSelected == null) return; 139 127 140 var node = (ISymbolicExpressionTreeNode)currSelected. SymbolicExpressionTreeNode.Clone();141 var originalNode = currSelected. SymbolicExpressionTreeNode;128 var node = (ISymbolicExpressionTreeNode)currSelected.Content.Clone(); 129 var originalNode = currSelected.Content; 142 130 143 131 ISymbolicExpressionTreeNode newNode = null; … … 172 160 foreach (var subtree in tempNode.IterateNodesPostfix()) { 173 161 var visualNode = GetVisualSymbolicExpressionTreeNode(subtree); 174 visualNode.LineColor = Color. FromArgb(255, visualNode.LineColor); // reset the alpha value to 255175 visualNode.TextColor = Color. FromArgb(255, visualNode.TextColor);162 visualNode.LineColor = Color.Black; 163 visualNode.TextColor = Color.Black; 176 164 if (subtree.Parent != null) { 177 165 var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(subtree.Parent, subtree); 178 visualLine.LineColor = Color. FromArgb(255, visualLine.LineColor);179 } 180 } 181 } 182 tempNode = currSelected. SymbolicExpressionTreeNode;166 visualLine.LineColor = Color.Black; 167 } 168 } 169 } 170 tempNode = currSelected.Content; 183 171 foreach (var node in tempNode.IterateNodesPostfix()) { 184 172 var visualNode = GetVisualSymbolicExpressionTreeNode(node); 185 visualNode.LineColor = Color. FromArgb(100, visualNode.LineColor);186 visualNode.TextColor = Color. FromArgb(100, visualNode.TextColor);173 visualNode.LineColor = Color.LightGray; 174 visualNode.TextColor = Color.LightGray; 187 175 foreach (var subtree in node.Subtrees) { 188 176 var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node, subtree); 189 visualLine.LineColor = Color. FromArgb(100, visualLine.LineColor);190 } 191 } 192 currSelected = null; 193 Repaint ();177 visualLine.LineColor = Color.LightGray; 178 } 179 } 180 currSelected = null; 181 RepaintNodes(); // no need to redo the layout and repaint everything since this operation does not change the tree 194 182 } 195 183 private void removeNodeToolStripMenuItem_Click(object sender, EventArgs e) { 196 var node = currSelected. SymbolicExpressionTreeNode;184 var node = currSelected.Content; 197 185 if (node == tempNode) tempNode = null; 198 186 ModifyTree(Tree, node.Parent, node, null, removeSubtree: false); … … 200 188 } 201 189 private void removeSubtreeToolStripMenuItem_Click(object sender, EventArgs e) { 202 var node = currSelected. SymbolicExpressionTreeNode;190 var node = currSelected.Content; 203 191 if (node.IterateNodesPostfix().Contains(tempNode)) tempNode = null; 204 192 ModifyTree(Tree, node.Parent, node, null, removeSubtree: true); … … 209 197 if (!(lastOp == EditOp.CopySubtree || lastOp == EditOp.CutSubtree)) return; 210 198 // check if the copied/cut node (stored in the tempNode) can be inserted as a child of the current selected node 211 var node = currSelected. SymbolicExpressionTreeNode;199 var node = currSelected.Content; 212 200 if (node is ConstantTreeNode || node is VariableTreeNode) return; 213 201 // check if the currently selected node can accept the copied node as a child … … 218 206 if (tempNode.IterateNodesBreadth().Contains(node)) 219 207 throw new ArgumentException();// cannot cut/paste a node into itself 220 ModifyTree(Tree, tempNode.Parent, tempNode, null); //remove node from its original parent 208 ModifyTree(Tree, tempNode.Parent, tempNode, null); //remove node from its original parent 221 209 ModifyTree(Tree, node, null, tempNode); //insert it as a child to the new parent 222 210 break;
Note: See TracChangeset
for help on using the changeset viewer.