- Timestamp:
- 03/22/10 01:00:52 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TSP.Views/3.3/PathTSPTourView.cs
r3139 r3153 69 69 base.OnContentChanged(); 70 70 if (Content == null) { 71 pictureBox.Image = null; 71 72 pictureBox.Enabled = false; 72 73 } else { 73 74 pictureBox.Enabled = true; 75 GenerateImage(); 74 76 } 75 GenerateImage();76 77 } 77 78 … … 85 86 Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 86 87 87 if ( coordinates != null) {88 if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) { 88 89 double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue; 89 90 for (int i = 0; i < coordinates.Rows; i++) { … … 99 100 100 101 Point[] points = new Point[coordinates.Rows]; 101 if (permutation == null) { 102 for (int i = 0; i < coordinates.Rows; i++) 103 points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)), 104 border + ((int)((coordinates[i, 1] - yMin) * yStep))); 105 } else { 106 for (int i = 0; i < coordinates.Rows; i++) 107 points[i] = new Point(border + ((int)((coordinates[permutation[i], 0] - xMin) * xStep)), 108 border + ((int)((coordinates[permutation[i], 1] - yMin) * yStep))); 109 } 102 for (int i = 0; i < coordinates.Rows; i++) 103 points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)), 104 border + ((int)((coordinates[i, 1] - yMin) * yStep))); 110 105 111 106 Graphics graphics = Graphics.FromImage(bitmap); 112 if (permutation != null) graphics.DrawPolygon(Pens.Black, points); 107 if ((permutation != null) && (permutation.Length == coordinates.Rows) && (permutation.Validate())) { 108 Point[] tour = new Point[permutation.Length]; 109 for (int i = 0; i < permutation.Length; i++) { 110 tour[i] = points[permutation[i]]; 111 } 112 graphics.DrawPolygon(Pens.Black, tour); 113 } 113 114 for (int i = 0; i < points.Length; i++) 114 115 graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6);
Note: See TracChangeset
for help on using the changeset viewer.