Changeset 16140 for branches/2817-BinPackingSpeedup/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs
- Timestamp:
- 09/14/18 11:36:59 (6 years ago)
- Location:
- branches/2817-BinPackingSpeedup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup
- Property svn:mergeinfo changed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs
r14185 r16140 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Drawing; 24 using System.Linq; 24 25 using System.Windows.Forms; 25 26 using HeuristicLab.Core.Views; … … 136 137 137 138 private void GenerateImage() { 138 if ( pictureBox.Enabled && pictureBox.Width > 0 && pictureBox.Height > 0) {139 140 141 } else {142 if (backgroundImage == null) {143 GenerateBackgroundImage();144 pictureBox.Image = backgroundImage;145 }146 pictureBox.Refresh();147 DoubleMatrix bounds = Content.Bounds;148 if (bounds == null) bounds = Content.Evaluator.Bounds;149 double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1];150 double xStep = backgroundImage.Width / (xMax - xMin), yStep = backgroundImage.Height / (yMax - yMin);151 using (Graphics graphics = pictureBox.CreateGraphics()) {152 if (Content.BestKnownRealVector != null) { 153 Pen cross = new Pen(Brushes.Red, 2.0f);154 float a = (float)((Content.BestKnownRealVector[0] - xMin) * xStep);155 float b = (float)((Content.BestKnownRealVector[1] - yMin) * yStep);156 graphics.DrawLine(cross, a - 4, b - 4, a + 4, b + 4);157 graphics.DrawLine(cross, a - 4, b + 4, a + 4, b - 4);158 }159 if (Content.Population != null) {160 foreach (RealVector vector in Content.Population)161 graphics.FillEllipse(Brushes.Blue, (float)((vector[0] - xMin) * xStep - 4), (float)((vector[1] - yMin) * yStep - 4), 8.0f, 8.0f);162 }163 if (Content.BestRealVector != null) {164 graphics.FillEllipse(Brushes.Green, (float)((Content.BestRealVector[0] - xMin) * xStep - 5), (float)((Content.BestRealVector[1] - yMin) * yStep - 5), 10.0f, 10.0f);165 }166 }139 if (!pictureBox.Enabled || pictureBox.Width <= 0 || pictureBox.Height <= 0) return; 140 if (Content == null) { 141 pictureBox.Image = null; 142 return; 143 } 144 if (backgroundImage == null) { 145 GenerateBackgroundImage(); 146 pictureBox.Image = backgroundImage; 147 } 148 pictureBox.Refresh(); 149 DoubleMatrix bounds = Content.Bounds; 150 if (bounds == null) bounds = Content.Evaluator.Bounds; 151 double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1]; 152 double xStep = backgroundImage.Width / (xMax - xMin), yStep = backgroundImage.Height / (yMax - yMin); 153 154 using (Graphics graphics = pictureBox.CreateGraphics()) { 155 if (Content.BestKnownRealVector != null && Content.BestKnownRealVector.Length == 2) { 156 Pen cross = new Pen(Brushes.Red, 2.0f); 157 float a = (float)((Content.BestKnownRealVector[0] - xMin) * xStep); 158 float b = (float)((Content.BestKnownRealVector[1] - yMin) * yStep); 159 graphics.DrawLine(cross, a - 4, b - 4, a + 4, b + 4); 160 graphics.DrawLine(cross, a - 4, b + 4, a + 4, b - 4); 161 } 162 if (Content.Population != null) { 163 foreach (RealVector vector in Content.Population.Where(x => x.Length == 2)) 164 graphics.FillEllipse(Brushes.Blue, (float)((vector[0] - xMin) * xStep - 4), (float)((vector[1] - yMin) * yStep - 4), 8.0f, 8.0f); 165 } 166 if (Content.BestRealVector != null && Content.BestRealVector.Length == 2) { 167 graphics.FillEllipse(Brushes.Green, (float)((Content.BestRealVector[0] - xMin) * xStep - 5), (float)((Content.BestRealVector[1] - yMin) * yStep - 5), 10.0f, 10.0f); 167 168 } 168 169 }
Note: See TracChangeset
for help on using the changeset viewer.