Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/GraphicalSymbolicExpressionTreeView.cs @ 3249

Last change on this file since 3249 was 3244, checked in by gkronber, 14 years ago

Integrated graphical symbolic expression tree view from model analyzer. #937 (Data types and operators for symbolic expression tree encoding)

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Collections.Specialized;
25using System.ComponentModel;
26using System.Data;
27using System.Drawing;
28using System.Linq;
29using System.Text;
30using System.Windows.Forms;
31using HeuristicLab.MainForm;
32using HeuristicLab.MainForm.WindowsForms;
33
34namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
35  [View("Graphical SymbolicExpressionTree View")]
36  [Content(typeof(SymbolicExpressionTree), true)]
37  public partial class GraphicalSymbolicExpressionTreeView : AsynchronousContentView {
38    public new SymbolicExpressionTree Content {
39      get { return (SymbolicExpressionTree)base.Content; }
40      set { base.Content = value; }
41    }
42
43    public GraphicalSymbolicExpressionTreeView()
44      : base() {
45      InitializeComponent();
46      Caption = "Graphical SymbolicExpressionTree View";
47    }
48
49    public GraphicalSymbolicExpressionTreeView(SymbolicExpressionTree content)
50      : this() {
51      Content = content;
52    }
53
54    protected override void OnContentChanged() {
55      base.OnContentChanged();
56      if (Content == null) {
57        symbolicExpressionTreeChart.Tree = null;
58      } else {
59        symbolicExpressionTreeChart.Tree = Content;
60      }
61    }
62   
63    //private VisualFunctionTreeModel visualModel;
64    //public VisualFunctionTreeModel VisualModel {
65    //  get { return this.visualModel; }
66    //  private set {
67    //    if (value != this.visualModel) {
68    //      if (this.visualModel != null)
69    //        this.visualModel.Changed -= new EventHandler(model_Changed);
70
71    //      if (value == null) {
72    //        this.Caption = "Formula tree";
73    //        this.functionTreeChart.FunctionTree = null;
74    //      } else {
75    //        value.Changed += new EventHandler(model_Changed);
76    //        this.functionTreeChart.FunctionTree = value.FunctionTree;
77    //        this.Caption = value.ModelName + " formula tree";
78    //      }
79    //      this.visualModel = value;
80    //    }
81    //  }
82    //}
83
84    private void functionTreeChart_FunctionTreeClicked(object sender, MouseEventArgs e) {
85      VisualSymbolicExpressionTreeNode visualFunctionTreeNode = (VisualSymbolicExpressionTreeNode)sender;
86      visualFunctionTreeNode.LineColor = Color.Red;
87      this.symbolicExpressionTreeChart.Repaint();
88    }
89
90    private void functionTreeChart_FunctionTreeDoubleClicked(object sender, MouseEventArgs e) {
91      VisualSymbolicExpressionTreeNode visualFunctionTreeNode = (VisualSymbolicExpressionTreeNode)sender;
92      visualFunctionTreeNode.FillColor = Color.Blue;
93      this.symbolicExpressionTreeChart.Repaint();
94    }
95  }
96}
Note: See TracBrowser for help on using the repository browser.