Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/13 13:01:40 (11 years ago)
Author:
bburlacu
Message:

#1772: Merged remaining trunk changes into the EvolutionaryTracking branch.

Location:
branches/HeuristicLab.EvolutionaryTracking
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking

  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Optimization.Views

  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r9421 r9835  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    5656    private bool suppressUpdates = false;
    5757
     58    private RunCollectionContentConstraint visibilityConstraint = new RunCollectionContentConstraint() { Active = true };
    5859
    5960    public RunCollectionBubbleChartView() {
    6061      InitializeComponent();
    6162
    62       chart.ContextMenuStrip.Items.Insert(0, hideRunToolStripMenuItem);
    63       chart.ContextMenuStrip.Items.Insert(1, openBoxPlotViewToolStripMenuItem);
    64       chart.ContextMenuStrip.Items.Add(getDataAsMatrixToolStripMenuItem);
     63      chart.ContextMenuStrip.Items.Insert(0, openBoxPlotViewToolStripMenuItem);
     64      chart.ContextMenuStrip.Items.Insert(1, getDataAsMatrixToolStripMenuItem);
     65      chart.ContextMenuStrip.Items.Insert(2, new ToolStripSeparator());
     66      chart.ContextMenuStrip.Items.Insert(3, hideRunsToolStripMenuItem);
     67      chart.ContextMenuStrip.Items.Insert(4, unhideAllRunToolStripMenuItem);
     68      chart.ContextMenuStrip.Items.Insert(5, colorResetToolStripMenuItem);
     69      chart.ContextMenuStrip.Items.Insert(6, new ToolStripSeparator());
    6570      chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
    6671
    67       colorDialog.Color = Color.Black;
    68       colorDialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
     72      colorDialog.Color = Color.Orange;
     73      colorRunsButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
    6974      isSelecting = false;
    7075
     
    167172            point.MarkerStyle = MarkerStyle.Cross;
    168173          } else {
    169             point.Color = Color.FromArgb(255 - transparencyTrackBar.Value, ((IRun)point.Tag).Color);
     174            point.Color = Color.FromArgb(255 - LogTransform(transparencyTrackBar.Value), ((IRun)point.Tag).Color);
    170175            point.MarkerStyle = MarkerStyle.Circle;
    171176          }
     
    310315      double sizeRange = maxSizeValue - minSizeValue;
    311316
    312       const int smallestBubbleSize = 5;
     317      const int smallestBubbleSize = 7;
    313318
    314319      foreach (DataPoint point in series.Points) {
     
    331336      var yAxis = this.chart.ChartAreas[0].AxisY;
    332337
    333       SetAutomaticUpdateOfAxis(xAxis, false);
    334       SetAutomaticUpdateOfAxis(yAxis, false);
    335 
    336338      double xAxisRange = xAxis.Maximum - xAxis.Minimum;
    337339      double yAxisRange = yAxis.Maximum - yAxis.Minimum;
     
    351353      }
    352354
     355      if (xJitterFactor.IsAlmost(0.0) && yJitterFactor.IsAlmost(0.0)) {
     356        SetAutomaticUpdateOfAxis(xAxis, true);
     357        SetAutomaticUpdateOfAxis(yAxis, true);
     358        chart.ChartAreas[0].RecalculateAxesScale();
     359      } else {
     360        SetAutomaticUpdateOfAxis(xAxis, false);
     361        SetAutomaticUpdateOfAxis(yAxis, false);
     362      }
    353363    }
    354364
     
    431441      if (!this.categoricalMapping.ContainsKey(dimension)) {
    432442        this.categoricalMapping[dimension] = new Dictionary<object, double>();
    433         var orderedCategories = Content.Where(r => r.Visible).Select(r => Content.GetValue(r, dimension).ToString())
    434                                     .Distinct()
    435                                     .OrderBy(x => x, new NaturalStringComparer());
     443        var orderedCategories = Content.Where(r => r.Visible && Content.GetValue(r, dimension) != null).Select(r => Content.GetValue(r, dimension).ToString())
     444                                    .Distinct().OrderBy(x => x, new NaturalStringComparer());
    436445        int count = 1;
    437446        foreach (var category in orderedCategories) {
     
    535544      double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd);
    536545
     546      if (Control.ModifierKeys != Keys.Control) {
     547        ClearSelectedRuns();
     548      }
     549
    537550      //check for click to select a single model
    538551      if (minX == maxX && minY == maxY) {
     
    542555          var point = chart.Series[0].Points[pointIndex];
    543556          IRun run = (IRun)point.Tag;
    544           point.Color = Color.Red;
    545           point.MarkerStyle = MarkerStyle.Cross;
    546           selectedRuns.Add(run);
    547 
    548         } else ClearSelectedRuns();
     557          if (selectedRuns.Contains(run)) {
     558            point.MarkerStyle = MarkerStyle.Circle;
     559            point.Color = Color.FromArgb(255 - LogTransform(transparencyTrackBar.Value), run.Color);
     560            selectedRuns.Remove(run);
     561          } else {
     562            point.Color = Color.Red;
     563            point.MarkerStyle = MarkerStyle.Cross;
     564            selectedRuns.Add(run);
     565          }
     566        }
    549567      } else {
    550568        foreach (DataPoint point in this.chart.Series[0].Points) {
    551           if (point.XValue < minX || point.XValue >= maxX) continue;
    552           if (point.YValues[0] < minY || point.YValues[0] >= maxY) continue;
     569          if (point.XValue < minX || point.XValue > maxX) continue;
     570          if (point.YValues[0] < minY || point.YValues[0] > maxY) continue;
    553571          point.MarkerStyle = MarkerStyle.Cross;
    554572          point.Color = Color.Red;
     
    688706    private void zoomButton_CheckedChanged(object sender, EventArgs e) {
    689707      this.isSelecting = selectButton.Checked;
     708      this.colorRunsButton.Enabled = this.isSelecting;
    690709      this.colorDialogButton.Enabled = this.isSelecting;
    691       this.colorRunsButton.Enabled = this.isSelecting;
    692710      this.hideRunsButton.Enabled = this.isSelecting;
    693711      this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting;
     
    696714    }
    697715
    698     private IRun runToHide = null;
    699716    private void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e) {
    700       var pos = Control.MousePosition;
    701       var chartPos = chart.PointToClient(pos);
    702 
    703       HitTestResult h = this.chart.HitTest(chartPos.X, chartPos.Y);
    704       if (h.ChartElementType == ChartElementType.DataPoint) {
    705         runToHide = (IRun)((DataPoint)h.Object).Tag;
    706         hideRunToolStripMenuItem.Visible = true;
    707       } else {
    708         runToHide = null;
    709         hideRunToolStripMenuItem.Visible = false;
    710       }
    711 
    712     }
    713     private void hideRunToolStripMenuItem_Click(object sender, EventArgs e) {
    714       var constraint = Content.Constraints.OfType<RunCollectionContentConstraint>().FirstOrDefault(c => c.Active);
    715       if (constraint == null) {
    716         constraint = new RunCollectionContentConstraint();
    717         Content.Constraints.Add(constraint);
    718         constraint.Active = true;
    719       }
    720       constraint.ConstraintData.Add(runToHide);
     717      hideRunsToolStripMenuItem.Visible = selectedRuns.Any();
     718    }
     719
     720    private void unhideAllRunToolStripMenuItem_Click(object sender, EventArgs e) {
     721      visibilityConstraint.ConstraintData.Clear();
     722      if (Content.Constraints.Contains(visibilityConstraint)) Content.Constraints.Remove(visibilityConstraint);
     723    }
     724    private void hideRunsToolStripMenuItem_Click(object sender, EventArgs e) {
     725      HideRuns(selectedRuns);
     726      //could not use ClearSelectedRuns as the runs are not visible anymore
     727      selectedRuns.Clear();
    721728    }
    722729    private void hideRunsButton_Click(object sender, EventArgs e) {
    723       if (!selectedRuns.Any()) return;
    724       var constraint = new RunCollectionContentConstraint();
    725       constraint.ConstraintData = new ItemSet<IRun>(selectedRuns);
    726       Content.Constraints.Add(constraint);
    727       ClearSelectedRuns();
    728       constraint.Active = true;
     730      HideRuns(selectedRuns);
     731      //could not use ClearSelectedRuns as the runs are not visible anymore
     732      selectedRuns.Clear();
     733    }
     734
     735    private void HideRuns(IEnumerable<IRun> runs) {
     736      visibilityConstraint.Active = false;
     737      if (!Content.Constraints.Contains(visibilityConstraint)) Content.Constraints.Add(visibilityConstraint);
     738      foreach (var run in runs) {
     739        visibilityConstraint.ConstraintData.Add(run);
     740      }
     741      visibilityConstraint.Active = true;
    729742    }
    730743
     
    744757      double max = transparencyTrackBar.Maximum;
    745758      double r = (x - min) / (max - min);  // r \in [0..1]
    746       double l = Math.Log(r + 1) / Math.Log(2.0); // l \in [0..1]
     759      double l = Math.Max(Math.Min((1.0 - Math.Pow(0.05, r)) / 0.95, 1), 0); // l \in [0..1]
    747760      return (int)Math.Round(255.0 * l);
    748761    }
     
    800813
    801814    #region coloring
     815    private void colorResetToolStripMenuItem_Click(object sender, EventArgs e) {
     816      Content.UpdateOfRunsInProgress = true;
     817
     818      IEnumerable<IRun> runs;
     819      if (selectedRuns.Any()) runs = selectedRuns;
     820      else runs = Content;
     821
     822      foreach (var run in runs)
     823        run.Color = Color.Black;
     824      ClearSelectedRuns();
     825
     826      Content.UpdateOfRunsInProgress = false;
     827    }
    802828    private void colorDialogButton_Click(object sender, EventArgs e) {
    803829      if (colorDialog.ShowDialog(this) == DialogResult.OK) {
    804         this.colorDialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
     830        this.colorRunsButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
     831        colorRunsButton_Click(sender, e);
    805832      }
    806833    }
Note: See TracChangeset for help on using the changeset viewer.