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 ++++++++++++++--------------------- 1 file changed, 80 insertions(+), 116 deletions(-) (limited to 'grapher/Models/Charts/AccelCharts.cs') 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 -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grapher/Models/Charts/AccelCharts.cs') 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 -- 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 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'grapher/Models/Charts/AccelCharts.cs') 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; } } -- 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 ++++++ 1 file changed, 6 insertions(+) (limited to 'grapher/Models/Charts/AccelCharts.cs') 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, -- 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 + 1 file changed, 1 insertion(+) (limited to 'grapher/Models/Charts/AccelCharts.cs') 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 -- cgit v1.2.3