From 05c7094a93c7d29eb8ac05247110995574a7b963 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Wed, 16 Sep 2020 01:20:23 -0700 Subject: Unsure if I will use this --- grapher/Models/Charts/AccelCharts.cs | 196 +++++++++------------ grapher/Models/Charts/ChartState/ChartState.cs | 86 +++++++++ .../Models/Charts/ChartState/ChartStateManager.cs | 68 +++++++ grapher/Models/Charts/ChartState/CombinedState.cs | 38 ++++ .../Models/Charts/ChartState/XYOneGraphState.cs | 20 +++ .../Models/Charts/ChartState/XYTwoGraphState.cs | 38 ++++ 6 files changed, 330 insertions(+), 116 deletions(-) create mode 100644 grapher/Models/Charts/ChartState/ChartState.cs create mode 100644 grapher/Models/Charts/ChartState/ChartStateManager.cs create mode 100644 grapher/Models/Charts/ChartState/CombinedState.cs create mode 100644 grapher/Models/Charts/ChartState/XYOneGraphState.cs create mode 100644 grapher/Models/Charts/ChartState/XYTwoGraphState.cs (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 3f228c3..f255d79 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -1,5 +1,6 @@ using grapher.Models.Calculations; using grapher.Models.Charts; +using grapher.Models.Charts.ChartState; using grapher.Models.Serialized; using System; using System.Drawing; @@ -20,31 +21,21 @@ namespace grapher ToolStripMenuItem enableLastMouseMove, Button writeButton) { - Estimated = new EstimatedPoints(); - EstimatedX = new EstimatedPoints(); - EstimatedY = new EstimatedPoints(); - AccelData = new AccelData(Estimated, EstimatedX, EstimatedY); + var estimated = new EstimatedPoints(); + var estimatedX = new EstimatedPoints(); + var estimatedY = new EstimatedPoints(); + SetupCharts(sensitivityChart, velocityChart, gainChart, estimated, estimatedX, estimatedY); + var accelData = new AccelData(estimated, estimatedX, estimatedY); + ChartStateManager = new ChartStateManager(sensitivityChart, velocityChart, gainChart, accelData); - ContaingForm = form; - SensitivityChart = sensitivityChart; - VelocityChart = velocityChart; - GainChart = gainChart; + ContainingForm = form; EnableVelocityAndGain = enableVelocityAndGain; EnableLastValue = enableLastMouseMove; WriteButton = writeButton; - 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); - VelocityChart.SetTop(SensitivityChart.Height + Constants.ChartSeparationVertical); - GainChart.SetHeight(SensitivityChart.Height); - GainChart.SetTop(VelocityChart.Top + VelocityChart.Height + Constants.ChartSeparationVertical); - - Rectangle screenRectangle = ContaingForm.RectangleToScreen(ContaingForm.ClientRectangle); - FormBorderHeight = screenRectangle.Top - ContaingForm.Top; + Rectangle screenRectangle = ContainingForm.RectangleToScreen(ContainingForm.ClientRectangle); + FormBorderHeight = screenRectangle.Top - ContainingForm.Top; EnableVelocityAndGain.Click += new System.EventHandler(OnEnableClick); EnableVelocityAndGain.CheckedChanged += new System.EventHandler(OnEnableVelocityGainCheckStateChange); @@ -52,22 +43,15 @@ namespace grapher EnableLastValue.CheckedChanged += new System.EventHandler(OnEnableLastMouseMoveCheckStateChange); HideVelocityAndGain(); - SensitivityChart.Show(); - Combined = false; - ShowCombined(); + ChartState = ChartStateManager.InitialState(); + ChartState.Activate(); } #endregion Constructors #region Properties - public Form ContaingForm { get; } - - public ChartXY SensitivityChart { get; } - - public ChartXY VelocityChart { get; } - - public ChartXY GainChart { get; } + public Form ContainingForm { get; } public ToolStripMenuItem EnableVelocityAndGain { get; } @@ -75,90 +59,109 @@ namespace grapher private Button WriteButton { get; } - public AccelData AccelData { get; } - - private EstimatedPoints Estimated { get; } + public AccelData AccelData + { + get + { + return ChartState.AccelData; + } + } - private EstimatedPoints EstimatedX { get; } + public int Left + { + get + { + return ChartState.SensitivityChart.Left; + } + } - private EstimatedPoints EstimatedY { get; } + public int Top + { + get + { + return ChartState.SensitivityChart.Top; + } + } - private bool Combined { get; set; } + public int TopChartHeight + { + get + { + return ChartState.SensitivityChart.Height; + } + } private int FormBorderHeight { get; } + private ChartState ChartState { get; set; } + + private ChartStateManager ChartStateManager { get; } + #endregion Properties #region Methods public void MakeDots(int x, int y, double timeInMs) { - if (Combined) - { - AccelData.CalculateDots(x, y, timeInMs); - } - else - { - AccelData.CalculateDotsXY(x, y, timeInMs); - } + ChartState.MakeDots(x, y, timeInMs); } public void DrawLastMovement() { if (EnableLastValue.Checked) { - SensitivityChart.DrawLastMovementValue(); - VelocityChart.DrawLastMovementValue(); - GainChart.DrawLastMovementValue(); + ChartState.DrawLastMovement(); } } public void Bind() { - if (Combined) - { - SensitivityChart.Bind(AccelData.Combined.AccelPoints); - VelocityChart.Bind(AccelData.Combined.VelocityPoints); - GainChart.Bind(AccelData.Combined.GainPoints); - } - else - { - SensitivityChart.BindXY(AccelData.X.AccelPoints, AccelData.Y.AccelPoints); - VelocityChart.BindXY(AccelData.X.VelocityPoints, AccelData.Y.VelocityPoints); - GainChart.BindXY(AccelData.X.GainPoints, AccelData.Y.GainPoints); - } + ChartState.Bind(); } public void ShowActive(DriverSettings driverSettings) { - if (driverSettings.combineMagnitudes) - { - ShowCombined(); - } - else - { - ShowXandYSeparate(); - } + ChartState = ChartStateManager.DetermineState(driverSettings); + ChartState.Activate(); + UpdateFormWidth(); + Bind(); } public void SetWidened() { - SensitivityChart.SetWidened(); - VelocityChart.SetWidened(); - GainChart.SetWidened(); + ChartState.SetWidened(); UpdateFormWidth(); AlignWriteButton(); } public void SetNarrowed() { - SensitivityChart.SetNarrowed(); - VelocityChart.SetNarrowed(); - GainChart.SetNarrowed(); + ChartState.SetNarrowed(); UpdateFormWidth(); AlignWriteButton(); } + private static void SetupCharts( + ChartXY sensitivityChart, + ChartXY velocityChart, + ChartXY gainChart, + EstimatedPoints estimated, + EstimatedPoints estimatedX, + EstimatedPoints estimatedY) + { + 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); + velocityChart.SetTop(sensitivityChart.Height + Constants.ChartSeparationVertical); + gainChart.SetHeight(sensitivityChart.Height); + gainChart.SetTop(velocityChart.Top + velocityChart.Height + Constants.ChartSeparationVertical); + + sensitivityChart.Show(); + } + private void OnEnableClick(object sender, EventArgs e) { EnableVelocityAndGain.Checked = !EnableVelocityAndGain.Checked; @@ -180,67 +183,28 @@ namespace grapher { if (!EnableLastValue.Checked) { - SensitivityChart.ClearLastValue(); - VelocityChart.ClearLastValue(); - GainChart.ClearLastValue(); + ChartState.ClearLastValue(); } } private void ShowVelocityAndGain() { - VelocityChart.Show(); - GainChart.Show(); - ContaingForm.Height = SensitivityChart.Height + - Constants.ChartSeparationVertical + - VelocityChart.Height + - Constants.ChartSeparationVertical + - GainChart.Height + - FormBorderHeight; + ChartState.ShowVelocityAndGain(ContainingForm, FormBorderHeight); } private void HideVelocityAndGain() { - VelocityChart.Hide(); - GainChart.Hide(); - ContaingForm.Height = SensitivityChart.Height + FormBorderHeight; - } - - private void ShowXandYSeparate() - { - if (Combined) - { - Combined = false; - - SensitivityChart.SetSeparate(); - VelocityChart.SetSeparate(); - GainChart.SetSeparate(); - UpdateFormWidth(); - Bind(); - } - } - - private void ShowCombined() - { - if (!Combined) - { - Combined = true; - - SensitivityChart.SetCombined(); - VelocityChart.SetCombined(); - GainChart.SetCombined(); - UpdateFormWidth(); - Bind(); - } + ChartState.HideVelocityAndGain(ContainingForm, FormBorderHeight); } private void UpdateFormWidth() { - ContaingForm.Width = SensitivityChart.Left + SensitivityChart.Width; + ContainingForm.Width = ChartState.SensitivityChart.Left + ChartState.SensitivityChart.Width; } private void AlignWriteButton() { - WriteButton.Left = SensitivityChart.Left / 2 - WriteButton.Width / 2; + WriteButton.Left = ChartState.SensitivityChart.Left / 2 - WriteButton.Width / 2; } #endregion Methods diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs new file mode 100644 index 0000000..b450357 --- /dev/null +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -0,0 +1,86 @@ +using grapher.Models.Calculations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace grapher.Models.Charts.ChartState +{ + public abstract class ChartState + { + public ChartState( + ChartXY sensitivityChart, + ChartXY velocityChart, + ChartXY gainChart, + AccelData accelData) + { + SensitivityChart = sensitivityChart; + VelocityChart = velocityChart; + GainChart = gainChart; + AccelData = accelData; + } + + public ChartXY SensitivityChart { get; } + + public ChartXY VelocityChart { get; } + + public ChartXY GainChart { get; } + + public AccelData AccelData { get; } + + public abstract void MakeDots(int x, int y, double timeInMs); + + public abstract void Bind(); + + public abstract void Activate(); + + public void DrawLastMovement() + { + SensitivityChart.DrawLastMovementValue(); + VelocityChart.DrawLastMovementValue(); + GainChart.DrawLastMovementValue(); + } + + public void SetWidened() + { + SensitivityChart.SetWidened(); + VelocityChart.SetWidened(); + GainChart.SetWidened(); + } + + public void SetNarrowed() + { + SensitivityChart.SetNarrowed(); + VelocityChart.SetNarrowed(); + GainChart.SetNarrowed(); + } + + public void ClearLastValue() + { + SensitivityChart.ClearLastValue(); + VelocityChart.ClearLastValue(); + GainChart.ClearLastValue(); + } + + public void ShowVelocityAndGain(Form form, int borderHeight) + { + VelocityChart.Show(); + GainChart.Show(); + form.Height = SensitivityChart.Height + + Constants.ChartSeparationVertical + + VelocityChart.Height + + Constants.ChartSeparationVertical + + GainChart.Height + + borderHeight; + } + + public void HideVelocityAndGain(Form form, int borderHeight) + { + VelocityChart.Hide(); + GainChart.Hide(); + form.Height = SensitivityChart.Height + borderHeight; + } + } +} diff --git a/grapher/Models/Charts/ChartState/ChartStateManager.cs b/grapher/Models/Charts/ChartState/ChartStateManager.cs new file mode 100644 index 0000000..27d0836 --- /dev/null +++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs @@ -0,0 +1,68 @@ +using grapher.Models.Calculations; +using grapher.Models.Serialized; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Models.Charts.ChartState +{ + public class ChartStateManager + { + public ChartStateManager( + ChartXY sensitivityChart, + ChartXY velocityChart, + ChartXY gainChat, + AccelData accelData) + { + CombinedState = new CombinedState( + sensitivityChart, + velocityChart, + gainChat, + accelData); + + XYOneGraphState = new XYOneGraphState( + sensitivityChart, + velocityChart, + gainChat, + accelData); + + XYTwoGraphState = new XYTwoGraphState( + sensitivityChart, + velocityChart, + gainChat, + accelData); + } + + private CombinedState CombinedState { get; } + + private XYOneGraphState XYOneGraphState { get; } + + private XYTwoGraphState XYTwoGraphState { get; } + + public ChartState DetermineState(DriverSettings settings) + { + if (settings.combineMagnitudes) + { + if (settings.sensitivity.x != settings.sensitivity.y) + { + return XYOneGraphState; + } + else + { + return CombinedState; + } + } + else + { + return XYTwoGraphState; + } + } + + public ChartState InitialState() + { + return CombinedState; + } + } +} diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs new file mode 100644 index 0000000..bc8c720 --- /dev/null +++ b/grapher/Models/Charts/ChartState/CombinedState.cs @@ -0,0 +1,38 @@ +using grapher.Models.Calculations; + +namespace grapher.Models.Charts.ChartState +{ + public class CombinedState : ChartState + { + public CombinedState( + ChartXY sensitivityChart, + ChartXY velocityChart, + ChartXY gainChart, + AccelData accelData) + : base( + sensitivityChart, + velocityChart, + gainChart, + accelData) + { } + + public override void Activate() + { + SensitivityChart.SetCombined(); + VelocityChart.SetCombined(); + GainChart.SetCombined(); + } + + public override void MakeDots(int x, int y, double timeInMs) + { + AccelData.CalculateDots(x, y, timeInMs); + } + + public override void Bind() + { + SensitivityChart.Bind(AccelData.Combined.AccelPoints); + VelocityChart.Bind(AccelData.Combined.VelocityPoints); + GainChart.Bind(AccelData.Combined.GainPoints); + } + } +} diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs new file mode 100644 index 0000000..58276e4 --- /dev/null +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -0,0 +1,20 @@ +using grapher.Models.Calculations; + +namespace grapher.Models.Charts.ChartState +{ + public class XYOneGraphState : ChartState + { + public XYOneGraphState( + ChartXY sensitivityChart, + ChartXY velocityChart, + ChartXY gainChart, + AccelData accelData) + : base( + sensitivityChart, + velocityChart, + gainChart, + accelData) + { } + + } +} diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs new file mode 100644 index 0000000..f37af08 --- /dev/null +++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs @@ -0,0 +1,38 @@ +using grapher.Models.Calculations; + +namespace grapher.Models.Charts.ChartState +{ + public class XYTwoGraphState : ChartState + { + public XYTwoGraphState( + ChartXY sensitivityChart, + ChartXY velocityChart, + ChartXY gainChart, + AccelData accelData) + : base( + sensitivityChart, + velocityChart, + gainChart, + accelData) + { } + + public override void Activate() + { + SensitivityChart.SetSeparate(); + VelocityChart.SetSeparate(); + GainChart.SetSeparate(); + } + + public override void MakeDots(int x, int y, double timeInMs) + { + AccelData.CalculateDotsXY(x, y, timeInMs); + } + + public override void Bind() + { + SensitivityChart.BindXY(AccelData.X.AccelPoints, AccelData.Y.AccelPoints); + VelocityChart.BindXY(AccelData.X.VelocityPoints, AccelData.Y.VelocityPoints); + GainChart.BindXY(AccelData.X.GainPoints, AccelData.Y.GainPoints); + } + } +} -- cgit v1.2.3 From 5beedd6d1aca73adaae6556ded584d3f454509b0 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 17 Sep 2020 01:29:18 -0700 Subject: Much progress --- grapher/Models/Charts/AccelCharts.cs | 2 +- grapher/Models/Charts/ChartState/ChartState.cs | 3 ++ .../Models/Charts/ChartState/ChartStateManager.cs | 12 ++++++-- .../Models/Charts/ChartState/XYOneGraphState.cs | 18 ++++++++++++ .../Models/Charts/ChartState/XYTwoGraphState.cs | 32 +++++++++++++++++++++- 5 files changed, 62 insertions(+), 5 deletions(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index f255d79..844afe1 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -42,9 +42,9 @@ namespace grapher EnableLastValue.CheckedChanged += new System.EventHandler(OnEnableLastMouseMoveCheckStateChange); - HideVelocityAndGain(); ChartState = ChartStateManager.InitialState(); ChartState.Activate(); + HideVelocityAndGain(); } #endregion Constructors diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index b450357..cc334ac 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -1,4 +1,5 @@ using grapher.Models.Calculations; +using grapher.Models.Serialized; using System; using System.Collections.Generic; using System.Linq; @@ -30,6 +31,8 @@ namespace grapher.Models.Charts.ChartState public AccelData AccelData { get; } + public virtual DriverSettings Settings { get; set; } + public abstract void MakeDots(int x, int y, double timeInMs); public abstract void Bind(); diff --git a/grapher/Models/Charts/ChartState/ChartStateManager.cs b/grapher/Models/Charts/ChartState/ChartStateManager.cs index 27d0836..b64b1a2 100644 --- a/grapher/Models/Charts/ChartState/ChartStateManager.cs +++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs @@ -41,23 +41,29 @@ namespace grapher.Models.Charts.ChartState private XYTwoGraphState XYTwoGraphState { get; } + public ChartState DetermineState(DriverSettings settings) { + ChartState chartState; + if (settings.combineMagnitudes) { if (settings.sensitivity.x != settings.sensitivity.y) { - return XYOneGraphState; + chartState = XYOneGraphState; } else { - return CombinedState; + chartState = CombinedState; } } else { - return XYTwoGraphState; + chartState = XYTwoGraphState; } + + chartState.Settings = settings; + return chartState; } public ChartState InitialState() diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index 58276e4..3ed5c5b 100644 --- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -16,5 +16,23 @@ namespace grapher.Models.Charts.ChartState accelData) { } + public override void Activate() + { + SensitivityChart.SetSeparate(); + VelocityChart.SetSeparate(); + GainChart.SetSeparate(); + } + + public override void MakeDots(int x, int y, double timeInMs) + { + AccelData.CalculateDotsXY(x, y, timeInMs); + } + + public override void Bind() + { + SensitivityChart.BindXY(AccelData.X.AccelPoints, AccelData.Y.AccelPoints); + VelocityChart.BindXY(AccelData.X.VelocityPoints, AccelData.Y.VelocityPoints); + GainChart.BindXY(AccelData.X.GainPoints, AccelData.Y.GainPoints); + } } } diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs index f37af08..b54832c 100644 --- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs @@ -1,9 +1,13 @@ using grapher.Models.Calculations; +using grapher.Models.Serialized; +using System; namespace grapher.Models.Charts.ChartState { public class XYTwoGraphState : ChartState { + private DriverSettings _settings; + public XYTwoGraphState( ChartXY sensitivityChart, ChartXY velocityChart, @@ -16,6 +20,24 @@ namespace grapher.Models.Charts.ChartState accelData) { } + public override DriverSettings Settings + { + get { return _settings; } + set + { + _settings = value; + ShouldStripSens = AccelCalculator.ShouldStripSens(ref value); + if (ShouldStripSens) + { + Sensitivity = AccelCalculator.GetSens(ref value); + } + } + } + + private bool ShouldStripSens { get; set; } + + private (double, double) Sensitivity { get; set; } + public override void Activate() { SensitivityChart.SetSeparate(); @@ -25,7 +47,15 @@ namespace grapher.Models.Charts.ChartState public override void MakeDots(int x, int y, double timeInMs) { - AccelData.CalculateDotsXY(x, y, timeInMs); + double xCalc = x; + double yCalc = y; + + if (ShouldStripSens) + { + (xCalc, yCalc) = AccelCalculator.StripSens(xCalc, yCalc, Sensitivity.Item1, Sensitivity.Item2); + } + + AccelData.CalculateDotsXY((int)Math.Round(xCalc), (int)Math.Round(yCalc), timeInMs); } public override void Bind() -- cgit v1.2.3 From df173decac3ac5e1043b53961f1512bb88b85136 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 17 Sep 2020 20:26:15 -0700 Subject: Further work --- grapher/Models/Charts/AccelCharts.cs | 7 ++++--- grapher/Models/Charts/ChartState/ChartState.cs | 12 +++++++++--- grapher/Models/Charts/ChartState/ChartStateManager.cs | 12 ++++++++---- grapher/Models/Charts/ChartState/CombinedState.cs | 14 ++++++++------ grapher/Models/Charts/ChartState/XYOneGraphState.cs | 14 ++++++++------ grapher/Models/Charts/ChartState/XYTwoGraphState.cs | 14 ++++++++------ 6 files changed, 45 insertions(+), 28 deletions(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 844afe1..a5f004d 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -19,14 +19,15 @@ namespace grapher ChartXY gainChart, ToolStripMenuItem enableVelocityAndGain, ToolStripMenuItem enableLastMouseMove, - Button writeButton) + Button writeButton, + AccelCalculator accelCalculator) { var estimated = new EstimatedPoints(); var estimatedX = new EstimatedPoints(); var estimatedY = new EstimatedPoints(); SetupCharts(sensitivityChart, velocityChart, gainChart, estimated, estimatedX, estimatedY); var accelData = new AccelData(estimated, estimatedX, estimatedY); - ChartStateManager = new ChartStateManager(sensitivityChart, velocityChart, gainChart, accelData); + ChartStateManager = new ChartStateManager(sensitivityChart, velocityChart, gainChart, accelData, accelCalculator); ContainingForm = form; EnableVelocityAndGain = enableVelocityAndGain; @@ -63,7 +64,7 @@ namespace grapher { get { - return ChartState.AccelData; + return ChartState.Data; } } diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index cc334ac..99f44ff 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -15,12 +15,14 @@ namespace grapher.Models.Charts.ChartState ChartXY sensitivityChart, ChartXY velocityChart, ChartXY gainChart, - AccelData accelData) + AccelData accelData, + AccelCalculator calculator) { SensitivityChart = sensitivityChart; VelocityChart = velocityChart; GainChart = gainChart; - AccelData = accelData; + Data = accelData; + Calculator = calculator; } public ChartXY SensitivityChart { get; } @@ -29,7 +31,9 @@ namespace grapher.Models.Charts.ChartState public ChartXY GainChart { get; } - public AccelData AccelData { get; } + public AccelData Data { get; } + + public AccelCalculator Calculator { get; } public virtual DriverSettings Settings { get; set; } @@ -39,6 +43,8 @@ namespace grapher.Models.Charts.ChartState public abstract void Activate(); + public abstract void Calculate(); + public void DrawLastMovement() { SensitivityChart.DrawLastMovementValue(); diff --git a/grapher/Models/Charts/ChartState/ChartStateManager.cs b/grapher/Models/Charts/ChartState/ChartStateManager.cs index b64b1a2..54d2e81 100644 --- a/grapher/Models/Charts/ChartState/ChartStateManager.cs +++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs @@ -14,25 +14,29 @@ namespace grapher.Models.Charts.ChartState ChartXY sensitivityChart, ChartXY velocityChart, ChartXY gainChat, - AccelData accelData) + AccelData accelData, + AccelCalculator accelCalculator) { CombinedState = new CombinedState( sensitivityChart, velocityChart, gainChat, - accelData); + accelData, + accelCalculator); XYOneGraphState = new XYOneGraphState( sensitivityChart, velocityChart, gainChat, - accelData); + accelData, + accelCalculator); XYTwoGraphState = new XYTwoGraphState( sensitivityChart, velocityChart, gainChat, - accelData); + accelData, + accelCalculator); } private CombinedState CombinedState { get; } diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs index bc8c720..d229a43 100644 --- a/grapher/Models/Charts/ChartState/CombinedState.cs +++ b/grapher/Models/Charts/ChartState/CombinedState.cs @@ -8,12 +8,14 @@ namespace grapher.Models.Charts.ChartState ChartXY sensitivityChart, ChartXY velocityChart, ChartXY gainChart, - AccelData accelData) + AccelData accelData, + AccelCalculator accelCalculator) : base( sensitivityChart, velocityChart, gainChart, - accelData) + accelData, + accelCalculator) { } public override void Activate() @@ -25,14 +27,14 @@ namespace grapher.Models.Charts.ChartState public override void MakeDots(int x, int y, double timeInMs) { - AccelData.CalculateDots(x, y, timeInMs); + Data.CalculateDots(x, y, timeInMs); } public override void Bind() { - SensitivityChart.Bind(AccelData.Combined.AccelPoints); - VelocityChart.Bind(AccelData.Combined.VelocityPoints); - GainChart.Bind(AccelData.Combined.GainPoints); + SensitivityChart.Bind(Data.Combined.AccelPoints); + VelocityChart.Bind(Data.Combined.VelocityPoints); + GainChart.Bind(Data.Combined.GainPoints); } } } diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index 3ed5c5b..bc9a88d 100644 --- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -8,12 +8,14 @@ namespace grapher.Models.Charts.ChartState ChartXY sensitivityChart, ChartXY velocityChart, ChartXY gainChart, - AccelData accelData) + AccelData accelData, + AccelCalculator accelCalculator) : base( sensitivityChart, velocityChart, gainChart, - accelData) + accelData, + accelCalculator) { } public override void Activate() @@ -25,14 +27,14 @@ namespace grapher.Models.Charts.ChartState public override void MakeDots(int x, int y, double timeInMs) { - AccelData.CalculateDotsXY(x, y, timeInMs); + Data.CalculateDotsXY(x, y, timeInMs); } public override void Bind() { - SensitivityChart.BindXY(AccelData.X.AccelPoints, AccelData.Y.AccelPoints); - VelocityChart.BindXY(AccelData.X.VelocityPoints, AccelData.Y.VelocityPoints); - GainChart.BindXY(AccelData.X.GainPoints, AccelData.Y.GainPoints); + SensitivityChart.BindXY(Data.X.AccelPoints, Data.Y.AccelPoints); + VelocityChart.BindXY(Data.X.VelocityPoints, Data.Y.VelocityPoints); + GainChart.BindXY(Data.X.GainPoints, Data.Y.GainPoints); } } } diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs index b54832c..8be88f0 100644 --- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs @@ -12,12 +12,14 @@ namespace grapher.Models.Charts.ChartState ChartXY sensitivityChart, ChartXY velocityChart, ChartXY gainChart, - AccelData accelData) + AccelData accelData, + AccelCalculator accelCalculator) : base( sensitivityChart, velocityChart, gainChart, - accelData) + accelData, + accelCalculator) { } public override DriverSettings Settings @@ -55,14 +57,14 @@ namespace grapher.Models.Charts.ChartState (xCalc, yCalc) = AccelCalculator.StripSens(xCalc, yCalc, Sensitivity.Item1, Sensitivity.Item2); } - AccelData.CalculateDotsXY((int)Math.Round(xCalc), (int)Math.Round(yCalc), timeInMs); + Data.CalculateDotsXY((int)Math.Round(xCalc), (int)Math.Round(yCalc), timeInMs); } public override void Bind() { - SensitivityChart.BindXY(AccelData.X.AccelPoints, AccelData.Y.AccelPoints); - VelocityChart.BindXY(AccelData.X.VelocityPoints, AccelData.Y.VelocityPoints); - GainChart.BindXY(AccelData.X.GainPoints, AccelData.Y.GainPoints); + SensitivityChart.BindXY(Data.X.AccelPoints, Data.Y.AccelPoints); + VelocityChart.BindXY(Data.X.VelocityPoints, Data.Y.VelocityPoints); + GainChart.BindXY(Data.X.GainPoints, Data.Y.GainPoints); } } } -- cgit v1.2.3 From 1dd0c108b8948c50fd8f2b9c9055dbb8e7d47270 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Thu, 17 Sep 2020 23:51:47 -0700 Subject: Add y lines to graphes + further work --- grapher/Models/Charts/AccelCharts.cs | 6 ++++++ grapher/Models/Charts/ChartState/ChartState.cs | 7 ++++++- grapher/Models/Charts/ChartState/CombinedState.cs | 6 ++++++ grapher/Models/Charts/ChartState/XYTwoGraphState.cs | 6 ++++++ 4 files changed, 24 insertions(+), 1 deletion(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index a5f004d..657ae89 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -142,6 +142,12 @@ namespace grapher AlignWriteButton(); } + public void Calculate(ManagedAccel accel, DriverSettings settings) + { + ChartState.SetUpCalculate(settings); + ChartState.Calculate(accel, settings); + } + private static void SetupCharts( ChartXY sensitivityChart, ChartXY velocityChart, diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index 99f44ff..a219cc4 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -43,7 +43,12 @@ namespace grapher.Models.Charts.ChartState public abstract void Activate(); - public abstract void Calculate(); + public abstract void Calculate(ManagedAccel accel, DriverSettings settings); + public virtual void SetUpCalculate(DriverSettings settings) + { + Data.Clear(); + Calculator.ScaleByMouseSettings(); + } public void DrawLastMovement() { diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs index d229a43..c788775 100644 --- a/grapher/Models/Charts/ChartState/CombinedState.cs +++ b/grapher/Models/Charts/ChartState/CombinedState.cs @@ -1,4 +1,5 @@ using grapher.Models.Calculations; +using grapher.Models.Serialized; namespace grapher.Models.Charts.ChartState { @@ -36,5 +37,10 @@ namespace grapher.Models.Charts.ChartState VelocityChart.Bind(Data.Combined.VelocityPoints); GainChart.Bind(Data.Combined.GainPoints); } + + public override void Calculate(ManagedAccel accel, DriverSettings settings) + { + Calculator.Calculate(Data.Combined, accel, settings.sensitivity.x, Calculator.MagnitudesCombined, true, settings); + } } } diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs index 8be88f0..69dc335 100644 --- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs @@ -66,5 +66,11 @@ namespace grapher.Models.Charts.ChartState VelocityChart.BindXY(Data.X.VelocityPoints, Data.Y.VelocityPoints); GainChart.BindXY(Data.X.GainPoints, Data.Y.GainPoints); } + + public override void Calculate(ManagedAccel accel, DriverSettings settings) + { + Calculator.Calculate(Data.X, accel, settings.sensitivity.x, Calculator.MagnitudesX); + Calculator.Calculate(Data.Y, accel, settings.sensitivity.y, Calculator.MagnitudesY); + } } } -- cgit v1.2.3 From 8f5c6c2a733812b19641789e34552afe9e601686 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sat, 19 Sep 2020 19:27:37 -0700 Subject: further work --- grapher/Models/Charts/ChartState/CombinedState.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs index c788775..17cd68a 100644 --- a/grapher/Models/Charts/ChartState/CombinedState.cs +++ b/grapher/Models/Charts/ChartState/CombinedState.cs @@ -40,7 +40,7 @@ namespace grapher.Models.Charts.ChartState public override void Calculate(ManagedAccel accel, DriverSettings settings) { - Calculator.Calculate(Data.Combined, accel, settings.sensitivity.x, Calculator.MagnitudesCombined, true, settings); + Calculator.Calculate(Data.Combined, accel, settings.sensitivity.x, Calculator.MagnitudesCombined); } } } -- cgit v1.2.3 From 2a756dfb08b4f8c0870173ad4e0393cdeef33c94 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sun, 20 Sep 2020 23:16:15 -0700 Subject: Attempt to get separate x/y working --- grapher/Models/Charts/ChartState/XYOneGraphState.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index bc9a88d..c1153c1 100644 --- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -1,4 +1,5 @@ using grapher.Models.Calculations; +using grapher.Models.Serialized; namespace grapher.Models.Charts.ChartState { @@ -27,7 +28,7 @@ namespace grapher.Models.Charts.ChartState public override void MakeDots(int x, int y, double timeInMs) { - Data.CalculateDotsXY(x, y, timeInMs); + Data.CalculateDotsCombinedDiffSens(x, y, timeInMs); } public override void Bind() @@ -36,5 +37,10 @@ namespace grapher.Models.Charts.ChartState VelocityChart.BindXY(Data.X.VelocityPoints, Data.Y.VelocityPoints); GainChart.BindXY(Data.X.GainPoints, Data.Y.GainPoints); } + + public override void Calculate(ManagedAccel accel, DriverSettings settings) + { + Calculator.CalculateCombinedDiffSens(Data, accel, settings, Calculator.MagnitudesCombined); + } } } -- cgit v1.2.3 From ba642cd8c8e63ec3778fa17ecbcd7964074aaba1 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 21 Sep 2020 00:08:19 -0700 Subject: separate x/y mostly works --- grapher/Models/Charts/AccelCharts.cs | 1 + grapher/Models/Charts/ChartState/ChartState.cs | 10 ++++++--- .../Models/Charts/ChartState/XYOneGraphState.cs | 18 ++++++++------- grapher/Models/Charts/ChartXY.cs | 26 ++++++++++++++++++---- 4 files changed, 40 insertions(+), 15 deletions(-) (limited to 'grapher/Models/Charts') diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs index 657ae89..d22ab78 100644 --- a/grapher/Models/Charts/AccelCharts.cs +++ b/grapher/Models/Charts/AccelCharts.cs @@ -98,6 +98,7 @@ namespace grapher private ChartStateManager ChartStateManager { get; } + #endregion Properties #region Methods diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs index a219cc4..ea67e83 100644 --- a/grapher/Models/Charts/ChartState/ChartState.cs +++ b/grapher/Models/Charts/ChartState/ChartState.cs @@ -23,6 +23,7 @@ namespace grapher.Models.Charts.ChartState GainChart = gainChart; Data = accelData; Calculator = calculator; + TwoDotsPerGraph = false; } public ChartXY SensitivityChart { get; } @@ -37,6 +38,8 @@ namespace grapher.Models.Charts.ChartState public virtual DriverSettings Settings { get; set; } + internal bool TwoDotsPerGraph { get; set; } + public abstract void MakeDots(int x, int y, double timeInMs); public abstract void Bind(); @@ -44,6 +47,7 @@ namespace grapher.Models.Charts.ChartState public abstract void Activate(); public abstract void Calculate(ManagedAccel accel, DriverSettings settings); + public virtual void SetUpCalculate(DriverSettings settings) { Data.Clear(); @@ -52,9 +56,9 @@ namespace grapher.Models.Charts.ChartState public void DrawLastMovement() { - SensitivityChart.DrawLastMovementValue(); - VelocityChart.DrawLastMovementValue(); - GainChart.DrawLastMovementValue(); + SensitivityChart.DrawLastMovementValue(TwoDotsPerGraph); + VelocityChart.DrawLastMovementValue(TwoDotsPerGraph); + GainChart.DrawLastMovementValue(TwoDotsPerGraph); } public void SetWidened() diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs index c1153c1..bbc0c28 100644 --- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs +++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs @@ -17,25 +17,27 @@ namespace grapher.Models.Charts.ChartState gainChart, accelData, accelCalculator) - { } + { + TwoDotsPerGraph = true; + } public override void Activate() { - SensitivityChart.SetSeparate(); - VelocityChart.SetSeparate(); - GainChart.SetSeparate(); + SensitivityChart.SetCombined(); + VelocityChart.SetCombined(); + GainChart.SetCombined(); } public override void MakeDots(int x, int y, double timeInMs) { - Data.CalculateDotsCombinedDiffSens(x, y, timeInMs); + Data.CalculateDotsCombinedDiffSens(x, y, timeInMs, Settings); } public override void Bind() { - 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.BindXYCombined(Data.X.AccelPoints, Data.Y.AccelPoints); + VelocityChart.BindXYCombined(Data.X.VelocityPoints, Data.Y.VelocityPoints); + GainChart.BindXYCombined(Data.X.GainPoints, Data.Y.GainPoints); } public override void Calculate(ManagedAccel accel, DriverSettings settings) diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs index 1360409..fdd0258 100644 --- a/grapher/Models/Charts/ChartXY.cs +++ b/grapher/Models/Charts/ChartXY.cs @@ -117,12 +117,17 @@ namespace grapher chart.Titles[0].Font = new System.Drawing.Font(chart.Titles[0].Font.Name, 9.0f, System.Drawing.FontStyle.Italic); } - public static void DrawPoint(Chart chart, PointData point) + public static void DrawPoint(Chart chart, PointData pointOne, PointData pointTwo = null) { if (chart.Visible) { - point.Get(out var x, out var y); + pointOne.Get(out var x, out var y); chart.Series[1].Points.DataBindXY(x, y); + if (pointTwo != null) + { + pointTwo.Get(out x, out y); + chart.Series[3].Points.DataBindXY(x, y); + } chart.Update(); } } @@ -134,11 +139,18 @@ namespace grapher YPointData = y; } - public void DrawLastMovementValue() + public void DrawLastMovementValue(bool twoDotsPerGraph = false) { if(Combined) { - DrawPoint(ChartX, CombinedPointData); + if (twoDotsPerGraph) + { + DrawPoint(ChartX, XPointData, YPointData); + } + else + { + DrawPoint(ChartX, CombinedPointData); + } } else { @@ -164,6 +176,12 @@ namespace grapher ChartY.Series[0].Points.DataBindXY(dataY.Keys, dataY.Values); } + public void BindXYCombined(IDictionary dataX, IDictionary dataY) + { + ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values); + ChartX.Series[2].Points.DataBindXY(dataY.Keys, dataY.Values); + } + public void SetCombined() { if (!Combined) -- cgit v1.2.3