summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grapher/Form1.Designer.cs190
-rw-r--r--grapher/Models/AccelGUI.cs7
-rw-r--r--grapher/Models/AccelGUIFactory.cs11
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs111
-rw-r--r--grapher/Models/Calculations/AccelChartData.cs31
-rw-r--r--grapher/Models/Calculations/AccelData.cs48
-rw-r--r--grapher/Models/Charts/AccelCharts.cs206
-rw-r--r--grapher/Models/Charts/ChartState/ChartState.cs104
-rw-r--r--grapher/Models/Charts/ChartState/ChartStateManager.cs78
-rw-r--r--grapher/Models/Charts/ChartState/CombinedState.cs46
-rw-r--r--grapher/Models/Charts/ChartState/XYOneGraphState.cs48
-rw-r--r--grapher/Models/Charts/ChartState/XYTwoGraphState.cs76
-rw-r--r--grapher/Models/Charts/ChartXY.cs26
-rw-r--r--grapher/Models/Options/ApplyOptions.cs2
-rw-r--r--grapher/grapher.csproj6
15 files changed, 771 insertions, 219 deletions
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index a659c4e..535ee15 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -34,31 +34,40 @@ namespace grapher
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series7 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Title title2 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Title title3 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series7 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series13 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series14 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series15 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Title title4 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend5 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series16 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series17 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series18 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Title title5 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend6 = new System.Windows.Forms.DataVisualization.Charting.Legend();
- System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series();
- System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series19 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series20 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ System.Windows.Forms.DataVisualization.Charting.Series series21 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Title title6 = new System.Windows.Forms.DataVisualization.Charting.Title();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RawAcceleration));
this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
@@ -174,8 +183,19 @@ namespace grapher
series2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
series2.Legend = "Legend1";
series2.Name = "Last Mouse Move";
+ series3.ChartArea = "ChartArea1";
+ series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series3.Legend = "Legend1";
+ series3.Name = "Y: Accelerated Sensitivity";
+ series4.ChartArea = "ChartArea1";
+ series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series4.IsVisibleInLegend = false;
+ series4.Legend = "Legend1";
+ series4.Name = "Y - Last Mouse Move";
this.AccelerationChart.Series.Add(series1);
this.AccelerationChart.Series.Add(series2);
+ this.AccelerationChart.Series.Add(series3);
+ this.AccelerationChart.Series.Add(series4);
this.AccelerationChart.Size = new System.Drawing.Size(698, 328);
this.AccelerationChart.TabIndex = 0;
this.AccelerationChart.Text = "Sensitivity";
@@ -388,17 +408,28 @@ namespace grapher
this.VelocityChart.Legends.Add(legend2);
this.VelocityChart.Location = new System.Drawing.Point(482, 334);
this.VelocityChart.Name = "VelocityChart";
- series3.ChartArea = "ChartArea1";
- series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series3.Legend = "Legend1";
- series3.Name = "Output Velocity";
- series4.ChartArea = "ChartArea1";
- series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series4.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series4.Legend = "Legend1";
- series4.Name = "Last Mouse Move";
- this.VelocityChart.Series.Add(series3);
- this.VelocityChart.Series.Add(series4);
+ series5.ChartArea = "ChartArea1";
+ series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series5.Legend = "Legend1";
+ series5.Name = "Output Velocity";
+ series6.ChartArea = "ChartArea1";
+ series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series6.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series6.Legend = "Legend1";
+ series6.Name = "Last Mouse Move";
+ series7.ChartArea = "ChartArea1";
+ series7.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series7.Legend = "Legend1";
+ series7.Name = "Y: Output Velocity";
+ series8.ChartArea = "ChartArea1";
+ series8.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series8.IsVisibleInLegend = false;
+ series8.Legend = "Legend1";
+ series8.Name = "Y: Last Mouse Move";
+ this.VelocityChart.Series.Add(series5);
+ this.VelocityChart.Series.Add(series6);
+ this.VelocityChart.Series.Add(series7);
+ this.VelocityChart.Series.Add(series8);
this.VelocityChart.Size = new System.Drawing.Size(698, 307);
this.VelocityChart.TabIndex = 28;
this.VelocityChart.Text = "chart1";
@@ -418,17 +449,28 @@ namespace grapher
this.GainChart.Legends.Add(legend3);
this.GainChart.Location = new System.Drawing.Point(482, 647);
this.GainChart.Name = "GainChart";
- series5.ChartArea = "ChartArea1";
- series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series5.Legend = "Legend1";
- series5.Name = "Velocity Gain";
- series6.ChartArea = "ChartArea1";
- series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series6.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series6.Legend = "Legend1";
- series6.Name = "Last Mouse Move";
- this.GainChart.Series.Add(series5);
- this.GainChart.Series.Add(series6);
+ series9.ChartArea = "ChartArea1";
+ series9.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series9.Legend = "Legend1";
+ series9.Name = "Velocity Gain";
+ series10.ChartArea = "ChartArea1";
+ series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series10.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series10.Legend = "Legend1";
+ series10.Name = "Last Mouse Move";
+ series11.ChartArea = "ChartArea1";
+ series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series11.Legend = "Legend1";
+ series11.Name = "Y: Velocity Gain";
+ series12.ChartArea = "ChartArea1";
+ series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series12.IsVisibleInLegend = false;
+ series12.Legend = "Legend1";
+ series12.Name = "Y: Last Mouse Move";
+ this.GainChart.Series.Add(series9);
+ this.GainChart.Series.Add(series10);
+ this.GainChart.Series.Add(series11);
+ this.GainChart.Series.Add(series12);
this.GainChart.Size = new System.Drawing.Size(698, 309);
this.GainChart.TabIndex = 29;
this.GainChart.Text = "chart1";
@@ -627,17 +669,23 @@ namespace grapher
this.AccelerationChartY.Legends.Add(legend4);
this.AccelerationChartY.Location = new System.Drawing.Point(1186, 0);
this.AccelerationChartY.Name = "AccelerationChartY";
- series7.ChartArea = "ChartArea1";
- series7.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series7.Legend = "Legend1";
- series7.Name = "Accelerated Sensitivity";
- series8.ChartArea = "ChartArea1";
- series8.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series8.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series8.Legend = "Legend1";
- series8.Name = "Last Mouse Move";
- this.AccelerationChartY.Series.Add(series7);
- this.AccelerationChartY.Series.Add(series8);
+ series13.ChartArea = "ChartArea1";
+ series13.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series13.Legend = "Legend1";
+ series13.Name = "Accelerated Sensitivity";
+ series14.ChartArea = "ChartArea1";
+ series14.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series14.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series14.Legend = "Legend1";
+ series14.Name = "Last Mouse Move";
+ series15.ChartArea = "ChartArea1";
+ series15.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series15.IsVisibleInLegend = false;
+ series15.Legend = "Legend1";
+ series15.Name = "Placeholder";
+ this.AccelerationChartY.Series.Add(series13);
+ this.AccelerationChartY.Series.Add(series14);
+ this.AccelerationChartY.Series.Add(series15);
this.AccelerationChartY.Size = new System.Drawing.Size(698, 328);
this.AccelerationChartY.TabIndex = 31;
this.AccelerationChartY.Text = "chart1";
@@ -657,17 +705,23 @@ namespace grapher
this.VelocityChartY.Legends.Add(legend5);
this.VelocityChartY.Location = new System.Drawing.Point(1186, 334);
this.VelocityChartY.Name = "VelocityChartY";
- series9.ChartArea = "ChartArea1";
- series9.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series9.Legend = "Legend1";
- series9.Name = "Output Velocity";
- series10.ChartArea = "ChartArea1";
- series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series10.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series10.Legend = "Legend1";
- series10.Name = "Last Mouse Move";
- this.VelocityChartY.Series.Add(series9);
- this.VelocityChartY.Series.Add(series10);
+ series16.ChartArea = "ChartArea1";
+ series16.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series16.Legend = "Legend1";
+ series16.Name = "Output Velocity";
+ series17.ChartArea = "ChartArea1";
+ series17.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series17.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series17.Legend = "Legend1";
+ series17.Name = "Last Mouse Move";
+ series18.ChartArea = "ChartArea1";
+ series18.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series18.IsVisibleInLegend = false;
+ series18.Legend = "Legend1";
+ series18.Name = "Placeholder";
+ this.VelocityChartY.Series.Add(series16);
+ this.VelocityChartY.Series.Add(series17);
+ this.VelocityChartY.Series.Add(series18);
this.VelocityChartY.Size = new System.Drawing.Size(698, 307);
this.VelocityChartY.TabIndex = 32;
this.VelocityChartY.Text = "chart1";
@@ -687,17 +741,23 @@ namespace grapher
this.GainChartY.Legends.Add(legend6);
this.GainChartY.Location = new System.Drawing.Point(1186, 647);
this.GainChartY.Name = "GainChartY";
- series11.ChartArea = "ChartArea1";
- series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
- series11.Legend = "Legend1";
- series11.Name = "Velocity Gain";
- series12.ChartArea = "ChartArea1";
- series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
- series12.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- series12.Legend = "Legend1";
- series12.Name = "Last Mouse Move";
- this.GainChartY.Series.Add(series11);
- this.GainChartY.Series.Add(series12);
+ series19.ChartArea = "ChartArea1";
+ series19.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series19.Legend = "Legend1";
+ series19.Name = "Velocity Gain";
+ series20.ChartArea = "ChartArea1";
+ series20.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
+ series20.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
+ series20.Legend = "Legend1";
+ series20.Name = "Last Mouse Move";
+ series21.ChartArea = "ChartArea1";
+ series21.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series21.IsVisibleInLegend = false;
+ series21.Legend = "Legend1";
+ series21.Name = "Placeholder";
+ this.GainChartY.Series.Add(series19);
+ this.GainChartY.Series.Add(series20);
+ this.GainChartY.Series.Add(series21);
this.GainChartY.Size = new System.Drawing.Size(698, 309);
this.GainChartY.TabIndex = 33;
this.GainChartY.Text = "chart1";
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 3acb943..95d0c25 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -96,14 +96,13 @@ namespace grapher
public void RefreshOnRead()
{
- UpdateGraph();
UpdateShownActiveValues();
+ UpdateGraph();
}
public void UpdateGraph()
{
- AccelCalculator.Calculate(
- AccelCharts.AccelData,
+ AccelCharts.Calculate(
Settings.ActiveAccel,
Settings.RawAccelSettings.AccelerationSettings);
AccelCharts.Bind();
@@ -128,7 +127,7 @@ namespace grapher
private void SetupWriteButton()
{
- WriteButton.Top = AccelCharts.SensitivityChart.Top + AccelCharts.SensitivityChart.Height - Constants.WriteButtonVerticalOffset;
+ WriteButton.Top = AccelCharts.Top + AccelCharts.TopChartHeight - Constants.WriteButtonVerticalOffset;
SetWriteButtonDefault();
}
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
index 526e399..eb30864 100644
--- a/grapher/Models/AccelGUIFactory.cs
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -89,6 +89,10 @@ namespace grapher.Models
Label optionSetYTitle,
Label mouseLabel)
{
+ var accelCalculator = new AccelCalculator(
+ new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI),
+ new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate));
+
var accelCharts = new AccelCharts(
form,
new ChartXY(accelerationChart, accelerationChartY, Constants.SensitivityChartTitle),
@@ -96,7 +100,8 @@ namespace grapher.Models
new ChartXY(gainChart, gainChartY, Constants.GainChartTitle),
showVelocityGainToolStripMenuItem,
showLastMouseMoveMenuItem,
- writeButton);
+ writeButton,
+ accelCalculator);
var sensitivity = new OptionXY(
sensitivityBoxX,
@@ -276,10 +281,6 @@ namespace grapher.Models
lockXYLabel,
accelCharts);
- var accelCalculator = new AccelCalculator(
- new Field(dpiTextBox.TextBox, form, Constants.DefaultDPI),
- new Field(pollRateTextBox.TextBox, form, Constants.DefaultPollRate));
-
var settings = new SettingsManager(
activeAccel,
accelCalculator.DPI,
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index 7293681..8865939 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -49,20 +49,13 @@ namespace grapher.Models.Calculations
private double MeasurementTime { get; set; }
- #endregion Fields
-
- #region Methods
+ private (double, double) RotationVector { get; set; }
- public void Calculate(AccelData data, ManagedAccel accel, DriverSettings settings)
- {
- ScaleByMouseSettings();
+ private (double, double) Sensitivity { get; set; }
- data.Clear();
+ #endregion Fields
- Calculate(data.Combined, accel, settings.sensitivity.x, MagnitudesCombined);
- Calculate(data.X, accel, settings.sensitivity.x, MagnitudesX);
- Calculate(data.Y, accel, settings.sensitivity.y, MagnitudesY);
- }
+ #region Methods
public void Calculate(AccelChartData data, ManagedAccel accel, double starter, ICollection<MagnitudeData> magnitudeData)
{
@@ -72,7 +65,6 @@ namespace grapher.Models.Calculations
foreach (var magnitudeDatum in magnitudeData)
{
var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime);
-
var outMagnitude = Magnitude(output.Item1, output.Item2);
var ratio = magnitudeDatum.magnitude > 0 ? outMagnitude / magnitudeDatum.magnitude : starter;
@@ -103,6 +95,77 @@ namespace grapher.Models.Calculations
data.OrderedVelocityPointsList.AddRange(data.VelocityPoints.Values.ToList());
}
+ public void CalculateCombinedDiffSens(AccelData data, ManagedAccel accel, DriverSettings settings, ICollection<MagnitudeData> magnitudeData)
+ {
+ double lastInputMagnitude = 0;
+ double lastOutputMagnitudeX = 0;
+ double lastOutputMagnitudeY = 0;
+
+ Sensitivity = GetSens(ref settings);
+
+ foreach (var magnitudeDatum in magnitudeData)
+ {
+ var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime);
+ var outputWithoutSens = StripThisSens(output.Item1, output.Item2);
+ var magnitudeWithoutSens = Magnitude(outputWithoutSens.Item1, outputWithoutSens.Item2);
+
+ var ratio = magnitudeDatum.magnitude > 0 ? magnitudeWithoutSens / magnitudeDatum.magnitude : 1;
+
+ if (!data.Combined.VelocityPoints.ContainsKey(magnitudeDatum.magnitude))
+ {
+ data.Combined.VelocityPoints.Add(magnitudeDatum.magnitude, magnitudeWithoutSens);
+ }
+
+ var xRatio = settings.sensitivity.x * ratio;
+ var yRatio = settings.sensitivity.y * ratio;
+
+ if (!data.X.AccelPoints.ContainsKey(magnitudeDatum.magnitude))
+ {
+ data.X.AccelPoints.Add(magnitudeDatum.magnitude, xRatio);
+ }
+
+ if (!data.Y.AccelPoints.ContainsKey(magnitudeDatum.magnitude))
+ {
+ data.Y.AccelPoints.Add(magnitudeDatum.magnitude, yRatio);
+ }
+
+ var xOut = xRatio * magnitudeDatum.magnitude;
+ var yOut = yRatio * magnitudeDatum.magnitude;
+
+ var inDiff = magnitudeDatum.magnitude - lastInputMagnitude;
+ var xOutDiff = xOut - lastOutputMagnitudeX;
+ var yOutDiff = yOut - lastOutputMagnitudeY;
+ var xSlope = inDiff > 0 ? xOutDiff / inDiff : settings.sensitivity.x;
+ var ySlope = inDiff > 0 ? yOutDiff / inDiff : settings.sensitivity.y;
+
+ if (!data.X.VelocityPoints.ContainsKey(magnitudeDatum.magnitude))
+ {
+ data.X.VelocityPoints.Add(magnitudeDatum.magnitude, xOut);
+ }
+
+ if (!data.Y.VelocityPoints.ContainsKey(magnitudeDatum.magnitude))
+ {
+ data.Y.VelocityPoints.Add(magnitudeDatum.magnitude, yOut);
+ }
+
+ if (!data.X.GainPoints.ContainsKey(magnitudeDatum.magnitude))
+ {
+ data.X.GainPoints.Add(magnitudeDatum.magnitude, xSlope);
+ }
+
+ if (!data.Y.GainPoints.ContainsKey(magnitudeDatum.magnitude))
+ {
+ data.Y.GainPoints.Add(magnitudeDatum.magnitude, ySlope);
+ }
+
+ lastInputMagnitude = magnitudeDatum.magnitude;
+ lastOutputMagnitudeX = xOut;
+ lastOutputMagnitudeY = yOut;
+ }
+
+ data.Combined.OrderedVelocityPointsList.AddRange(data.Combined.VelocityPoints.Values.ToList());
+ }
+
public ReadOnlyCollection<MagnitudeData> GetMagnitudes()
{
var magnitudes = new List<MagnitudeData>();
@@ -175,6 +238,30 @@ namespace grapher.Models.Calculations
return Magnitude(x, y) / time;
}
+ public static bool ShouldStripSens(ref DriverSettings settings) =>
+ settings.sensitivity.x != settings.sensitivity.y;
+
+ public static bool ShouldStripRot(ref DriverSettings settings) =>
+ settings.rotation > 0;
+
+ public static (double, double) GetSens(ref DriverSettings settings) =>
+ (settings.sensitivity.x, settings.sensitivity.y);
+
+ public static (double, double) GetRotVector(ref DriverSettings settings) =>
+ (Math.Cos(settings.rotation), Math.Sin(settings.rotation));
+
+ public static (double, double) StripSens(double outputX, double outputY, double sensitivityX, double sensitivityY) =>
+ (outputX / sensitivityX, outputY / sensitivityY);
+
+ public (double, double) StripRot(double outputX, double outputY, double rotX, double rotY) =>
+ (outputX * rotX + outputY * rotY, outputX * rotY - outputY * rotX);
+
+ public (double, double) StripThisSens(double outputX, double outputY) =>
+ StripSens(outputX, outputY, Sensitivity.Item1, Sensitivity.Item2);
+
+ public (double, double) StripThisRot(double outputX, double outputY) =>
+ StripRot(outputX, outputY, RotationVector.Item1, RotationVector.Item2);
+
public void ScaleByMouseSettings()
{
var dpiPollFactor = DPI.Data / PollRate.Data;
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs
index 8c0c8ea..fbf1944 100644
--- a/grapher/Models/Calculations/AccelChartData.cs
+++ b/grapher/Models/Calculations/AccelChartData.cs
@@ -52,12 +52,7 @@ namespace grapher.Models.Calculations
}
else
{
- var velIdx = OrderedVelocityPointsList.BinarySearch(outVelocityValue);
-
- if (velIdx < 0)
- {
- velIdx = ~velIdx;
- }
+ var velIdx = GetVelocityIndex(outVelocityValue);
velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
values = (VelocityPoints.ElementAt(velIdx).Key, AccelPoints.ElementAt(velIdx).Value, GainPoints.ElementAt(velIdx).Value);
@@ -66,6 +61,30 @@ namespace grapher.Models.Calculations
}
}
+ public (double, double, double) ValuesAtIndex(int index)
+ {
+ return (AccelPoints.ElementAt(index).Value, VelocityPoints.ElementAt(index).Value, GainPoints.ElementAt(index).Value);
+ }
+
+ public (double, double, double) ValuesAtInVelocity(double inVelocity)
+ {
+ return (AccelPoints[inVelocity], VelocityPoints[inVelocity], GainPoints[inVelocity]);
+ }
+
+ public int GetVelocityIndex(double outVelocityValue)
+ {
+ var velIdx = OrderedVelocityPointsList.BinarySearch(outVelocityValue);
+
+ if (velIdx < 0)
+ {
+ velIdx = ~velIdx;
+ }
+
+ velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
+
+ return velIdx;
+ }
+
#endregion Methods
}
}
diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs
index eef4d01..67d4f3f 100644
--- a/grapher/Models/Calculations/AccelData.cs
+++ b/grapher/Models/Calculations/AccelData.cs
@@ -1,5 +1,8 @@
using grapher.Models.Charts;
+using grapher.Models.Serialized;
using System;
+using System.Collections.Generic;
+using System.Linq;
namespace grapher.Models.Calculations
{
@@ -19,6 +22,8 @@ namespace grapher.Models.Calculations
Estimated = combined;
EstimatedX = x;
EstimatedY = y;
+
+ OutVelocityToPoints = new Dictionary<double, (double, double, double, double, double, double, double)>();
}
#endregion Constructors
@@ -37,6 +42,8 @@ namespace grapher.Models.Calculations
private EstimatedPoints EstimatedY { get; }
+ private Dictionary<double, (double, double, double, double, double, double, double)> OutVelocityToPoints { get; }
+
#endregion Properties
#region Methods
@@ -46,22 +53,23 @@ namespace grapher.Models.Calculations
Combined.Clear();
X.Clear();
Y.Clear();
+ OutVelocityToPoints.Clear();
}
public void CalculateDots(int x, int y, double timeInMs)
{
- var magnitude = AccelCalculator.Velocity(x, y, timeInMs);
+ var outVelocity = AccelCalculator.Velocity(x, y, timeInMs);
- (var inCombVel, var combSens, var combGain) = Combined.FindPointValuesFromOut(magnitude);
- Estimated.Velocity.Set(inCombVel, magnitude);
+ (var inCombVel, var combSens, var combGain) = Combined.FindPointValuesFromOut(outVelocity);
+ Estimated.Velocity.Set(inCombVel, outVelocity);
Estimated.Sensitivity.Set(inCombVel, combSens);
Estimated.Gain.Set(inCombVel, combGain);
}
public void CalculateDotsXY(int x, int y, double timeInMs)
{
- var outX = Math.Abs(x);
- var outY = Math.Abs(y);
+ var outX = Math.Abs(x) / timeInMs;
+ var outY = Math.Abs(y) / timeInMs;
(var inXVelocity, var xSensitivity, var xGain) = X.FindPointValuesFromOut(outX);
EstimatedX.Velocity.Set(inXVelocity, outX);
@@ -74,6 +82,36 @@ namespace grapher.Models.Calculations
EstimatedY.Gain.Set(inYVelocity, yGain);
}
+ public void CalculateDotsCombinedDiffSens(int x, int y, double timeInMs, DriverSettings settings)
+ {
+ (var xStripped, var yStripped) = AccelCalculator.StripSens(x, y, settings.sensitivity.x, settings.sensitivity.y);
+ var outVelocity = AccelCalculator.Velocity(xStripped, yStripped, timeInMs);
+
+ if (OutVelocityToPoints.TryGetValue(outVelocity, out var points))
+ {
+ EstimatedX.Sensitivity.Set(points.Item1, points.Item2);
+ EstimatedX.Velocity.Set(points.Item1, points.Item3);
+ EstimatedX.Gain.Set(points.Item1, points.Item4);
+ EstimatedY.Sensitivity.Set(points.Item1, points.Item5);
+ EstimatedY.Velocity.Set(points.Item1, points.Item6);
+ EstimatedY.Gain.Set(points.Item1, points.Item7);
+ }
+ else
+ {
+ var index = Combined.GetVelocityIndex(outVelocity);
+ var inVelocity = Combined.VelocityPoints.ElementAt(index).Key;
+ var xPoints = X.ValuesAtIndex(index);
+ var yPoints = Y.ValuesAtIndex(index);
+ OutVelocityToPoints.Add(outVelocity, (inVelocity, xPoints.Item1, xPoints.Item2, xPoints.Item3, yPoints.Item1, yPoints.Item2, yPoints.Item3));
+ EstimatedX.Sensitivity.Set(inVelocity, xPoints.Item1);
+ EstimatedX.Velocity.Set(inVelocity, xPoints.Item2);
+ EstimatedX.Gain.Set(inVelocity, xPoints.Item3);
+ EstimatedY.Sensitivity.Set(inVelocity, yPoints.Item1);
+ EstimatedY.Velocity.Set(inVelocity, yPoints.Item2);
+ EstimatedY.Gain.Set(inVelocity, yPoints.Item3);
+ }
+ }
+
#endregion Methods
}
}
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index 3f228c3..d22ab78 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;
@@ -18,56 +19,40 @@ namespace grapher
ChartXY gainChart,
ToolStripMenuItem enableVelocityAndGain,
ToolStripMenuItem enableLastMouseMove,
- Button writeButton)
+ Button writeButton,
+ AccelCalculator accelCalculator)
{
- 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, accelCalculator);
- 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);
EnableLastValue.CheckedChanged += new System.EventHandler(OnEnableLastMouseMoveCheckStateChange);
+ ChartState = ChartStateManager.InitialState();
+ ChartState.Activate();
HideVelocityAndGain();
- SensitivityChart.Show();
- Combined = false;
- ShowCombined();
}
#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 +60,116 @@ namespace grapher
private Button WriteButton { get; }
- public AccelData AccelData { get; }
-
- private EstimatedPoints Estimated { get; }
+ public AccelData AccelData
+ {
+ get
+ {
+ return ChartState.Data;
+ }
+ }
- 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();
}
+ public void Calculate(ManagedAccel accel, DriverSettings settings)
+ {
+ ChartState.SetUpCalculate(settings);
+ ChartState.Calculate(accel, settings);
+ }
+
+ 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 +191,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..ea67e83
--- /dev/null
+++ b/grapher/Models/Charts/ChartState/ChartState.cs
@@ -0,0 +1,104 @@
+using grapher.Models.Calculations;
+using grapher.Models.Serialized;
+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,
+ AccelCalculator calculator)
+ {
+ SensitivityChart = sensitivityChart;
+ VelocityChart = velocityChart;
+ GainChart = gainChart;
+ Data = accelData;
+ Calculator = calculator;
+ TwoDotsPerGraph = false;
+ }
+
+ public ChartXY SensitivityChart { get; }
+
+ public ChartXY VelocityChart { get; }
+
+ public ChartXY GainChart { get; }
+
+ public AccelData Data { get; }
+
+ public AccelCalculator Calculator { get; }
+
+ 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();
+
+ public abstract void Activate();
+
+ public abstract void Calculate(ManagedAccel accel, DriverSettings settings);
+
+ public virtual void SetUpCalculate(DriverSettings settings)
+ {
+ Data.Clear();
+ Calculator.ScaleByMouseSettings();
+ }
+
+ public void DrawLastMovement()
+ {
+ SensitivityChart.DrawLastMovementValue(TwoDotsPerGraph);
+ VelocityChart.DrawLastMovementValue(TwoDotsPerGraph);
+ GainChart.DrawLastMovementValue(TwoDotsPerGraph);
+ }
+
+ 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..54d2e81
--- /dev/null
+++ b/grapher/Models/Charts/ChartState/ChartStateManager.cs
@@ -0,0 +1,78 @@
+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,
+ AccelCalculator accelCalculator)
+ {
+ CombinedState = new CombinedState(
+ sensitivityChart,
+ velocityChart,
+ gainChat,
+ accelData,
+ accelCalculator);
+
+ XYOneGraphState = new XYOneGraphState(
+ sensitivityChart,
+ velocityChart,
+ gainChat,
+ accelData,
+ accelCalculator);
+
+ XYTwoGraphState = new XYTwoGraphState(
+ sensitivityChart,
+ velocityChart,
+ gainChat,
+ accelData,
+ accelCalculator);
+ }
+
+ private CombinedState CombinedState { get; }
+
+ private XYOneGraphState XYOneGraphState { get; }
+
+ private XYTwoGraphState XYTwoGraphState { get; }
+
+
+ public ChartState DetermineState(DriverSettings settings)
+ {
+ ChartState chartState;
+
+ if (settings.combineMagnitudes)
+ {
+ if (settings.sensitivity.x != settings.sensitivity.y)
+ {
+ chartState = XYOneGraphState;
+ }
+ else
+ {
+ chartState = CombinedState;
+ }
+ }
+ else
+ {
+ chartState = XYTwoGraphState;
+ }
+
+ chartState.Settings = settings;
+ return chartState;
+ }
+
+ 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..17cd68a
--- /dev/null
+++ b/grapher/Models/Charts/ChartState/CombinedState.cs
@@ -0,0 +1,46 @@
+using grapher.Models.Calculations;
+using grapher.Models.Serialized;
+
+namespace grapher.Models.Charts.ChartState
+{
+ public class CombinedState : ChartState
+ {
+ public CombinedState(
+ ChartXY sensitivityChart,
+ ChartXY velocityChart,
+ ChartXY gainChart,
+ AccelData accelData,
+ AccelCalculator accelCalculator)
+ : base(
+ sensitivityChart,
+ velocityChart,
+ gainChart,
+ accelData,
+ accelCalculator)
+ { }
+
+ public override void Activate()
+ {
+ SensitivityChart.SetCombined();
+ VelocityChart.SetCombined();
+ GainChart.SetCombined();
+ }
+
+ public override void MakeDots(int x, int y, double timeInMs)
+ {
+ Data.CalculateDots(x, y, timeInMs);
+ }
+
+ public override void Bind()
+ {
+ SensitivityChart.Bind(Data.Combined.AccelPoints);
+ 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);
+ }
+ }
+}
diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
new file mode 100644
index 0000000..bbc0c28
--- /dev/null
+++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
@@ -0,0 +1,48 @@
+using grapher.Models.Calculations;
+using grapher.Models.Serialized;
+
+namespace grapher.Models.Charts.ChartState
+{
+ public class XYOneGraphState : ChartState
+ {
+ public XYOneGraphState(
+ ChartXY sensitivityChart,
+ ChartXY velocityChart,
+ ChartXY gainChart,
+ AccelData accelData,
+ AccelCalculator accelCalculator)
+ : base(
+ sensitivityChart,
+ velocityChart,
+ gainChart,
+ accelData,
+ accelCalculator)
+ {
+ TwoDotsPerGraph = true;
+ }
+
+ public override void Activate()
+ {
+ SensitivityChart.SetCombined();
+ VelocityChart.SetCombined();
+ GainChart.SetCombined();
+ }
+
+ public override void MakeDots(int x, int y, double timeInMs)
+ {
+ Data.CalculateDotsCombinedDiffSens(x, y, timeInMs, Settings);
+ }
+
+ public override void Bind()
+ {
+ 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)
+ {
+ Calculator.CalculateCombinedDiffSens(Data, accel, settings, Calculator.MagnitudesCombined);
+ }
+ }
+}
diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
new file mode 100644
index 0000000..69dc335
--- /dev/null
+++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
@@ -0,0 +1,76 @@
+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,
+ ChartXY gainChart,
+ AccelData accelData,
+ AccelCalculator accelCalculator)
+ : base(
+ sensitivityChart,
+ velocityChart,
+ gainChart,
+ accelData,
+ accelCalculator)
+ { }
+
+ 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();
+ VelocityChart.SetSeparate();
+ GainChart.SetSeparate();
+ }
+
+ public override void MakeDots(int x, int y, double timeInMs)
+ {
+ double xCalc = x;
+ double yCalc = y;
+
+ if (ShouldStripSens)
+ {
+ (xCalc, yCalc) = AccelCalculator.StripSens(xCalc, yCalc, Sensitivity.Item1, Sensitivity.Item2);
+ }
+
+ Data.CalculateDotsXY((int)Math.Round(xCalc), (int)Math.Round(yCalc), timeInMs);
+ }
+
+ 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);
+ }
+
+ 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);
+ }
+ }
+}
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)
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index 241fe50..6ec9d31 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -227,7 +227,7 @@ namespace grapher.Models.Options
private void SetActiveTitlesWhole()
{
OptionSetX.ActiveValuesTitle.Left = OptionSetX.Options.Left + OptionSetX.Options.Width;
- LockXYLabel.Width = (AccelCharts.SensitivityChart.Left - OptionSetX.ActiveValuesTitle.Left) / 2;
+ LockXYLabel.Width = (AccelCharts.Left - OptionSetX.ActiveValuesTitle.Left) / 2;
OptionSetX.ActiveValuesTitle.Width = LockXYLabel.Width;
LockXYLabel.Left = OptionSetX.ActiveValuesTitle.Left + OptionSetX.ActiveValuesTitle.Width;
Sensitivity.Fields.LockCheckBox.Left = LockXYLabel.Left + LockXYLabel.Width / 2 - Sensitivity.Fields.LockCheckBox.Width / 2;
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index b81a310..ebe224a 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -64,7 +64,12 @@
<Compile Include="Models\Calculations\AccelData.cs" />
<Compile Include="Models\Charts\AccelCharts.cs" />
<Compile Include="Models\AccelGUI.cs" />
+ <Compile Include="Models\Charts\ChartState\ChartState.cs" />
+ <Compile Include="Models\Charts\ChartState\ChartStateManager.cs" />
+ <Compile Include="Models\Charts\ChartState\CombinedState.cs" />
<Compile Include="Models\Charts\EstimatedPoints.cs" />
+ <Compile Include="Models\Charts\ChartState\XYOneGraphState.cs" />
+ <Compile Include="Models\Charts\ChartState\XYTwoGraphState.cs" />
<Compile Include="Models\Mouse\MouseWatcher.cs" />
<Compile Include="Models\Mouse\PointData.cs" />
<Compile Include="Models\Options\AccelTypeOptions.cs" />
@@ -134,6 +139,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <Folder Include="Icon\" />
<Folder Include="ReadMe\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />