- Timestamp:
- 07/26/12 09:51:13 (12 years ago)
- Location:
- branches/ScatterSearch (trunk integration)
- Files:
-
- 7 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesControl.cs
r7259 r8331 26 26 27 27 namespace HeuristicLab.Analysis.Views { 28 [View("Data RowVisual Properties")]28 [View("DataTable Visual Properties")] 29 29 public partial class DataTableVisualPropertiesControl : UserControl { 30 30 protected bool SuppressEvents { get; set; } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Analysis.Views/3.3/HeuristicLab.Analysis.Views-3.3.csproj
r8086 r8331 122 122 <DependentUpon>ScatterPlotView.cs</DependentUpon> 123 123 </Compile> 124 <Compile Include="ScatterPlotHistoryView.cs"> 125 <SubType>UserControl</SubType> 126 </Compile> 127 <Compile Include="ScatterPlotHistoryView.Designer.cs"> 128 <DependentUpon>ScatterPlotHistoryView.cs</DependentUpon> 129 </Compile> 124 130 <None Include="Plugin.cs.frame" /> 125 131 <Compile Include="AlleleFrequencyCollectionView.cs"> -
branches/ScatterSearch (trunk integration)/HeuristicLab.Analysis.Views/3.3/Plugin.cs.frame
r7259 r8331 26 26 /// Plugin class for HeuristicLab.Analysis.Views plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Analysis.Views", "3.3. 6.$WCREV$")]28 [Plugin("HeuristicLab.Analysis.Views", "3.3.7.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Analysis.Views-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/ScatterSearch (trunk integration)/HeuristicLab.Analysis.Views/3.3/Properties/AssemblyInfo.cs.frame
r7259 r8331 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3. 6.$WCREV$")]56 [assembly: AssemblyFileVersion("3.3.7.$WCREV$")] -
branches/ScatterSearch (trunk integration)/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.Designer.cs
r8086 r8331 1 #region License Information1 #region License Information 2 2 /* HeuristicLab 3 3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 22 22 namespace HeuristicLab.Analysis.Views { 23 23 partial class ScatterPlotView { 24 /// <summary> 24 /// <summary> 25 25 /// Required designer variable. 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 28 29 /// <summary> 29 /// <summary> 30 30 /// Clean up any resources being used. 31 31 /// </summary> 32 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 33 protected override void Dispose(bool disposing) { 34 if (disposing && (components != null)) {35 components.Dispose();34 if (disposing) { 35 if (components != null) components.Dispose(); 36 36 } 37 37 base.Dispose(disposing); 38 38 } 39 39 40 #region Windows FormDesigner generated code40 #region Component Designer generated code 41 41 42 /// <summary> 43 /// Required method for Designer support - do not modify 42 /// <summary> 43 /// Required method for Designer support - do not modify 44 44 /// the contents of this method with the code editor. 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 47 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 48 System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); 48 49 System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); 49 50 System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title(); … … 57 58 this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 58 59 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 59 this.nameTextBox.Size = new System.Drawing.Size(596, 20); 60 this.nameTextBox.Location = new System.Drawing.Point(55, 0); 61 this.nameTextBox.Size = new System.Drawing.Size(279, 20); 62 // 63 // infoLabel 64 // 65 this.infoLabel.Location = new System.Drawing.Point(340, 3); 60 66 // 61 67 // chart 62 68 // 63 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 64 | System.Windows.Forms.AnchorStyles.Left) 65 | System.Windows.Forms.AnchorStyles.Right))); 66 chartArea1.Name = "ChartArea1"; 69 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 70 | System.Windows.Forms.AnchorStyles.Left) 71 | System.Windows.Forms.AnchorStyles.Right))); 72 this.chart.BorderlineColor = System.Drawing.Color.Black; 73 this.chart.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid; 74 chartArea1.AxisX.Minimum = 0D; 75 chartArea1.CursorX.IsUserEnabled = true; 76 chartArea1.CursorX.IsUserSelectionEnabled = true; 77 chartArea1.CursorY.IsUserEnabled = true; 78 chartArea1.CursorY.IsUserSelectionEnabled = true; 79 chartArea1.Name = "Default"; 67 80 this.chart.ChartAreas.Add(chartArea1); 81 legend1.Alignment = System.Drawing.StringAlignment.Center; 82 legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top; 83 legend1.Name = "Default"; 84 this.chart.Legends.Add(legend1); 68 85 this.chart.Location = new System.Drawing.Point(0, 26); 69 86 this.chart.Name = "chart"; 70 series1.ChartArea = "ChartArea1"; 71 series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint; 72 series1.EmptyPointStyle.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.LeftRight; 73 series1.MarkerSize = 3; 74 series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; 75 series1.Name = "Series1"; 87 series1.ChartArea = "Default"; 88 series1.Legend = "Default"; 89 series1.Name = "Default"; 76 90 this.chart.Series.Add(series1); 77 this.chart.Size = new System.Drawing.Size(668, 378); 78 this.chart.TabIndex = 5; 79 title1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 80 title1.Name = "Title1"; 81 title1.Text = "Scatter Plot"; 91 this.chart.Size = new System.Drawing.Size(359, 248); 92 this.chart.TabIndex = 3; 93 this.chart.Text = "chart"; 94 title1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 95 title1.Name = "Default"; 96 title1.Text = "Title"; 82 97 this.chart.Titles.Add(title1); 98 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); 99 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 100 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 83 101 // 84 102 // ScatterPlotView 85 103 // 86 this.AllowDrop = true;87 104 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 105 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 88 106 this.Controls.Add(this.chart); 89 107 this.Name = "ScatterPlotView"; 90 this.Size = new System.Drawing.Size( 668, 404);108 this.Size = new System.Drawing.Size(359, 274); 91 109 this.Controls.SetChildIndex(this.infoLabel, 0); 92 110 this.Controls.SetChildIndex(this.chart, 0); … … 102 120 #endregion 103 121 104 private HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart; 122 protected HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart; 123 105 124 } 106 125 } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.cs
r8086 r8331 1 #region License Information1 #region License Information 2 2 /* HeuristicLab 3 3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 25 using System.Linq; 24 26 using System.Windows.Forms; 27 using System.Windows.Forms.DataVisualization.Charting; 25 28 using HeuristicLab.Collections; 29 using HeuristicLab.Common; 26 30 using HeuristicLab.Core.Views; 27 31 using HeuristicLab.MainForm; … … 30 34 [View("ScatterPlot View")] 31 35 [Content(typeof(ScatterPlot), true)] 32 public partial class ScatterPlotView : NamedItemView { 36 public partial class ScatterPlotView : NamedItemView, IConfigureableView { 37 protected List<Series> invisibleSeries; 38 protected Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow> pointsRowsTable; 39 33 40 public new ScatterPlot Content { 34 41 get { return (ScatterPlot)base.Content; } … … 38 45 public ScatterPlotView() { 39 46 InitializeComponent(); 47 pointsRowsTable = new Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow>(); 48 invisibleSeries = new List<Series>(); 40 49 chart.CustomizeAllChartAreas(); 41 } 42 50 chart.ChartAreas[0].CursorX.Interval = 1; 51 } 52 53 #region Event Handler Registration 43 54 protected override void DeregisterContentEvents() { 44 Content.Points.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 45 Content.Points.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 46 Content.Points.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 47 Content.Points.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 48 Content.AxisNameChanged -= new EventHandler(Content_AxisNameChanged); 55 foreach (ScatterPlotDataRow row in Content.Rows) 56 DeregisterScatterPlotDataRowEvents(row); 57 Content.VisualPropertiesChanged -= new EventHandler(Content_VisualPropertiesChanged); 58 Content.Rows.ItemsAdded -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded); 59 Content.Rows.ItemsRemoved -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsRemoved); 60 Content.Rows.ItemsReplaced -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsReplaced); 61 Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset); 49 62 base.DeregisterContentEvents(); 50 63 } 51 52 64 protected override void RegisterContentEvents() { 53 65 base.RegisterContentEvents(); 54 Content.Points.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 55 Content.Points.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 56 Content.Points.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 57 Content.Points.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<PointF>>(Content_Points_Changed); 58 Content.AxisNameChanged += new EventHandler(Content_AxisNameChanged); 59 } 60 61 private void Content_Points_Changed(object sender, CollectionItemsChangedEventArgs<IndexedItem<PointF>> e) { 62 RedrawChart(); 63 } 66 Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged); 67 Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded); 68 Content.Rows.ItemsRemoved += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsRemoved); 69 Content.Rows.ItemsReplaced += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsReplaced); 70 Content.Rows.CollectionReset += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset); 71 } 72 73 protected virtual void RegisterScatterPlotDataRowEvents(ScatterPlotDataRow row) { 74 row.NameChanged += new EventHandler(Row_NameChanged); 75 row.VisualPropertiesChanged += new EventHandler(Row_VisualPropertiesChanged); 76 pointsRowsTable.Add(row.Points, row); 77 row.Points.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsAdded); 78 row.Points.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsRemoved); 79 row.Points.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsReplaced); 80 row.Points.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_CollectionReset); 81 } 82 protected virtual void DeregisterScatterPlotDataRowEvents(ScatterPlotDataRow row) { 83 row.Points.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsAdded); 84 row.Points.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsRemoved); 85 row.Points.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsReplaced); 86 row.Points.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_CollectionReset); 87 pointsRowsTable.Remove(row.Points); 88 row.VisualPropertiesChanged -= new EventHandler(Row_VisualPropertiesChanged); 89 row.NameChanged -= new EventHandler(Row_NameChanged); 90 } 91 #endregion 64 92 65 93 protected override void OnContentChanged() { 66 94 base.OnContentChanged(); 95 invisibleSeries.Clear(); 96 chart.Titles[0].Text = string.Empty; 97 chart.ChartAreas[0].AxisX.Title = string.Empty; 98 chart.ChartAreas[0].AxisY.Title = string.Empty; 99 chart.Series.Clear(); 67 100 if (Content != null) { 68 ConfigureChart(); 69 RedrawChart(); 101 chart.Titles[0].Text = Content.Name; 102 AddScatterPlotDataRows(Content.Rows); 103 ConfigureChartArea(chart.ChartAreas[0]); 104 RecalculateAxesScale(chart.ChartAreas[0]); 105 } 106 } 107 108 protected override void SetEnabledStateOfControls() { 109 base.SetEnabledStateOfControls(); 110 chart.Enabled = Content != null; 111 } 112 113 public void ShowConfiguration() { 114 //if (Content != null) { 115 // using (ScatterPlotVisualPropertiesDialog dialog = new ScatterPlotVisualPropertiesDialog(Content)) { 116 // dialog.ShowDialog(this); 117 // } 118 //} else MessageBox.Show("Nothing to configure."); 119 } 120 protected virtual void AddScatterPlotDataRows(IEnumerable<ScatterPlotDataRow> rows) { 121 foreach (var row in rows) { 122 RegisterScatterPlotDataRowEvents(row); 123 Series series = new Series(row.Name); 124 if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName; 125 else series.LegendText = row.Name; 126 ConfigureSeries(series, row); 127 FillSeriesWithRowValues(series, row); 128 chart.Series.Add(series); 129 } 130 ConfigureChartArea(chart.ChartAreas[0]); 131 RecalculateAxesScale(chart.ChartAreas[0]); 132 UpdateYCursorInterval(); 133 } 134 135 protected virtual void RemoveScatterPlotDataRows(IEnumerable<ScatterPlotDataRow> rows) { 136 foreach (var row in rows) { 137 DeregisterScatterPlotDataRowEvents(row); 138 Series series = chart.Series[row.Name]; 139 chart.Series.Remove(series); 140 if (invisibleSeries.Contains(series)) 141 invisibleSeries.Remove(series); 142 } 143 RecalculateAxesScale(chart.ChartAreas[0]); 144 } 145 146 private void ConfigureSeries(Series series, ScatterPlotDataRow row) { 147 series.BorderWidth = 1; 148 series.BorderDashStyle = ChartDashStyle.Solid; 149 series.BorderColor = Color.Empty; 150 151 if (row.VisualProperties.Color != Color.Empty) 152 series.Color = row.VisualProperties.Color; 153 else series.Color = Color.Empty; 154 series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend; 155 series.ChartType = SeriesChartType.FastPoint; 156 series.MarkerSize = row.VisualProperties.PointSize; 157 series.MarkerStyle = ConvertPointStyle(row.VisualProperties.PointStyle); 158 series.XAxisType = AxisType.Primary; 159 series.YAxisType = AxisType.Primary; 160 161 if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName; 162 else series.LegendText = row.Name; 163 164 string xAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.XAxisTitle) 165 ? "X" 166 : Content.VisualProperties.XAxisTitle; 167 string yAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.YAxisTitle) 168 ? "Y" 169 : Content.VisualProperties.YAxisTitle; 170 series.ToolTip = 171 series.LegendText + Environment.NewLine + 172 xAxisTitle + " = " + "#VALX," + Environment.NewLine + 173 yAxisTitle + " = " + "#VAL"; 174 } 175 176 private void ConfigureChartArea(ChartArea area) { 177 if (Content.VisualProperties.TitleFont != null) chart.Titles[0].Font = Content.VisualProperties.TitleFont; 178 if (!Content.VisualProperties.TitleColor.IsEmpty) chart.Titles[0].ForeColor = Content.VisualProperties.TitleColor; 179 chart.Titles[0].Text = Content.VisualProperties.Title; 180 181 if (Content.VisualProperties.AxisTitleFont != null) area.AxisX.TitleFont = Content.VisualProperties.AxisTitleFont; 182 if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisX.TitleForeColor = Content.VisualProperties.AxisTitleColor; 183 area.AxisX.Title = Content.VisualProperties.XAxisTitle; 184 area.AxisX.MajorGrid.Enabled = Content.VisualProperties.XAxisGrid; 185 186 if (Content.VisualProperties.AxisTitleFont != null) area.AxisY.TitleFont = Content.VisualProperties.AxisTitleFont; 187 if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisY.TitleForeColor = Content.VisualProperties.AxisTitleColor; 188 area.AxisY.Title = Content.VisualProperties.YAxisTitle; 189 area.AxisY.MajorGrid.Enabled = Content.VisualProperties.YAxisGrid; 190 } 191 192 private void RecalculateAxesScale(ChartArea area) { 193 // Reset the axes bounds so that RecalculateAxesScale() will assign new bounds 194 foreach (Axis a in area.Axes) { 195 a.Minimum = double.NaN; 196 a.Maximum = double.NaN; 197 } 198 area.RecalculateAxesScale(); 199 area.AxisX.IsMarginVisible = false; 200 201 if (!Content.VisualProperties.XAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue)) area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue; 202 if (!Content.VisualProperties.XAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue)) area.AxisX.Maximum = Content.VisualProperties.XAxisMaximumFixedValue; 203 if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue; 204 if (!Content.VisualProperties.YAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.YAxisMaximumFixedValue)) area.AxisY.Maximum = Content.VisualProperties.YAxisMaximumFixedValue; 205 if (area.AxisX.Minimum >= area.AxisX.Maximum) area.AxisX.Maximum = area.AxisX.Minimum + 1; 206 if (area.AxisY.Minimum >= area.AxisY.Maximum) area.AxisY.Maximum = area.AxisY.Minimum + 1; 207 } 208 209 protected virtual void UpdateYCursorInterval() { 210 double interestingValuesRange = ( 211 from series in chart.Series 212 where series.Enabled 213 let values = (from point in series.Points 214 where !point.IsEmpty 215 select point.YValues[0]).DefaultIfEmpty(1.0) 216 let range = values.Max() - values.Min() 217 where range > 0.0 218 select range 219 ).DefaultIfEmpty(1.0).Min(); 220 221 double digits = (int)Math.Log10(interestingValuesRange) - 3; 222 double yZoomInterval = Math.Pow(10, digits); 223 this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval; 224 } 225 226 #region Event Handlers 227 #region Content Event Handlers 228 protected override void Content_NameChanged(object sender, EventArgs e) { 229 if (InvokeRequired) 230 Invoke(new EventHandler(Content_NameChanged), sender, e); 231 else { 232 chart.Titles[0].Text = Content.Name; 233 base.Content_NameChanged(sender, e); 234 } 235 } 236 private void Content_VisualPropertiesChanged(object sender, EventArgs e) { 237 if (InvokeRequired) 238 Invoke(new EventHandler(Content_VisualPropertiesChanged), sender, e); 239 else { 240 ConfigureChartArea(chart.ChartAreas[0]); 241 RecalculateAxesScale(chart.ChartAreas[0]); // axes min/max could have changed 242 } 243 } 244 #endregion 245 #region Rows Event Handlers 246 private void Rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) { 247 if (InvokeRequired) 248 Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded), sender, e); 249 else { 250 AddScatterPlotDataRows(e.Items); 251 } 252 } 253 private void Rows_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) { 254 if (InvokeRequired) 255 Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsRemoved), sender, e); 256 else { 257 RemoveScatterPlotDataRows(e.Items); 258 } 259 } 260 private void Rows_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) { 261 if (InvokeRequired) 262 Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsReplaced), sender, e); 263 else { 264 RemoveScatterPlotDataRows(e.OldItems); 265 AddScatterPlotDataRows(e.Items); 266 } 267 } 268 private void Rows_CollectionReset(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) { 269 if (InvokeRequired) 270 Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset), sender, e); 271 else { 272 RemoveScatterPlotDataRows(e.OldItems); 273 AddScatterPlotDataRows(e.Items); 274 } 275 } 276 #endregion 277 #region Row Event Handlers 278 private void Row_VisualPropertiesChanged(object sender, EventArgs e) { 279 if (InvokeRequired) 280 Invoke(new EventHandler(Row_VisualPropertiesChanged), sender, e); 281 else { 282 ScatterPlotDataRow row = (ScatterPlotDataRow)sender; 283 Series series = chart.Series[row.Name]; 284 series.Points.Clear(); 285 ConfigureSeries(series, row); 286 FillSeriesWithRowValues(series, row); 287 RecalculateAxesScale(chart.ChartAreas[0]); 288 } 289 } 290 private void Row_NameChanged(object sender, EventArgs e) { 291 if (InvokeRequired) 292 Invoke(new EventHandler(Row_NameChanged), sender, e); 293 else { 294 ScatterPlotDataRow row = (ScatterPlotDataRow)sender; 295 chart.Series[row.Name].Name = row.Name; 296 } 297 } 298 #endregion 299 #region Points Event Handlers 300 private void Points_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) { 301 if (InvokeRequired) 302 Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsAdded), sender, e); 303 else { 304 ScatterPlotDataRow row = null; 305 pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row); 306 if (row != null) { 307 Series rowSeries = chart.Series[row.Name]; 308 if (!invisibleSeries.Contains(rowSeries)) { 309 rowSeries.Points.Clear(); 310 FillSeriesWithRowValues(rowSeries, row); 311 RecalculateAxesScale(chart.ChartAreas[0]); 312 UpdateYCursorInterval(); 313 } 314 } 315 } 316 } 317 private void Points_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) { 318 if (InvokeRequired) 319 Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsRemoved), sender, e); 320 else { 321 ScatterPlotDataRow row = null; 322 pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row); 323 if (row != null) { 324 Series rowSeries = chart.Series[row.Name]; 325 if (!invisibleSeries.Contains(rowSeries)) { 326 rowSeries.Points.Clear(); 327 FillSeriesWithRowValues(rowSeries, row); 328 RecalculateAxesScale(chart.ChartAreas[0]); 329 UpdateYCursorInterval(); 330 } 331 } 332 } 333 } 334 private void Points_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) { 335 if (InvokeRequired) 336 Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsReplaced), sender, e); 337 else { 338 ScatterPlotDataRow row = null; 339 pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row); 340 if (row != null) { 341 Series rowSeries = chart.Series[row.Name]; 342 if (!invisibleSeries.Contains(rowSeries)) { 343 rowSeries.Points.Clear(); 344 FillSeriesWithRowValues(rowSeries, row); 345 RecalculateAxesScale(chart.ChartAreas[0]); 346 UpdateYCursorInterval(); 347 } 348 } 349 } 350 } 351 private void Points_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) { 352 if (InvokeRequired) 353 Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_CollectionReset), sender, e); 354 else { 355 ScatterPlotDataRow row = null; 356 pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row); 357 if (row != null) { 358 Series rowSeries = chart.Series[row.Name]; 359 if (!invisibleSeries.Contains(rowSeries)) { 360 rowSeries.Points.Clear(); 361 FillSeriesWithRowValues(rowSeries, row); 362 RecalculateAxesScale(chart.ChartAreas[0]); 363 UpdateYCursorInterval(); 364 } 365 } 366 } 367 } 368 #endregion 369 #endregion 370 371 #region Chart Event Handlers 372 private void chart_MouseDown(object sender, MouseEventArgs e) { 373 HitTestResult result = chart.HitTest(e.X, e.Y); 374 if (result.ChartElementType == ChartElementType.LegendItem) { 375 ToggleSeriesVisible(result.Series); 376 } 377 } 378 private void chart_MouseMove(object sender, MouseEventArgs e) { 379 HitTestResult result = chart.HitTest(e.X, e.Y); 380 if (result.ChartElementType == ChartElementType.LegendItem) 381 this.Cursor = Cursors.Hand; 382 else 383 this.Cursor = Cursors.Default; 384 } 385 private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) { 386 foreach (LegendItem legendItem in e.LegendItems) { 387 var series = chart.Series[legendItem.SeriesName]; 388 if (series != null) { 389 bool seriesIsInvisible = invisibleSeries.Contains(series); 390 foreach (LegendCell cell in legendItem.Cells) { 391 cell.ForeColor = seriesIsInvisible ? Color.Gray : Color.Black; 392 } 393 } 394 } 395 } 396 #endregion 397 398 private void ToggleSeriesVisible(Series series) { 399 if (!invisibleSeries.Contains(series)) { 400 series.Points.Clear(); 401 invisibleSeries.Add(series); 70 402 } else { 71 ClearChart(); 72 } 73 } 74 75 private void Content_AxisNameChanged(object sender, EventArgs e) { 76 ConfigureChart(); 77 } 78 79 private void ConfigureChart() { 80 if (InvokeRequired) { 81 Invoke((Action)ConfigureChart); 82 } else { 83 chart.ChartAreas[0].AxisX.Title = Content.XAxisName; 84 chart.ChartAreas[0].AxisY.Title = Content.YAxisName; 85 chart.Titles[0].Text = Content.Name; 86 } 87 } 88 89 private void ClearChart() { 90 if (InvokeRequired) { 91 Invoke((Action)ClearChart); 92 } else { 93 chart.Series[0].Points.Clear(); 94 chart.ChartAreas[0].AxisX.Title = String.Empty; 95 chart.ChartAreas[0].AxisY.Title = String.Empty; 96 chart.Titles[0].Text = String.Empty; 97 } 98 } 99 100 private void RedrawChart() { 101 if (InvokeRequired) { 102 Invoke((Action)RedrawChart); 103 } else { 104 chart.Series[0].Points.SuspendUpdates(); 105 chart.Series[0].Points.Clear(); 106 foreach (var p in Content.Points.ToArray()) { 107 chart.Series[0].Points.AddXY(p.X, p.Y); 108 } 109 chart.Series[0].Points.ResumeUpdates(); 110 } 111 } 403 invisibleSeries.Remove(series); 404 if (Content != null) { 405 406 var row = (from r in Content.Rows 407 where r.Name == series.Name 408 select r).Single(); 409 FillSeriesWithRowValues(series, row); 410 this.chart.Legends[series.Legend].ForeColor = Color.Black; 411 RecalculateAxesScale(chart.ChartAreas[0]); 412 UpdateYCursorInterval(); 413 } 414 } 415 } 416 417 private void FillSeriesWithRowValues(Series series, ScatterPlotDataRow row) { 418 for (int i = 0; i < row.Points.Count; i++) { 419 var value = row.Points[i]; 420 DataPoint point = new DataPoint(); 421 if (IsInvalidValue(value.X) || IsInvalidValue(value.Y)) 422 point.IsEmpty = true; 423 else { 424 point.XValue = value.X; 425 point.YValues = new double[] { value.Y }; 426 } 427 series.Points.Add(point); 428 } 429 } 430 431 #region Helpers 432 public static IEnumerable<double> DoubleRange(double min, double max, double step) { 433 double i; 434 for (i = min; i <= max; i += step) 435 yield return i; 436 437 if (i != max + step) 438 yield return i; 439 } 440 441 private double HumanRoundRange(double range) { 442 double base10 = Math.Pow(10.0, Math.Floor(Math.Log10(range))); 443 double rounding = range / base10; 444 if (rounding <= 1.5) rounding = 1; 445 else if (rounding <= 2.25) rounding = 2; 446 else if (rounding <= 3.75) rounding = 2.5; 447 else if (rounding <= 7.5) rounding = 5; 448 else rounding = 10; 449 return rounding * base10; 450 } 451 452 private double HumanRoundMax(double max) { 453 double base10; 454 if (max > 0) base10 = Math.Pow(10.0, Math.Floor(Math.Log10(max))); 455 else base10 = Math.Pow(10.0, Math.Ceiling(Math.Log10(-max))); 456 double rounding = (max > 0) ? base10 : -base10; 457 while (rounding < max) rounding += base10; 458 return rounding; 459 } 460 461 private MarkerStyle ConvertPointStyle(ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle pointStyle) { 462 switch (pointStyle) { 463 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle: 464 return MarkerStyle.Circle; 465 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Cross: 466 return MarkerStyle.Cross; 467 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Diamond: 468 return MarkerStyle.Diamond; 469 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Square: 470 return MarkerStyle.Square; 471 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star4: 472 return MarkerStyle.Star4; 473 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star5: 474 return MarkerStyle.Star5; 475 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star6: 476 return MarkerStyle.Star6; 477 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star10: 478 return MarkerStyle.Star10; 479 case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Triangle: 480 return MarkerStyle.Triangle; 481 default: 482 return MarkerStyle.None; 483 } 484 } 485 486 protected static bool IsInvalidValue(double x) { 487 return double.IsNaN(x) || x < (double)decimal.MinValue || x > (double)decimal.MaxValue; 488 } 489 #endregion 112 490 } 113 491 }
Note: See TracChangeset
for help on using the changeset viewer.