Ignore:
Timestamp:
07/07/14 16:55:50 (5 years ago)
Author:
gkronber
Message:

#2076,#2159, #2092
multi-ticket merge to stable:

Location:
stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r9478 r11120  
    5252      Content.ModelChanged += Content_Changed;
    5353      Content.ProblemDataChanged += Content_Changed;
     54      treeChart.Repainted += treeChart_Repainted;
    5455    }
    5556    protected override void DeregisterContentEvents() {
     
    5758      Content.ModelChanged -= Content_Changed;
    5859      Content.ProblemDataChanged -= Content_Changed;
     60      treeChart.Repainted -= treeChart_Repainted;
    5961    }
    6062
     
    6870      UpdateView();
    6971      viewHost.Content = this.Content;
     72    }
     73
     74    private void treeChart_Repainted(object sender, EventArgs e) {
     75      if (nodeImpacts != null && nodeImpacts.Count > 0)
     76        PaintNodeImpacts();
    7077    }
    7178
     
    96103
    97104    private void treeChart_SymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
    98       var visualNode = (VisualSymbolicExpressionTreeNode)sender;
    99       var symbExprTreeNode = (SymbolicExpressionTreeNode)visualNode.SymbolicExpressionTreeNode;
    100       if (symbExprTreeNode == null) return;
    101       var tree = Content.Model.SymbolicExpressionTree;
     105      var visualNode = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender;
     106      if (visualNode.Content == null) { throw new Exception("Visual node content cannot be null."); }
     107      var symbExprTreeNode = (SymbolicExpressionTreeNode)visualNode.Content;
     108      if (!foldedNodes.ContainsKey(symbExprTreeNode)) return; // constant nodes cannot be folded
    102109      var parent = symbExprTreeNode.Parent;
    103110      int indexOfSubtree = parent.IndexOfSubtree(symbExprTreeNode);
    104       if (foldedNodes.ContainsKey(symbExprTreeNode)) {
    105         // undo node folding
    106         SwitchNodeWithReplacementNode(parent, indexOfSubtree);
    107       }
    108       UpdateModel(tree);
     111      SwitchNodeWithReplacementNode(parent, indexOfSubtree);
     112      UpdateModel(Content.Model.SymbolicExpressionTree);
    109113    }
    110114
    111115    private void SwitchNodeWithReplacementNode(ISymbolicExpressionTreeNode parent, int subTreeIndex) {
    112116      ISymbolicExpressionTreeNode subTree = parent.GetSubtree(subTreeIndex);
    113       parent.RemoveSubtree(subTreeIndex);
    114117      if (foldedNodes.ContainsKey(subTree)) {
     118        parent.RemoveSubtree(subTreeIndex);
    115119        var replacementNode = foldedNodes[subTree];
    116120        parent.InsertSubtree(subTreeIndex, replacementNode);
     
    125129      double max = impacts.Max();
    126130      double min = impacts.Min();
    127       foreach (ISymbolicExpressionTreeNode treeNode in Content.Model.SymbolicExpressionTree.IterateNodesPostfix()) {
    128         VisualSymbolicExpressionTreeNode visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
     131      foreach (var treeNode in Content.Model.SymbolicExpressionTree.IterateNodesPostfix()) {
     132        VisualTreeNode<ISymbolicExpressionTreeNode> visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
    129133
    130134        if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
     135          visualTree.ToolTip = visualTree.Content.ToString(); // to avoid duplicate tooltips
    131136          double impact = nodeImpacts[treeNode];
    132137
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs

    r9456 r11120  
    3333  internal sealed partial class InteractiveSymbolicExpressionTreeChart : SymbolicExpressionTreeChart {
    3434    private ISymbolicExpressionTreeNode tempNode; // node in clipboard (to be cut/copy/pasted etc)
    35     private VisualSymbolicExpressionTreeNode currSelected; // currently selected node
     35    private VisualTreeNode<ISymbolicExpressionTreeNode> currSelected; // currently selected node
    3636    private enum EditOp { NoOp, CopySubtree, CutSubtree }
    3737    private EditOp lastOp = EditOp.NoOp;
     
    6565        pasteToolStripMenuItem.Visible = false;
    6666      } else {
    67         var node = currSelected.SymbolicExpressionTreeNode;
     67        var node = currSelected.Content;
    6868        insertNodeToolStripMenuItem.Visible = true;
    6969        changeNodeToolStripMenuItem.Visible = true;
     
    7777        pasteToolStripMenuItem.Enabled = tempNode != null && insertNodeToolStripMenuItem.Enabled
    7878                                                          && !(lastOp == EditOp.CutSubtree
    79                                                                && tempNode.IterateNodesBreadth().Contains(currSelected.SymbolicExpressionTreeNode));
     79                                                               && tempNode.IterateNodesBreadth().Contains(currSelected.Content));
    8080      }
    8181    }
    8282
    8383    protected override void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    84       currSelected = (VisualSymbolicExpressionTreeNode)sender; ;
     84      currSelected = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender; ;
    8585      if (currSelected != null) {
    8686        currSelected.LineColor = Color.FromArgb(130, currSelected.LineColor);
     
    104104
    105105    private void insertNodeToolStripMenuItem_Click(object sender, EventArgs e) {
    106       if (currSelected == null || currSelected.SymbolicExpressionTreeNode is SymbolicExpressionTreeTerminalNode) return;
    107       var parent = currSelected.SymbolicExpressionTreeNode;
     106      if (currSelected == null || currSelected.Content is SymbolicExpressionTreeTerminalNode) return;
     107      var parent = currSelected.Content;
    108108
    109109      using (var dialog = new InsertNodeDialog()) {
     
    138138      if (currSelected == null) return;
    139139
    140       var node = (ISymbolicExpressionTreeNode)currSelected.SymbolicExpressionTreeNode.Clone();
    141       var originalNode = currSelected.SymbolicExpressionTreeNode;
     140      var node = (ISymbolicExpressionTreeNode)currSelected.Content.Clone();
     141      var originalNode = currSelected.Content;
    142142
    143143      ISymbolicExpressionTreeNode newNode = null;
     
    180180        }
    181181      }
    182       tempNode = currSelected.SymbolicExpressionTreeNode;
     182      tempNode = currSelected.Content;
    183183      foreach (var node in tempNode.IterateNodesPostfix()) {
    184184        var visualNode = GetVisualSymbolicExpressionTreeNode(node);
     
    194194    }
    195195    private void removeNodeToolStripMenuItem_Click(object sender, EventArgs e) {
    196       var node = currSelected.SymbolicExpressionTreeNode;
     196      var node = currSelected.Content;
    197197      if (node == tempNode) tempNode = null;
    198198      ModifyTree(Tree, node.Parent, node, null, removeSubtree: false);
     
    200200    }
    201201    private void removeSubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
    202       var node = currSelected.SymbolicExpressionTreeNode;
     202      var node = currSelected.Content;
    203203      if (node.IterateNodesPostfix().Contains(tempNode)) tempNode = null;
    204204      ModifyTree(Tree, node.Parent, node, null, removeSubtree: true);
     
    209209      if (!(lastOp == EditOp.CopySubtree || lastOp == EditOp.CutSubtree)) return;
    210210      // 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;
     211      var node = currSelected.Content;
    212212      if (node is ConstantTreeNode || node is VariableTreeNode) return;
    213213      // check if the currently selected node can accept the copied node as a child
     
    218218            if (tempNode.IterateNodesBreadth().Contains(node))
    219219              throw new ArgumentException();// cannot cut/paste a node into itself
    220             ModifyTree(Tree, tempNode.Parent, tempNode, null); //remove node from its original parent     
     220            ModifyTree(Tree, tempNode.Parent, tempNode, null); //remove node from its original parent
    221221            ModifyTree(Tree, node, null, tempNode); //insert it as a child to the new parent
    222222            break;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TextualSymbolicDataAnalysisModelView.designer.cs

    r11118 r11120  
    4848      this.SuspendLayout();
    4949      //
    50       // expressionTreeView
     50      // symbolicExpressionTreeView
    5151      //
    5252      this.symbolicExpressionTreeView.AllowDrop = true;
     
    5555      this.symbolicExpressionTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
    5656      this.symbolicExpressionTreeView.Location = new System.Drawing.Point(0, 0);
    57       this.symbolicExpressionTreeView.Name = "expressionTreeView";
     57      this.symbolicExpressionTreeView.Name = "symbolicExpressionTreeView";
    5858      this.symbolicExpressionTreeView.ReadOnly = false;
    5959      this.symbolicExpressionTreeView.Size = new System.Drawing.Size(352, 413);
    6060      this.symbolicExpressionTreeView.TabIndex = 0;
    6161      //
    62       // SymbolicExpressionModelView
     62      // TextualSymbolicDataAnalysisModelView
    6363      //
    6464      this.AllowDrop = true;
    65       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    6665      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    6766      this.Controls.Add(this.symbolicExpressionTreeView);
    68       this.Name = "SymbolicExpressionModelView";
     67      this.Name = "TextualSymbolicDataAnalysisModelView";
    6968      this.Size = new System.Drawing.Size(352, 413);
    7069      this.ResumeLayout(false);
Note: See TracChangeset for help on using the changeset viewer.