Changeset 3428
- Timestamp:
- 04/20/10 00:39:59 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.Designer.cs
r3411 r3428 179 179 this.chart.TabIndex = 16; 180 180 this.chart.Text = "chart1"; 181 this.chart.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chart_MouseUp); 181 182 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 182 183 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r3411 r3428 55 55 this.yJitter = new Dictionary<IRun, double>(); 56 56 this.random = new Random(); 57 this.colorDialog.Color = Color.Black; 58 this.colorButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color); 59 this.isSelecting = false; 57 60 58 61 this.chart.Series[0]["BubbleMaxSize"] = "0"; … … 87 90 Content.Reset += new EventHandler(Content_Reset); 88 91 Content.ColumnNamesChanged += new EventHandler(Content_ColumnNamesChanged); 89 } 92 Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded); 93 Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 94 Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 95 foreach (IRun run in Content) 96 run.Changed += new EventHandler(run_Changed); 97 } 98 90 99 protected override void DeregisterContentEvents() { 91 100 base.DeregisterContentEvents(); 92 101 Content.Reset -= new EventHandler(Content_Reset); 93 102 Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged); 94 } 103 Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded); 104 Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 105 Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 106 foreach (IRun run in Content) 107 run.Changed -= new EventHandler(run_Changed); 108 } 109 110 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 111 foreach (IRun run in e.OldItems) 112 run.Changed -= new EventHandler(run_Changed); 113 foreach (IRun run in e.Items) 114 run.Changed += new EventHandler(run_Changed); 115 } 116 117 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 118 foreach (IRun run in e.OldItems) 119 run.Changed -= new EventHandler(run_Changed); 120 } 121 private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 122 foreach (IRun run in e.Items) 123 run.Changed += new EventHandler(run_Changed); 124 } 125 private void run_Changed(object sender, EventArgs e) { 126 IRun run = (IRun)sender; 127 DataPoint point = this.chart.Series[0].Points.Where(p => p.Tag == run).SingleOrDefault(); 128 if (point != null) { 129 point.Color = run.Color; 130 if (!run.Visible) 131 this.chart.Series[0].Points.Remove(point); 132 } else 133 AddDataPoint(run); 134 } 135 95 136 protected override void OnContentChanged() { 96 137 base.OnContentChanged(); … … 98 139 this.UpdateComboBoxes(); 99 140 } 100 101 141 private void Content_ColumnNamesChanged(object sender, EventArgs e) { 102 142 if (InvokeRequired) … … 128 168 Series series = this.chart.Series[0]; 129 169 series.Points.Clear(); 130 170 foreach (IRun run in this.Content) 171 this.AddDataPoint(run); 172 } 173 private void AddDataPoint(IRun run) { 131 174 double? xValue; 132 175 double? yValue; 133 176 double? sizeValue; 134 for (int row = 0; row < Content.Count; row++) { 135 xValue = GetValue(row, xAxisComboBox.SelectedIndex); 136 yValue = GetValue(row, yAxisComboBox.SelectedIndex); 137 sizeValue = 1.0; 138 if (xValue.HasValue && yValue.HasValue) { 139 if (sizeComboBox.SelectedIndex > 0) 140 sizeValue = GetValue(row, sizeComboBox.SelectedIndex-1); 141 xValue = xValue.Value + xValue.Value * GetXJitter(Content.ElementAt(row)) * xJitterFactor; 142 yValue = yValue.Value + yValue.Value * GetYJitter(Content.ElementAt(row)) * yJitterFactor; 177 Series series = this.chart.Series[0]; 178 int row = this.Content.ToList().IndexOf(run); 179 xValue = GetValue(row, xAxisComboBox.SelectedIndex); 180 yValue = GetValue(row, yAxisComboBox.SelectedIndex); 181 sizeValue = 1.0; 182 if (xValue.HasValue && yValue.HasValue) { 183 if (sizeComboBox.SelectedIndex > 0) 184 sizeValue = GetValue(row, sizeComboBox.SelectedIndex - 1); 185 xValue = xValue.Value + xValue.Value * GetXJitter(Content.ElementAt(row)) * xJitterFactor; 186 yValue = yValue.Value + yValue.Value * GetYJitter(Content.ElementAt(row)) * yJitterFactor; 187 if (run.Visible) { 143 188 DataPoint point = new DataPoint(xValue.Value, new double[] { yValue.Value, sizeValue.Value }); 144 189 point.ToolTip = this.CreateTooltip(row); 145 point.Tag = this.Content.ElementAt(row); 190 point.Tag = run; 191 point.Color = run.Color; 146 192 series.Points.Add(point); 147 193 } … … 180 226 HitTestResult h = this.chart.HitTest(e.X, e.Y); 181 227 if (h.ChartElementType == ChartElementType.DataPoint) { 182 this.draggedRun = (IRun)((DataPoint)h.Object).Tag; 183 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = false; 184 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = false; 185 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = false; 186 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = false; 228 IRun run =(IRun)((DataPoint)h.Object).Tag; 229 if (e.Clicks >= 2) { 230 IContentView view = MainFormManager.CreateDefaultView(run); 231 view.ReadOnly = this.ReadOnly; 232 view.Locked = this.Locked; 233 view.Show(); 234 } else { 235 this.draggedRun = run; 236 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = false; 237 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = false; 238 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = false; 239 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = false; 240 } 241 } 242 } 243 244 private void chart_MouseUp(object sender, MouseEventArgs e) { 245 if (isDragOperationInProgress) { 246 this.isDragOperationInProgress = false; 247 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting; 248 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = !isSelecting; 249 this.chart.ChartAreas[0].CursorX.SetSelectionPosition(0, 0); 250 this.chart.ChartAreas[0].CursorY.SetSelectionPosition(0, 0); 251 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; 252 this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; 253 return; 254 } 255 if (!isSelecting) return; 256 System.Windows.Forms.DataVisualization.Charting.Cursor xCursor = chart.ChartAreas[0].CursorX; 257 System.Windows.Forms.DataVisualization.Charting.Cursor yCursor = chart.ChartAreas[0].CursorY; 258 259 double minX = Math.Min(xCursor.SelectionStart, xCursor.SelectionEnd); 260 double maxX = Math.Max(xCursor.SelectionStart, xCursor.SelectionEnd); 261 double minY = Math.Min(yCursor.SelectionStart, yCursor.SelectionEnd); 262 double maxY = Math.Max(yCursor.SelectionStart, yCursor.SelectionEnd); 263 264 //check for click to select model 265 if (minX == maxX && minY == maxY) { 266 HitTestResult hitTest = chart.HitTest(e.X, e.Y); 267 if (hitTest.ChartElementType == ChartElementType.DataPoint) { 268 int pointIndex = hitTest.PointIndex; 269 IRun run = (IRun)this.chart.Series[0].Points[pointIndex].Tag; 270 run.Color = colorDialog.Color; 271 } 272 } else { 273 List<DataPoint> selectedPoints = new List<DataPoint>(); 274 foreach (DataPoint p in this.chart.Series[0].Points) { 275 if (p.XValue >= minX && p.XValue < maxX && 276 p.YValues[0] >= minY && p.YValues[0] < maxY) { 277 selectedPoints.Add(p); 278 } 279 } 280 foreach (DataPoint p in selectedPoints) { 281 IRun run = (IRun)p.Tag; 282 run.Color = colorDialog.Color; 283 } 284 xCursor.SetSelectionPosition(0, 0); 285 yCursor.SetSelectionPosition(0, 0); 187 286 } 188 287 } -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IRun.cs
r3376 r3428 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using System.Drawing; 26 using System; 25 27 26 28 namespace HeuristicLab.Optimization { … … 32 34 IDictionary<string, IItem> Parameters { get; } 33 35 IDictionary<string, IItem> Results { get; } 36 37 Color Color {get;set;} 38 bool Visible { get; set; } 39 event EventHandler Changed; 34 40 } 35 41 } -
trunk/sources/HeuristicLab.Optimization/3.3/Run.cs
r3376 r3428 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Drawing; 27 28 28 29 namespace HeuristicLab.Optimization { … … 47 48 public IDictionary<string, IItem> Results { 48 49 get { return results; } 50 } 51 52 private Color color = Color.Black; 53 public Color Color { 54 get { return this.color; } 55 set { 56 if (color != value) { 57 this.color = value; 58 this.OnChanged(); 59 } 60 } 61 } 62 private bool visible = true; 63 public bool Visible { 64 get { return this.visible; } 65 set { 66 if (visible != value) { 67 this.visible = value; 68 this.OnChanged(); 69 } 70 } 71 } 72 public event EventHandler Changed; 73 private void OnChanged() { 74 EventHandler handler = Changed; 75 if (handler != null) 76 handler(this, EventArgs.Empty); 49 77 } 50 78
Note: See TracChangeset
for help on using the changeset viewer.