- Timestamp:
- 07/08/10 11:23:02 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.cs
r3938 r4015 97 97 protected override void SetEnabledStateOfControls() { 98 98 base.SetEnabledStateOfControls(); 99 tab Control1.Enabled = Content != null;99 tableLayoutPanel1.Enabled = Content != null; 100 100 pictureBox.Enabled = Content != null; 101 101 tourGroupBox.Enabled = Content != null; … … 108 108 } else { 109 109 DoubleMatrix coordinates = Content.Coordinates; 110 DoubleMatrix distanceMatrix = Content.DistanceMatrix; 111 BoolValue useDistanceMatrix = Content.UseDistanceMatrix; 112 DoubleArray dueTime = Content.DueTime; 113 DoubleArray serviceTime = Content.ServiceTime; 114 DoubleArray readyTime = Content.ReadyTime; 115 110 116 Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height); 117 118 Pen[] pens = {new Pen(Color.FromArgb(92,20,237)), new Pen(Color.FromArgb(237,183,20)), new Pen(Color.FromArgb(237,20,219)), new Pen(Color.FromArgb(20,237,76)), 119 new Pen(Color.FromArgb(237,61,20)), new Pen(Color.FromArgb(115,78,26)), new Pen(Color.FromArgb(20,237,229)), new Pen(Color.FromArgb(39,101,19)), 120 new Pen(Color.FromArgb(230,170,229)), new Pen(Color.FromArgb(142,136,89)), new Pen(Color.FromArgb(157,217,166)), new Pen(Color.FromArgb(31,19,101)), 121 new Pen(Color.FromArgb(173,237,20)), new Pen(Color.FromArgb(230,231,161)), new Pen(Color.FromArgb(142,89,89)), new Pen(Color.FromArgb(93,89,142)), 122 new Pen(Color.FromArgb(146,203,217)), new Pen(Color.FromArgb(101,19,75)), new Pen(Color.FromArgb(198,20,237)), new Pen(Color.FromArgb(185,185,185)), 123 new Pen(Color.FromArgb(179,32,32)), new Pen(Color.FromArgb(18,119,115)), new Pen(Color.FromArgb(104,158,239)), new Pen(Color.Black)}; 111 124 112 125 if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) { … … 123 136 double yStep = yMax != yMin ? (pictureBox.Height - 2 * border) / (yMax - yMin) : 1; 124 137 125 Point[] points = new Point[coordinates.Rows];126 for (int i = 0; i < coordinates.Rows; i++)127 points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),128 bitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));129 130 138 using (Graphics graphics = Graphics.FromImage(bitmap)) { 131 139 if (Content.Solution != null) { 140 int currentTour = 0; 132 141 foreach (Tour tour in Content.Solution.Tours) { 142 double t = 0.0; 133 143 Point[] tourPoints = new Point[tour.Count]; 144 int lastCustomer = 0; 145 134 146 for (int i = 0; i < tour.Count; i++) { 135 tourPoints[i] = points[tour[i].Value]; 147 int customer = tour[i].Value; 148 149 Point customerPoint = new Point(border + ((int)((coordinates[customer, 0] - xMin) * xStep)), 150 bitmap.Height - (border + ((int)((coordinates[customer, 1] - yMin) * yStep)))); 151 tourPoints[i] = customerPoint; 152 153 if (i > 0) { 154 Brush customerBrush = Brushes.Black; 155 156 t += VehicleRoutingProblem.GetDistance( 157 lastCustomer, customer, coordinates, distanceMatrix, useDistanceMatrix); 158 159 if (t < readyTime[customer]) { 160 t = readyTime[customer]; 161 customerBrush = Brushes.Yellow; 162 } else if (t > dueTime[customer]) { 163 customerBrush = Brushes.Red; 164 } 165 166 t += serviceTime[customer]; 167 168 graphics.FillRectangle(customerBrush, customerPoint.X - 2, customerPoint.Y - 2, 6, 6); 169 } 170 lastCustomer = customer; 136 171 } 137 graphics.DrawPolygon(Pens.Black, tourPoints); 172 173 graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints); 174 currentTour++; 138 175 } 139 } 140 141 for (int i = 0; i < points.Length; i++) 142 graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6); 176 } 143 177 } 144 178 } 179 180 for (int i = 0; i < pens.Length; i++) 181 pens[i].Dispose(); 182 145 183 pictureBox.Image = bitmap; 146 184 }
Note: See TracChangeset
for help on using the changeset viewer.