From f3740b21ad9c08d23368826d1de9eed9a89d9a11 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sun, 2 Aug 2020 14:03:55 -0700 Subject: Move logic out of forms class into accelgui class --- grapher/AccelGUI.cs | 151 ++++++++++++++++++++++++++++++++++++++++++++++ grapher/Form1.cs | 161 ++++++++++++++----------------------------------- grapher/grapher.csproj | 1 + 3 files changed, 198 insertions(+), 115 deletions(-) create mode 100644 grapher/AccelGUI.cs diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs new file mode 100644 index 0000000..d372869 --- /dev/null +++ b/grapher/AccelGUI.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; + +namespace grapher +{ + public class AccelGUI + { + public struct MagnitudeData + { + public double magnitude; + public int x; + public int y; + } + + public static ReadOnlyCollection Magnitudes = GetMagnitudes(); + + #region constructors + + public AccelGUI( + RawAcceleration accelForm, + Chart accelerationChart, + ManagedAccel managedAccel, + AccelOptions accelOptions, + OptionXY sensitivity, + Option rotation, + OptionXY weight, + OptionXY cap, + Option offset, + Option acceleration, + Option limtOrExp, + Option midpoint) + { + AccelForm = accelForm; + AccelChart = accelerationChart; + ManagedAcceleration = managedAccel; + AccelerationOptions = accelOptions; + Sensitivity = sensitivity; + Rotation = rotation; + Weight = weight; + Cap = cap; + Offset = offset; + Acceleration = acceleration; + LimitOrExponent = limtOrExp; + Midpoint = midpoint; + + UpdateGraph(); + } + + #endregion constructors + + #region properties + + public RawAcceleration AccelForm { get; } + + public Chart AccelChart { get; } + + public ManagedAccel ManagedAcceleration { get; } + + public AccelOptions AccelerationOptions { get; } + + public OptionXY Sensitivity { get; } + + public Option Rotation { get; } + + public OptionXY Weight { get; } + + public OptionXY Cap { get; } + + public Option Offset { get; } + + public Option Acceleration { get; } + + public Option LimitOrExponent { get; } + + public Option Midpoint { get; } + + public Button WriteButton { get; } + + #endregion properties + + #region methods + + public static ReadOnlyCollection GetMagnitudes() + { + var magnitudes = new List(); + for (int i = 0; i < 100; i++) + { + for (int j = 0; j <= i; j++) + { + MagnitudeData magnitudeData; + magnitudeData.magnitude = Magnitude(i, j); + magnitudeData.x = i; + magnitudeData.y = j; + magnitudes.Add(magnitudeData); + } + } + + magnitudes.Sort((m1, m2) => m1.magnitude.CompareTo(m2.magnitude)); + + return magnitudes.AsReadOnly(); + } + + public static double Magnitude(int x, int y) + { + return Math.Sqrt(x * x + y * y); + } + + public static double Magnitude(double x, double y) + { + return Math.Sqrt(x * x + y * y); + } + + public void UpdateGraph() + { + var orderedPoints = new SortedDictionary(); + + foreach (var magnitudeData in Magnitudes) + { + var output = ManagedAcceleration.Accelerate(magnitudeData.x, magnitudeData.y, 1); + + var outMagnitude = Magnitude(output.Item1, output.Item2); + var ratio = magnitudeData.magnitude > 0 ? outMagnitude / magnitudeData.magnitude : Sensitivity.Fields.X; + + if (!orderedPoints.ContainsKey(magnitudeData.magnitude)) + { + orderedPoints.Add(magnitudeData.magnitude, ratio); + } + } + + var series = AccelChart.Series.FirstOrDefault(); + series.Points.Clear(); + + foreach (var point in orderedPoints) + { + series.Points.AddXY(point.Key, point.Value); + } + + } + + + #endregion methods + + } + +} diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 3807d2a..1cbd6c9 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -55,16 +55,9 @@ namespace grapher public partial class RawAcceleration : Form { - public struct MagnitudeData - { - public double magnitude; - public int x; - public int y; - } #region Constructor - public static ReadOnlyCollection Magnitudes = GetMagnitudes(); public RawAcceleration() { @@ -90,39 +83,51 @@ namespace grapher IntPtr args_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(args)); Marshal.StructureToPtr(args, args_ptr, false); - ManagedAcceleration = new ManagedAccel(args_ptr); + var managedAcceleration = new ManagedAccel(args_ptr); Marshal.FreeHGlobal(args_ptr); - Sensitivity = new OptionXY(sensitivityBoxX, sensitivityBoxY, sensXYLock, this, 1, sensitivityLabel, "Sensitivity"); - Rotation = new Option(rotationBox, this, 0, rotationLabel, "Rotation"); - Weight = new OptionXY(weightBoxFirst, weightBoxSecond, weightXYLock, this, 1, weightLabel, "Weight"); - Cap = new OptionXY(capBoxX, capBoxY, capXYLock, this, 0, capLabel, "Cap"); - Offset = new Option(offsetBox, this, 0, offsetLabel, "Offset"); + var sensitivity = new OptionXY(sensitivityBoxX, sensitivityBoxY, sensXYLock, this, 1, sensitivityLabel, "Sensitivity"); + var rotation = new Option(rotationBox, this, 0, rotationLabel, "Rotation"); + var weight = new OptionXY(weightBoxFirst, weightBoxSecond, weightXYLock, this, 1, weightLabel, "Weight"); + var cap = new OptionXY(capBoxX, capBoxY, capXYLock, this, 0, capLabel, "Cap"); + var offset = new Option(offsetBox, this, 0, offsetLabel, "Offset"); // The name and layout of these options is handled by AccelerationOptions object. - Acceleration = new Option(new Field(accelerationBox, this, 0), constantOneLabel); - LimitOrExponent = new Option(new Field(limitBox, this, 2), constantTwoLabel); - Midpoint = new Option(new Field(midpointBox, this, 0), constantThreeLabel); + var acceleration = new Option(new Field(accelerationBox, this, 0), constantOneLabel); + var limitOrExponent = new Option(new Field(limitBox, this, 2), constantTwoLabel); + var midpoint = new Option(new Field(midpointBox, this, 0), constantThreeLabel); - AccelerationOptions = new AccelOptions( + var accelerationOptions = new AccelOptions( accelTypeDrop, new Option[] { - Offset, - Acceleration, - LimitOrExponent, - Midpoint, + offset, + acceleration, + limitOrExponent, + midpoint, }, new OptionXY[] { - Weight, - Cap, + weight, + cap, }, writeButton); - UpdateGraph(); - + AccelGUI = new AccelGUI( + this, + AccelerationChart, + managedAcceleration, + accelerationOptions, + sensitivity, + rotation, + weight, + cap, + offset, + acceleration, + limitOrExponent, + midpoint); + this.AccelerationChart.ChartAreas[0].AxisX.RoundAxisValues(); this.AccelerationChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; @@ -147,108 +152,34 @@ namespace grapher #region Properties - public ManagedAccel ManagedAcceleration { get; set; } - - private AccelOptions AccelerationOptions { get; set; } - - private OptionXY Sensitivity { get; set; } - - private Option Rotation { get; set; } - - private OptionXY Weight { get; set; } - - private OptionXY Cap { get; set; } - - private Option Offset { get; set; } - - private Option Acceleration { get; set; } - - private Option LimitOrExponent { get; set; } - - private Option Midpoint { get; set; } + public AccelGUI AccelGUI { get; } #endregion Properties #region Methods - public static ReadOnlyCollection GetMagnitudes() - { - var magnitudes = new List(); - for (int i = 0; i < 100; i++) - { - for (int j = 0; j <= i; j++) - { - MagnitudeData magnitudeData; - magnitudeData.magnitude = Magnitude(i, j); - magnitudeData.x = i; - magnitudeData.y = j; - magnitudes.Add(magnitudeData); - } - } - - magnitudes.Sort((m1, m2) => m1.magnitude.CompareTo(m2.magnitude)); - - return magnitudes.AsReadOnly(); - } - - public static double Magnitude(int x, int y) - { - return Math.Sqrt(x * x + y * y); - } - - public static double Magnitude(double x, double y) - { - return Math.Sqrt(x * x + y * y); - } - private void Form1_Load(object sender, EventArgs e) { } - private void UpdateGraph() - { - var orderedPoints = new SortedDictionary(); - - foreach (var magnitudeData in Magnitudes) - { - var output = ManagedAcceleration.Accelerate(magnitudeData.x, magnitudeData.y, 1); - - var outMagnitude = Magnitude(output.Item1, output.Item2); - var ratio = magnitudeData.magnitude > 0 ? outMagnitude / magnitudeData.magnitude : Sensitivity.Fields.X; - - if (!orderedPoints.ContainsKey(magnitudeData.magnitude)) - { - orderedPoints.Add(magnitudeData.magnitude, ratio); - } - } - - var series = this.AccelerationChart.Series.FirstOrDefault(); - series.Points.Clear(); - - foreach (var point in orderedPoints) - { - series.Points.AddXY(point.Key, point.Value); - } - } - private void writeButton_Click(object sender, EventArgs e) { - ManagedAcceleration.UpdateAccel( - AccelerationOptions.AccelerationIndex, - Rotation.Field.Data, - Sensitivity.Fields.X, - Sensitivity.Fields.Y, - Weight.Fields.X, - Weight.Fields.Y, - Cap.Fields.X, - Cap.Fields.Y, - Offset.Field.Data, - Acceleration.Field.Data, - LimitOrExponent.Field.Data, - Midpoint.Field.Data); - ManagedAcceleration.WriteToDriver(); - UpdateGraph(); + AccelGUI.ManagedAcceleration.UpdateAccel( + AccelGUI.AccelerationOptions.AccelerationIndex, + AccelGUI.Rotation.Field.Data, + AccelGUI.Sensitivity.Fields.X, + AccelGUI.Sensitivity.Fields.Y, + AccelGUI.Weight.Fields.X, + AccelGUI.Weight.Fields.Y, + AccelGUI.Cap.Fields.X, + AccelGUI.Cap.Fields.Y, + AccelGUI.Offset.Field.Data, + AccelGUI.Acceleration.Field.Data, + AccelGUI.LimitOrExponent.Field.Data, + AccelGUI.Midpoint.Field.Data); + AccelGUI.ManagedAcceleration.WriteToDriver(); + AccelGUI.UpdateGraph(); } #endregion Methods diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index bd86a0c..4fe8f64 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -47,6 +47,7 @@ + -- cgit v1.2.3 From 529f18bd6ddbcd182fd03a13e3c07dc10162f036 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sun, 2 Aug 2020 15:54:47 -0700 Subject: Add velocity graph --- grapher/AccelGUI.cs | 31 +++++++++++++++++++++++------- grapher/Form1.Designer.cs | 49 +++++++++++++++++++++++++++++++++++------------ grapher/Form1.cs | 21 ++++++++++++++++++++ 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index d372869..9acb38e 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -25,6 +25,7 @@ namespace grapher public AccelGUI( RawAcceleration accelForm, Chart accelerationChart, + Chart velocityChart, ManagedAccel managedAccel, AccelOptions accelOptions, OptionXY sensitivity, @@ -38,6 +39,7 @@ namespace grapher { AccelForm = accelForm; AccelChart = accelerationChart; + VelocityChart = velocityChart; ManagedAcceleration = managedAccel; AccelerationOptions = accelOptions; Sensitivity = sensitivity; @@ -60,6 +62,8 @@ namespace grapher public Chart AccelChart { get; } + public Chart VelocityChart { get; } + public ManagedAccel ManagedAcceleration { get; } public AccelOptions AccelerationOptions { get; } @@ -118,7 +122,8 @@ namespace grapher public void UpdateGraph() { - var orderedPoints = new SortedDictionary(); + var orderedAccelPoints = new SortedDictionary(); + var orderedVelocityPoints = new SortedDictionary(); foreach (var magnitudeData in Magnitudes) { @@ -127,20 +132,32 @@ namespace grapher var outMagnitude = Magnitude(output.Item1, output.Item2); var ratio = magnitudeData.magnitude > 0 ? outMagnitude / magnitudeData.magnitude : Sensitivity.Fields.X; - if (!orderedPoints.ContainsKey(magnitudeData.magnitude)) + if (!orderedAccelPoints.ContainsKey(magnitudeData.magnitude)) + { + orderedAccelPoints.Add(magnitudeData.magnitude, ratio); + } + + if (!orderedVelocityPoints.ContainsKey(magnitudeData.magnitude)) { - orderedPoints.Add(magnitudeData.magnitude, ratio); + orderedVelocityPoints.Add(magnitudeData.magnitude, outMagnitude); } } - var series = AccelChart.Series.FirstOrDefault(); - series.Points.Clear(); + var accelSeries = AccelChart.Series.FirstOrDefault(); + accelSeries.Points.Clear(); - foreach (var point in orderedPoints) + foreach (var point in orderedAccelPoints) { - series.Points.AddXY(point.Key, point.Value); + accelSeries.Points.AddXY(point.Key, point.Value); } + var velSeries = VelocityChart.Series.FirstOrDefault(); + velSeries.Points.Clear(); + + foreach (var point in orderedVelocityPoints) + { + velSeries.Points.AddXY(point.Key, point.Value); + } } diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 667abf1..11b84f9 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -30,6 +30,9 @@ namespace grapher /// private void InitializeComponent() { + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + 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.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 series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); @@ -59,24 +62,26 @@ namespace grapher this.capXYLock = new System.Windows.Forms.CheckBox(); this.weightXYLock = new System.Windows.Forms.CheckBox(); this.LockXYLabel = new System.Windows.Forms.Label(); + this.VelocityChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); this.SuspendLayout(); // // AccelerationChart // - chartArea2.AxisX.Title = "Speed (counts/ms)"; - chartArea2.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea2.Name = "ChartArea1"; - this.AccelerationChart.ChartAreas.Add(chartArea2); - legend2.Name = "Legend1"; - this.AccelerationChart.Legends.Add(legend2); + chartArea1.AxisX.Title = "Speed (counts/ms)"; + chartArea1.AxisY.Title = "Sensitivity (magnitude ratio)"; + chartArea1.Name = "ChartArea1"; + this.AccelerationChart.ChartAreas.Add(chartArea1); + legend1.Name = "Legend1"; + this.AccelerationChart.Legends.Add(legend1); this.AccelerationChart.Location = new System.Drawing.Point(242, 1); this.AccelerationChart.Name = "AccelerationChart"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series2.Legend = "Legend1"; - series2.Name = "Accelerated Sensitivity"; - this.AccelerationChart.Series.Add(series2); + series1.ChartArea = "ChartArea1"; + series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series1.Legend = "Legend1"; + series1.Name = "Accelerated Sensitivity"; + this.AccelerationChart.Series.Add(series1); this.AccelerationChart.Size = new System.Drawing.Size(721, 312); this.AccelerationChart.TabIndex = 0; this.AccelerationChart.Text = "chart1"; @@ -297,11 +302,29 @@ namespace grapher this.LockXYLabel.TabIndex = 27; this.LockXYLabel.Text = "Lock X && Y"; // + // VelocityChart + // + chartArea2.Name = "ChartArea1"; + this.VelocityChart.ChartAreas.Add(chartArea2); + legend2.Name = "Legend1"; + this.VelocityChart.Legends.Add(legend2); + this.VelocityChart.Location = new System.Drawing.Point(242, 319); + this.VelocityChart.Name = "VelocityChart"; + series2.ChartArea = "ChartArea1"; + series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series2.Legend = "Legend1"; + series2.Name = "Mouse Velocity"; + this.VelocityChart.Series.Add(series2); + this.VelocityChart.Size = new System.Drawing.Size(721, 300); + this.VelocityChart.TabIndex = 28; + this.VelocityChart.Text = "chart1"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(963, 312); + this.ClientSize = new System.Drawing.Size(963, 621); + this.Controls.Add(this.VelocityChart); this.Controls.Add(this.LockXYLabel); this.Controls.Add(this.weightXYLock); this.Controls.Add(this.capXYLock); @@ -332,6 +355,7 @@ namespace grapher this.Text = "Raw Acceleration Graph"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -365,6 +389,7 @@ namespace grapher private System.Windows.Forms.CheckBox capXYLock; private System.Windows.Forms.CheckBox weightXYLock; private System.Windows.Forms.Label LockXYLabel; + private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChart; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 1cbd6c9..50d6476 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -117,6 +117,7 @@ namespace grapher AccelGUI = new AccelGUI( this, AccelerationChart, + VelocityChart, managedAcceleration, accelerationOptions, sensitivity, @@ -146,6 +147,26 @@ namespace grapher this.AccelerationChart.ChartAreas[0].CursorX.IsUserEnabled = true; this.AccelerationChart.ChartAreas[0].CursorY.IsUserEnabled = true; + + this.VelocityChart.ChartAreas[0].AxisX.RoundAxisValues(); + + this.VelocityChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; + this.VelocityChart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; + + this.VelocityChart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; + this.VelocityChart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; + + this.VelocityChart.ChartAreas[0].CursorY.Interval = 0.001; + + this.VelocityChart.ChartAreas[0].CursorX.AutoScroll = true; + this.VelocityChart.ChartAreas[0].CursorY.AutoScroll = true; + + this.VelocityChart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; + this.VelocityChart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + + this.VelocityChart.ChartAreas[0].CursorX.IsUserEnabled = true; + this.VelocityChart.ChartAreas[0].CursorY.IsUserEnabled = true; + } #endregion Constructor -- cgit v1.2.3 From 26b8727a8de23f829dbd95d9ec5a7f2713da7eb7 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sun, 2 Aug 2020 18:20:29 -0700 Subject: Add gain and velocity graphs --- grapher/AccelGUI.cs | 31 +++++++++++++++++++++++++++++-- grapher/Form1.Designer.cs | 31 ++++++++++++++++++++++++++++++- grapher/Form1.cs | 21 +++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index 9acb38e..48fad7e 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -26,6 +26,7 @@ namespace grapher RawAcceleration accelForm, Chart accelerationChart, Chart velocityChart, + Chart gainChart, ManagedAccel managedAccel, AccelOptions accelOptions, OptionXY sensitivity, @@ -40,6 +41,7 @@ namespace grapher AccelForm = accelForm; AccelChart = accelerationChart; VelocityChart = velocityChart; + GainChart = gainChart; ManagedAcceleration = managedAccel; AccelerationOptions = accelOptions; Sensitivity = sensitivity; @@ -64,6 +66,8 @@ namespace grapher public Chart VelocityChart { get; } + public Chart GainChart { get; } + public ManagedAccel ManagedAcceleration { get; } public AccelOptions AccelerationOptions { get; } @@ -122,8 +126,12 @@ namespace grapher public void UpdateGraph() { - var orderedAccelPoints = new SortedDictionary(); - var orderedVelocityPoints = new SortedDictionary(); + var orderedAccelPoints = new SortedDictionary(); + var orderedVelocityPoints = new SortedDictionary(); + var orderedGainPoints = new SortedDictionary(); + + double lastInputMagnitude = 0; + double lastOutputMagnitude = 0; foreach (var magnitudeData in Magnitudes) { @@ -132,6 +140,12 @@ namespace grapher var outMagnitude = Magnitude(output.Item1, output.Item2); var ratio = magnitudeData.magnitude > 0 ? outMagnitude / magnitudeData.magnitude : Sensitivity.Fields.X; + var inDiff = magnitudeData.magnitude - lastInputMagnitude; + var outDiff = outMagnitude - lastOutputMagnitude; + var slope = inDiff > 0 ? outDiff / inDiff : Sensitivity.Fields.X; + lastInputMagnitude = magnitudeData.magnitude; + lastOutputMagnitude = outMagnitude; + if (!orderedAccelPoints.ContainsKey(magnitudeData.magnitude)) { orderedAccelPoints.Add(magnitudeData.magnitude, ratio); @@ -141,6 +155,11 @@ namespace grapher { orderedVelocityPoints.Add(magnitudeData.magnitude, outMagnitude); } + + if (!orderedGainPoints.ContainsKey(magnitudeData.magnitude)) + { + orderedGainPoints.Add(magnitudeData.magnitude, slope); + } } var accelSeries = AccelChart.Series.FirstOrDefault(); @@ -158,6 +177,14 @@ namespace grapher { velSeries.Points.AddXY(point.Key, point.Value); } + + var gainSeries = GainChart.Series.FirstOrDefault(); + gainSeries.Points.Clear(); + + foreach (var point in orderedGainPoints) + { + gainSeries.Points.AddXY(point.Key, point.Value); + } } diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index 11b84f9..f7e674d 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -36,6 +36,9 @@ namespace grapher 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 series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + 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 series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.accelTypeDrop = new System.Windows.Forms.ComboBox(); this.sensitivityBoxX = new System.Windows.Forms.TextBox(); @@ -63,8 +66,10 @@ namespace grapher this.weightXYLock = new System.Windows.Forms.CheckBox(); this.LockXYLabel = new System.Windows.Forms.Label(); this.VelocityChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit(); this.SuspendLayout(); // // AccelerationChart @@ -304,6 +309,8 @@ namespace grapher // // VelocityChart // + chartArea2.AxisX.Title = "Speed (count/ms)"; + chartArea2.AxisY.Title = "Output Speed (counts/ms)"; chartArea2.Name = "ChartArea1"; this.VelocityChart.ChartAreas.Add(chartArea2); legend2.Name = "Legend1"; @@ -319,11 +326,31 @@ namespace grapher this.VelocityChart.TabIndex = 28; this.VelocityChart.Text = "chart1"; // + // GainChart + // + chartArea3.AxisX.Title = "Speed (counts/ms)"; + chartArea3.AxisY.Title = "Slope of Velocity Chart"; + chartArea3.Name = "ChartArea1"; + this.GainChart.ChartAreas.Add(chartArea3); + legend3.Name = "Legend1"; + this.GainChart.Legends.Add(legend3); + this.GainChart.Location = new System.Drawing.Point(242, 625); + this.GainChart.Name = "GainChart"; + series3.ChartArea = "ChartArea1"; + series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series3.Legend = "Legend1"; + series3.Name = "Velocity Gain"; + this.GainChart.Series.Add(series3); + this.GainChart.Size = new System.Drawing.Size(721, 300); + this.GainChart.TabIndex = 29; + this.GainChart.Text = "chart1"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(963, 621); + this.ClientSize = new System.Drawing.Size(963, 925); + this.Controls.Add(this.GainChart); this.Controls.Add(this.VelocityChart); this.Controls.Add(this.LockXYLabel); this.Controls.Add(this.weightXYLock); @@ -356,6 +383,7 @@ namespace grapher this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.GainChart)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -390,6 +418,7 @@ namespace grapher private System.Windows.Forms.CheckBox weightXYLock; private System.Windows.Forms.Label LockXYLabel; private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChart; + private System.Windows.Forms.DataVisualization.Charting.Chart GainChart; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 50d6476..fb841e9 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -118,6 +118,7 @@ namespace grapher this, AccelerationChart, VelocityChart, + GainChart, managedAcceleration, accelerationOptions, sensitivity, @@ -148,6 +149,7 @@ namespace grapher this.AccelerationChart.ChartAreas[0].CursorX.IsUserEnabled = true; this.AccelerationChart.ChartAreas[0].CursorY.IsUserEnabled = true; + this.VelocityChart.ChartAreas[0].AxisX.RoundAxisValues(); this.VelocityChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; @@ -167,6 +169,25 @@ namespace grapher this.VelocityChart.ChartAreas[0].CursorX.IsUserEnabled = true; this.VelocityChart.ChartAreas[0].CursorY.IsUserEnabled = true; + + this.GainChart.ChartAreas[0].AxisX.RoundAxisValues(); + + this.GainChart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; + this.GainChart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; + + this.GainChart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01; + this.GainChart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001; + + this.GainChart.ChartAreas[0].CursorY.Interval = 0.001; + + this.GainChart.ChartAreas[0].CursorX.AutoScroll = true; + this.GainChart.ChartAreas[0].CursorY.AutoScroll = true; + + this.GainChart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; + this.GainChart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; + + this.GainChart.ChartAreas[0].CursorX.IsUserEnabled = true; + this.GainChart.ChartAreas[0].CursorY.IsUserEnabled = true; } #endregion Constructor -- cgit v1.2.3 From dba84307479550135db0bccce9554da09c74aa74 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 3 Aug 2020 13:20:17 -0700 Subject: Add tool menu to enable\disable charts --- grapher/AccelCharts.cs | 95 ++++++++++++++++++++++++ grapher/AccelGUI.cs | 20 ++--- grapher/Form1.Designer.cs | 185 +++++++++++++++++++++++++++------------------- grapher/Form1.cs | 9 ++- grapher/Form1.resx | 6 ++ grapher/grapher.csproj | 1 + 6 files changed, 225 insertions(+), 91 deletions(-) create mode 100644 grapher/AccelCharts.cs diff --git a/grapher/AccelCharts.cs b/grapher/AccelCharts.cs new file mode 100644 index 0000000..62c60e5 --- /dev/null +++ b/grapher/AccelCharts.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; + +namespace grapher +{ + public class AccelCharts + { + public const int ChartSeparation = 10; + + /// Needed to show full contents in form. Unsure why. + public const int FormHeightPadding = 35; + + public AccelCharts( + Form form, + Chart sensitivityChart, + Chart velocityChart, + Chart gainChart, + ToolStripMenuItem enableVelocityAndGain) + { + ContaingForm = form; + SensitivityChart = sensitivityChart; + VelocityChart = velocityChart; + GainChart = gainChart; + EnableVelocityAndGain = enableVelocityAndGain; + + SensitivityChart.Top = 0; + VelocityChart.Height = SensitivityChart.Height; + VelocityChart.Top = SensitivityChart.Height + ChartSeparation; + GainChart.Height = SensitivityChart.Height; + GainChart.Top = VelocityChart.Top + VelocityChart.Height + ChartSeparation; + + Rectangle screenRectangle = ContaingForm.RectangleToScreen(ContaingForm.ClientRectangle); + FormBorderHeight = screenRectangle.Top - ContaingForm.Top; + + EnableVelocityAndGain.Click += new System.EventHandler(OnEnableClick); + EnableVelocityAndGain.CheckedChanged += new System.EventHandler(OnEnableCheckStateChange); + + HideVelocityAndGain(); + } + + public Form ContaingForm { get; } + + public Chart SensitivityChart { get; } + + public Chart VelocityChart { get; } + + public Chart GainChart { get; } + + public ToolStripMenuItem EnableVelocityAndGain { get; } + + private int FormBorderHeight { get; } + + private void OnEnableClick(object sender, EventArgs e) + { + EnableVelocityAndGain.Checked = !EnableVelocityAndGain.Checked; + } + + private void OnEnableCheckStateChange(object sender, EventArgs e) + { + if (EnableVelocityAndGain.Checked) + { + ShowVelocityAndGain(); + } + else + { + HideVelocityAndGain(); + } + } + + private void ShowVelocityAndGain() + { + VelocityChart.Show(); + GainChart.Show(); + ContaingForm.Height = SensitivityChart.Height + + ChartSeparation + + VelocityChart.Height + + ChartSeparation + + GainChart.Height + + FormBorderHeight; + } + + private void HideVelocityAndGain() + { + VelocityChart.Hide(); + GainChart.Hide(); + ContaingForm.Height = SensitivityChart.Height + FormBorderHeight; + } + } +} diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index 48fad7e..b8f1bed 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -24,9 +24,7 @@ namespace grapher public AccelGUI( RawAcceleration accelForm, - Chart accelerationChart, - Chart velocityChart, - Chart gainChart, + AccelCharts accelCharts, ManagedAccel managedAccel, AccelOptions accelOptions, OptionXY sensitivity, @@ -39,9 +37,7 @@ namespace grapher Option midpoint) { AccelForm = accelForm; - AccelChart = accelerationChart; - VelocityChart = velocityChart; - GainChart = gainChart; + AccelCharts = accelCharts; ManagedAcceleration = managedAccel; AccelerationOptions = accelOptions; Sensitivity = sensitivity; @@ -62,11 +58,7 @@ namespace grapher public RawAcceleration AccelForm { get; } - public Chart AccelChart { get; } - - public Chart VelocityChart { get; } - - public Chart GainChart { get; } + public AccelCharts AccelCharts { get; } public ManagedAccel ManagedAcceleration { get; } @@ -162,7 +154,7 @@ namespace grapher } } - var accelSeries = AccelChart.Series.FirstOrDefault(); + var accelSeries = AccelCharts.SensitivityChart.Series.FirstOrDefault(); accelSeries.Points.Clear(); foreach (var point in orderedAccelPoints) @@ -170,7 +162,7 @@ namespace grapher accelSeries.Points.AddXY(point.Key, point.Value); } - var velSeries = VelocityChart.Series.FirstOrDefault(); + var velSeries = AccelCharts.VelocityChart.Series.FirstOrDefault(); velSeries.Points.Clear(); foreach (var point in orderedVelocityPoints) @@ -178,7 +170,7 @@ namespace grapher velSeries.Points.AddXY(point.Key, point.Value); } - var gainSeries = GainChart.Series.FirstOrDefault(); + var gainSeries = AccelCharts.GainChart.Series.FirstOrDefault(); gainSeries.Points.Clear(); foreach (var point in orderedGainPoints) diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index f7e674d..1a268d6 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -30,15 +30,15 @@ namespace grapher /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - 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.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 series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); - 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 series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea10 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend10 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea11 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend11 = 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.ChartArea chartArea12 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend12 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.AccelerationChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.accelTypeDrop = new System.Windows.Forms.ComboBox(); this.sensitivityBoxX = new System.Windows.Forms.TextBox(); @@ -67,34 +67,38 @@ namespace grapher this.LockXYLabel = new System.Windows.Forms.Label(); this.VelocityChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.GainChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.graphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showVelocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit(); + this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // AccelerationChart // - chartArea1.AxisX.Title = "Speed (counts/ms)"; - chartArea1.AxisY.Title = "Sensitivity (magnitude ratio)"; - chartArea1.Name = "ChartArea1"; - this.AccelerationChart.ChartAreas.Add(chartArea1); - legend1.Name = "Legend1"; - this.AccelerationChart.Legends.Add(legend1); - this.AccelerationChart.Location = new System.Drawing.Point(242, 1); + chartArea10.AxisX.Title = "Speed (counts/ms)"; + chartArea10.AxisY.Title = "Sensitivity (magnitude ratio)"; + chartArea10.Name = "ChartArea1"; + this.AccelerationChart.ChartAreas.Add(chartArea10); + legend10.Name = "Legend1"; + this.AccelerationChart.Legends.Add(legend10); + this.AccelerationChart.Location = new System.Drawing.Point(242, 0); this.AccelerationChart.Name = "AccelerationChart"; - series1.ChartArea = "ChartArea1"; - series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series1.Legend = "Legend1"; - series1.Name = "Accelerated Sensitivity"; - this.AccelerationChart.Series.Add(series1); - this.AccelerationChart.Size = new System.Drawing.Size(721, 312); + series10.ChartArea = "ChartArea1"; + series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series10.Legend = "Legend1"; + series10.Name = "Accelerated Sensitivity"; + this.AccelerationChart.Series.Add(series10); + this.AccelerationChart.Size = new System.Drawing.Size(721, 328); this.AccelerationChart.TabIndex = 0; this.AccelerationChart.Text = "chart1"; // // accelTypeDrop // this.accelTypeDrop.FormattingEnabled = true; - this.accelTypeDrop.Location = new System.Drawing.Point(14, 89); + this.accelTypeDrop.Location = new System.Drawing.Point(24, 98); this.accelTypeDrop.Name = "accelTypeDrop"; this.accelTypeDrop.Size = new System.Drawing.Size(151, 21); this.accelTypeDrop.TabIndex = 2; @@ -102,7 +106,7 @@ namespace grapher // // sensitivityBoxX // - this.sensitivityBoxX.Location = new System.Drawing.Point(95, 37); + this.sensitivityBoxX.Location = new System.Drawing.Point(105, 46); this.sensitivityBoxX.Name = "sensitivityBoxX"; this.sensitivityBoxX.Size = new System.Drawing.Size(32, 20); this.sensitivityBoxX.TabIndex = 3; @@ -110,7 +114,7 @@ namespace grapher // sensitivityLabel // this.sensitivityLabel.AutoSize = true; - this.sensitivityLabel.Location = new System.Drawing.Point(14, 40); + this.sensitivityLabel.Location = new System.Drawing.Point(24, 49); this.sensitivityLabel.Name = "sensitivityLabel"; this.sensitivityLabel.Size = new System.Drawing.Size(54, 13); this.sensitivityLabel.TabIndex = 4; @@ -118,7 +122,7 @@ namespace grapher // // rotationBox // - this.rotationBox.Location = new System.Drawing.Point(95, 63); + this.rotationBox.Location = new System.Drawing.Point(105, 72); this.rotationBox.Name = "rotationBox"; this.rotationBox.Size = new System.Drawing.Size(70, 20); this.rotationBox.TabIndex = 5; @@ -126,7 +130,7 @@ namespace grapher // rotationLabel // this.rotationLabel.AutoSize = true; - this.rotationLabel.Location = new System.Drawing.Point(24, 66); + this.rotationLabel.Location = new System.Drawing.Point(34, 75); this.rotationLabel.Name = "rotationLabel"; this.rotationLabel.Size = new System.Drawing.Size(47, 13); this.rotationLabel.TabIndex = 6; @@ -134,7 +138,7 @@ namespace grapher // // accelerationBox // - this.accelerationBox.Location = new System.Drawing.Point(96, 116); + this.accelerationBox.Location = new System.Drawing.Point(106, 125); this.accelerationBox.Name = "accelerationBox"; this.accelerationBox.Size = new System.Drawing.Size(70, 20); this.accelerationBox.TabIndex = 7; @@ -142,7 +146,7 @@ namespace grapher // constantOneLabel // this.constantOneLabel.AutoSize = true; - this.constantOneLabel.Location = new System.Drawing.Point(14, 119); + this.constantOneLabel.Location = new System.Drawing.Point(24, 128); this.constantOneLabel.Name = "constantOneLabel"; this.constantOneLabel.Size = new System.Drawing.Size(66, 13); this.constantOneLabel.TabIndex = 9; @@ -151,7 +155,7 @@ namespace grapher // // capBoxX // - this.capBoxX.Location = new System.Drawing.Point(95, 142); + this.capBoxX.Location = new System.Drawing.Point(105, 151); this.capBoxX.Name = "capBoxX"; this.capBoxX.Size = new System.Drawing.Size(32, 20); this.capBoxX.TabIndex = 10; @@ -159,7 +163,7 @@ namespace grapher // capLabel // this.capLabel.AutoSize = true; - this.capLabel.Location = new System.Drawing.Point(24, 146); + this.capLabel.Location = new System.Drawing.Point(34, 155); this.capLabel.Name = "capLabel"; this.capLabel.Size = new System.Drawing.Size(26, 13); this.capLabel.TabIndex = 11; @@ -168,7 +172,7 @@ namespace grapher // // weightBoxFirst // - this.weightBoxFirst.Location = new System.Drawing.Point(95, 168); + this.weightBoxFirst.Location = new System.Drawing.Point(105, 177); this.weightBoxFirst.Name = "weightBoxFirst"; this.weightBoxFirst.Size = new System.Drawing.Size(32, 20); this.weightBoxFirst.TabIndex = 12; @@ -176,7 +180,7 @@ namespace grapher // weightLabel // this.weightLabel.AutoSize = true; - this.weightLabel.Location = new System.Drawing.Point(24, 171); + this.weightLabel.Location = new System.Drawing.Point(34, 180); this.weightLabel.Name = "weightLabel"; this.weightLabel.Size = new System.Drawing.Size(41, 13); this.weightLabel.TabIndex = 13; @@ -185,14 +189,14 @@ namespace grapher // // weightBoxSecond // - this.weightBoxSecond.Location = new System.Drawing.Point(134, 168); + this.weightBoxSecond.Location = new System.Drawing.Point(144, 177); this.weightBoxSecond.Name = "weightBoxSecond"; this.weightBoxSecond.Size = new System.Drawing.Size(32, 20); this.weightBoxSecond.TabIndex = 14; // // limitBox // - this.limitBox.Location = new System.Drawing.Point(95, 220); + this.limitBox.Location = new System.Drawing.Point(105, 229); this.limitBox.Name = "limitBox"; this.limitBox.Size = new System.Drawing.Size(70, 20); this.limitBox.TabIndex = 15; @@ -200,7 +204,7 @@ namespace grapher // constantTwoLabel // this.constantTwoLabel.AutoSize = true; - this.constantTwoLabel.Location = new System.Drawing.Point(14, 223); + this.constantTwoLabel.Location = new System.Drawing.Point(24, 232); this.constantTwoLabel.Name = "constantTwoLabel"; this.constantTwoLabel.Size = new System.Drawing.Size(78, 13); this.constantTwoLabel.TabIndex = 16; @@ -209,7 +213,7 @@ namespace grapher // // midpointBox // - this.midpointBox.Location = new System.Drawing.Point(95, 246); + this.midpointBox.Location = new System.Drawing.Point(105, 255); this.midpointBox.Name = "midpointBox"; this.midpointBox.Size = new System.Drawing.Size(70, 20); this.midpointBox.TabIndex = 17; @@ -217,7 +221,7 @@ namespace grapher // constantThreeLabel // this.constantThreeLabel.AutoSize = true; - this.constantThreeLabel.Location = new System.Drawing.Point(21, 249); + this.constantThreeLabel.Location = new System.Drawing.Point(31, 258); this.constantThreeLabel.Name = "constantThreeLabel"; this.constantThreeLabel.Size = new System.Drawing.Size(47, 13); this.constantThreeLabel.TabIndex = 18; @@ -226,7 +230,7 @@ namespace grapher // // offsetBox // - this.offsetBox.Location = new System.Drawing.Point(95, 194); + this.offsetBox.Location = new System.Drawing.Point(105, 203); this.offsetBox.Name = "offsetBox"; this.offsetBox.Size = new System.Drawing.Size(70, 20); this.offsetBox.TabIndex = 19; @@ -234,7 +238,7 @@ namespace grapher // offsetLabel // this.offsetLabel.AutoSize = true; - this.offsetLabel.Location = new System.Drawing.Point(24, 197); + this.offsetLabel.Location = new System.Drawing.Point(34, 206); this.offsetLabel.Name = "offsetLabel"; this.offsetLabel.Size = new System.Drawing.Size(35, 13); this.offsetLabel.TabIndex = 20; @@ -243,7 +247,7 @@ namespace grapher // // writeButton // - this.writeButton.Location = new System.Drawing.Point(47, 272); + this.writeButton.Location = new System.Drawing.Point(57, 281); this.writeButton.Name = "writeButton"; this.writeButton.Size = new System.Drawing.Size(102, 23); this.writeButton.TabIndex = 21; @@ -253,14 +257,14 @@ namespace grapher // // sensitivityBoxY // - this.sensitivityBoxY.Location = new System.Drawing.Point(133, 37); + this.sensitivityBoxY.Location = new System.Drawing.Point(143, 46); this.sensitivityBoxY.Name = "sensitivityBoxY"; this.sensitivityBoxY.Size = new System.Drawing.Size(32, 20); this.sensitivityBoxY.TabIndex = 22; // // capBoxY // - this.capBoxY.Location = new System.Drawing.Point(135, 142); + this.capBoxY.Location = new System.Drawing.Point(145, 151); this.capBoxY.Name = "capBoxY"; this.capBoxY.Size = new System.Drawing.Size(31, 20); this.capBoxY.TabIndex = 23; @@ -270,7 +274,7 @@ namespace grapher this.sensXYLock.AutoSize = true; this.sensXYLock.Checked = true; this.sensXYLock.CheckState = System.Windows.Forms.CheckState.Checked; - this.sensXYLock.Location = new System.Drawing.Point(188, 40); + this.sensXYLock.Location = new System.Drawing.Point(198, 49); this.sensXYLock.Name = "sensXYLock"; this.sensXYLock.Size = new System.Drawing.Size(15, 14); this.sensXYLock.TabIndex = 24; @@ -281,7 +285,7 @@ namespace grapher this.capXYLock.AutoSize = true; this.capXYLock.Checked = true; this.capXYLock.CheckState = System.Windows.Forms.CheckState.Checked; - this.capXYLock.Location = new System.Drawing.Point(188, 145); + this.capXYLock.Location = new System.Drawing.Point(198, 154); this.capXYLock.Name = "capXYLock"; this.capXYLock.Size = new System.Drawing.Size(15, 14); this.capXYLock.TabIndex = 25; @@ -292,7 +296,7 @@ namespace grapher this.weightXYLock.AutoSize = true; this.weightXYLock.Checked = true; this.weightXYLock.CheckState = System.Windows.Forms.CheckState.Checked; - this.weightXYLock.Location = new System.Drawing.Point(188, 171); + this.weightXYLock.Location = new System.Drawing.Point(198, 180); this.weightXYLock.Name = "weightXYLock"; this.weightXYLock.Size = new System.Drawing.Size(15, 14); this.weightXYLock.TabIndex = 26; @@ -301,7 +305,7 @@ namespace grapher // LockXYLabel // this.LockXYLabel.AutoSize = true; - this.LockXYLabel.Location = new System.Drawing.Point(165, 21); + this.LockXYLabel.Location = new System.Drawing.Point(175, 30); this.LockXYLabel.Name = "LockXYLabel"; this.LockXYLabel.Size = new System.Drawing.Size(60, 13); this.LockXYLabel.TabIndex = 27; @@ -309,47 +313,74 @@ namespace grapher // // VelocityChart // - chartArea2.AxisX.Title = "Speed (count/ms)"; - chartArea2.AxisY.Title = "Output Speed (counts/ms)"; - chartArea2.Name = "ChartArea1"; - this.VelocityChart.ChartAreas.Add(chartArea2); - legend2.Name = "Legend1"; - this.VelocityChart.Legends.Add(legend2); - this.VelocityChart.Location = new System.Drawing.Point(242, 319); + chartArea11.AxisX.Title = "Speed (count/ms)"; + chartArea11.AxisY.Title = "Output Speed (counts/ms)"; + chartArea11.Name = "ChartArea1"; + this.VelocityChart.ChartAreas.Add(chartArea11); + legend11.Name = "Legend1"; + this.VelocityChart.Legends.Add(legend11); + this.VelocityChart.Location = new System.Drawing.Point(242, 334); this.VelocityChart.Name = "VelocityChart"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series2.Legend = "Legend1"; - series2.Name = "Mouse Velocity"; - this.VelocityChart.Series.Add(series2); - this.VelocityChart.Size = new System.Drawing.Size(721, 300); + series11.ChartArea = "ChartArea1"; + series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series11.Legend = "Legend1"; + series11.Name = "Mouse Velocity"; + this.VelocityChart.Series.Add(series11); + this.VelocityChart.Size = new System.Drawing.Size(721, 307); this.VelocityChart.TabIndex = 28; this.VelocityChart.Text = "chart1"; // // GainChart // - chartArea3.AxisX.Title = "Speed (counts/ms)"; - chartArea3.AxisY.Title = "Slope of Velocity Chart"; - chartArea3.Name = "ChartArea1"; - this.GainChart.ChartAreas.Add(chartArea3); - legend3.Name = "Legend1"; - this.GainChart.Legends.Add(legend3); - this.GainChart.Location = new System.Drawing.Point(242, 625); + chartArea12.AxisX.Title = "Speed (counts/ms)"; + chartArea12.AxisY.Title = "Slope of Velocity Chart"; + chartArea12.Name = "ChartArea1"; + this.GainChart.ChartAreas.Add(chartArea12); + legend12.Name = "Legend1"; + this.GainChart.Legends.Add(legend12); + this.GainChart.Location = new System.Drawing.Point(242, 647); this.GainChart.Name = "GainChart"; - series3.ChartArea = "ChartArea1"; - series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series3.Legend = "Legend1"; - series3.Name = "Velocity Gain"; - this.GainChart.Series.Add(series3); - this.GainChart.Size = new System.Drawing.Size(721, 300); + series12.ChartArea = "ChartArea1"; + series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + series12.Legend = "Legend1"; + series12.Name = "Velocity Gain"; + this.GainChart.Series.Add(series12); + this.GainChart.Size = new System.Drawing.Size(721, 309); this.GainChart.TabIndex = 29; this.GainChart.Text = "chart1"; // + // menuStrip1 + // + this.menuStrip1.BackColor = System.Drawing.SystemColors.ControlLight; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.graphsToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(963, 24); + this.menuStrip1.TabIndex = 30; + this.menuStrip1.Text = "menuStrip1"; + // + // graphsToolStripMenuItem + // + this.graphsToolStripMenuItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.graphsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.showVelocityGainToolStripMenuItem}); + this.graphsToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.graphsToolStripMenuItem.Name = "graphsToolStripMenuItem"; + this.graphsToolStripMenuItem.Size = new System.Drawing.Size(53, 20); + this.graphsToolStripMenuItem.Text = "Charts"; + // + // showVelocityGainToolStripMenuItem + // + this.showVelocityGainToolStripMenuItem.Name = "showVelocityGainToolStripMenuItem"; + this.showVelocityGainToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.showVelocityGainToolStripMenuItem.Text = "Show Velocity && Gain"; + // // RawAcceleration // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(963, 925); + this.ClientSize = new System.Drawing.Size(963, 955); this.Controls.Add(this.GainChart); this.Controls.Add(this.VelocityChart); this.Controls.Add(this.LockXYLabel); @@ -378,12 +409,15 @@ namespace grapher this.Controls.Add(this.sensitivityBoxX); this.Controls.Add(this.accelTypeDrop); this.Controls.Add(this.AccelerationChart); + this.Controls.Add(this.menuStrip1); this.Name = "RawAcceleration"; this.Text = "Raw Acceleration Graph"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.GainChart)).EndInit(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -419,6 +453,9 @@ namespace grapher private System.Windows.Forms.Label LockXYLabel; private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChart; private System.Windows.Forms.DataVisualization.Charting.Chart GainChart; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem graphsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showVelocityGainToolStripMenuItem; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index fb841e9..7fa6928 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -116,9 +116,12 @@ namespace grapher AccelGUI = new AccelGUI( this, - AccelerationChart, - VelocityChart, - GainChart, + new AccelCharts( + this, + AccelerationChart, + VelocityChart, + GainChart, + showVelocityGainToolStripMenuItem), managedAcceleration, accelerationOptions, sensitivity, diff --git a/grapher/Form1.resx b/grapher/Form1.resx index 1af7de1..32fcbfb 100644 --- a/grapher/Form1.resx +++ b/grapher/Form1.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 25 + \ No newline at end of file diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 4fe8f64..1611fd3 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -47,6 +47,7 @@ + -- cgit v1.2.3 From 4e63da9daa1a3869caef1ac6c45c598aaf5a4b6e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 3 Aug 2020 14:07:21 -0700 Subject: Start work on reading from driver --- grapher/AccelGUI.cs | 1 + grapher/Form1.cs | 1 - rawaccel.sln | 2 ++ wrapper/wrapper.cpp | 13 ++++++++++--- wrapper/wrapper.hpp | 10 ++++++---- wrapper/wrapper.vcxproj | 4 ++-- wrapper/wrapper.vcxproj.filters | 4 ++-- wrapper/wrapper_io.cpp | 15 +++++++++++++++ wrapper/wrapper_io.hpp | 8 ++++++++ wrapper/wrapper_writer.cpp | 9 --------- wrapper/wrapper_writer.hpp | 7 ------- 11 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 wrapper/wrapper_io.cpp create mode 100644 wrapper/wrapper_io.hpp delete mode 100644 wrapper/wrapper_writer.cpp delete mode 100644 wrapper/wrapper_writer.hpp diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index b8f1bed..8ef411f 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -49,6 +49,7 @@ namespace grapher LimitOrExponent = limtOrExp; Midpoint = midpoint; + ManagedAcceleration.ReadFromDriver(); UpdateGraph(); } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 7fa6928..4edb9e3 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -223,7 +223,6 @@ namespace grapher AccelGUI.Acceleration.Field.Data, AccelGUI.LimitOrExponent.Field.Data, AccelGUI.Midpoint.Field.Data); - AccelGUI.ManagedAcceleration.WriteToDriver(); AccelGUI.UpdateGraph(); } diff --git a/rawaccel.sln b/rawaccel.sln index 3325e47..33735fd 100644 --- a/rawaccel.sln +++ b/rawaccel.sln @@ -23,6 +23,8 @@ Global GlobalSection(SharedMSBuildProjectFiles) = preSolution common-install\common-install.vcxitems*{058d66c6-d88b-4fdb-b0e4-0a6fe7483b95}*SharedItemsImports = 9 common\common.vcxitems*{24b4226f-1461-408f-a1a4-1371c97153ea}*SharedItemsImports = 9 + common\common.vcxitems*{28a3656f-a1de-405c-b547-191c32ec555f}*SharedItemsImports = 4 + common\common.vcxitems*{60d6c942-ac20-4c05-a2be-54b5c966534d}*SharedItemsImports = 4 common-install\common-install.vcxitems*{896950d1-520a-420a-b6b1-73014b92a68c}*SharedItemsImports = 4 common-install\common-install.vcxitems*{a4097ff6-a6f0-44e8-b8d0-538d0fb75936}*SharedItemsImports = 4 common\common.vcxitems*{ab7b3759-b85f-4067-8935-fb4539b41869}*SharedItemsImports = 4 diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index bd0574f..38ac481 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -30,8 +30,6 @@ void ManagedAccel::UpdateAccel( double lim_exp, double midpoint) { - delete modifier_instance; - modifier_args args{}; args.acc_fn_args.accel_mode = mode; args.degrees = rotation; @@ -46,11 +44,20 @@ void ManagedAccel::UpdateAccel( args.acc_fn_args.acc_args.limit = lim_exp; args.acc_fn_args.acc_args.exponent = lim_exp; args.acc_fn_args.acc_args.midpoint = midpoint; + + mouse_modifier* temp_modifier = new mouse_modifier(args); + driverWriter->writeToDriver(temp_modifier); + delete temp_modifier; - modifier_instance = new mouse_modifier(args); + ReadFromDriver(); } void ManagedAccel::WriteToDriver() { driverWriter->writeToDriver(modifier_instance); } + +void ManagedAccel::ReadFromDriver() +{ + modifier_instance = driverWriter->readFromDriver(); +} diff --git a/wrapper/wrapper.hpp b/wrapper/wrapper.hpp index e8f100d..22a1b1e 100644 --- a/wrapper/wrapper.hpp +++ b/wrapper/wrapper.hpp @@ -5,7 +5,7 @@ #include #include -#include "wrapper_writer.hpp" +#include "wrapper_io.hpp" using namespace rawaccel; using namespace System; @@ -14,18 +14,18 @@ public ref class ManagedAccel { protected: mouse_modifier* modifier_instance; - writer* driverWriter; + wrapper_io* driverWriter; public: ManagedAccel(mouse_modifier* accel) : modifier_instance(accel) { - driverWriter = new writer(); + driverWriter = new wrapper_io(); } ManagedAccel(System::IntPtr args) { modifier_instance = new mouse_modifier(*reinterpret_cast(args.ToPointer())); - driverWriter = new writer(); + driverWriter = new wrapper_io(); } virtual ~ManagedAccel() @@ -66,4 +66,6 @@ public: void WriteToDriver(); + + void ReadFromDriver(); }; \ No newline at end of file diff --git a/wrapper/wrapper.vcxproj b/wrapper/wrapper.vcxproj index bffbf8b..3407d6d 100644 --- a/wrapper/wrapper.vcxproj +++ b/wrapper/wrapper.vcxproj @@ -117,11 +117,11 @@ - + - + diff --git a/wrapper/wrapper.vcxproj.filters b/wrapper/wrapper.vcxproj.filters index 28b22ba..60fcc9c 100644 --- a/wrapper/wrapper.vcxproj.filters +++ b/wrapper/wrapper.vcxproj.filters @@ -18,7 +18,7 @@ Header Files - + Header Files @@ -26,7 +26,7 @@ Source Files - + Source Files diff --git a/wrapper/wrapper_io.cpp b/wrapper/wrapper_io.cpp new file mode 100644 index 0000000..be3bd58 --- /dev/null +++ b/wrapper/wrapper_io.cpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "wrapper_io.hpp" + +void wrapper_io::writeToDriver(rawaccel::mouse_modifier* modifier) +{ + rawaccel::write(*modifier); +} + +rawaccel::mouse_modifier* wrapper_io::readFromDriver() +{ + rawaccel::mouse_modifier modifier = rawaccel::read(); + return &(modifier); +} diff --git a/wrapper/wrapper_io.hpp b/wrapper/wrapper_io.hpp new file mode 100644 index 0000000..3427e3f --- /dev/null +++ b/wrapper/wrapper_io.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include + +struct wrapper_io { + void writeToDriver(rawaccel::mouse_modifier* modifier); + rawaccel::mouse_modifier* readFromDriver(); +}; \ No newline at end of file diff --git a/wrapper/wrapper_writer.cpp b/wrapper/wrapper_writer.cpp deleted file mode 100644 index da7c9bf..0000000 --- a/wrapper/wrapper_writer.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include -#include "wrapper_writer.hpp" - -void writer::writeToDriver(rawaccel::mouse_modifier* modifier) -{ - rawaccel::write(*modifier); -} diff --git a/wrapper/wrapper_writer.hpp b/wrapper/wrapper_writer.hpp deleted file mode 100644 index dcbef10..0000000 --- a/wrapper/wrapper_writer.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -struct writer { - void writeToDriver(rawaccel::mouse_modifier* modifier); -}; \ No newline at end of file -- cgit v1.2.3 From 1777a3decf6acdb836580f2c7cfe055aaee94b3e Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 3 Aug 2020 19:12:04 -0700 Subject: Read from driver to get graph values --- wrapper/wrapper.cpp | 1 + wrapper/wrapper_io.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 38ac481..e29f08d 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -59,5 +59,6 @@ void ManagedAccel::WriteToDriver() void ManagedAccel::ReadFromDriver() { + delete modifier_instance; modifier_instance = driverWriter->readFromDriver(); } diff --git a/wrapper/wrapper_io.cpp b/wrapper/wrapper_io.cpp index be3bd58..4284d60 100644 --- a/wrapper/wrapper_io.cpp +++ b/wrapper/wrapper_io.cpp @@ -11,5 +11,8 @@ void wrapper_io::writeToDriver(rawaccel::mouse_modifier* modifier) rawaccel::mouse_modifier* wrapper_io::readFromDriver() { rawaccel::mouse_modifier modifier = rawaccel::read(); - return &(modifier); + rawaccel::mouse_modifier* mod_pnt = (rawaccel::mouse_modifier*)malloc(sizeof(rawaccel::mouse_modifier)); + memcpy(mod_pnt, &modifier, sizeof(rawaccel::mouse_modifier)); + + return mod_pnt; } -- cgit v1.2.3 From c0b8b46f84eda91d01ce2eead3777c31be96bd60 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 4 Aug 2020 15:08:48 -0700 Subject: Data rebind for faster graph update --- grapher/AccelGUI.cs | 53 +++++++++++++++++++++++++++-------------------------- grapher/Form1.cs | 3 ++- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index 8ef411f..85d2416 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -34,7 +34,8 @@ namespace grapher Option offset, Option acceleration, Option limtOrExp, - Option midpoint) + Option midpoint, + Button writeButton) { AccelForm = accelForm; AccelCharts = accelCharts; @@ -48,6 +49,12 @@ namespace grapher Acceleration = acceleration; LimitOrExponent = limtOrExp; Midpoint = midpoint; + WriteButton = writeButton; + + OrderedAccelPoints = new SortedDictionary(); + OrderedVelocityPoints = new SortedDictionary(); + OrderedGainPoints = new SortedDictionary(); + ManagedAcceleration.ReadFromDriver(); UpdateGraph(); @@ -83,6 +90,12 @@ namespace grapher public Button WriteButton { get; } + public SortedDictionary OrderedAccelPoints { get; } + + public SortedDictionary OrderedVelocityPoints { get; } + + public SortedDictionary OrderedGainPoints { get; } + #endregion properties #region methods @@ -119,9 +132,9 @@ namespace grapher public void UpdateGraph() { - var orderedAccelPoints = new SortedDictionary(); - var orderedVelocityPoints = new SortedDictionary(); - var orderedGainPoints = new SortedDictionary(); + OrderedAccelPoints.Clear(); + OrderedVelocityPoints.Clear(); + OrderedGainPoints.Clear(); double lastInputMagnitude = 0; double lastOutputMagnitude = 0; @@ -139,50 +152,38 @@ namespace grapher lastInputMagnitude = magnitudeData.magnitude; lastOutputMagnitude = outMagnitude; - if (!orderedAccelPoints.ContainsKey(magnitudeData.magnitude)) + if (!OrderedAccelPoints.ContainsKey(magnitudeData.magnitude)) { - orderedAccelPoints.Add(magnitudeData.magnitude, ratio); + OrderedAccelPoints.Add(magnitudeData.magnitude, ratio); } - if (!orderedVelocityPoints.ContainsKey(magnitudeData.magnitude)) + if (!OrderedVelocityPoints.ContainsKey(magnitudeData.magnitude)) { - orderedVelocityPoints.Add(magnitudeData.magnitude, outMagnitude); + OrderedVelocityPoints.Add(magnitudeData.magnitude, outMagnitude); } - if (!orderedGainPoints.ContainsKey(magnitudeData.magnitude)) + if (!OrderedGainPoints.ContainsKey(magnitudeData.magnitude)) { - orderedGainPoints.Add(magnitudeData.magnitude, slope); + OrderedGainPoints.Add(magnitudeData.magnitude, slope); } + } var accelSeries = AccelCharts.SensitivityChart.Series.FirstOrDefault(); accelSeries.Points.Clear(); - foreach (var point in orderedAccelPoints) - { - accelSeries.Points.AddXY(point.Key, point.Value); - } - var velSeries = AccelCharts.VelocityChart.Series.FirstOrDefault(); velSeries.Points.Clear(); - foreach (var point in orderedVelocityPoints) - { - velSeries.Points.AddXY(point.Key, point.Value); - } - var gainSeries = AccelCharts.GainChart.Series.FirstOrDefault(); gainSeries.Points.Clear(); - foreach (var point in orderedGainPoints) - { - gainSeries.Points.AddXY(point.Key, point.Value); - } + accelSeries.Points.DataBindXY(OrderedAccelPoints.Keys, OrderedAccelPoints.Values); + velSeries.Points.DataBindXY(OrderedVelocityPoints.Keys, OrderedVelocityPoints.Values); + gainSeries.Points.DataBindXY(OrderedGainPoints.Keys, OrderedGainPoints.Values); } - #endregion methods - } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 4edb9e3..237a25d 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -131,7 +131,8 @@ namespace grapher offset, acceleration, limitOrExponent, - midpoint); + midpoint, + writeButton); this.AccelerationChart.ChartAreas[0].AxisX.RoundAxisValues(); -- cgit v1.2.3 From 2ada822c137329005a31c7f49f9e4d9aa8eb51b2 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 4 Aug 2020 15:10:16 -0700 Subject: Remove unnecessary .clear() call --- grapher/AccelGUI.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index 85d2416..c701054 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -170,13 +170,8 @@ namespace grapher } var accelSeries = AccelCharts.SensitivityChart.Series.FirstOrDefault(); - accelSeries.Points.Clear(); - var velSeries = AccelCharts.VelocityChart.Series.FirstOrDefault(); - velSeries.Points.Clear(); - var gainSeries = AccelCharts.GainChart.Series.FirstOrDefault(); - gainSeries.Points.Clear(); accelSeries.Points.DataBindXY(OrderedAccelPoints.Keys, OrderedAccelPoints.Values); velSeries.Points.DataBindXY(OrderedVelocityPoints.Keys, OrderedVelocityPoints.Values); -- cgit v1.2.3 From f27ee9d9d7f9adad6dc55e964421277a4a2262d8 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 4 Aug 2020 15:16:45 -0700 Subject: Even nicer --- grapher/AccelGUI.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/grapher/AccelGUI.cs b/grapher/AccelGUI.cs index c701054..c660afe 100644 --- a/grapher/AccelGUI.cs +++ b/grapher/AccelGUI.cs @@ -169,13 +169,9 @@ namespace grapher } - var accelSeries = AccelCharts.SensitivityChart.Series.FirstOrDefault(); - var velSeries = AccelCharts.VelocityChart.Series.FirstOrDefault(); - var gainSeries = AccelCharts.GainChart.Series.FirstOrDefault(); - - accelSeries.Points.DataBindXY(OrderedAccelPoints.Keys, OrderedAccelPoints.Values); - velSeries.Points.DataBindXY(OrderedVelocityPoints.Keys, OrderedVelocityPoints.Values); - gainSeries.Points.DataBindXY(OrderedGainPoints.Keys, OrderedGainPoints.Values); + AccelCharts.SensitivityChart.Series[0].Points.DataBindXY(OrderedAccelPoints.Keys, OrderedAccelPoints.Values); + AccelCharts.VelocityChart.Series[0].Points.DataBindXY(OrderedVelocityPoints.Keys, OrderedVelocityPoints.Values); + AccelCharts.GainChart.Series[0].Points.DataBindXY(OrderedGainPoints.Keys, OrderedGainPoints.Values); } #endregion methods -- cgit v1.2.3