Changeset 11864


Ignore:
Timestamp:
02/02/15 17:23:33 (3 years ago)
Author:
bburlacu
Message:

#1772: Improved functionality of the SymbolicDataAnalysisGenealogyGraphView in terms of graph navigation and display of useful information. Fixed save of tree image to file in the SymbolicExpressionTreeChart.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
7 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r11638 r11864  
    299299
    300300    #region methods for painting the symbolic expression tree
    301     private void DrawFunctionTree(Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) {
    302       CalculateLayout(preferredWidth, preferredHeight, minHDistance, minVDistance);
     301    private void DrawFunctionTree(Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance, bool recalculateLayout = true) {
     302      if (recalculateLayout)
     303        CalculateLayout(preferredWidth, preferredHeight, minHDistance, minVDistance);
     304
    303305      var visualNodes = visualTreeNodes.Values;
    304306      //draw nodes and connections
     
    364366    public void SaveImageAsBitmap(string filename) {
    365367      if (tree == null) return;
    366       Image image = new Bitmap(Width, Height);
    367       using (Graphics g = Graphics.FromImage(image)) {
    368         DrawFunctionTree(g, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);
    369       }
    370       image.Save(filename);
     368      Image bitmap = new Bitmap(Width, Height);
     369      using (var g = Graphics.FromImage(bitmap)) {
     370        DrawFunctionTree(g, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);
     371      }
     372      bitmap.Save(filename);
    371373    }
    372374
     
    376378        using (Metafile file = new Metafile(filename, g.GetHdc())) {
    377379          using (Graphics emfFile = Graphics.FromImage(file)) {
    378             DrawFunctionTree(emfFile, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);
     380            DrawFunctionTree(emfFile, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);
    379381          }
    380382        }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r11852 r11864  
    5757        return SelectedVisualNode == null ? null : SelectedVisualNode.Data;
    5858      }
     59      set {
     60        SelectedVisualNode = GetMappedNode(value);
     61        UpdateSelectedVisualNode();
     62      }
    5963    }
    6064
     
    215219      if (SelectedVisualNode == null) return;
    216220
     221      UpdateSelectedVisualNode(); // redraw ancestries, mark node etc.
     222
     223      base.pictureBox_MouseUp(sender, e);
     224    }
     225
     226    private void UpdateSelectedVisualNode() {
    217227      if (!LockGenealogy) {
    218228        // new node has been selected, clean up
     
    238248
    239249      if (SelectedVisualNode != null)
    240         OnGenealogyGraphNodeClicked(SelectedVisualNode, e); // emit clicked event
    241 
    242       base.pictureBox_MouseUp(sender, e);
     250        OnGenealogyGraphNodeClicked(SelectedVisualNode, null); // emit clicked event
    243251    }
    244252    #endregion
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r11817 r11864  
    219219    <Compile Include="MenuItems\OptimizeDataAnalysisRunsMenuItem.cs" />
    220220    <Compile Include="Plugin.cs" />
     221    <Compile Include="Properties\Resources.Designer.cs">
     222      <AutoGen>True</AutoGen>
     223      <DesignTime>True</DesignTime>
     224      <DependentUpon>Resources.resx</DependentUpon>
     225    </Compile>
    221226    <Compile Include="SlidingWindowDataView.cs">
    222227      <SubType>UserControl</SubType>
     
    371376      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    372377    </Content>
     378    <None Include="Resources\LargeLeftDiagonal_235.png" />
     379    <None Include="Resources\LargeRightDiagonal_238.png" />
     380  </ItemGroup>
     381  <ItemGroup>
     382    <EmbeddedResource Include="Properties\Resources.resx">
     383      <Generator>ResXFileCodeGenerator</Generator>
     384      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     385      <SubType>Designer</SubType>
     386    </EmbeddedResource>
     387    <EmbeddedResource Include="Tracking\SymbolicDataAnalysisGenealogyGraphView.resx">
     388      <DependentUpon>SymbolicDataAnalysisGenealogyGraphView.cs</DependentUpon>
     389    </EmbeddedResource>
    373390  </ItemGroup>
    374391  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.Designer.cs

    r11817 r11864  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.components = new System.ComponentModel.Container();
     47      this.groupBox1 = new System.Windows.Forms.GroupBox();
     48      this.navigateRightButton = new System.Windows.Forms.Button();
     49      this.navigateLeftButton = new System.Windows.Forms.Button();
     50      this.nodeDegreeLabel = new System.Windows.Forms.Label();
     51      this.nodeDegreeLabelLabel = new System.Windows.Forms.Label();
     52      this.nodeRankLabel = new System.Windows.Forms.Label();
     53      this.nodeRankLabelLabel = new System.Windows.Forms.Label();
     54      this.nodeQualityLabel = new System.Windows.Forms.Label();
     55      this.nodeQualityLabelLabel = new System.Windows.Forms.Label();
     56      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     57      this.splitContainer.Panel1.SuspendLayout();
     58      this.splitContainer.Panel2.SuspendLayout();
     59      this.splitContainer.SuspendLayout();
     60      this.groupBox1.SuspendLayout();
    4861      this.SuspendLayout();
     62      //
     63      // splitContainer
     64      //
     65      //
     66      // genealogyGraphChart
     67      //
     68      this.genealogyGraphChart.Size = new System.Drawing.Size(692, 697);
     69      //
     70      // groupBox1
     71      //
     72      this.groupBox1.Controls.Add(this.navigateRightButton);
     73      this.groupBox1.Controls.Add(this.navigateLeftButton);
     74      this.groupBox1.Controls.Add(this.nodeDegreeLabel);
     75      this.groupBox1.Controls.Add(this.nodeDegreeLabelLabel);
     76      this.groupBox1.Controls.Add(this.nodeRankLabel);
     77      this.groupBox1.Controls.Add(this.nodeRankLabelLabel);
     78      this.groupBox1.Controls.Add(this.nodeQualityLabel);
     79      this.groupBox1.Controls.Add(this.nodeQualityLabelLabel);
     80      this.groupBox1.Location = new System.Drawing.Point(420, 4);
     81      this.groupBox1.Name = "groupBox1";
     82      this.groupBox1.Size = new System.Drawing.Size(624, 44);
     83      this.groupBox1.TabIndex = 2;
     84      this.groupBox1.TabStop = false;
     85      this.groupBox1.Text = "Current Node";
     86      //
     87      // navigateRightButton
     88      //
     89      this.navigateRightButton.Image = global::HeuristicLab.Problems.DataAnalysis.Symbolic.Views.Properties.Resources.LargeLeftDiagonal_235;
     90      this.navigateRightButton.Location = new System.Drawing.Point(309, 15);
     91      this.navigateRightButton.Name = "navigateRightButton";
     92      this.navigateRightButton.Size = new System.Drawing.Size(22, 22);
     93      this.navigateRightButton.TabIndex = 6;
     94      this.navigateRightButton.UseVisualStyleBackColor = true;
     95      this.navigateRightButton.Click += new System.EventHandler(this.navigateRightButton_Click);
     96      //
     97      // navigateLeftButton
     98      //
     99      this.navigateLeftButton.Image = global::HeuristicLab.Problems.DataAnalysis.Symbolic.Views.Properties.Resources.LargeRightDiagonal_238;
     100      this.navigateLeftButton.Location = new System.Drawing.Point(281, 15);
     101      this.navigateLeftButton.Name = "navigateLeftButton";
     102      this.navigateLeftButton.Size = new System.Drawing.Size(22, 22);
     103      this.navigateLeftButton.TabIndex = 6;
     104      this.navigateLeftButton.UseVisualStyleBackColor = true;
     105      this.navigateLeftButton.Click += new System.EventHandler(this.navigateLeftButton_Click);
     106      //
     107      // nodeDegreeLabel
     108      //
     109      this.nodeDegreeLabel.AutoSize = true;
     110      this.nodeDegreeLabel.Location = new System.Drawing.Point(235, 20);
     111      this.nodeDegreeLabel.Name = "nodeDegreeLabel";
     112      this.nodeDegreeLabel.Size = new System.Drawing.Size(0, 13);
     113      this.nodeDegreeLabel.TabIndex = 5;
     114      //
     115      // nodeDegreeLabelLabel
     116      //
     117      this.nodeDegreeLabelLabel.AutoSize = true;
     118      this.nodeDegreeLabelLabel.Location = new System.Drawing.Point(192, 20);
     119      this.nodeDegreeLabelLabel.Name = "nodeDegreeLabelLabel";
     120      this.nodeDegreeLabelLabel.Size = new System.Drawing.Size(45, 13);
     121      this.nodeDegreeLabelLabel.TabIndex = 4;
     122      this.nodeDegreeLabelLabel.Text = "Degree:";
     123      //
     124      // nodeRankLabel
     125      //
     126      this.nodeRankLabel.AutoSize = true;
     127      this.nodeRankLabel.Location = new System.Drawing.Point(138, 20);
     128      this.nodeRankLabel.Name = "nodeRankLabel";
     129      this.nodeRankLabel.Size = new System.Drawing.Size(0, 13);
     130      this.nodeRankLabel.TabIndex = 3;
     131      //
     132      // nodeRankLabelLabel
     133      //
     134      this.nodeRankLabelLabel.AutoSize = true;
     135      this.nodeRankLabelLabel.Location = new System.Drawing.Point(96, 20);
     136      this.nodeRankLabelLabel.Name = "nodeRankLabelLabel";
     137      this.nodeRankLabelLabel.Size = new System.Drawing.Size(36, 13);
     138      this.nodeRankLabelLabel.TabIndex = 2;
     139      this.nodeRankLabelLabel.Text = "Rank:";
     140      //
     141      // nodeQualityLabel
     142      //
     143      this.nodeQualityLabel.AutoSize = true;
     144      this.nodeQualityLabel.Location = new System.Drawing.Point(54, 20);
     145      this.nodeQualityLabel.Name = "nodeQualityLabel";
     146      this.nodeQualityLabel.Size = new System.Drawing.Size(0, 13);
     147      this.nodeQualityLabel.TabIndex = 1;
     148      //
     149      // nodeQualityLabelLabel
     150      //
     151      this.nodeQualityLabelLabel.AutoSize = true;
     152      this.nodeQualityLabelLabel.Location = new System.Drawing.Point(6, 20);
     153      this.nodeQualityLabelLabel.Name = "nodeQualityLabelLabel";
     154      this.nodeQualityLabelLabel.Size = new System.Drawing.Size(42, 13);
     155      this.nodeQualityLabelLabel.TabIndex = 0;
     156      this.nodeQualityLabelLabel.Text = "Quality:";
    49157      //
    50158      // SymbolicDataAnalysisGenealogyGraphView
     
    52160      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    53161      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     162      this.Controls.Add(this.groupBox1);
    54163      this.Name = "SymbolicDataAnalysisGenealogyGraphView";
    55164      this.Size = new System.Drawing.Size(1247, 755);
     165      this.Controls.SetChildIndex(this.splitContainer, 0);
     166      this.Controls.SetChildIndex(this.groupBox1, 0);
     167      this.splitContainer.Panel1.ResumeLayout(false);
     168      this.splitContainer.Panel2.ResumeLayout(false);
     169      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     170      this.splitContainer.ResumeLayout(false);
     171      this.groupBox1.ResumeLayout(false);
     172      this.groupBox1.PerformLayout();
    56173      this.ResumeLayout(false);
     174
    57175    }
    58176
    59177    #endregion
     178
     179    private System.Windows.Forms.GroupBox groupBox1;
     180    private System.Windows.Forms.Label nodeQualityLabelLabel;
     181    private System.Windows.Forms.Label nodeQualityLabel;
     182    private System.Windows.Forms.Label nodeRankLabelLabel;
     183    private System.Windows.Forms.Label nodeRankLabel;
     184    private System.Windows.Forms.Label nodeDegreeLabel;
     185    private System.Windows.Forms.Label nodeDegreeLabelLabel;
     186    private System.Windows.Forms.Button navigateRightButton;
     187    private System.Windows.Forms.Button navigateLeftButton;
    60188  }
    61189}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicDataAnalysisGenealogyGraphView.cs

    r11852 r11864  
    7373      var visualNode = (VisualGenealogyGraphNode)sender;
    7474      var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)visualNode.Data;
     75
     76      nodeQualityLabel.Text = String.Format("{0:0.000}", graphNode.Quality);
     77      nodeRankLabel.Text = String.Format("{0:0.0}", graphNode.Rank);
     78      nodeDegreeLabel.Text = String.Format("{0} / {1}", graphNode.InDegree, graphNode.OutDegree);
    7579
    7680      if (openNew_CheckBox.Checked) {
     
    169173        var visualNode = SymbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(s);
    170174        visualNode.LineColor = myColor;
    171         //        visualNode.FillColor = myColor;
    172175
    173176        foreach (var c in s.Subtrees) {
     
    178181      SymbolicExpressionTreeChart.RepaintNodes();
    179182    }
     183
     184    private void navigateLeftButton_Click(object sender, EventArgs e) {
     185      var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode;
     186      if (graphNode.Parents.Any()) {
     187        genealogyGraphChart.SelectedGraphNode = graphNode.Parents.First();
     188      }
     189    }
     190
     191    private void navigateRightButton_Click(object sender, EventArgs e) {
     192      var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)genealogyGraphChart.SelectedGraphNode;
     193      if (graphNode.Parents.Any()) {
     194        genealogyGraphChart.SelectedGraphNode = graphNode.Parents.Last(); // this will only work for genealogy graphs (not trace graphs)
     195      }
     196    }
    180197  }
    181198
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman/3.3/Analyzers/TSPGenealogyAnalyzer.cs

    r10300 r11864  
    88  [Item("TSPGenealogyAnalyzer", "A genealogy analyzer for permutation encodings.")]
    99  public class TSPGenealogyAnalyzer : GenealogyAnalyzer<Permutation> {
     10    public TSPGenealogyAnalyzer() { }
     11
     12    [StorableConstructor]
     13    protected TSPGenealogyAnalyzer(bool deserializing) : base(deserializing) { }
    1014  }
    1115}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r11208 r11864  
    388388        if (TSPCrossover != null) {
    389389          TSPGenealogyAnalyzer.BeforeCrossoverOperatorParameter.ActualValue = new BeforeCrossoverOperator<Permutation>();
    390           TSPGenealogyAnalyzer.BeforeCrossoverOperator.ParentsParameter.ActualName = TSPCrossover.ParentsParameter.Name;
    391           TSPGenealogyAnalyzer.BeforeCrossoverOperator.ChildParameter.ActualName = TSPCrossover.ChildParameter.Name;
     390          TSPGenealogyAnalyzer.BeforeCrossoverOperator.ParentsParameter.ActualName = TSPCrossover.ParentsParameter.ActualName;
     391          TSPGenealogyAnalyzer.BeforeCrossoverOperator.ChildParameter.ActualName = TSPCrossover.ChildParameter.ActualName;
    392392          TSPGenealogyAnalyzer.AfterCrossoverOperatorParameter.ActualValue = new AfterCrossoverOperator<Permutation>();
    393           TSPGenealogyAnalyzer.AfterCrossoverOperator.ParentsParameter.ActualName = TSPCrossover.ParentsParameter.Name;
    394           TSPGenealogyAnalyzer.AfterCrossoverOperator.ChildParameter.ActualName = TSPCrossover.ChildParameter.Name;
     393          TSPGenealogyAnalyzer.AfterCrossoverOperator.ParentsParameter.ActualName = TSPCrossover.ParentsParameter.ActualName;
     394          TSPGenealogyAnalyzer.AfterCrossoverOperator.ChildParameter.ActualName = TSPCrossover.ChildParameter.ActualName;
    395395        }
    396396        if (TSPManipulator != null) {
    397397          TSPGenealogyAnalyzer.BeforeManipulatorOperatorParameter.ActualValue = new BeforeManipulatorOperator<Permutation>();
    398           TSPGenealogyAnalyzer.BeforeManipulatorOperator.ChildParameter.ActualName = TSPManipulator.PermutationParameter.Name;
     398          TSPGenealogyAnalyzer.BeforeManipulatorOperator.ChildParameter.ActualName = TSPManipulator.PermutationParameter.ActualName;
    399399          TSPGenealogyAnalyzer.AfterManipulatorOperatorParameter.ActualValue = new AfterManipulatorOperator<Permutation>();
    400           TSPGenealogyAnalyzer.AfterManipulatorOperator.ChildParameter.ActualName = TSPManipulator.PermutationParameter.Name;
     400          TSPGenealogyAnalyzer.AfterManipulatorOperator.ChildParameter.ActualName = TSPManipulator.PermutationParameter.ActualName;
    401401        }
    402402        TSPGenealogyAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Tracking.sln

    r11852 r11864  
    184184    HideSolutionNode = FALSE
    185185  EndGlobalSection
     186  GlobalSection(Performance) = preSolution
     187    HasPerformanceSessions = true
     188  EndGlobalSection
    186189  GlobalSection(TestCaseManagementSettings) = postSolution
    187190    CategoryFile = HeuristicLab.Tracking.vsmdi
Note: See TracChangeset for help on using the changeset viewer.