Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/30/14 14:59:20 (10 years ago)
Author:
pfleck
Message:

#2208 improved visualization of orienteering solution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringSolutionView.cs

    r11235 r11240  
    2222using System;
    2323using System.Drawing;
     24using System.Linq;
    2425using HeuristicLab.Core.Views;
    2526using HeuristicLab.MainForm;
     
    4142      Content.QualityChanged -= new EventHandler(Content_QualityChanged);
    4243      Content.CoordinatesChanged -= new EventHandler(Content_CoordinatesChanged);
     44      Content.ScoresChanged -= new EventHandler(Content_ScoresChanged);
    4345      Content.IntegerVectorChanged -= new EventHandler(Content_IntegerVectorChanged);
    4446      base.DeregisterContentEvents();
     
    4850      Content.QualityChanged += new EventHandler(Content_QualityChanged);
    4951      Content.CoordinatesChanged += new EventHandler(Content_CoordinatesChanged);
     52      Content.ScoresChanged += new EventHandler(Content_ScoresChanged);
    5053      Content.IntegerVectorChanged += new EventHandler(Content_IntegerVectorChanged);
    5154    }
     
    7780        } else {
    7881          var coordinates = Content.Coordinates;
     82          var scores = Content.Scores;
    7983          var integerVector = Content.IntegerVector;
    8084          var bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
     
    106110                graphics.DrawPolygon(Pens.Black, tour);
    107111              }
    108               for (int i = 0; i < points.Length; i++)
    109                 graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6);
     112
     113              double scoreMin = scores.Min();
     114              double scoreMax = scores.Max();
     115              double scoreRange = scoreMax - scoreMin;
     116              for (int i = 0; i < points.Length; i++) {
     117                double score = scores[i];
     118                int size = (int)Math.Round(((score - scoreMin) / scoreRange) * 9 + 1);
     119                graphics.FillRectangle(Brushes.Red, points[i].X - size / 2, points[i].Y - size / 2, size, size);
     120              }
    110121            }
    111122          } else {
     
    135146        GenerateImage();
    136147    }
     148    private void Content_ScoresChanged(object sender, EventArgs e) {
     149      if (InvokeRequired)
     150        Invoke(new EventHandler(Content_ScoresChanged), sender, e);
     151      else
     152        GenerateImage();
     153    }
    137154    private void Content_IntegerVectorChanged(object sender, EventArgs e) {
    138155      if (InvokeRequired)
Note: See TracChangeset for help on using the changeset viewer.