Changeset 12969 for branches/gteufl/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- 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 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
branches/gteufl/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 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; … … 103 91 } 104 92 93 94 private static readonly ISymbolicExpressionGrammar grammar = new TypeCoherentExpressionGrammar(); 105 95 private void insertNodeToolStripMenuItem_Click(object sender, EventArgs e) { 106 if (currSelected == null || currSelected. SymbolicExpressionTreeNodeis SymbolicExpressionTreeTerminalNode) return;107 var parent = currSelected. SymbolicExpressionTreeNode;96 if (currSelected == null || currSelected.Content is SymbolicExpressionTreeTerminalNode) return; 97 var parent = currSelected.Content; 108 98 109 99 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)));100 dialog.SetAllowedSymbols(grammar.Symbols.Where(s => !(s is ProgramRootSymbol || s is StartSymbol || s is Defun || s is GroupSymbol))); // allow everything 111 101 dialog.ShowDialog(this); 112 102 if (dialog.DialogResult != DialogResult.OK) return; … … 138 128 if (currSelected == null) return; 139 129 140 var node = (ISymbolicExpressionTreeNode)currSelected. SymbolicExpressionTreeNode.Clone();141 var originalNode = currSelected. SymbolicExpressionTreeNode;130 var node = (ISymbolicExpressionTreeNode)currSelected.Content.Clone(); 131 var originalNode = currSelected.Content; 142 132 143 133 ISymbolicExpressionTreeNode newNode = null; … … 172 162 foreach (var subtree in tempNode.IterateNodesPostfix()) { 173 163 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);164 visualNode.LineColor = Color.Black; 165 visualNode.TextColor = Color.Black; 176 166 if (subtree.Parent != null) { 177 167 var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(subtree.Parent, subtree); 178 visualLine.LineColor = Color. FromArgb(255, visualLine.LineColor);179 } 180 } 181 } 182 tempNode = currSelected. SymbolicExpressionTreeNode;168 visualLine.LineColor = Color.Black; 169 } 170 } 171 } 172 tempNode = currSelected.Content; 183 173 foreach (var node in tempNode.IterateNodesPostfix()) { 184 174 var visualNode = GetVisualSymbolicExpressionTreeNode(node); 185 visualNode.LineColor = Color. FromArgb(100, visualNode.LineColor);186 visualNode.TextColor = Color. FromArgb(100, visualNode.TextColor);175 visualNode.LineColor = Color.LightGray; 176 visualNode.TextColor = Color.LightGray; 187 177 foreach (var subtree in node.Subtrees) { 188 178 var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node, subtree); 189 visualLine.LineColor = Color. FromArgb(100, visualLine.LineColor);190 } 191 } 192 currSelected = null; 193 Repaint ();179 visualLine.LineColor = Color.LightGray; 180 } 181 } 182 currSelected = null; 183 RepaintNodes(); // no need to redo the layout and repaint everything since this operation does not change the tree 194 184 } 195 185 private void removeNodeToolStripMenuItem_Click(object sender, EventArgs e) { 196 var node = currSelected. SymbolicExpressionTreeNode;186 var node = currSelected.Content; 197 187 if (node == tempNode) tempNode = null; 198 188 ModifyTree(Tree, node.Parent, node, null, removeSubtree: false); … … 200 190 } 201 191 private void removeSubtreeToolStripMenuItem_Click(object sender, EventArgs e) { 202 var node = currSelected. SymbolicExpressionTreeNode;192 var node = currSelected.Content; 203 193 if (node.IterateNodesPostfix().Contains(tempNode)) tempNode = null; 204 194 ModifyTree(Tree, node.Parent, node, null, removeSubtree: true); … … 209 199 if (!(lastOp == EditOp.CopySubtree || lastOp == EditOp.CutSubtree)) return; 210 200 // 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;201 var node = currSelected.Content; 212 202 if (node is ConstantTreeNode || node is VariableTreeNode) return; 213 203 // check if the currently selected node can accept the copied node as a child … … 218 208 if (tempNode.IterateNodesBreadth().Contains(node)) 219 209 throw new ArgumentException();// cannot cut/paste a node into itself 220 ModifyTree(Tree, tempNode.Parent, tempNode, null); //remove node from its original parent 210 ModifyTree(Tree, tempNode.Parent, tempNode, null); //remove node from its original parent 221 211 ModifyTree(Tree, node, null, tempNode); //insert it as a child to the new parent 222 212 break;
Note: See TracChangeset
for help on using the changeset viewer.