Changeset 15387
- Timestamp:
- 09/28/17 13:16:34 (7 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15336,15383
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs
r14186 r15387 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.