From cc531c79f2bd664551071ef315a54814bd9ab914 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 12 Aug 2020 19:22:21 -0700 Subject: Reorganized solution into directories --- grapher/Models/Charts/AccelCharts.cs | 117 +++++++++++++++++++++++++++++ grapher/Models/Charts/ChartXY.cs | 142 +++++++++++++++++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 grapher/Models/Charts/AccelCharts.cs create mode 100644 grapher/Models/Charts/ChartXY.cs (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs new file mode 100644 index 0000000..9952016 --- /dev/null +++ b/grapher/Models/Charts/AccelCharts.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; + +namespace grapher +{ + public class AccelCharts + { + public const int ChartSeparationVertical = 10; + + /// Needed to show full contents in form. Unsure why. + public const int FormHeightPadding = 35; + + public AccelCharts( + Form form, + ChartXY sensitivityChart, + ChartXY velocityChart, + ChartXY gainChart, + ToolStripMenuItem enableVelocityAndGain) + { + ContaingForm = form; + SensitivityChart = sensitivityChart; + VelocityChart = velocityChart; + GainChart = gainChart; + EnableVelocityAndGain = enableVelocityAndGain; + + SensitivityChart.SetTop(0); + VelocityChart.SetHeight(SensitivityChart.Height); + VelocityChart.SetTop(SensitivityChart.Height + ChartSeparationVertical); + GainChart.SetHeight(SensitivityChart.Height); + GainChart.SetTop(VelocityChart.Top + VelocityChart.Height + ChartSeparationVertical); + + Rectangle screenRectangle = ContaingForm.RectangleToScreen(ContaingForm.ClientRectangle); + FormBorderHeight = screenRectangle.Top - ContaingForm.Top; + + EnableVelocityAndGain.Click += new System.EventHandler(OnEnableClick); + EnableVelocityAndGain.CheckedChanged += new System.EventHandler(OnEnableCheckStateChange); + + HideVelocityAndGain(); + ShowCombined(); + } + + public Form ContaingForm { get; } + + public ChartXY SensitivityChart { get; } + + public ChartXY VelocityChart { get; } + + public ChartXY GainChart { get; } + + public ToolStripMenuItem EnableVelocityAndGain { get; } + + private int FormBorderHeight { get; } + + private void OnEnableClick(object sender, EventArgs e) + { + EnableVelocityAndGain.Checked = !EnableVelocityAndGain.Checked; + } + + private void OnEnableCheckStateChange(object sender, EventArgs e) + { + if (EnableVelocityAndGain.Checked) + { + ShowVelocityAndGain(); + } + else + { + HideVelocityAndGain(); + } + } + + private void ShowVelocityAndGain() + { + VelocityChart.Show(); + GainChart.Show(); + ContaingForm.Height = SensitivityChart.Height + + ChartSeparationVertical + + VelocityChart.Height + + ChartSeparationVertical + + GainChart.Height + + FormBorderHeight; + } + + private void HideVelocityAndGain() + { + VelocityChart.Hide(); + GainChart.Hide(); + ContaingForm.Height = SensitivityChart.Height + FormBorderHeight; + } + + private void ShowXandYSeparate() + { + SensitivityChart.SetSeparate(); + VelocityChart.SetSeparate(); + GainChart.SetSeparate(); + UpdateFormWidth(); + } + + private void ShowCombined() + { + SensitivityChart.SetCombined(); + VelocityChart.SetCombined(); + GainChart.SetCombined(); + UpdateFormWidth(); + } + + private void UpdateFormWidth() + { + ContaingForm.Width = SensitivityChart.Left + SensitivityChart.Width; + } + } +} diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs new file mode 100644 index 0000000..4bb1bd5 --- /dev/null +++ b/grapher/Models/Charts/ChartXY.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; + +namespace grapher +{ + public class ChartXY + { + public const int ChartSeparationHorizontal = 10; + + public ChartXY(Chart chartX, Chart chartY) + { + ChartX = chartX; + ChartY = chartY; + + ChartY.Top = ChartX.Top; + ChartY.Height = ChartX.Height; + ChartY.Width = ChartX.Width; + ChartY.Left = ChartX.Left + ChartX.Width + ChartSeparationHorizontal; + + SetupChart(ChartX); + SetupChart(ChartY); + } + + public Chart ChartX { get; } + + public Chart ChartY { get; } + + public static void SetupChart(Chart chart) + { + chart.ChartAreas[0].AxisX.RoundAxisValues(); + + chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; + chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; + + chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; + chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; + + chart.ChartAreas[0].CursorY.Interval = 0.001; + + chart.ChartAreas[0].CursorX.AutoScroll = true; + chart.ChartAreas[0].CursorY.AutoScroll = true; + + chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; + chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + + chart.ChartAreas[0].CursorX.IsUserEnabled = true; + chart.ChartAreas[0].CursorY.IsUserEnabled = true; + } + + public int Height { + get + { + return ChartX.Height; + } + } + + public int Width { + get + { + if (Combined) + { + return ChartX.Width; + } + else + { + return ChartY.Left + ChartY.Width - ChartX.Left; + } + } + } + + public int Top { + get + { + return ChartX.Height; + } + } + + public int Left { + get + { + return ChartX.Left; + } + } + + public bool Combined { get; private set; } + + public void SetCombined() + { + if (!Combined) + { + ChartY.Hide(); + Combined = true; + } + } + + public void SetSeparate() + { + if (Combined) + { + if (ChartX.Visible) + { + ChartY.Show(); + } + + Combined = false; + } + } + + public void Hide() + { + ChartX.Hide(); + ChartY.Hide(); + } + + public void Show() + { + ChartX.Show(); + + if (!Combined) + { + ChartY.Show(); + } + } + + public void SetTop(int top) + { + ChartX.Top = top; + ChartY.Top = top; + } + + public void SetHeight(int height) + { + ChartX.Height = height; + ChartY.Height = height; + } + } +} -- cgit v1.2.3 From b6254f32a6cfbd40bd1919950b344160f38bf1e4 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 12 Aug 2020 19:51:38 -0700 Subject: Factor accel calculations into calculation classes --- grapher/Models/Charts/AccelCharts.cs | 14 +++++++++++++- grapher/Models/Charts/ChartXY.cs | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 9952016..4ed44c7 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Calculations; +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -55,8 +56,17 @@ namespace grapher public ToolStripMenuItem EnableVelocityAndGain { get; } + private bool Combined { get; set; } + private int FormBorderHeight { get; } + public void Bind(AccelData data) + { + SensitivityChart.Bind(data.OrderedAccelPoints); + VelocityChart.Bind(data.OrderedVelocityPoints); + GainChart.Bind(data.OrderedGainPoints); + } + private void OnEnableClick(object sender, EventArgs e) { EnableVelocityAndGain.Checked = !EnableVelocityAndGain.Checked; @@ -99,6 +109,7 @@ namespace grapher VelocityChart.SetSeparate(); GainChart.SetSeparate(); UpdateFormWidth(); + Combined = false; } private void ShowCombined() @@ -107,6 +118,7 @@ namespace grapher VelocityChart.SetCombined(); GainChart.SetCombined(); UpdateFormWidth(); + Combined = true; } private void UpdateFormWidth() diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 4bb1bd5..a57801e 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; @@ -89,6 +90,11 @@ namespace grapher public bool Combined { get; private set; } + public void Bind(IDictionary data) + { + ChartX.Series[0].Points.DataBindXY(data.Keys, data.Values); + } + public void SetCombined() { if (!Combined) -- cgit v1.2.3 From 30e1391b224ae028f4476e06a07415a0285ac6c9 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 12 Aug 2020 20:39:53 -0700 Subject: Almost working --- grapher/Models/Charts/AccelCharts.cs | 59 +++++++++++++++++++++++++++--------- grapher/Models/Charts/ChartXY.cs | 6 ++++ 2 files changed, 51 insertions(+), 14 deletions(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 4ed44c7..0728abc 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -22,13 +22,15 @@ namespace grapher ChartXY sensitivityChart, ChartXY velocityChart, ChartXY gainChart, - ToolStripMenuItem enableVelocityAndGain) + ToolStripMenuItem enableVelocityAndGain, + ICollection checkBoxesXY) { ContaingForm = form; SensitivityChart = sensitivityChart; VelocityChart = velocityChart; GainChart = gainChart; EnableVelocityAndGain = enableVelocityAndGain; + CheckBoxesXY = checkBoxesXY; SensitivityChart.SetTop(0); VelocityChart.SetHeight(SensitivityChart.Height); @@ -56,15 +58,38 @@ namespace grapher public ToolStripMenuItem EnableVelocityAndGain { get; } + private ICollection CheckBoxesXY { get; } + private bool Combined { get; set; } private int FormBorderHeight { get; } public void Bind(AccelData data) { - SensitivityChart.Bind(data.OrderedAccelPoints); - VelocityChart.Bind(data.OrderedVelocityPoints); - GainChart.Bind(data.OrderedGainPoints); + if (Combined) + { + SensitivityChart.Bind(data.Combined.AccelPoints); + VelocityChart.Bind(data.Combined.VelocityPoints); + GainChart.Bind(data.Combined.GainPoints); + } + else + { + SensitivityChart.BindXY(data.X.AccelPoints, data.Y.AccelPoints); + VelocityChart.BindXY(data.X.VelocityPoints, data.Y.VelocityPoints); + GainChart.BindXY(data.X.GainPoints, data.Y.GainPoints); + } + } + + public void RefreshXY() + { + if (CheckBoxesXY.All(box => box.Checked)) + { + ShowCombined(); + } + else + { + ShowXandYSeparate(); + } } private void OnEnableClick(object sender, EventArgs e) @@ -105,20 +130,26 @@ namespace grapher private void ShowXandYSeparate() { - SensitivityChart.SetSeparate(); - VelocityChart.SetSeparate(); - GainChart.SetSeparate(); - UpdateFormWidth(); - Combined = false; + if (Combined) + { + SensitivityChart.SetSeparate(); + VelocityChart.SetSeparate(); + GainChart.SetSeparate(); + UpdateFormWidth(); + Combined = false; + } } private void ShowCombined() { - SensitivityChart.SetCombined(); - VelocityChart.SetCombined(); - GainChart.SetCombined(); - UpdateFormWidth(); - Combined = true; + if (!Combined) + { + SensitivityChart.SetCombined(); + VelocityChart.SetCombined(); + GainChart.SetCombined(); + UpdateFormWidth(); + Combined = true; + } } private void UpdateFormWidth() diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index a57801e..7bb7ac8 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -95,6 +95,12 @@ namespace grapher ChartX.Series[0].Points.DataBindXY(data.Keys, data.Values); } + public void BindXY(IDictionary dataX, IDictionary dataY) + { + ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values); + ChartY.Series[0].Points.DataBindXY(dataY.Keys, dataY.Values); + } + public void SetCombined() { if (!Combined) -- cgit v1.2.3 From 93a22c08b3223b040c3a3644fc3c4ef82fc576f0 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 13 Aug 2020 01:52:49 -0700 Subject: Dot to show mouse move --- grapher/Models/Charts/AccelCharts.cs | 73 +++++++++++++++++++++++++---- grapher/Models/Charts/ChartXY.cs | 90 +++++++++++++++++++++++++++--------- 2 files changed, 131 insertions(+), 32 deletions(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 0728abc..e593bb9 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Linq; +using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,6 +13,27 @@ namespace grapher { public class AccelCharts { + public struct ChartPoint + { + public double X; + public double Y; + } + + public struct EstimatedPoints + { + public ChartPoint CombinedVelocity; + public ChartPoint CombinedSensitivity; + public ChartPoint CombinedGain; + + public ChartPoint XVelocity; + public ChartPoint XSensitivity; + public ChartPoint XGain; + + public ChartPoint YVelocity; + public ChartPoint YSensitivity; + public ChartPoint YGain; + } + public const int ChartSeparationVertical = 10; /// Needed to show full contents in form. Unsure why. @@ -31,6 +53,22 @@ namespace grapher GainChart = gainChart; EnableVelocityAndGain = enableVelocityAndGain; CheckBoxesXY = checkBoxesXY; + AccelData = new AccelData(); + + Estimated = new EstimatedPoints + { + CombinedVelocity = new ChartPoint { X = 0, Y = 0 }, + CombinedSensitivity = new ChartPoint { X = 0, Y = 0 }, + CombinedGain = new ChartPoint { X = 0, Y = 0 }, + + XVelocity = new ChartPoint { X = 0, Y = 0 }, + XSensitivity = new ChartPoint { X = 0, Y = 0 }, + XGain = new ChartPoint { X = 0, Y = 0 }, + + YVelocity = new ChartPoint { X = 0, Y = 0 }, + YSensitivity = new ChartPoint { X = 0, Y = 0 }, + YGain = new ChartPoint { X = 0, Y = 0 }, + }; SensitivityChart.SetTop(0); VelocityChart.SetHeight(SensitivityChart.Height); @@ -45,6 +83,7 @@ namespace grapher EnableVelocityAndGain.CheckedChanged += new System.EventHandler(OnEnableCheckStateChange); HideVelocityAndGain(); + Combined = false; ShowCombined(); } @@ -58,25 +97,37 @@ namespace grapher public ToolStripMenuItem EnableVelocityAndGain { get; } + public AccelData AccelData { get; } + + private EstimatedPoints Estimated; + private ICollection CheckBoxesXY { get; } private bool Combined { get; set; } private int FormBorderHeight { get; } - public void Bind(AccelData data) + public void MakeDots(int x, int y) + { + AccelData.CalculateDots(x, y, ref Estimated); + SensitivityChart.DrawPoints(Estimated.CombinedSensitivity, Estimated.XSensitivity, Estimated.YSensitivity); + VelocityChart.DrawPoints(Estimated.CombinedVelocity, Estimated.XVelocity, Estimated.YVelocity); + GainChart.DrawPoints(Estimated.CombinedGain, Estimated.XGain, Estimated.YGain); + } + + public void Bind() { if (Combined) { - SensitivityChart.Bind(data.Combined.AccelPoints); - VelocityChart.Bind(data.Combined.VelocityPoints); - GainChart.Bind(data.Combined.GainPoints); + SensitivityChart.Bind(AccelData.Combined.AccelPoints); + VelocityChart.Bind(AccelData.Combined.VelocityPoints); + GainChart.Bind(AccelData.Combined.GainPoints); } else { - SensitivityChart.BindXY(data.X.AccelPoints, data.Y.AccelPoints); - VelocityChart.BindXY(data.X.VelocityPoints, data.Y.VelocityPoints); - GainChart.BindXY(data.X.GainPoints, data.Y.GainPoints); + SensitivityChart.BindXY(AccelData.X.AccelPoints, AccelData.Y.AccelPoints); + VelocityChart.BindXY(AccelData.X.VelocityPoints, AccelData.Y.VelocityPoints); + GainChart.BindXY(AccelData.X.GainPoints, AccelData.Y.GainPoints); } } @@ -132,11 +183,13 @@ namespace grapher { if (Combined) { + Combined = false; + SensitivityChart.SetSeparate(); VelocityChart.SetSeparate(); GainChart.SetSeparate(); UpdateFormWidth(); - Combined = false; + Bind(); } } @@ -144,11 +197,13 @@ namespace grapher { if (!Combined) { + Combined = true; + SensitivityChart.SetCombined(); VelocityChart.SetCombined(); GainChart.SetCombined(); UpdateFormWidth(); - Combined = true; + Bind(); } } diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 7bb7ac8..2c0ce2c 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -1,18 +1,26 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; +using static grapher.AccelCharts; namespace grapher { public class ChartXY { + #region Consts + public const int ChartSeparationHorizontal = 10; + #endregion Consts + + #region Constructors + public ChartXY(Chart chartX, Chart chartY) { ChartX = chartX; @@ -27,31 +35,13 @@ namespace grapher SetupChart(ChartY); } - public Chart ChartX { get; } - - public Chart ChartY { get; } - - public static void SetupChart(Chart chart) - { - chart.ChartAreas[0].AxisX.RoundAxisValues(); - - chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; - chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; - - chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; - chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; - - chart.ChartAreas[0].CursorY.Interval = 0.001; + #endregion Constructors - chart.ChartAreas[0].CursorX.AutoScroll = true; - chart.ChartAreas[0].CursorY.AutoScroll = true; + #region Properties - chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; - chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + public Chart ChartX { get; } - chart.ChartAreas[0].CursorX.IsUserEnabled = true; - chart.ChartAreas[0].CursorY.IsUserEnabled = true; - } + public Chart ChartY { get; } public int Height { get @@ -77,7 +67,7 @@ namespace grapher public int Top { get { - return ChartX.Height; + return ChartX.Top; } } @@ -90,6 +80,58 @@ namespace grapher public bool Combined { get; private set; } + #endregion Properties + + #region Methods + + public static void SetupChart(Chart chart) + { + chart.ChartAreas[0].AxisX.RoundAxisValues(); + + chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; + chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; + + chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; + chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; + + chart.ChartAreas[0].CursorY.Interval = 0.001; + + chart.ChartAreas[0].CursorX.AutoScroll = true; + chart.ChartAreas[0].CursorY.AutoScroll = true; + + chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; + chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + + chart.ChartAreas[0].CursorX.IsUserEnabled = true; + chart.ChartAreas[0].CursorY.IsUserEnabled = true; + + chart.Series[1].Points.Clear(); + chart.Series[1].Points.AddXY(0, 0); + } + + public static void DrawPoint(Chart chart, ChartPoint point) + { + chart.Series[1].Points[0].XValue = point.X; + chart.Series[1].Points[0].YValues[0] = point.Y; + } + + public void DrawPoints(ChartPoint CombinedPoint, ChartPoint XPoint, ChartPoint YPoint) + { + if (Combined) + { + DrawPoint(ChartX, CombinedPoint); + } + else + { + DrawPoint(ChartX, XPoint); + } + + if (ChartY.Visible) + { + DrawPoint(ChartY, YPoint); + } + } + public void Bind(IDictionary data) { ChartX.Series[0].Points.DataBindXY(data.Keys, data.Values); @@ -150,5 +192,7 @@ namespace grapher ChartX.Height = height; ChartY.Height = height; } + + #endregion Methods } } -- cgit v1.2.3 From 6602649bd7f9a9849b25fe55a5e5e8a617f40b70 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 13 Aug 2020 13:39:40 -0700 Subject: All works smoothly --- grapher/Models/Charts/AccelCharts.cs | 70 +++++++++++++------------------- grapher/Models/Charts/ChartXY.cs | 41 +++++++++++++------ grapher/Models/Charts/EstimatedPoints.cs | 25 ++++++++++++ 3 files changed, 82 insertions(+), 54 deletions(-) create mode 100644 grapher/Models/Charts/EstimatedPoints.cs (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index e593bb9..42377c4 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -1,4 +1,5 @@ using grapher.Models.Calculations; +using grapher.Models.Charts; using System; using System.Collections.Generic; using System.Drawing; @@ -13,27 +14,6 @@ namespace grapher { public class AccelCharts { - public struct ChartPoint - { - public double X; - public double Y; - } - - public struct EstimatedPoints - { - public ChartPoint CombinedVelocity; - public ChartPoint CombinedSensitivity; - public ChartPoint CombinedGain; - - public ChartPoint XVelocity; - public ChartPoint XSensitivity; - public ChartPoint XGain; - - public ChartPoint YVelocity; - public ChartPoint YSensitivity; - public ChartPoint YGain; - } - public const int ChartSeparationVertical = 10; /// Needed to show full contents in form. Unsure why. @@ -47,28 +27,21 @@ namespace grapher ToolStripMenuItem enableVelocityAndGain, ICollection checkBoxesXY) { + Estimated = new EstimatedPoints(); + EstimatedX = new EstimatedPoints(); + EstimatedY = new EstimatedPoints(); + AccelData = new AccelData(Estimated, EstimatedX, EstimatedY); + ContaingForm = form; SensitivityChart = sensitivityChart; VelocityChart = velocityChart; GainChart = gainChart; EnableVelocityAndGain = enableVelocityAndGain; CheckBoxesXY = checkBoxesXY; - AccelData = new AccelData(); - - Estimated = new EstimatedPoints - { - CombinedVelocity = new ChartPoint { X = 0, Y = 0 }, - CombinedSensitivity = new ChartPoint { X = 0, Y = 0 }, - CombinedGain = new ChartPoint { X = 0, Y = 0 }, - - XVelocity = new ChartPoint { X = 0, Y = 0 }, - XSensitivity = new ChartPoint { X = 0, Y = 0 }, - XGain = new ChartPoint { X = 0, Y = 0 }, - YVelocity = new ChartPoint { X = 0, Y = 0 }, - YSensitivity = new ChartPoint { X = 0, Y = 0 }, - YGain = new ChartPoint { X = 0, Y = 0 }, - }; + SensitivityChart.SetPointBinds(Estimated.Sensitivity, EstimatedX.Sensitivity, EstimatedY.Sensitivity); + VelocityChart.SetPointBinds(Estimated.Velocity, EstimatedX.Velocity, EstimatedY.Velocity); + GainChart.SetPointBinds(Estimated.Gain, EstimatedX.Gain, EstimatedY.Gain); SensitivityChart.SetTop(0); VelocityChart.SetHeight(SensitivityChart.Height); @@ -99,7 +72,11 @@ namespace grapher public AccelData AccelData { get; } - private EstimatedPoints Estimated; + private EstimatedPoints Estimated { get; } + + private EstimatedPoints EstimatedX { get; } + + private EstimatedPoints EstimatedY { get; } private ICollection CheckBoxesXY { get; } @@ -109,10 +86,21 @@ namespace grapher public void MakeDots(int x, int y) { - AccelData.CalculateDots(x, y, ref Estimated); - SensitivityChart.DrawPoints(Estimated.CombinedSensitivity, Estimated.XSensitivity, Estimated.YSensitivity); - VelocityChart.DrawPoints(Estimated.CombinedVelocity, Estimated.XVelocity, Estimated.YVelocity); - GainChart.DrawPoints(Estimated.CombinedGain, Estimated.XGain, Estimated.YGain); + if (Combined) + { + AccelData.CalculateDots(x, y); + } + else + { + AccelData.CalculateDotsXY(x, y); + } + } + + public void DrawPoints() + { + SensitivityChart.DrawPoints(); + VelocityChart.DrawPoints(); + GainChart.DrawPoints(); } public void Bind() diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 2c0ce2c..c0c8713 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -1,4 +1,6 @@ -using System; +using grapher.Models.Charts; +using grapher.Models.Mouse; +using System; using System.Collections; using System.Collections.Generic; using System.Drawing; @@ -80,6 +82,12 @@ namespace grapher public bool Combined { get; private set; } + private PointData CombinedPointData { get; set; } + + private PointData XPointData { get; set; } + + private PointData YPointData { get; set; } + #endregion Properties #region Methods @@ -109,26 +117,33 @@ namespace grapher chart.Series[1].Points.AddXY(0, 0); } - public static void DrawPoint(Chart chart, ChartPoint point) + public static void DrawPoint(Chart chart, PointData point) { - chart.Series[1].Points[0].XValue = point.X; - chart.Series[1].Points[0].YValues[0] = point.Y; + if (chart.Visible) + { + (var x, var y) = point.Get(); + chart.Series[1].Points.DataBindXY(x, y); + chart.Update(); + } } - public void DrawPoints(ChartPoint CombinedPoint, ChartPoint XPoint, ChartPoint YPoint) + public void SetPointBinds(PointData combined, PointData x, PointData y) { - if (Combined) + CombinedPointData = combined; + XPointData = x; + YPointData = y; + } + + public void DrawPoints() + { + if(Combined) { - DrawPoint(ChartX, CombinedPoint); + DrawPoint(ChartX, CombinedPointData); } else { - DrawPoint(ChartX, XPoint); - } - - if (ChartY.Visible) - { - DrawPoint(ChartY, YPoint); + DrawPoint(ChartX, XPointData); + DrawPoint(ChartY, YPointData); } } diff --git a/grapher/Models/Charts/EstimatedPoints.cs b/grapher/Models/Charts/EstimatedPoints.cs new file mode 100644 index 0000000..fa0718b --- /dev/null +++ b/grapher/Models/Charts/EstimatedPoints.cs @@ -0,0 +1,25 @@ +using grapher.Models.Mouse; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Models.Charts +{ + public class EstimatedPoints + { + public EstimatedPoints() + { + Sensitivity = new PointData(); + Velocity = new PointData(); + Gain = new PointData(); + } + + public PointData Sensitivity { get; } + + public PointData Velocity { get; } + + public PointData Gain { get; } + } +} -- cgit v1.2.3 From 32323636b4b5390c114fc2a6d845b7621a983cdc Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 13 Aug 2020 20:56:41 -0700 Subject: Fix initial points, add poll time constant --- grapher/Models/Charts/AccelCharts.cs | 6 +++--- grapher/Models/Charts/ChartXY.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 42377c4..1aa3909 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -84,15 +84,15 @@ namespace grapher private int FormBorderHeight { get; } - public void MakeDots(int x, int y) + public void MakeDots(int x, int y, double timeInMs) { if (Combined) { - AccelData.CalculateDots(x, y); + AccelData.CalculateDots(x, y, timeInMs); } else { - AccelData.CalculateDotsXY(x, y); + AccelData.CalculateDotsXY(x, y, timeInMs); } } diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index c0c8713..81874a2 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -121,7 +121,7 @@ namespace grapher { if (chart.Visible) { - (var x, var y) = point.Get(); + point.Get(out var x, out var y); chart.Series[1].Points.DataBindXY(x, y); chart.Update(); } -- cgit v1.2.3