Documentation/Howto/ImplementANewVRPEvaluator: CapacityDependentStopSizeViewPatch.patch
File CapacityDependentStopSizeViewPatch.patch, 3.2 KB (added by pfleck, 10 years ago) |
---|
-
HeuristicLab.Problems.VehicleRouting.Views/3.4/SingleDepotVRPView.cs
21 21 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel;25 using System.Data;26 24 using System.Drawing; 27 using System. Text;28 using System.Windows.Forms;25 using System.Linq; 26 using HeuristicLab.Data; 29 27 using HeuristicLab.MainForm; 30 28 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 31 using HeuristicLab.Data;32 29 33 30 namespace HeuristicLab.Problems.VehicleRouting.Views { 34 31 [View("SingleDepotVRPProblemInstance View")] … … 61 58 double xStep = xMax != xMin ? (bitmap.Width - 2 * border) / (xMax - xMin) : 1; 62 59 double yStep = yMax != yMin ? (bitmap.Height - 2 * border) / (yMax - yMin) : 1; 63 60 61 double maxDemand = Content.Demand.Max(); 62 64 63 using (Graphics graphics = Graphics.FromImage(bitmap)) { 65 64 if (Solution != null) { 66 67 65 List<Tour> tours = Solution.GetTours(); 66 List<Pen> pens = GetColors(tours.Count); 68 67 69 68 int currentTour = 0; 70 69 foreach (Tour tour in tours) { … … 91 90 lastCustomer = location; 92 91 } 93 92 94 graphics.DrawPolygon(pens[currentTour], tourPoints );93 graphics.DrawPolygon(pens[currentTour], tourPoints.ToArray()); 95 94 96 95 for (int i = 0; i < tour.Stops.Count; i++) { 97 graphics.FillRectangle(customerBrushes[i], tourPoints[i + 1].X - 3, tourPoints[i + 1].Y - 3, 6, 6); 96 float size = (float)(10.0 * (Content.GetDemand(tour.Stops[i]) / maxDemand)); 97 size = Math.Max(size, 2); 98 99 graphics.FillRectangle(customerBrushes[i], tourPoints[i + 1].X - size / 2, tourPoints[i + 1].Y - size / 2, size, size); 98 100 } 99 101 100 102 graphics.FillEllipse(Brushes.Blue, tourPoints[0].X - 5, tourPoints[0].Y - 5, 10, 10); … … 103 105 } 104 106 105 107 for (int i = 0; i < pens.Count; i++) 106 108 pens[i].Dispose(); 107 109 } else { 108 110 Point locationPoint; 109 111 //just draw customers … … 111 113 locationPoint = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)), 112 114 bitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep)))); 113 115 114 graphics.FillRectangle(Brushes.Black, locationPoint.X - 3, locationPoint.Y - 3, 6, 6); 116 float size = (float)(10.0 * (Content.GetDemand(i) / maxDemand)); 117 size = Math.Max(size, 2); 118 119 graphics.FillRectangle(Brushes.Black, locationPoint.X - size / 2, locationPoint.Y - size / 2, size, size); 115 120 } 116 121 117 122 locationPoint = new Point(border + ((int)((coordinates[0, 0] - xMin) * xStep)),