diff options
| author | Jacob Palecki <[email protected]> | 2020-08-13 01:52:49 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-08-13 01:52:49 -0700 |
| commit | 93a22c08b3223b040c3a3644fc3c4ef82fc576f0 (patch) | |
| tree | 336d99789e3dac52466c00fb5e07fc82a73c3bc8 /grapher/Models/Charts | |
| parent | Almost working (diff) | |
| download | rawaccel-93a22c08b3223b040c3a3644fc3c4ef82fc576f0.tar.xz rawaccel-93a22c08b3223b040c3a3644fc3c4ef82fc576f0.zip | |
Dot to show mouse move
Diffstat (limited to 'grapher/Models/Charts')
| -rw-r--r-- | grapher/Models/Charts/AccelCharts.cs | 73 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartXY.cs | 90 |
2 files changed, 131 insertions, 32 deletions
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; /// <summary> Needed to show full contents in form. Unsure why. </summary> @@ -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<CheckBox> 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 } } |