Changeset 6482


Ignore:
Timestamp:
06/27/11 15:51:15 (8 years ago)
Author:
jhelm
Message:

#1329: Applied some changes to the ScheduleView. Added TaskNr properties to ScheduledTask to make specific selection of tasks in the view possible.

Location:
branches/Scheduling
Files:
1 added
8 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Tests/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3

    • Property svn:ignore
      •  

        old new  
        11HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.csproj.user
         2Plugin.cs
        23bin
        34obj
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/GanttChart.cs

    r6406 r6482  
    1111    private IDictionary<int, Color> jobColors = new SortedDictionary<int, Color>();
    1212    private IDictionary<string, int> rowNames = new Dictionary<string, int>();
    13    
     13
    1414
    1515    public GanttChart() {
     
    2121      if (!jobColors.ContainsKey(jobNr)) {
    2222        Random r = new Random(jobNr + 1);
    23         jobColors[jobNr] = Color.FromArgb (r.Next(256),r.Next(256),r.Next(256));
     23        jobColors[jobNr] = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256));
    2424        chart.Legends[0].CustomItems.Clear();
    2525        if (jobColors.Count > 1) {
     
    2828            chart.Legends[0].CustomItems.Add(c, "Job#" + (i++));
    2929          }
    30         }   
     30        }
    3131      }
    3232    }
     
    3939    }
    4040
    41     public void AddData(string rowName, int jobNr, double start, double end, string tooltip, bool showLabel = true) {
     41    public void AddData(string rowName, int jobNr, int taskNr, double start, double end, string tooltip, bool showLabel = true) {
    4242      AddRowName(rowName);
    43       var point = new DataPoint(rowNames[rowName], new double[] { start, end });
     43      AddJobColor(jobNr);
     44      JobDataPoint point = new JobDataPoint(rowNames[rowName], new double[] { start, end }, jobNr, taskNr);
    4445      point.Color = jobColors[jobNr];
    4546      point.AxisLabel = rowName;
     
    5657
    5758    void chart_MouseClick(object sender, MouseEventArgs e) {
    58       var pos = e.Location;
    59       var results = chart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);
    60       foreach (DataPoint dp in chart.Series[0].Points) {
    61         Color newColor = Color.FromArgb(255, dp.Color);
    62         dp.Color = newColor;
    63       }
    64       foreach (var result in results) {
    65         if (result.ChartElementType == ChartElementType.DataPoint) {
    66           Color currentColor = chart.Series[0].Points[result.PointIndex].Color;
    67           foreach (DataPoint dp in result.Series.Points) {
    68             if (dp.Color != currentColor) {
    69               Color newColor = Color.FromArgb(0, dp.Color);
    70               dp.Color = newColor;
    71             }
    72           }
     59      Point pos = e.Location;
     60      HitTestResult[] results = chart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);
     61      ResetDataColors();
     62
     63      foreach (HitTestResult result in results) {
     64        if (result.ChartElementType == ChartElementType.DataPoint && result.Object.GetType() == typeof(JobDataPoint)) {
     65          int currentJobNr = (result.Object as JobDataPoint).JobNr;
     66          int currentTaskNr = (result.Object as JobDataPoint).TaskNr;
     67
     68          HighlightTaskAndJob(currentJobNr, currentTaskNr);
    7369        }
    7470      }
    7571    }
     72
     73    public void ResetDataColors() {
     74      foreach (DataPoint dp in chart.Series[0].Points) {
     75        if (dp.GetType() == typeof(JobDataPoint))
     76          dp.Color = jobColors[(dp as JobDataPoint).JobNr];
     77      }
     78    }
     79
     80    public void HighlightTaskAndJob(int jobNr, int taskNr) {
     81      foreach (DataPoint dp in chart.Series[0].Points) {
     82        if (dp.GetType() == typeof(JobDataPoint) && ((dp as JobDataPoint).JobNr == jobNr) && ((dp as JobDataPoint).TaskNr == taskNr)) {
     83          Color newColor = Color.FromArgb(255, dp.Color);
     84          dp.Color = newColor;
     85        } else if (dp.GetType() == typeof(JobDataPoint) && ((dp as JobDataPoint).JobNr == jobNr)) {
     86          Color newColor = Color.FromArgb(180, dp.Color);
     87          dp.Color = newColor;
     88        } else if (dp.GetType() == typeof(JobDataPoint) && !((dp as JobDataPoint).JobNr == jobNr)) {
     89          Color newColor = Color.FromArgb(0, dp.Color);
     90          dp.Color = newColor;
     91        }
     92      }
     93    }
     94
    7695  }
    7796}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.csproj

    r6406 r6482  
    5656      <DependentUpon>GanttChart.cs</DependentUpon>
    5757    </Compile>
     58    <Compile Include="JobDataPoint.cs" />
    5859    <Compile Include="Plugin.cs" />
    5960    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/ScheduleView.Designer.cs

    r6406 r6482  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.ganttChart = new GanttChart();
     47      this.ganttChart = new HeuristicLab.Encodings.ScheduleEncoding.Views.GanttChart();
    4848      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4949      this.SuspendLayout();
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/ScheduleView.cs

    r6412 r6482  
    7272        foreach (ScheduledTask t in content.Resources[resCount].Tasks) {
    7373          int categoryNr = 0;
    74           string toolTip = "Task#";// +t.TaskNr;
     74          string toolTip = "Task#" + t.TaskNr;
    7575          string categoryName = "ScheduleTasks";
    7676          if (t is ScheduledTask) {
     
    7979            toolTip = categoryName + " - " + toolTip;
    8080          }
    81           ganttChart.AddJobColor(categoryNr);
    8281          ganttChart.AddData("Resource" + r.Index,
    8382            categoryNr,
     83            t.TaskNr,
    8484            t.StartTime,
    8585            t.EndTime,
     
    8888        resCount++;
    8989      }
     90    }
     91
     92    private void RefreshChartInformations(Schedule content) {
     93
    9094    }
    9195
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3

    • Property svn:ignore
      •  

        old new  
        11HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj.user
         2Plugin.cs
        23bin
        34obj
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs

    r6475 r6482  
    123123        i++;
    124124
     125      if (!lastScheduledTaskOfJob.ContainsKey(jobNr)) {
     126        lastScheduledTaskOfJob.Add(jobNr, task);
     127        task.TaskNr = 0;
     128      } else {
     129        task.TaskNr = lastScheduledTaskOfJob[jobNr].TaskNr + 1;
     130        lastScheduledTaskOfJob[jobNr] = task;
     131      }
     132
    125133      if (i >= affectedResource.Tasks.Count)
    126134        affectedResource.Tasks.Add(task);
     
    128136        affectedResource.Tasks.Insert(i, task);
    129137
    130       if (!lastScheduledTaskOfJob.ContainsKey(jobNr))
    131         lastScheduledTaskOfJob.Add(jobNr, task);
    132       else
    133         lastScheduledTaskOfJob[jobNr] = task;
    134138    }
    135139
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs

    r6475 r6482  
    3131    #region Properties
    3232    [Storable]
     33    public int TaskNr { get; set; }
     34    [Storable]
    3335    public int ResourceNr { get; set; }
    3436    [Storable]
     
    4951    protected ScheduledTask(ScheduledTask original, Cloner cloner)
    5052      : base(original, cloner) {
     53      this.TaskNr = original.TaskNr;
    5154      this.ResourceNr = original.ResourceNr;
    5255      this.Duration = original.Duration;
     
    8184
    8285    public static bool AreEqual(ScheduledTask task1, ScheduledTask task2) {
    83       return (task1.Duration == task2.Duration &&
     86      return (
     87        task1.TaskNr == task2.TaskNr &&
     88        task1.Duration == task2.Duration &&
    8489        task1.JobNr == task2.JobNr &&
    8590        task1.ResourceNr == task2.ResourceNr &&
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3

    • Property svn:ignore
      •  

        old new  
         1HeuristicLab.Problems.Scheduling.Views-3.3.csproj.user
         2Plugin.cs
        13bin
        24obj
        3 HeuristicLab.Problems.Scheduling.Views-3.3.csproj.user
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r6475 r6482  
    6363          int categoryNr = t.JobNr;
    6464          string categoryName = "Job" + categoryNr;
    65           ganttChart.AddJobColor(categoryNr);
    6665          ganttChart.AddData(categoryName,
    6766            categoryNr,
     67            t.TaskNr,
    6868            lastEndTime + 1,
    6969            lastEndTime + t.Duration,
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3

    • Property svn:ignore
      •  

        old new  
         1HeuristicLab.Problems.Scheduling-3.3.csproj.user
        12Plugin.cs
        23bin
        34obj
        4 HeuristicLab.Problems.Scheduling-3.3.csproj.user
Note: See TracChangeset for help on using the changeset viewer.