Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7372


Ignore:
Timestamp:
01/19/12 17:04:32 (13 years ago)
Author:
bburlacu
Message:

#1763: Intermediate commit with work done on the SymbolicExpressionTreeChart view (proxy right click events to nodes, methods for changing the weight/value of variable/constant nodes).

Location:
branches/HeuristicLab.TreeSimplifierView
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj

    r7365 r7372  
    135135      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
    136136    </Reference>
     137    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    137138    <Reference Include="HeuristicLab.Random-3.3">
    138139      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
     
    232233      <Install>true</Install>
    233234    </BootstrapperPackage>
     235  </ItemGroup>
     236  <ItemGroup>
     237    <EmbeddedResource Include="SymbolicExpressionTreeChart.resx">
     238      <DependentUpon>SymbolicExpressionTreeChart.cs</DependentUpon>
     239    </EmbeddedResource>
    234240  </ItemGroup>
    235241  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.Designer.cs

    r7259 r7372  
    1919 */
    2020#endregion
     21
     22using System;
     23using System.Windows.Forms;
     24using HeuristicLab.Common;
    2125
    2226namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
     
    4953      this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    5054      this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     55      this.changeValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5156      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    5257      this.contextMenuStrip.SuspendLayout();
     
    5661      //
    5762      this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    58             this.saveImageToolStripMenuItem});
     63            this.saveImageToolStripMenuItem,
     64            this.changeValueToolStripMenuItem});
    5965      this.contextMenuStrip.Name = "contextMenuStrip";
    60       this.contextMenuStrip.Size = new System.Drawing.Size(135, 26);
     66      this.contextMenuStrip.Size = new System.Drawing.Size(153, 70);
     67      this.contextMenuStrip.Opened += new System.EventHandler(this.contextMenuStrip_Opened);
    6168      //
    6269      // saveImageToolStripMenuItem
    6370      //
    6471      this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem";
    65       this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
     72      this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    6673      this.saveImageToolStripMenuItem.Text = "Save Image";
    6774      this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click);
     75      //
     76      // changeValueToolStripMenuItem
     77      //
     78      this.changeValueToolStripMenuItem.Enabled = false;
     79      this.changeValueToolStripMenuItem.Name = "changeValueToolStripMenuItem";
     80      this.changeValueToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     81      this.changeValueToolStripMenuItem.Text = "Change Value";
     82      this.changeValueToolStripMenuItem.Click += new System.EventHandler(this.changeValueToolStripMenuItem_Click);
    6883      //
    6984      // saveFileDialog
    7085      //
    7186      this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|EMF (*.emf)|*.emf";
    72       this.saveFileDialog.FilterIndex = 1;     
     87      //
    7388      // SymbolicExpressionTreeChart
    7489      //
     
    93108    private System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem;
    94109    private System.Windows.Forms.SaveFileDialog saveFileDialog;
     110    private System.Windows.Forms.ToolStripMenuItem changeValueToolStripMenuItem;
    95111  }
    96112}
  • branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r7259 r7372  
    2525using System.Drawing.Imaging;
    2626using System.Windows.Forms;
     27using System.Windows.Forms.VisualStyles;
    2728
    2829namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
     
    3233    private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;
    3334    private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines;
     35    private VisualSymbolicExpressionTreeNode selectedNode;
    3436
    3537    public SymbolicExpressionTreeChart() {
     
    4345      this.backgroundColor = Color.White;
    4446      this.textFont = new Font("Times New Roman", 8);
     47      selectedNode = null;
    4548    }
    4649
     
    347350    }
    348351    #endregion
     352
     353    private void contextMenuStrip_Opened(object sender, EventArgs e) {
     354      var menu = sender as ContextMenuStrip;
     355      if (menu == null) return;
     356      var point = menu.SourceControl.PointToClient(Cursor.Position);
     357      selectedNode = FindVisualSymbolicExpressionTreeNodeAt(point.X, point.Y);
     358      if (selectedNode != null) {
     359        OnSymbolicExpressionTreeNodeClicked(selectedNode, new MouseEventArgs(MouseButtons.Right, 1, point.X, point.Y, 0));
     360      }
     361    }
     362
     363    private void changeValueToolStripMenuItem_Click(object sender, EventArgs e) {
     364      var treeNode = selectedNode.SymbolicExpressionTreeNode;
     365      // textbox as a popup/tooltip
     366      var dialog = new Core.Views.TextDialog("Change value", String.Empty, false);
     367      dialog.AutoSize = true;
     368      dialog.ShowDialog(this);
     369      double newValue;
     370      if (double.TryParse(dialog.Text, out newValue)) {
     371        if (treeNode.Symbol is Problems.DataAnalysis.Symbolic.Constant) {
     372          var node = treeNode as Problems.DataAnalysis.Symbolic.ConstantTreeNode;
     373          node.Value = newValue;
     374        } else if (treeNode.Symbol is Problems.DataAnalysis.Symbolic.Variable) {
     375          var node = treeNode as Problems.DataAnalysis.Symbolic.VariableTreeNode;
     376          node.Weight = newValue;
     377        }
     378      }
     379      this.Repaint();
     380    }
    349381  }
    350382}
  • branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r7365 r7372  
    211211    </BootstrapperPackage>
    212212  </ItemGroup>
     213  <ItemGroup>
     214    <EmbeddedResource Include="InteractiveSymbolicDataAnalysisSolutionSimplifierView.resx">
     215      <DependentUpon>InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs</DependentUpon>
     216    </EmbeddedResource>
     217  </ItemGroup>
    213218  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    214219  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs

    r6256 r7372  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    4847      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4948      this.splitContainer = new System.Windows.Forms.SplitContainer();
     
    5352      this.btnOptimizeConstants = new System.Windows.Forms.Button();
    5453      this.grpViewHost = new System.Windows.Forms.GroupBox();
     54      this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    5555      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    5656      this.splitContainer.Panel1.SuspendLayout();
     
    6161      this.grpViewHost.SuspendLayout();
    6262      this.SuspendLayout();
    63       //
    64       // treeChart
    65       //
    66       this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    67             | System.Windows.Forms.AnchorStyles.Left)
    68             | System.Windows.Forms.AnchorStyles.Right)));
    69       this.treeChart.BackgroundColor = System.Drawing.Color.White;
    70       this.treeChart.LineColor = System.Drawing.Color.Black;
    71       this.treeChart.Location = new System.Drawing.Point(6, 16);
    72       this.treeChart.Name = "treeChart";
    73       this.treeChart.Size = new System.Drawing.Size(201, 291);
    74       this.treeChart.Spacing = 5;
    75       this.treeChart.TabIndex = 0;
    76       this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
    77       this.treeChart.Tree = null;
    78       this.treeChart.SymbolicExpressionTreeNodeDoubleClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeDoubleClicked);
    7963      //
    8064      // viewHost
     
    168152      this.grpViewHost.Text = "Details";
    169153      //
     154      // treeChart
     155      //
     156      this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     157            | System.Windows.Forms.AnchorStyles.Left)
     158            | System.Windows.Forms.AnchorStyles.Right)));
     159      this.treeChart.BackgroundColor = System.Drawing.Color.White;
     160      this.treeChart.LineColor = System.Drawing.Color.Black;
     161      this.treeChart.Location = new System.Drawing.Point(6, 16);
     162      this.treeChart.Name = "treeChart";
     163      this.treeChart.Size = new System.Drawing.Size(201, 291);
     164      this.treeChart.Spacing = 5;
     165      this.treeChart.SuspendRepaint = false;
     166      this.treeChart.TabIndex = 0;
     167      this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
     168      this.treeChart.Tree = null;
     169      this.treeChart.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeClicked);
     170      this.treeChart.SymbolicExpressionTreeNodeDoubleClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeDoubleClicked);
     171      //
    170172      // InteractiveSymbolicDataAnalysisSolutionSimplifierView
    171173      //
  • branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r7259 r7372  
    146146            updateInProgress = false;
    147147            return; // break all loops
     148          }
     149        }
     150      }
     151    }
     152
     153    private void treeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
     154      if (e.Button == MouseButtons.Right) {
     155        var visualTreeNode = sender as VisualSymbolicExpressionTreeNode;
     156        var node = visualTreeNode.SymbolicExpressionTreeNode;
     157        // on a right click we want to show the option of changing the node value (if the node is a constant) or the weight (if the node is a variable)
     158        var menu = treeChart.ContextMenuStrip;
     159        ToolStripItem[] items = menu.Items.Find("changeValueToolStripMenuItem", false);
     160        ToolStripItem changeValueMenuItem = null;
     161        if (items.Length > 0) {
     162          changeValueMenuItem = items[0];
     163        }
     164
     165        if (node.Symbol is Constant || node.Symbol is Variable) {
     166          if (changeValueMenuItem != null) {
     167            changeValueMenuItem.Enabled = true;
     168            changeValueMenuItem.Visible = true;
     169          }
     170        } else {
     171          if (changeValueMenuItem != null) {
     172            changeValueMenuItem.Enabled = false;
     173            changeValueMenuItem.Visible = false;
    148174          }
    149175        }
Note: See TracChangeset for help on using the changeset viewer.