Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/07/11 09:57:12 (13 years ago)
Author:
svonolfe
Message:

Adapted PDP view to show the flows (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/CVRPPDTWView.cs

    r6710 r6715  
    2323    }
    2424
     25    private bool drawFlow = false;
     26
     27    protected override void pictureBox_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) {
     28      if (e.Button == System.Windows.Forms.MouseButtons.Right) {
     29        drawFlow = !drawFlow;
     30        GenerateImage();
     31      }     
     32    }
     33
    2534    protected override void DrawVisualization(Bitmap bitmap) {
    2635      DoubleMatrix coordinates = Content.Coordinates;
     
    3948                    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)),
    4049                    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)};
     50
     51      Pen flowPen = new Pen(Brushes.Red, 3);
     52      flowPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
     53      flowPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
    4154
    4255      if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
     
    88101                    customerBrush = Brushes.Orange;
    89102                    customerPen = Pens.Orange;
    90                    
     103
    91104                  } else if (t > dueTime[location]) {
    92105                    customerBrush = Brushes.Red;
     
    108121              }
    109122
    110               graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     123              if (!drawFlow)
     124                graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
    111125
    112126              for (int i = 0; i < tour.Stops.Count; i++) {
    113                 if(validPickupDelivery[i])
     127                if (validPickupDelivery[i]) {
    114128                  graphics.FillRectangle(customerBrushes[i], tourPoints[i + 1].X - 3, tourPoints[i + 1].Y - 3, 6, 6);
    115                 else
     129
     130                  if (demand[tour.Stops[i]] < 0 && drawFlow) {
     131                    int location = pickupDeliveryLocation[tour.Stops[i]];
     132                    int source = tour.Stops.IndexOf(location);
     133
     134                    graphics.DrawLine(flowPen, tourPoints[source + 1], tourPoints[i + 1]);
     135                  }
     136                } else
    116137                  graphics.DrawRectangle(customerPens[i], tourPoints[i + 1].X - 3, tourPoints[i + 1].Y - 3, 6, 6);
    117138              }
     
    122143            }
    123144          } else {
    124             Point locationPoint;
    125             //just draw customers
    126             for (int i = 1; i < coordinates.Rows; i++) {
    127               locationPoint = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
    128                               bitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
     145            {
     146              Point locationPoint;
     147              //just draw customers
     148              for (int i = 1; i < coordinates.Rows; i++) {
     149                locationPoint = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
     150                                bitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
    129151
    130               graphics.FillRectangle(Brushes.Black, locationPoint.X - 3, locationPoint.Y - 3, 6, 6);
     152                graphics.FillRectangle(Brushes.Black, locationPoint.X - 3, locationPoint.Y - 3, 6, 6);
     153              }
     154
     155              locationPoint = new Point(border + ((int)((coordinates[0, 0] - xMin) * xStep)),
     156                                bitmap.Height - (border + ((int)((coordinates[0, 1] - yMin) * yStep))));
     157              graphics.FillEllipse(Brushes.Blue, locationPoint.X - 5, locationPoint.Y - 5, 10, 10);
    131158            }
    132 
    133             locationPoint = new Point(border + ((int)((coordinates[0, 0] - xMin) * xStep)),
    134                               bitmap.Height - (border + ((int)((coordinates[0, 1] - yMin) * yStep))));
    135             graphics.FillEllipse(Brushes.Blue, locationPoint.X - 5, locationPoint.Y - 5, 10, 10);
    136159          }
    137160        }
     
    140163      for (int i = 0; i < pens.Length; i++)
    141164        pens[i].Dispose();
     165
     166      flowPen.Dispose();
    142167    }
    143168  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VRPProblemInstanceView.Designer.cs

    r4374 r6715  
    3939      this.pictureBox.TabStop = false;
    4040      this.pictureBox.SizeChanged += new System.EventHandler(this.pictureBox_SizeChanged);
     41      this.pictureBox.MouseClick += new System.Windows.Forms.MouseEventHandler(pictureBox_MouseClick);
    4142      //
    4243      // VRPProblemInstanceView
     
    5051
    5152    }
    52 
    5353    #endregion
    5454
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VRPProblemInstanceView.cs

    r4374 r6715  
    6969    }
    7070
     71    protected virtual void pictureBox_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) {
     72    }
     73
    7174    protected abstract void DrawVisualization(Bitmap bitmap);
    7275
    73     private void GenerateImage() {
     76    protected void GenerateImage() {
    7477      if ((pictureBox.Width > 0) && (pictureBox.Height > 0)) {
    7578        if (Content == null) {
Note: See TracChangeset for help on using the changeset viewer.