Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/03/13 16:46:26 (10 years ago)
Author:
mkommend
Message:

#2016: Added patch from sforsten, that improves the BubbleChart- and BoxPlotView.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r9404 r9435  
    5656    private bool suppressUpdates = false;
    5757
     58    private const double transperencyExponent = 2.5;
     59
     60    private RunCollectionContentConstraint visibilityConstraint = new RunCollectionContentConstraint() { Active = true };
    5861
    5962    public RunCollectionBubbleChartView() {
    6063      InitializeComponent();
    6164
    62       chart.ContextMenuStrip.Items.Insert(0, hideRunToolStripMenuItem);
    63       chart.ContextMenuStrip.Items.Insert(1, openBoxPlotViewToolStripMenuItem);
    64       chart.ContextMenuStrip.Items.Add(getDataAsMatrixToolStripMenuItem);
     65      chart.ContextMenuStrip.Items.Insert(0, openBoxPlotViewToolStripMenuItem);
     66      chart.ContextMenuStrip.Items.Insert(1, getDataAsMatrixToolStripMenuItem);
     67      chart.ContextMenuStrip.Items.Insert(2, new ToolStripSeparator());
     68      chart.ContextMenuStrip.Items.Insert(3, hideRunsToolStripMenuItem);
     69      chart.ContextMenuStrip.Items.Insert(4, unhideAllRunToolStripMenuItem);
     70      chart.ContextMenuStrip.Items.Insert(5, colorResetToolStripMenuItem);
     71      chart.ContextMenuStrip.Items.Insert(6, new ToolStripSeparator());
    6572      chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
    6673
    67       colorDialog.Color = Color.Black;
    68       colorDialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
     74      colorDialog.Color = Color.Orange;
     75      colorRunsButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
    6976      isSelecting = false;
    7077
     
    167174            point.MarkerStyle = MarkerStyle.Cross;
    168175          } else {
    169             point.Color = Color.FromArgb(255 - transparencyTrackBar.Value, ((IRun)point.Tag).Color);
     176            point.Color = Color.FromArgb(255 - LogTransform(transparencyTrackBar.Value), ((IRun)point.Tag).Color);
    170177            point.MarkerStyle = MarkerStyle.Circle;
    171178          }
     
    310317      double sizeRange = maxSizeValue - minSizeValue;
    311318
    312       const int smallestBubbleSize = 5;
     319      const int smallestBubbleSize = 7;
    313320
    314321      foreach (DataPoint point in series.Points) {
     
    331338      var yAxis = this.chart.ChartAreas[0].AxisY;
    332339
    333       SetAutomaticUpdateOfAxis(xAxis, false);
    334       SetAutomaticUpdateOfAxis(yAxis, false);
    335 
    336340      double xAxisRange = xAxis.Maximum - xAxis.Minimum;
    337341      double yAxisRange = yAxis.Maximum - yAxis.Minimum;
     
    351355      }
    352356
     357      if (xJitterFactor.IsAlmost(0.0) && yJitterFactor.IsAlmost(0.0)) {
     358        SetAutomaticUpdateOfAxis(xAxis, true);
     359        SetAutomaticUpdateOfAxis(yAxis, true);
     360        chart.ChartAreas[0].RecalculateAxesScale();
     361      } else {
     362        SetAutomaticUpdateOfAxis(xAxis, false);
     363        SetAutomaticUpdateOfAxis(yAxis, false);
     364      }
    353365    }
    354366
     
    431443      if (!this.categoricalMapping.ContainsKey(dimension)) {
    432444        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());
     445        var orderedCategories = Content.Where(r => r.Visible && Content.GetValue(r, dimension) != null).Select(r => Content.GetValue(r, dimension).ToString())
     446                                    .Distinct().OrderBy(x => x, new NaturalStringComparer());
    436447        int count = 1;
    437448        foreach (var category in orderedCategories) {
     
    535546      double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd);
    536547
     548      if (Control.ModifierKeys != Keys.Control) {
     549        ClearSelectedRuns();
     550      }
     551
    537552      //check for click to select a single model
    538553      if (minX == maxX && minY == maxY) {
     
    545560          point.MarkerStyle = MarkerStyle.Cross;
    546561          selectedRuns.Add(run);
    547 
    548         } else ClearSelectedRuns();
     562        }
    549563      } else {
    550564        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;
     565          if (point.XValue < minX || point.XValue > maxX) continue;
     566          if (point.YValues[0] < minY || point.YValues[0] > maxY) continue;
    553567          point.MarkerStyle = MarkerStyle.Cross;
    554568          point.Color = Color.Red;
     
    688702    private void zoomButton_CheckedChanged(object sender, EventArgs e) {
    689703      this.isSelecting = selectButton.Checked;
     704      this.colorRunsButton.Enabled = this.isSelecting;
    690705      this.colorDialogButton.Enabled = this.isSelecting;
    691       this.colorRunsButton.Enabled = this.isSelecting;
    692706      this.hideRunsButton.Enabled = this.isSelecting;
    693707      this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting;
     
    701715      var chartPos = chart.PointToClient(pos);
    702716
    703       HitTestResult h = this.chart.HitTest(chartPos.X, chartPos.Y);
     717      HitTestResult h = this.chart.HitTest(chartPos.X, chartPos.Y, ChartElementType.DataPoint);
    704718      if (h.ChartElementType == ChartElementType.DataPoint) {
    705719        runToHide = (IRun)((DataPoint)h.Object).Tag;
    706         hideRunToolStripMenuItem.Visible = true;
     720        hideRunsToolStripMenuItem.Visible = true;
    707721      } else {
    708722        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);
     723        hideRunsToolStripMenuItem.Visible = false;
     724      }
     725    }
     726
     727    private void unhideAllRunToolStripMenuItem_Click(object sender, EventArgs e) {
     728      visibilityConstraint.ConstraintData.Clear();
     729      if (Content.Constraints.Contains(visibilityConstraint)) Content.Constraints.Remove(visibilityConstraint);
     730    }
     731    private void hideRunsToolStripMenuItem_Click(object sender, EventArgs e) {
     732      HideRuns(selectedRuns);
     733      //could not use ClearSelectedRuns as the runs are not visible anymore
     734      selectedRuns.Clear();
    721735    }
    722736    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;
     737      HideRuns(selectedRuns);
     738      //could not use ClearSelectedRuns as the runs are not visible anymore
     739      selectedRuns.Clear();
     740    }
     741
     742    private void HideRuns(IEnumerable<IRun> runs) {
     743      visibilityConstraint.Active = false;
     744      if (!Content.Constraints.Contains(visibilityConstraint)) Content.Constraints.Add(visibilityConstraint);
     745      foreach (var run in selectedRuns) {
     746        visibilityConstraint.ConstraintData.Add(run);
     747      }
     748      visibilityConstraint.Active = true;
    729749    }
    730750
     
    800820
    801821    #region coloring
     822    private void colorResetToolStripMenuItem_Click(object sender, EventArgs e) {
     823      Content.UpdateOfRunsInProgress = true;
     824
     825      IEnumerable<IRun> runs;
     826      if (selectedRuns.Any()) runs = selectedRuns;
     827      else runs = Content;
     828
     829      foreach (var run in runs)
     830        run.Color = Color.Black;
     831      ClearSelectedRuns();
     832
     833      Content.UpdateOfRunsInProgress = false;
     834    }
    802835    private void colorDialogButton_Click(object sender, EventArgs e) {
    803836      if (colorDialog.ShowDialog(this) == DialogResult.OK) {
    804         this.colorDialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
     837        this.colorRunsButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
     838        colorRunsButton_Click(sender, e);
    805839      }
    806840    }
Note: See TracChangeset for help on using the changeset viewer.