Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/10 11:23:02 (14 years ago)
Author:
svonolfe
Message:

Improved VRP solution view (#1039)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.cs

    r3938 r4015  
    9797    protected override void SetEnabledStateOfControls() {
    9898      base.SetEnabledStateOfControls();
    99       tabControl1.Enabled = Content != null;
     99      tableLayoutPanel1.Enabled = Content != null;
    100100      pictureBox.Enabled = Content != null;
    101101      tourGroupBox.Enabled = Content != null;
     
    108108        } else {
    109109          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
    110116          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)};
    111124
    112125          if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
     
    123136            double yStep = yMax != yMin ? (pictureBox.Height - 2 * border) / (yMax - yMin) : 1;
    124137
    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 
    130138            using (Graphics graphics = Graphics.FromImage(bitmap)) {
    131139              if (Content.Solution != null) {
     140                int currentTour = 0;
    132141                foreach (Tour tour in Content.Solution.Tours) {
     142                  double t = 0.0;
    133143                  Point[] tourPoints = new Point[tour.Count];
     144                  int lastCustomer = 0;
     145
    134146                  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;
    136171                  }
    137                   graphics.DrawPolygon(Pens.Black, tourPoints);
     172
     173                  graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     174                  currentTour++;
    138175                }
    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              }               
    143177            }
    144178          }
     179
     180          for (int i = 0; i < pens.Length; i++)
     181            pens[i].Dispose();
     182
    145183          pictureBox.Image = bitmap;
    146184        }
Note: See TracChangeset for help on using the changeset viewer.