Changeset 9444 for branches/HivePerformance/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
- Timestamp:
- 05/06/13 12:30:18 (11 years ago)
- Location:
- branches/HivePerformance/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HivePerformance/sources
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 9376,9379,9388,9390,9396,9402-9410,9413,9417,9426-9429,9432-9433,9435-9439,9441-9443
- Property svn:mergeinfo changed
-
branches/HivePerformance/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r9340 r9444 56 56 private bool suppressUpdates = false; 57 57 58 private const double transperencyExponent = 2.5; 59 60 private RunCollectionContentConstraint visibilityConstraint = new RunCollectionContentConstraint() { Active = true }; 58 61 59 62 public RunCollectionBubbleChartView() { 60 63 InitializeComponent(); 61 64 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()); 65 72 chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening); 66 73 67 colorDialog.Color = Color. Black;68 color DialogButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);74 colorDialog.Color = Color.Orange; 75 colorRunsButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color); 69 76 isSelecting = false; 70 77 … … 167 174 point.MarkerStyle = MarkerStyle.Cross; 168 175 } 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); 170 177 point.MarkerStyle = MarkerStyle.Circle; 171 178 } … … 310 317 double sizeRange = maxSizeValue - minSizeValue; 311 318 312 const int smallestBubbleSize = 5;319 const int smallestBubbleSize = 7; 313 320 314 321 foreach (DataPoint point in series.Points) { … … 331 338 var yAxis = this.chart.ChartAreas[0].AxisY; 332 339 333 SetAutomaticUpdateOfAxis(xAxis, false);334 SetAutomaticUpdateOfAxis(yAxis, false);335 336 340 double xAxisRange = xAxis.Maximum - xAxis.Minimum; 337 341 double yAxisRange = yAxis.Maximum - yAxis.Minimum; … … 351 355 } 352 356 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 } 353 365 } 354 366 … … 431 443 if (!this.categoricalMapping.ContainsKey(dimension)) { 432 444 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()); 436 447 int count = 1; 437 448 foreach (var category in orderedCategories) { … … 535 546 double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd); 536 547 548 if (Control.ModifierKeys != Keys.Control) { 549 ClearSelectedRuns(); 550 } 551 537 552 //check for click to select a single model 538 553 if (minX == maxX && minY == maxY) { … … 545 560 point.MarkerStyle = MarkerStyle.Cross; 546 561 selectedRuns.Add(run); 547 548 } else ClearSelectedRuns(); 562 } 549 563 } else { 550 564 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; 553 567 point.MarkerStyle = MarkerStyle.Cross; 554 568 point.Color = Color.Red; … … 688 702 private void zoomButton_CheckedChanged(object sender, EventArgs e) { 689 703 this.isSelecting = selectButton.Checked; 704 this.colorRunsButton.Enabled = this.isSelecting; 690 705 this.colorDialogButton.Enabled = this.isSelecting; 691 this.colorRunsButton.Enabled = this.isSelecting;692 706 this.hideRunsButton.Enabled = this.isSelecting; 693 707 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting; … … 701 715 var chartPos = chart.PointToClient(pos); 702 716 703 HitTestResult h = this.chart.HitTest(chartPos.X, chartPos.Y );717 HitTestResult h = this.chart.HitTest(chartPos.X, chartPos.Y, ChartElementType.DataPoint); 704 718 if (h.ChartElementType == ChartElementType.DataPoint) { 705 719 runToHide = (IRun)((DataPoint)h.Object).Tag; 706 hideRun ToolStripMenuItem.Visible = true;720 hideRunsToolStripMenuItem.Visible = true; 707 721 } else { 708 722 runToHide = null; 709 hideRun ToolStripMenuItem.Visible = false;710 } 711 712 } 713 private void hideRunToolStripMenuItem_Click(object sender, EventArgs e) {714 v ar 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(); 721 735 } 722 736 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; 729 749 } 730 750 … … 733 753 foreach (var point in runToDataPointMapping[run]) { 734 754 point.MarkerStyle = MarkerStyle.Circle; 735 point.Color = Color.FromArgb(255 - transparencyTrackBar.Value, run.Color);755 point.Color = Color.FromArgb(255 - LogTransform(transparencyTrackBar.Value), run.Color); 736 756 } 737 757 } 738 758 selectedRuns.Clear(); 759 } 760 761 // returns a value in [0..255] 762 private int LogTransform(int x) { 763 double min = transparencyTrackBar.Minimum; 764 double max = transparencyTrackBar.Maximum; 765 double r = (x - min) / (max - min); // r \in [0..1] 766 double l = Math.Max(Math.Min((1.0 - Math.Pow(0.05, r)) / 0.95, 1), 0); // l \in [0..1] 767 return (int)Math.Round(255.0 * l); 739 768 } 740 769 … … 791 820 792 821 #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 } 793 835 private void colorDialogButton_Click(object sender, EventArgs e) { 794 836 if (colorDialog.ShowDialog(this) == DialogResult.OK) { 795 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); 796 839 } 797 840 }
Note: See TracChangeset
for help on using the changeset viewer.