diff options
| author | Jacob Palecki <[email protected]> | 2020-09-16 01:20:23 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-16 01:20:23 -0700 |
| commit | 05c7094a93c7d29eb8ac05247110995574a7b963 (patch) | |
| tree | 8bf2845cc7f33d2e20399001d2724510cf35336a /grapher/Models/Charts/ChartState | |
| parent | Fix box write (diff) | |
| download | rawaccel-05c7094a93c7d29eb8ac05247110995574a7b963.tar.xz rawaccel-05c7094a93c7d29eb8ac05247110995574a7b963.zip | |
Unsure if I will use this
Diffstat (limited to 'grapher/Models/Charts/ChartState')
| -rw-r--r-- | grapher/Models/Charts/ChartState/ChartState.cs | 86 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartState/ChartStateManager.cs | 68 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartState/CombinedState.cs | 38 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartState/XYOneGraphState.cs | 20 | ||||
| -rw-r--r-- | grapher/Models/Charts/ChartState/XYTwoGraphState.cs | 38 |
5 files changed, 250 insertions, 0 deletions
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); + } + } +} |